xiongchao 3 tahun lalu
induk
melakukan
190f8629c8

+ 2 - 0
src/utils/dict.js

@@ -79,6 +79,8 @@ DictCache.TYPE = {
   SBTYPE_SOURCETYPE: 'SBTYPE_SOURCETYPE', // 设备来源方式
   SBINFO_UNIT: 'SBINFO_UNIT', // 计量单位
   SB_USE_TYPE: 'SB_USE_TYPE', // 自定义类型
+  SB_IS_CHILD: 'SB_IS_CHILD', // 自定义类型
+  SB_IS_SHOW: 'SB_IS_SHOW', // 自定义类型
   PRODUCER_AREA: 'PRODUCER_AREA', // 产地
   PART_LEVEL: 'PART_LEVEL', // 部件等级
   PART_STATUS: 'PART_STATUS', // 部件状态

+ 14 - 5
src/views/sb/info/SbInfo.vue

@@ -78,6 +78,10 @@
               <a-icon type="upload"/>
               新增导入
             </a-button>
+            <a-button style="margin-left:8px;" type="primary" @click="doImportForUpdate">
+              <a-icon type="upload"/>
+              修改导入
+            </a-button>
             <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="print" @click="printQcode()">打印</a-button>
             <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
               <a-menu slot="overlay">
@@ -156,6 +160,7 @@
     <download-modal ref="downloadModal"/>
     <preview-modal ref="previewModal"/>
     <import-form-add ref="importModal" @ok="handleOk"/>
+    <import-form-update ref="importModalUpdate" @ok="handleOk"/>
     <print-sb-code ref="printSbCode"/>
   </a-card>
 
@@ -171,6 +176,7 @@ import { updateSbInfo, getSbInfoPage, deleteSbInfos, fetchSbInfo, exportSbInfo }
 import { queryDept } from '@/api/upms/dept'
 import { fetchSbTypeTree } from '@/api/sb/type'
 import ImportFormAdd from './modules/ImportFormAdd'
+import ImportFormUpdate from './modules/ImportFormUpdate'
 import PrintSbCode from '@/views/sb/info/modules/PrintSbCode'
 
 export default {
@@ -183,7 +189,8 @@ export default {
     DownloadModal,
     PreviewModal,
     PrintSbCode,
-    ImportFormAdd
+    ImportFormAdd,
+    ImportFormUpdate
   },
   props: {
     filter: {
@@ -209,6 +216,8 @@ export default {
       areaList: {},
       companyList: {},
       projectList: {},
+      isChildMap: {},
+      isShowMap: {},
       deptList: {},
       useTypeMap: {},
       statusMap: {},
@@ -372,6 +381,8 @@ export default {
     this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
     this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
     this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
+    this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
+    this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
   },
   methods: {
     tableOption () {
@@ -534,10 +545,8 @@ export default {
     doImport () {
       this.$refs.importModal.base(null, null)
     },
-    doImportDe () {
-      this.queryParam.useCompany = null
-      this.queryParam.useProject = null
-      this.$refs.importModal.base()
+    doImportForUpdate () {
+      this.$refs.importModalUpdate.base(null, null)
     }
   }
 }

+ 18 - 7
src/views/sb/info/modules/BaseForm.vue

@@ -237,10 +237,13 @@
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
-            <a-select @change="childChange" v-decorator="['isChild']" placeholder="请选择">
-              <a-select-option value="1">子设备</a-select-option>
-              <a-select-option value="2">父设备</a-select-option>
-              <a-select-option value="3">普通设备</a-select-option>
+            <a-select @change="childChange" v-decorator="['isChild', {initialValue:3, rules: [{required: true, message: '是否子设备不能为空'}]}]" placeholder="请选择">
+              <a-select-option
+                v-for="(label,value) in isChildMap"
+                :key="value"
+                :label="label"
+                :value="parseInt(value)">{{ label }}
+              </a-select-option>
             </a-select>
           </a-form-item>
         </a-col>
@@ -264,9 +267,13 @@
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
-            <a-select v-decorator="['isShow']" placeholder="请选择">
-              <a-select-option value="0">不显示</a-select-option>
-              <a-select-option value="1">显示</a-select-option>
+            <a-select @change="isShow" v-decorator="['isChild', {initialValue:0, rules: [{required: true, message: '是否显示不能为空'}]}]" placeholder="请选择">
+              <a-select-option
+                v-for="(label,value) in isShowMap"
+                :key="value"
+                :label="label"
+                :value="parseInt(value)">{{ label }}
+              </a-select-option>
             </a-select>
           </a-form-item>
         </a-col>
@@ -845,6 +852,8 @@ export default {
       colorMap: {},
       useTypeMap: {},
       statusMap: {},
+      isChildMap: {},
+      isShowMap: {},
       userList: {},
       unitMap: {},
       sbInfoSelectType: null,
@@ -880,6 +889,8 @@ export default {
     this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
     this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
     this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
+    this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
+    this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
   },
   methods: {
     base (record, type) {

+ 4 - 0
src/views/sb/info/modules/Detail.vue

@@ -197,6 +197,8 @@ export default {
       visible: false,
       visibleDetail: false,
       activeKey: '3',
+      isChildMap: {},
+      isShowMap: {},
       collapseActiveKey: '1',
       model: {
         'no': null,
@@ -302,6 +304,8 @@ export default {
     this.rlTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.RANLIAO_TYPE)
     this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
     this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
+    this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
+    this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
   },
   computed: {
   },

+ 1 - 2
src/views/sb/info/modules/ImportFormAdd.vue

@@ -21,7 +21,6 @@
       1:请确保设备新号、名称、型号的准确填写<br/>
       2:请确保数据都未导入,重新导入成功不会覆盖原有数据,导致存在多台同样设备<br/>
       3:导入如出现问题,请及时联系<br/>
-      4:如果导入折旧,请确保设备新号必须填写<br/>
     </p>
     <template slot="footer">
       <a-button :loading="confirmLoading" type="primary" @click="save()">确定</a-button>
@@ -51,7 +50,7 @@ export default {
       this.visible = true
       this.useCompany = useCompany
       this.useProject = useProject
-      this.modalTitle = '设备导入'
+      this.modalTitle = '设备新增导入'
       this.type = 1
     },
     handleRemove (file) {

+ 118 - 0
src/views/sb/info/modules/ImportFormUpdate.vue

@@ -0,0 +1,118 @@
+<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 { importSbInfo } 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, 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])
+        importSbInfo(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>