@bdsoft/element 1.1.9 → 1.1.11
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/dist/BdElement.js +23111 -0
- package/package.json +2 -1
- package/global/index.ts +0 -6
- package/global/register-properties.ts +0 -10
- package/index.html +0 -13
- package/package-form/core/components/formCreate.js +0 -274
- package/package-form/core/components/fragment.js +0 -12
- package/package-form/core/factory/context.js +0 -257
- package/package-form/core/factory/creator.js +0 -63
- package/package-form/core/factory/maker.js +0 -17
- package/package-form/core/factory/manager.js +0 -79
- package/package-form/core/factory/node.js +0 -85
- package/package-form/core/factory/parser.js +0 -28
- package/package-form/core/frame/api.js +0 -599
- package/package-form/core/frame/attrs.js +0 -12
- package/package-form/core/frame/dataDriver.js +0 -76
- package/package-form/core/frame/fetch.js +0 -119
- package/package-form/core/frame/formCreate.js +0 -274
- package/package-form/core/frame/index.js +0 -760
- package/package-form/core/frame/provider.js +0 -288
- package/package-form/core/frame/util.js +0 -274
- package/package-form/core/handler/context.js +0 -380
- package/package-form/core/handler/effect.js +0 -122
- package/package-form/core/handler/index.js +0 -111
- package/package-form/core/handler/inject.js +0 -145
- package/package-form/core/handler/input.js +0 -197
- package/package-form/core/handler/lifecycle.js +0 -43
- package/package-form/core/handler/loader.js +0 -373
- package/package-form/core/handler/page.js +0 -46
- package/package-form/core/handler/render.js +0 -29
- package/package-form/core/index.js +0 -12
- package/package-form/core/package.json +0 -15
- package/package-form/core/parser/html.js +0 -17
- package/package-form/core/render/cache.js +0 -47
- package/package-form/core/render/index.js +0 -31
- package/package-form/core/render/render.js +0 -393
- package/package-form/element-form/components/checkbox/package.json +0 -17
- package/package-form/element-form/components/checkbox/src/component.jsx +0 -110
- package/package-form/element-form/components/checkbox/src/index.js +0 -3
- package/package-form/element-form/components/frame/package.json +0 -17
- package/package-form/element-form/components/frame/src/IconCircleClose.vue +0 -14
- package/package-form/element-form/components/frame/src/IconDelete.vue +0 -12
- package/package-form/element-form/components/frame/src/IconDocument.vue +0 -12
- package/package-form/element-form/components/frame/src/IconFolderOpened.vue +0 -12
- package/package-form/element-form/components/frame/src/IconView.vue +0 -12
- package/package-form/element-form/components/frame/src/component.jsx +0 -349
- package/package-form/element-form/components/frame/src/index.js +0 -3
- package/package-form/element-form/components/frame/src/style.css +0 -66
- package/package-form/element-form/components/group/package.json +0 -17
- package/package-form/element-form/components/group/src/component.jsx +0 -314
- package/package-form/element-form/components/group/src/index.js +0 -3
- package/package-form/element-form/components/group/src/style.css +0 -125
- package/package-form/element-form/components/index.js +0 -22
- package/package-form/element-form/components/radio/package.json +0 -17
- package/package-form/element-form/components/radio/src/component.jsx +0 -101
- package/package-form/element-form/components/radio/src/index.js +0 -3
- package/package-form/element-form/components/select/package.json +0 -17
- package/package-form/element-form/components/select/src/component.jsx +0 -52
- package/package-form/element-form/components/select/src/index.js +0 -3
- package/package-form/element-form/components/subform/package.json +0 -14
- package/package-form/element-form/components/subform/src/component.jsx +0 -76
- package/package-form/element-form/components/subform/src/index.js +0 -3
- package/package-form/element-form/components/tree/package.json +0 -17
- package/package-form/element-form/components/tree/src/component.jsx +0 -62
- package/package-form/element-form/components/tree/src/index.js +0 -3
- package/package-form/element-form/components/upload/package.json +0 -17
- package/package-form/element-form/components/upload/src/IconUpload.vue +0 -12
- package/package-form/element-form/components/upload/src/component.jsx +0 -129
- package/package-form/element-form/components/upload/src/index.js +0 -3
- package/package-form/element-form/components/upload/src/style.css +0 -11
- package/package-form/element-form/index.js +0 -8
- package/package-form/element-form/package.json +0 -16
- package/package-form/element-form/src/components/icon/IconWarning.vue +0 -12
- package/package-form/element-form/src/components/index.js +0 -22
- package/package-form/element-form/src/core/alias.js +0 -34
- package/package-form/element-form/src/core/api.js +0 -208
- package/package-form/element-form/src/core/config.js +0 -62
- package/package-form/element-form/src/core/index.js +0 -60
- package/package-form/element-form/src/core/maker.js +0 -76
- package/package-form/element-form/src/core/manager.js +0 -315
- package/package-form/element-form/src/core/provider.js +0 -79
- package/package-form/element-form/src/parsers/datePicker.js +0 -31
- package/package-form/element-form/src/parsers/hidden.js +0 -12
- package/package-form/element-form/src/parsers/index.js +0 -17
- package/package-form/element-form/src/parsers/input.js +0 -21
- package/package-form/element-form/src/parsers/row.js +0 -10
- package/package-form/element-form/src/parsers/select.js +0 -15
- package/package-form/element-form/src/parsers/slider.js +0 -21
- package/package-form/element-form/src/parsers/timePicker.js +0 -17
- package/package-form/element-form/src/style/index.css +0 -52
- package/src/App.vue +0 -28
- package/src/assets/css/element.scss +0 -196
- package/src/assets/css/layout.scss +0 -215
- package/src/assets/css/tailwind.scss +0 -67
- package/src/assets/images/banner.gif +0 -0
- package/src/assets/images/banner.png +0 -0
- package/src/assets/images/bg1.svg +0 -22
- 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 +0 -346
- package/src/components/3dcloudwords/index.vue +0 -99
- package/src/components/3dcloudwords/readme.md +0 -66
- package/src/components/badge/index.js +0 -167
- package/src/components/badge/index.scss +0 -166
- package/src/components/badge/index.vue +0 -98
- package/src/components/badge/readme.md +0 -18
- package/src/components/basic/Finish.vue +0 -107
- package/src/components/basic/button.vue +0 -19
- package/src/components/basic/readme.md +0 -7
- package/src/components/button/index.vue +0 -48
- package/src/components/button/readme.md +0 -62
- package/src/components/carousel/index.vue +0 -104
- package/src/components/carousel/readme.md +0 -12
- package/src/components/chartconfig/index.vue +0 -141
- package/src/components/chartconfig/readme.md +0 -25
- package/src/components/contextMenu/hookContxtMenu.js +0 -41
- package/src/components/contextMenu/index.vue +0 -245
- package/src/components/contextMenu/readme.md +0 -55
- package/src/components/contextMenu/useElementBounding.js +0 -40
- package/src/components/countup/countUp.js +0 -196
- package/src/components/countup/index.vue +0 -114
- package/src/components/countup/readme.md +0 -9
- 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 +0 -117
- package/src/components/empty/empty.vue +0 -120
- package/src/components/empty/index.js +0 -12
- package/src/components/empty/invalid.vue +0 -56
- package/src/components/error/Error.vue +0 -79
- package/src/components/error/readme.md +0 -20
- package/src/components/form/Form.vue +0 -84
- package/src/components/form/FormItem.vue +0 -143
- package/src/components/form/data.js +0 -52
- package/src/components/form/readme.md +0 -69
- package/src/components/layout/banner.vue +0 -412
- package/src/components/layout/bar.vue +0 -43
- package/src/components/layout/layout1.vue +0 -60
- package/src/components/layout/layout2.vue +0 -134
- package/src/components/layout/layout3.vue +0 -107
- package/src/components/layout/layout4.vue +0 -66
- package/src/components/layout/nav.vue +0 -333
- package/src/components/layout/readme.md +0 -61
- package/src/components/loading/index.vue +0 -122
- package/src/components/loading/readme.md +0 -6
- package/src/components/notice/NoticeList.vue +0 -198
- package/src/components/notice/NoticeListPaging.vue +0 -281
- package/src/components/notice/NoticeView.vue +0 -92
- package/src/components/notice/readme.md +0 -1
- package/src/components/pagination/index.vue +0 -100
- package/src/components/pagination/readme.md +0 -19
- package/src/components/pagination/scroll-to.js +0 -51
- package/src/components/progress/bar.vue +0 -72
- package/src/components/progress/progress.vue +0 -58
- package/src/components/screenfull/index.js +0 -3
- package/src/components/screenfull/index.vue +0 -65
- package/src/components/screenfull/package.json +0 -15
- package/src/components/screenfull/readme.md +0 -6
- package/src/components/statisticalCount/index.vue +0 -80
- package/src/components/statisticalCount/readme.md +0 -21
- package/src/components/username/index.vue +0 -79
- package/src/components/username/readme.md +0 -22
- package/src/components/username//346/225/210/346/236/234/345/233/276.png +0 -0
- package/src/index.js +0 -88
- package/src/utils/index.js +0 -32
- package/src/xm_components/HeadSearch/hook/hookSearch.js +0 -96
- package/src/xm_components/HeadSearch/index.vue +0 -206
- package/src/xm_components/HeadSearch/readme.md +0 -12
- 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 +0 -213
- package/src/xm_components/Milestone/readme.md +0 -15
- package/src/xm_components/MultiStatisticalCard/image.png +0 -0
- package/src/xm_components/MultiStatisticalCard/index.vue +0 -114
- package/src/xm_components/MultiStatisticalCard/readme.md +0 -29
- package/src/xm_components/StatisticalCard/image.png +0 -0
- package/src/xm_components/StatisticalCard/index.vue +0 -196
- package/src/xm_components/StatisticalCard/readme.md +0 -41
- package/src/xm_components/readme.md +0 -1
- package/utils/coms/load.jsx +0 -10
- package/utils/func.js +0 -32
- package/utils/hookDialog.js +0 -38
- package/utils/hookPage.js +0 -49
- package/utils/index.js +0 -5
- package/utils/lib/console.js +0 -39
- package/utils/lib/debounce.js +0 -19
- package/utils/lib/deepextend.js +0 -51
- package/utils/lib/deepset.js +0 -14
- package/utils/lib/extend.js +0 -28
- package/utils/lib/index.js +0 -13
- package/utils/lib/json.js +0 -90
- package/utils/lib/mergeprops.js +0 -62
- package/utils/lib/mitt.js +0 -43
- package/utils/lib/modify.js +0 -8
- package/utils/lib/slot.js +0 -19
- package/utils/lib/toarray.js +0 -5
- package/utils/lib/tocase.js +0 -11
- package/utils/lib/todate.js +0 -10
- package/utils/lib/toline.js +0 -10
- package/utils/lib/tostring.js +0 -7
- package/utils/lib/type.js +0 -45
- package/utils/lib/unique.js +0 -6
- package/utils/message.js +0 -164
- package/utils/package.json +0 -16
- package/utils/type.js +0 -45
- package/vite.config.js +0 -56
|
@@ -1,145 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}
|