Răsfoiți Sursa

设施环境配置页优化;组件新增参数单位选项

luoaoxuan 1 an în urmă
părinte
comite
1fc39c91c8

+ 23 - 3
src/views/component/facility/facilityData.vue

@@ -25,6 +25,19 @@
                             <span v-else>{{ row.label|| '/' }}</span>
                         </template>
                     </el-table-column>
+                    <el-table-column label="参数单位" prop="unit">
+                        <template slot-scope="{row}">
+                            <el-autocomplete
+                                v-if="!readonly"
+                                v-model="row.unit"
+                                class="inline-input"
+                                :fetch-suggestions="querySearch"
+                                placeholder="请输入内容"
+                                size="mini"
+                            />
+                            <span v-else>{{ row.unit || '/' }}</span>
+                        </template>
+                    </el-table-column>
 
                     <el-table-column label="参数范围限值" prop="range">
                         <template slot-scope="{row}">
@@ -122,11 +135,17 @@ export default {
         // console.log('mounted', this.formData)
     },
     methods: {
+        // 默认单位
+        querySearch (queryString, cb) {
+            const units = [{ value: '℃' }, { value: '%' }, { value: 'Pa' }]
+            // 调用 callback 返回建议列表的数据
+            cb(units)
+        },
         // 计算状态
         getStatus (range, result) {
             let [min, max] = range
-            if (!min) min = -9999
-            if (!max) max = 9999
+            if (min === null || min === '' || typeof min === 'undefined') min = Number.MIN_VALUE
+            if (max === null || max === '' || typeof max === 'undefined') max = Number.MAX_VALUE
             // console.log(min, max, result)
             if (+min === 0 && +max === 0) {
                 return '正常'
@@ -169,7 +188,8 @@ export default {
                 fixValue: '',
                 value: '',
                 result: '',
-                status: ''
+                status: '',
+                unit: ''
             })
         },
         goRemove () {

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

@@ -19,10 +19,13 @@
         <div class="container">
             <div class="main">
                 <div class="form">
-                    <el-form ref="form" :model="form" label-width="120px" :rules="rules">
+                    <el-form ref="form" :model="form" label-width="120px" :rules="rules" :hide-required-asterisk="true">
                         <el-row>
                             <el-col :span="12">
                                 <el-form-item label="类型:" prop="lei_xing_">
+                                    <template slot="label">
+                                        <span class="required">类型</span>
+                                    </template>
                                     <el-select v-model="form.lei_xing_" placeholder="请选择" size="mini" style="width:80%">
                                         <el-option
                                             v-for="(value,key) in config"
@@ -350,9 +353,8 @@
                     />
                 </div>
             </div>
-
+            <FecDialog v-if="subDialogVisible" ref="FecDialogRef" @onSubmit="sonSubmit" @onClose="sonClose" />
         </div>
-        <FecDialog v-if="subDialogVisible" ref="FecDialogRef" @onSubmit="sonSubmit" @onClose="sonClose" />
     </el-dialog>
 </template>
 
@@ -582,26 +584,26 @@ export default {
                 switch (val) {
                     case '01-室内温湿度监控':
                         this.form.lie_biao_shu_ju_ = JSON.stringify([
-                            { label: '上午温度', range: [], fixValue: '', value: '', result: '', status: '' },
-                            { label: '上午湿度', range: [], fixValue: '', value: '', result: '', status: '' },
-                            { label: '下午温度', range: [], fixValue: '', value: '', result: '', status: '' },
-                            { label: '下午湿度', range: [], fixValue: '', value: '', result: '', status: '' }
+                            { label: '上午温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' },
+                            { label: '上午湿度', range: [], fixValue: '', value: '', result: '', status: '', unit: '%' },
+                            { label: '下午温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' },
+                            { label: '下午湿度', range: [], fixValue: '', value: '', result: '', status: '', unit: '%' }
                         ])
                         break
                     case '02-冰箱温度监控':
                         this.form.lie_biao_shu_ju_ = JSON.stringify([
-                            { label: '冷藏', range: [], fixValue: '', value: '', result: '', status: '' },
-                            { label: '冷冻', range: [], fixValue: '', value: '', result: '', status: '' }
+                            { label: '冷藏', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' },
+                            { label: '冷冻', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
                         ])
                         break
                     case '03-温浴箱温度监控':
                         this.form.lie_biao_shu_ju_ = JSON.stringify([
-                            { label: '温度', range: [], fixValue: '', value: '', result: '', status: '' }
+                            { label: '温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
                         ])
                         break
                     case '04-阴凉柜温度监控':
                         this.form.lie_biao_shu_ju_ = JSON.stringify([
-                            { label: '温度', range: [], fixValue: '', value: '', result: '', status: '' }
+                            { label: '温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
                         ])
                         break
                     default:
@@ -930,15 +932,22 @@ export default {
                         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_)
-                            sub.forEach((i, index) => {
-                                if (i.range.length === 0 || i.range === [null, null]) {
-                                    i.range = main[index].range
-                                }
-                                if (i.fixValue === '') {
-                                    i.fixValue = main[index].fixValue
-                                }
-                            })
-                            item.lie_biao_shu_ju_ = JSON.stringify(sub)
+                            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
+                                    }
+                                })
+                                item.lie_biao_shu_ju_ = JSON.stringify(sub)
+                            } else {
+                                item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
+                            }
                         }
                     })
                 })
