@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,119 @@
|
|
|
1
|
+
// https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
|
|
2
|
+
|
|
3
|
+
import is from '@bdsoft-element/utils/lib/type';
|
|
4
|
+
import {parseFn} from '@bdsoft-element/utils/lib/json';
|
|
5
|
+
import {deepGet} from './util';
|
|
6
|
+
|
|
7
|
+
function getError(action, option, xhr) {
|
|
8
|
+
const msg = `fail to ${action} ${xhr.status}'`;
|
|
9
|
+
const err = new Error(msg);
|
|
10
|
+
err.status = xhr.status;
|
|
11
|
+
err.url = action;
|
|
12
|
+
return err;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getBody(xhr) {
|
|
16
|
+
const text = xhr.responseText || xhr.response;
|
|
17
|
+
if (!text) {
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(text);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function fetch(option) {
|
|
29
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const xhr = new XMLHttpRequest();
|
|
34
|
+
let action = option.action || '';
|
|
35
|
+
|
|
36
|
+
if (xhr.upload && option.onProgress) {
|
|
37
|
+
xhr.upload.addEventListener('progress', (evt) => {
|
|
38
|
+
evt.percent = evt.total > 0 ? (evt.loaded / evt.total) * 100 : 0
|
|
39
|
+
option.onProgress(evt)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (option.query) {
|
|
44
|
+
const queryString = new URLSearchParams(option.query).toString();
|
|
45
|
+
if (action.includes('?')) {
|
|
46
|
+
action += `&${queryString}`;
|
|
47
|
+
} else {
|
|
48
|
+
action += `?${queryString}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
xhr.onerror = function error(e) {
|
|
53
|
+
option.onError(e);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
xhr.onload = function onload() {
|
|
57
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
58
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
option.onSuccess(getBody(xhr));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
xhr.open(option.method || 'get', action, true);
|
|
65
|
+
|
|
66
|
+
let formData;
|
|
67
|
+
if (option.data || option.file) {
|
|
68
|
+
if (option.file || (option.dataType || '').toLowerCase() !== 'json') {
|
|
69
|
+
formData = new FormData();
|
|
70
|
+
Object.keys(option.data || {}).map(key => {
|
|
71
|
+
formData.append(key, option.data[key]);
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
formData = JSON.stringify(option.data || {});
|
|
75
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if(option.file){
|
|
80
|
+
formData.append(option.filename, option.file, option.file.name)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
84
|
+
xhr.withCredentials = true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const headers = option.headers || {};
|
|
88
|
+
|
|
89
|
+
Object.keys(headers).forEach(item => {
|
|
90
|
+
if (headers[item] != null) {
|
|
91
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
xhr.send(formData);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
export function asyncFetch(config, _fetch, api) {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
(_fetch || fetch)({
|
|
101
|
+
...config,
|
|
102
|
+
onSuccess(res) {
|
|
103
|
+
let fn = (v) => v;
|
|
104
|
+
const parse = parseFn(config.parse);
|
|
105
|
+
if (is.Function(parse)) {
|
|
106
|
+
fn = parse;
|
|
107
|
+
} else if (parse && is.String(parse)) {
|
|
108
|
+
fn = (v) => {
|
|
109
|
+
return deepGet(v, parse);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
resolve(fn(res, undefined, api));
|
|
113
|
+
},
|
|
114
|
+
onError(err) {
|
|
115
|
+
reject(err);
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
getCurrentInstance,
|
|
4
|
+
inject,
|
|
5
|
+
markRaw,
|
|
6
|
+
nextTick,
|
|
7
|
+
onBeforeMount,
|
|
8
|
+
onBeforeUnmount,
|
|
9
|
+
onMounted,
|
|
10
|
+
onUpdated,
|
|
11
|
+
provide,
|
|
12
|
+
reactive,
|
|
13
|
+
toRefs,
|
|
14
|
+
watch, watchEffect
|
|
15
|
+
} from 'vue';
|
|
16
|
+
import toArray from '@bdsoft-element/utils/lib/toarray';
|
|
17
|
+
import debounce from '@bdsoft-element/utils/lib/debounce';
|
|
18
|
+
import toLine from '@bdsoft-element/utils/lib/toline';
|
|
19
|
+
|
|
20
|
+
const getGroupInject = (vm, parent) => {
|
|
21
|
+
if (!vm || vm === parent) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (vm.props.formCreateInject) {
|
|
25
|
+
return vm.props.formCreateInject
|
|
26
|
+
}
|
|
27
|
+
if (vm.parent) {
|
|
28
|
+
return getGroupInject(vm.parent, parent);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default function $FormCreate(FormCreate, components, directives) {
|
|
33
|
+
return defineComponent({
|
|
34
|
+
name: 'FormCreate' ,
|
|
35
|
+
components,
|
|
36
|
+
directives,
|
|
37
|
+
props: {
|
|
38
|
+
rule: {
|
|
39
|
+
type: Array,
|
|
40
|
+
required: true,
|
|
41
|
+
default: () => []
|
|
42
|
+
},
|
|
43
|
+
option: {
|
|
44
|
+
type: Object,
|
|
45
|
+
default: () => ({})
|
|
46
|
+
},
|
|
47
|
+
extendOption: Boolean,
|
|
48
|
+
driver: [String, Object],
|
|
49
|
+
modelValue: Object,
|
|
50
|
+
disabled: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: undefined,
|
|
53
|
+
},
|
|
54
|
+
preview: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: undefined,
|
|
57
|
+
},
|
|
58
|
+
index: [String, Number],
|
|
59
|
+
api: Object,
|
|
60
|
+
locale: [String, Object],
|
|
61
|
+
name: String,
|
|
62
|
+
subForm: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: true
|
|
65
|
+
},
|
|
66
|
+
inFor: Boolean,
|
|
67
|
+
},
|
|
68
|
+
emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'reset', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail', 'created'],
|
|
69
|
+
render() {
|
|
70
|
+
return this.fc.render();
|
|
71
|
+
},
|
|
72
|
+
setup(props) {
|
|
73
|
+
const vm = getCurrentInstance();
|
|
74
|
+
provide('parentFC', vm);
|
|
75
|
+
const parent = inject('parentFC', null);
|
|
76
|
+
let top = parent;
|
|
77
|
+
|
|
78
|
+
if (parent) {
|
|
79
|
+
while (top.setupState.parent) {
|
|
80
|
+
top = top.setupState.parent;
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
top = vm;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const {rule, modelValue, subForm, inFor} = toRefs(props);
|
|
87
|
+
|
|
88
|
+
const data = reactive({
|
|
89
|
+
ctxInject: {},
|
|
90
|
+
destroyed: false,
|
|
91
|
+
isShow: true,
|
|
92
|
+
unique: 1,
|
|
93
|
+
renderRule: [...rule.value || []],
|
|
94
|
+
updateValue: JSON.stringify(modelValue.value || {}),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const fc = new FormCreate(vm);
|
|
98
|
+
const fapi = fc.api();
|
|
99
|
+
|
|
100
|
+
const isMore = inFor.value;
|
|
101
|
+
|
|
102
|
+
const addSubForm = () => {
|
|
103
|
+
if (parent) {
|
|
104
|
+
const inject = getGroupInject(vm, parent);
|
|
105
|
+
if (inject) {
|
|
106
|
+
let sub;
|
|
107
|
+
if (isMore) {
|
|
108
|
+
sub = toArray(inject.getSubForm());
|
|
109
|
+
sub.push(fapi);
|
|
110
|
+
|
|
111
|
+
} else {
|
|
112
|
+
sub = fapi;
|
|
113
|
+
}
|
|
114
|
+
inject.subForm(sub);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const rmSubForm = () => {
|
|
120
|
+
const inject = getGroupInject(vm, parent);
|
|
121
|
+
if (inject) {
|
|
122
|
+
if (isMore) {
|
|
123
|
+
const sub = toArray(inject.getSubForm());
|
|
124
|
+
const idx = sub.indexOf(fapi);
|
|
125
|
+
if (idx > -1) {
|
|
126
|
+
sub.splice(idx, 1);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
inject.subForm();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
let styleEl = null;
|
|
135
|
+
|
|
136
|
+
onBeforeMount(() => {
|
|
137
|
+
watchEffect(() => {
|
|
138
|
+
let content = '';
|
|
139
|
+
const globalClass = (props.option && props.option.globalClass) || {};
|
|
140
|
+
Object.keys(globalClass).forEach(k => {
|
|
141
|
+
let subCss = '';
|
|
142
|
+
globalClass[k].style && Object.keys(globalClass[k].style).forEach(key => {
|
|
143
|
+
subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
|
|
144
|
+
});
|
|
145
|
+
if (globalClass[k].content) {
|
|
146
|
+
subCss += globalClass[k].content + ';';
|
|
147
|
+
}
|
|
148
|
+
if (subCss) {
|
|
149
|
+
content += `.${k}{${subCss}}`;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (props.option && props.option.style) {
|
|
153
|
+
content += props.option.style;
|
|
154
|
+
}
|
|
155
|
+
if (!styleEl) {
|
|
156
|
+
styleEl = document.createElement('style');
|
|
157
|
+
styleEl.type = 'text/css';
|
|
158
|
+
document.head.appendChild(styleEl);
|
|
159
|
+
}
|
|
160
|
+
styleEl.innerHTML = content || '';
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const emit$topForm = debounce(() => {
|
|
165
|
+
fc.bus.$emit('$loadData.$topForm');
|
|
166
|
+
}, 100);
|
|
167
|
+
|
|
168
|
+
const emit$form = debounce(() => {
|
|
169
|
+
fc.bus.$emit('$loadData.$form');
|
|
170
|
+
}, 100);
|
|
171
|
+
|
|
172
|
+
const emit$change = (field) => {
|
|
173
|
+
fc.bus.$emit('change-$form.' + field);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
onMounted(() => {
|
|
177
|
+
if (parent) {
|
|
178
|
+
fapi.top.bus.$on('$loadData.$form', emit$topForm);
|
|
179
|
+
fapi.top.bus.$on('change', emit$change);
|
|
180
|
+
}
|
|
181
|
+
fc.mounted();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
onBeforeUnmount(() => {
|
|
185
|
+
if (parent) {
|
|
186
|
+
fapi.top.bus.$off('$loadData.$form', emit$topForm);
|
|
187
|
+
fapi.top.bus.$off('change', emit$change);
|
|
188
|
+
}
|
|
189
|
+
styleEl && document.head.removeChild(styleEl);
|
|
190
|
+
rmSubForm();
|
|
191
|
+
data.destroyed = true;
|
|
192
|
+
fc.unmount();
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
onUpdated(() => {
|
|
196
|
+
fc.updated();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
watch(subForm, (n) => {
|
|
200
|
+
n ? addSubForm() : rmSubForm();
|
|
201
|
+
}, {immediate: true});
|
|
202
|
+
|
|
203
|
+
watch(() => [...rule.value], (n) => {
|
|
204
|
+
if (fc.$handle.isBreakWatch() || n.length === data.renderRule.length && n.every(v => data.renderRule.indexOf(v) > -1)) return;
|
|
205
|
+
fc.$handle.updateAppendData();
|
|
206
|
+
fc.$handle.reloadRule(rule.value);
|
|
207
|
+
vm.setupState.renderRule();
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
watch(() => props.option, () => {
|
|
211
|
+
fc.initOptions();
|
|
212
|
+
fapi.refresh();
|
|
213
|
+
}, {deep: true});
|
|
214
|
+
|
|
215
|
+
watch(() => [props.disabled, props.preview], () => {
|
|
216
|
+
fapi.refresh();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
watch(modelValue, (n) => {
|
|
220
|
+
if (JSON.stringify(n || {}) === data.updateValue) return;
|
|
221
|
+
if (fapi.config.forceCoverValue) {
|
|
222
|
+
fapi.coverValue(n || {});
|
|
223
|
+
} else {
|
|
224
|
+
fapi.setValue(n || {});
|
|
225
|
+
}
|
|
226
|
+
}, {deep: true, flush: 'post'});
|
|
227
|
+
|
|
228
|
+
watch(() => props.index, () => {
|
|
229
|
+
fapi.coverValue({});
|
|
230
|
+
fc.$handle.updateAppendData();
|
|
231
|
+
nextTick(() => {
|
|
232
|
+
nextTick(() => {
|
|
233
|
+
fapi.clearValidateState();
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}, {flush: 'sync'});
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
fc: markRaw(fc),
|
|
240
|
+
parent: parent ? markRaw(parent) : parent,
|
|
241
|
+
top: markRaw(top),
|
|
242
|
+
fapi: markRaw(fapi),
|
|
243
|
+
...toRefs(data),
|
|
244
|
+
getGroupInject: () => getGroupInject(vm, parent),
|
|
245
|
+
refresh() {
|
|
246
|
+
++data.unique;
|
|
247
|
+
},
|
|
248
|
+
renderRule() {
|
|
249
|
+
data.renderRule = [...rule.value || []];
|
|
250
|
+
},
|
|
251
|
+
updateValue(value) {
|
|
252
|
+
if (data.destroyed) return;
|
|
253
|
+
const json = JSON.stringify(value);
|
|
254
|
+
if (data.updateValue === json) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
data.updateValue = json;
|
|
258
|
+
vm.emit('update:modelValue', value);
|
|
259
|
+
nextTick(() => {
|
|
260
|
+
emit$form();
|
|
261
|
+
if (!parent) {
|
|
262
|
+
emit$topForm();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
created() {
|
|
269
|
+
const vm = getCurrentInstance();
|
|
270
|
+
vm.emit('update:api', vm.setupState.fapi);
|
|
271
|
+
vm.setupState.fc.init();
|
|
272
|
+
},
|
|
273
|
+
})
|
|
274
|
+
}
|