vor 1 Jahr
Ursprung
Commit
346a35a0ce

+ 11 - 0
src/api/sb/info.js

@@ -369,6 +369,17 @@ export function deleteSbInfo (parameter) {
  * @returns {*}
  */
 export function exportSbInfo (parameter) {
+  return axios({
+    url: '/sb/infos/export?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    responseType: 'blob'
+  })
+}
+
+export function exportSbInfo2 (parameter) {
   return axios({
     url: '/sb/infos/export2?' + stringify(parameter),
     method: 'get',

+ 7 - 7
src/views/sb/info/SbInfoC.vue

@@ -295,7 +295,7 @@
     <preview-modal ref="previewModal"/>
     <import-form-add ref="importModal" @ok="handleOk"/>
     <import-form-add-standard ref="importModalStandard" @ok="handleOk"/>
-    <import-form-update ref="importModalUpdate" @ok="handleOk"/>
+    <import-form-update2 ref="importModalUpdate2" @ok="handleOk"/>
     <print-sb-code ref="printSbCode"/>
     <print-in-sb-info-batch ref="printInSbInfoBatch" @ok="handleOk"/>
     <detail-sb-measure ref="detailSbMeasureModal" @ok="handleOk"/>
@@ -319,13 +319,13 @@ import BaseFormMeasureInStore from './modules/BaseFormMeasureInStore'
 import BaseFormLocation from './modules/BaseFormLocation'
 import DownloadModal from '@/views/download/DownloadModal'
 import PreviewModal from '@/views/preview/PreviewModal'
-import { getSbInfoPage, deleteSbInfos, querySbInfo, getLogBySbId, updateLogBySbId, fetchSbInfo, fetchSbInfos, exportSbInfo, batchLocationList } from '@/api/sb/info'
+import { getSbInfoPage, deleteSbInfos, querySbInfo, getLogBySbId, updateLogBySbId, fetchSbInfo, fetchSbInfos, exportSbInfo2, batchLocationList } from '@/api/sb/info'
 import { queryDept } from '@/api/upms/dept'
 import { generateSbCodeAll } from '@/api/upms/code'
 import { fetchSbTypeTree } from '@/api/sb/type'
 import ImportFormAdd from './modules/ImportFormAdd'
 import ImportFormAddStandard from './modules/ImportFormAddStandard'
-import ImportFormUpdate from './modules/ImportFormUpdate'
+import ImportFormUpdate2 from './modules/ImportFormUpdate2'
 import PrintSbCode from '@/views/sb/info/modules/PrintSbCode'
 import PrintInSbInfoBatch from '@/views/sb/info/modules/PrintInSbInfoBatch'
 import { querySbPosition } from '@/api/sb/position'
@@ -344,7 +344,7 @@ export default {
     PrintSbCode,
     ImportFormAdd,
     ImportFormAddStandard,
-    ImportFormUpdate,
+    ImportFormUpdate2,
     PrintInSbInfoBatch,
     BaseFormMeasure,
     BaseFormMeasureInStore,
@@ -973,7 +973,7 @@ export default {
         }
       }
       console.log(parameter)
-      exportSbInfo(parameter).then(file => {
+      exportSbInfo2(parameter).then(file => {
         this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
     },
@@ -1012,10 +1012,10 @@ export default {
     },
     doImportStandard () {
       // this.$refs.importModalStandard.base()
-      this.$refs.importModalUpdate.base(null, 1)
+      this.$refs.importModalUpdate2.base(null, 1)
     },
     doImportForUpdate () {
-      this.$refs.importModalUpdate.base(null, 2)
+      this.$refs.importModalUpdate2.base(null, 2)
     },
     rowClassName (record, index) {
       if (record.measureStatus === 1 && record.status !== 7) return 'orange'

+ 2 - 2
src/views/sb/info/modules/ImportFormUpdate.vue

@@ -29,7 +29,7 @@
 </template>
 
 <script>
-import { importSbInfo2 } from '@/api/sb/info'
+import { importSbInfo } from '@/api/sb/info'
 
 export default {
   name: 'SbModelBomImportForm',
@@ -96,7 +96,7 @@ export default {
         const formData = new FormData()
         formData.append('type', this.type)
         formData.append('file', this.fileList[0])
-        importSbInfo2(formData)
+        importSbInfo(formData)
           .then((res) => {
             this.$message.success(res.data)
             this.handleCancel(values)

+ 121 - 0
src/views/sb/info/modules/ImportFormUpdate2.vue

@@ -0,0 +1,121 @@
+<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>
+    <p style="color: red">注意事项:<br/>
+      1:请确保设备编号、名称、型号的准确填写<br/>
+      2:请确保文件从系统中导出,并未修改格式,重新导入成功的数据将覆盖原有数据的属性<br/>
+      3:导入如出现问题,请及时联系<br/>
+    </p>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="save()">确定</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import { importSbInfo2 } from '@/api/sb/info'
+
+export default {
+  name: 'SbModelBomImportForm',
+  data () {
+    return {
+      confirmLoading: false,
+      modalTitle: null,
+      form: this.$form.createForm(this),
+      visible: false,
+      useCompany: null,
+      useProject: null,
+      type: null,
+      fileList: []
+    }
+  },
+  methods: {
+    base (useCompany, type) {
+      this.visible = true
+      this.useCompany = useCompany
+      if (type === 1) {
+        this.modalTitle = '设备新增导入'
+      } else {
+        this.modalTitle = '设备修改导入'
+      }
+      this.type = type
+    },
+    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])
+        importSbInfo2(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>