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
| <template>
| <div>当前操作网格: {{ selectedGrid.gName }}</div>
| <div>网格编号:{{ selectedGrid.gId }}</div>
| <div>网格顶点:</div>
| <div v-for="(item, index) in selectedGrid.gSide" :key="index">
| {{ item }}
| </div>
| <div class="btn-group">
| <el-button @click="startOrCompleteEdit">{{
| isEdit ? '保存编辑' : '开始编辑'
| }}</el-button>
| <el-button :disabled="!isEdit" @click="cancelEdit"
| >取消编辑</el-button
| >
| </div>
| </template>
|
| <script>
| import { mapState, mapActions } from 'pinia';
| import { useGridStore } from '@/stores/grid';
|
| export default {
| props: {
| grid: {
| type: Object,
| default: () => {
| return { gName: '' };
| }
| }
| },
| data() {
| return {
| editing: false
| };
| },
| computed: {
| ...mapState(useGridStore, ['selectedGrid', 'isEdit'])
| },
| methods: {
| ...mapActions(useGridStore, [
| 'openGridEdit',
| 'closeGridEdit',
| 'saveSelectedGrid',
| 'quitSelectedGrid'
| ]),
| // 开始或完成保存编辑网格多边形
| startOrCompleteEdit() {
| if (this.isEdit) {
| this.saveSelectedGrid();
| this.closeGridEdit();
| } else {
| this.openGridEdit();
| }
| },
| // 取消编辑网格多边形
| cancelEdit() {
| this.quitSelectedGrid();
| this.closeGridEdit();
| }
| }
| };
| </script>
| <style scoped>
| .btn-group {
| display: flex;
| }
| </style>
|
|