@bdsoft/element 1.1.0
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.
- package/README.md +90 -0
- package/global/index.ts +6 -0
- package/global/register-properties.ts +10 -0
- package/index.html +13 -0
- package/index.js +84 -0
- package/package-form/core/components/formCreate.js +274 -0
- package/package-form/core/components/fragment.js +12 -0
- package/package-form/core/factory/context.js +257 -0
- package/package-form/core/factory/creator.js +63 -0
- package/package-form/core/factory/maker.js +17 -0
- package/package-form/core/factory/manager.js +79 -0
- package/package-form/core/factory/node.js +85 -0
- package/package-form/core/factory/parser.js +28 -0
- package/package-form/core/frame/api.js +599 -0
- package/package-form/core/frame/attrs.js +12 -0
- package/package-form/core/frame/dataDriver.js +76 -0
- package/package-form/core/frame/fetch.js +119 -0
- package/package-form/core/frame/formCreate.js +274 -0
- package/package-form/core/frame/index.js +760 -0
- package/package-form/core/frame/provider.js +288 -0
- package/package-form/core/frame/util.js +274 -0
- package/package-form/core/handler/context.js +380 -0
- package/package-form/core/handler/effect.js +122 -0
- package/package-form/core/handler/index.js +111 -0
- package/package-form/core/handler/inject.js +145 -0
- package/package-form/core/handler/input.js +197 -0
- package/package-form/core/handler/lifecycle.js +43 -0
- package/package-form/core/handler/loader.js +373 -0
- package/package-form/core/handler/page.js +46 -0
- package/package-form/core/handler/render.js +29 -0
- package/package-form/core/index.js +12 -0
- package/package-form/core/package.json +15 -0
- package/package-form/core/parser/html.js +17 -0
- package/package-form/core/render/cache.js +47 -0
- package/package-form/core/render/index.js +31 -0
- package/package-form/core/render/render.js +393 -0
- package/package-form/element-form/components/checkbox/package.json +17 -0
- package/package-form/element-form/components/checkbox/src/component.jsx +110 -0
- package/package-form/element-form/components/checkbox/src/index.js +3 -0
- package/package-form/element-form/components/frame/package.json +17 -0
- package/package-form/element-form/components/frame/src/IconCircleClose.vue +14 -0
- package/package-form/element-form/components/frame/src/IconDelete.vue +12 -0
- package/package-form/element-form/components/frame/src/IconDocument.vue +12 -0
- package/package-form/element-form/components/frame/src/IconFolderOpened.vue +12 -0
- package/package-form/element-form/components/frame/src/IconView.vue +12 -0
- package/package-form/element-form/components/frame/src/component.jsx +349 -0
- package/package-form/element-form/components/frame/src/index.js +3 -0
- package/package-form/element-form/components/frame/src/style.css +66 -0
- package/package-form/element-form/components/group/package.json +17 -0
- package/package-form/element-form/components/group/src/component.jsx +314 -0
- package/package-form/element-form/components/group/src/index.js +3 -0
- package/package-form/element-form/components/group/src/style.css +125 -0
- package/package-form/element-form/components/index.js +22 -0
- package/package-form/element-form/components/radio/package.json +17 -0
- package/package-form/element-form/components/radio/src/component.jsx +101 -0
- package/package-form/element-form/components/radio/src/index.js +3 -0
- package/package-form/element-form/components/select/package.json +17 -0
- package/package-form/element-form/components/select/src/component.jsx +52 -0
- package/package-form/element-form/components/select/src/index.js +3 -0
- package/package-form/element-form/components/subform/package.json +14 -0
- package/package-form/element-form/components/subform/src/component.jsx +76 -0
- package/package-form/element-form/components/subform/src/index.js +3 -0
- package/package-form/element-form/components/tree/package.json +17 -0
- package/package-form/element-form/components/tree/src/component.jsx +62 -0
- package/package-form/element-form/components/tree/src/index.js +3 -0
- package/package-form/element-form/components/upload/package.json +17 -0
- package/package-form/element-form/components/upload/src/IconUpload.vue +12 -0
- package/package-form/element-form/components/upload/src/component.jsx +129 -0
- package/package-form/element-form/components/upload/src/index.js +3 -0
- package/package-form/element-form/components/upload/src/style.css +11 -0
- package/package-form/element-form/index.js +8 -0
- package/package-form/element-form/package.json +16 -0
- package/package-form/element-form/src/components/icon/IconWarning.vue +12 -0
- package/package-form/element-form/src/components/index.js +22 -0
- package/package-form/element-form/src/core/alias.js +34 -0
- package/package-form/element-form/src/core/api.js +208 -0
- package/package-form/element-form/src/core/config.js +62 -0
- package/package-form/element-form/src/core/index.js +60 -0
- package/package-form/element-form/src/core/maker.js +76 -0
- package/package-form/element-form/src/core/manager.js +315 -0
- package/package-form/element-form/src/core/provider.js +79 -0
- package/package-form/element-form/src/parsers/datePicker.js +31 -0
- package/package-form/element-form/src/parsers/hidden.js +12 -0
- package/package-form/element-form/src/parsers/index.js +17 -0
- package/package-form/element-form/src/parsers/input.js +21 -0
- package/package-form/element-form/src/parsers/row.js +10 -0
- package/package-form/element-form/src/parsers/select.js +15 -0
- package/package-form/element-form/src/parsers/slider.js +21 -0
- package/package-form/element-form/src/parsers/timePicker.js +17 -0
- package/package-form/element-form/src/style/index.css +52 -0
- package/package.json +17 -0
- package/src/App.vue +28 -0
- package/src/assets/css/element.scss +179 -0
- package/src/assets/css/layout.scss +215 -0
- package/src/assets/css/tailwind.scss +67 -0
- package/src/assets/images/banner.gif +0 -0
- package/src/assets/images/banner.png +0 -0
- package/src/assets/images/bg1.svg +22 -0
- package/src/assets/images/bg2.png +0 -0
- package/src/assets/images/ff.png +0 -0
- package/src/assets/images/home-file1.png +0 -0
- package/src/assets/images/ky.png +0 -0
- package/src/assets/images/menu/add.png +0 -0
- package/src/assets/images/menu/del.png +0 -0
- package/src/assets/images/menu/down.png +0 -0
- package/src/assets/images/menu/dr.png +0 -0
- package/src/assets/images/menu/edit.png +0 -0
- package/src/assets/images/menu/kx.png +0 -0
- package/src/assets/images/menu/mb.png +0 -0
- package/src/assets/images/menu/pz.png +0 -0
- package/src/assets/images/menu/save.png +0 -0
- package/src/assets/images/menu/sj.png +0 -0
- package/src/assets/images/menu/sjk.png +0 -0
- package/src/assets/images/menu/up.png +0 -0
- package/src/assets/images/po-i.png +0 -0
- package/src/assets/images/po1-i1.png +0 -0
- package/src/assets/images/po1-i2.png +0 -0
- package/src/assets/images/po1-i3.png +0 -0
- package/src/assets/images/po1-i4.png +0 -0
- package/src/assets/images/po1-i5.png +0 -0
- package/src/assets/images/po1-i6.png +0 -0
- package/src/assets/images/po1-i7.png +0 -0
- package/src/assets/images/po1-i8.png +0 -0
- package/src/assets/images/po2-i1.png +0 -0
- package/src/assets/images/po2-i2.png +0 -0
- package/src/assets/images/po3-i1.png +0 -0
- package/src/assets/images/po4-i1.png +0 -0
- package/src/assets/images/po5-i1.png +0 -0
- package/src/assets/images/po6-i1.png +0 -0
- package/src/assets/images/po6-i2.png +0 -0
- package/src/assets/images/po7-i1.png +0 -0
- package/src/assets/images/tj1.png +0 -0
- package/src/assets/images/tj2.png +0 -0
- package/src/assets/images/tj3.png +0 -0
- package/src/components/3dcloudwords/index.js +346 -0
- package/src/components/3dcloudwords/index.vue +99 -0
- package/src/components/3dcloudwords/readme.md +66 -0
- package/src/components/badge/index.js +167 -0
- package/src/components/badge/index.scss +166 -0
- package/src/components/badge/index.vue +98 -0
- package/src/components/badge/readme.md +18 -0
- package/src/components/basic/Finish.vue +107 -0
- package/src/components/basic/button.vue +19 -0
- package/src/components/basic/readme.md +7 -0
- package/src/components/button/index.vue +48 -0
- package/src/components/button/readme.md +62 -0
- package/src/components/carousel/index.vue +104 -0
- package/src/components/carousel/readme.md +12 -0
- package/src/components/chartconfig/index.vue +141 -0
- package/src/components/chartconfig/readme.md +25 -0
- package/src/components/contextMenu/hookContxtMenu.js +41 -0
- package/src/components/contextMenu/index.vue +245 -0
- package/src/components/contextMenu/readme.md +55 -0
- package/src/components/contextMenu/useElementBounding.js +40 -0
- package/src/components/countup/countUp.js +196 -0
- package/src/components/countup/index.vue +112 -0
- package/src/components/countup/readme.md +9 -0
- package/src/components/empty/assets/build.png +0 -0
- package/src/components/empty/assets/emptybg.gif +0 -0
- package/src/components/empty/assets/emptybg.png +0 -0
- package/src/components/empty/assets/emptybg2.jpg +0 -0
- package/src/components/empty/assets/emptybg3.jpg +0 -0
- package/src/components/empty/assets/wuxiao.png +0 -0
- package/src/components/empty/assets/wuxiao.webp +0 -0
- package/src/components/empty/building.vue +117 -0
- package/src/components/empty/empty.vue +120 -0
- package/src/components/empty/index.js +12 -0
- package/src/components/empty/invalid.vue +56 -0
- package/src/components/error/Error.vue +79 -0
- package/src/components/error/readme.md +20 -0
- package/src/components/form/Form.vue +84 -0
- package/src/components/form/FormItem.vue +143 -0
- package/src/components/form/data.js +52 -0
- package/src/components/form/readme.md +69 -0
- package/src/components/layout/banner.vue +412 -0
- package/src/components/layout/bar.vue +43 -0
- package/src/components/layout/layout1.vue +60 -0
- package/src/components/layout/layout2.vue +134 -0
- package/src/components/layout/layout3.vue +107 -0
- package/src/components/layout/layout4.vue +66 -0
- package/src/components/layout/nav.vue +333 -0
- package/src/components/layout/readme.md +61 -0
- package/src/components/loading/index.vue +122 -0
- package/src/components/loading/readme.md +6 -0
- package/src/components/notice/NoticeList.vue +198 -0
- package/src/components/notice/NoticeListPaging.vue +281 -0
- package/src/components/notice/NoticeView.vue +92 -0
- package/src/components/notice/readme.md +1 -0
- package/src/components/pagination/index.vue +100 -0
- package/src/components/pagination/readme.md +19 -0
- package/src/components/pagination/scroll-to.js +51 -0
- package/src/components/progress/bar.vue +72 -0
- package/src/components/progress/progress.vue +58 -0
- package/src/components/screenfull/index.js +3 -0
- package/src/components/screenfull/index.vue +65 -0
- package/src/components/screenfull/package.json +15 -0
- package/src/components/screenfull/readme.md +6 -0
- package/src/components/statisticalCount/index.vue +80 -0
- package/src/components/statisticalCount/readme.md +21 -0
- package/src/components/username/index.vue +79 -0
- package/src/components/username/readme.md +22 -0
- package/src/components/username//346/225/210/346/236/234/345/233/276.png +0 -0
- package/src/index.js +82 -0
- package/src/utils/index.js +32 -0
- package/src/xm_components/HeadSearch/hook/hookSearch.js +96 -0
- package/src/xm_components/HeadSearch/index.vue +206 -0
- package/src/xm_components/HeadSearch/readme.md +12 -0
- package/src/xm_components/HeadSearch//346/220/234/347/264/242/345/210/227/350/241/250.png +0 -0
- package/src/xm_components/Milestone/index.vue +212 -0
- package/src/xm_components/Milestone/readme.md +15 -0
- package/src/xm_components/readme.md +1 -0
- package/utils/coms/load.jsx +10 -0
- package/utils/func.js +32 -0
- package/utils/hookDialog.js +38 -0
- package/utils/hookPage.js +49 -0
- package/utils/index.js +5 -0
- package/utils/lib/console.js +39 -0
- package/utils/lib/debounce.js +19 -0
- package/utils/lib/deepextend.js +51 -0
- package/utils/lib/deepset.js +14 -0
- package/utils/lib/extend.js +28 -0
- package/utils/lib/index.js +13 -0
- package/utils/lib/json.js +90 -0
- package/utils/lib/mergeprops.js +62 -0
- package/utils/lib/mitt.js +43 -0
- package/utils/lib/modify.js +8 -0
- package/utils/lib/slot.js +19 -0
- package/utils/lib/toarray.js +5 -0
- package/utils/lib/tocase.js +11 -0
- package/utils/lib/todate.js +10 -0
- package/utils/lib/toline.js +10 -0
- package/utils/lib/tostring.js +7 -0
- package/utils/lib/type.js +45 -0
- package/utils/lib/unique.js +6 -0
- package/utils/message.js +166 -0
- package/utils/package.json +16 -0
- package/utils/type.js +45 -0
- package/vite.config.js +51 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import extend from '@bdsoft-element/utils/lib/extend';
|
|
2
|
+
import is from '@bdsoft-element/utils/lib/type';
|
|
3
|
+
import toLine from '@bdsoft-element/utils/lib/toline';
|
|
4
|
+
import {extractVar, parseFn} from '../frame/util';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default function useInject(Handler) {
|
|
8
|
+
extend(Handler.prototype, {
|
|
9
|
+
parseInjectEvent(rule, on) {
|
|
10
|
+
const inject = rule.inject || this.options.injectEvent;
|
|
11
|
+
return this.parseEventLst(rule, on, inject);
|
|
12
|
+
},
|
|
13
|
+
parseEventLst(rule, data, inject, deep) {
|
|
14
|
+
Object.keys(data).forEach(k => {
|
|
15
|
+
const fn = this.parseEvent(rule, data[k], inject, deep);
|
|
16
|
+
if (fn) {
|
|
17
|
+
data[k] = fn;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return data;
|
|
21
|
+
},
|
|
22
|
+
parseEvent(rule, fn, inject, deep) {
|
|
23
|
+
if (is.Function(fn) && ((inject !== false && !is.Undef(inject)) || fn.__inject)) {
|
|
24
|
+
return this.inject(rule, fn, inject)
|
|
25
|
+
} else if (!deep && Array.isArray(fn) && fn[0] && (is.String(fn[0]) || is.Function(fn[0]))) {
|
|
26
|
+
return this.parseEventLst(rule, fn, inject, true);
|
|
27
|
+
} else if (is.String(fn)) {
|
|
28
|
+
const val = parseFn(fn);
|
|
29
|
+
if (val && fn !== val) {
|
|
30
|
+
return val.__inject ? this.parseEvent(rule, val, inject, true) : val;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
parseEmit(ctx) {
|
|
35
|
+
let event = {}, rule = ctx.rule, {emitPrefix, field, name, inject} = rule;
|
|
36
|
+
let emit = rule.emit || [];
|
|
37
|
+
if (is.trueArray(emit)) {
|
|
38
|
+
emit.forEach(eventName => {
|
|
39
|
+
if (!eventName) return;
|
|
40
|
+
let eventInject;
|
|
41
|
+
let emitKey = emitPrefix || field || name;
|
|
42
|
+
if (is.Object(eventName)) {
|
|
43
|
+
eventInject = eventName.inject;
|
|
44
|
+
eventName = eventName.name;
|
|
45
|
+
emitKey = eventName.prefix || emitKey;
|
|
46
|
+
}
|
|
47
|
+
if (emitKey) {
|
|
48
|
+
const fieldKey = toLine(`${emitKey}-${eventName}`);
|
|
49
|
+
const fn = (...arg) => {
|
|
50
|
+
if (this.vm.emitsOptions) {
|
|
51
|
+
this.vm.emitsOptions[fieldKey] = null;
|
|
52
|
+
}
|
|
53
|
+
this.vm.emit(fieldKey, ...arg);
|
|
54
|
+
this.vm.emit('emit-event', fieldKey, ...arg);
|
|
55
|
+
this.bus.$emit(fieldKey, ...arg);
|
|
56
|
+
};
|
|
57
|
+
fn.__emit = true;
|
|
58
|
+
|
|
59
|
+
if (!eventInject && inject === false) {
|
|
60
|
+
event[eventName] = fn;
|
|
61
|
+
} else {
|
|
62
|
+
let _inject = eventInject || inject || this.options.injectEvent;
|
|
63
|
+
event[eventName] = is.Undef(_inject) ? fn : this.inject(rule, fn, _inject);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
ctx.computed.on = event;
|
|
70
|
+
return event;
|
|
71
|
+
},
|
|
72
|
+
getInjectData(self, inject) {
|
|
73
|
+
const $api = self.__fc__ && self.__fc__.$api;
|
|
74
|
+
const vm = (self.__fc__ && self.__fc__.$handle.vm) || this.vm;
|
|
75
|
+
const {option, rule} = vm.props;
|
|
76
|
+
return {
|
|
77
|
+
$f: $api || this.api,
|
|
78
|
+
api: $api || this.api,
|
|
79
|
+
rule,
|
|
80
|
+
self: self.__origin__,
|
|
81
|
+
option,
|
|
82
|
+
inject
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
inject(self, _fn, inject) {
|
|
86
|
+
if (_fn.__origin) {
|
|
87
|
+
if (this.watching && !this.loading)
|
|
88
|
+
return _fn;
|
|
89
|
+
_fn = _fn.__origin;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const h = this;
|
|
93
|
+
|
|
94
|
+
const fn = function (...args) {
|
|
95
|
+
const data = h.getInjectData(self, inject);
|
|
96
|
+
data.args = [...args];
|
|
97
|
+
args.unshift(data);
|
|
98
|
+
return _fn.apply(this, args);
|
|
99
|
+
};
|
|
100
|
+
fn.__origin = _fn;
|
|
101
|
+
fn.__json = _fn.__json;
|
|
102
|
+
return fn;
|
|
103
|
+
},
|
|
104
|
+
loadStrVar(str, get) {
|
|
105
|
+
if (str && typeof str === 'string' && str.indexOf('{{') > -1 && str.indexOf('}}') > -1) {
|
|
106
|
+
const tmp = str;
|
|
107
|
+
const vars = extractVar(str);
|
|
108
|
+
let lastVal;
|
|
109
|
+
vars.forEach(v => {
|
|
110
|
+
const split = v.split('||');
|
|
111
|
+
const field = split[0].trim();
|
|
112
|
+
if (field) {
|
|
113
|
+
const def = (split[1] || '').trim();
|
|
114
|
+
const val = get ? get(field, def) : this.fc.getLoadData(field, def);
|
|
115
|
+
lastVal = val;
|
|
116
|
+
str = str.replaceAll(`{{${v}}}`, val == null ? '' : val);
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
if (vars.length === 1 && tmp === `{{${vars[0]}}}`) {
|
|
120
|
+
return lastVal;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return str;
|
|
124
|
+
},
|
|
125
|
+
loadFetchVar(options, get) {
|
|
126
|
+
const loadVal = str => {
|
|
127
|
+
return this.loadStrVar(str, get);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
options.action = loadVal(options.action || '');
|
|
131
|
+
|
|
132
|
+
['headers', 'data', 'query'].forEach(key => {
|
|
133
|
+
if (options[key]) {
|
|
134
|
+
const data = {};
|
|
135
|
+
Object.keys(options[key]).forEach(k => {
|
|
136
|
+
data[loadVal(k)] = loadVal(options[key][k]);
|
|
137
|
+
});
|
|
138
|
+
options[key] = data;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return options;
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import extend from '@bdsoft-element/utils/lib/extend';
|
|
2
|
+
import {$set} from '@bdsoft-element/utils/lib/modify';
|
|
3
|
+
import is, {hasProperty} from '@bdsoft-element/utils/lib/type';
|
|
4
|
+
import {invoke} from '../frame/util';
|
|
5
|
+
import {nextTick, reactive, toRef} from 'vue';
|
|
6
|
+
|
|
7
|
+
export default function useInput(Handler) {
|
|
8
|
+
extend(Handler.prototype, {
|
|
9
|
+
setValue(ctx, value, formValue, setFlag) {
|
|
10
|
+
if (ctx.deleted) return;
|
|
11
|
+
ctx.rule.value = value;
|
|
12
|
+
this.changeStatus = true;
|
|
13
|
+
this.nextRefresh();
|
|
14
|
+
this.$render.clearCache(ctx);
|
|
15
|
+
this.setFormData(ctx, formValue);
|
|
16
|
+
this.syncValue();
|
|
17
|
+
this.valueChange(ctx, value);
|
|
18
|
+
this.vm.emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
|
|
19
|
+
this.effect(ctx, 'value');
|
|
20
|
+
this.targetHook(ctx, 'value', {value});
|
|
21
|
+
this.emitEvent('change', ctx.field, value, {
|
|
22
|
+
rule: ctx.origin,
|
|
23
|
+
api: this.api,
|
|
24
|
+
setFlag: setFlag || false
|
|
25
|
+
})
|
|
26
|
+
if (setFlag) {
|
|
27
|
+
nextTick(() => {
|
|
28
|
+
nextTick(() => {
|
|
29
|
+
nextTick(() => {
|
|
30
|
+
this.api.clearValidateState(ctx.id);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
onInput(ctx, value) {
|
|
37
|
+
let val;
|
|
38
|
+
if (ctx.input && (this.isQuote(ctx, val = ctx.parser.toValue(value, ctx)) || this.isChange(ctx, value))) {
|
|
39
|
+
this.setValue(ctx, val, value);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
onUpdateValue(ctx, data) {
|
|
43
|
+
this.deferSyncValue(() => {
|
|
44
|
+
const group = ctx.getParentGroup();
|
|
45
|
+
const subForm = group ? this.subRuleData[group.id] : null;
|
|
46
|
+
const subData = {};
|
|
47
|
+
Object.keys(data || {}).forEach(k => {
|
|
48
|
+
if (subForm && hasProperty(subForm, k)) {
|
|
49
|
+
subData[k] = data[k];
|
|
50
|
+
} else if (hasProperty(this.api.form, k)) {
|
|
51
|
+
this.api.form[k] = data[k];
|
|
52
|
+
} else if (this.api.top !== this.api && hasProperty(this.api.top.form, k)) {
|
|
53
|
+
this.api.top.form[k] = data[k];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (Object.keys(subData).length) {
|
|
57
|
+
this.api.setChildrenFormData(group.rule, subData);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
},
|
|
61
|
+
onBaseInput(ctx, value) {
|
|
62
|
+
this.setFormData(ctx, value);
|
|
63
|
+
ctx.modelValue = value;
|
|
64
|
+
this.nextRefresh();
|
|
65
|
+
this.$render.clearCache(ctx);
|
|
66
|
+
},
|
|
67
|
+
setFormData(ctx, value) {
|
|
68
|
+
ctx.modelValue = value;
|
|
69
|
+
const group = ctx.getParentGroup();
|
|
70
|
+
if (group) {
|
|
71
|
+
if (!this.subRuleData[group.id]) {
|
|
72
|
+
this.subRuleData[group.id] = {};
|
|
73
|
+
}
|
|
74
|
+
this.subRuleData[group.id][ctx.field] = ctx.rule.value;
|
|
75
|
+
}
|
|
76
|
+
$set(this.formData, ctx.id, value);
|
|
77
|
+
},
|
|
78
|
+
rmSubRuleData(ctx) {
|
|
79
|
+
const group = ctx.getParentGroup();
|
|
80
|
+
if (group && this.subRuleData[group.id]) {
|
|
81
|
+
delete this.subRuleData[group.id][ctx.field];
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
getFormData(ctx) {
|
|
85
|
+
return this.formData[ctx.id];
|
|
86
|
+
},
|
|
87
|
+
syncForm() {
|
|
88
|
+
const data = reactive({});
|
|
89
|
+
const fields = this.fields();
|
|
90
|
+
const ignoreFields = [];
|
|
91
|
+
if (this.options.appendValue !== false) {
|
|
92
|
+
Object.keys(this.appendData).reduce((initial, field) => {
|
|
93
|
+
if (fields.indexOf(field) === -1) {
|
|
94
|
+
initial[field] = toRef(this.appendData, field);
|
|
95
|
+
}
|
|
96
|
+
return initial;
|
|
97
|
+
}, data);
|
|
98
|
+
}
|
|
99
|
+
fields.reduce((initial, field) => {
|
|
100
|
+
const ctx = (this.fieldCtx[field] || []).filter(ctx => !this.isIgnore(ctx.rule))[0] || (this.fieldCtx[field][0]);
|
|
101
|
+
if (this.isIgnore(ctx.rule)) {
|
|
102
|
+
ignoreFields.push(field);
|
|
103
|
+
}
|
|
104
|
+
initial[field] = toRef(ctx.rule, 'value');
|
|
105
|
+
return initial;
|
|
106
|
+
}, data);
|
|
107
|
+
this.form = data;
|
|
108
|
+
this.ignoreFields = ignoreFields;
|
|
109
|
+
this.syncValue();
|
|
110
|
+
},
|
|
111
|
+
isIgnore(rule) {
|
|
112
|
+
return rule.ignore === true || (rule.ignore === 'hidden' && rule.hidden) || (this.options.ignoreHiddenFields && rule.hidden);
|
|
113
|
+
},
|
|
114
|
+
appendValue(rule) {
|
|
115
|
+
if ((!rule.field || !hasProperty(this.appendData, rule.field)) && !this.options.forceCoverValue) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
rule.value = this.appendData[rule.field];
|
|
119
|
+
delete this.appendData[rule.field];
|
|
120
|
+
},
|
|
121
|
+
addSubForm(ctx, subForm) {
|
|
122
|
+
this.subForm[ctx.id] = subForm;
|
|
123
|
+
},
|
|
124
|
+
deferSyncValue(fn, sync) {
|
|
125
|
+
if (!this.deferSyncFn) {
|
|
126
|
+
this.deferSyncFn = fn;
|
|
127
|
+
}
|
|
128
|
+
if (!this.deferSyncFn.sync) {
|
|
129
|
+
this.deferSyncFn.sync = sync;
|
|
130
|
+
}
|
|
131
|
+
invoke(fn);
|
|
132
|
+
if (this.deferSyncFn === fn) {
|
|
133
|
+
this.deferSyncFn = null;
|
|
134
|
+
if (fn.sync) {
|
|
135
|
+
this.syncForm();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
syncValue() {
|
|
140
|
+
if (this.deferSyncFn) {
|
|
141
|
+
return this.deferSyncFn.sync = true;
|
|
142
|
+
}
|
|
143
|
+
const data = {};
|
|
144
|
+
Object.keys(this.form).forEach(k => {
|
|
145
|
+
if (this.ignoreFields.indexOf(k) === -1) {
|
|
146
|
+
data[k] = this.form[k];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
this.vm.setupState.updateValue(data);
|
|
150
|
+
},
|
|
151
|
+
isChange(ctx, value) {
|
|
152
|
+
return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
|
|
153
|
+
},
|
|
154
|
+
isQuote(ctx, value) {
|
|
155
|
+
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
156
|
+
},
|
|
157
|
+
refreshUpdate(ctx, val, origin, field) {
|
|
158
|
+
if (is.Function(ctx.rule.update)) {
|
|
159
|
+
const state = invoke(() => ctx.rule.update(val, ctx.origin, this.api, {
|
|
160
|
+
origin: origin || 'change',
|
|
161
|
+
linkField: field
|
|
162
|
+
}));
|
|
163
|
+
if (state === undefined) return;
|
|
164
|
+
ctx.rule.hidden = state === true;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
valueChange(ctx, val) {
|
|
168
|
+
this.refreshRule(ctx, val);
|
|
169
|
+
this.bus.$emit('change-' + ctx.field, val);
|
|
170
|
+
},
|
|
171
|
+
refreshRule(ctx, val, origin, field) {
|
|
172
|
+
if (this.refreshControl(ctx)) {
|
|
173
|
+
this.$render.clearCacheAll();
|
|
174
|
+
this.loadRule();
|
|
175
|
+
this.bus.$emit('update', this.api);
|
|
176
|
+
this.refresh();
|
|
177
|
+
}
|
|
178
|
+
this.refreshUpdate(ctx, val, origin, field);
|
|
179
|
+
},
|
|
180
|
+
appendLink(ctx) {
|
|
181
|
+
const link = ctx.rule.link;
|
|
182
|
+
is.trueArray(link) && link.forEach(field => {
|
|
183
|
+
const fn = () => this.refreshRule(ctx, ctx.rule.value, 'link', field);
|
|
184
|
+
|
|
185
|
+
this.bus.$on('change-' + field, fn);
|
|
186
|
+
ctx.linkOn.push(() => this.bus.$off('change-' + field, fn));
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
fields() {
|
|
190
|
+
return Object.keys(this.fieldCtx);
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function strFn(key, val) {
|
|
196
|
+
return typeof val === 'function' ? '' + val : val;
|
|
197
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import extend from '@bdsoft-element/utils/lib/extend';
|
|
2
|
+
import is from '@bdsoft-element/utils/lib/type';
|
|
3
|
+
import {invoke, parseFn} from '../frame/util';
|
|
4
|
+
import toCase from '@bdsoft-element/utils/lib/tocase';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default function useLifecycle(Handler) {
|
|
8
|
+
extend(Handler.prototype, {
|
|
9
|
+
mounted() {
|
|
10
|
+
const _mounted = () => {
|
|
11
|
+
this.isMounted = true;
|
|
12
|
+
this.lifecycle('mounted');
|
|
13
|
+
}
|
|
14
|
+
if (this.pageEnd) {
|
|
15
|
+
_mounted();
|
|
16
|
+
} else {
|
|
17
|
+
this.bus.$once('page-end', _mounted);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
lifecycle(name) {
|
|
21
|
+
this.fc.targetFormDriver(name, this.api, this.fc);
|
|
22
|
+
this.vm.emit(name, this.api);
|
|
23
|
+
this.emitEvent(name, this.api);
|
|
24
|
+
},
|
|
25
|
+
emitEvent(name, ...args) {
|
|
26
|
+
const _fn = this.options[name] || this.options[toCase('on-' + name)];
|
|
27
|
+
if (_fn) {
|
|
28
|
+
const fn = parseFn(_fn);
|
|
29
|
+
is.Function(fn) && invoke(() => fn(...args));
|
|
30
|
+
}
|
|
31
|
+
this.bus.$emit(name, ...args);
|
|
32
|
+
},
|
|
33
|
+
targetHook(ctx, name, args) {
|
|
34
|
+
let hook = ctx.prop?.hook?.[name];
|
|
35
|
+
if (hook) {
|
|
36
|
+
hook = Array.isArray(hook) ? hook : [hook];
|
|
37
|
+
hook.forEach(fn => {
|
|
38
|
+
invoke(() => fn({...args || {}, rule: ctx.rule, api: this.api}));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|