ap-dev 1.2.25 → 1.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/abap/ApiPanel/components/ApiContent.vue +1 -1
  2. package/abap/ApiPanel/components/ApiTable.vue +1 -1
  3. package/abap/ApiPanel/components/ApiTittle1.vue +1 -1
  4. package/abap/ApiPanel/components/ApiTittle2.vue +1 -1
  5. package/abap/ApiPanel/components/index.js +1 -1
  6. package/abap/CodePanel/abapKeywords.js +6 -6
  7. package/abap/CodePanel/componentMenus.js +28 -28
  8. package/abap/ConfigPanel/AbapCustomTable.vue +122 -122
  9. package/abap/ConfigPanel/AbapDocHistory.vue +145 -145
  10. package/abap/ConfigPanel/AbapSql.vue +81 -81
  11. package/abap/ConfigPanel/AbapTable.vue +379 -379
  12. package/abap/ConfigPanel/AbapTableCondition.vue +213 -213
  13. package/abap/ConfigPanel/AbapTableLink.vue +391 -391
  14. package/abap/SqlPanel/index.vue +1088 -1088
  15. package/abap/abap/abapStore.js +27 -27
  16. package/abap/abap/index.vue +87 -87
  17. package/abap/components/SapTable.vue +129 -129
  18. package/abap/components/SapTableField.vue +161 -161
  19. package/dev/ApiPanel/components/ApiCode.vue +1 -1
  20. package/dev/ApiPanel/components/ApiContent.vue +1 -1
  21. package/dev/ApiPanel/components/ApiTable.vue +1 -1
  22. package/dev/ApiPanel/components/ApiTittle1.vue +1 -1
  23. package/dev/ApiPanel/components/ApiTittle2.vue +1 -1
  24. package/dev/ApiPanel/components/index.js +1 -1
  25. package/dev/ApiPanel/modules/ApiBaseLayout.vue +1 -1
  26. package/dev/ComponentsPanel/items/ApDevItemBase.vue +1 -1
  27. package/dev/ComponentsPanel/items/ApDevItemButton.vue +1 -1
  28. package/dev/ComponentsPanel/items/ApDevItemChartBar.vue +1 -1
  29. package/dev/ComponentsPanel/items/ApDevItemChartGauge.vue +1 -1
  30. package/dev/ComponentsPanel/items/ApDevItemChartLine.vue +1 -1
  31. package/dev/ComponentsPanel/items/ApDevItemChartPie.vue +1 -1
  32. package/dev/ComponentsPanel/items/ApDevItemChartRadar.vue +1 -1
  33. package/dev/ComponentsPanel/items/ApDevItemCheckbox.vue +1 -1
  34. package/dev/ComponentsPanel/items/ApDevItemDateTime.vue +1 -1
  35. package/dev/ComponentsPanel/items/ApDevItemForm.vue +1 -1
  36. package/dev/ComponentsPanel/items/ApDevItemInput.vue +1 -1
  37. package/dev/ComponentsPanel/items/ApDevItemInputNumber.vue +1 -1
  38. package/dev/ComponentsPanel/items/ApDevItemLoading.vue +1 -1
  39. package/dev/ComponentsPanel/items/ApDevItemRadio.vue +1 -1
  40. package/dev/ComponentsPanel/items/ApDevItemSelect.vue +1 -1
  41. package/dev/ComponentsPanel/items/ApDevItemSwitch.vue +1 -1
  42. package/dev/ComponentsPanel/items/ApDevItemTooltip.vue +1 -1
  43. package/dev/ComponentsPanel/items/ApDevItemTree.vue +1 -1
  44. package/dev/ComponentsPanel/items/ApDevItemUpload.vue +1 -1
  45. package/dev/ComponentsPanel/items/test.vue +1 -1
  46. package/dev/ConfigPanel/DevCpt.vue +1036 -1036
  47. package/dev/ConfigPanel/DevCptBase.vue +210 -210
  48. package/dev/ConfigPanel/DevDbSource.vue +108 -108
  49. package/dev/ConfigPanel/DevDbUserSource.vue +117 -117
  50. package/dev/ConfigPanel/DevDocHistory.vue +145 -145
  51. package/dev/ConfigPanel/DevMyConfig.vue +205 -205
  52. package/dev/CustomPanel/CustomComponents.vue +10 -10
  53. package/dev/CustomPanel/CustomDataTree.vue +1 -1
  54. package/dev/CustomPanel/CustomTools.vue +1 -1
  55. package/dev/CustomPanel/index.vue +1 -1
  56. package/dev/CustomPanel/items/ApDevCheckbox.vue +7 -7
  57. package/dev/CustomPanel/items/ApDevCheckboxProp.vue +1 -1
  58. package/dev/CustomPanel/items/ApDevContainerRow.vue +155 -155
  59. package/dev/CustomPanel/items/ApDevContainerRowProp.vue +39 -39
  60. package/dev/CustomPanel/items/ApDevDateTime.vue +5 -5
  61. package/dev/CustomPanel/items/ApDevDateTimeProp.vue +1 -1
  62. package/dev/CustomPanel/items/ApDevDefaultProp.vue +20 -20
  63. package/dev/CustomPanel/items/ApDevInput.vue +49 -49
  64. package/dev/CustomPanel/items/ApDevInputNumber.vue +57 -57
  65. package/dev/CustomPanel/items/ApDevInputNumberProp.vue +96 -96
  66. package/dev/CustomPanel/items/ApDevInputProp.vue +85 -85
  67. package/dev/CustomPanel/items/ApDevRadio.vue +7 -7
  68. package/dev/CustomPanel/items/ApDevRadioProp.vue +1 -1
  69. package/dev/CustomPanel/items/ApDevSelect.vue +314 -314
  70. package/dev/CustomPanel/items/ApDevSelectProp.vue +83 -83
  71. package/dev/CustomPanel/items/ApDevTree.vue +5 -5
  72. package/dev/CustomPanel/items/ApDevTreeProp.vue +1 -1
  73. package/dev/CustomPanel/items/ApDevUpload.vue +6 -6
  74. package/dev/CustomPanel/items/ApDevUploadProp.vue +1 -1
  75. package/dev/CustomPanel/items/base/ApDevBase.vue +1 -1
  76. package/dev/CustomPanel/items/base/ApDevItemBase.vue +2 -2
  77. package/dev/CustomPanel/items/base/ApDevPropBase.vue +1 -1
  78. package/dev/CustomPanel/items/base/ApDevPropStyle.vue +93 -93
  79. package/dev/dev/DevUtil.js +31 -31
  80. package/dev/dev/devConfig.js +99 -99
  81. package/dev/dev/devStore.js +368 -368
  82. package/dev/dev/index.vue +85 -85
  83. package/ops/ApiPanel/components/ApiContent.vue +1 -1
  84. package/ops/ApiPanel/components/ApiTable.vue +1 -1
  85. package/ops/ApiPanel/components/ApiTittle1.vue +1 -1
  86. package/ops/ApiPanel/components/ApiTittle2.vue +1 -1
  87. package/ops/ApiPanel/components/index.js +1 -1
  88. package/ops/ConfigPanel/OpsDocHistory.vue +145 -145
  89. package/ops/ops/index.vue +60 -60
  90. package/ops/ops/opsStore.js +27 -27
  91. package/package.json +1 -1
