web-component-gallery 1.3.12 → 2.0.2

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 (218) hide show
  1. package/dist/923.umd.js +1 -0
  2. package/dist/index.umd.js +1 -12252
  3. package/dist/js.umd.js +1 -0
  4. package/dist/style.css +17 -0
  5. package/dist/style.umd.js +1 -0
  6. package/{method → extensions}/AMap.js +1 -5
  7. package/{plugins/method → extensions}/Dialog.js +2 -2
  8. package/{lib/lazy_use.js → extensions/index.js} +16 -2
  9. package/lib/{amap/components/AmapSearch/index.jsx → amap-comp/AmapSearch.jsx} +3 -5
  10. package/lib/amap-comp/index.js +18 -0
  11. package/{plugins/lib/amap/components/AmapSearch/index.less → lib/amap-comp/style/AmapSearch.less} +5 -3
  12. package/lib/amap-comp/style/index.js +1 -0
  13. package/lib/amap-comp/style/index.less +1 -0
  14. package/lib/{amap/AmapDraw.jsx → amap-draw/index.jsx} +2 -4
  15. package/lib/amap-draw/style/index.js +1 -0
  16. package/lib/{amap/AmapDraw.less → amap-draw/style/index.less} +6 -3
  17. package/lib/browse/index.jsx +0 -2
  18. package/lib/browse/style/index.js +1 -0
  19. package/lib/button/Button.js +1 -3
  20. package/lib/button/style/index.js +1 -0
  21. package/{plugins/lib/dateTime → lib/date-time}/index.vue +3 -13
  22. package/lib/date-time/style/index.js +1 -0
  23. package/lib/date-time/style/index.less +7 -0
  24. package/lib/{descriptions → descriptions-list}/index.jsx +1 -3
  25. package/lib/descriptions-list/style/index.js +1 -0
  26. package/{plugins/lib/tree → lib/directory}/Directory.js +4 -21
  27. package/lib/directory/index.js +8 -0
  28. package/lib/directory/style/index.js +1 -0
  29. package/lib/{tree/style/Directory.less → directory/style/index.less} +3 -4
  30. package/{plugins/lib/form/components → lib/form-comp}/ACascaderMultiple.vue +1 -106
  31. package/lib/form-comp/ARadio.vue +70 -0
  32. package/lib/{form/components → form-comp}/ARangePicker.vue +9 -20
  33. package/lib/{form/components → form-comp}/ASelectCustom.vue +1 -8
  34. package/lib/form-comp/ATagsInput.vue +88 -0
  35. package/lib/form-comp/ATimePicker.vue +127 -0
  36. package/lib/{form/components → form-comp}/AUpload.vue +2 -17
  37. package/lib/form-comp/index.js +37 -0
  38. package/lib/form-comp/style/ACascaderMultiple.less +117 -0
  39. package/lib/form-comp/style/ARadio.less +0 -0
  40. package/lib/form-comp/style/ARangePicker.less +11 -0
  41. package/lib/form-comp/style/ASelectCustom.less +4 -0
  42. package/lib/form-comp/style/ATagsInput.less +24 -0
  43. package/lib/form-comp/style/ATimePicker.less +8 -0
  44. package/lib/form-comp/style/AUpload.less +15 -0
  45. package/lib/form-comp/style/index.js +1 -0
  46. package/lib/form-comp/style/index.less +7 -0
  47. package/lib/index.js +60 -45
  48. package/lib/modal/index.jsx +4 -6
  49. package/lib/modal/style/index.js +1 -0
  50. package/lib/modal/{index.less → style/index.less} +6 -7
  51. package/{plugins/lib/form → lib/model}/Model.js +1 -3
  52. package/lib/model/index.js +7 -0
  53. package/lib/model/style/index.js +1 -0
  54. package/lib/{form/style/Model.less → model/style/index.less} +10 -10
  55. package/{plugins/lib/form → lib/model}/utils/render.js +1 -1
  56. package/lib/{form → model}/utils/resetFields.js +1 -1
  57. package/lib/no-data/directive.js +65 -0
  58. package/lib/no-data/index.js +21 -0
  59. package/lib/no-data/index.vue +35 -0
  60. package/lib/no-data/style/index.js +1 -0
  61. package/lib/no-data/style/index.less +15 -0
  62. package/lib/search/index.js +7 -0
  63. package/{plugins/lib/form/Search.vue → lib/search/index.vue} +3 -6
  64. package/lib/search/style/index.js +1 -0
  65. package/{plugins/lib/form/style/Search.less → lib/search/style/index.less} +7 -8
  66. package/lib/style/mixins.less +1 -1
  67. package/lib/{svgIcon → svg-icon}/index.vue +1 -17
  68. package/lib/svg-icon/style/index.js +1 -0
  69. package/lib/svg-icon/style/index.less +15 -0
  70. package/lib/table/index.vue +4 -8
  71. package/lib/table/style/index.js +1 -0
  72. package/lib/table/style/index.less +12 -13
  73. package/lib/tree/index.js +2 -11
  74. package/{plugins/lib/tree/Tree.vue → lib/tree/index.vue} +2 -5
  75. package/lib/tree/style/index.js +1 -0
  76. package/{plugins/lib/tree/style/Tree.less → lib/tree/style/index.less} +4 -4
  77. package/lib/weather/index.vue +1 -9
  78. package/lib/weather/style/index.js +1 -0
  79. package/lib/weather/style/index.less +7 -0
  80. package/package.json +16 -34
  81. package/utils/Axios.js +91 -82
  82. package/utils/Postcss.js +12 -8
  83. package/README.md +0 -24
  84. package/dist/amap.umd.js +0 -12252
  85. package/dist/avatar.umd.js +0 -5337
  86. package/dist/button.umd.js +0 -5845
  87. package/dist/dateTime.umd.js +0 -1287
  88. package/dist/form.umd.js +0 -9981
  89. package/dist/multiTab.umd.js +0 -5556
  90. package/dist/svgIcon.umd.js +0 -1167
  91. package/dist/table.umd.js +0 -6306
  92. package/dist/tree.umd.js +0 -5393
  93. package/dist/weather.umd.js +0 -1167
  94. package/lib/amap/components/AmapSearch/index.less +0 -16
  95. package/lib/amap/index.js +0 -13
  96. package/lib/avatar/index.js +0 -7
  97. package/lib/avatar/index.vue +0 -47
  98. package/lib/basic/404.vue +0 -24
  99. package/lib/dateTime/index.vue +0 -43
  100. package/lib/form/Model.js +0 -153
  101. package/lib/form/Search.vue +0 -159
  102. package/lib/form/components/ACascaderMultiple.vue +0 -766
  103. package/lib/form/components/ARadio.vue +0 -74
  104. package/lib/form/components/ATagsInput.vue +0 -93
  105. package/lib/form/components/ATimePicker.vue +0 -73
  106. package/lib/form/index.js +0 -55
  107. package/lib/form/style/Search.less +0 -34
  108. package/lib/form/utils/render.js +0 -85
  109. package/lib/iframe/events.js +0 -2
  110. package/lib/iframe/index.jsx +0 -234
  111. package/lib/iframe/index.less +0 -19
  112. package/lib/multiTab/APIEnums.js +0 -17
  113. package/lib/multiTab/MultiTab.jsx +0 -237
  114. package/lib/multiTab/RouteAPI.js +0 -71
  115. package/lib/multiTab/RouteContent.jsx +0 -90
  116. package/lib/multiTab/RouteKeepAlive.js +0 -183
  117. package/lib/multiTab/events.js +0 -2
  118. package/lib/multiTab/index.js +0 -15
  119. package/lib/multiTab/index.less +0 -73
  120. package/lib/style/index.less +0 -2
  121. package/lib/tree/Directory.js +0 -428
  122. package/lib/tree/Tree.vue +0 -181
  123. package/lib/tree/style/Tree.less +0 -52
  124. package/method/Dialog.js +0 -134
  125. package/method/index.js +0 -12
  126. package/plugins/lib/amap/AmapDraw.jsx +0 -349
  127. package/plugins/lib/amap/AmapDraw.less +0 -45
  128. package/plugins/lib/amap/components/AmapSearch/index.jsx +0 -73
  129. package/plugins/lib/amap/index.js +0 -13
  130. package/plugins/lib/avatar/index.js +0 -7
  131. package/plugins/lib/avatar/index.vue +0 -47
  132. package/plugins/lib/basic/404.vue +0 -24
  133. package/plugins/lib/browse/index.jsx +0 -76
  134. package/plugins/lib/browse/index.less +0 -4
  135. package/plugins/lib/button/Button.js +0 -89
  136. package/plugins/lib/button/index.js +0 -7
  137. package/plugins/lib/dateTime/index.js +0 -7
  138. package/plugins/lib/descriptions/index.jsx +0 -108
  139. package/plugins/lib/descriptions/index.less +0 -15
  140. package/plugins/lib/form/components/ARadio.vue +0 -74
  141. package/plugins/lib/form/components/ARangePicker.vue +0 -129
  142. package/plugins/lib/form/components/ASelectCustom.vue +0 -226
  143. package/plugins/lib/form/components/ATagsInput.vue +0 -93
  144. package/plugins/lib/form/components/ATimePicker.vue +0 -73
  145. package/plugins/lib/form/components/AUpload.vue +0 -183
  146. package/plugins/lib/form/components/RenderComp.vue +0 -69
  147. package/plugins/lib/form/index.js +0 -55
  148. package/plugins/lib/form/style/Model.less +0 -53
  149. package/plugins/lib/form/utils/resetFields.js +0 -16
  150. package/plugins/lib/iframe/events.js +0 -2
  151. package/plugins/lib/iframe/index.jsx +0 -234
  152. package/plugins/lib/iframe/index.less +0 -19
  153. package/plugins/lib/index.js +0 -72
  154. package/plugins/lib/lazy_use.js +0 -40
  155. package/plugins/lib/modal/index.jsx +0 -53
  156. package/plugins/lib/modal/index.less +0 -50
  157. package/plugins/lib/multiTab/APIEnums.js +0 -17
  158. package/plugins/lib/multiTab/MultiTab.jsx +0 -237
  159. package/plugins/lib/multiTab/RouteAPI.js +0 -71
  160. package/plugins/lib/multiTab/RouteContent.jsx +0 -90
  161. package/plugins/lib/multiTab/RouteKeepAlive.js +0 -183
  162. package/plugins/lib/multiTab/events.js +0 -2
  163. package/plugins/lib/multiTab/index.js +0 -15
  164. package/plugins/lib/multiTab/index.less +0 -73
  165. package/plugins/lib/style/index.less +0 -2
  166. package/plugins/lib/style/mixins.less +0 -79
  167. package/plugins/lib/svgIcon/index.js +0 -7
  168. package/plugins/lib/svgIcon/index.vue +0 -77
  169. package/plugins/lib/table/index.js +0 -7
  170. package/plugins/lib/table/index.vue +0 -217
  171. package/plugins/lib/table/style/index.less +0 -50
  172. package/plugins/lib/tree/index.js +0 -17
  173. package/plugins/lib/tree/style/Directory.less +0 -119
  174. package/plugins/lib/weather/index.js +0 -7
  175. package/plugins/lib/weather/index.vue +0 -58
  176. package/plugins/method/AMap.js +0 -368
  177. package/plugins/method/PageLoading.jsx +0 -106
  178. package/plugins/method/Theme.js +0 -88
  179. package/plugins/method/index.js +0 -12
  180. package/plugins/store/auth.js +0 -31
  181. package/plugins/store/cache.js +0 -56
  182. package/plugins/store/chat.js +0 -74
  183. package/plugins/store/project.js +0 -46
  184. package/plugins/utils/Axios.js +0 -105
  185. package/plugins/utils/Base64.js +0 -314
  186. package/plugins/utils/Filter.js +0 -249
  187. package/plugins/utils/PostMessage.js +0 -16
  188. package/plugins/utils/Postcss.js +0 -9
  189. package/plugins/utils/Rem.js +0 -24
  190. package/plugins/utils/Request.js +0 -38
  191. package/plugins/utils/Storage.js +0 -73
  192. package/plugins/utils/Tree.js +0 -169
  193. package/plugins/utils/Utils.js +0 -51
  194. package/plugins/utils/Validate.js +0 -33
  195. package/plugins/utils/Websocket.js +0 -186
  196. package/utils/PostMessage.js +0 -16
  197. package/utils/Request.js +0 -38
  198. /package/{method → extensions}/PageLoading.jsx +0 -0
  199. /package/{method → extensions}/Theme.js +0 -0
  200. /package/{plugins/font → font}/DS-DIGI-1.ttf +0 -0
  201. /package/{plugins/font → font}/DS-DIGIB-2.ttf +0 -0
  202. /package/{plugins/font → font}/DS-DIGII-3.ttf +0 -0
  203. /package/{plugins/font → font}/DS-DIGIT-4.ttf +0 -0
  204. /package/{plugins/font → font}/Orbitron-Black.ttf +0 -0
  205. /package/{plugins/font → font}/Orbitron-Bold.ttf +0 -0
  206. /package/{plugins/font → font}/Orbitron-Medium.ttf +0 -0
  207. /package/{plugins/font → font}/Orbitron-Regular.ttf +0 -0
  208. /package/{plugins/font → font}/PANGMENZHENGDAOBIAOTITI-1.TTF +0 -0
  209. /package/{plugins/font → font}/PingFang SC.ttf +0 -0
  210. /package/{plugins/font → font}/YouSheBiaoTiHei.ttf +0 -0
  211. /package/{plugins/font → font}/font.css +0 -0
  212. /package/{plugins/font → font}//345/255/227/351/255/20235/345/217/267-/347/273/217/345/205/270/351/233/205/351/273/221.ttf" +0 -0
  213. /package/lib/browse/{index.less → style/index.less} +0 -0
  214. /package/{dist/css/index.css → lib/button/style/index.less} +0 -0
  215. /package/lib/{dateTime → date-time}/index.js +0 -0
  216. /package/lib/{descriptions → descriptions-list/style}/index.less +0 -0
  217. /package/lib/{form/components → form-comp}/RenderComp.vue +0 -0
  218. /package/lib/{svgIcon → svg-icon}/index.js +0 -0
