|
@@ -1,6 +1,7 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
@open="openEvent"
|
|
|
+ @close="closeLog"
|
|
|
title="更多关系"
|
|
|
:visible.sync="dialogTableVisible"
|
|
|
>
|
|
@@ -13,11 +14,11 @@
|
|
|
align="left"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
- {{
|
|
|
- (item[1].includes("objectInfo") && scope.row.objectInfo
|
|
|
- ? scope.row.objectInfo[0][item[1].split("-")[1]]
|
|
|
- : scope.row[item[1]]) || "--"
|
|
|
- }}
|
|
|
+ {{
|
|
|
+ item[1].includes("objectInfo")
|
|
|
+ ? scope.row[item[1].split("-")[1]]
|
|
|
+ : "--"
|
|
|
+ }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" align="left">
|
|
@@ -53,7 +54,7 @@ import { zoneQuery, relDel } from "@/api/datacenter";
|
|
|
})
|
|
|
export default class extends Vue {
|
|
|
@Prop({ default: Array }) tableHeader?: [];
|
|
|
- @Prop({ default: String }) mainId?: ""; //主对象id
|
|
|
+ @Prop({ default: Array }) allRelation?: []; //主对象id
|
|
|
// 分页
|
|
|
page: object = {
|
|
|
total: 0, //总数
|
|
@@ -70,26 +71,35 @@ export default class extends Vue {
|
|
|
* 分页数量切换
|
|
|
*/
|
|
|
|
|
|
- handleSizeChange(val: any) {}
|
|
|
+ handleSizeChange(val: any) {
|
|
|
+ this.page.pageSize = 10;
|
|
|
+ this.page.currentPage = 1;
|
|
|
+ this.getTable()
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 分页切换
|
|
|
*/
|
|
|
- handleCurrentChange(val: any) {}
|
|
|
+ handleCurrentChange(val: any) {
|
|
|
+ this.page.currentPage = val;
|
|
|
+ this.getTable()
|
|
|
+ }
|
|
|
|
|
|
getTable() {
|
|
|
- const data = {
|
|
|
- pageSize: this.page.pageSize,
|
|
|
- pageNumber: this.page.currentPage,
|
|
|
- orders: "name asc, createTime desc",
|
|
|
- filters: `buildingId='${this.mainId}'`,
|
|
|
- };
|
|
|
- zoneQuery(data).then((res: any) => {
|
|
|
- if (res.content && res.content.length) {
|
|
|
- this.gridData = res.content;
|
|
|
- }
|
|
|
- this.page.total = res.total;
|
|
|
- });
|
|
|
+ // const data = {
|
|
|
+ // pageSize: this.page.pageSize,
|
|
|
+ // pageNumber: this.page.currentPage,
|
|
|
+ // orders: "name asc, createTime desc",
|
|
|
+ // filters: `buildingId='${this.mainId}'`,
|
|
|
+ // };
|
|
|
+ // zoneQuery(data).then((res: any) => {
|
|
|
+ // if (res.content && res.content.length) {
|
|
|
+ // this.gridData = res.content;
|
|
|
+ // }
|
|
|
+ // this.page.total = res.total;
|
|
|
+ // });
|
|
|
+ this.page.total= this.allRelation?.objectInfo?.length;
|
|
|
+ this.gridData = this.allRelation?.objectInfo.slice((this.page.currentPage-1)*this.page.pageSize,this.page.currentPage*this.page.pageSize);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -97,6 +107,7 @@ export default class extends Vue {
|
|
|
*
|
|
|
*/
|
|
|
openEvent() {
|
|
|
+ this.page.pageSize
|
|
|
// 请求从关系接口
|
|
|
this.getTable();
|
|
|
}
|
|
@@ -111,15 +122,30 @@ export default class extends Vue {
|
|
|
fromId: this.mainId, //主对象id
|
|
|
toId: val.id, //从对象id
|
|
|
};
|
|
|
+ const delId = val.id
|
|
|
relDel(data).then((res) => {
|
|
|
if (res.result == "success") {
|
|
|
this.$message.success("删除成功!");
|
|
|
+ let delIndex = -1;
|
|
|
+ this.allRelation?.objectInfo.forEach((item:any,index:number)=>{
|
|
|
+ if(item.val == delId) {
|
|
|
+ delIndex = index
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.allRelation.objectInfo.splice(delIndex,1) //模拟删除
|
|
|
this.getTable();
|
|
|
} else {
|
|
|
this.$message.error("删除失败!");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 关闭按钮
|
|
|
+ */
|
|
|
+ closeLog(){
|
|
|
+ this.$emit('update')
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
</script>
|
|
|
<style lang="">
|