@@ -1030,7 +1039,7 @@ export default {
         handleSelectionChange (val) {
             this.multipleSelection = val
         },
-        submit () {
+        async submit () {
             if (this.subForm.length === 0) {
                 return this.$message.warning('请添加子表数据')
             }
@@ -1088,7 +1097,7 @@ export default {
                         }
                     ]
                 }
-                this.$common.request('update', params).then(() => {
+                await this.$common.request('update', params).then(async () => {
                     console.log('主表更新数据成功')
                     if (addList.length) {
                         const params = {
@@ -1113,7 +1122,7 @@ export default {
                                 }
                             })
                         }
-                        this.$common.request('add', params).then(() => { console.log('子表添加数据成功') })
+                        await this.$common.request('add', params).then(() => { console.log('子表添加数据成功') })
                     }
                     if (updateList.length) {
                         const params = {
@@ -1139,14 +1148,14 @@ export default {
                                 }
                             }))
                         }
-                        this.$common.request('update', params).then(() => { console.log('子表更新数据成功') })
+                        await this.$common.request('update', params).then(() => { console.log('子表更新数据成功') })
                     }
                     if (deleteList.length) {
                         const params = {
                             tableName: 't_sshjpzxq',
                             paramWhere: { zi_wai_deng_wai_j: deleteList.join(',') }
                         }
-                        this.$common.request('delete', params).then(() => { console.log('子表删除数据成功') })
+                        await this.$common.request('delete', params).then(() => { console.log('子表删除数据成功') })
                     }
                     this.$nextTick(() => {
                         this.$message.success('修改成功!')
@@ -1160,7 +1169,7 @@ export default {
                         ...this.form
                     }]
                 }
-                this.$common.request('add', params).then((res) => {
+                await this.$common.request('add', params).then(async (res) => {
                     console.log('主表新增数据成功')
                     const { cont = [] } = res.variables || {}
                     if (addList.length) {
@@ -1186,7 +1195,7 @@ export default {
                                 }
                             })
                         }
-                        this.$common.request('add', params).then(() => {
+                        await this.$common.request('add', params).then(() => {
                             this.$message.success('添加成功!')
                             console.log('子表添加数据成功')
                             this.closeDialog()
@@ -1246,7 +1255,7 @@ export default {
                 }
 
                 // 执行所有请求
-                Promise.all(allRequests)
+                await Promise.all(allRequests)
                     .then(() => console.log('所有请求完成'))
                     .catch(error => console.error('请求出错:', error))
             }
@@ -1450,13 +1459,23 @@ export default {
         display: flex;
         width: 100%;
         justify-content: center;
-
+        .el-row{
+            margin: 0 !important;
+        }
+        .required{
+            color: #606266 !important;
+            &::before{
+                content: '*';
+                margin: 0 4px 0 -7.5px;
+                color: #F56C6C;
+            }
+        }
         .main{
             width: 80%;
             height: calc(100vh - 70px);
             box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
             padding:20px;
-            // overflow-y: auto;
+            overflow-y: auto;
             .form{
                 .el-row{
                     margin: 10px 0;

+ 4 - 2
src/views/system/fasc/fecDialog.vue

@@ -416,7 +416,7 @@ export default {
             const sql2 = `select * from t_jjqfjb where di_dian_='${pos}'`
             this.$common.request('sql', sql2).then(res => {
                 const { data = [] } = res.variables || {}
-                this.fangJianList = data
+                this.fangJianList = data.filter(item => item.fang_jian_ming_ha)
             })
         },
         // 格式化数据
@@ -619,7 +619,9 @@ export default {
             margin: 10px 0;
         }
     }
-
+    .el-row{
+            margin: 0 !important;
+    }
 }
 .dialog-footer{
         display: flex;