ソースを参照

调整使用默认数据的逻辑;隐藏导入导出按钮

luoaoxuan 2 年 前
親
コミット
69551d991b
1 ファイル変更、84 行追加、49 行削除
  1. 84 49
      src/views/system/fasc/facilityEnvConfig.vue

+ 84 - 49
src/views/system/fasc/facilityEnvConfig.vue

@@ -26,7 +26,7 @@
                                     <template slot="label">
                                     <template slot="label">
                                         <span class="required">类型:</span>
                                         <span class="required">类型:</span>
                                     </template>
                                     </template>
-                                    <el-select v-model="form.lei_xing_" placeholder="请选择" size="mini" style="width:80%">
+                                    <el-select v-model="form.lei_xing_" placeholder="请选择" size="mini" style="width:80%" :disabled="isEdit">
                                         <el-option
                                         <el-option
                                             v-for="(value,key) in config"
                                             v-for="(value,key) in config"
                                             :key="key"
                                             :key="key"
@@ -233,7 +233,7 @@
                             <div class="search-item" style="width:68px">
                             <div class="search-item" style="width:68px">
                                 <el-button type="success" size="mini" icon="ibps-icon-plus" @click="openDialog">添加</el-button>
                                 <el-button type="success" size="mini" icon="ibps-icon-plus" @click="openDialog">添加</el-button>
                             </div>
                             </div>
-                            <div class="search-item" style="width:70px">
+                            <!-- <div class="search-item" style="width:70px">
                                 <el-upload
                                 <el-upload
                                     ref="uploadRef"
                                     ref="uploadRef"
                                     class="upload-demo"
                                     class="upload-demo"
@@ -248,7 +248,7 @@
                             </div>
                             </div>
                             <div class="search-item" style="width:70px">
                             <div class="search-item" style="width:70px">
                                 <el-button type="primary" size="mini" icon="el-icon-download" @click="exportExcel">导出</el-button>
                                 <el-button type="primary" size="mini" icon="el-icon-download" @click="exportExcel">导出</el-button>
-                            </div>
+                            </div> -->
                             <div v-if="trueList.length>0" class="search-item" style="width:120px">
                             <div v-if="trueList.length>0" class="search-item" style="width:120px">
                                 <el-button type="info" size="mini" icon="el-icon-setting" @click="settingData">使用默认数据</el-button>
                                 <el-button type="info" size="mini" icon="el-icon-setting" @click="settingData">使用默认数据</el-button>
                             </div>
                             </div>
@@ -623,6 +623,13 @@ export default {
                             { label: '温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
                             { label: '温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
                         ])
                         ])
                         break
                         break
+                    // case '05-纯水机水质监测':
+                    //     this.form.lie_biao_shu_ju_ = JSON.stringify([
+                    //         { label: '电阻率', range: [10, null], fixValue: '', value: '', result: '', status: '', unit: 'MΩ·CM' },
+                    //         { label: '电导率', range: [0, 1], fixValue: '', value: '', result: '', status: '', unit: 'uS/cm' },
+                    //         { label: '微生物含量', range: [0, 10], fixValue: '', value: '', result: '', status: '', unit: 'cfu/ml' }
+                    //     ])
+                    //     break
                     default:
                     default:
                         delete this.form.lie_biao_shu_ju_
                         delete this.form.lie_biao_shu_ju_
                         break
                         break
@@ -921,56 +928,84 @@ export default {
         },
         },
         // 使用默认数据
         // 使用默认数据
         settingData () {
         settingData () {
-            this.$confirm('使用默认数据后子表中为空的字段将会被以上数据代替,是否继续?', '提示', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
+            this.$confirm('选择默认数据的填充方式?', '提示', {
+                confirmButtonText: '完全替换',
+                cancelButtonText: '为空替换',
+                closeOnClickModal: false,
+                closeOnPressEscape: false,
+                distinguishCancelAndClose: true,
+                type: 'info'
             })
             })
                 .then(() => {
                 .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.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_
+                    this.settingAll()
+                })
+                .catch((action) => {
+                    if (action === 'close') return
+                    if (action === 'cancel') {
+                        this.settingEmpty()
+                    }
+                })
+        },
+        settingAll () {
+            this.subForm.forEach(item => {
+                item.bu_men_ = this.form.bian_zhi_bu_men_
+                item.jian_ce_gang_wei_ = this.form.gang_wei_
+                item.kong_zhi_tiao_jia = this.form.tiao_jian_
+                item.jian_ce_ri_qi_ = this.form.jian_ce_ri_qi_
+                item.ri_qi_lie_biao_ = this.form.ri_qi_lie_biao_
+                item.jian_ce_zhou_qi_ = this.form.zhou_qi_
+                item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
+            })
+        },
+        // 使用默认数据
+        settingEmpty () {
+            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.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_
+                }
+                if (this.form.lie_biao_shu_ju_) {
+                    if (item.lie_biao_shu_ju_) {
+                        const main = JSON.parse(this.form.lie_biao_shu_ju_)
+                        const sub = JSON.parse(item.lie_biao_shu_ju_)
+                        if (sub.length === 0) {
+                            item.lie_biao_shu_ju_ = JSON.stringify(sub)
                         }
                         }
-                        if (item.lie_biao_shu_ju_ && this.form.lie_biao_shu_ju_) {
-                            const main = JSON.parse(this.form.lie_biao_shu_ju_)
-                            const sub = JSON.parse(item.lie_biao_shu_ju_)
-                            if (sub.length === 0) {
-                                item.lie_biao_shu_ju_ = JSON.stringify(sub)
-                            }
-                            if (sub.length > 0) {
-                                sub.forEach((i, index) => {
-                                    if (i.label === main[index].label && (i.range.length === 0 || i.range.join(',') === [null, null].join(',') || i.range.join(',') === ['', ''].join(','))) {
-                                        i.range = main[index].range
-                                    }
-                                    if (i.label === main[index].label && i.fixValue === '') {
-                                        i.fixValue = main[index].fixValue
-                                    }
-                                    if (i.label === main[index].label && i.unit === '') {
-                                        i.unit = main[index].unit
-                                    }
-                                })
-                                item.lie_biao_shu_ju_ = JSON.stringify(sub)
-                            } else {
-                                item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
-                            }
+                        if (sub.length > 0) {
+                            sub.forEach((i, index) => {
+                                if (i.label === main[index].label && (i.range.length === 0 || i.range.join(',') === [null, null].join(',') || i.range.join(',') === ['', ''].join(','))) {
+                                    i.range = main[index].range
+                                }
+                                if (i.label === main[index].label && i.fixValue === '') {
+                                    i.fixValue = main[index].fixValue
+                                }
+                                if (i.label === main[index].label && i.unit === '') {
+                                    i.unit = main[index].unit
+                                }
+                            })
+                            item.lie_biao_shu_ju_ = JSON.stringify(sub)
+                        } else {
+                            item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
                         }
                         }
-                    })
-                })
+                    } else {
+                        item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
+                    }
+                }
+            })
         },
         },
         // 当前页码改变
         // 当前页码改变
         handleCurrentChange (val) {
         handleCurrentChange (val) {