Browse Source

批量关联表格

zhangyu 5 years ago
parent
commit
1bd4f57a97

+ 12 - 0
src/api/scan/request.js

@@ -735,6 +735,12 @@ export function getCenoteTableData(param, success) {
     http.postJson(url, param, success)
 }
 
+//查询竖井信息
+export function queryCenoteTableData(param, success) {
+    let url = `${baseUrl}/datacenter/shaft/query`
+    http.postJson(url, param, success)
+}
+
 //添加竖井信息
 export function createCenoteTableData(param, success) {
     let url = `${baseUrl}/datacenter/shaft/create`
@@ -974,6 +980,12 @@ export function queryPartsDie(param, success) {
     http.postJson(url, param, success)
 }
 
+//查询项目下设备或部件的类别、以及名称
+export function TypePartsDie( success) {
+    let url = `${baseUrl}/equip-component/equip-query/equip-compon-category`;
+    http.getJson(url, {}, success)
+}
+
 //根据条件查询项目下设备部件数量
 export function countPartsDie(param, success) {
     let url = `${baseUrl}/equip-component/equip-query/count`;

+ 1 - 1
src/components/ledger/cenote/table/cenoteTable.vue

@@ -126,7 +126,7 @@ export default {
     getTableData() {
       let pa = {
         data: {
-          Filters: `RoomID="${this.params.RoomID}"`,
+          Filters: `RoomID='${this.params.RoomID}'`,
           Cascade: [
             {
               Name: this.type,

+ 22 - 28
src/components/ledger/cenote/table/deviceTable.vue

@@ -44,11 +44,7 @@
 </template>
 
 <script>
-// import {
-//   queryZone,
-//   eqInSpaceDelete, //设备所在业务空间--删除关系
-//   eqForSpaceDelete, //设备服务业务空间--删除关系
-// } from "@/api/scan/request";
+import { queryCenoteTableData } from "@/api/scan/request";
 import { mapGetters } from "vuex";
 import addEquipDialog from "@/components/ledger/cenote/dialog/addEquipDialog"
 export default {
@@ -75,9 +71,29 @@ export default {
     type: String
   },
   created() {
-    // this.getTableData()
+    this.getTableData()
   },
   methods: {
+    // 获取列表数据
+    getTableData() {
+      let params = {
+        Filters: `ShaftID='${this.params.ShaftID}'`,
+        Cascade: [
+          {
+            Name: 'equipmentList',
+            Cascade: [{ Name: 'equipCategory' }]
+          }
+        ]
+      }
+      queryCenoteTableData(params, res => {
+        debugger
+        this.tableData = res.Content[0].Equipment || []
+        this.tableData.map(t => {
+          t.SpaceId = res.Content[0].RoomID
+          return t;
+        })
+      })
+    },
     // 删除关系
     handleDelete(index, row) {
       this.$confirm("确认删除该关系?", "提示", {
@@ -122,28 +138,6 @@ export default {
       this.page.pageNumber = pageNo;
       this.getTableData();
     },
-    // 获取列表数据
-    getTableData() {
-      let pa = {
-        data: {
-          Filters: `RoomID="${this.params.RoomID}"`,
-          Cascade: [
-            {
-              Name: this.type,
-              Cascade: [{ Name: 'equipCategory' }]
-            }
-          ]
-        },
-        zone: this.params.zone
-      }
-      queryZone(pa, res => {
-        this.tableData = res.Content[0].Equipment || []
-        this.tableData.map(t => {
-          t.SpaceId = res.Content[0].RoomID
-          return t;
-        })
-      })
-    },
     // 添加设备
     add() {
       this.$refs.addEqDialog.floor = [this.params.BuildingId, this.params.FloorId];

+ 3 - 7
src/components/ledger/cenote/table/systemTable.vue

@@ -11,7 +11,7 @@
         <el-table-column :label="`${inSpaceType}名称`" show-overflow-tooltip min-width="100">
           <template slot-scope="scope">
             <div>
-              {{scope.row.EquipLocalName||scope.row.EquipName||''}}
+              {{scope.row.ShaftLocalName||scope.row.ShaftName||''}}
             </div>
           </template>
         </el-table-column>
@@ -126,7 +126,7 @@ export default {
     getTableData() {
       let pa = {
         data: {
-          Filters: `RoomID="${this.params.RoomID}"`,
+          Filters: `RoomID='${this.params.RoomID}'`,
           Cascade: [
             {
               Name: this.type,
@@ -137,11 +137,7 @@ export default {
         zone: this.params.zone
       }
       queryZone(pa, res => {
-        this.tableData = res.Content[0].Equipment || []
-        this.tableData.map(t => {
-          t.SpaceId = res.Content[0].RoomID
-          return t;
-        })
+        this.tableData = res.Content[0].EquipmentList || []
       })
     },
     // 添加设备

+ 18 - 9
src/components/ledger/lib/linkassets.vue

@@ -3,7 +3,7 @@
     <el-row>
       <span class="condition-title">设备类型:</span>
       <el-select v-model="deviceType" filterable size="small" @change="handleChangeDevice" style="width:250px;">
-        <el-option  v-for="item in deviceTypeList" :key="item.code" :label="item.facility" :value="item.code"></el-option>
+        <el-option  v-for="item in deviceTypeList" :key="item.Category" :label="item.CategoryName" :value="item.Category"></el-option>
       </el-select>
     </el-row>
     <el-row style="margin-top:30px;">
@@ -22,7 +22,7 @@
 </template>
 <script>
 
-import { floorQuery, buildingQuery, queryDictionaryHead, queryZone } from '@/api/scan/request'
+import { floorQuery, buildingQuery, queryDictionaryHead, queryZone, TypePartsDie } from '@/api/scan/request'
 
 import { mapGetters } from "vuex"
 export default {
@@ -56,11 +56,20 @@ export default {
     };
   },
   created() {
+    this.getPartsDieType() //获取未关联资产的设备或部件类型
     this.getBuildFloorData() //获取建筑楼层数据
     this.getSpaceData() //获取分区类型数据
   },
   mounted() { },
   methods: {
+    //获取未关联资产的设备或部件类型
+    getPartsDieType() {
+      TypePartsDie(res => {
+        this.deviceTypeList = res.Content.filter(item => {
+          return item.CategoryName
+        })
+      })
+    },
     //获取建筑楼层数据
     getBuildFloorData() {
       let data, buildParams = {
@@ -232,13 +241,13 @@ export default {
     toLinkAssets() {
       let query = {}
       // 校验必填项
-      // if(!this.deviceType) {
-      //   this.$message.info('请选择设备类型!')
-      //   return false
-      // } else if (!this.buildFloor.length) {
-      //   this.$message.info('请选择建筑楼层!')
-      //   return false
-      // }
+      if(!this.deviceType) {
+        this.$message.info('请选择设备类型!')
+        return false
+      } else if (!this.buildFloor.length) {
+        this.$message.info('请选择建筑楼层!')
+        return false
+      }
       if(this.spaceShow) {
         query = {
           deviceType: this.deviceType,

+ 2 - 2
src/views/ledger/cenotelist/cenoteDetail/index.vue

@@ -36,7 +36,7 @@ import systemTable from '@/components/ledger/cenote/table/systemTable'
 export default {
   data() {
     return {
-      params: {}, //参数-包含空间id 分区类型 进入方式(1-平面图 2-列表)
+      params: {},
       tabsList: [
         { Code: 'device', Name: '竖井内的设备' },
         { Code: 'cenote', Name: '连通的其它竖井' },
@@ -72,7 +72,7 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
-        deleteCenoteTableData([{ShaftID: this.params.id}], res => {
+        deleteCenoteTableData([{ShaftID: this.params.ShaftID}], res => {
           this.$message.success('删除成功')
           this.goBack()
         })

+ 1 - 1
src/views/ledger/cenotelist/index.vue

@@ -351,7 +351,7 @@ export default {
         this.$router.push({
           path: "/ledger/cenoteDetail",
           query: {
-            id: this.shaftId,
+            ShaftID: this.shaftId,
             name: name
           }
         })

+ 120 - 45
src/views/ledger/facility/batchlink.vue

@@ -8,20 +8,32 @@
         <el-button style="float:right;margin-top:1px;" @click="handleClickCreate">保存选定的设备资产关联关系</el-button>
       </div>
       <div class="main">
-        <el-table ref="multipleTable" :data="tableData" v-loading='loading' stripe height="100%" @selection-change="handleSelectionChange">
-          <el-table-column type="selection" width="55"></el-table-column>
-          <el-table-column label="设备名称" width="200">
+        <el-table ref="multipleTable" :data="tableData" v-loading='loading' stripe height="100%" :span-method="objectSpanMethod">
+          <el-table-column label="设备本地名称" width="200">
             <template slot-scope="scope">{{ scope.row.EquipLocalName?scope.row.EquipLocalName:scope.row.EquipName }}</template>
           </el-table-column>
           <el-table-column label="设备本地编码" show-overflow-tooltip>
             <template slot-scope="scope">{{ scope.row.EquipLocalID?scope.row.EquipLocalID:scope.row.EquipID }}</template>
           </el-table-column>
-          <el-table-column prop="EquipCategory.EquipName" label="设备类型" show-overflow-tooltip width="200"></el-table-column>
-          <el-table-column prop="Building.BuildLocalName" label="所属建筑"></el-table-column>
-          <el-table-column prop="Floor.FloorLocalName" label="所属楼层"></el-table-column>
+          <el-table-column prop="EquipName" label="设备类" show-overflow-tooltip width="200"></el-table-column>
+          <el-table-column prop="BIMID" label="设计图纸中编码"></el-table-column>
+          <el-table-column label="所属建筑楼层">
+            <template slot-scope="scope">{{ scope.row.BuildLocalName }}-{{ scope.row.FloorLocalName }}</template>
+          </el-table-column>
+          <el-table-column label="资产本地名称" width="200">
+            <template slot-scope="scope">{{ scope.row.AssetsLocalName }}</template>
+          </el-table-column>
+          <el-table-column label="资产本地编码" show-overflow-tooltip>
+            <template slot-scope="scope">{{ scope.row.AssetsLocalId }}</template>
+          </el-table-column>
+          <el-table-column prop="Family" label="设备族" show-overflow-tooltip width="200"></el-table-column>
+          <el-table-column prop="AssetsBIMID" label="设计图纸中编码"></el-table-column>
+          <el-table-column label="所属建筑楼层">
+            <template slot-scope="scope">{{ scope.row.AssetsBuildLocalName }}-{{ scope.row.AssetsFloorLocalName }}</template>
+          </el-table-column>
           <el-table-column prop="address" label="操作" width="100">
             <template slot-scope="scope">
-              <el-button @click.native.prevent="handleOpenDetail(scope.row, tableData)" type="text" size="small">详情</el-button>
+              <el-radio v-model="radio[scope.row.EquipLocalID]" :label="scope.row.AssetsLocalId">&nbsp;</el-radio>
             </template>
           </el-table-column>
         </el-table>
@@ -46,7 +58,57 @@
 <script>
 import { mapGetters } from "vuex"
 //api
-import { queryPartsDie, createPropertys } from "@/api/scan/request";
+import { } from "@/api/scan/request";
+
+let list = [
+  {
+    EquipLocalName: '风机盘管0019',
+    EquipLocalID: '1784815',
+    EquipName: '风机盘管',
+    BIMID: '18168746166',
+    BuildLocalName: 'A座',
+    FloorLocalName: '1F',
+    AssetsList: [{
+      AssetsLocalName: '资产1',
+      AssetsLocalId: '1',
+      Family: '风机盘管-资产',
+      AssetsBIMID: '18168746166',
+      AssetsBuildLocalName: 'A座',
+      AssetsFloorLocalName: '1F',
+    }, {
+      AssetsLocalName: '资产2',
+      AssetsLocalId: '2',
+      Family: '风机盘管-资产',
+      AssetsBIMID: '18168746166',
+      AssetsBuildLocalName: 'A座',
+      AssetsFloorLocalName: '1F',
+    }, {
+      AssetsLocalName: '资产3',
+      AssetsLocalId: '3',
+      Family: '风机盘管-资产',
+      AssetsBIMID: '18168746166',
+      AssetsBuildLocalName: 'A座',
+      AssetsFloorLocalName: '1F',
+    }]
+  },
+  {
+    EquipLocalName: '风机盘管0020',
+    EquipLocalID: '1784812',
+    EquipName: '风机盘管',
+    BIMID: '1816874456457',
+    BuildLocalName: 'A座',
+    FloorLocalName: '1F',
+    AssetsList: [{
+      AssetsLocalName: '资产4',
+      AssetsLocalId: '4',
+      Family: '风机盘管-资产',
+      AssetsBIMID: '234567',
+      AssetsBuildLocalName: 'A座',
+      AssetsFloorLocalName: '1F',
+    }]
+  }
+]
+
 export default {
   data() {
     return {
@@ -58,8 +120,9 @@ export default {
         pageNumber: 1,
         total: 0
       },
+      radio: {},
       tableData: [],
-      multipleSelection:[]
+      mergeCol: []
     }
   },
   computed: {
@@ -70,6 +133,7 @@ export default {
   },
   created() {
     this.params = this.$route.params
+    this.getTableData()
   },
   mounted() {
     
@@ -82,39 +146,45 @@ export default {
     goBack() {
       this.$router.push({ name: "facilityLedger" })
     },
-    //选择设备或部件
-    changeDevice(val) {
-      if(val.code) {
-        this.params.category = val.code
-      } else {
-        this.params.category = ''
-      }
-      this.page.pageNumber = 1
-      this.getTableData()
-    },
-    //选择建筑楼层
-    changeFloor(value) {
-      if (value[0]) {
-        this.params.buildId = value[0]
-      }
-      if (value[1]) {
-        this.params.floorId = value[1]
-      } else {
-        this.params.floorId = ''
-      }
-      this.page.pageNumber = 1
-      this.getTableData()
-    },
     //获取表格数据
     getTableData() {
-      this.loading = true
-      let param = this.formatFilter()
-      queryPartsDie(param, res => {
-        this.tableData = res.Content
-        this.page.total = res.Total
-        this.loading = false
+      // this.loading = true
+      // let param = this.formatFilter()
+      // queryPartsDie(param, res => {
+      //   this.tableData = res.Content
+      //   this.page.total = res.Total
+      //   this.loading = false
+      // })
+      list.forEach(item =>{
+        if(item.AssetsList && item.AssetsList.length){
+          item.AssetsList.forEach((Assets, index) => {
+            let obj = JSON.parse(JSON.stringify(Object.assign(item,Assets)))
+            delete obj.AssetsList
+            this.tableData.push(obj)
+            if(index == 0){
+              this.mergeCol.push(item.AssetsList.length)
+            } else {
+              this.mergeCol.push(false)
+            }
+          })
+        }
       })
     },
+    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
+      if (columnIndex < 5) {
+        if (this.mergeCol[rowIndex]) {
+          return {
+            rowspan: this.mergeCol[rowIndex],
+            colspan: 1
+          };
+        } else {
+          return {
+            rowspan: 0,
+            colspan: 1
+          };
+        }
+      }
+    },
     //格式化条件
     formatFilter() {
       let param = {
@@ -154,7 +224,7 @@ export default {
     },
     //选择的设备或部件
     handleSelectionChange(val) {
-      this.multipleSelection = val;
+      
     },
     //切换每页显示多少条数据
     handleSizeChange(val) {
@@ -166,14 +236,19 @@ export default {
       this.page.pageNumber = val
       this.getTableData()
     },
-    //查看详情
-    handleOpenDetail(row) {
-      // window.open(`http://adm.sagacloud.cn:8058/spread?id=${row.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
-      this.$message("开发中...")
-    },
     //创建已选
     handleClickCreate() {
-      
+      let params = []
+      if(Object.keys(this.radio).length){
+        for(let key in this.radio){
+          params.push({
+            id: key,
+            pid: this.radio[key]
+          })
+        }
+      } else {
+        this.$message.info('请选择要关联的关系!')
+      }
     }
   }
 };