@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,76 @@
|
|
|
1
|
+
import {defineComponent, reactive, markRaw, nextTick} from 'vue';
|
|
2
|
+
|
|
3
|
+
const NAME = 'fcSubForm';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: NAME,
|
|
8
|
+
props: {
|
|
9
|
+
rule: Array,
|
|
10
|
+
options: {
|
|
11
|
+
type: Object,
|
|
12
|
+
default: () => reactive(({
|
|
13
|
+
submitBtn: false,
|
|
14
|
+
resetBtn: false,
|
|
15
|
+
}))
|
|
16
|
+
},
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: () => ({})
|
|
20
|
+
},
|
|
21
|
+
disabled: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
syncDisabled: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true
|
|
28
|
+
},
|
|
29
|
+
formCreateInject: Object,
|
|
30
|
+
},
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
cacheValue: {},
|
|
34
|
+
subApi: {},
|
|
35
|
+
form: markRaw(this.formCreateInject.form.$form())
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
emits: ['fc:subform', 'update:modelValue', 'change', 'itemMounted'],
|
|
39
|
+
watch: {
|
|
40
|
+
modelValue(n) {
|
|
41
|
+
this.setValue(n);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
methods: {
|
|
45
|
+
formData(value) {
|
|
46
|
+
this.cacheValue = JSON.stringify(value);
|
|
47
|
+
this.$emit('update:modelValue', value);
|
|
48
|
+
this.$emit('change', value);
|
|
49
|
+
},
|
|
50
|
+
setValue(value) {
|
|
51
|
+
const str = JSON.stringify(value);
|
|
52
|
+
if (this.cacheValue === str) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.cacheValue = str;
|
|
56
|
+
this.subApi.coverValue(value || {});
|
|
57
|
+
},
|
|
58
|
+
add$f(api) {
|
|
59
|
+
this.subApi = api;
|
|
60
|
+
nextTick(() => {
|
|
61
|
+
this.$emit('itemMounted', api);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
render() {
|
|
66
|
+
const Type = this.form;
|
|
67
|
+
return <Type
|
|
68
|
+
disabled={this.disabled}
|
|
69
|
+
onUpdate:modelValue={this.formData}
|
|
70
|
+
modelValue={this.modelValue}
|
|
71
|
+
onEmit-event={this.$emit}
|
|
72
|
+
onUpdate:api={this.add$f}
|
|
73
|
+
rule={this.rule}
|
|
74
|
+
option={this.options} extendOption={true}/>
|
|
75
|
+
}
|
|
76
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bdsoft-element/form-tree",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.min.js",
|
|
6
|
+
"module": "./dist/index.esm.js",
|
|
7
|
+
"unpkg": "./dist/index.min.js",
|
|
8
|
+
"jsdelivr": "./dist/index.min.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf dist/",
|
|
11
|
+
"bili": "cross-env bili",
|
|
12
|
+
"build": "npm-run-all clean bili"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@bdsoft-element/utils": "workspace:^1.0.1"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {defineComponent} from 'vue';
|
|
2
|
+
import toArray from '@bdsoft-element/utils/lib/toarray';
|
|
3
|
+
|
|
4
|
+
const NAME = 'fcTree';
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: NAME,
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
formCreateParser: {
|
|
10
|
+
mergeProp(ctx) {
|
|
11
|
+
const props = ctx.prop.props;
|
|
12
|
+
if (!props.nodeKey) props.nodeKey = 'id';
|
|
13
|
+
if (!props.props) props.props = {
|
|
14
|
+
label: 'title'
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
props: {
|
|
19
|
+
type: String,
|
|
20
|
+
modelValue: {
|
|
21
|
+
type: [Array, String, Number],
|
|
22
|
+
default: () => ([])
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
emits: ['update:modelValue', 'fc.el'],
|
|
26
|
+
watch: {
|
|
27
|
+
modelValue() {
|
|
28
|
+
this.setValue();
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
updateValue() {
|
|
33
|
+
if (!this.$refs.tree) return;
|
|
34
|
+
let value;
|
|
35
|
+
if (this.type === 'selected') {
|
|
36
|
+
value = this.$refs.tree.getCurrentKey();
|
|
37
|
+
} else {
|
|
38
|
+
value = this.$refs.tree.getCheckedKeys();
|
|
39
|
+
}
|
|
40
|
+
this.$emit('update:modelValue', value);
|
|
41
|
+
},
|
|
42
|
+
setValue() {
|
|
43
|
+
if (!this.$refs.tree) return;
|
|
44
|
+
const type = this.type;
|
|
45
|
+
|
|
46
|
+
if (type === 'selected') {
|
|
47
|
+
this.$refs.tree.setCurrentKey(this.modelValue);
|
|
48
|
+
} else {
|
|
49
|
+
this.$refs.tree.setCheckedKeys(toArray(this.modelValue));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
render() {
|
|
54
|
+
return <ElTree {...this.$attrs} ref="tree" onCheck={this.updateValue}
|
|
55
|
+
onNodeClick={this.updateValue}
|
|
56
|
+
v-slots={this.$slots}/>;
|
|
57
|
+
},
|
|
58
|
+
mounted() {
|
|
59
|
+
this.setValue();
|
|
60
|
+
this.$emit('fc.el',this.$refs.tree);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bdsoft-element/form-upload",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.min.js",
|
|
6
|
+
"module": "./dist/index.esm.js",
|
|
7
|
+
"unpkg": "./dist/index.min.js",
|
|
8
|
+
"jsdelivr": "./dist/index.min.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf dist/",
|
|
11
|
+
"bili": "cross-env bili",
|
|
12
|
+
"build": "npm-run-all clean bili"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@bdsoft-element/utils": "workspace:^1.0.1"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="currentColor"
|
|
4
|
+
d="M160 832h704a32 32 0 110 64H160a32 32 0 110-64zm384-578.304V704h-64V247.296L237.248 490.048 192 444.8 508.8 128l316.8 316.8-45.312 45.248L544 253.696z"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: 'IconUpload'
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import toArray from '@bdsoft-element/utils/lib/toarray';
|
|
2
|
+
import getSlot from '@bdsoft-element/utils/lib/slot';
|
|
3
|
+
import './style.css';
|
|
4
|
+
import {defineComponent} from 'vue';
|
|
5
|
+
import IconUpload from './IconUpload.vue';
|
|
6
|
+
|
|
7
|
+
function parseFile(file, i) {
|
|
8
|
+
if (typeof file === 'object') {
|
|
9
|
+
return file;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
url: file,
|
|
13
|
+
is_string: true,
|
|
14
|
+
name: getFileName(file),
|
|
15
|
+
uid: i
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseUpload(file) {
|
|
20
|
+
return {...file, file, value: file};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getFileName(file) {
|
|
24
|
+
return ('' + file).split('/').pop()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const NAME = 'fcUpload';
|
|
28
|
+
|
|
29
|
+
export default defineComponent({
|
|
30
|
+
name: NAME,
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
formCreateParser: {
|
|
33
|
+
toFormValue(value) {
|
|
34
|
+
return toArray(value);
|
|
35
|
+
},
|
|
36
|
+
toValue(formValue, ctx) {
|
|
37
|
+
return ctx.prop.props.limit === 1 ? (formValue[0] || '') : formValue;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
props: {
|
|
41
|
+
previewMask: undefined,
|
|
42
|
+
onPreview: Function,
|
|
43
|
+
httpRequest: Function,
|
|
44
|
+
modalTitle: String,
|
|
45
|
+
listType: String,
|
|
46
|
+
formCreateInject: Object,
|
|
47
|
+
modelValue: [Array, String, Object]
|
|
48
|
+
},
|
|
49
|
+
emits: ['update:modelValue', 'change', 'remove', 'fc.el'],
|
|
50
|
+
data() {
|
|
51
|
+
return {
|
|
52
|
+
previewVisible: false,
|
|
53
|
+
previewImage: '',
|
|
54
|
+
fileList: [],
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
created() {
|
|
58
|
+
this.fileList = toArray(this.modelValue).map(parseFile).map(parseUpload);
|
|
59
|
+
},
|
|
60
|
+
watch: {
|
|
61
|
+
modelValue(n) {
|
|
62
|
+
this.fileList = toArray(n).map(parseFile).map(parseUpload);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
methods: {
|
|
66
|
+
handlePreview(file) {
|
|
67
|
+
if (this.onPreview) {
|
|
68
|
+
this.onPreview(...arguments);
|
|
69
|
+
} else {
|
|
70
|
+
if ('text' === this.listType) {
|
|
71
|
+
window.open(file.url);
|
|
72
|
+
} else {
|
|
73
|
+
this.previewImage = file.url;
|
|
74
|
+
this.previewVisible = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
update(fileList) {
|
|
79
|
+
let files = fileList.map((v) => v.is_string ? v.url : (v.value || v.url)).filter((url) => url !== undefined);
|
|
80
|
+
this.$emit('update:modelValue', files);
|
|
81
|
+
},
|
|
82
|
+
handleCancel() {
|
|
83
|
+
this.previewVisible = false;
|
|
84
|
+
},
|
|
85
|
+
handleChange(file, fileList) {
|
|
86
|
+
this.$emit('change', ...arguments);
|
|
87
|
+
if (file.status === 'success') {
|
|
88
|
+
this.update(fileList);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
handleRemove(file, fileList) {
|
|
92
|
+
this.$emit('remove', ...arguments);
|
|
93
|
+
this.update(fileList);
|
|
94
|
+
},
|
|
95
|
+
doHttpRequest(option) {
|
|
96
|
+
if (this.httpRequest) {
|
|
97
|
+
return this.httpRequest(option);
|
|
98
|
+
} else {
|
|
99
|
+
option.source = 'upload';
|
|
100
|
+
this.formCreateInject.api.fetch(option);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
render() {
|
|
105
|
+
const len = toArray(this.modelValue).length;
|
|
106
|
+
return (
|
|
107
|
+
<div class="_fc-upload"><ElUpload key={len} {...this.$attrs} listType={this.listType || 'picture-card'}
|
|
108
|
+
class={{'_fc-exceed': this.$attrs.limit ? this.$attrs.limit <= len : false}}
|
|
109
|
+
onPreview={this.handlePreview} onChange={this.handleChange}
|
|
110
|
+
onRemove={this.handleRemove} httpRequest={this.doHttpRequest}
|
|
111
|
+
fileList={this.fileList}
|
|
112
|
+
v-slots={getSlot(this.$slots, ['default'])} ref="upload">
|
|
113
|
+
{((this.$slots.default?.()) ||
|
|
114
|
+
(['text', 'picture'].indexOf(this.listType) === -1 ? <ElIcon>
|
|
115
|
+
<IconUpload/>
|
|
116
|
+
</ElIcon> : <ElButton type="primary">{this.formCreateInject.t('clickToUpload') || '点击上传'}</ElButton>)
|
|
117
|
+
)}
|
|
118
|
+
</ElUpload>
|
|
119
|
+
<ElDialog appendToBody={true} modal={this.previewMask} title={this.modalTitle}
|
|
120
|
+
modelValue={this.previewVisible}
|
|
121
|
+
onClose={this.handleCancel}>
|
|
122
|
+
<img style="width: 100%" src={this.previewImage}/>
|
|
123
|
+
</ElDialog>
|
|
124
|
+
</div>);
|
|
125
|
+
},
|
|
126
|
+
mounted() {
|
|
127
|
+
this.$emit('fc.el', this.$refs.upload);
|
|
128
|
+
}
|
|
129
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bdsoft/element-form",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@bdsoft-element/formcore": "workspace:^",
|
|
14
|
+
"@bdsoft-element/utils": "workspace:^1.0.1"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="currentColor"
|
|
4
|
+
d="M512 64a448 448 0 110 896 448 448 0 010-896zm0 832a384 384 0 000-768 384 384 0 000 768zm48-176a48 48 0 11-96 0 48 48 0 0196 0zm-48-464a32 32 0 0132 32v288a32 32 0 01-64 0V288a32 32 0 0132-32z"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: 'IconWarning'
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import checkbox from '../../components/checkbox/src/index';
|
|
2
|
+
import frame from '../../components/frame/src/index';
|
|
3
|
+
import radio from '../../components/radio/src/index';
|
|
4
|
+
import select from '../../components/select/src/index';
|
|
5
|
+
import tree from '../../components/tree/src/index';
|
|
6
|
+
import upload from '../../components/upload/src/index';
|
|
7
|
+
import group from '../../components/group/src/index';
|
|
8
|
+
// import subForm from '../../components/subform/src/index';
|
|
9
|
+
import IconWarning from './icon/IconWarning.vue';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export default [
|
|
13
|
+
checkbox,
|
|
14
|
+
frame,
|
|
15
|
+
radio,
|
|
16
|
+
select,
|
|
17
|
+
tree,
|
|
18
|
+
upload,
|
|
19
|
+
group,
|
|
20
|
+
// subForm,
|
|
21
|
+
IconWarning,
|
|
22
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const PRE = 'el';
|
|
2
|
+
export default {
|
|
3
|
+
button: PRE + '-button',
|
|
4
|
+
icon: PRE + '-icon',
|
|
5
|
+
slider: PRE + '-slider',
|
|
6
|
+
rate: PRE + '-rate',
|
|
7
|
+
upload: 'fc-upload',
|
|
8
|
+
cascader: PRE + '-cascader',
|
|
9
|
+
popover: PRE + '-popover',
|
|
10
|
+
tooltip: PRE + '-tooltip',
|
|
11
|
+
colorPicker: PRE + '-colorPicker',
|
|
12
|
+
timePicker: PRE + '-time-picker',
|
|
13
|
+
timeSelect: PRE + '-time-select',
|
|
14
|
+
datePicker: PRE + '-date-picker',
|
|
15
|
+
'switch': PRE + '-switch',
|
|
16
|
+
select: 'fc-select',
|
|
17
|
+
checkbox: 'fc-checkbox',
|
|
18
|
+
radio: 'fc-radio',
|
|
19
|
+
inputNumber: PRE + '-input-number',
|
|
20
|
+
number: PRE + '-input-number',
|
|
21
|
+
input: PRE + '-input',
|
|
22
|
+
formItem: PRE + '-form-item',
|
|
23
|
+
form: PRE + '-form',
|
|
24
|
+
frame: 'fc-frame',
|
|
25
|
+
col: PRE + '-col',
|
|
26
|
+
row: PRE + '-row',
|
|
27
|
+
tree: 'fc-tree',
|
|
28
|
+
autoComplete: PRE + '-autocomplete',
|
|
29
|
+
auto: PRE + '-autocomplete',
|
|
30
|
+
group: 'fc-group',
|
|
31
|
+
array: 'fc-group',
|
|
32
|
+
object: 'fc-sub-form',
|
|
33
|
+
subForm: 'fc-sub-form',
|
|
34
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import extend from '@bdsoft-element/utils/lib/extend';
|
|
2
|
+
import is from '@bdsoft-element/utils/lib/type';
|
|
3
|
+
import {invoke} from '@bdsoft-element/formcore/frame/util';
|
|
4
|
+
import toArray from '@bdsoft-element/utils/lib/toarray';
|
|
5
|
+
|
|
6
|
+
function tidyBtnProp(btn, def) {
|
|
7
|
+
if (is.Boolean(btn))
|
|
8
|
+
btn = {show: btn};
|
|
9
|
+
else if (!is.Undef(btn) && !is.Object(btn)) btn = {show: def};
|
|
10
|
+
return btn;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 扩展 API 功能的函数
|
|
15
|
+
* @param {Object} api - 原始 API 对象
|
|
16
|
+
* @param {Object} h - 辅助对象,包含一些工具方法和上下文信息
|
|
17
|
+
* @returns {Object} 扩展后的 API 对象
|
|
18
|
+
*/
|
|
19
|
+
export default function extendApi(api, h) {
|
|
20
|
+
return {
|
|
21
|
+
/**
|
|
22
|
+
* 获取表单元素
|
|
23
|
+
* @returns {HTMLElement} 表单元素
|
|
24
|
+
*/
|
|
25
|
+
formEl() {
|
|
26
|
+
return h.$manager.form();
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* 根据字段 ID 获取包装元素
|
|
30
|
+
* @param {string} id - 字段 ID
|
|
31
|
+
* @returns {HTMLElement|undefined} 包装元素,如果未找到则返回 undefined
|
|
32
|
+
*/
|
|
33
|
+
wrapEl(id) {
|
|
34
|
+
const ctx = h.getFieldCtx(id);
|
|
35
|
+
if (!ctx) return;
|
|
36
|
+
return h.vm.refs[ctx.wrapRef];
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* 验证整个表单
|
|
40
|
+
* @param {Function} [callback] - 验证完成后的回调函数,接收验证结果作为参数
|
|
41
|
+
* @returns {Promise<boolean>} 验证结果的 Promise 对象
|
|
42
|
+
*/
|
|
43
|
+
validate(callback) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const forms = api.children;
|
|
46
|
+
const all = [h.$manager.validate()];
|
|
47
|
+
// 遍历所有子表单并添加验证 Promise
|
|
48
|
+
forms.forEach(v => {
|
|
49
|
+
all.push(v.validate());
|
|
50
|
+
})
|
|
51
|
+
Promise.all(all).then(() => {
|
|
52
|
+
resolve(true);
|
|
53
|
+
callback && callback(true);
|
|
54
|
+
}).catch((e) => {
|
|
55
|
+
reject(e);
|
|
56
|
+
callback && callback(e);
|
|
57
|
+
h.vm.emit('validate-fail', e, {api});
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* 验证指定字段
|
|
63
|
+
* @param {string} field - 字段名
|
|
64
|
+
* @param {Function} [callback] - 验证完成后的回调函数,接收验证错误信息作为参数
|
|
65
|
+
* @returns {Promise<null|Error>} 验证结果的 Promise 对象
|
|
66
|
+
*/
|
|
67
|
+
validateField(field, callback) {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
const ctx = h.getFieldCtx(field);
|
|
70
|
+
if (!ctx) return;
|
|
71
|
+
const sub = h.subForm[ctx.id];
|
|
72
|
+
const all = [h.$manager.validateField(ctx.id)];
|
|
73
|
+
// 遍历所有子表单并添加验证 Promise
|
|
74
|
+
toArray(sub).forEach(v => {
|
|
75
|
+
all.push(v.validate());
|
|
76
|
+
})
|
|
77
|
+
Promise.all(all).then(() => {
|
|
78
|
+
resolve(null);
|
|
79
|
+
callback && callback(null);
|
|
80
|
+
}).catch((e) => {
|
|
81
|
+
reject(e);
|
|
82
|
+
callback && callback(e);
|
|
83
|
+
h.vm.emit('validate-field-fail', e, {field, api});
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* 清除指定字段的验证状态
|
|
89
|
+
* @param {string|string[]} fields - 字段名或字段名数组
|
|
90
|
+
* @param {boolean} [clearSub=true] - 是否清除子表单的验证状态
|
|
91
|
+
*/
|
|
92
|
+
clearValidateState(fields, clearSub = true) {
|
|
93
|
+
api.helper.tidyFields(fields).forEach(field => {
|
|
94
|
+
if (clearSub) this.clearSubValidateState(field);
|
|
95
|
+
h.getCtxs(field).forEach(ctx => {
|
|
96
|
+
h.$manager.clearValidateState(ctx);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* 清除指定字段的子表单验证状态
|
|
102
|
+
* @param {string|string[]} fields - 字段名或字段名数组
|
|
103
|
+
*/
|
|
104
|
+
clearSubValidateState(fields) {
|
|
105
|
+
api.helper.tidyFields(fields).forEach(field => {
|
|
106
|
+
h.getCtxs(field).forEach(ctx => {
|
|
107
|
+
const subForm = h.subForm[ctx.id];
|
|
108
|
+
if (!subForm) return;
|
|
109
|
+
if (Array.isArray(subForm)) {
|
|
110
|
+
subForm.forEach(form => {
|
|
111
|
+
form.clearValidateState();
|
|
112
|
+
})
|
|
113
|
+
} else if (subForm) {
|
|
114
|
+
subForm.clearValidateState();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
})
|
|
118
|
+
},
|
|
119
|
+
// 提交按钮相关操作
|
|
120
|
+
btn: {
|
|
121
|
+
/**
|
|
122
|
+
* 设置提交按钮的加载状态
|
|
123
|
+
* @param {boolean} [loading=true] - 是否加载中
|
|
124
|
+
*/
|
|
125
|
+
loading: (loading = true) => {
|
|
126
|
+
api.submitBtnProps({loading: !!loading});
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* 设置提交按钮的禁用状态
|
|
130
|
+
* @param {boolean} [disabled=true] - 是否禁用
|
|
131
|
+
*/
|
|
132
|
+
disabled: (disabled = true) => {
|
|
133
|
+
api.submitBtnProps({disabled: !!disabled});
|
|
134
|
+
},
|
|
135
|
+
/**
|
|
136
|
+
* 设置提交按钮的显示状态
|
|
137
|
+
* @param {boolean} [isShow=true] - 是否显示
|
|
138
|
+
*/
|
|
139
|
+
show: (isShow = true) => {
|
|
140
|
+
api.submitBtnProps({show: !!isShow});
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
// 重置按钮相关操作
|
|
144
|
+
resetBtn: {
|
|
145
|
+
/**
|
|
146
|
+
* 设置重置按钮的加载状态
|
|
147
|
+
* @param {boolean} [loading=true] - 是否加载中
|
|
148
|
+
*/
|
|
149
|
+
loading: (loading = true) => {
|
|
150
|
+
api.resetBtnProps({loading: !!loading});
|
|
151
|
+
},
|
|
152
|
+
/**
|
|
153
|
+
* 设置重置按钮的禁用状态
|
|
154
|
+
* @param {boolean} [disabled=true] - 是否禁用
|
|
155
|
+
*/
|
|
156
|
+
disabled: (disabled = true) => {
|
|
157
|
+
api.resetBtnProps({disabled: !!disabled});
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* 设置重置按钮的显示状态
|
|
161
|
+
* @param {boolean} [isShow=true] - 是否显示
|
|
162
|
+
*/
|
|
163
|
+
show: (isShow = true) => {
|
|
164
|
+
api.resetBtnProps({show: !!isShow});
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* 设置提交按钮的属性
|
|
169
|
+
* @param {Object} [props={}] - 按钮属性对象
|
|
170
|
+
*/
|
|
171
|
+
submitBtnProps: (props = {}) => {
|
|
172
|
+
let btn = tidyBtnProp(h.options.submitBtn, true);
|
|
173
|
+
extend(btn, props);
|
|
174
|
+
h.options.submitBtn = btn;
|
|
175
|
+
api.refreshOptions();
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* 设置重置按钮的属性
|
|
179
|
+
* @param {Object} [props={}] - 按钮属性对象
|
|
180
|
+
*/
|
|
181
|
+
resetBtnProps: (props = {}) => {
|
|
182
|
+
let btn = tidyBtnProp(h.options.resetBtn, false);
|
|
183
|
+
extend(btn, props);
|
|
184
|
+
h.options.resetBtn = btn;
|
|
185
|
+
api.refreshOptions();
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* 提交表单
|
|
189
|
+
* @param {Function} [successFn] - 提交成功后的回调函数,接收表单数据和 API 对象作为参数
|
|
190
|
+
* @param {Function} [failFn] - 提交失败后的回调函数,接收 API 对象和错误信息作为参数
|
|
191
|
+
* @returns {Promise<Object>} 表单数据的 Promise 对象
|
|
192
|
+
*/
|
|
193
|
+
submit(successFn, failFn) {
|
|
194
|
+
return new Promise((resolve, reject) => {
|
|
195
|
+
api.validate().then(() => {
|
|
196
|
+
let formData = api.formData();
|
|
197
|
+
is.Function(successFn) && invoke(() => successFn(formData, api));
|
|
198
|
+
is.Function(h.options.onSubmit) && invoke(() => h.options.onSubmit(formData, api));
|
|
199
|
+
h.vm.emit('submit', formData, api);
|
|
200
|
+
resolve(formData);
|
|
201
|
+
}).catch((...args) => {
|
|
202
|
+
is.Function(failFn) && invoke(() => failFn(api, ...args));
|
|
203
|
+
reject(...args)
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|