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
| <template>
| <Popup ref="pop" :title="form.title" left="calc(100% - 330px)">
| <div class="terrainDig">
| <el-form ref="form" :model="form" label-width="100px">
| <el-form-item label="深度(米):">
| <el-input-number
| v-model="form.depth"
| controls-position="right"
| @change="handleChange"
| :min="1"
| ></el-input-number>
| </el-form-item>
| <!-- <el-form-item label="添加墙体:">
| <el-switch v-model="form.showWall"></el-switch>
| </el-form-item> -->
| <el-form-item>
| <el-button type="primary" size="mini" @click="dig">绘制</el-button>
| <!-- <el-upload
| class="button-group"
| action=""
| :auto-upload="false"
| :show-file-list="false"
| :on-change="inputDig"
| accept=".json"
| >
| <el-button type="primary" size="mini" slot="trigger"
| >导入</el-button
| >
| </el-upload> -->
| </el-form-item>
| </el-form>
| </div>
| </Popup>
| </template>
| <script>
| import Popup from './Popup.vue';
|
| export default {
| name: 'terrainDig',
| components: {
| Popup,
| },
| data() {
| return {
| form: {
| title: '地形开挖',
| depth: 50,
| showWall: true,
| },
| };
| },
| computed: {},
| mounted() {},
| methods: {
| // 关闭弹窗
| close() {
| this.$refs.pop.close();
| },
| // 打开弹窗
| open() {
| this.$refs.pop.open();
| },
| // 输入框数据修改
| handleChange(value) {
| if (Excavation) {
| Excavation.setDeepth(value);
| }
| },
| // 地形开挖
| dig() {
| window.Excavation = sgworld.Analysis.TerrainExcavation(
| this.form.depth,
| {
| showWall: this.form.showWall,
| },
| (degreesArr) => {
| this.addToTree(Excavation, degreesArr);
| }
| );
| },
| inputDig(file) {
| let reader = new FileReader();
| reader.onload = (e) => {
| let data = JSON.parse(e.target.result);
| data &&
| data.forEach((item) => {
| let degreesArr = [];
| item.polygon.forEach((p) => {
| degreesArr.push(...p);
| });
| let length = degreesArr.length;
| if (
| degreesArr[0] === degreesArr[length - 3] &&
| degreesArr[1] === degreesArr[length - 2]
| ) {
| degreesArr.splice(length - 3, 3);
| }
| Excavation = sgworld.Analysis.TerrainExcavation(this.form.depth, {
| positions: degreesArr,
| showWall: this.form.showWall,
| });
| this.addToTree(Excavation, degreesArr);
| });
| this.$message('开挖区域已导入');
| };
| reader.readAsText(file.raw);
| },
| addToTree(excavation, degreesArr) {
| let data = {
| id: sgworld.Core.getuid(),
| name: '新建地形开挖',
| sourceType: 'excavate',
| item: excavation,
| depth: this.form.depth,
| showWall: this.form.showWall,
| positions: degreesArr,
| };
| // this.$parent.addAnalyseToTree(data);
| },
| },
| };
| </script>
| <style lang="less">
| .terrainDig {
| .el-input-number {
| width: 180px !important;
| }
| .el-button {
| margin-left: 10px;
| padding: 12px 30px;
| }
| .button-group {
| text-align: center;
| margin-top: 12px;
| }
| .el-form-item {
| margin-bottom: 10px;
| }
| }
| </style>
|
|