Jelajahi Sumber

update:设施环境配置页重构

luoaoxuan 1 tahun lalu
induk
melakukan
c5726b0fc9
2 mengubah file dengan 291 tambahan dan 400 penghapusan
  1. 125 242
      src/views/system/fasc/facilityEnvConfig.vue
  2. 166 158
      src/views/system/fasc/fecDialog.vue

+ 125 - 242
src/views/system/fasc/facilityEnvConfig.vue

@@ -168,30 +168,18 @@
                             </el-col>
                         </el-row>
                         <el-row>
-                            <el-col :span="12">
-                                <el-form-item v-if="labelText.label1" :label="labelText.label1">
-                                    <el-input-number v-model="form.temperatureMin" size="mini" controls-position="right" :min="-100" :max="form.temperatureMax" :step="1" />
-                                    至
-                                    <el-input-number v-model="form.temperatureMax" size="mini" controls-position="right" :min="form.temperatureMin" :max="100" :step="1" />
-                                    (℃)
-                                </el-form-item>
-                            </el-col>
-                            <el-col :span="12">
-                                <el-form-item v-if="labelText.label2" :label="labelText.label2">
-                                    <el-input-number v-model="form.humidityMin" size="mini" controls-position="right" :min="-100" :max="form.humidityMax" :step="1" />
-                                    至
-                                    <el-input-number v-model="form.humidityMax" size="mini" controls-position="right" :min="form.humidityMin" :max="100" :step="1" />
-                                    (℃)
-                                </el-form-item>
+                            <el-col :span="24">
+                                <FacilityData v-if="form.lie_biao_shu_ju_" :form-data="{lieBiaoShuJu:form.lie_biao_shu_ju_}" :is-cul="false" @change-data="onFacilityData" />
                             </el-col>
+
                         </el-row>
                     </el-form>
                 </div>
                 <!-- <el-divider /> -->
                 <div class="table">
                     <div class="hearder">
-                        <div class="search" :style="isEdit?{}:{justifyContent: 'flex-end'}">
-                            <div v-if="isEdit" class="search-item">
+                        <div class="search">
+                            <div class="search-item">
                                 <span>部门:</span>
                                 <ibps-user-selector
                                     v-model="search.buMen"
@@ -203,15 +191,15 @@
                                     size="mini"
                                 />
                             </div>
-                            <div v-if="isEdit" class="search-item">
+                            <div class="search-item">
                                 <span>区域:</span>
                                 <el-input v-model="search.quYu" size="mini" style="width:100%" placeholder="请输入" />
                             </div>
-                            <div v-if="isEdit" class="search-item">
+                            <div class="search-item">
                                 <span>房间:</span>
                                 <el-input v-model="search.fangJian" size="mini" style="width:100%" placeholder="请输入" />
                             </div>
-                            <div v-if="isEdit" class="search-item">
+                            <div class="search-item">
                                 <span>监测周期:</span>
                                 <el-select v-model="search.zhouQi" placeholder="请选择" size="mini" style="width:66%" :clearable="true">
                                     <el-option
@@ -222,7 +210,7 @@
                                     />
                                 </el-select>
                             </div>
-                            <div v-if="isEdit" class="search-item">
+                            <div class="search-item">
                                 <span>监测岗位:</span>
                                 <el-select v-model="search.gangWei" placeholder="请选择" size="mini" style="width:66%" :clearable="true">
                                     <el-option
@@ -233,7 +221,7 @@
                                     />
                                 </el-select>
                             </div>
-                            <div v-if="isEdit" class="search-item" style="width:60px">
+                            <div class="search-item" style="width:60px">
                                 <el-button size="mini" type="primary" icon="el-icon-search" @click="goSearch">查询</el-button>
                             </div>
                             <div class="search-item" style="width:60px">
@@ -255,9 +243,6 @@
                             <div class="search-item" style="width:60px">
                                 <el-button type="primary" size="mini" icon="el-icon-download" @click="exportExcel">导出</el-button>
                             </div>
-                            <div v-if="trueList.length>0" class="search-item" style="width:110px">
-                                <el-button type="info" size="mini" icon="el-icon-setting" @click="settingData">使用默认数据</el-button>
-                            </div>
                             <div class="search-item" style="width:60px">
                                 <el-button type="danger" size="mini" icon="el-icon-delete" @click="removeItem">删除</el-button>
                             </div>
@@ -364,20 +349,20 @@
             </div>
 
         </div>
-        <FecDialog ref="FecDialogRef" @onSubmit="sonSubmit" />
+        <FecDialog v-if="subDialogVisible" ref="FecDialogRef" @onSubmit="sonSubmit" @onClose="sonClose" />
     </el-dialog>
 </template>
 
 <script>
-import IbpsAttachment from '@/business/platform/file/attachment/selector'
 import ibpsUserSelector from '@/business/platform/org/selector'
 import xlsx from 'xlsx'
 import fs from 'file-saver'
 import FecDialog from './fecDialog.vue'
