ソースを参照

wanda-adm:feat > 回显问题

shaun-sheep 4 年 前
コミット
897a0c129b

+ 26 - 10
src/components/business/baseDataForm.vue

@@ -1,6 +1,6 @@
 <template>
     <el-row :gutter="20" class="data-form">
-        <el-form label-position="top" label-width="300px" :model="form">
+        <el-form label-position="top" label-width="300px" :model="form" :rules="rules" ref="form">
             <template v-if="Object.keys(objectHeaders).length > 0">
                 <div v-for="obj in objectHeaders" :key="obj.name">
                     <p class="title"> {{ obj.name }}</p>
@@ -8,18 +8,17 @@
                         <el-col :span="item.dataType == 'ATTACHMENT'? 24:8"
                                 :key="item.path"
                                 v-for="item in obj.data"
-                                :style="{ 'height':item.dataType == 'ATTACHMENT'? 'auto':'93px' }"
-                        >
-                            <el-form-item :label="item.name">
+                                :style="{ 'height':item.dataType == 'ATTACHMENT'? 'auto':'93px' }">
+                            <el-form-item :label="item.name" :prop="item.code">
+                                <el-input
+                                    v-if="item.path == 'classification' || item.path=='buildingSign' || item.path=='floorSign'"
+                                    v-model="form[item.path]"
+                                    disabled/>
                                 <el-input
                                     :disabled="!item.editable"
-                                    v-if="item.dataType == 'STRING'"
+                                    v-else-if="item.dataType == 'STRING'"
                                     v-model="form[item.path]"/>
-                                <el-input
-                                    v-else-if="item.path == 'classification'"
-                                    v-model="form[item.path]"
-                                    disabled
-                                />
+
                                 <el-input
                                     v-else-if="item.dataType == 'DOUBLE' || item.dataType == 'INTEGER'"
                                     type="number"
@@ -111,6 +110,12 @@ function flattenKeys(obj: any) {
     components: { uploadFiles, uploadImgs }
 })
 export default class extends Vue {
+    rules = {
+        'localName': [{ required: true, message: '请填写本地名称', trigger: 'blur' }],
+        'localId': [{ required: true, message: '请填写本地编码', trigger: 'blur' }],
+        'buildingSign': [{ required: true, message: '请填写建筑', trigger: 'blur' }],
+        'floorSign': [{ required: true, message: '请填写本地楼层', trigger: 'blur' }]
+    }
     header = {}
     form = {}
     @Prop({ default: Object }) objectHeaders ?: {}
@@ -125,6 +130,7 @@ export default class extends Vue {
         })
 
     }
+
     changeItem(val) {
         console.log(val)
         let _key = Object.keys(val)[0] + '';
@@ -132,6 +138,16 @@ export default class extends Vue {
 
     }
 
+    submitForm(callback) {
+        this.$refs.form.validate((valid) => {
+            if (valid) {
+                callback()
+            } else {
+                return false;
+            }
+        });
+    }
+
 }
 
 </script>

+ 18 - 13
src/components/business/dataForm.vue

@@ -1,11 +1,12 @@
 <template>
     <el-row :gutter="20" class="data-form">
-        <el-form label-position="top" label-width="300px" :model="form">
+        <el-form label-position="top" ref="form" label-width="300px" :model="form" :rules="rules">
             <template v-if="Object.keys(header).length > 0">
                 <p class="title">基础信息</p>
                 <el-row :gutter="18">
                     <el-col :span="8" :key="item.path" v-for="item in header.basicInfos.data">
                         <el-form-item
+                            :prop="item.path"
                             :label="item.name">
                             <el-input v-model="form[item.path]"/>
                         </el-form-item>
@@ -124,6 +125,12 @@ function flattenKeys(obj: any) {
     components: { uploadFiles, uploadImgs }
 })
 export default class extends Vue {
+    rules = {
+        bimTypeId: [{ required: true, message: "请填写BIM构件编码", trigger: 'blur' }],
+        systemCategory: [{ required: true, message: "请填写系统分类", trigger: 'blur' }],
+        codeName: [{ required: true, message: "请填写设备类型名称", trigger: 'blur' }],
+        localId: [{ required: true, message: "请填写本地编码", trigger: 'blur' }],
+    }
     // tabs数据
     activeName = ""
     header = {}
@@ -163,18 +170,6 @@ export default class extends Vue {
                         })
                     }
                 })
