Преглед изворни кода

设备分组改为岗位/分组;导入功能同时兼容新旧模板

luoaoxuan пре 1 година
родитељ
комит
2f2609101a
2 измењених фајлова са 22 додато и 11 уклоњено
  1. 1 1
      src/views/component/device/deviceDialog.vue
  2. 21 10
      src/views/component/device/index.vue

+ 1 - 1
src/views/component/device/deviceDialog.vue

@@ -472,7 +472,7 @@
                                                 </el-row>
                                                 <el-row>
                                                     <el-col>
-                                                        <el-form-item label="设备分组:">
+                                                        <el-form-item label="岗位/分组:">
                                                             <ibps-custom-dialog
                                                                 v-model="form.weiHuFangShi"
                                                                 size="mini"

+ 21 - 10
src/views/component/device/index.vue

@@ -473,7 +473,7 @@ export default {
                     { key: 'customPrint', label: '打印标签', icon: 'ibps-icon-cog', type: 'warning' },
                     { key: 'customExport', label: '导出数据', icon: 'ibps-icon-sign-in', type: 'primary' },
                     { key: 'customImport', label: '导入数据', icon: 'ibps-icon-sign-in', type: 'primary' },
-                    { key: 'customSetting', label: '设置分组配置', icon: 'ibps-icon-cogs', type: 'info' },
+                    { key: 'customSetting', label: '岗位/分组配置', icon: 'ibps-icon-cogs', type: 'info' },
                     { key: 'customRemove', label: '删除', icon: 'ibps-icon-close', type: 'danger', hidden: () => { return !this.hasRole } }
                 ],
                 // 查询条件
@@ -488,7 +488,7 @@ export default {
                         { prop: '', label: '设备状态', fieldType: 'slot', slotName: 'deviceStatus' },
                         { prop: '', label: '放置地点', fieldType: 'slot', slotName: 'place' },
                         { prop: '', label: '管理人', fieldType: 'slot', slotName: 'managePeople' },
-                        { prop: '', label: '设备分组', fieldType: 'slot', slotName: 'deviceClass' }
+                        { prop: '', label: '岗位/分组', fieldType: 'slot', slotName: 'deviceClass' }
 
                     ]
                 },
@@ -504,7 +504,7 @@ export default {
                     { prop: 'guiGeXingHao', label: '规格型号', sortable: true },
                     { prop: 'sheBeiZhuangTa', label: '设备状态', sortable: true, slotName: 'deviceStateSlot' },
                     { prop: 'guanLiRen', label: '保管人', slotName: 'userSlot', sortable: true },
-                    { prop: 'weiHuFangShi', label: '设备分组', slotName: 'deviceSlot', sortable: true },
+                    { prop: 'weiHuFangShi', label: '岗位/分组', slotName: 'deviceSlot', sortable: true },
                     { prop: 'cunFangWeiZhi', label: '放置地点', slotName: 'placeSlot', sortable: true },
                     { prop: '', label: '操作', width: 130, slotName: 'customButton' }
                 ]
@@ -524,7 +524,7 @@ export default {
                 sheBeiLeiXing: '设备类型(检验系统/通用设备/软件/信息系统)',
                 shiFouWeiHu: '是否维护(是/否)',
                 shiFouXiaoZhun: '是否校准(是/否)',
-                weiHuFangShi: '设备分组',
+                weiHuFangShi: '岗位/分组',
                 guiGeXingHao: '规格型号',
                 cunFangDiDian: '存放地点(格式:房间号+空格+房间名)',
                 guanLiRen: '保管人',
@@ -749,7 +749,7 @@ export default {
                 })
                 parameters.parameters.push(obj)
             }
