@complex-suite/component-antd 4.10.12

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 (51) hide show
  1. package/LayoutResizeObserver.ts +104 -0
  2. package/LocalResizeObserver.ts +46 -0
  3. package/README.md +67 -0
  4. package/antdConfig.ts +361 -0
  5. package/format.ts +458 -0
  6. package/history.md +325 -0
  7. package/icon.ts +65 -0
  8. package/index.test.ts +5 -0
  9. package/index.ts +55 -0
  10. package/package.json +39 -0
  11. package/plugin.ts +95 -0
  12. package/quick/QuickCascade.tsx +107 -0
  13. package/quick/QuickEdit.tsx +117 -0
  14. package/quick/QuickFloat.tsx +32 -0
  15. package/quick/QuickFloatModal.tsx +95 -0
  16. package/quick/QuickFloatValue.tsx +103 -0
  17. package/quick/QuickList.tsx +433 -0
  18. package/quick/data/FloatData.ts +77 -0
  19. package/src/AutoSpin.vue +39 -0
  20. package/src/AutoText.vue +101 -0
  21. package/src/ButtonView.tsx +62 -0
  22. package/src/CollapseArea.tsx +88 -0
  23. package/src/EditArea.tsx +205 -0
  24. package/src/EditView.tsx +179 -0
  25. package/src/FlexBox.tsx +74 -0
  26. package/src/FormList.tsx +226 -0
  27. package/src/ImageViewer.tsx +122 -0
  28. package/src/InfoArea.tsx +182 -0
  29. package/src/InfoView.tsx +150 -0
  30. package/src/MenuView.tsx +91 -0
  31. package/src/ModalView.tsx +274 -0
  32. package/src/MultipleImport.tsx +231 -0
  33. package/src/SearchArea.tsx +170 -0
  34. package/src/SelectText.vue +59 -0
  35. package/src/SimpleTable.tsx +256 -0
  36. package/src/SingleImport.tsx +189 -0
  37. package/src/TableView.tsx +415 -0
  38. package/src/components/AutoRender.tsx +19 -0
  39. package/src/components/ChoiceInfo.vue +73 -0
  40. package/src/components/PaginationView.tsx +103 -0
  41. package/src/components/TableMenu.tsx +93 -0
  42. package/src/dictionary/AutoEditItem.tsx +164 -0
  43. package/src/dictionary/AutoInfoItem.tsx +126 -0
  44. package/src/dictionary/AutoItem.tsx +219 -0
  45. package/src/icons/EmptyImage.vue +30 -0
  46. package/src/icons/ErrorImage.vue +30 -0
  47. package/src/style/index.css +304 -0
  48. package/tsconfig.json +8 -0
  49. package/type.ts +4 -0
  50. package/vitest.config.ts +11 -0
  51. package/widthCalculator.ts +20 -0