@@ -1,428 +0,0 @@
1
- import { h } from 'vue'
2
- import { getTreeKey, filterTreeById } from '../../utils/Tree'
3
- import { Tree, Menu, Input, Icon, Button, Dropdown, Popconfirm } from 'ant-design-vue'
4
- import './style/Directory.less'
5
-
6
- import SvgIcon from '../svgIcon'
7
-
8
- /* 明天来了做一下@快捷指向 */
9
-
10
- const TreeNode = Tree.TreeNode
11
- const DirectoryTree = Tree.DirectoryTree
12
-
13
- export default {
14
- name: 'DirectoryTreeMenu',
15
- props: {
16
- treeData: {
17
- type: Array,
18
- default: () => ([])
19
- },
20
- treeExpandKeys: {
21
- type: Array,
22
- default: () => ([])
23
- },
24
- treePlus: {
25
- type: Boolean,
26
- default: true
27
- },
28
- treeActions: {
29
- type: Array,
30
- default: () => ([])
31
- },
32
- /** 是否只显示父级一层操作 */
33
- treeActionsParent: {
34
- type: Boolean,
35
- default: false
36
- },
37
- treeActionsPlus: {
38
- type: Boolean,
39
- default: true
40
- },
41
- replaceFields: {
42
- type: Object,
43
- default: () => ({
44
- children: 'children',
45
- key: 'id',
46
- title: 'title'
47
- })
48
- }
49
- },
50
- data() {
51
- return {
52
- NodeCheckedKeys: [],
53
- NodeSelectedKeys: [],
54
- NodeExpandKeys: [],
55
- NodeKey: [],
56
- NodeActions: null,
57
- MenuDropdown: false,
58
- NodeActionsStyle: {}
59
- }
60
- },
61
- mounted() {
62
- this.onInitTree()
63
- // this.NodeExpandKeys = ( this.treeExpandKeys.length && this.treeExpandKeys ) || ( treeExpend && getTreeKey(this.treeData, true, this.replaceFields) ) || []
64
- },
65
- watch: {
66
- treeData(newValue, oldValue) {
67
- this.onInitTree( !oldValue.length )
68
- },
69
- treeExpandKeys: {
70
- handler(newValue) {
71
- this.NodeExpandKeys = newValue
72
- },
73
- immediate: true
74
- }
75
- },
76
- methods: {
77
- TreeNodeRender(node, nodeIndex, parentNode) {
78
- const {
79
- replaceFields,
80
- NodeActions,
81
- treeActions,
82
- NodeActionsStyle,
83
- NodeExpandKeys,
84
- NodeKey,
85
- treeActionsPlus,
86
- createTreeNode,
87
- handleMouseLeave,
88
- handleOperateClick,
89
- handlePlusClick
90
- } = this
91
- const key = node[replaceFields.key]
92
- const treeActionsParent = this.treeActionsParent ? !parentNode : true
93
- return (
94
- <TreeNode
95
- key={key}
96
- class="DirectoryTreeMenu__Node"
97
- scopedSlots={{
98
- title: props => {
99
- return (
100
- <div class="__Title">
101
- {node.type != 'input' ? (
102
- <span>{node[replaceFields.title]}</span>
103
- ) : (
104
- <Input
105
- placeholder="请输入节点名称"
106
- {...{
107
- on: {
108
- blur: ({ target }) => createTreeNode(target, node),
109
- pressEnter: event => event.target.blur(event, true)
110
- }
111
- }}
112
- default-value={node[replaceFields.title]}
113
- ref="inputNodeRef"
114
- />
115
- )}
116
- {NodeActions && NodeKey.includes(props.eventKey) && treeActionsParent && node.type != 'input' && (
117
- <div
118
- ref="TreeMenuActions"
119
- class="DirectoryTreeMenu__Actions"
120
- // 通过阻止mouseenter事件冒泡来达到 触发中的时候不切换
121
- {...{on: { mouseenter: event => event.stopPropagation() }} }
122
- >
123
- <Dropdown
124
- trigger={['click']}
125
- overlayClassName="DirectoryTreeMenu__Dropdown"
126
- >
127
- {/* getPopupContainer={() => this.$refs.TreeMenuActions} */}
128
- <SvgIcon
129
- class="ActionsIcons"
130
- icon-class="tree-more"
131
- {...{
132
- on: {
133
- click: e => e.preventDefault()
134
- }
135
- }}
136
- />
137
- <div slot="overlay" class="DirectoryTreeMenu__Dropdown__Menu">
138
- {treeActions.map((handle, i) => {
139
- return (
140
- <span
141
- key={i}
142
- {...{
143
- on: {
144
- // this.$emit('handleOperateClick', handle, NodeActions)
145
- click: () => handleOperateClick(handle, { ...node, nodeIndex }, parentNode)
146
- }
147
- }}
148
- >
149
- <SvgIcon icon-class={handle.svg} /> {handle.text}
150
- </span>
151
- )
152
- })}
153
- </div>
154
- </Dropdown>
155
- {
156
- treeActionsPlus &&
157
- <SvgIcon
158
- class="ActionsIcons"
159
- icon-class="tree-plus"
160
- {...{
161
- on: {
162
- click: () => handlePlusClick()
163
- }
164
- }}
165
- />
166
- }
167
- </div>
168
- )}
169
- </div>
170
- )
171
- }
172
- }}
173
- >
174
- {node[replaceFields.children] &&
175
- node[replaceFields.children].length &&
176
- node[replaceFields.children].map((childNode, childNodeIndex) =>
177
- this.TreeNodeRender(childNode, childNodeIndex, node)
178
- )}
179
- </TreeNode>
180
- )
181
- },
182
- appendTreeNode() {
183
- this.treeData.push({
184
- type: 'input',
185
- append: true,
186
- [this.replaceFields.key]: new Date().getTime()
187
- })
188
- this.$nextTick(() => this.$refs.inputNodeRef.focus())
189
- },
190
- createTreeNode({ value }, node) {
191
- this.$set(node, 'type', 'text')
192
- this.$emit(
193
- `handlePlus${node.append ? 'Add' : 'Update'}`,
194
- value,
195
- node.append ? node.parentOrgId : node[this.replaceFields.key]
196
- )
197
- const parentNodes = node.parentOrgId
198
- ? this.findItemById(this.treeData, node.parentOrgId)[this.replaceFields.children]
199
- : this.treeData
200
- if (node.append) {
201
- const i = parentNodes.findIndex(child => child[this.replaceFields.key] == node[this.replaceFields.key])
202
- parentNodes.splice(i, 1)
203
- }
204
- },
205
- handleOperateClick(handle, node, parentNode) {
206
- const key = node[this.replaceFields.key]
207
- let that = this
208
- switch (handle.type) {
209
- case 'update':
210
- const updateNode = this.findItemById(this.treeData, key)
211
- this.$set(updateNode, 'type', 'input')
212
- this.$nextTick(() => this.$refs.inputNodeRef.focus())
213
- break
214
- case 'copy':
215
- // 明天来了优化一下
216
- const cloneNode = parentNode ? parentNode[this.replaceFields.children] : this.treeData
217
- cloneNode.splice(node.nodeIndex + 1, 0, {
218
- type: 'input',
219
- append: true,
220
- parentOrgId: parentNode ? parentNode[this.replaceFields.key] : null,
221
- [this.replaceFields.key]: new Date().getTime(),
222
- [this.replaceFields.title]: node[this.replaceFields.title]
223
- })
224
- this.$nextTick(() => this.$refs.inputNodeRef.focus())
225
- break
226
- case 'delete':
227
- this.$confirm({
228
- title: '确定要删除当前节点吗?',
229
- okText: '确定',
230
- cancelText: '取消',
231
- onOk() {
232
- that.$emit('handleDeleteClick', node)
233
- console.log('OK')
234
- },
235
- onCancel() {
236
- console.log('Cancel')
237
- }
238
- })
239
- break
240
- default:
241
- this.$emit('handleOperateClick', handle, node)
242
- break
243
- }
244
- },
245
- handlePlusClick() {
246
- const node = this.findItemById(this.treeData, this.NodeActions.id)
247
- const childNode = node[this.replaceFields.children] ?? []
248
- childNode.push({
249
- type: 'input',
250
- append: true,
251
- parentOrgId: this.NodeActions.id,
252
- [this.replaceFields.key]: new Date().getTime()
253
- })
254
- this.NodeExpandKeys.push(this.NodeActions.id)
255
- node[this.replaceFields.children] = childNode
256
- this.$nextTick(() => this.$refs.inputNodeRef.focus())
257
- },
258
- findItemById(treeData, id) {
259
- for (let i = 0; i < treeData.length; i++) {
260
- if (treeData[i][this.replaceFields.key] === id) return treeData[i]
261
- let childNode = treeData[i][this.replaceFields.children]
262
- if (childNode && childNode.length > 0) {
263
- const foundItem = this.findItemById(treeData[i][this.replaceFields.children], id)
264
- if (foundItem) return foundItem
265
- }
266
- }
267
- },
268
- onInitTree(treeExpend = true) {
269
- this.treeData && (this.NodeSelectedKeys = [this.treeData.at(0)?.[this.replaceFields.key]])
270
- // this.NodeExpandKeys = ( this.treeExpandKeys.length && this.treeExpandKeys ) || ( treeExpend && getTreeKey(this.treeData, true, this.replaceFields) ) || []
271
- },
272
- onCheck(keys, {}) {
273
- this.NodeCheckedKeys = keys
274
- this.$emit('onCheck', keys)
275
- },
276
- onSelect(keys, { nativeEvent, node }) {
277
- this.NodeSelectedKeys = keys
278
- this.NodeKey = [].concat(this.NodeSelectedKeys)
279
- this.$emit('onSelect', keys)
280
- },
281
- onExpand(expandedKeys, { expanded, node }) {
282
- this.NodeExpandKeys = [].concat(expandedKeys)
283
- console.log(expandedKeys, expanded, node, 'Trigger Expand')
284
- },
285
- getIcon(props) {
286
- const { isLeaf, expanded } = props
287
- if (isLeaf) {
288
- return <Icon type="home" />
289
- }
290
- return <Icon type={expanded ? 'folder-open' : 'folder'} />
291
- },
292
- handleMouseEnter({ event, node }) {
293
- this.NodeActions = {
294
- id: node._props.eventKey,
295
- title: node._props.title,
296
- parentOrgId: node.$parent.eventKey || null
297
- }
298
- // this.MenuDropdown = false
299
- this.NodeKey = [].concat(this.NodeSelectedKeys)
300
- this.NodeKey.push(node.eventKey)
301
- // console.log(node, 'handleMouseEnter')
302
- // 是否加个参数 判断是否处于打开状态
303
- },
304
- handleMouseLeave({ event, node }) {
305
- if( this.NodeKey.includes(node.eventKey) && this.NodeSelectedKeys != node.eventKey ) {
306
- const i = this.NodeKey.findIndex( key => key == node.eventKey )
307
- this.NodeKey.splice( i, 1 )
308
- }
309
- // this.NodeKey = []
310
- },
311
- onDragEnter(node) {
312
- console.log(node, '--onDragEnter')
313
- // expandedKeys 需要受控时设置
314
- // this.expandedKeys = info.expandedKeys
315
- },
316
- onDrop(info) {
317
-
318
- const dragKey = info.dragNode.eventKey
319
- const dropPos = info.node.pos.split("-")
320
- // 拖动的位置
321
- const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1])
322
-
323
- const node = info.node //目标节点
324
- const dragNode = info.dragNode // 拖动节点
325
- const dropKey = node.eventKey
326
-
327
- console.log( dragNode, node, '--dropToGap' )
328
-
329
- if (dragNode.$parent?.eventKey !== node.$parent?.eventKey || !info.dropToGap) {
330
- // 阻止跨父级拖拽
331
- this.$message.warning("只能在同级排序")
332
- return false
333
- }
334
-
335
- const { key, children } = this.replaceFields
336
-
337
- const loop = (data, eventKey, callback) => {
338
- data.forEach((node, i, array) => {
339
- if ( node[key] === eventKey ) {
340
- return callback( node, i, array )
341
- }
342
- if ( node[children] ) {
343
- return loop( node[children], eventKey, callback )
344
- }
345
- })
346
- }
347
-
348
- const data = [...this.treeData]
349
-
350
- let dragObj
351
- let dragObjIndex
352
- loop(data, dragKey, (node, i, array) => {
353
- dragObj = node
354
- dragObjIndex = i
355
- })
356
-
357
- let dropIndex
358
- loop(data, dropKey, (node, i, array) => {
359
- dropIndex = i
360
- console.log( node, i, dragObj, dragObjIndex, '--i' )
361
- })
362
-
363
- this.$emit(
364
- 'onDrop',
365
- {
366
- [key]: dragObj[key],
367
- originalIndex: dragObjIndex,
368
- presentIndex: dropPosition === -1 ? dropIndex : dropIndex + 1
369
- }
370
- )
371
- }
372
- },
373
- render() {
374
- const {
375
- $attrs,
376
- treePlus,
377
- treeData,
378
- NodeCheckedKeys,
379
- NodeSelectedKeys,
380
- NodeExpandKeys,
381
- onCheck,
382
- onSelect,
383
- onExpand,
384
- handleMouseEnter,
385
- handleMouseLeave,
386
- onDragEnter,
387
- onDrop,
388
- TreeNodeRender,
389
- appendTreeNode,
390
- replaceFields
391
- } = this
392
- return (
393
- <div class="DirectoryTreeMenu">
394
- {
395
- $attrs.menuTitle &&
396
- <div class="treeDirectory">
397
- <span>{$attrs.menuTitle || '目录'}</span>
398
- {treePlus && <Button icon="plus" size="small" {...{ on: { click: appendTreeNode } }} />}
399
- </div>
400
- }
401
- <DirectoryTree
402
- draggable
403
- class="DirectoryTreeMenu__Tree"
404
- default-expand-all
405
- checkedKeys={NodeCheckedKeys}
406
- selectedKeys={NodeSelectedKeys}
407
- expandedKeys={NodeExpandKeys}
408
- expandAction="dblclick"
409
- {...{
410
- on: {
411
- check: onCheck,
412
- select: onSelect,
413
- expand: onExpand,
414
- mouseenter: handleMouseEnter,
415
- mouseleave: handleMouseLeave,
416
- dragenter: onDragEnter,
417
- drop: onDrop
418
- },
419
- attrs: $attrs
420
- }}
421
- tree-node-filter-prop="title"
422
- >
423
- {treeData.map((node, nodeIndex) => TreeNodeRender(node, nodeIndex))}
424
- </DirectoryTree>
425
- </div>
426
- )
427
- }
428
- }
package/lib/tree/Tree.vue DELETED
@@ -1,181 +0,0 @@
1
- <template>
2
- <div class="publicTreeCheck">
3
- <div class="TreeSelect">
4
- <slot name="SearchTree" v-if="isHasSearch">
5
- <InputSearch placeholder="请输入关键字" @change="searchHandle" />
6
- </slot>
7
-
8
- <Tree
9
- checkable
10
- v-bind="$attrs"
11
- :treeData="treeData"
12
- :replaceFields="replaceFields"
13
- :expandedKeys="innerExpandedKeys"
14
- :checkedKeys="innerCheckedKeys"
15
- @expand="onExpand"
16
- @check="onCheck"
17
- />
18
- </div>
19
-
20
- <div class="TreeReveal">
21
- <div class="TreeSelectCount">
22
- <span>已选: {{ innerTreeOptions.length }}</span>
23
- <span class="clear" @click="innerCheckedKeys = []">清空</span>
24
- </div>
25
-
26
- <div class="TreeListPage">
27
- <CheckboxGroup
28
- v-model="innerCheckedKeys"
29
- name="checkboxgroup"
30
- :options="innerTreeOptions"
31
- @change="onChange"
32
- />
33
- </div>
34
- </div>
35
- </div>
36
- </template>
37
-
38
- <script>
39
- import { Tree, Checkbox, Input } from 'ant-design-vue'
40
-
41
- import { getTreeKey, findCheckNodes } from '../../utils/Tree'
42
-
43
- export default {
44
- name: 'TreeTransfer',
45
- components: {
46
- Tree,
47
- InputSearch: Input.Search,
48
- CheckboxGroup: Checkbox.Group
49
- },
50
- props: {
51
- /** 是否携带搜索 */
52
- isHasSearch: {
53
- type: Boolean,
54
- default: true
55
- },
56
- checkedKeys: {
57
- // 传递选中的key
58
- type: Array,
59
- default: () => []
60
- },
61
- checkNodes: {
62
- // 传递选中的node节点
63
- type: Array,
64
- default: () => []
65
- },
66
- expandedKeys: {
67
- // 传递需要展开的key / 默认为全部展开
68
- type: Array,
69
- default: () => []
70
- },
71
- treeData: {
72
- type: Array,
73
- // 传递树形结构数据
74
- default: () => []
75
- },
76
- replaceFields: {
77
- type: Object,
78
- default: () => ({
79
- children: 'children',
80
- key: 'id',
81
- title: 'title'
82
- })
83
- }
84
- },
85
- data() {
86
- return {
87
- initTreeData: [], // 缓存原始组树结构
88
- openSearch: false, // 是否开启搜索
89
- innerCheckedKeys: [], // 选中的值
90
- innerExpandedKeys: [] // 展开的值
91
- }
92
- },
93
- watch: {
94
- checkedKeys: {
95
- immediate: true,
96
- deep: true,
97
- handler(newValue, oldValue) {
98
- newValue && (this.innerCheckedKeys = newValue)
99
- }
100
- },
101
- expandedKeys: {
102
- immediate: true,
103
- deep: true,
104
- handler(newValue, oldValue) {
105
- newValue && (this.innerExpandedKeys = newValue)
106
- }
107
- },
108
- checkNodes: {
109
- immediate: true,
110
- deep: true,
111
- handler(newValue, oldValue) {
112
- newValue && (this.innerCheckedKeys = newValue.map(e => e[this.replaceFields.key]))
113
- }
114
- },
115
- treeData: {
116
- immediate: true,
117
- deep: true,
118
- handler(newValue, oldValue) {
119
- !this.openSearch && (this.initTreeData = [].concat(this.treeData))
120
- newValue && (this.innerExpandedKeys = this.getTreeAllGroupKey)
121
- }
122
- }
123
- },
124
- mounted() {
125
- // 缓存原始组
126
- this.initTreeData = [].concat(this.treeData)
127
- this.innerExpandedKeys = this.getTreeAllGroupKey
128
- },
129
- computed: {
130
- cacheEmitValue() {
131
- // 缓存响应的值
132
- return {
133
- checkedKeys: this.innerCheckedKeys,
134
- expandedKeys: this.innerExpandedKeys
135
- }
136
- },
137
- getTreeAllKey() {
138
- // 获取树的所有key
139
- return getTreeKey(this.initTreeData)
140
- },
141
- getTreeAllGroupKey() {
142
- // 获取树的所有组key
143
- return getTreeKey(this.initTreeData, true, this.replaceFields)
144
- },
145
- innerTreeOptions() {
146
- const { key, title, children } = this.replaceFields
147
- return findCheckNodes(this.initTreeData, this.innerCheckedKeys, key, children).filter(
148
- e => ((e.label = e[title]), (e.value = e[key]))
149
- )
150
- }
151
- },
152
-
153
- methods: {
154
- onExpand(expandedKeys) {
155
- this.innerExpandedKeys = expandedKeys
156
- },
157
- onCheck(checkedKeys, { checked, checkedNodes, node, event }) {
158
- const { key, children } = this.replaceFields
159
- if (!this.openSearch) return (this.innerCheckedKeys = checkedKeys)
160
- checked
161
- ? (this.innerCheckedKeys = this.innerCheckedKeys.concat(
162
- findCheckNodes(this.initTreeData, checkedKeys, key, children).map(node => node[key])
163
- ))
164
- : this.innerCheckedKeys.splice(
165
- this.innerCheckedKeys.findIndex(nodeKey => nodeKey == node.eventKey),
166
- 1
167
- )
168
- },
169
- onChange(checkedKeys) {
170
- console.log(checkedKeys, 'checkedKeys')
171
- },
172
- searchHandle({ target }) {
173
- this.openSearch = Boolean(target.value)
174
- this.$emit('SearchTree', target.value)
175
- }
176
- }
177
- }
178
- </script>
179
- <style lang="less" scoped>
180
- @import url('./style/Tree.less');
181
- </style>
@@ -1,52 +0,0 @@
1
- /* 混入样式 */
2
- @import '../../style/mixins.less';
3
- @import 'ant-design-vue/lib/style/themes/default.less';
4
-
5
- .publicTreeCheck {
6
- display: flex;
7
- .square( 100% );
8
-
9
- & > div {
10
- flex: 1;
11
- padding: @padding-md @padding-lg;
12
- box-sizing: border-box;
13
- overflow-y: auto;
14
- .scrollbarStyle();
15
- .flex-layout( column );
16
- }
17
-
18
- .TreeSelect {
19
- border-right: 1px solid @border-color-split;
20
- }
21
-
22
- .TreeReveal {
23
- .TreeSelectCount {
24
- display: flex;
25
- color: @primary-color;
26
- margin-bottom: @padding-md;
27
-
28
- .clear {
29
- flex: 1;
30
- text-align: right;
31
- color: @info-color;
32
- cursor: pointer;
33
- }
34
- }
35
-
36
- .TreeListPage {
37
- .scrollbarStyle();
38
- :deep(.ant-checkbox-group) {
39
- width: 100%;
40
- .flex-layout( column );
41
- }
42
- :deep(.ant-checkbox-group-item) {
43
- height: 40px;
44
- display: flex;
45
- align-items: center;
46
- margin-right: 0;
47
- padding: 0 @padding-sm;
48
- box-sizing: border-box;
49
- }
50
- }
51
- }
52
- }