|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="relation-ship">
|
|
|
+ <div class="relation-ship" v-loading="loading">
|
|
|
<section style="margin-top: 20px">
|
|
|
<el-button
|
|
|
style="padding: 10px"
|
|
@@ -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>
|
|
@@ -87,6 +91,8 @@
|
|
|
|
|
|
</section>
|
|
|
<section class="table-list">
|
|
|
+ <!-- :span-method="objectSpanMethod"
|
|
|
+ -->
|
|
|
<el-table
|
|
|
:data="tableData"
|
|
|
:span-method="objectSpanMethod"
|
|
@@ -96,32 +102,33 @@
|
|
|
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"
|
|
|
>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
label="对象详情"
|
|
|
+ prop="btn"
|
|
|
align="center"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
@@ -133,26 +140,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"
|
|
|
>
|
|
@@ -174,15 +181,30 @@
|
|
|
align="center"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button
|
|
|
- size="mini"
|
|
|
- icon="el-icon-edit-outline"
|
|
|
- @click="lookOver(scope.$index, scope.row)">
|
|
|
- </el-button>
|
|
|
+ <!-- <el-button-->
|
|
|
+ <!-- size="mini"-->
|
|
|
+ <!-- icon="el-icon-delete"-->
|
|
|
+ <!-- @click="deleteObject(scope.$index, scope.row)">-->
|
|
|
+ <!-- </el-button>-->
|
|
|
+ <el-popconfirm
|
|
|
+ title="确定删除吗?"
|
|
|
+ @onConfirm="deleteObject(scope.$index, scope.row)"
|
|
|
+ >
|
|
|
+ <el-button slot="reference" size="mini" icon="el-icon-delete"/>
|
|
|
+ </el-popconfirm>
|
|
|
</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 +212,7 @@
|
|
|
<addRelationShip
|
|
|
ref="addShipComponent"
|
|
|
:values="values"
|
|
|
+ @addShip="addShip"
|
|
|
/>
|
|
|
<editRelationShip
|
|
|
ref="editShipComponent"
|
|
@@ -199,15 +222,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, relDelete, 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 +260,8 @@
|
|
|
cancel: '取消',
|
|
|
delete: '删除关系'
|
|
|
},
|
|
|
+ mainValue: '',
|
|
|
+ formValue: '',
|
|
|
options: [
|
|
|
{
|
|
|
value: 'all',
|
|
@@ -276,92 +306,12 @@
|
|
|
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: [],
|
|
|
+ loading: false,
|
|
|
+ needMergeArr: ['Name', 'LocalId', 'LocalName', 'CADID','btn'],
|
|
|
+ rowMergeArrs: {}
|
|
|
+ // needMergeArr: ['name', 'id'], // 有合并项的列
|
|
|
+ // rowMergeArrs: {}, // 包含需要一个或多个合并项信息的对象
|
|
|
}
|
|
|
},
|
|
|
components: {exportExcel, addRelationShip, editRelationShip},
|
|
@@ -377,28 +327,139 @@
|
|
|
label: '设备控制关系',
|
|
|
},
|
|
|
])
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ projectId() {
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters('layout', ["projectId"])
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.getSpanArr(this.tableData)
|
|
|
+ // this.getSpanArr(this.tableData)
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
+ deepCopy(obj) {
|
|
|
+ return JSON.parse(JSON.stringify(obj))
|
|
|
+ },
|
|
|
+ init() {
|
|
|
+ this.loading = true
|
|
|
+ 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
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ filterTable(list) {
|
|
|
+ let arr = []
|
|
|
+ if(list.Content.length) {
|
|
|
+ list.Content.forEach(i => {
|
|
|
+ i.ObjectInfo && i.ObjectInfo.forEach(j => {
|
|
|
+ arr.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,
|
|
|
+ Id: i.Id,
|
|
|
+ cId: j.Id
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ this.tableData = this.deepCopy(arr)
|
|
|
+ this.rowMergeArrs = this.rowMergeHandle(this.needMergeArr, this.tableData); // 处理数据
|
|
|
+ } else {
|
|
|
+ this.tableData = []
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
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 => {
|
|
|
+ this.filterTable(res)
|
|
|
+ console.log(res, '==object==')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addShip(index) {
|
|
|
+ let that = this
|
|
|
+ relAdd(index).then(res => {
|
|
|
+ if (res.data.Result === "failure") {
|
|
|
+ this.$message.error(res.data.Message);
|
|
|
+ return false
|
|
|
+ } else if (res.data.Result === "success") {
|
|
|
+ this.$message.success(res.data.Message);
|
|
|
+ this.init()
|
|
|
+ that.$refs.addShipComponent.addShipDialog = false
|
|
|
+ that.$refs.addShipComponent.codeValue = ''
|
|
|
+ that.$refs.addShipComponent.ruleForm.codeList = [{value:''}]
|
|
|
+ that.$refs.addShipComponent.ruleForm.main = ''
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //分页更换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
|
|
|
+ },
|
|
|
+ deleteObject(index, row) {
|
|
|
+ let param = {
|
|
|
+ "FromId": row.Id,
|
|
|
+ "RelType": localStorage.getItem('RelManualType'),
|
|
|
+ "ToId": row.cId
|
|
|
+ }
|
|
|
+ relDelete(param, res => {
|
|
|
+ this.init()
|
|
|
+ })
|
|
|
+ },
|
|
|
cellStyle({row, column, rowIndex, columnIndex}) {
|
|
|
if (column.label === '全局名称') {
|
|
|
return {
|
|
@@ -408,40 +469,45 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- 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
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
+ if (column.property === 'Name') return this.mergeAction('Name', rowIndex, column);
|
|
|
+ if (column.property === 'LocalId' && row.LocalId != undefined) return this.mergeAction('LocalId', rowIndex, column);
|
|
|
+ if (column.property === 'LocalName' && row.LocalName != undefined) return this.mergeAction('LocalName', rowIndex, column);
|
|
|
+ if (column.property === 'CADID' && row.CADID != undefined) return this.mergeAction('CADID', rowIndex, column);
|
|
|
+ if (column.property === 'btn') return this.mergeAction('Name', 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>
|