@bdsoft/element 1.1.9 → 1.1.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 (244) hide show
  1. package/dist/BdElement.js +23111 -0
  2. package/index.js +11 -11
  3. package/package.json +2 -1
  4. package/global/index.ts +0 -6
  5. package/global/register-properties.ts +0 -10
  6. package/index.html +0 -13
  7. package/package-form/core/components/formCreate.js +0 -274
  8. package/package-form/core/components/fragment.js +0 -12
  9. package/package-form/core/factory/context.js +0 -257
  10. package/package-form/core/factory/creator.js +0 -63
  11. package/package-form/core/factory/maker.js +0 -17
  12. package/package-form/core/factory/manager.js +0 -79
  13. package/package-form/core/factory/node.js +0 -85
  14. package/package-form/core/factory/parser.js +0 -28
  15. package/package-form/core/frame/api.js +0 -599
  16. package/package-form/core/frame/attrs.js +0 -12
  17. package/package-form/core/frame/dataDriver.js +0 -76
  18. package/package-form/core/frame/fetch.js +0 -119
  19. package/package-form/core/frame/formCreate.js +0 -274
  20. package/package-form/core/frame/index.js +0 -760
  21. package/package-form/core/frame/provider.js +0 -288
  22. package/package-form/core/frame/util.js +0 -274
  23. package/package-form/core/handler/context.js +0 -380
  24. package/package-form/core/handler/effect.js +0 -122
  25. package/package-form/core/handler/index.js +0 -111
  26. package/package-form/core/handler/inject.js +0 -145
  27. package/package-form/core/handler/input.js +0 -197
  28. package/package-form/core/handler/lifecycle.js +0 -43
  29. package/package-form/core/handler/loader.js +0 -373
  30. package/package-form/core/handler/page.js +0 -46
  31. package/package-form/core/handler/render.js +0 -29
  32. package/package-form/core/index.js +0 -12
  33. package/package-form/core/package.json +0 -15
  34. package/package-form/core/parser/html.js +0 -17
  35. package/package-form/core/render/cache.js +0 -47
  36. package/package-form/core/render/index.js +0 -31
  37. package/package-form/core/render/render.js +0 -393
  38. package/package-form/element-form/components/checkbox/package.json +0 -17
  39. package/package-form/element-form/components/checkbox/src/component.jsx +0 -110
  40. package/package-form/element-form/components/checkbox/src/index.js +0 -3
  41. package/package-form/element-form/components/frame/package.json +0 -17
  42. package/package-form/element-form/components/frame/src/IconCircleClose.vue +0 -14
  43. package/package-form/element-form/components/frame/src/IconDelete.vue +0 -12
  44. package/package-form/element-form/components/frame/src/IconDocument.vue +0 -12
  45. package/package-form/element-form/components/frame/src/IconFolderOpened.vue +0 -12
  46. package/package-form/element-form/components/frame/src/IconView.vue +0 -12
  47. package/package-form/element-form/components/frame/src/component.jsx +0 -349
  48. package/package-form/element-form/components/frame/src/index.js +0 -3
  49. package/package-form/element-form/components/frame/src/style.css +0 -66
  50. package/package-form/element-form/components/group/package.json +0 -17
  51. package/package-form/element-form/components/group/src/component.jsx +0 -314
  52. package/package-form/element-form/components/group/src/index.js +0 -3
  53. package/package-form/element-form/components/group/src/style.css +0 -125
  54. package/package-form/element-form/components/index.js +0 -22
  55. package/package-form/element-form/components/radio/package.json +0 -17
  56. package/package-form/element-form/components/radio/src/component.jsx +0 -101
  57. package/package-form/element-form/components/radio/src/index.js +0 -3
  58. package/package-form/element-form/components/select/package.json +0 -17
  59. package/package-form/element-form/components/select/src/component.jsx +0 -52
  60. package/package-form/element-form/components/select/src/index.js +0 -3
  61. package/package-form/element-form/components/subform/package.json +0 -14
  62. package/package-form/element-form/components/subform/src/component.jsx +0 -76
  63. package/package-form/element-form/components/subform/src/index.js +0 -3
  64. package/package-form/element-form/components/tree/package.json +0 -17
  65. package/package-form/element-form/components/tree/src/component.jsx +0 -62
  66. package/package-form/element-form/components/tree/src/index.js +0 -3
  67. package/package-form/element-form/components/upload/package.json +0 -17
  68. package/package-form/element-form/components/upload/src/IconUpload.vue +0 -12
  69. package/package-form/element-form/components/upload/src/component.jsx +0 -129
  70. package/package-form/element-form/components/upload/src/index.js +0 -3
  71. package/package-form/element-form/components/upload/src/style.css +0 -11
  72. package/package-form/element-form/index.js +0 -8
  73. package/package-form/element-form/package.json +0 -16
  74. package/package-form/element-form/src/components/icon/IconWarning.vue +0 -12
  75. package/package-form/element-form/src/components/index.js +0 -22
  76. package/package-form/element-form/src/core/alias.js +0 -34
  77. package/package-form/element-form/src/core/api.js +0 -208
  78. package/package-form/element-form/src/core/config.js +0 -62
  79. package/package-form/element-form/src/core/index.js +0 -60
  80. package/package-form/element-form/src/core/maker.js +0 -76
  81. package/package-form/element-form/src/core/manager.js +0 -315
  82. package/package-form/element-form/src/core/provider.js +0 -79
  83. package/package-form/element-form/src/parsers/datePicker.js +0 -31
  84. package/package-form/element-form/src/parsers/hidden.js +0 -12
  85. package/package-form/element-form/src/parsers/index.js +0 -17
  86. package/package-form/element-form/src/parsers/input.js +0 -21
  87. package/package-form/element-form/src/parsers/row.js +0 -10
  88. package/package-form/element-form/src/parsers/select.js +0 -15
  89. package/package-form/element-form/src/parsers/slider.js +0 -21
  90. package/package-form/element-form/src/parsers/timePicker.js +0 -17
  91. package/package-form/element-form/src/style/index.css +0 -52
  92. package/src/App.vue +0 -28
  93. package/src/assets/css/element.scss +0 -196
  94. package/src/assets/css/layout.scss +0 -215
  95. package/src/assets/css/tailwind.scss +0 -67
  96. package/src/assets/images/banner.gif +0 -0
  97. package/src/assets/images/banner.png +0 -0
  98. package/src/assets/images/bg1.svg +0 -22
  99. package/src/assets/images/bg2.png +0 -0
  100. package/src/assets/images/ff.png +0 -0
  101. package/src/assets/images/home-file1.png +0 -0
  102. package/src/assets/images/ky.png +0 -0
  103. package/src/assets/images/menu/add.png +0 -0
  104. package/src/assets/images/menu/del.png +0 -0
  105. package/src/assets/images/menu/down.png +0 -0
  106. package/src/assets/images/menu/dr.png +0 -0
  107. package/src/assets/images/menu/edit.png +0 -0
  108. package/src/assets/images/menu/kx.png +0 -0
  109. package/src/assets/images/menu/mb.png +0 -0
  110. package/src/assets/images/menu/pz.png +0 -0
  111. package/src/assets/images/menu/save.png +0 -0
  112. package/src/assets/images/menu/sj.png +0 -0
  113. package/src/assets/images/menu/sjk.png +0 -0
  114. package/src/assets/images/menu/up.png +0 -0
  115. package/src/assets/images/po-i.png +0 -0
  116. package/src/assets/images/po1-i1.png +0 -0
  117. package/src/assets/images/po1-i2.png +0 -0
  118. package/src/assets/images/po1-i3.png +0 -0
  119. package/src/assets/images/po1-i4.png +0 -0
  120. package/src/assets/images/po1-i5.png +0 -0
  121. package/src/assets/images/po1-i6.png +0 -0
  122. package/src/assets/images/po1-i7.png +0 -0
  123. package/src/assets/images/po1-i8.png +0 -0
  124. package/src/assets/images/po2-i1.png +0 -0
  125. package/src/assets/images/po2-i2.png +0 -0
  126. package/src/assets/images/po3-i1.png +0 -0
  127. package/src/assets/images/po4-i1.png +0 -0
  128. package/src/assets/images/po5-i1.png +0 -0
  129. package/src/assets/images/po6-i1.png +0 -0
  130. package/src/assets/images/po6-i2.png +0 -0
  131. package/src/assets/images/po7-i1.png +0 -0
  132. package/src/assets/images/tj1.png +0 -0
  133. package/src/assets/images/tj2.png +0 -0
  134. package/src/assets/images/tj3.png +0 -0
  135. package/src/components/3dcloudwords/index.js +0 -346
  136. package/src/components/3dcloudwords/index.vue +0 -99
  137. package/src/components/3dcloudwords/readme.md +0 -66
  138. package/src/components/badge/index.js +0 -167
  139. package/src/components/badge/index.scss +0 -166
  140. package/src/components/badge/index.vue +0 -98
  141. package/src/components/badge/readme.md +0 -18
  142. package/src/components/basic/Finish.vue +0 -107
  143. package/src/components/basic/button.vue +0 -19
  144. package/src/components/basic/readme.md +0 -7
  145. package/src/components/button/index.vue +0 -48
  146. package/src/components/button/readme.md +0 -62
  147. package/src/components/carousel/index.vue +0 -104
  148. package/src/components/carousel/readme.md +0 -12
  149. package/src/components/chartconfig/index.vue +0 -141
  150. package/src/components/chartconfig/readme.md +0 -25
  151. package/src/components/contextMenu/hookContxtMenu.js +0 -41
  152. package/src/components/contextMenu/index.vue +0 -245
  153. package/src/components/contextMenu/readme.md +0 -55
  154. package/src/components/contextMenu/useElementBounding.js +0 -40
  155. package/src/components/countup/countUp.js +0 -196
  156. package/src/components/countup/index.vue +0 -114
  157. package/src/components/countup/readme.md +0 -9
  158. package/src/components/empty/assets/build.png +0 -0
  159. package/src/components/empty/assets/emptybg.gif +0 -0
  160. package/src/components/empty/assets/emptybg.png +0 -0
  161. package/src/components/empty/assets/emptybg2.jpg +0 -0
  162. package/src/components/empty/assets/emptybg3.jpg +0 -0
  163. package/src/components/empty/assets/wuxiao.png +0 -0
  164. package/src/components/empty/assets/wuxiao.webp +0 -0
  165. package/src/components/empty/building.vue +0 -117
  166. package/src/components/empty/empty.vue +0 -120
  167. package/src/components/empty/index.js +0 -12
  168. package/src/components/empty/invalid.vue +0 -56
  169. package/src/components/error/Error.vue +0 -79
  170. package/src/components/error/readme.md +0 -20
  171. package/src/components/form/Form.vue +0 -84
  172. package/src/components/form/FormItem.vue +0 -143
  173. package/src/components/form/data.js +0 -52
  174. package/src/components/form/readme.md +0 -69
  175. package/src/components/layout/banner.vue +0 -412
  176. package/src/components/layout/bar.vue +0 -43
  177. package/src/components/layout/layout1.vue +0 -60
  178. package/src/components/layout/layout2.vue +0 -134
  179. package/src/components/layout/layout3.vue +0 -107
  180. package/src/components/layout/layout4.vue +0 -66
  181. package/src/components/layout/nav.vue +0 -333
  182. package/src/components/layout/readme.md +0 -61
  183. package/src/components/loading/index.vue +0 -122
  184. package/src/components/loading/readme.md +0 -6
  185. package/src/components/notice/NoticeList.vue +0 -198
  186. package/src/components/notice/NoticeListPaging.vue +0 -281
  187. package/src/components/notice/NoticeView.vue +0 -92
  188. package/src/components/notice/readme.md +0 -1
  189. package/src/components/pagination/index.vue +0 -100
  190. package/src/components/pagination/readme.md +0 -19
  191. package/src/components/pagination/scroll-to.js +0 -51
  192. package/src/components/progress/bar.vue +0 -72
  193. package/src/components/progress/progress.vue +0 -58
  194. package/src/components/screenfull/index.js +0 -3
  195. package/src/components/screenfull/index.vue +0 -65
  196. package/src/components/screenfull/package.json +0 -15
  197. package/src/components/screenfull/readme.md +0 -6
  198. package/src/components/statisticalCount/index.vue +0 -80
  199. package/src/components/statisticalCount/readme.md +0 -21
  200. package/src/components/username/index.vue +0 -79
  201. package/src/components/username/readme.md +0 -22
  202. package/src/components/username//346/225/210/346/236/234/345/233/276.png +0 -0
  203. package/src/index.js +0 -88
  204. package/src/utils/index.js +0 -32
  205. package/src/xm_components/HeadSearch/hook/hookSearch.js +0 -96
  206. package/src/xm_components/HeadSearch/index.vue +0 -206
  207. package/src/xm_components/HeadSearch/readme.md +0 -12
  208. package/src/xm_components/HeadSearch//346/220/234/347/264/242/345/210/227/350/241/250.png +0 -0
  209. package/src/xm_components/Milestone/index.vue +0 -213
  210. package/src/xm_components/Milestone/readme.md +0 -15
  211. package/src/xm_components/MultiStatisticalCard/image.png +0 -0
  212. package/src/xm_components/MultiStatisticalCard/index.vue +0 -114
  213. package/src/xm_components/MultiStatisticalCard/readme.md +0 -29
  214. package/src/xm_components/StatisticalCard/image.png +0 -0
  215. package/src/xm_components/StatisticalCard/index.vue +0 -196
  216. package/src/xm_components/StatisticalCard/readme.md +0 -41
  217. package/src/xm_components/readme.md +0 -1
  218. package/utils/coms/load.jsx +0 -10
  219. package/utils/func.js +0 -32
  220. package/utils/hookDialog.js +0 -38
  221. package/utils/hookPage.js +0 -49
  222. package/utils/index.js +0 -5
  223. package/utils/lib/console.js +0 -39
  224. package/utils/lib/debounce.js +0 -19
  225. package/utils/lib/deepextend.js +0 -51
  226. package/utils/lib/deepset.js +0 -14
  227. package/utils/lib/extend.js +0 -28
  228. package/utils/lib/index.js +0 -13
  229. package/utils/lib/json.js +0 -90
  230. package/utils/lib/mergeprops.js +0 -62
  231. package/utils/lib/mitt.js +0 -43
  232. package/utils/lib/modify.js +0 -8
  233. package/utils/lib/slot.js +0 -19
  234. package/utils/lib/toarray.js +0 -5
  235. package/utils/lib/tocase.js +0 -11
  236. package/utils/lib/todate.js +0 -10
  237. package/utils/lib/toline.js +0 -10
  238. package/utils/lib/tostring.js +0 -7
  239. package/utils/lib/type.js +0 -45
  240. package/utils/lib/unique.js +0 -6
  241. package/utils/message.js +0 -164
  242. package/utils/package.json +0 -16
  243. package/utils/type.js +0 -45
  244. package/vite.config.js +0 -56
