hfxc226 il y a 3 ans
Parent
commit
7d1a095317

+ 18 - 0
src/api/check/checkjob.js

@@ -237,3 +237,21 @@ export function finishJobBatch (parameter) {
     data: parameter
   })
 }
+
+/**
+ * add batch func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function importCheckJobForUpdate (parameter) {
+  return axios({
+    url: '/check/jobs/import/update',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}

+ 10 - 0
src/views/check/checkjob/CheckJob.vue

@@ -114,6 +114,10 @@
       <div class="table-operator">
         <a-button v-if="$auth('check-polling-jobs-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
         <a-button style="margin-left: 8px" v-if="($auth('check-spot-jobs-export') || $auth('check-polling-jobs-export'))" type="primary" icon="download" @click="doExport">导出</a-button>
+        <a-button style="margin-left:8px;" type="primary" @click="doImportForUpdate">
+          <a-icon type="upload"/>
+          修改导入
+        </a-button>
         <a-button style="margin-left: 8px" type="success" @click="handleSeven">本周</a-button>
         <a-button style="margin-left: 8px" type="success" @click="handleMonth">本月</a-button>
         <a-button style="margin-left: 8px" type="success" @click="handleTuiCalendar">日历图</a-button>
@@ -182,6 +186,7 @@
     </div>
     <base-form :check-type="checkType" ref="baseModal" @ok="handleOk"/>
     <detail :check-type="checkType" ref="detailModal" @ok="handleOk"/>
+    <import-form-update ref="importModalUpdate" @ok="handleOk"/>
   </a-card>
 </template>
 
@@ -192,6 +197,7 @@ import Detail from './modules/Detail'
 import { getCheckJobPage, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJob, executeJobBatch, finishJobBatch, queryTuiCalendarIgnores } from '@/api/check/checkjob'
 import { fetchSbTypeTree } from '@/api/sb/type'
 import DictCache from '@/utils/dict'
+import ImportFormUpdate from './modules/ImportFormUpdate'
 
 export default {
   name: 'CheckJobList',
@@ -199,6 +205,7 @@ export default {
     STable,
     Ellipsis,
     BaseForm,
+    ImportFormUpdate,
     Detail
   },
   props: {
@@ -626,6 +633,9 @@ export default {
       exportCheckJob(parameter).then(file => {
         this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
+    },
+    doImportForUpdate () {
+      this.$refs.importModalUpdate.base(null, null)
     }
   }
 }

+ 113 - 0
src/views/check/checkjob/modules/ImportFormUpdate.vue

@@ -0,0 +1,113 @@
+<template>
+  <a-modal
+    :title="modalTitle"
+    :width="640"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @cancel="handleCancel"
+  >
+    <a-form :form="form">
+      <a-form-item
+        label="上传文件"
+        :labelCol="BaseTool.Constant.labelCol"
+        :wrapperCol="BaseTool.Constant.wrapperCol"
+      >
+        <a-upload :fileList="fileList" @change="handleChange" :remove="handleRemove" :beforeUpload="beforeUpload">
+          <a-button> <a-icon type="upload" />选择上传文件</a-button>
+        </a-upload>
+      </a-form-item>
+    </a-form>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="save()">确定</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import { importCheckJobForUpdate } from '@/api/check/checkjob'
+
+export default {
+  name: 'CheckJobImportForm',
+  data () {
+    return {
+      confirmLoading: false,
+      modalTitle: null,
+      form: this.$form.createForm(this),
+      visible: false,
+      useCompany: null,
+      useProject: null,
+      type: null,
+      fileList: []
+    }
+  },
+  methods: {
+    base (useCompany, useProject) {
+      this.visible = true
+      this.useCompany = useCompany
+      this.useProject = useProject
+      this.modalTitle = '设备修改导入'
+      this.type = 2
+    },
+    handleRemove (file) {
+      const index = this.fileList.indexOf(file)
+      const newFileList = this.fileList.slice()
+      newFileList.splice(index, 1)
+      this.fileList = newFileList
+    },
+    beforeUpload (file) {
+      const reg = /\.(xls|xlsx)(\?.*)?$/
+      return new Promise((resolve, reject) => {
+        if (reg.test(file.name)) {
+          this.fileList = [file]
+          return false
+        } else {
+          this.$message.error(`请上传正确的excel文件`)
+          reject(new Error('请上传正确的excel文件'))
+          return false
+        }
+      })
+    },
+    handleChange (info) {
+      if (info.file.status !== 'uploading') {
+        console.log(info.file, info.fileList)
+      }
+      if (info.file.status === 'done') {
+        this.$message.success(`${info.file.name} file uploaded successfully`)
+      } else if (info.file.status === 'error') {
+        this.$message.error(`${info.file.name} file upload failed.`)
+      }
+    },
+    save () {
+      const { form: { validateFieldsAndScroll } } = this
+      this.confirmLoading = true
+      validateFieldsAndScroll((errors, values) => {
+        if (errors) {
+          this.confirmLoading = false
+          return
+        }
+        const formData = new FormData()
+        formData.append('type', this.type)
+        formData.append('file', this.fileList[0])
+        importCheckJobForUpdate(formData)
+          .then((res) => {
+            this.$message.success(res.data)
+            this.handleCancel(values)
+            this.BaseTool.ListForm.clearOneList(this)
+            this.BaseTool.ListForm.pushOneListAddMore(this, res.data)
+          }).catch(() => {
+            this.confirmLoading = false
+          })
+      })
+    },
+    handleCancel (values) {
+      this.visible = false
+      this.confirmLoading = false
+      this.fileList = []
+      this.form.resetFields()
+      this.storeId = null
+      this.$emit('ok', values)
+    }
+
+  }
+}
+</script>