@@ -1,368 +1,368 @@
1
- import Vuex from 'vuex'
2
- import Vue from 'vue'
3
- import { deepClone } from 'ap-util/util/ObjectUtil'
4
- import { formatDate } from 'ap-util/util/DateUtil'
5
-
6
- // 获取组件的store对象
7
- const getItemByRef = function(ref, data) {
8
- if (data != null && data.ref == ref) {
9
- return data
10
- }
11
- if (data != null && data.children != null && data.children.length > 0) {
12
- for (var i = 0; i < data.children.length; i++) {
13
- var tempData = getItemByRef(ref, data.children[i])
14
- if (tempData != null) {
15
- return tempData
16
- }
17
- }
18
- }
19
- }
20
-
21
- // 获取组件的父store对象
22
- const getParentItemByRef = function(ref, data) {
23
- if (data == null || data.children == null || data.children.length < 1) {
24
- return null
25
- }
26
- for (var i = 0; i < data.children.length; i++) {
27
- if (data.children[i].ref == ref) {
28
- return data
29
- }
30
- var tempData = getParentItemByRef(ref, data.children[i])
31
- if (tempData != null) {
32
- return tempData
33
- }
34
- }
35
- }
36
-
37
- // 获取item的索引
38
- const getItemIndexByRef = function(ref, data) {
39
- const parentItem = getParentItemByRef(ref, data)
40
- for (let i = 0; i < parentItem.children.length; i++) {
41
- if (parentItem.children[i].ref == ref) {
42
- return i
43
- }
44
- }
45
- }
46
-
47
- const getNewRef = function(type) {
48
- // 三位编号:取store根路径rootContainer的seq
49
- const seq = apDevStore.state.json.seq
50
- // 更新seq
51
- apDevStore.commit('seqIncrease')
52
- return type + '_' + (Array(3).join('0') + seq).slice(-3)
53
- }
54
-
55
- const setNewRef = function(item) {
56
- if (item == null) {
57
- return
58
- }
59
- item.ref = getNewRef(item.type)
60
- const children = item.children
61
- if (children != null && children.length > 0) {
62
- for (let i = 0; i < children.length; i++) {
63
- setNewRef(children[i])
64
- }
65
- }
66
- }
67
-
68
- const apDevStore = new Vuex.Store({
69
- state: {
70
- json: {
71
- ref: 'rootContainer', // 默认父容器
72
- type: 'containerRow',
73
- seq: 1, // 组件数量计数
74
- children: []
75
- },
76
- currentComps: {
77
- ref: '',
78
- type: 'ap-dev-default-prop'
79
- },
80
- history: {
81
- currentIndex: 0,
82
- data: []
83
- },
84
- tempData: {
85
- copyItem: {},
86
- currentDesignPanel: 'api-panel',
87
- currentModel: 'AP'
88
- }
89
- },
90
- strict: true,
91
- getters: {
92
- // 获取组件:根据ref
93
- getItem: (state) => (ref) => {
94
- return getItemByRef(ref, state.json)
95
- },
96
- // 获取json
97
- getJson: (state) => {
98
- return state.json
99
- }
100
- },
101
- mutations: {
102
- // 历史记录:增加
103
- historyAdd(state, param) {
104
- if (state.history.currentIndex > 0) {
105
- state.history.data.splice(0, state.history.currentIndex)
106
- }
107
- param.date = formatDate(new Date(), 'MM-dd hh:mm')
108
- param.data = deepClone(state.json)
109
- state.history.data.splice(0, 0, param)
110
- state.history.currentIndex = 0
111
- },
112
- // 序列增加
113
- seqIncrease(state) {
114
- state.json.seq++
115
- },
116
- // 更新当前选择组件
117
- updateCurrentItem(state, param) {
118
- const propType = 'ap-dev-' + param.type + '-prop'
119
- const newObj = {
120
- type: propType,
121
- ref: param.ref
122
- }
123
- state.currentComps = newObj
124
- },
125
- // 重置当前选择组件
126
- resetCurrentItem(state) {
127
- this.commit('updateCurrentItem', {
128
- type: 'default',
129
- ref: ''
130
- })
131
- },
132
-
133
- // 通用:添加组件store数据:参数 -> 父组件ref、添加位置、添加对象
134
- addItem(state, param) {
135
- if (param == null) {
136
- return
137
- }
138
- var item = getItemByRef(param.parentRef, state.json)
139
- // 指定位置插入新元素
140
- item.children.splice(param.dataIndex, 0, param.obj)
141
- },
142
- // 通用:删除组件
143
- removeItem(state, param) {
144
- var parent = getParentItemByRef(param.ref, state.json)
145
- if (!parent) {
146
- return
147
- }
148
- var children = parent.children
149
- for (var i = 0; i < children.length; i++) {
150
- if (children[i].ref == param.ref) {
151
- children.splice(i, 1)
152
- return
153
- }
154
- }
155
- },
156
-
157
- // 属性修改:初始化组件options
158
- propInitItemOptions(state, param) {
159
- console.log('属性修改:store -> ' + param.ref + '参数初始化')
160
- var item = getItemByRef(param.ref, state.json)
161
- Vue.set(item, 'options', param.options)
162
- },
163
- // 属性修改:更新options
164
- propUpdateItemOptions(state, param) {
165
- const item = getItemByRef(param.ref, state.json)
166
- // 避免不同组件的itemClick,也会调用该方法,从而多余的更新
167
- if (JSON.stringify(item.options) != JSON.stringify(param.obj)) {
168
- Vue.set(item, 'options', deepClone(param.obj))
169
- console.log('属性修改:store -> ' + param.ref + '更新组件options')
170
- // 添加历史记录
171
- this.commit('historyAdd', {
172
- type: 'propUpdateItemOptions',
173
- msg: '组件属性更新【' + param.ref + '】'
174
- })
175
- }
176
- },
177
-
178
- // 拖拽:添加组件
179
- mainAddItem(state, param) {
180
- console.log('拖拽:store -> ' + param.parentRef + '添加组件')
181
- this.commit('addItem', param)
182
-
183
- // 添加历史记录
184
- this.commit('historyAdd', {
185
- type: 'mainAddItem',
186
- msg: '添加组件【' + param.obj.type + '】'
187
- })
188
- },
189
- // 拖拽:同一容器交换位置
190
- mainSwapItemWithSameCtn(state, param) {
191
- console.log('拖拽:store -> ' + param.ref + '组件交换位置')
192
- const parent = getParentItemByRef(param.ref, state.json)
193
- const children = parent.children
194
- const newItem = deepClone(children[param.newIndex])
195
- const oldItem = deepClone(children[param.oldIndex])
196
- Vue.set(children, param.newIndex, oldItem)
197
- Vue.set(children, param.oldIndex, newItem)
198
- // 添加历史记录
199
- this.commit('historyAdd', {
200
- type: 'mainSwapItemWithSameCtn',
201
- msg: '容器交换位置【' + param.ref + '】'
202
- })
203
- },
204
- // 拖拽:不同容器交换位置
205
- mainSwapItemWithDiffCtn(state, param) {
206
- console.log('拖拽:store -> ' + param.ref + '组件交换位置')
207
- this.commit('removeItem', param)
208
- this.commit('addItem', param)
209
- // 添加历史记录
210
- this.commit('historyAdd', {
211
- type: 'mainSwapItemWithDiffCtn',
212
- msg: '容器位置修改【' + param.ref + '】'
213
- })
214
- },
215
-
216
- // 树结构拖动:先删除,再增加
217
- treeUpdate(state, param) {
218
- console.log('树:拖拽更新')
219
- const draggingItem = getItemByRef(param.draggingNodeRef, state.json)
220
- const dropNodeItem = getItemByRef(param.dropNodeRef, state.json)
221
-
222
- var parentItem = getParentItemByRef(param.dropNodeRef, state.json)
223
- var parentRef = ''
224
- var dataIndex = ''
225
-
226
- // 移除拖的组件
227
- this.commit('removeItem', {
228
- ref: param.draggingNodeRef
229
- })
230
-
231
- switch (param.dropType) {
232
- case 'before':
233
- parentRef = parentItem.ref
234
- dataIndex = getItemIndexByRef(param.dropNodeRef, state.json)
235
- break
236
- case 'after':
237
- parentRef = parentItem.ref
238
- dataIndex = getItemIndexByRef(param.dropNodeRef, state.json) + 1
239
- break
240
- case 'inner':
241
- parentRef = param.dropNodeRef
242
- dataIndex = dropNodeItem.children.length
243
- break
244
- }
245
- // 添加组件
246
- this.commit('addItem', {
247
- parentRef: parentRef,
248
- dataIndex: dataIndex,
249
- obj: deepClone(draggingItem)
250
- })
251
- // 添加历史记录
252
- this.commit('historyAdd', {
253
- type: 'treeUpdate',
254
- msg: '树拖动位置【' + param.draggingNodeRef + '】'
255
- })
256
- },
257
-
258
- // 工具栏操作:重复
259
- toolRepeatItem(state, param) {
260
- console.log('工具栏:store -> ' + param.ref + '组件重复')
261
- const ref = param.ref
262
- const parent = getParentItemByRef(ref, state.json)
263
- const newItem = deepClone(getItemByRef(ref, state.json))
264
- setNewRef(newItem)
265
- const children = parent.children
266
- for (let i = 0; i < children.length; i++) {
267
- if (children[i].ref == ref) {
268
- children.splice(i + 1, 0, newItem)
269
- // 添加历史记录
270
- this.commit('historyAdd', {
271
- type: 'toolRepeatItem',
272
- msg: '重复操作【' + param.ref + '】'
273
- })
274
- return newItem.ref
275
- }
276
- }
277
- },
278
- // 工具栏操作:复制
279
- toolCopyItem(state, param) {
280
- console.log('工具栏:store -> ' + param.ref + '组件复制')
281
- const copyItem = deepClone(getItemByRef(param.ref, state.json))
282
- Vue.set(state.tempData, 'copyItem', copyItem)
283
- // 添加历史记录
284
- this.commit('historyAdd', {
285
- type: 'toolCopyItem',
286
- msg: '复制操作【' + param.ref + '】'
287
- })
288
- },
289
- // 工具栏操作:粘贴
290
- toolPasteItem(state, param) {
291
- console.log('工具栏:store -> ' + param.ref + '组件粘贴')
292
- const ref = param.ref
293
- const parent = getParentItemByRef(ref, state.json)
294
- const newItem = deepClone(state.tempData.copyItem)
295
- setNewRef(newItem)
296
- const children = parent.children
297
- for (let i = 0; i < children.length; i++) {
298
- if (children[i].ref == ref) {
299
- children.splice(i + 1, 0, newItem)
300
- return newItem.ref
301
- }
302
- }
303
- // 添加历史记录
304
- this.commit('historyAdd', {
305
- type: 'toolPasteItem',
306
- msg: '粘贴操作【' + param.ref + '】'
307
- })
308
- },
309
- // 工具栏操作:删除
310
- toolRemoveItem(state, param) {
311
- console.log('工具栏:store -> ' + param.ref + '组件删除')
312
- this.commit('removeItem', param)
313
-
314
- // 重置当前选择
315
- this.commit('resetCurrentItem')
316
-
317
- // 添加历史记录
318
- this.commit('historyAdd', {
319
- type: 'toolRemoveItem',
320
- msg: '删除操作【' + param.ref + '】'
321
- })
322
- },
323
- // 工具栏操作:回滚
324
- toolRevertStore(state, param) {
325
- const index = param.index
326
- Vue.set(state, 'json', deepClone(state.history.data[index].data))
327
- // 重置当前选择
328
- this.commit('resetCurrentItem')
329
- console.log(state.json)
330
- },
331
- revokeOperate(state) {
332
- const hisData = state.history.data
333
-
334
- if (hisData.length - 1 <= state.history.currentIndex) {
335
- console.log('已经是最后一个操作了,不能回滚了')
336
- return
337
- }
338
- state.history.currentIndex++
339
- Vue.set(state, 'json', deepClone(hisData[state.history.currentIndex].data))
340
- },
341
- redoOperate(state) {
342
- const hisData = state.history.data
343
-
344
- if (state.history.currentIndex <= 0) {
345
- console.log('已经是最新操作了,不能重做了')
346
- return
347
- }
348
- state.history.currentIndex--
349
- Vue.set(state, 'json', deepClone(hisData[state.history.currentIndex].data))
350
- },
351
- // 更新当前设计的页面
352
- updateCurrentDesignPanel(state, param) {
353
- state.tempData.currentDesignPanel = param
354
- },
355
- // 更新当前设计的页面
356
- updateCurrentModel(state, param) {
357
- state.tempData.currentModel = param
358
- }
359
-
360
-
361
- }
362
-
363
- })
364
-
365
-
366
-
367
-
368
- export default apDevStore
1
+ import Vuex from 'vuex'
2
+ import Vue from 'vue'
3
+ import { deepClone } from 'ap-util/util/ObjectUtil'
4
+ import { formatDate } from 'ap-util/util/DateUtil'
5
+
6
+ // 获取组件的store对象
7
+ const getItemByRef = function(ref, data) {
8
+ if (data != null && data.ref == ref) {
9
+ return data
10
+ }
11
+ if (data != null && data.children != null && data.children.length > 0) {
12
+ for (var i = 0; i < data.children.length; i++) {
13
+ var tempData = getItemByRef(ref, data.children[i])
14
+ if (tempData != null) {
15
+ return tempData
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ // 获取组件的父store对象
22
+ const getParentItemByRef = function(ref, data) {
23
+ if (data == null || data.children == null || data.children.length < 1) {
24
+ return null
25
+ }
26
+ for (var i = 0; i < data.children.length; i++) {
27
+ if (data.children[i].ref == ref) {
28
+ return data
29
+ }
30
+ var tempData = getParentItemByRef(ref, data.children[i])
31
+ if (tempData != null) {
32
+ return tempData
33
+ }
34
+ }
35
+ }
36
+
37
+ // 获取item的索引
38
+ const getItemIndexByRef = function(ref, data) {
39
+ const parentItem = getParentItemByRef(ref, data)
40
+ for (let i = 0; i < parentItem.children.length; i++) {
41
+ if (parentItem.children[i].ref == ref) {
42
+ return i
43
+ }
44
+ }
45
+ }
46
+
47
+ const getNewRef = function(type) {
48
+ // 三位编号:取store根路径rootContainer的seq
49
+ const seq = apDevStore.state.json.seq
50
+ // 更新seq
51
+ apDevStore.commit('seqIncrease')
52
+ return type + '_' + (Array(3).join('0') + seq).slice(-3)
53
+ }
54
+
55
+ const setNewRef = function(item) {
56
+ if (item == null) {
57
+ return
58
+ }
59
+ item.ref = getNewRef(item.type)
60
+ const children = item.children
61
+ if (children != null && children.length > 0) {
62
+ for (let i = 0; i < children.length; i++) {
63
+ setNewRef(children[i])
64
+ }
65
+ }
66
+ }
67
+
68
+ const apDevStore = new Vuex.Store({
69
+ state: {
70
+ json: {
71
+ ref: 'rootContainer', // 默认父容器
72
+ type: 'containerRow',
73
+ seq: 1, // 组件数量计数
74
+ children: []
75
+ },
76
+ currentComps: {
77
+ ref: '',
78
+ type: 'ap-dev-default-prop'
79
+ },
80
+ history: {
81
+ currentIndex: 0,
82
+ data: []
83
+ },
84
+ tempData: {
85
+ copyItem: {},
86
+ currentDesignPanel: 'api-panel',
87
+ currentModel: 'AP'
88
+ }
89
+ },
90
+ strict: true,
91
+ getters: {
92
+ // 获取组件:根据ref
93
+ getItem: (state) => (ref) => {
94
+ return getItemByRef(ref, state.json)
95
+ },
96
+ // 获取json
97
+ getJson: (state) => {
98
+ return state.json
99
+ }
100
+ },
101
+ mutations: {
102
+ // 历史记录:增加
103
+ historyAdd(state, param) {
104
+ if (state.history.currentIndex > 0) {
105
+ state.history.data.splice(0, state.history.currentIndex)
106
+ }
107
+ param.date = formatDate(new Date(), 'MM-dd hh:mm')
108
+ param.data = deepClone(state.json)
109
+ state.history.data.splice(0, 0, param)
110
+ state.history.currentIndex = 0
111
+ },
112
+ // 序列增加
113
+ seqIncrease(state) {
114
+ state.json.seq++
115
+ },
116
+ // 更新当前选择组件
117
+ updateCurrentItem(state, param) {
118
+ const propType = 'ap-dev-' + param.type + '-prop'
119
+ const newObj = {
120
+ type: propType,
121
+ ref: param.ref
122
+ }
123
+ state.currentComps = newObj
124
+ },
125
+ // 重置当前选择组件
126
+ resetCurrentItem(state) {
127
+ this.commit('updateCurrentItem', {
128
+ type: 'default',
129
+ ref: ''
130
+ })
131
+ },
132
+
133
+ // 通用:添加组件store数据:参数 -> 父组件ref、添加位置、添加对象
134
+ addItem(state, param) {
135
+ if (param == null) {
136
+ return
137
+ }
138
+ var item = getItemByRef(param.parentRef, state.json)
139
+ // 指定位置插入新元素
140
+ item.children.splice(param.dataIndex, 0, param.obj)
141
+ },
142
+ // 通用:删除组件
143
+ removeItem(state, param) {
144
+ var parent = getParentItemByRef(param.ref, state.json)
145
+ if (!parent) {
146
+ return
147
+ }
148
+ var children = parent.children
149
+ for (var i = 0; i < children.length; i++) {
150
+ if (children[i].ref == param.ref) {
151
+ children.splice(i, 1)
152
+ return
153
+ }
154
+ }
155
+ },
156
+
157
+ // 属性修改:初始化组件options
158
+ propInitItemOptions(state, param) {
159
+ console.log('属性修改:store -> ' + param.ref + '参数初始化')
160
+ var item = getItemByRef(param.ref, state.json)
161
+ Vue.set(item, 'options', param.options)
162
+ },
163
+ // 属性修改:更新options
164
+ propUpdateItemOptions(state, param) {
165
+ const item = getItemByRef(param.ref, state.json)
166
+ // 避免不同组件的itemClick,也会调用该方法,从而多余的更新
167
+ if (JSON.stringify(item.options) != JSON.stringify(param.obj)) {
168
+ Vue.set(item, 'options', deepClone(param.obj))
169
+ console.log('属性修改:store -> ' + param.ref + '更新组件options')
170
+ // 添加历史记录
171
+ this.commit('historyAdd', {
172
+ type: 'propUpdateItemOptions',
173
+ msg: '组件属性更新【' + param.ref + '】'
174
+ })
175
+ }
176
+ },
177
+
178
+ // 拖拽:添加组件
179
+ mainAddItem(state, param) {
180
+ console.log('拖拽:store -> ' + param.parentRef + '添加组件')
181
+ this.commit('addItem', param)
182
+
183
+ // 添加历史记录
184
+ this.commit('historyAdd', {
185
+ type: 'mainAddItem',
186
+ msg: '添加组件【' + param.obj.type + '】'
187
+ })
188
+ },
189
+ // 拖拽:同一容器交换位置
190
+ mainSwapItemWithSameCtn(state, param) {
191
+ console.log('拖拽:store -> ' + param.ref + '组件交换位置')
192
+ const parent = getParentItemByRef(param.ref, state.json)
193
+ const children = parent.children
194
+ const newItem = deepClone(children[param.newIndex])
195
+ const oldItem = deepClone(children[param.oldIndex])
196
+ Vue.set(children, param.newIndex, oldItem)
197
+ Vue.set(children, param.oldIndex, newItem)
198
+ // 添加历史记录
199
+ this.commit('historyAdd', {
200
+ type: 'mainSwapItemWithSameCtn',
201
+ msg: '容器交换位置【' + param.ref + '】'
202
+ })
203
+ },
204
+ // 拖拽:不同容器交换位置
205
+ mainSwapItemWithDiffCtn(state, param) {
206
+ console.log('拖拽:store -> ' + param.ref + '组件交换位置')
207
+ this.commit('removeItem', param)
208
+ this.commit('addItem', param)
209
+ // 添加历史记录
210
+ this.commit('historyAdd', {
211
+ type: 'mainSwapItemWithDiffCtn',
212
+ msg: '容器位置修改【' + param.ref + '】'
213
+ })
214
+ },
215
+
216
+ // 树结构拖动:先删除,再增加
217
+ treeUpdate(state, param) {
218
+ console.log('树:拖拽更新')
219
+ const draggingItem = getItemByRef(param.draggingNodeRef, state.json)
220
+ const dropNodeItem = getItemByRef(param.dropNodeRef, state.json)
221
+
222
+ var parentItem = getParentItemByRef(param.dropNodeRef, state.json)
223
+ var parentRef = ''
224
+ var dataIndex = ''
225
+
226
+ // 移除拖的组件
227
+ this.commit('removeItem', {
228
+ ref: param.draggingNodeRef
229
+ })
230
+
231
+ switch (param.dropType) {
232
+ case 'before':
233
+ parentRef = parentItem.ref
234
+ dataIndex = getItemIndexByRef(param.dropNodeRef, state.json)
235
+ break
236
+ case 'after':
237
+ parentRef = parentItem.ref
238
+ dataIndex = getItemIndexByRef(param.dropNodeRef, state.json) + 1
239
+ break
240
+ case 'inner':
241
+ parentRef = param.dropNodeRef
242
+ dataIndex = dropNodeItem.children.length
243
+ break
244
+ }
245
+ // 添加组件
246
+ this.commit('addItem', {
247
+ parentRef: parentRef,
248
+ dataIndex: dataIndex,
249
+ obj: deepClone(draggingItem)
250
+ })
251
+ // 添加历史记录
252
+ this.commit('historyAdd', {
253
+ type: 'treeUpdate',
254
+ msg: '树拖动位置【' + param.draggingNodeRef + '】'
255
+ })
256
+ },
257
+
258
+ // 工具栏操作:重复
259
+ toolRepeatItem(state, param) {
260
+ console.log('工具栏:store -> ' + param.ref + '组件重复')
261
+ const ref = param.ref
262
+ const parent = getParentItemByRef(ref, state.json)
263
+ const newItem = deepClone(getItemByRef(ref, state.json))
264
+ setNewRef(newItem)
265
+ const children = parent.children
266
+ for (let i = 0; i < children.length; i++) {
267
+ if (children[i].ref == ref) {
268
+ children.splice(i + 1, 0, newItem)
269
+ // 添加历史记录
270
+ this.commit('historyAdd', {
271
+ type: 'toolRepeatItem',
272
+ msg: '重复操作【' + param.ref + '】'
273
+ })
274
+ return newItem.ref
275
+ }
276
+ }
277
+ },
278
+ // 工具栏操作:复制
279
+ toolCopyItem(state, param) {
280
+ console.log('工具栏:store -> ' + param.ref + '组件复制')
281
+ const copyItem = deepClone(getItemByRef(param.ref, state.json))
282
+ Vue.set(state.tempData, 'copyItem', copyItem)
283
+ // 添加历史记录
284
+ this.commit('historyAdd', {
285
+ type: 'toolCopyItem',
286
+ msg: '复制操作【' + param.ref + '】'
287
+ })
288
+ },
289
+ // 工具栏操作:粘贴
290
+ toolPasteItem(state, param) {
291
+ console.log('工具栏:store -> ' + param.ref + '组件粘贴')
292
+ const ref = param.ref
293
+ const parent = getParentItemByRef(ref, state.json)
294
+ const newItem = deepClone(state.tempData.copyItem)
295
+ setNewRef(newItem)
296
+ const children = parent.children
297
+ for (let i = 0; i < children.length; i++) {
298
+ if (children[i].ref == ref) {
299
+ children.splice(i + 1, 0, newItem)
300
+ return newItem.ref
301
+ }
302
+ }
303
+ // 添加历史记录
304
+ this.commit('historyAdd', {
305
+ type: 'toolPasteItem',
306
+ msg: '粘贴操作【' + param.ref + '】'
307
+ })
308
+ },
309
+ // 工具栏操作:删除
310
+ toolRemoveItem(state, param) {
311
+ console.log('工具栏:store -> ' + param.ref + '组件删除')
312
+ this.commit('removeItem', param)
313
+
314
+ // 重置当前选择
315
+ this.commit('resetCurrentItem')
316
+
317
+ // 添加历史记录
318
+ this.commit('historyAdd', {
319
+ type: 'toolRemoveItem',
320
+ msg: '删除操作【' + param.ref + '】'
321
+ })
322
+ },
323
+ // 工具栏操作:回滚
324
+ toolRevertStore(state, param) {
325
+ const index = param.index
326
+ Vue.set(state, 'json', deepClone(state.history.data[index].data))
327
+ // 重置当前选择
328
+ this.commit('resetCurrentItem')
329
+ console.log(state.json)
330
+ },
331
+ revokeOperate(state) {
332
+ const hisData = state.history.data
333
+
334
+ if (hisData.length - 1 <= state.history.currentIndex) {
335
+ console.log('已经是最后一个操作了,不能回滚了')
336
+ return
337
+ }
338
+ state.history.currentIndex++
339
+ Vue.set(state, 'json', deepClone(hisData[state.history.currentIndex].data))
340
+ },
341
+ redoOperate(state) {
342
+ const hisData = state.history.data
343
+
344
+ if (state.history.currentIndex <= 0) {
345
+ console.log('已经是最新操作了,不能重做了')
346
+ return
347
+ }
348
+ state.history.currentIndex--
349
+ Vue.set(state, 'json', deepClone(hisData[state.history.currentIndex].data))
350
+ },
351
+ // 更新当前设计的页面
352
+ updateCurrentDesignPanel(state, param) {
353
+ state.tempData.currentDesignPanel = param
354
+ },
355
+ // 更新当前设计的页面
356
+ updateCurrentModel(state, param) {
357
+ state.tempData.currentModel = param
358
+ }
359
+
360
+
361
+ }
362
+
363
+ })
364
+
365
+
366
+
367
+
368
+ export default apDevStore