|
@@ -1,12 +1,18 @@
|
|
|
<template>
|
|
|
<div id="floor_space">
|
|
|
<el-row>
|
|
|
+ <el-col class="btn-top" :span="12">
|
|
|
+ <el-button type="primary" @click="saveData">设置范围</el-button>
|
|
|
+ <el-button @click="clearData">清空</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-input
|
|
|
type="textarea"
|
|
|
:rows="2"
|
|
|
placeholder="此处填写范围描述"
|
|
|
- v-model="textarea"
|
|
|
+ v-model="floorSpaceTeXt"
|
|
|
>
|
|
|
</el-input>
|
|
|
</el-col>
|
|
@@ -15,25 +21,27 @@
|
|
|
<el-col :span="6">
|
|
|
<h5>空间类型</h5>
|
|
|
<el-tree
|
|
|
+ ref="tree"
|
|
|
+ @check="checkChange"
|
|
|
:data="spaceTree"
|
|
|
+ :default-checked-keys="choiceCheckList"
|
|
|
+ :default-expanded-keys="choiceCheckList"
|
|
|
show-checkbox
|
|
|
node-key="id"
|
|
|
- :default-expanded-keys="[2, 3]"
|
|
|
- :default-checked-keys="[5]"
|
|
|
:props="defaultProps"
|
|
|
>
|
|
|
</el-tree>
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
|
<h5>空间分区</h5>
|
|
|
- <el-checkbox-group v-model="checkList">
|
|
|
+ <el-checkbox-group v-model="SpacecheckList">
|
|
|
<el-checkbox
|
|
|
v-for="(item, key) in partitioneList"
|
|
|
:key="key"
|
|
|
class="checkList"
|
|
|
:label="item.name"
|
|
|
+ :value="item.code"
|
|
|
></el-checkbox>
|
|
|
- <el-checkbox class="checkList" label="复选框 A"></el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -41,7 +49,12 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { space_fun, space_zone } from "@/api/workScope.js";
|
|
|
+import {
|
|
|
+ space_fun,
|
|
|
+ space_zone,
|
|
|
+ set_scope,
|
|
|
+ get_scope,
|
|
|
+} from "@/api/workScope.js";
|
|
|
import { treeTranslation } from "@/until.js";
|
|
|
export default {
|
|
|
data() {
|
|
@@ -49,41 +62,153 @@ export default {
|
|
|
// 分区范围
|
|
|
partitioneList: [],
|
|
|
spaceTree: [], //空间树
|
|
|
+ choiceCheckList: [], //选中的树
|
|
|
defaultProps: {
|
|
|
children: "children",
|
|
|
label: "label",
|
|
|
},
|
|
|
checkList: [],
|
|
|
+ SpacecheckList: [], // 选中的空间分区
|
|
|
+ floorSpaceTeXt: "", // 楼层空间文本
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
+ checkChange(node, choiceKey) {
|
|
|
+ const list = [];
|
|
|
+ choiceKey.checkedKeys.forEach((msg) => {
|
|
|
+ if (msg != undefined) {
|
|
|
+ list.push(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.choiceCheckList = list;
|
|
|
+ },
|
|
|
+
|
|
|
//请求树结构
|
|
|
getSpaceTree() {
|
|
|
- space_fun({ target: "rtn" }).then((res) => {
|
|
|
- this.spaceTree = treeTranslation(res.rtn, ["code", "name", "children"]);
|
|
|
+ return new Promise((reslve, reject) => {
|
|
|
+ space_fun({ target: "rtn" })
|
|
|
+ .then((res) => {
|
|
|
+ this.spaceTree = treeTranslation(res.rtn, [
|
|
|
+ "code",
|
|
|
+ "name",
|
|
|
+ "children",
|
|
|
+ ]);
|
|
|
+ reslve();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ reject();
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
//请求空间区域类型
|
|
|
spaceZone() {
|
|
|
- space_zone({}).then((res) => {
|
|
|
- res.rtn.forEach((item) => {
|
|
|
- this.partitioneList.push({
|
|
|
- name: item.name,
|
|
|
- id: item.code,
|
|
|
+ return new Promise((reslve, reject) => {
|
|
|
+ space_zone({}).then((res) => {
|
|
|
+ res.rtn.forEach((item) => {
|
|
|
+ this.partitioneList.push({
|
|
|
+ name: item.name,
|
|
|
+ id: item.code,
|
|
|
+ });
|
|
|
});
|
|
|
+ reslve();
|
|
|
});
|
|
|
+ }).catch(() => {
|
|
|
+ reject();
|
|
|
});
|
|
|
},
|
|
|
- },
|
|
|
|
|
|
+ // 保存数据
|
|
|
+ saveData() {
|
|
|
+ let data1 = {
|
|
|
+ type: "zone",
|
|
|
+ target: "action",
|
|
|
+ codes: [],
|
|
|
+ };
|
|
|
+ let data2 = {
|
|
|
+ type: "sp_fun",
|
|
|
+ target: "action",
|
|
|
+ codes: [],
|
|
|
+ };
|
|
|
+
|
|
|
+ // 如果功能分区有选择
|
|
|
+ if (this.SpacecheckList.length) {
|
|
|
+ const codes = [];
|
|
|
+ this.partitioneList.forEach((item) => {
|
|
|
+ if (this.SpacecheckList.includes(item.name)) {
|
|
|
+ codes.push(item.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ data1.codes = codes;
|
|
|
+ }
|
|
|
+ if (this.choiceCheckList.length) {
|
|
|
+ const codes = [];
|
|
|
+ data2.codes = this.choiceCheckList;
|
|
|
+ }
|
|
|
+ Promise.all([set_scope(data1), set_scope(data2)]).then(() => {
|
|
|
+ this.readData();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ readData() {
|
|
|
+ const data1 = { type: "zone", target: "rtn" };
|
|
|
+ const data2 = { type: "sp_fun", target: "rtn" };
|
|
|
+ Promise.all([get_scope(data1), get_scope(data2)]).then((res) => {
|
|
|
+ // 功能分区
|
|
|
+ const checkList = res[0].rtn.map((obj) => {
|
|
|
+ return obj.code;
|
|
|
+ });
|
|
|
+ const nameList = [];
|
|
|
+ this.partitioneList.forEach((item) => {
|
|
|
+ if (checkList.includes(item.id)) {
|
|
|
+ nameList.push(item.name);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.SpacecheckList = nameList;
|
|
|
+
|
|
|
+ // 空间树回显
|
|
|
+ this.choiceCheckList = res[1].rtn.map((a) => {
|
|
|
+ return a.code;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //清空
|
|
|
+ clearData() {
|
|
|
+ this.$confirm("是否继续?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.SpacecheckList = [];
|
|
|
+ this.choiceCheckList = [];
|
|
|
+ this.$refs.tree.setCheckedKeys([]);
|
|
|
+ this.saveData();
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "删除成功!",
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: "已取消删除",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
created() {
|
|
|
- this.getSpaceTree();
|
|
|
- this.spaceZone();
|
|
|
+ Promise.all([this.getSpaceTree(), this.spaceZone()]).then((res) => {
|
|
|
+ this.readData();
|
|
|
+ });
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|
|
|
#floor_space {
|
|
|
+ .btn-top {
|
|
|
+ margin-bottom: 12px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ }
|
|
|
.checkList {
|
|
|
display: block;
|
|
|
}
|