소스 검색

控制系统交互

shaun-sheep 5 년 전
부모
커밋
d9c972daa3

+ 17 - 0
src/api/relation/api.js

@@ -134,3 +134,20 @@ export function dictUpdate(param, success) {
   let url = '/api/equip-component/dict-custom/update'
   httpUtil.postJson(url, param, success)
 }
+
+// 查询关系数据
+export function relQuery(param,success) {
+  let url = '/api/datacenter/relation-manual-calc/rel-query'
+  httpUtil.postJson(url,param,success)
+}
+//添加关系数据
+export function relAdd(data) {
+  let userName = storage.get("user_name")
+  let ProjectId = localStorage.getItem("projectId")
+  return fetch({
+    method: 'POST',
+    url: `/api/datacenter/relation-manual-calc/rel-add`,
+    data,
+    headers: {'ProjectId': ProjectId, 'Comming': 'adm', 'Account': userName}
+  })
+}

+ 13 - 14
src/components/data_admin/buildTask/taskStatistics.vue

@@ -35,19 +35,18 @@
 </template>
 
 <script>
-import { mapGetters } from "vuex"
-import { queryTaskCount, countAssetsTask } from "@/api/data_admin/buildTaskApi"
-export default {
-  components: {
-    
-  },
-  computed: {
-    ...mapGetters("layout", ["projectId", "secret", "userId" ]),
-    taskProgress(){
-      if(typeof this.alreadyCount == 'number' && typeof this.allCount == 'number'){
-        return Math.round(this.alreadyCount/this.allCount*100)
+  import {mapGetters} from "vuex"
+  import {countAssetsTask, queryTaskCount} from "@/api/data_admin/buildTaskApi"
+
+  export default {
+    components: {},
+    computed: {
+      ...mapGetters("layout", ["projectId", "secret", "userId"]),
+      taskProgress() {
+        if (typeof this.alreadyCount == 'number' && typeof this.allCount == 'number') {
+          return Math.round(this.alreadyCount / this.allCount * 100)
+        }
       }
-    }
   },
   data() {
     return {
@@ -124,7 +123,7 @@ export default {
           flex: 1;
           font-size: 15px;
           line-height: 35px;
-        } 
+        }
       }
     }
     .statistics-list{
@@ -157,4 +156,4 @@ export default {
     display: flex;
 		flex-direction: column;
   }
-</style>
+</style>

+ 1 - 0
src/components/relation/overview/CardList.vue

@@ -259,6 +259,7 @@
             this.$router.push({
               path:"relationShip"
             })
+          localStorage.setItem('RelManualType',relation.RelManualType)
           } else {
             this.$message.warning("设计中")
             return false

+ 59 - 10
src/components/relation/relationShip/Modal/addRelationShip.vue

@@ -13,16 +13,29 @@
         class="demo-ruleForm"
       >
         <p class="mb-20 color-AAA">{{values.codeTip}}</p>
+<!--        <el-form-item-->
+<!--          :label="values.codeTitle"-->
+<!--          prop="code"-->
+<!--          class="mb-20"-->
+<!--        >-->
+<!--          <el-input-->
+<!--            v-model="ruleForm.code"-->
+<!--            autocomplete="off"-->
+<!--            :placeholder="values.pleaseEnter"-->
+<!--          />-->
+<!--        </el-form-item>-->
         <el-form-item
           :label="values.codeTitle"
-          prop="code"
           class="mb-20"
         >
-          <el-input
-            v-model="ruleForm.code"
-            autocomplete="off"
-            :placeholder="values.pleaseEnter"
-          />
+          <el-select v-model="codeValue" placeholder="请选择">
+            <el-option
+              v-for="item in optionsCode"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value">
+            </el-option>
+          </el-select>
         </el-form-item>
         <el-row class="mb-20">
           <el-col :span="12">
@@ -101,7 +114,6 @@
       var checkCode = (rule, value, callback) => {
         //TODO
         callback()
-        this.disabled = false
       }
       var checkMain = (rule, value, callback) => {
         //TODO
@@ -113,7 +125,24 @@
       }
       return {
         addShipDialog: false,
-        disabled: true,
+        // disabled: true,
+        optionsCode: [{
+          value: 'cadId',
+          label: 'CADID图纸编码'
+        }, {
+          value: 'name',
+          label: '设备名称'
+        }, {
+          value: 'id',
+          label: '设备ID'
+        }, {
+          value: 'localId',
+          label: '本地编码'
+        }, {
+          value: 'localName',
+          label: '本地名称'
+        }],
+        codeValue: '',
         ruleForm: {
           code: '',
           main: '',
@@ -137,6 +166,12 @@
         }
       }
     },
+    computed:{
+      disabled() {
+        return this.codeValue === '' ? 'disabled':false
+      },
+
+    },
     methods: {
       addCode() {
         this.ruleForm.codeList.push({
@@ -153,8 +188,22 @@
       submitForm(formName) {
         this.$refs[formName].validate(valid => {
           if (valid) {
-            this.addShipDialog = false
-            console.log('success')
+
+            let arr = []
+            for(let item  of this.ruleForm.codeList) {
+              if(item.value) {
+                arr = arr.concat(item.value)
+              }
+            }
+            let param = {
+              FromContent:arr,
+              MainContent:this.ruleForm.main,
+              RelType:localStorage.getItem('RelManualType'),
+              Type:this.codeValue
+            }
+            console.log(param,'===')
+            this.$emit('addShip',param)
+            // this.addShipDialog = false
           } else {
             console.log('error')
             return false

+ 192 - 140
src/views/relation/relationShip/index.vue

@@ -25,12 +25,13 @@
           <p class="border-left-8">主对象
             <span>限制条件:对象类型的范围(包括:XXXX类型,XXXX类型)</span></p>
           <label>所属建筑楼层:</label>
-          <el-select v-model="buildValue">
+          <el-select disabled v-model="buildValue">
             <el-option
               v-for="item in options"
               :key="item.value"
               :label="item.label"
               :value="item.value"
+
             />
           </el-select>
           <label>类型:</label>
@@ -39,16 +40,17 @@
             :props="props"
             collapse-tags
             clearable
+            disabled
           />
           <el-input
             placeholder="请输入"
-            v-model="deviceName"
-            @keyup.enter.native="queryTable"
+            @keyup.enter.native="queryTable(1)"
+            v-model="mainValue"
           >
             <i
               slot="suffix"
               class="el-input__icon el-icon-search cursor"
-              @click="queryTable"
+              @click="queryTable(1)"
             />
           </el-input>
         </el-col>
@@ -56,12 +58,13 @@
           <p class="border-left-8">从对象
             <span>(包括:XXXX类型,XXXX类型)</span></p>
           <label>所属建筑楼层:</label>
-          <el-select v-model="buildValue">
+          <el-select disabled v-model="buildValue">
             <el-option
               v-for="item in options"
               :key="item.value"
               :label="item.label"
               :value="item.value"
+
             />
           </el-select>
           <label>类型:</label>
@@ -70,16 +73,17 @@
             :props="props"
             collapse-tags
             clearable
+            disabled
           />
           <el-input
             placeholder="请输入"
-            v-model="deviceName"
-            @keyup.enter.native="queryTable"
+            @keyup.enter.native="queryTable(2)"
+            v-model="formValue"
           >
             <i
               slot="suffix"
               class="el-input__icon el-icon-search cursor"
-              @click="queryTable"
+              @click="queryTable(2)"
             />
           </el-input>
         </el-col>
@@ -96,26 +100,26 @@
         class="table"
       >
         <el-table-column
-          prop="id"
+          prop="Name"
           label="全局名称"
           width="180"
           align="center"
         >
         </el-table-column>
         <el-table-column
-          prop="name"
+          prop="LocalId"
           label="本地编码"
           align="center"
         >
         </el-table-column>
         <el-table-column
-          prop="amount1"
+          prop="LocalName"
           label="本地名称"
           align="center"
         >
         </el-table-column>
         <el-table-column
-          prop="amount2"
+          prop="CADID"
           label="CADID"
           align="center"
         >
@@ -133,26 +137,26 @@
           </template>
         </el-table-column>
         <el-table-column
-          prop="ids"
+          prop="cName"
           label="全局名称"
           width="180"
           align="center"
         >
         </el-table-column>
         <el-table-column
-          prop="names"
+          prop="cLocalId"
           align="center"
           label="本地编码"
         >
         </el-table-column>
         <el-table-column
-          prop="amount11"
+          prop="cLocalName"
           label="本地名称"
           align="center"
         >
         </el-table-column>
         <el-table-column
-          prop="amount22"
+          prop="cCADID"
           label="CADID"
           align="center"
         >
@@ -176,13 +180,19 @@
           <template slot-scope="scope">
             <el-button
               size="mini"
-              icon="el-icon-edit-outline"
+              icon="el-icon-delete"
               @click="lookOver(scope.$index, scope.row)">
             </el-button>
           </template>
         </el-table-column>
       </el-table>
     </section>
+    <!-- 分页 -->
+    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
+                   :page-sizes="pageSizes"
+                   :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"
+                   style="float:right;margin-top:10px;padding:2px 5px;">
+    </el-pagination>
     <exportExcel
       ref="export"
       :values="values"
@@ -190,6 +200,7 @@
     <addRelationShip
       ref="addShipComponent"
       :values="values"
+      @addShip="addShip"
     />
     <editRelationShip
       ref="editShipComponent"
@@ -199,15 +210,20 @@
 </template>
 
 <script>
-  import {mapActions, mapGetters, mapState} from 'vuex'
+  import {mapGetters} from 'vuex'
   import exportExcel from "../../../components/relation/relationShip/Modal/exportExcel";
   import addRelationShip from "../../../components/relation/relationShip/Modal/addRelationShip";
   import editRelationShip from "../../../components/relation/relationShip/Modal/editRelationShip";
+  import {relAdd, relQuery} from "../../../api/relation/api";
 
   export default {
     name: "index",
     data() {
       return {
+        pageSizes: [10, 20, 50, 100],
+        pageSize: 50,
+        currentPage: 1,
+        total: 0,
         values: {
           relation_maintenance: '关系维护',
           optionTips: '请下载最新最新 xxxx 数据进行手动维护', //请下载最新最新 xxxx 数据进行手动维护
@@ -232,6 +248,8 @@
           cancel: '取消',
           delete: '删除关系'
         },
+        mainValue: '',
+        formValue: '',
         options: [
           {
             value: 'all',
@@ -276,92 +294,9 @@
             label: '新疆维吾尔族自治区',
           }]
         }],
-        deviceName: "",
-        tableData: [
-          {
-            id: '12987122',
-            name: '王小虎',
-            amount1: '234',
-            amount2: '3.2',
-            amount3: 10,
-            ids: '12987122',
-            names: '王小虎',
-            amount11: '234',
-            amount22: '3.2',
-          }, {
-            id: '12987122',
-            name: '王小虎',
-            amount1: '234',
-            amount2: '3.2',
-            amount3: 10,
-            ids: '12987122',
-            names: '王小虎',
-            amount11: '234',
-            amount22: '3.2',
-          }, {
-            id: '12987122',
-            name: '王小虎',
-            amount1: '234',
-            amount2: '3.2',
-            amount3: 10,
-            ids: '12987122',
-            names: '王小虎',
-            amount11: '234',
-            amount22: '3.2',
-          }, {
-            id: '12987122',
-            name: '王小虎',
-            amount1: '234',
-            amount2: '3.2',
-            amount3: 10,
-            ids: '12987122',
-            names: '王小虎',
-            amount11: '234',
-            amount22: '3.2',
-          }, {
-            id: '12987122',
-            name: '王小虎',
-            amount1: '234',
-            amount2: '3.2',
-            amount3: 10,
-            ids: '12987122',
-            names: '王小虎',
-            amount11: '234',
-            amount22: '3.2',
-          }, {
-            id: '129871225',
-            name: '王小虎',
-            amount1: '621',
-            amount2: '2.2',
-            amount3: 17,
-            ids: '12987125',
-            names: '王小虎',
-            amount11: '621',
-            amount22: '2.2',
-          },
-          {
-            id: '129871225',
-            name: '王小虎',
-            amount1: '621',
-            amount2: '2.2',
-            amount3: 17,
-            ids: '12987124',
-            names: '小虎',
-            amount11: '324',
-            amount22: '1.9',
-          }, {
-            id: '1298712w25',
-            name: '小虎',
-            amount1: '621',
-            amount2: '2.2',
-            amount3: 17,
-            ids: '12987125',
-            names: '小虎',
-            amount11: '621',
-            amount22: '2.2',
-          }],
-        spanArr: [], // 一个空的数组,用于存放每一行记录的合并数
-        pos: 0, // spanArr 的索引
+        tableData: [],
+        needMergeArr: ['Name', 'LocalId', 'LocalName', 'CADID'],
+        rowMergeArrs: {}
       }
     },
     components: {exportExcel, addRelationShip, editRelationShip},
@@ -377,26 +312,106 @@
           label: '设备控制关系',
         },
       ])
+      this.init()
+    },
+    watch: {
+      projectId() {
+        this.init()
+      }
+    },
+    computed: {
+      ...mapGetters('layout', ["projectId"])
     },
     mounted() {
-      this.getSpanArr(this.tableData)
+      // this.getSpanArr(this.tableData)
+      this.rowMergeArrs = this.rowMergeHandle(this.needMergeArr, this.tableData); // 处理数据
+
     },
     methods: {
+      init() {
+        let data = {
+          projectId: this.projectId,
+          ObjectType: 1,
+          RelType: localStorage.getItem('RelManualType'),
+          PageSize: this.pageSize,
+          PageNumber: this.currentPage
+        };
+        relQuery(data, res => {
+          this.filterTable(res)
+          this.total = res.Total
+        })
+      },
+      filterTable(list) {
+        list.Content && list.Content.forEach(i => {
+          i.ObjectInfo && i.ObjectInfo.forEach(j => {
+            this.tableData.push({
+              Name: i.Name,
+              LocalName: i.LocalName,
+              LocalId: i.LocalId,
+              CADID: i.CADID,
+              cName: j.Name,
+              cLocalName: j.LocalName,
+              cLocalId: j.LocalId,
+              cCADID: j.CADID,
+            })
+          })
+        })
+
+      },
       back() {
         this.$router.go(-1)
       },
+
       addBtn() {
         this.$refs.addShipComponent.addShipDialog = true
       },
       excel() {
         this.$refs.export.dialogExport = true
       },
-      queryTable() {
+      queryTable(i) {
+        let param = {}, RelType = localStorage.getItem('RelManualType');
+        if (i === 1) {
+          param = {
+            ObjectType: 1,
+            RelType,
+            Vague: this.mainValue
+          }
+        } else {
+          param = {
+            ObjectType: 2,
+            RelType,
+            Vague: this.formValue
+          }
+        }
+        relQuery(param, res => {
+          console.log(res, '==object==')
+        })
+      },
+      addShip(index) {
+        relAdd(index).then(res => {
+          if (res.data.Result === "failure") {
+            this.$message.error(res.data.Message);
+            return
+          } else if (res.data.Result === "success") {
+            this.init()
+          }
+          console.log(res.data, 'addShip')
+        })
+      },
+      //分页更换size
+      handleSizeChange(val) {
+        this.currentPage = 1;
+        this.pageSize = val;
+        this.init()
+      },
+      //分页更换页
+      handleCurrentChange(val) {
+        this.currentPage = val;
+        this.init()
       },
-
       lookOver(index, row) {
         console.log(index, row)
-        this.$refs.editShipComponent.editShipDialog = true
+        // this.$refs.editShipComponent.editShipDialog = true
       },
 
       cellStyle({row, column, rowIndex, columnIndex}) {
@@ -408,40 +423,77 @@
           }
         }
       },
-      getSpanArr(data) {
-        for (let i = 0; i < data.length; i++) {
-          if (i === 0) {
-            this.spanArr.push(1);
-            this.pos = 0;
-
-          } else {
-            if (
-              data[i].id === data[i - 1].id &&
-              data[i].name === data[i - 1].name &&
-              data[i].amount2 === data[i - 1].amount2 &&
-              data[i].amount1 === data[i - 1].amount1
-
-            ) {
-              this.spanArr[this.pos] += 1;
-              this.spanArr.push(0);
-            } else {
-              this.spanArr.push(1);
-              this.pos = i;
-            }
-          }
-        }
-      },
+      // getSpanArr(data) {
+      //   for (let i = 0; i < data.length; i++) {
+      //     if (i === 0) {
+      //       this.spanArr.push(1);
+      //       this.pos = 0;
+      //
+      //     } else {
+      //       if (
+      //         data[i].id === data[i - 1].id &&
+      //         data[i].name === data[i - 1].name &&
+      //         data[i].amount2 === data[i - 1].amount2 &&
+      //         data[i].amount1 === data[i - 1].amount1
+      //
+      //       ) {
+      //         this.spanArr[this.pos] += 1;
+      //         this.spanArr.push(0);
+      //       } else {
+      //         this.spanArr.push(1);
+      //         this.pos = i;
+      //       }
+      //     }
+      //   }
+      // },
+      // objectSpanMethod({row, column, rowIndex, columnIndex}) {
+      //   if (columnIndex === 1 || columnIndex === 2 || columnIndex === 3) {
+      //     const _row = this.spanArr[rowIndex];
+      //     const _col = _row > 0 ? 1 : 0;
+      //     return {
+      //       rowspan: _row,
+      //       colspan: _col
+      //     };
+      //   }
+      //
+      // },
       objectSpanMethod({row, column, rowIndex, columnIndex}) {
-        if (columnIndex === 1 || columnIndex === 2 || columnIndex === 3) {
-          const _row = this.spanArr[rowIndex];
-          const _col = _row > 0 ? 1 : 0;
-          return {
-            rowspan: _row,
-            colspan: _col
-          };
-        }
-
+        if (column.property === 'Name') return this.mergeAction('Name', rowIndex, column)
+        if (column.property === 'LocalName') return this.mergeAction('LocalName', rowIndex, column)
+        if (column.property === 'LocalId') return this.mergeAction('LocalId', rowIndex, column)
+        if (column.property === 'CADID') return this.mergeAction('CADID', rowIndex, column)
       },
+      mergeAction(val, rowIndex, colData) {
+        let _row = this.rowMergeArrs[val].rowArr[rowIndex];
+        let _col = _row > 0 ? 1 : 0;
+        return [_row, _col];
+      },
+      rowMergeHandle(arr, data) {
+        if (!Array.isArray(arr) && !arr.length) return false;
+        if (!Array.isArray(data) && !data.length) return false;
+        let needMerge = {};
+        arr.forEach(i => {
+          needMerge[i] = {
+            rowArr: [],
+            rowMergeNum: 0
+          };
+          data.forEach((item, index) => {
+            if (index === 0) {
+              needMerge[i].rowArr.push(1);
+              needMerge[i].rowMergeNum = 0;
+            } else {
+              if (item[i] === data[index - 1][i]) {
+                needMerge[i].rowArr[needMerge[i].rowMergeNum] += 1;
+                needMerge[i].rowArr.push(0);
+              } else {
+                needMerge[i].rowArr.push(1);
+                needMerge[i].rowMergeNum = index;
+              }
+            }
+          });
+        });
+        return needMerge;
+      }
     }
   }
 </script>