@@ -1,380 +0,0 @@
1
- import extend from '@bdsoft-element/utils/lib/extend';
2
- import toCase from '@bdsoft-element/utils/lib/tocase';
3
- import BaseParser from '../factory/parser';
4
- import {$del} from '@bdsoft-element/utils/lib/modify';
5
- import is, {hasProperty} from '@bdsoft-element/utils/lib/type';
6
- import {condition, deepGet, invoke, convertFieldToConditions} from '../frame/util';
7
- import {computed, nextTick, toRef, watch} from 'vue';
8
- import {attrs} from '../frame/attrs';
9
- import deepSet from '@bdsoft-element/utils/lib/deepset';
10
- import toArray from '@bdsoft-element/utils/lib/toarray';
11
-
12
- const noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
13
- const oldValueTag = Symbol('oldValue');
14
-
15
- export default function useContext(Handler) {
16
- extend(Handler.prototype, {
17
- getCtx(id) {
18
- return this.getFieldCtx(id) || this.getNameCtx(id)[0] || this.ctxs[id];
19
- },
20
- getCtxs(id) {
21
- return this.fieldCtx[id] || this.nameCtx[id] || (this.ctxs[id] ? [this.ctxs[id]] : []);
22
- },
23
- setIdCtx(ctx, key, type) {
24
- const field = `${type}Ctx`;
25
- if (!this[field][key]) {
26
- this[field][key] = [ctx];
27
- } else {
28
- this[field][key].push(ctx);
29
- }
30
- },
31
- rmIdCtx(ctx, key, type) {
32
- const field = `${type}Ctx`;
33
- const lst = this[field][key];
34
- if (!lst) return false;
35
- const flag = lst.splice(lst.indexOf(ctx) >>> 0, 1).length > 0;
36
- if (!lst.length) {
37
- delete this[field][key];
38
- }
39
- return flag;
40
- },
41
- getFieldCtx(field) {
42
- return (this.fieldCtx[field] || [])[0];
43
- },
44
- getNameCtx(name) {
45
- return this.nameCtx[name] || [];
46
- },
47
- setCtx(ctx) {
48
- let {id, field, name, rule} = ctx;
49
- this.ctxs[id] = ctx;
50
- name && this.setIdCtx(ctx, name, 'name');
51
- if (!ctx.input) return;
52
- this.setIdCtx(ctx, field, 'field');
53
- this.setFormData(ctx, ctx.parser.toFormValue(rule.value, ctx));
54
- if (this.isMounted && !this.reloading) {
55
- this.vm.emit('change', ctx.field, rule.value, ctx.origin, this.api);
56
- }
57
- },
58
- getParser(ctx) {
59
- const list = this.fc.parsers;
60
- const renderDriver = this.fc.renderDriver;
61
- if (renderDriver) {
62
- const list = renderDriver.parsers || {};
63
- const parser = list[ctx.originType] || list[toCase(ctx.type)] || list[ctx.trueType];
64
- if (parser) {
65
- return parser;
66
- }
67
- }
68
- return list[ctx.originType] || list[toCase(ctx.type)] || list[ctx.trueType] || BaseParser;
69
- },
70
- bindParser(ctx) {
71
- ctx.setParser(this.getParser(ctx));
72
- },
73
- getType(alias) {
74
- const map = this.fc.CreateNode.aliasMap;
75
- const type = map[alias] || map[toCase(alias)] || alias;
76
- return toCase(type);
77
- },
78
- noWatch(fn) {
79
- if (!this.noWatchFn) {
80
- this.noWatchFn = fn;
81
- }
82
- invoke(fn);
83
- if (this.noWatchFn === fn) {
84
- this.noWatchFn = null;
85
- }
86
- },
87
- watchCtx(ctx) {
88
- const all = attrs();
89
- all.filter(k => k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1).forEach((key) => {
90
- const ref = toRef(ctx.rule, key);
91
- const flag = key === 'children';
92
- ctx.refRule[key] = ref;
93
- ctx.watch.push(watch(flag ? () => is.Function(ref.value) ? ref.value : [...(ref.value || [])] : () => ref.value, (_, o) => {
94
- let n = ref.value;
95
- if (this.isBreakWatch()) return;
96
- if (flag && ctx.parser.loadChildren === false) {
97
- this.$render.clearCache(ctx);
98
- this.nextRefresh();
99
- return;
100
- }
101
- this.watching = true;
102
- nextTick(() => {
103
- this.targetHook(ctx, 'watch', {key, oldValue: o, newValue: n});
104
- });
105
- if (key === 'hidden' && Boolean(n) !== Boolean(o)) {
106
- this.$render.clearCacheAll();
107
- nextTick(() => {
108
- this.targetHook(ctx, 'hidden', {value: n});
109
- });
110
- }
111
- if ((key === 'ignore' && ctx.input) || (key === 'hidden' && ctx.input && (ctx.rule.ignore === 'hidden' || this.options.ignoreHiddenFields))) {
112
- this.syncForm();
113
- } else if (key === 'link') {
114
- ctx.link();
115
- return;
116
- } else if (['props', 'on', 'deep'].indexOf(key) > -1) {
117
- this.parseInjectEvent(ctx.rule, n || {});
118
- if (key === 'props' && ctx.input) {
119
- this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
120
- }
121
- } else if (key === 'emit') {
122
- this.parseEmit(ctx);
123
- } else if (['prefix', 'suffix'].indexOf(key) > -1)
124
- n && this.loadFn(n, ctx.rule);
125
- else if (key === 'type') {
126
- ctx.updateType();
127
- this.bindParser(ctx);
128
- } else if (flag) {
129
- if (is.Function(o)) {
130
- o = ctx.getPending('children', []);
131
- }
132
- if (is.Function(n)) {
133
- n = ctx.loadChildrenPending();
134
- }
135
- this.updateChildren(ctx, n, o);
136
- }
137
- this.$render.clearCache(ctx);
138
- this.refresh();
139
- this.watching = false;
140
- }, {deep: !flag, sync: flag}));
141
- });
142
- ctx.refRule['__$title'] = computed(() => {
143
- let title = (typeof ctx.rule.title === 'object' ? ctx.rule.title.title : ctx.rule.title) || '';
144
- if (title) {
145
- const match = title.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
146
- if (match) {
147
- title = this.api.t(match[1]);
148
- }
149
- }
150
- return title;
151
- });
152
- ctx.refRule['__$info'] = computed(() => {
153
- let info = (typeof ctx.rule.info === 'object' ? ctx.rule.info.info : ctx.rule.info) || '';
154
- if (info) {
155
- const match = info.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
156
- if (match) {
157
- info = this.api.t(match[1]);
158
- }
159
- }
160
- return info;
161
- });
162
- ctx.refRule['__$validate'] = computed(() => {
163
- return toArray(ctx.rule.validate).map(item => {
164
- const temp = {...item};
165
- if (temp.message) {
166
- const match = temp.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
167
- if (match) {
168
- temp.message = this.api.t(match[1], {title: ctx.refRule.__$title.value});
169
- }
170
- }
171
- if (is.Function(temp.validator)) {
172
- const that = ctx;
173
- temp.validator = function (...args) {
174
- return item.validator.call({
175
- that: this,
176
- id: that.id,
177
- field: that.field,
178
- rule: that.rule,
179
- api: that.$handle.api,
180
- }, ...args)
181
- }
182
- return temp;
183
- }
184
- return temp;
185
- });
186
- });
187
- if (ctx.input) {
188
- const val = toRef(ctx.rule, 'value');
189
- ctx.watch.push(watch(() => val.value, () => {
190
- let formValue = ctx.parser.toFormValue(val.value, ctx);
191
- if (this.isChange(ctx, formValue)) {
192
- this.setValue(ctx, val.value, formValue, true);
193
- }
194
- }));
195
- }
196
- this.bus.$once('load-end', () => {
197
- let computedRule = ctx.rule.computed;
198
- if (!computedRule) {
199
- return;
200
- }
201
- if (typeof computedRule !== 'object') {
202
- computedRule = {value: computedRule}
203
- }
204
- Object.keys(computedRule).forEach(k => {
205
- let oldValue = undefined;
206
- const computedValue = computed(() => {
207
- const item = computedRule[k];
208
- if (!item) return undefined;
209
- const value = this.compute(ctx, item);
210
- if (item.linkage && value === oldValueTag) {
211
- return oldValue;
212
- }
213
- return value;
214
- });
215
- const callback = (n) => {
216
- if (k === 'value') {
217
- this.onInput(ctx, n);
218
- } else if (k[0] === '$') {
219
- this.api.setEffect(ctx.id, k, n);
220
- } else {
221
- deepSet(ctx.rule, k, n);
222
- }
223
- };
224
- if (k === 'value' ? [undefined, null, ''].indexOf(ctx.rule.value) > -1 : computedValue.value !== deepGet(ctx.rule, k)) {
225
- callback(computedValue.value);
226
- }
227
- ctx.watch.push(watch(computedValue, (n) => {
228
- oldValue = n;
229
- setTimeout(() => {
230
- callback(n);
231
- });
232
- }));
233
- });
234
-
235
- });
236
- this.watchEffect(ctx);
237
- },
238
- compute(ctx, item) {
239
- let fn;
240
- if (typeof item === 'object') {
241
- const group = ctx.getParentGroup();
242
- const checkCondition = (item) => {
243
- item = Array.isArray(item) ? {mode: 'AND', group: item} : item;
244
- if (!is.trueArray(item.group)) {
245
- return true;
246
- }
247
- const or = item.mode === 'OR';
248
- let valid = true;
249
- for (let i = 0; i < item.group.length; i++) {
250
- const one = item.group[i];
251
- let flag;
252
- let field = null;
253
- if (one.variable) {
254
- field = JSON.stringify(this.fc.getLoadData(one.variable) || '');
255
- } else if (one.field) {
256
- field = convertFieldToConditions(one.field || '');
257
- } else {
258
- return true;
259
- }
260
- let compare = one.compare;
261
- if(compare) {
262
- compare = convertFieldToConditions(compare || '');
263
- }
264
- if (one.mode) {
265
- flag = checkCondition(one);
266
- } else if (!condition[one.condition]) {
267
- flag = false;
268
- } else if (is.Function(one.handler)) {
269
- flag = invoke(() => one.handler(this.api, ctx.rule));
270
- } else {
271
- flag = (new Function('$condition', '$val', '$form', '$group', '$rule', `with($form){with(this){with($group){ return $condition['${one.condition}'](${field}, ${compare ? compare : '$val'}); }}}`)).call(this.api.form, condition, one.value, this.api.top.form, group ? (this.subRuleData[group.id] || {}) : {}, ctx.rule);
272
- }
273
- if (or && flag) {
274
- return true;
275
- }
276
- if (!or) {
277
- valid = valid && flag;
278
- }
279
- }
280
- return or ? false : valid;
281
- }
282
- let val = checkCondition(item);
283
- val = item.invert === true ? !val : val;
284
- if (item.linkage) {
285
- return val ? invoke(() => this.computeValue(item.linkage, ctx, group), undefined) : oldValueTag;
286
- }
287
- return val;
288
- } else if (is.Function(item)) {
289
- fn = () => item(this.api.form, this.api);
290
- } else {
291
- const group = ctx.getParentGroup();
292
- fn = () => this.computeValue(item, ctx, group);
293
- }
294
- return invoke(fn, undefined);
295
- },
296
- computeValue(str, ctx, group) {
297
- const that = this;
298
- const formulas = Object.keys(this.fc.formulas).reduce((obj, k) => {
299
- obj[k] = function (...args) {
300
- return that.fc.formulas[k].call({
301
- that: this,
302
- rule: ctx.rule,
303
- api: that.api,
304
- fc: that.fc
305
- }, ...args);
306
- }
307
- return obj;
308
- }, {})
309
- return (new Function('$formulas', '$form', '$group', '$rule', '$api', `with($form){with(this){with($group){with($formulas){ return ${str} }}}}`)).call(this.api.form, formulas, this.api.top.form, group ? (this.subRuleData[group.id] || {}) : {}, ctx.rule, this.api);
310
- },
311
- updateChildren(ctx, n, o) {
312
- this.deferSyncValue(() => {
313
- o && o.forEach((child) => {
314
- if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
315
- this.rmCtx(child.__fc__);
316
- }
317
- });
318
- if (is.trueArray(n)) {
319
- this.loadChildren(n, ctx);
320
- this.bus.$emit('update', this.api);
321
- }
322
- });
323
- },
324
- rmSub(sub) {
325
- is.trueArray(sub) && sub.forEach(r => {
326
- r && r.__fc__ && this.rmCtx(r.__fc__);
327
- })
328
- },
329
- rmCtx(ctx) {
330
- if (ctx.deleted) return;
331
- const {id, field, input, name} = ctx;
332
-
333
- $del(this.ctxs, id);
334
- $del(this.formData, id);
335
- $del(this.subForm, id);
336
- $del(this.vm.setupState.ctxInject, id);
337
- const group = ctx.getParentGroup();
338
- if (group && this.subRuleData[group.id]) {
339
- $del(this.subRuleData[group.id], field);
340
- }
341
- if (ctx.group) {
342
- $del(this.subRuleData, id);
343
- }
344
-
345
- input && this.rmIdCtx(ctx, field, 'field');
346
- name && this.rmIdCtx(ctx, name, 'name');
347
-
348
- if (input && !hasProperty(this.fieldCtx, field)) {
349
- $del(this.form, field);
350
- }
351
-
352
- this.deferSyncValue(() => {
353
- if (!this.reloading) {
354
- if (ctx.parser.loadChildren !== false) {
355
- const children = ctx.getPending('children', ctx.rule.children);
356
- if (is.trueArray(children)) {
357
- children.forEach(h => h.__fc__ && this.rmCtx(h.__fc__));
358
- }
359
- }
360
- if (ctx.root === this.rules) {
361
- this.vm.setupState.renderRule();
362
- }
363
- }
364
- }, input);
365
-
366
- const index = this.sort.indexOf(id);
367
- if (index > -1) {
368
- this.sort.splice(index, 1);
369
- }
370
-
371
- this.$render.clearCache(ctx);
372
- ctx.delete();
373
- this.effect(ctx, 'deleted');
374
- this.targetHook(ctx, 'deleted');
375
- input && !this.fieldCtx[field] && this.vm.emit('remove-field', field, ctx.rule, this.api);
376
- ctx.rule.__ctrl || this.vm.emit('remove-rule', ctx.rule, this.api);
377
- return ctx;
378
- },
379
- })
380
- }
@@ -1,122 +0,0 @@
1
- import extend from '@bdsoft-element/utils/lib/extend';
2
- import is, {hasProperty} from '@bdsoft-element/utils/lib/type';
3
- import {mergeRule} from '../frame/util';
4
- import {watch} from 'vue';
5
-
6
-
7
- export default function useEffect(Handler) {
8
- extend(Handler.prototype, {
9
- useProvider() {
10
- const ps = this.fc.providers;
11
- Object.keys(ps).forEach(k => {
12
- let prop = ps[k];
13
- if (is.Function(prop)) {
14
- prop = prop(this.fc);
15
- }
16
- prop._c = getComponent(prop);
17
- this.onEffect(prop);
18
- this.providers[k] = prop;
19
- });
20
- },
21
- onEffect(provider) {
22
- const used = [];
23
- (provider._c || ['*']).forEach(name => {
24
- const type = name === '*' ? '*' : this.getType(name);
25
- if (used.indexOf(type) > -1) return;
26
- used.push(type);
27
- this.bus.$on(`p:${provider.name}:${type}:${provider.input ? 1 : 0}`, (event, args) => {
28
- provider[event] && provider[event](...args);
29
- });
30
- });
31
- provider._used = used;
32
- },
33
- watchEffect(ctx) {
34
- let effect = {
35
- required: () => {
36
- return (hasProperty(ctx.rule, '$required') ? ctx.rule['$required'] : ctx.rule?.effect?.required) || false;
37
- }
38
- };
39
- Object.keys(ctx.rule.effect || {}).forEach(k => {
40
- effect[k] = () => ctx.rule.effect[k];
41
- })
42
- Object.keys(ctx.rule).forEach(k => {
43
- if (k[0] === '$') {
44
- effect[k.substr(1)] = () => ctx.rule[k];
45
- }
46
- })
47
- Object.keys(effect).forEach(k => {
48
- ctx.watch.push(watch(effect[k], (n) => {
49
- this.effect(ctx, 'watch', {[k]: n});
50
- }, {deep: true}));
51
- });
52
- },
53
- ruleEffect(rule, event, append) {
54
- this.emitEffect({
55
- rule,
56
- input: !!rule.field,
57
- type: this.getType(rule.type)
58
- }, event, append);
59
- },
60
- effect(ctx, event, custom) {
61
- this.emitEffect({
62
- rule: ctx.rule,
63
- input: ctx.input,
64
- type: ctx.trueType,
65
- ctx,
66
- custom
67
- }, event);
68
- },
69
- getEffect(rule, name) {
70
- if (hasProperty(rule, '$' + name)) {
71
- return rule['$' + name];
72
- }
73
- if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name))
74
- return rule.effect[name];
75
- return undefined;
76
- },
77
- emitEffect({ctx, rule, input, type, custom}, event, append) {
78
- if (!type || ['fcFragment', 'fragment'].indexOf(type) > -1) return;
79
- const effect = custom ? custom : (Object.keys(rule).reduce((i, k) => {
80
- if (k[0] === '$') {
81
- i[k.substr(1)] = rule[k];
82
- }
83
- return i;
84
- }, {...rule.effect || {}}));
85
- Object.keys(effect).forEach(attr => {
86
- const p = this.providers[attr];
87
- if (!p || (p.input && !input)) return;
88
- let _type;
89
- if (!p._c) {
90
- _type = '*';
91
- } else if (p._used.indexOf(type) > -1) {
92
- _type = type;
93
- } else {
94
- return;
95
- }
96
- const data = {value: effect[attr], getValue: () => this.getEffect(rule, attr), ...(append || {})};
97
- if (ctx) {
98
- data.getProp = () => ctx.effectData(attr);
99
- data.clearProp = () => ctx.clearEffectData(attr);
100
- data.mergeProp = (prop) => mergeRule(data.getProp(), [prop]);
101
- data.id = ctx.id;
102
- }
103
- this.bus.$emit(`p:${attr}:${_type}:${p.input ? 1 : 0}`, event, [data, rule, this.api]);
104
- });
105
- }
106
- });
107
- }
108
-
109
- function unique(arr) {
110
- return arr.filter(function (item, index, arr) {
111
- return arr.indexOf(item, 0) === index;
112
- });
113
- }
114
-
115
- function getComponent(p) {
116
- const c = p.components;
117
- if (Array.isArray(c)) {
118
- const arr = unique(c.filter(v => v !== '*'));
119
- return arr.length ? arr : false;
120
- } else if (is.String(c)) return [c];
121
- else return false;
122
- }
@@ -1,111 +0,0 @@
1
- import Api from '../frame/api';
2
- import Render from '../render';
3
- import extend from '@bdsoft-element/utils/lib/extend';
4
- import {funcProxy, invoke} from '../frame/util';
5
- import useInject from './inject';
6
- import usePage from './page';
7
- import useRender from './render';
8
- import useLoader from './loader';
9
- import useInput from './input';
10
- import useContext from './context';
11
- import useLifecycle from './lifecycle';
12
- import useEffect from './effect';
13
- import {reactive} from 'vue';
14
- import is from '@bdsoft-element/utils/lib/type';
15
-
16
-
17
- export default function Handler(fc) {
18
- funcProxy(this, {
19
- options() {
20
- return fc.options.value || {};
21
- },
22
- bus() {
23
- return fc.bus;
24
- },
25
- preview() {
26
- return (fc.vm.props.preview != null ? fc.vm.props.preview : (fc.options.value.preview || false));
27
- }
28
- })
29
- extend(this, {
30
- fc,
31
- vm: fc.vm,
32
- watching: false,
33
- loading: false,
34
- reloading: false,
35
- noWatchFn: null,
36
- deferSyncFn: null,
37
- isMounted: false,
38
- formData: reactive({}),
39
- subRuleData: reactive({}),
40
- subForm: {},
41
- form: reactive({}),
42
- appendData: {},
43
- ignoreFields: [],
44
- providers: {},
45
- cycleLoad: null,
46
- loadedId: 1,
47
- nextTick: null,
48
- changeStatus: false,
49
- pageEnd: true,
50
- nextReload: () => {
51
- this.lifecycle('reload');
52
- }
53
- });
54
-
55
- this.initData(fc.rules);
56
-
57
- this.$manager = new fc.manager(this);
58
- this.$render = new Render(this);
59
- this.api = fc.extendApiFn.reduce((api, fn) => {
60
- const extendApi = invoke(() => fn(api, this));
61
- if (extendApi && extendApi !== api) {
62
- extend(api, extendApi);
63
- }
64
- return api;
65
- }, Api(this));
66
- }
67
-
68
- extend(Handler.prototype, {
69
- initData(rules) {
70
- extend(this, {
71
- ctxs: {},
72
- fieldCtx: {},
73
- nameCtx: {},
74
- sort: [],
75
- rules,
76
- });
77
- },
78
- init() {
79
- this.updateAppendData();
80
- this.useProvider();
81
- this.usePage();
82
- this.loadRule();
83
- this.$manager.__init();
84
- this.lifecycle('created');
85
- },
86
- updateAppendData() {
87
- this.appendData = {...(this.options.formData || {}), ...(this.fc.vm.props.modelValue || {}), ...this.appendData};
88
- },
89
- isBreakWatch() {
90
- return this.loading || this.noWatchFn || this.reloading;
91
- },
92
- beforeFetch(opt) {
93
- return new Promise((resolve) => {
94
- const source = this.options.beforeFetch && invoke(() => this.options.beforeFetch(opt, {api: this.api}));
95
- if (source && is.Function(source.then)) {
96
- source.then(resolve);
97
- } else {
98
- resolve();
99
- }
100
- });
101
- },
102
- })
103
-
104
- useInject(Handler);
105
- usePage(Handler);
106
- useRender(Handler);
107
- useLoader(Handler);
108
- useInput(Handler);
109
- useContext(Handler);
110
- useLifecycle(Handler);
111
- useEffect(Handler);