mapControl.vue
4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
<div>
<el-drawer
@mousedown.prevent
@selectstart.prevent
@dblclick.prevent
title="管制区域"
:visible.sync="control"
:direction="direction"
:before-close="handleClose"
class="no-select"
>
<div class="demo-input-suffix">
<map-table ref="mapTable"></map-table>
<br />
<el-form ref="form" :model="form" label-width="80px">
<el-row>
<el-col :span="23">
<el-form-item label="管制名称">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="管制点位">
<div>
<el-tag
v-for="(item, index) in form.point"
:key="index"
closable
:disable-transitions="true"
:hit="true"
@close="handlePointDel(item)"
>{{ item }}</el-tag
>
</div>
<!-- <el-input
v-model="form.point"
type="textarea"
:rows="10"
></el-input> -->
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div class="drawer__footer">
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="handleOk">确 定</el-button>
</div>
</el-drawer>
</div>
</template>
<script>
import { formatTime, openConfirm, showMsg } from "@/utils/index.js";
import mapTable from "./mapTable.vue";
export default {
name: "mapControl",
components: {
mapTable,
},
props: {},
data() {
return {
//画布
graph: null,
control: false,
direction: "rtl",
form: {},
tableCol: [
{
label: "序号",
prop: "id",
width: 60,
},
{
label: "管制名称",
prop: "name",
width: 80,
},
{
label: "管制节点",
prop: "point",
},
],
tableData: [
{
id: 1,
name: "A",
point: "400280,440280",
},
{
id: 2,
name: "B",
point: "200160,280160",
},
],
};
},
mounted() {},
methods: {
//管制点位删除
handlePointDel(item) {
this.form.point.splice(this.form.point.indexOf(item), 1);
},
//管制区域
controlEdit(node) {
this.form = {
name: "",
point: [],
};
this.graph.getSelectedCells().forEach((cell) => {
if (cell.shape == "Point") {
this.form.point.push(cell.data.code);
}
});
this.control = true;
this.$nextTick(() => {
this.$refs.mapTable.isDelete = true;
this.$refs.mapTable.tableCol = this.tableCol;
this.$refs.mapTable.tableData = this.tableData;
});
},
//管制区域确定
handleOk() {
if (this.form.name == "") {
showMsg("管制名称不能为空,请输入!", false);
return;
} else {
var isRe = false;
for (let i = 0; i < this.tableData.length; i++) {
if (this.form.name == this.tableData[i].name) {
this.tableData[i].point = this.form.point.join(",");
isRe = true;
}
}
if (!isRe) {
this.tableData.push({
id: this.tableData.length + 1,
name: this.form.name,
point: this.form.point.join(","),
});
}
this.$refs.mapTable.tableData = this.tableData;
// this.graph.getNodes().forEach((item) => {
// if (item.shape == "Point") {
// item.data.control = this.getControlData();
// }
// });
this.control = false;
}
},
//获取管制区域数据
getControlData() {
// for (let i = 0; i < this.tableData.length; i++) {
// this.tableData[i].point = this.tableData[i].point.split(",");
// }
return this.tableData;
},
handleClose(done) {
this.control = false;
},
},
};
</script>
<style lang="scss" scoped>
.drawer__footer {
position: absolute;
bottom: 10px;
right: 10px;
}
.el-tag + .el-tag {
margin-left: 10px;
}
</style>