-                // header.map(item => {
-                //     const category = ['ENUM', 'MENUM', 'BOOLEAN']
-                //     if (item.category == 'STATIC' && category.includes(item.dataType) && item.dataSource) {
-                //         item.props = {
-                //             value: 'code',
-                //             label: 'name',
-                //             children: 'content',
-                //             checkStrictly: true
-                //         }
-                //     }
-                //     return item
-                // })
             }
             this.header = {
                 basicInfos: {
@@ -200,6 +195,16 @@ export default class extends Vue {
         this.currentHeader = val.label
         this.changeHeaders()
     }
+
+    submitForm(callback) {
+        this.$refs.form.validate((valid) => {
+            if (valid) {
+                callback()
+            } else {
+                return false;
+            }
+        });
+    }
 }
 
 </script>

+ 1 - 10
src/components/public/adm-multi-table.vue

@@ -49,13 +49,11 @@ export default class extends Vue {
 
     @Emit('handleCurrentEdit')
     handleEdit(index, row) {
+        console.log(index, row)
         return row
     }
 
 
-    created() {
-    }
-
     @Watch("headersStage", { immediate: true, deep: true })
     onCurrentHeaderChange() {
         this.$nextTick(() => {
@@ -64,13 +62,6 @@ export default class extends Vue {
         });
     }
 
-    @Watch("tableData", { immediate: true, deep: true })
-    handleTableData(o, n) {
-        this.$nextTick(() => {
-            console.log(o, n)
-            // this.tableData = this.tableData
-        })
-    }
 }
 </script>
 

+ 11 - 4
src/views/maintain/device/index.vue

@@ -78,9 +78,7 @@
                         </span>
                     </template>
                     <template v-else>
-
                             <dataForm :deviceHeaders="deviceHeaders" ref="dataForm" :currRowContent="currRowContent"/>
-
                         <span slot="footer" class="dialog-footer">
                          <el-button type="primary" @click="handleDataForm">确 定</el-button>
                          <el-button @click="handlePosition">维护位置</el-button>
@@ -278,7 +276,6 @@ export default class extends Vue {
         }
         // 信息点集合
         this.all = [...this.headersStage.basicInfos.data, ...this.headersStage.dictStages.data]
-        console.log(this.all, 'all')
         this.codeToDataSource = {}
         this.all.forEach(item => {
             if (item.dataSource) {
@@ -389,12 +386,20 @@ export default class extends Vue {
 
     // 维护位置
     handlePosition() {
+        this.$refs.dataForm.submitForm(this.handlePositionSave)
+    }
+
+    handlePositionSave() {
         this.curEquip = tools.formatData(this.$refs.dataForm.form)
         this.displayLocation = true
     }
 
     // 添加 事件处理
     handleDataForm() {
+        this.$refs.dataForm.submitForm(this.handleDataFormSave)
+    }
+
+    handleDataFormSave() {
         const eq = tools.formatData(this.$refs.dataForm.form);
         if (eq.id) {
             //更新
@@ -432,10 +437,12 @@ export default class extends Vue {
     }
     // 保存
     saveLocation() {
+        alert(1)
+        return
         // @ts-ignore
         const data = this.$refs.deviceGraph.getLocation()
         if (data) {
-            this.curEquip.bimLocation = `${data.x},${data.y},${data.z}`;
+            this.curEquip.bimLocation = `${ data.x },${ data.y },${ data.z }`;
             this.curEquip.buildingId = data.buildingId;
             this.curEquip.floorId = data.floorId;
         }

+ 58 - 12
src/views/maintain/space/index.vue

@@ -246,7 +246,6 @@ export default class spaceIndex extends Vue {
                 });
             });
             this.options = data;
-            let arr = data.filter((item) => item.children);
         });
 
         const pa = {
@@ -387,14 +386,28 @@ export default class spaceIndex extends Vue {
                     if (item.outline) {
                         delete item.outline;
                     }
-                    // this.all.forEach(i=> {
-                    //     const category = ['ENUM', 'MENUM', 'BOOLEAN']
-                    //     if (i.category == 'STATIC' && category.includes(i.dataType) && i.dataSource) {
-                    //         if(i.path == item.path) {
-                    //             console.log(item)
-                    //         }
-                    //     }
-                    // })
+                    this.all.forEach(i => {
+                        const category = ['ENUM', 'MENUM', 'BOOLEAN']
+                        if (i.category == 'STATIC' && category.includes(i.dataType) && i.dataSource) {
+                            let inx = i.path.substr(i.path.indexOf('.') + 1)
+                            for (let l in item) {
+                                if (l == inx) {
+                                    if (i.dataSource) {
+                                        item[l] = i.dataSource.filter(i => item[l].includes(i.code)).map(item => item.name).join(',')
+                                    }
+                                }
+                            }
+                        }
+                        if (i.category == 'STATIC' && i.dataType == 'ATTACHMENT') {
+                            let inx = i.path.substr(i.path.indexOf('.') + 1)
+                            for (let l in item) {
+                                if (l == inx) {
+                                    item['sign/' + inx] = item[l]
+                                    item[l] = item[l].length
+                                }
+                            }
+                        }
+                    })
 
                     // item = {
                     //     ...item,
@@ -426,7 +439,7 @@ export default class spaceIndex extends Vue {
         }
     }
     // 图建筑楼层修改
-    changeGraphCascader(value) {
+    changeGraphCascader() {
         this.toGraph();
     }
     // 动态信息点
@@ -510,6 +523,10 @@ export default class spaceIndex extends Vue {
 
     // 添加/编辑 事件处理
     handleDataForm() {
+        this.$refs.baseDataForm.submitForm(this.handleDataFormSave)
+    }
+
+    handleDataFormSave() {
         let from = tools.formatData(this.$refs.baseDataForm.form)
         let param = {
             content: [from]
@@ -539,13 +556,42 @@ export default class spaceIndex extends Vue {
 
     // 编辑当前行
     handleCurrentEdit(val) {
-        // this.next = false
+        // this.tableData.map(item => {
+            this.all.forEach(i => {
+                const category = ['ENUM', 'MENUM', 'BOOLEAN']
+                if (i.category == 'STATIC' && category.includes(i.dataType) && i.dataSource) {
+                    let inx = i.path.substr(i.path.indexOf('.') + 1)
+                    // for (let l in item) {
+                    //     if (l == inx) {
+                    //         if (i.dataSource) {
+                    //             item[l] = i.dataSource.filter(i => item[l].includes(i.name)).map(item => item.code).join(',')
+                    //         }
+                    //     }
+                    // }
+                    for (let l in val) {
+                        if (l == inx) {
+                            if (i.dataSource) {
+                                val[l] = i.dataSource.filter(i => val[l].includes(i.name)).map(item => item.code).join(',')
+                            }
+                        }
+                    }
+                }
+                if (i.category == 'STATIC' && i.dataType == 'ATTACHMENT') {
+                    let inx = i.path.substr(i.path.indexOf('.') + 1)
+                    // for (let l in item) {
+                    //     if (l == inx) {
+                    //         item[l] = item['sign/' + inx]
+                    //     }
+                    // }
+                }
+            })
+        // })
         this.currRowContent = val
+        console.log(val)
         let pic = this.headersStage.dictStages.data.filter(i => i.dataType == 'ATTACHMENT')
         let base = this.headersStage.dictStages.data.filter(i => i.dataType != 'ATTACHMENT')
         this.headersStage.dictStages.data = pic.length > 0 ? [...base, ...pic] : [...base]
         this.spaceHeaders = this.headersStage
-        // this.handleNext()
         this.dialogVisible = true
     }
 

+ 20 - 1
src/views/maintain/system/index.vue

@@ -277,7 +277,7 @@ export default class extends Vue {
 
     //信息点重组
     informationArrangement(arr: []): object {
-        let basicInfos = [{ path: "classification", name: "系统分类" }],
+        let basicInfos = [{ path: "classification", name: "系统分类"}],
             dictStages: any[] = [];
         this.all = arr;
         arr.forEach((item: any) => {
@@ -342,6 +342,17 @@ export default class extends Vue {
                 tableData = res[1].content; // 主体数据
                 // 添加系统分类
                 this.tableData = tableData.map((item) => {
+                    // this.all.forEach(i=> {
+                    //     const category = ['ENUM', 'MENUM', 'BOOLEAN']
+                    //     if (i.category == 'STATIC' && category.includes(i.dataType) && i.dataSource) {
+                    //         let inx = i.path.substr(i.path.indexOf('.') + 1)
+                    //         for(let i in item) {
+                    //             if(inx == i) {
+                    //                 console.log(i,'ppppp')
+                    //             }
+                    //         }
+                    //     }
+                    // })
                     item = { ...item, classification: this.systemLabel };
                     return item;
                 });
@@ -368,6 +379,11 @@ export default class extends Vue {
 
     // 添加/编辑 事件处理
     async handleDataForm() {
+        this.$refs.baseDataForm.submitForm(this.handleDataFormSave)
+
+    }
+
+    handleDataFormSave() {
         let from = tools.formatData(this.$refs.baseDataForm.form)
         //编辑
         if (Object.keys(this.currRowContent).length > 0) {
@@ -497,6 +513,9 @@ $border: 1px solid #e1e7ea;
     .el-select, .el-date-editor.el-input, .el-date-editor.el-input__inner {
         width: 100%;
     }
+    .el-dialog__header {
+        border-bottom: 1px solid #D8D8D8;
+    }
 
     .fr {
         float: right;