+import FacilityData from '@/views/component/facility/facilityData.vue'
 export default {
     components: {
+        FacilityData,
         ibpsUserSelector,
-        IbpsAttachment,
         FecDialog,
         IbpsCustomDialog: () => import('@/business/platform/data/templaterender/custom-dialog')
     },
@@ -392,7 +377,7 @@ export default {
         }
     },
     data () {
-        const { userId, level = {}} = this.$store.getters || {}
+        const { userId, level = {}, position } = this.$store.getters || {}
         return {
             search: {
                 buMen: '',
@@ -416,6 +401,7 @@ export default {
             },
             jianCeGangWeiList: [],
             dialogVisible: true,
+            subDialogVisible: false,
             title: '设施环境配置表',
             toolbars: [{ key: 'save', label: '保存' }, { key: 'cancel', label: '退出', type: 'danger' }],
             dayCheck: [],
@@ -425,23 +411,18 @@ export default {
             halfYearCheck: '',
             yearCheck: '',
             form: {
-                temperatureMin: 0,
-                temperatureMax: 0,
-                humidityMin: 0,
-                humidityMax: 0,
-
                 di_dian_: level.second || level.first,
                 bian_zhi_ren_: userId,
                 lei_xing_: '',
-                bian_zhi_bu_men_: '',
+                bian_zhi_bu_men_: position && position.split(',')[0],
                 zhou_qi_: '',
                 gang_wei_: '',
                 tiao_jian_: '',
-                default_environme: '',
                 she_bei_bian_hao_: '', // 设备编号
                 jian_ce_ri_qi_: '',
                 ri_qi_lie_biao_: '',
-                mo_kuai_lu_jing_: ''
+                mo_kuai_lu_jing_: '',
+                lie_biao_shu_ju_: ''
             },
             subForm: [
 
@@ -532,12 +513,11 @@ export default {
                 jian_ce_zhou_qi_: '监测周期',
                 jian_ce_ri_qi_: '监测日期',
                 jian_ce_gang_wei_: '监测岗位',
-                kong_zhi_tiao_jia: '控制条件',
-                xiu_zheng_shi_du_: '湿度修正值',
-                xiu_zheng_wen_du_: '温度修正值'
+                kong_zhi_tiao_jia: '控制条件'
             },
             subIdList: [],
-            isFirstDevice: true
+            isFirstDevice: true,
+            isFirstLieBiao: true
         }
     },
     computed: {
@@ -559,35 +539,9 @@ export default {
         },
         labelShow () {
             return this.form.zhou_qi_.split('每')[1] + '监测日期:'
-        },
-        labelText () {
-            switch (this.form.lei_xing_) {
-                case '01-室内温湿度监控':
-                    return { label1: '温度范围限值:', label2: '湿度范围限值:' }
-                case '02-冰箱温度监控':
-                    return { label1: '冷藏温度范围限值:', label2: '冷冻温度范围限值:' }
-                case '03-温浴箱温度监控':
-                case '04-阴凉柜温度监控':
-                    return { label1: '温度范围限值:', label2: '' }
-                default:
-                    return { label1: '', label2: '' }
-            }
         }
-
     },
     watch: {
-        'form.temperatureMin' (val) {
-            this.form.default_environme = this.formatEnv(this.form.temperatureMax, this.form.temperatureMin, this.form.humidityMax, this.form.humidityMin)
-        },
-        'form.temperatureMax' (val) {
-            this.form.default_environme = this.formatEnv(this.form.temperatureMax, this.form.temperatureMin, this.form.humidityMax, this.form.humidityMin)
-        },
-        'form.humidityMin' (val) {
-            this.form.default_environme = this.formatEnv(this.form.temperatureMax, this.form.temperatureMin, this.form.humidityMax, this.form.humidityMin)
-        },
-        'form.humidityMax' (val) {
-            this.form.default_environme = this.formatEnv(this.form.temperatureMax, this.form.temperatureMin, this.form.humidityMax, this.form.humidityMin)
-        },
         'form.she_bei_bian_hao_' (val) {
             if (!this.isFirstDevice) {
                 const sql = `select yuan_she_bei_bian,she_bei_ming_cheng_ from t_sbdj where find_in_set(id_, '${val}')`
@@ -601,21 +555,18 @@ export default {
                             this.subForm.push({
                                 deviceno1_: bianHao,
                                 devicename1_: mingChneg,
-
                                 shi_fou_qi_yong_: '1',
                                 bu_men_: this.form.bian_zhi_bu_men_,
                                 jian_ce_gang_wei_: this.form.gang_wei_,
                                 jian_ce_zhou_qi_: this.form.zhou_qi_,
                                 kong_zhi_tiao_jia: this.form.tiao_jian_,
-                                environment_range: this.form.default_environme,
-                                xiu_zheng_shi_du_: '',
-                                xiu_zheng_wen_du_: '',
                                 fang_jian_: '',
                                 qu_yu_: '',
                                 deviceno2_: '',
                                 jian_ce_ri_qi_: this.form.jian_ce_ri_qi_,
                                 ri_qi_lie_biao_: this.form.ri_qi_lie_biao_,
-                                zi_wai_deng_wai_j: this.$utils.guid()
+                                zi_wai_deng_wai_j: this.$utils.guid(),
+                                lie_biao_shu_ju_: this.form.lie_biao_shu_ju_
                             })
                         }
                     })
@@ -624,6 +575,35 @@ export default {
         },
         'form.lei_xing_' (val) {
             this.form.mo_kuai_lu_jing_ = this.config[val].path
+            if (!this.isFirstLieBiao) {
+                switch (val) {
+                    case '01-室内温湿度监控':
+                        this.form.lie_biao_shu_ju_ = JSON.stringify([
+                            { label: '温度', range: [], fixValue: '', value: '', result: '', status: '' },
+                            { label: '湿度', range: [], fixValue: '', value: '', result: '', status: '' }
+                        ])
+                        break
+                    case '02-冰箱温度监控':
+                        this.form.lie_biao_shu_ju_ = JSON.stringify([
+                            { label: '冷藏', range: [], fixValue: '', value: '', result: '', status: '' },
+                            { label: '冷冻', range: [], fixValue: '', value: '', result: '', status: '' }
+                        ])
+                        break
+                    case '03-温浴箱温度监控':
+                        this.form.lie_biao_shu_ju_ = JSON.stringify([
+                            { label: '温度', range: [], fixValue: '', value: '', result: '', status: '' }
+                        ])
+                        break
+                    case '04-阴凉柜温度监控':
+                        this.form.lie_biao_shu_ju_ = JSON.stringify([
+                            { label: '温度', range: [], fixValue: '', value: '', result: '', status: '' }
+                        ])
+                        break
+                    default:
+                        delete this.form.lie_biao_shu_ju_
+                        break
+                }
+            }
         },
         'form.zhou_qi_' (val) {
             this.dayCheck = []
@@ -762,9 +742,16 @@ export default {
             this.loadSubData()
         } else {
             this.isFirstDevice = false
+            this.isFirstLieBiao = false
         }
     },
     methods: {
+        // 接收自定义组件数据
+        onFacilityData (...arg) {
+            if (arg.length > 1) {
+                this.form.lie_biao_shu_ju_ = arg[1]
+            }
+        },
         init () {
             this.loadSelectorData()
         },
@@ -786,13 +773,6 @@ export default {
                 }
                 this.form = data[0]
                 const jian_ce_ri_qi_ = data[0].jian_ce_ri_qi_
-                if (this.form.default_environme) {
-                    const { humidity, temperature } = JSON.parse(this.form.default_environme)
-                    this.$set(this.form, 'temperatureMin', +temperature.min)
-                    this.$set(this.form, 'temperatureMax', +temperature.max)
-                    this.$set(this.form, 'humidityMin', +humidity.min)
-                    this.$set(this.form, 'humidityMax', +humidity.max)
-                }
                 if (this.form.jian_ce_ri_qi_) {
                     this.$nextTick(() => {
                         switch (this.form.zhou_qi_) {
@@ -825,6 +805,7 @@ export default {
                 }
                 this.$nextTick(() => {
                     this.isFirstDevice = false
+                    this.isFirstLieBiao = false
                 })
             })
         },
@@ -840,19 +821,6 @@ export default {
                 this.subIdList = data.map(item => item.zi_wai_deng_wai_j)
             })
         },
-        formatEnv (temperatureMax, temperatureMin, humidityMax, humidityMin) {
-            const temp_environment_range = {
-                temperature: {
-                    max: temperatureMax,
-                    min: temperatureMin
-                },
-                humidity: {
-                    max: humidityMax,
-                    min: humidityMin
-                }
-            }
-            return JSON.stringify(temp_environment_range)
-        },
         formatRiQi () {
             switch (this.form.zhou_qi_) {
                 case '每日':
@@ -952,147 +920,33 @@ export default {
                     break
             }
         },
-        // 使用默认数据
-        settingData () {
-            this.$confirm('使用默认数据后子表中为空的字段将会被以上数据代替,是否继续?', '提示', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
-            })
-                .then(() => {
-                    this.subForm.forEach(item => {
-                        if (item.bu_men_ === '') {
-                            item.bu_men_ = this.form.bian_zhi_bu_men_
-                        }
-                        if (item.jian_ce_gang_wei_ === '') {
-                            item.jian_ce_gang_wei_ = this.form.gang_wei_
-                        }
-                        if (item.kong_zhi_tiao_jia === '') {
-                            item.kong_zhi_tiao_jia = this.form.tiao_jian_
-                        }
-                        if (item.environment_range === '' || item.environment_range === this.formatEnv(0, 0, 0, 0)) {
-                            item.environment_range = this.form.default_environme
-                        }
-
-                        if (item.jian_ce_ri_qi_ === '') {
-                            item.jian_ce_ri_qi_ = this.form.jian_ce_ri_qi_
-                        }
-                        if (item.ri_qi_lie_biao_ === '') {
-                            item.ri_qi_lie_biao_ = this.form.ri_qi_lie_biao_
-                        }
-                        if (item.jian_ce_zhou_qi_ === '') {
-                            item.jian_ce_zhou_qi_ = this.form.zhou_qi_
-                        }
-                    })
-                })
+        // 子表关闭事件
+        sonClose () {
+            this.subDialogVisible = false
         },
         // 子表单添加/编辑按钮
         openDialog (row) {
             if (this.form.lei_xing_ === '') {
                 return this.$message.warning('请先选择类型!')
             }
-            this.$refs.FecDialogRef.open(row, this.jianCeGangWeiList, this.form, { dayCheck: this.dayCheck, weekCheck: this.weekCheck, monthCheck: this.monthCheck, quarterCheck: this.quarterCheck, halfYearCheck: this.halfYearCheck, yearCheck: this.yearCheck })
+            this.subDialogVisible = true
+            this.$nextTick(() => {
+                this.$refs.FecDialogRef.open(row, this.jianCeGangWeiList, this.form)
+            })
         },
         // 子表的提交事件
         sonSubmit (data) {
-            const { dayCheck, weekCheck, monthCheck, quarterCheck, halfYearCheck, yearCheck, form, isEdit, row } = data
-            const temp_form = JSON.parse(JSON.stringify(form))
-            const temp_environment_range = {
-                temperature: {
-                    max: temp_form.temperatureMax,
-                    min: temp_form.temperatureMin
-                },
-                humidity: {
-                    max: temp_form.humidityMax,
-                    min: temp_form.humidityMin
+            const { form, isEdit } = data
+            if (isEdit) {
+                const sub = this.subForm.find(item => item.zi_wai_deng_wai_j === form.zi_wai_deng_wai_j)
+                if (sub) {
+                    Object.assign(sub, form)
                 }
-            }
-            // 温度湿度格式化
-            temp_form.environment_range = JSON.stringify(temp_environment_range)
-            // 监测日期格式化
-            switch (temp_form.jian_ce_zhou_qi_) {
-                case '每日':
-                    if (!dayCheck || dayCheck.length === 0) {
-                        temp_form.jian_ce_ri_qi_ = ''
-                        temp_form.ri_qi_lie_biao_ = ''
-                    } else if (dayCheck.length === 7) {
-                        temp_form.jian_ce_ri_qi_ = '每天'
-                        temp_form.ri_qi_lie_biao_ = '1,2,3,4,5,6,7'
-                    } else {
-                        dayCheck.sort(function (a, b) {
-                            return a - b
-                        })
-                        temp_form.jian_ce_ri_qi_ = '每周' + dayCheck.join(',')
-                        temp_form.ri_qi_lie_biao_ = dayCheck.join(',')
-                    }
-                    break
-                case '每周':
-                    if (weekCheck) {
-                        temp_form.jian_ce_ri_qi_ = '每周' + weekCheck
-                        temp_form.ri_qi_lie_biao_ = weekCheck + ''
-                    } else {
-                        temp_form.jian_ce_ri_qi_ = ''
-                        temp_form.ri_qi_lie_biao_ = ''
-                    }
-
-                    break
-                case '每月':
-
-                    if (monthCheck) {
-                        temp_form.jian_ce_ri_qi_ = '每个月第' + monthCheck + '天'
-                        temp_form.ri_qi_lie_biao_ = monthCheck + ''
-                    } else {
-                        temp_form.jian_ce_ri_qi_ = ''
-                        temp_form.ri_qi_lie_biao_ = ''
-                    }
-                    break
-                case '每季度':
-
-                    if (quarterCheck) {
-                        temp_form.jian_ce_ri_qi_ = '每季度第' + [quarterCheck] + '个月'
-                        temp_form.ri_qi_lie_biao_ = quarterCheck + ''
-                    } else {
-                        temp_form.jian_ce_ri_qi_ = ''
-                        temp_form.ri_qi_lie_biao_ = ''
-                    }
-                    break
-                case '每半年':
-
-                    if (halfYearCheck) {
-                        temp_form.jian_ce_ri_qi_ = '每半年第' + [halfYearCheck] + '个月'
-                        temp_form.ri_qi_lie_biao_ = halfYearCheck + ''
-                    } else {
-                        temp_form.jian_ce_ri_qi_ = ''
-                        temp_form.ri_qi_lie_biao_ = ''
-                    }
-                    break
-                case '每年':
-
-                    if (yearCheck) {
-                        temp_form.jian_ce_ri_qi_ = '每年第' + [yearCheck] + '个月'
-                        temp_form.ri_qi_lie_biao_ = yearCheck + ''
-                    } else {
-                        temp_form.jian_ce_ri_qi_ = ''
-                        temp_form.ri_qi_lie_biao_ = ''
-                    }
-                    break
-                default:
-                    break
-            }
-            // 是否启用格式化
-            temp_form.shi_fou_qi_yong_ = temp_form.shi_fou_qi_yong_ ? '1' : '0'
-            // 删除多余项
-            delete temp_form.temperatureMax
-            delete temp_form.humidityMax
-            delete temp_form.temperatureMin
-            delete temp_form.humidityMin
-            if (isEdit === true) {
-                Object.assign(row, temp_form)
             } else {
-                this.subForm.push(temp_form)
+                this.subForm.push(form)
             }
             this.isEdit && this.goSearch()
-            this.$refs.FecDialogRef.close()
+            this.sonClose()
         },
         // 关闭当前窗口
         closeDialog () {
@@ -1143,11 +997,17 @@ export default {
                 if (item.jian_ce_gang_wei_ === '') {
                     return this.$message.warning(`子表第${i + 1}行监测岗位信息缺失!`)
                 }
+                if (item.lie_biao_shu_ju_) {
+                    const lie_biao_shu_ju_ = JSON.parse(item.lie_biao_shu_ju_)
+                    for (let i = 0; i < lie_biao_shu_ju_.length; i++) {
+                        const item = lie_biao_shu_ju_[i]
+                        if (!item.label && (item.range.length !== 2 || item.range[0] === null || item.range[1] === null) && (!item.fixValue)) {
+                            return this.$message.warning(`第${i + 1}行数据非法!`)
+                        }
+                    }
+                }
             }
-            delete this.form.temperatureMax
-            delete this.form.humidityMax
-            delete this.form.temperatureMin
-            delete this.form.humidityMin
+
             // console.log('主表', this.form)
             // console.log('子表', this.subForm)
             const allUid = this.subForm.map(item => item.zi_wai_deng_wai_j)
@@ -1155,12 +1015,6 @@ export default {
             const addList = this.subForm.filter(item => !existUid.includes(item.zi_wai_deng_wai_j))
             const deleteList = existUid.filter(item => !allUid.includes(item))
             const updateList = this.subForm.filter(item => existUid.includes(item.zi_wai_deng_wai_j))
-            // console.log('原来数据', existUid)
-            // console.log('全部数据', allUid)
-            // console.log('需要添加', addList)
-            // console.log('需要更新', updateList)
-            // console.log('需要删除', deleteList)
-            // return
             // 主表修改
             if (this.isEdit) {
                 const params = {
@@ -1176,11 +1030,11 @@ export default {
                                 zhou_qi_: this.form.zhou_qi_,
                                 gang_wei_: this.form.gang_wei_,
                                 tiao_jian_: this.form.tiao_jian_,
-                                default_environme: this.form.default_environme,
                                 she_bei_bian_hao_: this.form.she_bei_bian_hao_,
                                 jian_ce_ri_qi_: this.form.jian_ce_ri_qi_,
                                 ri_qi_lie_biao_: this.form.ri_qi_lie_biao_,
-                                mo_kuai_lu_jing_: this.form.mo_kuai_lu_jing_
+                                mo_kuai_lu_jing_: this.form.mo_kuai_lu_jing_,
+                                lie_biao_shu_ju_: this.form.lie_biao_shu_ju_
                             }
 
                         }
@@ -1192,7 +1046,23 @@ export default {
                         const params = {
                             tableName: 't_sshjpzxq',
                             paramWhere: addList.map(item => {
-                                return { ...item, parent_id_: this.parentData.mainId }
+                                return {
+                                    parent_id_: this.parentData.mainId,
+                                    bu_men_: item.bu_men_,
+                                    devicename1_: item.devicename1_,
+                                    deviceno1_: item.deviceno1_,
+                                    deviceno2_: item.deviceno2_,
+                                    fang_jian_: item.fang_jian_,
+                                    jian_ce_gang_wei_: item.jian_ce_gang_wei_,
+                                    jian_ce_ri_qi_: item.jian_ce_ri_qi_,
+                                    jian_ce_zhou_qi_: item.jian_ce_zhou_qi_,
+                                    kong_zhi_tiao_jia: item.kong_zhi_tiao_jia,
+                                    lie_biao_shu_ju_: item.lie_biao_shu_ju_,
+                                    qu_yu_: item.qu_yu_,
+                                    ri_qi_lie_biao_: item.ri_qi_lie_biao_,
+                                    shi_fou_qi_yong_: item.shi_fou_qi_yong_,
+                                    zi_wai_deng_wai_j: item.zi_wai_deng_wai_j
+                                }
                             })
                         }
                         this.$common.request('add', params).then(() => { console.log('子表添加数据成功') })
@@ -1215,11 +1085,9 @@ export default {
                                     jian_ce_gang_wei_: item.jian_ce_gang_wei_,
                                     shi_fou_qi_yong_: item.shi_fou_qi_yong_,
                                     kong_zhi_tiao_jia: item.kong_zhi_tiao_jia,
-                                    environment_range: item.environment_range,
-                                    xiu_zheng_shi_du_: item.xiu_zheng_shi_du_,
-                                    xiu_zheng_wen_du_: item.xiu_zheng_wen_du_,
                                     jian_ce_ri_qi_: item.jian_ce_ri_qi_,
-                                    ri_qi_lie_biao_: item.ri_qi_lie_biao_
+                                    ri_qi_lie_biao_: item.ri_qi_lie_biao_,
+                                    lie_biao_shu_ju_: item.lie_biao_shu_ju_
                                 }
                             }))
                         }
@@ -1240,7 +1108,9 @@ export default {
             } else {
                 const params = {
                     tableName: 't_sshjpzb',
-                    paramWhere: [this.form]
+                    paramWhere: [{
+                        ...this.form
+                    }]
                 }
                 this.$common.request('add', params).then((res) => {
                     console.log('主表新增数据成功')
@@ -1249,7 +1119,23 @@ export default {
                         const params = {
                             tableName: 't_sshjpzxq',
                             paramWhere: addList.map(item => {
-                                return { ...item, parent_id_: cont[0].id_ }
+                                return {
+                                    parent_id_: cont[0].id_,
+                                    bu_men_: item.bu_men_,
+                                    devicename1_: item.devicename1_,
+                                    deviceno1_: item.deviceno1_,
+                                    deviceno2_: item.deviceno2_,
+                                    fang_jian_: item.fang_jian_,
+                                    jian_ce_gang_wei_: item.jian_ce_gang_wei_,
+                                    jian_ce_ri_qi_: item.jian_ce_ri_qi_,
+                                    jian_ce_zhou_qi_: item.jian_ce_zhou_qi_,
+                                    kong_zhi_tiao_jia: item.kong_zhi_tiao_jia,
+                                    lie_biao_shu_ju_: item.lie_biao_shu_ju_,
+                                    qu_yu_: item.qu_yu_,
+                                    ri_qi_lie_biao_: item.ri_qi_lie_biao_,
+                                    shi_fou_qi_yong_: item.shi_fou_qi_yong_,
+                                    zi_wai_deng_wai_j: item.zi_wai_deng_wai_j
+                                }
                             })
                         }
                         this.$common.request('add', params).then(() => {
@@ -1355,9 +1241,6 @@ export default {
                     jian_ce_gang_wei_: item['监测岗位'] || '',
                     jian_ce_zhou_qi_: item['监测周期'] || '',
                     kong_zhi_tiao_jia: item['控制条件'] || '',
-                    environment_range: '',
-                    xiu_zheng_shi_du_: item['湿度修正值'] || '',
-                    xiu_zheng_wen_du_: item['温度修正值'] || '',
                     fang_jian_: item['房间'] || '',
                     qu_yu_: item['区域'] || '',
                     deviceno2_: item['监控设备编号'] || '',

+ 166 - 158
src/views/system/fasc/fecDialog.vue

@@ -96,42 +96,10 @@
 
                     </el-row>
 
-                    <el-row>
-                        <el-col :span="12">
-                            <el-form-item v-if="labelText.label1" :label="labelText.label1+'范围限值:'">
-                                <el-input-number v-model="form.temperatureMin" size="mini" controls-position="right" :min="-100" :max="form.temperatureMax" :step="1" />
-                                至
-                                <el-input-number v-model="form.temperatureMax" size="mini" controls-position="right" :min="form.temperatureMin" :max="100" :step="1" />
-                                (℃)
-                            </el-form-item>
-                        </el-col>
-                        <el-col :span="12">
-                            <el-form-item v-if="labelText.label2" :label="labelText.label2+'范围限值:'">
-                                <el-input-number v-model="form.humidityMin" size="mini" controls-position="right" :min="-100" :max="form.humidityMax" :step="1" />
-                                至
-                                <el-input-number v-model="form.humidityMax" size="mini" controls-position="right" :min="form.humidityMin" :max="100" :step="1" />
-                                (℃)
-                            </el-form-item>
-                        </el-col>
-                    </el-row>
-                    <el-row>
-
-                        <el-col :span="12">
-                            <el-form-item v-if="labelText.label1" :label="labelText.label1+'修正值:'">
-                                <el-input v-model="form.xiu_zheng_wen_du_" size="mini" style="width:80%" />
-                            </el-form-item>
-                        </el-col>
-                        <el-col :span="12">
-                            <el-form-item v-if="labelText.label2" :label="labelText.label2+'修正值:'">
-                                <el-input v-model="form.xiu_zheng_shi_du_" size="mini" style="width:80%" />
-                            </el-form-item>
-                        </el-col>
-                    </el-row>
-
                     <el-row>
                         <el-col :span="12">
                             <el-form-item label="监测周期:">
-                                <el-select v-model="form.jian_ce_zhou_qi_" placeholder="请选择" size="mini" style="width:60%">
+                                <el-select v-model="form.jian_ce_zhou_qi_" placeholder="请选择" size="mini" style="width:80%">
                                     <el-option
                                         v-for="item in period"
                                         :key="item.value"
@@ -149,6 +117,8 @@
                                     inactive-color="#ff4949"
                                     active-text="启用"
                                     inactive-text="停用"
+                                    active-value="1"
+                                    inactive-value="0"
                                 />
                             </el-form-item>
                         </el-col>
@@ -174,7 +144,7 @@
                                     <el-radio v-model="weekCheck" :label="6" size="mini">周六</el-radio>
                                     <el-radio v-model="weekCheck" :label="7" size="mini">周日</el-radio>
                                 </template>
-                                <el-select v-if="form.jian_ce_zhou_qi_==='每月'" v-model="monthCheck" placeholder="请选择" size="mini">
+                                <el-select v-if="form.jian_ce_zhou_qi_==='每月'" v-model="monthCheck" placeholder="请选择" size="mini" style="width:80%">
                                     <el-option
                                         v-for="item in 28"
                                         :key="item"
@@ -182,7 +152,7 @@
                                         :value="item"
                                     />
                                 </el-select>
-                                <el-select v-if="form.jian_ce_zhou_qi_==='每季度'" v-model="quarterCheck" placeholder="请选择" size="mini">
+                                <el-select v-if="form.jian_ce_zhou_qi_==='每季度'" v-model="quarterCheck" placeholder="请选择" size="mini" style="width:80%">
                                     <el-option
                                         v-for="item in 3"
                                         :key="item"
@@ -190,7 +160,7 @@
                                         :value="item"
                                     />
                                 </el-select>
-                                <el-select v-if="form.jian_ce_zhou_qi_==='每半年'" v-model="halfYearCheck" placeholder="请选择" size="mini">
+                                <el-select v-if="form.jian_ce_zhou_qi_==='每半年'" v-model="halfYearCheck" placeholder="请选择" size="mini" style="width:80%">
                                     <el-option
                                         v-for="item in 6"
                                         :key="item"
@@ -198,7 +168,7 @@
                                         :value="item"
                                     />
                                 </el-select>
-                                <el-select v-if="form.jian_ce_zhou_qi_==='每年'" v-model="yearCheck" placeholder="请选择" size="mini">
+                                <el-select v-if="form.jian_ce_zhou_qi_==='每年'" v-model="yearCheck" placeholder="请选择" size="mini" style="width:80%">
                                     <el-option
                                         v-for="item in 12"
                                         :key="item"
@@ -222,6 +192,11 @@
                             </el-form-item>
                         </el-col>
                     </el-row>
+                    <el-row>
+                        <el-col :span="24">
+                            <FacilityData v-if="form.lie_biao_shu_ju_" :is-cul="false" :form-data="{lieBiaoShuJu:form.lie_biao_shu_ju_}" @change-data="onFacilityData" />
+                        </el-col>
+                    </el-row>
                 </el-form>
             </div>
         </div>
@@ -235,24 +210,21 @@
 <script>
 import ibpsUserSelector from '@/business/platform/org/selector'
 import IbpsLinkData from '@/business/platform/data/templaterender/link-data'
+import FacilityData from '@/views/component/facility/facilityData.vue'
 
 export default {
     components: {
+        FacilityData,
         ibpsUserSelector,
         IbpsLinkData
     },
     data () {
         return {
-            dialogVisible: false,
+            dialogVisible: true,
             title: '配置详情',
             jianCeGangWeiList: [],
             lei_xing_: '',
             form: {
-                temperatureMin: 0,
-                temperatureMax: 0,
-                humidityMin: 0,
-                humidityMax: 0,
-
                 qu_yu_: '',
                 fang_jian_: '',
                 bu_men_: '',
@@ -261,14 +233,12 @@ export default {
                 deviceno2_: '', // 监控设备
                 jian_ce_zhou_qi_: '',
                 jian_ce_gang_wei_: '',
-                shi_fou_qi_yong_: true,
+                shi_fou_qi_yong_: '1',
                 kong_zhi_tiao_jia: '',
-                environment_range: '',
-                xiu_zheng_shi_du_: '',
-                xiu_zheng_wen_du_: '',
                 jian_ce_ri_qi_: '',
                 ri_qi_lie_biao_: '',
-                zi_wai_deng_wai_j: '' // 紫外灯外键
+                zi_wai_deng_wai_j: '', // 紫外灯外键
+                lie_biao_shu_ju_: ''
             },
             isEdit: false,
             quYuList: [],
@@ -287,15 +257,10 @@ export default {
                 { label: '季度监测', value: '每季度' },
                 { label: '半年监测', value: '每半年' },
                 { label: '年监测', value: '每年' }
-            ],
-            row: {}
-
+            ]
         }
     },
     computed: {
-        // isEdit () {
-        //     return this.parentData instanceof Object && this.parentData.mainId
-        // },
         isShowDevice () {
             return this.lei_xing_ !== '01-室内温湿度监控' && this.lei_xing_ !== '06-每日安全检查' && this.lei_xing_ !== '08-含氯有效性监测'
         },
@@ -304,33 +269,9 @@ export default {
                 return this.form.jian_ce_zhou_qi_.split('每')[1] + '监测日期:'
             }
             return ''
-        },
-        labelText () {
-            switch (this.lei_xing_) {
-                case '02-冰箱温度监控':
-                    return { label1: '冷藏温度', label2: '冷冻温度' }
-                case '03-温浴箱温度监控':
-                case '04-阴凉柜温度监控':
-                    return { label1: '温度', label2: '' }
-                case '05-纯水机水质监测':
-                case '06-每日安全检查':
-                case '08-含氯有效性监测':
-                case '10-洗眼器检查':
-                case '11-紧急淋浴器检查':
-                case '13-高压灭菌':
-                case '14-空气消毒机':
-                case '12-紫外灯消毒':
-                    return { label1: '', label2: '' }
-                default:
-                    return { label1: '温度', label2: '湿度' }
-            }
         }
-
     },
     watch: {
-        // 'form.lei_xing_' (val) {
-        //     this.mo_kuai_lu_jing_ = this.config[val].path
-        // },
         'form.jian_ce_zhou_qi_' (val) {
             this.dayCheck = []
             this.weekCheck = ''
@@ -459,6 +400,12 @@ export default {
         this.init()
     },
     methods: {
+        // 接收自定义组件数据
+        onFacilityData (...arg) {
+            if (arg.length > 1) {
+                this.form.lie_biao_shu_ju_ = arg[1]
+            }
+        },
         init () {
             const pos = this.$store.getters.level.second ? this.$store.getters.level.second : this.$store.getters.level.first
             const sql1 = `select * from t_qypzb where di_dian_='${pos}'`
@@ -472,98 +419,159 @@ export default {
                 this.fangJianList = data
             })
         },
+        // 格式化数据
+        formatForm () {
+            // 监测日期格式化
+            switch (this.form.jian_ce_zhou_qi_) {
+                case '每日':
+                    if (!this.dayCheck || this.dayCheck.length === 0) {
+                        this.form.jian_ce_ri_qi_ = ''
+                        this.form.ri_qi_lie_biao_ = ''
+                    } else if (this.dayCheck.length === 7) {
+                        this.form.jian_ce_ri_qi_ = '每天'
+                        this.form.ri_qi_lie_biao_ = '1,2,3,4,5,6,7'
+                    } else {
+                        this.dayCheck.sort(function (a, b) {
+                            return a - b
+                        })
+                        this.form.jian_ce_ri_qi_ = '每周' + this.dayCheck.join(',')
+                        this.form.ri_qi_lie_biao_ = this.dayCheck.join(',')
+                    }
+                    break
+                case '每周':
+                    if (this.weekCheck) {
+                        this.form.jian_ce_ri_qi_ = '每周' + this.weekCheck
+                        this.form.ri_qi_lie_biao_ = this.weekCheck + ''
+                    } else {
+                        this.form.jian_ce_ri_qi_ = ''
+                        this.form.ri_qi_lie_biao_ = ''
+                    }
+
+                    break
+                case '每月':
+                    if (this.monthCheck) {
+                        this.form.jian_ce_ri_qi_ = '每个月第' + this.monthCheck + '天'
+                        this.form.ri_qi_lie_biao_ = this.monthCheck + ''
+                    } else {
+                        this.form.jian_ce_ri_qi_ = ''
+                        this.form.ri_qi_lie_biao_ = ''
+                    }
+                    break
+                case '每季度':
+                    if (this.quarterCheck) {
+                        this.form.jian_ce_ri_qi_ = '每季度第' + [this.quarterCheck] + '个月'
+                        this.form.ri_qi_lie_biao_ = this.quarterCheck + ''
+                    } else {
+                        this.form.jian_ce_ri_qi_ = ''
+                        this.form.ri_qi_lie_biao_ = ''
+                    }
+                    break
+                case '每半年':
+                    if (this.halfYearCheck) {
+                        this.form.jian_ce_ri_qi_ = '每半年第' + [this.halfYearCheck] + '个月'
+                        this.form.ri_qi_lie_biao_ = this.halfYearCheck + ''
+                    } else {
+                        this.form.jian_ce_ri_qi_ = ''
+                        this.form.ri_qi_lie_biao_ = ''
+                    }
+                    break
+                case '每年':
+                    if (this.yearCheck) {
+                        this.form.jian_ce_ri_qi_ = '每年第' + [this.yearCheck] + '个月'
+                        this.form.ri_qi_lie_biao_ = this.yearCheck + ''
+                    } else {
+                        this.form.jian_ce_ri_qi_ = ''
+                        this.form.ri_qi_lie_biao_ = ''
+                    }
+                    break
+                default:
+                    break
+            }
+        },
+        checkForm () {
+            if (this.form.bu_men_ === '') {
+                throw new Error('部门信息缺失!')
+            }
+            if (this.form.jian_ce_ri_qi_ === '') {
+                throw new Error('监测日期信息缺失!')
+            }
+            if (this.form.jian_ce_gang_wei_ === '') {
+                throw new Error('监测岗位信息缺失!')
+            }
+            if (this.form.lie_biao_shu_ju_) {
+                const lie_biao_shu_ju_ = JSON.parse(this.form.lie_biao_shu_ju_)
+                for (let i = 0; i < lie_biao_shu_ju_.length; i++) {
+                    const item = lie_biao_shu_ju_[i]
+                    if (!item.label && (item.range.length !== 2 || item.range[0] === null || item.range[1] === null) && (!item.fixValue)) {
+                        throw new Error(`第${i + 1}行数据非法!`)
+                    }
+                }
+            }
+        },
         submit () {
-            this.$emit('onSubmit', { dayCheck: this.dayCheck, weekCheck: this.weekCheck, monthCheck: this.monthCheck, quarterCheck: this.quarterCheck, halfYearCheck: this.halfYearCheck, yearCheck: this.yearCheck, form: this.form, isEdit: this.isEdit, row: this.row })
+            try {
+                this.formatForm()
+                this.checkForm()
+                this.$emit('onSubmit', { form: this.form, isEdit: this.isEdit })
+            } catch (error) {
+                this.$message.warning(error.message)
+            }
         },
         close () {
-            this.dialogVisible = false
-            // 初始化操作
-            this.form.bu_men_ = ''
-            this.form.shi_fou_qi_yong_ = true
-            this.form.xiu_zheng_shi_du_ = ''
-            this.form.xiu_zheng_wen_du_ = ''
-            this.form.kong_zhi_tiao_jia = ''
-            this.form.fang_jian_ = ''
-            this.form.qu_yu_ = ''
-            this.form.deviceno2_ = ''
-            this.form.temperatureMin = 0
-            this.form.temperatureMax = 0
-            this.form.humidityMin = 0
-            this.form.humidityMax = 0
-            this.form.deviceno1_ = ''
-            this.form.devicename1_ = ''
-            this.form.jian_ce_zhou_qi_ = ''
-            this.form.jian_ce_gang_wei_ = ''
-            this.form.environment_range = ''
-            this.form.jian_ce_ri_qi_ = ''
-            this.form.ri_qi_lie_biao_ = ''
-            this.form.zi_wai_deng_wai_j = ''
-
-            this.dayCheck = []
-            this.weekCheck = ''
-            this.monthCheck = ''
-            this.quarterCheck = ''
-            this.halfYearCheck = ''
-            this.yearCheck = ''
+            this.$emit('onClose')
+        },
+        // 格式化监测日期
+        formatData () {
+            if (this.form.jian_ce_ri_qi_) {
+                this.$nextTick(() => {
+                    switch (this.form.jian_ce_zhou_qi_) {
+                        case '每日':
+                            if (this.form.jian_ce_ri_qi_ === '每天') {
+                                this.dayCheck = [1, 2, 3, 4, 5, 6, 7]
+                            } else {
+                                this.dayCheck = this.form.jian_ce_ri_qi_.split('每周')[1].split(',').map(item => +item)
+                            }
+                            break
+                        case '每周':
+                            this.weekCheck = +this.form.jian_ce_ri_qi_.split('每周')[1]
+                            break
+                        case '每月':
+                            this.monthCheck = +this.form.jian_ce_ri_qi_.split('每个月第')[1].split('天')[0]
+                            break
+                        case '每季度':
+                            this.quarterCheck = +this.form.jian_ce_ri_qi_.split('每季度第')[1].split('个月')[0]
+                            break
+                        case '每半年':
+                            this.halfYearCheck = +this.form.jian_ce_ri_qi_.split('每半年第')[1].split('个月')[0]
+                            break
+                        case '每年':
+                            this.yearCheck = +this.form.jian_ce_ri_qi_.split('每年第')[1].split('个月')[0]
+                            break
+                        default:
+                            break
+                    }
+                })
+            }
         },
-        open (row, jianCeGangWeiList, parentForm, dateCheck) {
+        open (row, jianCeGangWeiList, parentForm) {
             this.dialogVisible = true
             this.jianCeGangWeiList = jianCeGangWeiList
             this.lei_xing_ = parentForm.lei_xing_
-            this.row = row
+            this.isEdit = !!(row && row.zi_wai_deng_wai_j)
             // 编辑
-            if (row instanceof PointerEvent === false) {
-                this.isEdit = true
+            if (this.isEdit) {
                 this.form = JSON.parse(JSON.stringify(row))
-                if (row.shi_fou_qi_yong_ === '1') {
-                    this.form.shi_fou_qi_yong_ = true
-                }
-                if (row.shi_fou_qi_yong_ === '0') {
-                    this.form.shi_fou_qi_yong_ = false
-                }
-
-                if (this.form.jian_ce_ri_qi_) {
-                    this.$nextTick(() => {
-                        switch (this.form.jian_ce_zhou_qi_) {
-                            case '每日':
-                                if (this.form.jian_ce_ri_qi_ === '每天') {
-                                    this.dayCheck = [1, 2, 3, 4, 5, 6, 7]
-                                } else {
-                                    this.dayCheck = this.form.jian_ce_ri_qi_.split('每周')[1].split(',').map(item => +item)
-                                }
-                                break
-                            case '每周':
-                                this.weekCheck = +this.form.jian_ce_ri_qi_.split('每周')[1]
-                                break
-                            case '每月':
-                                this.monthCheck = +this.form.jian_ce_ri_qi_.split('每个月第')[1].split('天')[0]
-                                break
-                            case '每季度':
-                                this.quarterCheck = +this.form.jian_ce_ri_qi_.split('每季度第')[1].split('个月')[0]
-                                break
-                            case '每半年':
-                                this.halfYearCheck = +this.form.jian_ce_ri_qi_.split('每半年第')[1].split('个月')[0]
-                                break
-                            case '每年':
-                                this.yearCheck = +this.form.jian_ce_ri_qi_.split('每年第')[1].split('个月')[0]
-                                break
-                            default:
-                                break
-                        }
-                    })
-                }
-
-                if (this.form.environment_range) {
-                    const { humidity, temperature } = JSON.parse(this.form.environment_range)
-                    this.$set(this.form, 'temperatureMin', +temperature.min)
-                    this.$set(this.form, 'temperatureMax', +temperature.max)
-                    this.$set(this.form, 'humidityMin', +humidity.min)
-                    this.$set(this.form, 'humidityMax', +humidity.max)
-                }
             } else {
-                this.isEdit = false
                 this.form.zi_wai_deng_wai_j = this.$utils.guid()
+                this.form.bu_men_ = parentForm.bian_zhi_bu_men_
+                this.form.jian_ce_gang_wei_ = parentForm.gang_wei_
+                this.form.jian_ce_ri_qi_ = parentForm.jian_ce_ri_qi_
+                this.form.kong_zhi_tiao_jia = parentForm.tiao_jian_
+                this.form.jian_ce_zhou_qi_ = parentForm.zhou_qi_
+                this.form.ri_qi_lie_biao_ = parentForm.ri_qi_lie_biao_
+                this.form.lie_biao_shu_ju_ = parentForm.lie_biao_shu_ju_
             }
+            this.formatData()
         },
         getDayDate (type, dates) {
             const now = new Date()