Bläddra i källkod

wanda-adm:feat > 数据维护相关问题

shaun-sheep 4 år sedan
förälder
incheckning
bb73e5b289

+ 10 - 0
src/api/datacenter.ts

@@ -86,6 +86,16 @@ export function queryCountSystem(postParams: any): any {
     return httputils.postJson(`${ baseApi }/object/system/count`, postParams)
 }
 
+// 创建系统信息
+export function createSystem(postParams: any): any {
+    return httputils.postJson(`${ baseApi }/object/system/create`, postParams)
+}
+
+// 更新系统信息
+export function updateSystem(postParams: any): any {
+    return httputils.postJson(`${ baseApi }/object/system/update`, postParams)
+}
+
 // 查询空间统计
 export function queryCountSpace(postParams: any): any {
     return httputils.postJson(`${ baseApi }/object/zone/count`, postParams)

+ 2 - 3
src/components/business/baseDataForm.vue

@@ -54,7 +54,7 @@
                                     v-else-if="item.dataType == 'ATTACHMENT'&& item.path === 'infos.Pic'"
                                     :readOnly="false"
                                     v-model="form[item.path]"
-                                    :keysArr="Array.isArray(buildData[item.path]) ? buildData[item.path]:[]"
+                                    :keysArr="Array.isArray(form[item.path]) ? form[item.path]:[]"
                                     :context-key="item.path"
                                     :isShow="1"
                                     @change="changeItem"/>
@@ -64,7 +64,7 @@
                                     v-model="form[item.path]"
                                     :readOnly="false"
                                     :isShow="1"
-                                    :keys-arr="Array.isArray(buildData[item.path]) ? buildData[item.path]:[] "
+                                    :keys-arr="Array.isArray(form[item.path]) ? form[item.path]:[] "
                                     :show-file-list="false"
                                     :context-key="item.path"
                                     @change="changeItem"/>
@@ -113,7 +113,6 @@ function flattenKeys(obj: any) {
 export default class extends Vue {
     header = {}
     form = {}
-    buildData = {}
     @Prop({ default: Object }) objectHeaders ?: {}
     @Prop({ default: Object }) currRowContent ?: {}
 

+ 28 - 20
src/components/business/dataForm.vue

@@ -64,7 +64,7 @@
                                         v-else-if="item.dataType == 'ATTACHMENT'&& item.path === 'infos.Pic'"
                                         :readOnly="false"
                                         v-model="form[item.path]"
-                                        :keysArr="Array.isArray(buildData[item.path]) ? buildData[item.path]:[]"
+                                        :keysArr="Array.isArray(form[item.path]) ? form[item.path]:[]"
                                         :context-key="item.path"
                                         :isShow="1"
                                         @change="changeItem"/>
@@ -74,7 +74,7 @@
                                         v-model="form[item.path]"
                                         :readOnly="false"
                                         :isShow="1"
-                                        :keys-arr="Array.isArray(buildData[item.path]) ? buildData[item.path]:[] "
+                                        :keys-arr="Array.isArray(form[item.path]) ? form[item.path]:[] "
                                         :show-file-list="false"
                                         :context-key="item.path"
                                         @change="changeItem"/>
@@ -125,13 +125,12 @@ function flattenKeys(obj: any) {
 })
 export default class extends Vue {
     // tabs数据
-    paneMsg = ['设计阶段维护', '施工阶段维护', '运维阶段维护']
     activeName = ""
     header = {}
     form = {}
+    paneMsg = []
     // 默认当前阶段
-    currentHeader = this.paneMsg[0]
-    buildData = {}
+    currentHeader = ''
     @Prop({ default: Object }) deviceHeaders ?: {}
     @Prop({ default: Object }) currRowContent ?: {}
 
@@ -148,25 +147,34 @@ export default class extends Vue {
     @Watch('deviceHeaders', { immediate: true, deep: true })
     changeHeaders() {
         this.$nextTick(() => {
-            let header = []
+            let pic = [], base = []
             if (typeof this.deviceHeaders == 'object' && Object.keys(this.deviceHeaders).length > 0) {
+                this.paneMsg = this.deviceHeaders.dictStages.map(i => i.name)
+                let currentHeader = this.paneMsg[0]
+                this.currentHeader = this.currentHeader || currentHeader
                 this.deviceHeaders.dictStages.length > 0 && this.deviceHeaders.dictStages.forEach(item => {
                     if (this.currentHeader == item.name) {
-                        item.infos && item.infos.forEach(val => header.push(val))
+                        item.infos && item.infos.forEach(val => {
+                            if (val.dataType == 'ATTACHMENT') {
+                                pic.push(val)
+                            } else {
+                                base.push(val)
+                            }
+                        })
                     }
                 })
-                header.map(item => {
-                    const category = ['ENUM', 'MENUM', 'BOOLEAN']
-                    if (item.category == 'STATIC' && item.dataType.includes(category) && item.dataSource) {
-                        item.props = {
-                            value: 'code',
-                            label: 'name',
-                            children: 'content',
-                            checkStrictly: true
-                        }
-                    }
-                    return item
-                })
+                // 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: {
@@ -175,7 +183,7 @@ export default class extends Vue {
                 },
                 dictStages: {
                     name: this.currentHeader,
-                    data: header
+                    data: pic.length > 0 ? [...base, ...pic] : [...base]
                 }
             }
         })

+ 8 - 0
src/components/public/adm-multi-table.vue

@@ -63,6 +63,14 @@ export default class extends Vue {
                 this.tableDom.doLayout();
         });
     }
+
+    @Watch("tableData", { immediate: true, deep: true })
+    handleTableData(o, n) {
+        this.$nextTick(() => {
+            console.log(o, n)
+            // this.tableData = this.tableData
+        })
+    }
 }
 </script>
 

+ 24 - 14
src/views/maintain/device/index.vue

@@ -49,7 +49,6 @@
                             <el-cascader :options="list" clearable v-model="deviceVal"
                                          :props="optionProps"
                                          class="adm-select"></el-cascader>
-
                         </div>
                         <el-button type="primary" class="fr" @click="handleNext">下一步</el-button>
                     </template>
@@ -62,7 +61,7 @@
                     </template>
                     <template v-else>
                         <div>
-                            <dataForm :deviceHeaders="deviceHeaders" ref="dataForm" :currRowContent="currRowContent"/>
+                            <dataForm :deviceHeaders="deviceHeaders" ref="dataForm"/>
                         </div>
                         <span slot="footer" class="dialog-footer">
                          <el-button type="primary" @click="handleDataForm">确 定</el-button>
@@ -143,7 +142,7 @@ export default class extends Vue {
     // 弹窗开关
     dialogVisible = false
     // tabs数据
-    paneMsg = ['设计阶段维护', '施工阶段维护', '运维阶段维护']
+    paneMsg = []
     // 当前tabs值
     activeName = ""
     // 分页
@@ -158,7 +157,7 @@ export default class extends Vue {
     // 弹窗 title
     deviceMsg = '添加设备'
     // 默认当前阶段
-    currentHeader = this.paneMsg[0]
+    currentHeader = ''
     // 主体数据
     tableData = []
     codeToDataSource = {}
@@ -197,7 +196,6 @@ export default class extends Vue {
         })
     }
 
-
     handleChangeDevice() {
         if (this.deviceType[1]) {
             this.loading = true
@@ -229,6 +227,8 @@ export default class extends Vue {
                 // 类型下信息点,默认设计阶段
                 this.headerInformation = res[0] // 获取表头
                 this.tableData = res[1].content // 主体数据
+                this.paneMsg = res[0].dictStages.map(i => i.name)
+                this.currentHeader = this.paneMsg[0]
                 this.headerStage()
                 this.paginationList.total = res[1].total
             })
@@ -252,11 +252,17 @@ export default class extends Vue {
     }
 
     headerStage() {
-        let header: [] = []
+        let pic = [], base = []
         if (Object.keys(this.headerInformation).length > 0) {
             this.headerInformation.dictStages.forEach(item => {
                 if (this.currentHeader == item.name) {
-                    item.infos && item.infos.forEach(val => header.push(val))
+                    item.infos && item.infos.forEach(val => {
+                        if (val.dataType == 'ATTACHMENT') {
+                            pic.push(val)
+                        } else {
+                            base.push(val)
+                        }
+                    })
                 }
             })
         }
@@ -267,11 +273,12 @@ export default class extends Vue {
             },
             dictStages: {
                 name: this.currentHeader,
-                data: header
+                data: pic.length > 0 ? [...base, ...pic] : [...base]
             }
         }
         // 信息点集合
-        this.all = [...this.headerInformation.basicInfos, ...header]
+        this.all = [...this.headersStage.basicInfos.data, ...this.headersStage.dictStages.data]
+        console.log(this.all, 'all')
         this.codeToDataSource = {}
         this.all.forEach(item => {
             if (item.dataSource) {
@@ -331,7 +338,10 @@ export default class extends Vue {
                                         tools.setDataForKey(
                                             item,
                                             head.path,
-                                            child.error
+                                            child.error ? child.value
+                                                ? "表号功能号格式错误"
+                                                : "表号功能号不存在"
+                                                : "暂未采集到实时数据"
                                         );
                                     }
                                 });
@@ -386,7 +396,7 @@ export default class extends Vue {
     // 添加 事件处理
     handleDataForm() {
         const eq = tools.formatData(this.$refs.dataForm.form);
-        if (eq.id) { 
+        if (eq.id) {
             //更新
             this.handleUpdateEquip(eq);
         } else {
@@ -429,13 +439,15 @@ export default class extends Vue {
             this.curEquip.buildingId = data.buildingId;
             this.curEquip.floorId = data.floorId;
         }
-        if (this.curEquip.id) { 
+        if (this.curEquip.id) {
             //更新
             this.handleUpdateEquip(this.curEquip);
+            this.handleChangeDevice()
         } else {
             this.curEquip.classCode = this.deviceVal[1]
             // 创建
             this.handleCreateEquip(this.curEquip);
+            this.handleChangeDevice()
         }
     }
     // 更新设备
@@ -450,7 +462,6 @@ export default class extends Vue {
             if (res.result == 'success') {
                 this.$message.success('更新成功');
                 this.dialogVisible = false;
-                this.handleChangeDevice()
             }
         })
     }
@@ -466,7 +477,6 @@ export default class extends Vue {
             if (res.result == 'success') {
                 this.$message.success('创建成功');
                 this.dialogVisible = false;
-                this.handleChangeDevice()
             }
         })
     }

+ 27 - 25
src/views/maintain/space/index.vue

@@ -83,7 +83,7 @@ export default class spaceIndex extends Vue {
     loading = false;
     private statisticsMsg = {
         title: "全部空间",
-        total: 93640,
+        total: 0,
     };
     currentHeader = "租赁系统";
     activeName = "table";
@@ -247,7 +247,6 @@ export default class spaceIndex extends Vue {
             });
             this.options = data;
             let arr = data.filter((item) => item.children);
-            console.log(arr);
         });
 
         const pa = {
@@ -277,11 +276,7 @@ export default class spaceIndex extends Vue {
         });
     }
     //改变楼层
-    changeCascader(value) {
-        //todo delete
-        // if (value && value.length > 0  && this.building[0] != 'all') {
-        //     this.buildingLabel = this.$refs['floorCascader'].getCheckedNodes()[0].pathLabels
-        // }
+    changeCascader() {
         if (this.building.length > 0) {
             this.loading = true;
             let param = {
@@ -310,7 +305,6 @@ export default class spaceIndex extends Vue {
                         break;
                     case "all":
                         delete param2.filters;
-
                         break;
                 }
             } else if (this.building.length === 2) {
@@ -393,10 +387,14 @@ export default class spaceIndex extends Vue {
                     if (item.outline) {
                         delete item.outline;
                     }
-                    // const category = ['ENUM', 'MENUM', 'BOOLEAN']
-                    // if (item.category == 'STATIC' && item.dataType.includes(category) && item.dataSource) {
-                    //     console.log(item, item.path)
-                    // }
+                    // 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)
+                    //         }
+                    //     }
+                    // })
 
                     // item = {
                     //     ...item,
@@ -408,11 +406,6 @@ export default class spaceIndex extends Vue {
                 //  列表信息展示,获取动态数据
                 this.codeToDataSource = {};
                 this.all.forEach((item) => {
-                    const category = ['ENUM', 'MENUM', 'BOOLEAN']
-                    console.log(item.category,item.dataType)
-                    if (item.category == 'STATIC' && item.dataType.includes(category) && item.dataSource) {
-                        console.log(21)
-                    }
                     if (item.dataSource) {
                         try {
                             this.codeToDataSource[item.code] = {};
@@ -424,7 +417,7 @@ export default class spaceIndex extends Vue {
                             console.log(e);
                         }
                     }
-                    console.log(this.codeToDataSource,' this.codeToDataSource')
+                    // console.log(this.codeToDataSource,' this.codeToDataSource')
                 });
                 this.getBatch(this.tableData);
             });
@@ -438,6 +431,7 @@ export default class spaceIndex extends Vue {
     }
     // 动态信息点
     getBatch(data) {
+
         let param = {
             groupCode: "WD",
             appId: "datacenter",
@@ -482,7 +476,10 @@ export default class spaceIndex extends Vue {
                                         tools.setDataForKey(
                                             item,
                                             head.path,
-                                            child.error
+                                            child.error ? child.value
+                                                ? "表号功能号格式错误"
+                                                : "表号功能号不存在"
+                                                : "暂未采集到实时数据"
                                         );
                                     }
                                 });
@@ -518,12 +515,14 @@ export default class spaceIndex extends Vue {
             content: [from]
         }
         updateZone(param).then(res => {
-            res.result == 'success' && this.$message.success('更新成功')
-            this.dialogVisible = false
-            // this.getData();
-            // this.dataCount();
-            // 默认显示全部建筑信息
-            this.changeCascader();
+            if (res.result == 'success') {
+                this.$message.success('更新成功')
+                this.dialogVisible = false
+                // 默认显示全部建筑信息
+                this.changeCascader();
+            }
+
+
         })
     }
 
@@ -542,6 +541,9 @@ export default class spaceIndex extends Vue {
     handleCurrentEdit(val) {
         // this.next = false
         this.currRowContent = 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

+ 64 - 18
src/views/maintain/system/index.vue

@@ -14,9 +14,11 @@
         <div class="content">
             <div v-loading="loading" class="table">
                 <template v-if="systemType.length > 0">
-                    <admMultiTable @handleCurrentEdit="handleCurrentEdit"
-                                   :currentHeader="currentHeader"
-                                   :headersStage="headersStage" :tableData="tableData"/>
+                    <admMultiTable
+                        @handleCurrentEdit="handleCurrentEdit"
+                        :currentHeader="currentHeader"
+                        :headersStage="headersStage"
+                        :tableData="tableData"/>
                     <Pagination
                         :paginationList="paginationList"
                         @handleCurrentChange="handleCurrentChange"
@@ -32,7 +34,7 @@
             </div>
         </div>
         <!--        添加/编辑 系统-->
-        <el-dialog :title=" systemMsg" :visible.sync="dialogVisible" @close="close">
+        <el-dialog :title="systemMsg" :visible.sync="dialogVisible" @close="close">
             <template v-if="next">
                 <div class="align" style="height: 400px">
                     <span class="text">系统类别</span>
@@ -58,9 +60,9 @@
 </template>
 
 <script lang="ts">
-import { Component, Vue } from "vue-property-decorator";
+import { Component, Vue, Watch } from "vue-property-decorator";
 import { AdmMultiTable, AdmSearch, baseDataForm, Pagination, Statistics } from "../components/index";
-import { dictQuery, queryCountSystem, querySystem } from "@/api/datacenter";
+import { createSystem, dictQuery, queryCountSystem, querySystem, updateSystem } from "@/api/datacenter";
 import tools from "@/utils/maintain";
 import { UserModule } from "@/store/modules/user";
 import { allSystem, BeatchQueryParam } from "@/api/equipComponent";
@@ -159,7 +161,7 @@ export default class extends Vue {
                 });
             }
         });
-        if (param.data.length) {
+        if (param.data.length >0 ) {
             BeatchQueryParam(param).then((res) => {
                 this.tableData = data.map((item) => {
                     res.data.map((child) => {
@@ -177,7 +179,10 @@ export default class extends Vue {
                             } else {
                                 this.all.map((head) => {
                                     if (head.code == child.infoCode) {
-                                        tools.setDataForKey(item, head.path, child.error);
+                                        tools.setDataForKey(item, head.path, child.error ? child.value
+                                            ? "表号功能号格式错误"
+                                            : "表号功能号不存在"
+                                            : "暂未采集到实时数据");
                                     }
                                 });
                             }
@@ -208,23 +213,31 @@ export default class extends Vue {
 
     // 添加设备
     addDevice() {
+        this.systemMsg = '添加系统'
+        this.currRowContent = {}
         this.dialogVisible = true;
     }
 
     //下一步事件
     async handleNext() {
-        if (this.systemVal[1] || this.systemType[1]) {
+        if (this.systemVal[1]) {
             this.next = false
             let param = {
-                type: this.systemVal[1] || this.systemType[1],
+                type: this.systemVal[1],
                 orders: "sort asc, name desc",
             };
 
             await dictQuery(param).then(res => {
                 let { basicInfos, dictStages } = this.informationArrangement(res.content)
                 // 添加系统分类
-                dictStages = dictStages.map((item) => {
+                let pic = [], base = []
+                dictStages.map((item) => {
                     item = { ...item, classification: this.systemLabel };
+                    if (item.dataType == 'ATTACHMENT') {
+                        pic.push(item)
+                    } else {
+                        base.push(item)
+                    }
                     return item;
                 });
                 this.systemHeaders = {
@@ -234,7 +247,7 @@ export default class extends Vue {
                     },
                     dictStages: {
                         name: "运维阶段",
-                        data: dictStages,
+                        data: pic.length > 0 ? [...base, ...pic] : [...base],
                     },
                 };
             })
@@ -245,12 +258,18 @@ export default class extends Vue {
 
     // close
     close() {
+        if (this.systemType) {
+            this.systemVal = this.systemType
+        } else {
+            this.systemVal = ''
+        }
         this.next = true;
     }
 
     // 编辑当前行
     handleCurrentEdit(val) {
         this.next = false
+        this.systemMsg = '编辑系统'
         this.currRowContent = val
         this.handleNext()
         this.dialogVisible = true
@@ -275,7 +294,7 @@ export default class extends Vue {
         }
     }
 
-    private changeSystemList() {
+    changeSystemList() {
         if (this.systemType[1]) {
             let systemLabel = this.$refs["floorCascader"].getCheckedNodes()[0].pathLabels;
             this.systemLabel = systemLabel[1];
@@ -288,7 +307,7 @@ export default class extends Vue {
                 filters: this.systemType[1] ? `classCode='${ this.systemType[1] }'` : undefined,
                 pageNumber: this.paginationList.page,
                 pageSize: this.paginationList.size,
-                orders: "createTime desc, id asc",
+                orders: "createTime asc, id asc",
                 projectId: this.projectId,
             };
             if (this.inputSearch != "") {
@@ -309,8 +328,6 @@ export default class extends Vue {
                 this.loading = false;
                 // 类型下信息点,重组数据
                 let { basicInfos, dictStages } = this.informationArrangement(res[0].content)
-
-
                 this.headersStage = {
                     basicInfos: {
                         name: "基础信息台账",
@@ -350,10 +367,39 @@ export default class extends Vue {
     }
 
     // 添加/编辑 事件处理
-    handleDataForm() {
-        console.log(this.$refs.baseDataForm.form)
+    async handleDataForm() {
+        let from = tools.formatData(this.$refs.baseDataForm.form)
+        //编辑
+        if (Object.keys(this.currRowContent).length > 0) {
+            let param = {
+                content: [from]
+            }
+            updateSystem(param).then(res => {
+                res.result == 'success' && this.$message.success('更新成功')
+                this.dialogVisible = false
+                setTimeout(() => this.changeSystemList())
+            })
+        } else {
+            //添加
+            from = {
+                ...from,
+                classCode: this.systemVal[1]
+            }
+            let param = {
+                content: [from]
+            }
+            createSystem(param).then(res => {
+                res.result == 'success' && this.$message.success('添加成功')
+                this.dialogVisible = false
+                this.changeSystemList()
+            })
+        }
     }
 
+    @Watch("systemType", { immediate: true, deep: true })
+    handleDeviceMsg() {
+        this.systemVal = this.systemType
+    }
 }
 </script>