-            // 设备分组搜索(可多选)
+            // 岗位/分组搜索(可多选)
             if (this.search.deviceClass) {
                 const obj = { relation: 'OR', parameters: [] }
                 this.search.deviceClass.split(',').forEach(item => {
@@ -992,7 +992,7 @@ export default {
             }
         },
         async switchExportData (data) {
-            const deviceGroupSql = `select id_,wei_hu_gang_wei_ from t_sbwhgwpzb` // 设备分组信息
+            const deviceGroupSql = `select id_,wei_hu_gang_wei_ from t_sbwhgwpzb` // 岗位/分组信息
             const supplierSql = `select id_,gong_ying_shang_m from t_gysxxb` // 供应商信息
             const { variables: { data: deviceGroupData }} = await this.$common.request('sql', deviceGroupSql)
             const { variables: { data: gysData }} = await this.$common.request('sql', supplierSql)
@@ -1010,7 +1010,7 @@ export default {
             }
             return exportData
         },
-        // 设备分组id 转 设备分组名称
+        // 岗位/分组id 转 岗位/分组名称
         switchDeviceIdToName (val, deviceGroupList) {
             const result = []
             const valList = val?.split(',') || []
@@ -1433,7 +1433,7 @@ export default {
             const workBook = xlsx.read(dataBinary, { type: 'binary', cellDates: true })
             const workSheet = workBook.Sheets[workBook.SheetNames[0]]
             const data = xlsx.utils.sheet_to_json(workSheet)
-            let importData = this.switchDeviceObj(data, this.deviceColumns)
+            let importData = this.switchDeviceObj(data, { ...this.deviceColumns, t: '设备分组' }) // 这个t用于兼容老版本的模板
             importData.forEach(i => {
                 delete i.sheBeiShiBieH // 设备编号需自动生成
                 // i.sheBeiZhuangTa = '合格'
@@ -1442,11 +1442,22 @@ export default {
                     i.sheBeiZhuangTa = keyFound[0]
                 }
             })
+            const isNewVersion = importData.some(i => i.weiHuFangShi) // 判断是否是最新模板
+            if (isNewVersion) { // 使用岗位/分组
+                importData.forEach(i => {
+                    delete i.t
+                })
+            } else { // 使用设备分组
+                importData.forEach(i => {
+                    i.weiHuFangShi = i.t
+                    delete i.t
+                })
+            }
             const currentPosition = this.level
             const { userList = [], deptList = [] } = this.$store.getters || {}
             const positionSql = `select id_,fang_jian_ming_ha from t_jjqfjb where di_dian_ = ${currentPosition}` // 房间信息
             const supplierSql = `select id_,gong_ying_shang_m from t_gysxxb where di_dian_ = ${currentPosition}` // 供应商信息
-            const deviceGroupSql = `select id_,suo_shu_bu_men_,wei_hu_gang_wei_ from t_sbwhgwpzb where di_dian_ =  ${currentPosition}` // 设备分组信息
+            const deviceGroupSql = `select id_,suo_shu_bu_men_,wei_hu_gang_wei_ from t_sbwhgwpzb where di_dian_ =  ${currentPosition}` // 岗位/分组信息
             const currentTime = dayjs().format('YYYY-MM-DD HH:mm')
             const currentApartment = this.$store.getters.userInfo.employee.positions
             const currentUser = this.userId
@@ -1596,7 +1607,7 @@ export default {
             const { userList = [], deptList = [] } = this.$store.getters || {}
             const positionSql = `select id_,fang_jian_ming_ha from t_jjqfjb where di_dian_ = ${currentPosition}` // 房间信息
             const supplierSql = `select id_,gong_ying_shang_m from t_gysxxb where di_dian_ = ${currentPosition}` // 供应商信息
-            const deviceGroupSql = `select id_,suo_shu_bu_men_,wei_hu_gang_wei_ from t_sbwhgwpzb where di_dian_ =  ${currentPosition}` // 设备分组信息
+            const deviceGroupSql = `select id_,suo_shu_bu_men_,wei_hu_gang_wei_ from t_sbwhgwpzb where di_dian_ =  ${currentPosition}` // 岗位/分组信息
             const currentTime = dayjs().format('YYYY-MM-DD HH:mm')
             const currentApartment = this.$store.getters.userInfo.employee.positions
             const currentUser = this.userId