|
@@ -41,7 +41,7 @@ import Handsontable from "handsontable-pro"
|
|
|
import 'handsontable-pro/dist/handsontable.full.css'
|
|
|
import zhCN from 'handsontable-pro/languages/zh-CN';
|
|
|
import qrcode from "@/components/ledger/lib/qrcode";
|
|
|
-import { updateBusiness, queryZone, updateZone, deleteZone, createBusiness, createBusinessList, delManySpace, isSpaceBuss } from "@/api/scan/request";
|
|
|
+import { updateBusiness, queryZone, updateZone, deleteZone, createZone, createBusiness, createBusinessList, delManySpace, isSpaceBuss } from "@/api/scan/request";
|
|
|
import { mapGetters, mapActions } from "vuex";
|
|
|
export default {
|
|
|
props: {
|
|
@@ -118,6 +118,7 @@ export default {
|
|
|
this.activeType = activeTabType
|
|
|
},
|
|
|
getData(buildMess) {
|
|
|
+ this.isLoading = true
|
|
|
if (buildMess) {
|
|
|
this.buildMess = buildMess
|
|
|
}
|
|
@@ -142,13 +143,13 @@ export default {
|
|
|
this.main = res.Content
|
|
|
if (this.main && this.main.length && this.main[0].RoomID) {
|
|
|
this.copyMain = tools.deepCopy(this.main);
|
|
|
- }
|
|
|
+ }
|
|
|
+ this.isLoading = false
|
|
|
this.getMain()
|
|
|
})
|
|
|
},
|
|
|
//获取表格主体内容
|
|
|
getMain() {
|
|
|
- this.isLoading = true;
|
|
|
if (!!this.hot) {
|
|
|
this.hot.destroy();
|
|
|
this.hot = null;
|
|
@@ -198,7 +199,6 @@ export default {
|
|
|
if (!!pro) {
|
|
|
pro.parentNode.removeChild(pro);
|
|
|
}
|
|
|
- this.isLoading = false;
|
|
|
},
|
|
|
//表格中的查看详情
|
|
|
eventClick(el, rowArr) {
|
|
@@ -249,7 +249,11 @@ export default {
|
|
|
let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
|
|
|
let data = []
|
|
|
for (let i = 0; i < param.length; i++) {
|
|
|
- data.push(param[i]);
|
|
|
+ if (param[i].RoomID) {
|
|
|
+ data.push(param[i])
|
|
|
+ } else {
|
|
|
+ this.handleCreateZone(param[i])
|
|
|
+ }
|
|
|
}
|
|
|
//如果data中包含/且data长度为1,将其转换成.
|
|
|
if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
|
|
@@ -290,21 +294,31 @@ export default {
|
|
|
this.$message("取消删除")
|
|
|
})
|
|
|
},
|
|
|
- // 新建
|
|
|
- createSq(param, change) {
|
|
|
- let seedData = {
|
|
|
- building_id: this.buildMess.buildCode,
|
|
|
- floor_id: this.buildMess.code,
|
|
|
- business_type: this.activeType.code == "GeneralZone" ? null : this.activeType.code,
|
|
|
- infos: {}
|
|
|
- };
|
|
|
- for (let i = 0; i < change.length; i++) {
|
|
|
- let arr = change[i][1].split(".");
|
|
|
- seedData[arr[0]][arr[1]] = [{
|
|
|
- value: change[i][3] != "" ? change[i][3] : null
|
|
|
- }];
|
|
|
+ //创建业务空间
|
|
|
+ handleCreateZone(param) {
|
|
|
+ let keys = Object.keys(param)
|
|
|
+ keys.map((key) => { //将值为空字符串的属性删除
|
|
|
+ if(param[key] == "") {
|
|
|
+ delete param[key]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!Object.keys(param).length) {
|
|
|
+ this.$message("新添加业务空间内容不能为空!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.buildMess.selectd && this.buildMess.selectd[0] && this.buildMess.selectd[1]) {
|
|
|
+ param.BuildingId = this.buildMess.selectd[0]
|
|
|
+ param.FloorId = this.buildMess.selectd[1]
|
|
|
+ } else if (this.buildMess.selectd && this.buildMess.selectd[0] && !this.buildMess.selectd[1]) {
|
|
|
+ param.BuildingId = this.buildMess.selectd[0]
|
|
|
+ }
|
|
|
+ let params = {
|
|
|
+ zone: this.zoneObj.code,
|
|
|
+ data: [param]
|
|
|
}
|
|
|
- this.createSpace(seedData);
|
|
|
+ createZone(params,(res) => {
|
|
|
+ this.getData()
|
|
|
+ })
|
|
|
},
|
|
|
// 修改
|
|
|
updateBusiness(data, change) {
|
|
@@ -331,32 +345,6 @@ export default {
|
|
|
})
|
|
|
updateZone(param, (res) => {})
|
|
|
},
|
|
|
- /** 请求部分 ------------------------------------ */
|
|
|
- createSpace(data) {
|
|
|
- let param = {
|
|
|
- ProjId: this.param.ProjId,
|
|
|
- secret: this.param.secret,
|
|
|
- data: {
|
|
|
- criterias: [data]
|
|
|
- }
|
|
|
- };
|
|
|
- createBusinessList(param).then(res => {
|
|
|
- if (res.data.Result == "success") {
|
|
|
- console.log(this.main);
|
|
|
- this.main.map(item => {
|
|
|
- if (!item.id) {
|
|
|
- item.id = res.data.id;
|
|
|
- item.infos.RoomID = res.data.id;
|
|
|
- item.infos.RoomName = res.data.RoomName;
|
|
|
- }
|
|
|
- });
|
|
|
- this.hot.loadData(this.main);
|
|
|
- this.reset()
|
|
|
- } else {
|
|
|
- this.$message.error("创建发生错误:" + res.data.ResultMsg);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
//获取被筛选掉的行号
|
|
|
trimmedRows() {
|
|
|
// var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
|
|
@@ -425,44 +413,41 @@ export default {
|
|
|
},
|
|
|
myRenderer(instance, td, row, col, prop, value, cellProperties) {
|
|
|
if (value) {
|
|
|
- td.innerHTML = "已关联";
|
|
|
+ td.innerHTML = "已关联"
|
|
|
} else {
|
|
|
- td.innerHTML = "未关联";
|
|
|
+ td.innerHTML = "未关联"
|
|
|
}
|
|
|
return td;
|
|
|
},
|
|
|
facilityRender(instance, td, row, col, prop, value, cellProperties) {
|
|
|
- td.style.color = "#409EFF";
|
|
|
- td.style.cursor = "pointer";
|
|
|
- td.innerHTML = "点击查看";
|
|
|
+ td.style.color = "#409EFF"
|
|
|
+ td.style.cursor = "pointer"
|
|
|
+ td.innerHTML = "点击查看"
|
|
|
return td;
|
|
|
},
|
|
|
/** 页面中的按钮事件--------------------------- */
|
|
|
addSp() {
|
|
|
- // this.dialog.addDevice = true
|
|
|
- // this.hot.downloadFile()
|
|
|
- // this.hot.getPlugin('exportFile').downloadFile("csv", { columnHeaders: true, exportHiddenRows: true, exportHiddenColumns: true, rowHeaders: true })
|
|
|
- if (this.main && this.main.length && !!this.main[0].RoomID) {
|
|
|
- this.hot.destroy();
|
|
|
- this.hot = null;
|
|
|
- this.main.unshift([]);
|
|
|
- this.getMain();
|
|
|
+ if (this.main && this.main.length && this.main[0].RoomID) {
|
|
|
+ this.hot.destroy()
|
|
|
+ this.hot = null
|
|
|
+ this.main.unshift({})
|
|
|
+ this.getMain()
|
|
|
} else {
|
|
|
if (this.main && this.main.length) {
|
|
|
- this.$message.error("请添加完成后继续添加");
|
|
|
+ this.$message("请添加完成后继续添加")
|
|
|
} else {
|
|
|
- this.main.unshift([]);
|
|
|
- this.getMain();
|
|
|
+ this.main.unshift({})
|
|
|
+ this.getMain()
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
//刷新
|
|
|
reset() {
|
|
|
- this.getData();
|
|
|
+ this.getData()
|
|
|
},
|
|
|
//撤回操作
|
|
|
undo() {
|
|
|
- this.hot.undo();
|
|
|
+ this.hot.undo()
|
|
|
},
|
|
|
/** 分页事件------------------------ */
|
|
|
//切换每页显示多少条数据
|