package/history.md ADDED
@@ -0,0 +1,325 @@
1
+
2
+ ### Tips
3
+
4
+ ### ToDo
5
+ - ListView的TableMenu实现级联
6
+ - 通过antd实现基础主题色的设置:全局样式
7
+ - table布局考虑计算准确性
8
+ - SimpleTable的插槽和菜单逻辑同步
9
+ - Import的complex属性适配,接收一个复杂对象实现,具体的名称和URL解析考虑单独参数或者额外包装
10
+ - 统一的布局切换逻辑实现方案
11
+ - - quick优化,参数优化配置细分
12
+
13
+ ### Doing
14
+ - 简化SimpleTable,可自定义组件,通过此组件实现ListEdit
15
+
16
+ ### `4.10.12`
17
+ - refactor: 将TypeScript类型导入语法升级为type关键字形式。
18
+
19
+ ### `4.10.11`
20
+ - fix: 修正`QuickList`的`onEditSubmit`未自动关闭编辑弹窗的问题,并在浮动弹窗相关组件添加获取弹窗实例的函数。
21
+
22
+ ### `4.10.10`
23
+ - feat: 适配`Date`相关的`complexDisabledDate` `rangeLimit`配置项,实现复杂日期禁止函数和时间范围限制相关功能。
24
+
25
+ ### `4.10.9`
26
+ - feat: `QuickList` 的 `onEditSubmit` 函数添加自定义传参供外部特殊调用使用。
27
+
28
+ ### `4.10.8`
29
+ - feat: MenuView和TableMenu适配MenuValue的事件修饰符。
30
+
31
+ ### `4.10.6` `4.10.7`
32
+ - feat: 修正cascader级联选择器未适配filter的BUG。
33
+
34
+ ### `4.10.4` `4.10.5`
35
+ - refactor: 迁移 `localIconProps` 类型定义至 `type.ts` 文件,解决循环依赖。
36
+ - refactor: 调整 `dataConfig` 的导入方式,由 `antdConfig.dataConfig` 改为直接导入,解决循环依赖。
37
+
38
+ ### `4.10.3`
39
+ - feat: 重构 `QuickList` 的编辑逻辑,新增 `startEdit` 函数以提高灵活性和可扩展性。
40
+ - feat: 为 `QuickList` 的 `buildData` 方法调用增加 `originData` 参数,支持基于模板创建数据。
41
+
42
+ ### `4.10.1` `4.10.2`
43
+ - feat: 搭建测试流程
44
+
45
+ ### `4.9.5`
46
+ - feat: 输出AutoRender,ChoiceInfo,PaginationView,TableMenu模板组件
47
+
48
+ ### `4.9.4`
49
+ - fix: 修正AutoText未正确接收attrs的BUG
50
+
51
+ ### `4.9.1` `4.9.2` `4.9.3`
52
+ - feat: 修改模块加载逻辑为ES2020
53
+ - feat: antdConfig等配置项更改为reactive对象
54
+
55
+ ### `4.8.17` - `4.8.20`
56
+ - feat: config=>antdConfig,style迁移到dataConfig中
57
+
58
+ ### `4.8.15` `4.8.16`
59
+ - feat: SelectText适配$color模式,此模式下取config.style.color的颜色动态赋值
60
+
61
+ ### `4.8.14`
62
+ - feat: 输出AutoSpin组件
63
+
64
+ ### `4.8.12` `4.8.13`
65
+ - chore: 升级依赖,适配新版SelectEdit
66
+ - feat: QuickList的editThrottle=>editDebounce
67
+ - feat: EmptyPic=>EmptyImage
68
+ - feat: 添加ErrorImage
69
+ - feat: ImageViewer添加图片加载失败判断逻辑
70
+
71
+ ### `4.8.11`
72
+ - chore: 适配DefaultSelectEdit的filter函数
73
+
74
+ ### `4.8.8` `4.8.9` `4.8.10`
75
+ - feat!: 重大变化:优化样式自动构建整体逻辑,为全局统一样式实现基础
76
+ - feat: 添加SelectText组件,展示SelectValue
77
+
78
+ ### `4.8.7`
79
+ - fix: 修正SimpleTable的行高与Antd的Table保持一致
80
+
81
+ ### `4.8.6`
82
+ - chore: 基于AI优化代码
83
+
84
+ ### `4.8.5`
85
+ - chore: 升级依赖
86
+ - feat: 删除QuickTrack
87
+
88
+ ### `4.8.4`
89
+ - feat: 添加FlexBox组件,实现基础大屏布局
90
+
91
+ ### `4.8.3`
92
+ - fix: 修正config.showValue未正确解析数组的BUG
93
+
94
+ ### `4.8.1` `4.8.2`
95
+ - chore: 升级依赖
96
+ - chore: 优化Float相关功能
97
+ - chore: 稳定版
98
+
99
+ ### `4.6.35` `4.6.36`
100
+ - chore: 升级依赖
101
+ - feat: 级联列表组件
102
+ - chore: QuickList优化render模块功能
103
+ - chore: 优化Float相关功能
104
+
105
+ ### `4.6.33`
106
+ - chore: 升级依赖
107
+ - chore: SimpleTable无数据样式同步antd
108
+
109
+ ### `4.6.31` `4.6.32`
110
+ - chore: 升级data依赖,同步ChoiceData改动
111
+ - feat: 适配SortData列表排序
112
+ - feat: TableView添加事件['choice', 'sort']
113
+
114
+ ### `4.6.30`
115
+ - chore: 升级data依赖,适配CustomEdit的model配置项优化
116
+
117
+ ### `4.6.29`
118
+ - chore: ImageViewer的class优化,样式优化
119
+
120
+ ### `4.6.27` `4.6.28`
121
+ - chore: 升级依赖
122
+ - feat: ImportView的事件更改为change
123
+ - refactor: ImportView使用组合式API重构,修正数据变更未触发校验的BUG
124
+
125
+ ### `4.6.26`
126
+ - fix: 修正AutoText在text变更后直接计算宽度的BUG
127
+ - feat: ModalView添加destroyOnClose配置项,默认为真,减少dom结构的同时保证默认情况下每次打开的加载存在,避免BUG
128
+
129
+ ### `4.6.24` `4.6.25`
130
+ - fix: 修正TableMenu中间hidden后错误break的BUG
131
+ - chore: ListEdit仅作为数据结构存在,不统一处理
132
+
133
+ ### `4.6.23`
134
+ - chore: 初步视频优化FormEdit/ListEdit数据格式
135
+
136
+ ### `4.6.22`
137
+ - chore: 全局优化Promise返回逻辑
138
+
139
+ ### `4.6.18` - `4.6.21`
140
+ - chore: 全局优化width赋值
141
+ - chore: 升级data依赖,适配ComplexData的常见方法去除$符
142
+
143
+ ### `4.6.16` `4.6.17`
144
+ - chore: 优化iconDict构建逻辑
145
+ - chore: 优化按钮icon与文字的间隔
146
+
147
+ ### `4.6.15`
148
+ - chore: 升级data依赖,适配DefaultSimpleEdit.disabled更改为InterfaceValue结构
149
+ - chore: 优化编辑的disabled传值逻辑
150
+ - fix: 修正PaginationView的sizeSelect展示错误的BUG
151
+
152
+ ### `4.6.13`
153
+ - feat: 适配File的isUrl配置项
154
+
155
+ ### `4.6.11` `4.6.12`
156
+ - chore: 升级data依赖,优化refreshData调用
157
+ - chore: 优化openEdit函数
158
+ - chore: 优化SingleImport.renderContent
159
+
160
+ ### `4.6.8` `4.6.9` `4.6.10`
161
+ - chore: 升级data依赖,同步icon变更
162
+ - feat: 文件上传组件通过图片查看器实现图片的特殊处理
163
+
164
+ ### `4.6.7`
165
+ - chore: 升级data依赖,Edit适配DefaultMod的hidden/frozen属性
166
+ - chore: 开发环境添加observe检查
167
+
168
+ ### `4.6.5` `4.6.6`
169
+ - chore: ImageViewer无图优化,添加localIcon
170
+
171
+ ### `4.6.3` `4.6.4`
172
+ - fix: 修正widthCalculator
173
+
174
+ ### `4.6.2`
175
+ - chore: 升级data依赖
176
+ - feat: tablePayload.payload.target => tablePayload.payload.column
177
+ - feat: 适配MenuValue.confirm/hidden
178
+ - feat: 适配TableMenu.disabled
179
+ - feat: 添加ImageViewer
180
+ - feat: 删除SimpleTableContent
181
+ - feat: 适配ListEdit:兼容问题暂不可用
182
+ - feat: 添加EditTable
183
+
184
+ ### `4.6.1`
185
+ - chore: 升级data依赖
186
+ - chore: 升级plugin依赖
187
+
188
+ ### `4.4.10` `4.4.11`
189
+ - chore: 升级data依赖
190
+ - chore: 升级plugin依赖
191
+ - feat: Edit/Info添加onInit函数,在加载后可对数据在特殊处理如排序等
192
+
193
+ ### `4.4.5` - `4.4.9`
194
+ - chore: 升级data依赖
195
+ - chore: 升级plugin依赖
196
+
197
+ ### `4.4.4`
198
+ - chore: 升级data插件
199
+ - feat: 添加基础的轨迹类
200
+
201
+ ### `4.4.2` `4.4.3`
202
+ - feat: 适配SearchData的异步加载
203
+
204
+ ### `4.4.1`
205
+ - feat: 适配生命周期优化
206
+
207
+ ### `4.3.35`
208
+ - chore: 优化quick相关路径
209
+ - feat: 实现基础的Float布局
210
+ - fix: 修正AutoText在文本变化时未重新计算宽度的BUG
211
+ - feat: 添加LayoutResizeObserver类,基于PluginLayout初步兼容ResizeObserver
212
+
213
+ ### `4.3.34`
214
+ - chore: 升级data插件适配triggerMethod的节流参数,QuickList的节流参数默认值添加
215
+
216
+ ### `4.3.33`
217
+ - chore: 升级data插件适配可能存在的depth数据
218
+
219
+ ### `4.3.32`
220
+ - feat: 适配Vue3的插件加载模式,优化可配置项,优化PluginLayout的引用逻辑
221
+
222
+ ### `4.3.29` - `4.3.31`
223
+ - feat: 适配DictionaryData/DefaultMod的collapse折叠判断值
224
+ - chore: 优化PluginLayout的全局引用逻辑
225
+ - chore: layout升级
226
+
227
+ ### `4.3.27` `4.2.28`
228
+ - feat: 适配SelectEdit的search配置项
229
+
230
+ ### `4.3.26`
231
+ - feat: SearchArea/EditArea/EditView添加enter属性,检索默认为真,为真则监控子组件input的回车事件,触发后QuickList检索默认触发,简化操作
232
+
233
+ ### `4.3.24` `4.3.25`
234
+ - chore: 规范命名,tsx文件由之前的ts后缀修正为tsx后缀
235
+ - chore: 优化未使用变量前缀
236
+
237
+ ### `4.3.23`
238
+ - chore: 优化QuickList的页面结构,仅edit/info时不构建主div
239
+ - chore: 优化编辑回调,非标准编辑全部默认走$editChange函数,通过此函数分流
240
+
241
+ ### `4.3.21` `4.3.22`
242
+ - feat: 适配优化rule校验
243
+
244
+ ### `4.3.19` `4.3.20`
245
+ - chore: 优化icon
246
+
247
+ ### `4.3.18`
248
+ - feat: 适配custom的双向绑定加载
249
+
250
+ ### `4.3.17`
251
+ - chore: 优化TableView的autoText的attrs设置
252
+
253
+ ### `4.3.16`
254
+ - fix: 修正ButtonView的upload传参错误的BUG
255
+
256
+ ### `4.3.15`
257
+ - chore: 优化undefined校验
258
+
259
+ ### `4.3.12` - `4.3.14`
260
+ - feat: 拆分上传组件
261
+ - chore: 优化上传组件类型
262
+ - feat: 适配上传组件的complex属性
263
+
264
+ ### `4.3.11`
265
+ - feat: QuickList的事件由menu拆分成search/table
266
+ - chore: 升级依赖,适配时间范围限制
267
+
268
+ ### `4.3.8` `4.3.9` `4.3.10`
269
+ - feat: 按钮适配防抖
270
+ - chore: Cascader名称统一
271
+ - fix: 修正ImportView的文件判断BUG
272
+
273
+ ### `4.3.5` `4.3.6` `4.3.7`
274
+ - chore: 优化代码
275
+ - feat: ImportView的文件下载逻辑实现
276
+
277
+ ### `4.3.1` - `4.3.4`
278
+ - feat: 适配4.3版本data
279
+ - feat: 删除无用输出
280
+
281
+ ### `4.2.10` `4.2.11`
282
+ - feat: ListView => QuickList
283
+ - feat: 添加QuickPanel
284
+ - feat: 全局添加emits-持续优化中
285
+
286
+ ### `4.2.9`
287
+ - fix: EditArea: data生成完成后再进行list赋值,避免list提前赋值导致的EditView提前加载导致的数据为空的加载
288
+
289
+ ### `4.2.6` `4.2.7` `4.2.8`
290
+ - chore: 升级data依赖
291
+ - fix: 修正class生成
292
+
293
+ ### `4.2.5`
294
+ - feat: ListView添加reset/destory
295
+
296
+ ### `4.2.4`
297
+ - chore: 升级data依赖,适配select
298
+
299
+ ### `4.2.3`
300
+ - chore: 升级依赖,修正错误引用
301
+
302
+ ### `4.2.2`
303
+ - chore: 优化layout传值逻辑,更新插件
304
+
305
+ ### `4.2.1`
306
+ - feat: 适配新版data
307
+ - feat: Table的滚动跟随列表而非检索和分页器
308
+ - feat: 实现InfoView的展示,接收观察函数
309
+ - feat: 实现InfoItem/EditItem两个组件,form中不交互的值通过InfoItem实现
310
+ - fix: InfoItem的lable样式还原
311
+ - chore: 简化Attrs调用
312
+
313
+ ### `4.1.4`
314
+ - feat: Select的分页和插槽实现
315
+
316
+ ### `4.1.3`
317
+ - chore: 升级data依赖,适配非编辑模块
318
+ - fix: 修正样式和类型
319
+
320
+ ### `4.1.2`
321
+ - chore: 升级plugin依赖,适配新版layout
322
+ - chore: 优化ModalView的菜单属性
323
+
324
+ ### `4.1.1`
325
+ - feat: 基于v4版本的ant-design和complex-component构建模板
package/icon.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { Component, VNode, h, reactive } from 'vue'
2
+ import { SearchOutlined, SettingOutlined, PlusOutlined, DeleteOutlined, ContainerOutlined, EditOutlined, ReloadOutlined, SyncOutlined, CloseOutlined, StopOutlined, DownloadOutlined, UploadOutlined, LinkOutlined, DownOutlined, UpOutlined } from '@ant-design/icons-vue'
3
+ import type { MenuValue } from '@complex-suite/data'
4
+ import EmptyImage from "./src/icons/EmptyImage.vue"
5
+ import ErrorImage from "./src/icons/ErrorImage.vue"
6
+ import type { localIconProps } from './type'
7
+
8
+ export const iconDict: Record<string, (props?: Record<PropertyKey, any>) => VNode> = reactive({
9
+ search: (props) => h(SearchOutlined, props),
10
+ setting: (props) => h(SettingOutlined, props),
11
+ build: (props) => h(PlusOutlined, props),
12
+ delete: (props) => h(DeleteOutlined, props),
13
+ info: (props) => h(ContainerOutlined, props),
14
+ edit: (props) => h(EditOutlined, props),
15
+ reset: (props) => h(ReloadOutlined, props),
16
+ refresh: (props) => h(SyncOutlined, props),
17
+ close: (props) => h(CloseOutlined, props),
18
+ stop: (props) => h(StopOutlined, props),
19
+ export: (props) => h(DownloadOutlined, props),
20
+ import: (props) => h(UploadOutlined, props),
21
+ link: (props) => h(LinkOutlined, props),
22
+ down: (props) => h(DownOutlined, props),
23
+ up: (props) => h(UpOutlined, props)
24
+ })
25
+
26
+ export const localIconDict: Record<string, Component> = {
27
+ emptyImage: EmptyImage,
28
+ errorImage: ErrorImage
29
+ }
30
+
31
+ const icon = reactive({
32
+ parse(name: MenuValue['icon']) {
33
+ if (name) {
34
+ if (typeof name === 'string') {
35
+ if (iconDict[name]) {
36
+ return iconDict[name]({
37
+ class: 'complex-icon'
38
+ })
39
+ } else {
40
+ console.error(`警告:${name}对应的icon未定义!`)
41
+ return name
42
+ }
43
+ } else {
44
+ return name() as VNode
45
+ }
46
+ } else {
47
+ return undefined
48
+ }
49
+ },
50
+ local(name: string, props: localIconProps = {}) {
51
+ if (name) {
52
+ if (localIconDict[name]) {
53
+ return h(localIconDict[name], props)
54
+ } else {
55
+ console.error(`警告:${name}对应的localIcon未定义!`)
56
+ return name
57
+ }
58
+ } else {
59
+ return undefined
60
+ }
61
+ }
62
+ })
63
+
64
+ export default icon
65
+
package/index.test.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { expect, test } from 'vitest'
2
+
3
+ test('adds 1 + 2 to equal 3', () => {
4
+ expect(1 + 2).toBe(3)
5
+ })
package/index.ts ADDED
@@ -0,0 +1,55 @@
1
+ import AutoSpin from "./src/AutoSpin.vue"
2
+ import AutoText from "./src/AutoText.vue"
3
+ import SelectText from "./src/SelectText.vue"
4
+ import MenuView from "./src/MenuView"
5
+ import ButtonView from "./src/ButtonView"
6
+ import SimpleTable from "./src/SimpleTable"
7
+ import TableView from "./src/TableView"
8
+ import ModalView from "./src/ModalView"
9
+ import InfoView from "./src/InfoView"
10
+ import InfoArea from "./src/InfoArea"
11
+ import EditView from "./src/EditView"
12
+ import EditArea from "./src/EditArea"
13
+ import SearchArea from "./src/SearchArea"
14
+ import ImageViewer from "./src/ImageViewer"
15
+ import FlexBox from "./src/FlexBox"
16
+ import AutoRender from "./src/components/AutoRender"
17
+ import ChoiceInfo from "./src/components/ChoiceInfo.vue"
18
+ import PaginationView from "./src/components/PaginationView"
19
+ import TableMenu from "./src/components/TableMenu"
20
+ import QuickList from "./quick/QuickList"
21
+ import QuickCascade from "./quick/QuickCascade"
22
+ import QuickEdit from "./quick/QuickEdit"
23
+ import QuickFloat from "./quick/QuickFloat"
24
+ import plugin from "./plugin"
25
+ import antdConfig from "./antdConfig"
26
+
27
+ export const ComplexAutoSpin = AutoSpin
28
+ export const ComplexAutoText = AutoText
29
+ export const ComplexSelectText = SelectText
30
+ export const ComplexMenuView = MenuView
31
+ export const ComplexButtonView = ButtonView
32
+ export const ComplexSimpleTable = SimpleTable
33
+ export const ComplexTableView = TableView
34
+ export const ComplexModalView = ModalView
35
+ export const ComplexInfoView = InfoView
36
+ export const ComplexInfoArea = InfoArea
37
+ export const ComplexEditView = EditView
38
+ export const ComplexEditArea = EditArea
39
+ export const ComplexSearchArea = SearchArea
40
+ export const ComplexImageViewer = ImageViewer
41
+ export const ComplexFlexBox = FlexBox
42
+ export const ComplexAutoRender = AutoRender
43
+ export const ComplexChoiceInfo = ChoiceInfo
44
+ export const ComplexPaginationView = PaginationView
45
+ export const ComplexTableMenu = TableMenu
46
+ export const ComplexQuickList = QuickList
47
+ export const ComplexQuickCascade = QuickCascade
48
+ export const ComplexQuickEdit = QuickEdit
49
+ export const ComplexQuickFloat = QuickFloat
50
+
51
+ export {
52
+ antdConfig
53
+ }
54
+
55
+ export default plugin
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@complex-suite/component-antd",
3
+ "version": "4.10.12",
4
+ "description": "a complex component by antd v4",
5
+ "type": "module",
6
+ "main": "index.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/MarAngle/complex-component-antd.git"
10
+ },
11
+ "dependencies": {
12
+ "ant-design-vue": "^4.2.6",
13
+ "dayjs": "^1.11.0",
14
+ "@complex-suite/utils": "2.10.5",
15
+ "@complex-suite/component": "4.10.4",
16
+ "@complex-suite/plugin": "4.10.2",
17
+ "@complex-suite/data": "4.10.9"
18
+ },
19
+ "devDependencies": {
20
+ "typescript": "^5.2.2",
21
+ "vitest": "^4.0.7",
22
+ "jsdom": "^27.1.0",
23
+ "@vitejs/plugin-vue": "^5.1.1",
24
+ "@vitejs/plugin-vue-jsx": "^4.0.0"
25
+ },
26
+ "keywords": [
27
+ "complex",
28
+ "component",
29
+ "antd"
30
+ ],
31
+ "author": "MarAngle",
32
+ "license": "ISC",
33
+ "scripts": {
34
+ "check": "tsc --noEmit",
35
+ "test": "vitest",
36
+ "coverage": "vitest run --coverage",
37
+ "release": "npm publish --registry=https://registry.npmjs.org"
38
+ }
39
+ }
package/plugin.ts ADDED
@@ -0,0 +1,95 @@
1
+ import { App, reactive } from "vue"
2
+ import type { FormInstance } from 'ant-design-vue'
3
+ import dayjs from 'dayjs'
4
+ import type { Dayjs } from 'dayjs'
5
+ import customParseFormat from "dayjs/plugin/customParseFormat"
6
+ import { date } from '@complex-suite/plugin'
7
+ import type { PluginLayout } from '@complex-suite/plugin'
8
+ import { Data, FormValue, DefaultEdit, SimpleDateEdit } from "@complex-suite/data"
9
+ import type { ruleOption } from "@complex-suite/data"
10
+ import LayoutResizeObserver from "./LayoutResizeObserver"
11
+ import './src/style/index.css'
12
+ import antdConfig from "./antdConfig"
13
+
14
+ export type ComplexComponentAntdOptions = {
15
+ reactive?: boolean
16
+ style?: boolean
17
+ pluginLayout?: PluginLayout
18
+ }
19
+
20
+ const defaultParseRule = function(ruleValue: ruleOption, form: Record<PropertyKey, any>) {
21
+ const currentRuleValue = { ...ruleValue } as any
22
+ if (currentRuleValue.validator) {
23
+ currentRuleValue.validator = function(rule: any, value: any, callback: any) {
24
+ const res = ruleValue.validator!(value, form, rule, callback)
25
+ if (typeof res === 'boolean') {
26
+ return res ? Promise.resolve() : Promise.reject()
27
+ } else {
28
+ return res
29
+ }
30
+ }
31
+ }
32
+ return currentRuleValue
33
+ }
34
+
35
+ const plugin = {
36
+ install: function(_app: App, options: ComplexComponentAntdOptions = {}) {
37
+ // dayjs扩展插件
38
+ dayjs.extend(customParseFormat)
39
+
40
+ if (options.reactive !== false) {
41
+ Data.$format = function(data, formatConfig) {
42
+ if (formatConfig && formatConfig.recommend) {
43
+ return reactive(data) as Data
44
+ } else {
45
+ return data
46
+ }
47
+ }
48
+ }
49
+ if (options.style !== false) {
50
+ antdConfig.initStyle()
51
+ }
52
+ if (options && options.pluginLayout) {
53
+ antdConfig.pluginLayout = options.pluginLayout
54
+ LayoutResizeObserver.init(options.pluginLayout)
55
+ }
56
+ FormValue.clearValidate = function(formValue, ...args: Parameters<FormInstance['clearValidate']>) {
57
+ if (formValue.ref) {
58
+ (formValue.ref as FormInstance).clearValidate(...args)
59
+ }
60
+ }
61
+ FormValue.validate = function(formValue, ...args: Parameters<FormInstance['validate']>) {
62
+ if (formValue.ref) {
63
+ return (formValue.ref as FormInstance).validate(...args)
64
+ } else {
65
+ return Promise.reject({ status: 'fail', code: 'no ref' })
66
+ }
67
+ }
68
+
69
+ DefaultEdit.$parseRule = defaultParseRule
70
+
71
+ date.pushParse('dayjs', value => dayjs(value))
72
+
73
+ SimpleDateEdit.$parseDate = function(dateValue) {
74
+ if (typeof dateValue.value === 'string') {
75
+ return date.getData('dayjs', dateValue.value)
76
+ } else {
77
+ return dateValue.value
78
+ }
79
+ }
80
+
81
+ SimpleDateEdit.$compareDate = function(target, other) {
82
+ return (other as Dayjs).valueOf() - (target as Dayjs).valueOf()
83
+ }
84
+
85
+ SimpleDateEdit.$parse = function(value, format) {
86
+ return value != undefined ? dayjs(value, format) : value
87
+ }
88
+
89
+ SimpleDateEdit.$collect = function(value, format) {
90
+ return value != undefined ? (value as Dayjs).format(format) : value
91
+ }
92
+ }
93
+ }
94
+
95
+ export default plugin
@@ -0,0 +1,107 @@
1
+ import { defineComponent, h, PropType, VNode } from "vue"
2
+ import type { AutoItemPayloadType } from "../src/dictionary/AutoItem"
3
+ import type { tablePayload } from "../src/TableView"
4
+ import ModalView from "../src/ModalView"
5
+ import type { ModalViewProps } from "../src/ModalView"
6
+ import QuickList from "./QuickList"
7
+ import type { QuickListProps } from "./QuickList"
8
+
9
+ export interface QuickCascadeProps {
10
+ list: QuickListProps
11
+ sublist: {
12
+ name: string
13
+ props: QuickListProps
14
+ show?: (payload: tablePayload) => void
15
+ modal?: Partial<ModalViewProps> // 子列表弹窗配置
16
+ render?: (props: QuickListProps) => VNode
17
+ }
18
+ }
19
+
20
+ export default defineComponent({
21
+ name: 'QuickCascade',
22
+ emits: {
23
+ search: (prop: string, _payload: AutoItemPayloadType<'edit'>) => {
24
+ return !!prop
25
+ },
26
+ table: (prop: string, _payload: tablePayload) => {
27
+ return !!prop
28
+ },
29
+ subSearch: (prop: string, _payload: AutoItemPayloadType<'edit'>) => {
30
+ return !!prop
31
+ },
32
+ subTable: (prop: string, _payload: tablePayload) => {
33
+ return !!prop
34
+ },
35
+ },
36
+ props: {
37
+ list: {
38
+ type: Object as PropType<QuickCascadeProps['list']>,
39
+ required: true
40
+ },
41
+ sublist: {
42
+ type: Object as PropType<QuickCascadeProps['sublist']>,
43
+ required: true
44
+ }
45
+ },
46
+ methods: {
47
+ renderList() {
48
+ return h(QuickList, {
49
+ ref: 'list',
50
+ onSearch: (prop, payload) => {
51
+ this.$emit('search', prop, payload)
52
+ },
53
+ onTable: (prop, payload) => {
54
+ this.$emit('table', prop, payload)
55
+ if (prop === '$sublist') {
56
+ this.openSublist(payload)
57
+ }
58
+ },
59
+ ...this.list
60
+ })
61
+ },
62
+ renderSublist() {
63
+ return h(
64
+ ModalView,
65
+ {
66
+ ref: 'sublist-modal',
67
+ menu: ['close'],
68
+ ...this.sublist.modal
69
+ },
70
+ {
71
+ default: () => this.$renderSublist()
72
+ }
73
+ )
74
+ },
75
+ $renderSublist() {
76
+ if (!this.sublist.render) {
77
+ return h(QuickList, {
78
+ ref: 'sublist',
79
+ onSearch: (prop, payload) => {
80
+ this.$emit('subSearch', prop, payload)
81
+ },
82
+ onTable: (prop, payload) => {
83
+ this.$emit('subTable', prop, payload)
84
+ },
85
+ ...this.sublist.props
86
+ })
87
+ } else {
88
+ return this.sublist.render(this.sublist.props)
89
+ }
90
+ },
91
+ openSublist(payload: tablePayload) {
92
+ (this.$refs['sublist-modal'] as InstanceType<typeof ModalView>).show(this.sublist.name)
93
+ if (this.sublist.show) {
94
+ this.sublist.show(payload)
95
+ }
96
+ },
97
+ },
98
+
99
+ /**
100
+ * 主要模板
101
+
102
+ * @returns {VNode}
103
+ */
104
+ render() {
105
+ return [this.renderList(), this.renderSublist()]
106
+ }
107
+ })