@cicctencent/formily 0.0.0-stage → 0.0.1
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/.eslintrc.js +40 -0
- package/.prettierrc.js +28 -0
- package/.vscode/launch.json +23 -0
- package/CHANGELOG.md +8 -0
- package/README.md +22 -2
- package/babel.config.js +3 -0
- package/build/build.js +96 -0
- package/build/rollup.config.bundle.js +63 -0
- package/build/update.version.js +35 -0
- package/dist/index.css +2516 -0
- package/dist/index.js +8377 -0
- package/dist/schema-field/index.css +2466 -0
- package/dist/schema-field/index.js +8213 -0
- package/dist/transform/index.js +551 -0
- package/dist/validate/index.js +1104 -0
- package/dist/vue-form/index.css +2516 -0
- package/dist/vue-form/index.js +8359 -0
- package/docs/.vuepress/client.ts +15 -0
- package/docs/.vuepress/components/code-preview.vue +203 -0
- package/docs/.vuepress/components/highlight.ts +53 -0
- package/docs/.vuepress/config.ts +39 -0
- package/docs/.vuepress/util.ts +7 -0
- package/docs/README.md +30 -0
- package/docs/components/anyOf.md +26 -0
- package/docs/components/array-cards.md +12 -0
- package/docs/components/array-collapse.md +12 -0
- package/docs/components/array-items.md +12 -0
- package/docs/components/array-table.md +12 -0
- package/docs/components/array-tabs.md +16 -0
- package/docs/components/cascader.md +12 -0
- package/docs/components/checkbox.md +12 -0
- package/docs/components/event.md +27 -0
- package/docs/components/hotArea.md +25 -0
- package/docs/components/index.md +4 -0
- package/docs/components/input.md +30 -0
- package/docs/components/layout-group.md +19 -0
- package/docs/components/link.md +22 -0
- package/docs/components/oneOf.md +8 -0
- package/docs/components/radio.md +12 -0
- package/docs/components/rich-editor.md +21 -0
- package/docs/components/select.md +34 -0
- package/docs/components/space.md +11 -0
- package/docs/components/switch.md +20 -0
- package/docs/components/text.md +21 -0
- package/docs/components/time-picker.md +11 -0
- package/docs/components/transfer.md +14 -0
- package/docs/components/upload-button.md +28 -0
- package/docs/demos/any-of/index.vue +66 -0
- package/docs/demos/array-cards/index.vue +105 -0
- package/docs/demos/array-collapse/index.vue +155 -0
- package/docs/demos/array-items/index.vue +171 -0
- package/docs/demos/array-table/index.vue +115 -0
- package/docs/demos/array-tabs/index.vue +56 -0
- package/docs/demos/cascader/index.vue +297 -0
- package/docs/demos/checkbox/index.vue +39 -0
- package/docs/demos/event/index.vue +436 -0
- package/docs/demos/hotArea/index.vue +240 -0
- package/docs/demos/index.vue +36 -0
- package/docs/demos/input/index.vue +46 -0
- package/docs/demos/layout-group/index.vue +51 -0
- package/docs/demos/link/index.vue +32 -0
- package/docs/demos/radio/index.vue +36 -0
- package/docs/demos/rich-editor/index.vue +22 -0
- package/docs/demos/select/index.vue +76 -0
- package/docs/demos/space/index.vue +93 -0
- package/docs/demos/switch/index.vue +31 -0
- package/docs/demos/text/index.vue +38 -0
- package/docs/demos/time-picker/index.vue +39 -0
- package/docs/demos/transfer/index.vue +26 -0
- package/docs/demos/upload-button/index.vue +27 -0
- package/docs/demos/x-data/add-button-title.vue +101 -0
- package/docs/demos/x-data/send-message.vue +33 -0
- package/docs/demos/x-reactions/any-of.vue +40 -0
- package/docs/demos/x-reactions/x-reactions.vue +39 -0
- package/docs/guide/component-extend.md +23 -0
- package/docs/guide/extra-bury-report.md +64 -0
- package/docs/guide/schema.md +22 -0
- package/docs/guide/x-data.md +41 -0
- package/docs/guide/x-reactions.md +20 -0
- package/example/.browserslistrc +4 -0
- package/example/.eslintrc.js +20 -0
- package/example/README.md +24 -0
- package/example/index.html +15 -0
- package/example/jest.config.js +26 -0
- package/example/package.json +50 -0
- package/example/public/favicon.ico +0 -0
- package/example/public/index.html +17 -0
- package/example/src/App.vue +25 -0
- package/example/src/assets/logo.png +0 -0
- package/example/src/components/HelloWorld.vue +148 -0
- package/example/src/components/group/index.vue +16 -0
- package/example/src/components/uploadBtn/index.vue +44 -0
- package/example/src/components/uploadBtn/upload-icon.svg +6 -0
- package/example/src/layout/component/Aside.vue +39 -0
- package/example/src/layout/component/Main.vue +9 -0
- package/example/src/layout/index.vue +15 -0
- package/example/src/main.ts +17 -0
- package/example/src/router/index.ts +99 -0
- package/example/src/shims-vue.d.ts +6 -0
- package/example/src/store/index.ts +9 -0
- package/example/src/views/demo/any-of/data.ts +38 -0
- package/example/src/views/demo/any-of/index.vue +35 -0
- package/example/src/views/demo/array-cards/data.ts +65 -0
- package/example/src/views/demo/array-cards/index.vue +33 -0
- package/example/src/views/demo/array-items/data.ts +29 -0
- package/example/src/views/demo/array-items/index.vue +33 -0
- package/example/src/views/demo/cloud-button/data.ts +14 -0
- package/example/src/views/demo/cloud-button/index.vue +22 -0
- package/example/src/views/demo/color-group/data.ts +15 -0
- package/example/src/views/demo/color-group/index.vue +22 -0
- package/example/src/views/demo/color-picker/data.ts +21 -0
- package/example/src/views/demo/color-picker/index.vue +33 -0
- package/example/src/views/demo/datatime/data.ts +62 -0
- package/example/src/views/demo/datatime/index.vue +22 -0
- package/example/src/views/demo/event/data.ts +184 -0
- package/example/src/views/demo/event/index.vue +33 -0
- package/example/src/views/demo/hot-area/data.ts +196 -0
- package/example/src/views/demo/hot-area/index.vue +33 -0
- package/example/src/views/demo/input/data.ts +39 -0
- package/example/src/views/demo/input/index.vue +33 -0
- package/example/src/views/demo/link/data.ts +23 -0
- package/example/src/views/demo/link/index.vue +22 -0
- package/example/src/views/demo/one-of/data.ts +139 -0
- package/example/src/views/demo/one-of/index.vue +33 -0
- package/example/src/views/demo/rich-editor/data.ts +12 -0
- package/example/src/views/demo/rich-editor/index.vue +24 -0
- package/example/src/views/demo/select/data.ts +38 -0
- package/example/src/views/demo/select/index.vue +33 -0
- package/example/src/views/demo/upload-button/data1.ts +11 -0
- package/example/src/views/demo/upload-button/data2.ts +12 -0
- package/example/src/views/demo/upload-button/index.vue +42 -0
- package/example/tsconfig.json +32 -0
- package/example/vite.config.ts +12 -0
- package/jest.config.js +4 -0
- package/package.json +92 -4
- package/src/components/__builtins__/configs/index.ts +1 -0
- package/src/components/__builtins__/index.ts +2 -0
- package/src/components/__builtins__/shared/create-context.ts +54 -0
- package/src/components/__builtins__/shared/index.ts +7 -0
- package/src/components/__builtins__/shared/loading.ts +20 -0
- package/src/components/__builtins__/shared/portal.ts +43 -0
- package/src/components/__builtins__/shared/resolve-component.ts +22 -0
- package/src/components/__builtins__/shared/transform-component.ts +33 -0
- package/src/components/__builtins__/shared/types.ts +8 -0
- package/src/components/__builtins__/shared/utils.ts +35 -0
- package/src/components/__builtins__/styles/common.scss +22 -0
- package/src/components/__builtins__/styles/element-plus.scss +1094 -0
- package/src/components/any-of/index.ts +20 -0
- package/src/components/array-base/index.ts +413 -0
- package/src/components/array-base/style.scss +53 -0
- package/src/components/array-base/style.ts +2 -0
- package/src/components/array-cards/index.ts +253 -0
- package/src/components/array-cards/style.scss +33 -0
- package/src/components/array-cards/style.ts +7 -0
- package/src/components/array-collapse/index.ts +381 -0
- package/src/components/array-collapse/style.scss +38 -0
- package/src/components/array-collapse/style.ts +10 -0
- package/src/components/array-items/index.ts +213 -0
- package/src/components/array-items/style.scss +82 -0
- package/src/components/array-items/style.ts +4 -0
- package/src/components/array-table/index.ts +567 -0
- package/src/components/array-table/style.scss +84 -0
- package/src/components/array-table/style.ts +11 -0
- package/src/components/array-tabs/index.ts +141 -0
- package/src/components/array-tabs/style.scss +16 -0
- package/src/components/array-tabs/style.ts +5 -0
- package/src/components/base/AnyOf/index.ts +155 -0
- package/src/components/base/AnyOf/index.vue +111 -0
- package/src/components/base/CloudButton/index.ts +46 -0
- package/src/components/base/CloudButton/index.vue +128 -0
- package/src/components/base/ColorGroup/index.ts +57 -0
- package/src/components/base/ColorGroup/index.vue +30 -0
- package/src/components/base/ColorPicker/index.ts +45 -0
- package/src/components/base/ColorPicker/index.vue +50 -0
- package/src/components/base/Container/index.vue +39 -0
- package/src/components/base/HotArea/index.ts +698 -0
- package/src/components/base/HotArea/index.vue +565 -0
- package/src/components/base/HotArea/type.ts +18 -0
- package/src/components/base/Input/index.vue +150 -0
- package/src/components/base/LayoutGroup/index.vue +40 -0
- package/src/components/base/Link/index.vue +43 -0
- package/src/components/base/Middleware/index.ts +235 -0
- package/src/components/base/Middleware/index.vue +169 -0
- package/src/components/base/OneOf/index.ts +105 -0
- package/src/components/base/OneOf/index.vue +85 -0
- package/src/components/base/RichEditor/index.ts +13 -0
- package/src/components/base/RichEditor/index.vue +120 -0
- package/src/components/base/RichEditor/options.ts +24 -0
- package/src/components/base/Select/index.ts +106 -0
- package/src/components/base/Select/index.vue +161 -0
- package/src/components/base/Switch/index.vue +42 -0
- package/src/components/base/Text/index.vue +47 -0
- package/src/components/base/event/index.ts +226 -0
- package/src/components/base/event/index.vue +356 -0
- package/src/components/cascader/index.ts +48 -0
- package/src/components/cascader/style.ts +5 -0
- package/src/components/checkbox/index.ts +166 -0
- package/src/components/checkbox/style.ts +5 -0
- package/src/components/cloud-button/index.ts +21 -0
- package/src/components/color-group/index.ts +18 -0
- package/src/components/color-picker/index.ts +18 -0
- package/src/components/container/index.ts +18 -0
- package/src/components/data-time/index.ts +24 -0
- package/src/components/date-picker/index.ts +51 -0
- package/src/components/date-picker/style.ts +4 -0
- package/src/components/editable/index.ts +261 -0
- package/src/components/editable/style.scss +55 -0
- package/src/components/editable/style.ts +5 -0
- package/src/components/el-form-item/index.ts +21 -0
- package/src/components/el-form-item/style.ts +3 -0
- package/src/components/event/index.ts +16 -0
- package/src/components/form/index.ts +94 -0
- package/src/components/form/style.scss +0 -0
- package/src/components/form/style.ts +3 -0
- package/src/components/form-button-group/index.ts +74 -0
- package/src/components/form-button-group/style.scss +0 -0
- package/src/components/form-button-group/style.ts +4 -0
- package/src/components/form-collapse/index.ts +215 -0
- package/src/components/form-collapse/style.scss +6 -0
- package/src/components/form-collapse/style.ts +4 -0
- package/src/components/form-dialog/index.ts +433 -0
- package/src/components/form-dialog/style.ts +4 -0
- package/src/components/form-drawer/index.ts +424 -0
- package/src/components/form-drawer/style.scss +21 -0
- package/src/components/form-drawer/style.ts +4 -0
- package/src/components/form-grid/index.ts +181 -0
- package/src/components/form-grid/style.scss +5 -0
- package/src/components/form-grid/style.ts +1 -0
- package/src/components/form-item/animation.scss +72 -0
- package/src/components/form-item/grid.scss +171 -0
- package/src/components/form-item/index.ts +642 -0
- package/src/components/form-item/style.scss +521 -0
- package/src/components/form-item/style.ts +2 -0
- package/src/components/form-item/var.scss +17 -0
- package/src/components/form-layout/index.ts +161 -0
- package/src/components/form-layout/style.scss +6 -0
- package/src/components/form-layout/style.ts +1 -0
- package/src/components/form-layout/useResponsiveFormLayout.ts +118 -0
- package/src/components/form-step/index.ts +210 -0
- package/src/components/form-step/style.ts +2 -0
- package/src/components/form-tab/index.ts +172 -0
- package/src/components/form-tab/style.scss +6 -0
- package/src/components/form-tab/style.ts +4 -0
- package/src/components/hot-area/index.ts +20 -0
- package/src/components/index.ts +49 -0
- package/src/components/input/index.ts +35 -0
- package/src/components/input/style.ts +4 -0
- package/src/components/input-number/index.ts +36 -0
- package/src/components/input-number/style.ts +3 -0
- package/src/components/layout-group/index.ts +18 -0
- package/src/components/link/index.ts +18 -0
- package/src/components/middleware/index.ts +21 -0
- package/src/components/one-of/index.ts +20 -0
- package/src/components/placeholder-input/index.ts +21 -0
- package/src/components/placeholder-input/index.vue +87 -0
- package/src/components/preview-text/index.ts +303 -0
- package/src/components/preview-text/style.ts +9 -0
- package/src/components/radio/index.ts +109 -0
- package/src/components/radio/style.ts +3 -0
- package/src/components/reset/index.ts +52 -0
- package/src/components/reset/style.ts +1 -0
- package/src/components/rich-editor/index.ts +18 -0
- package/src/components/row/index.ts +20 -0
- package/src/components/row/index.vue +53 -0
- package/src/components/select/index.ts +19 -0
- package/src/components/select/style.ts +5 -0
- package/src/components/space/index.ts +98 -0
- package/src/components/space/style.scss +24 -0
- package/src/components/space/style.ts +1 -0
- package/src/components/submit/index.ts +59 -0
- package/src/components/submit/style.ts +1 -0
- package/src/components/switch/index.ts +9 -0
- package/src/components/switch/style.ts +1 -0
- package/src/components/text/index.ts +21 -0
- package/src/components/time-picker/index.ts +21 -0
- package/src/components/time-picker/style.ts +4 -0
- package/src/components/transfer/index.ts +12 -0
- package/src/components/transfer/style.ts +1 -0
- package/src/components/upload/index.ts +136 -0
- package/src/components/upload/style.ts +2 -0
- package/src/components/upload-button/index.ts +21 -0
- package/src/components/upload-button/index.vue +199 -0
- package/src/createScemaField.ts +14 -0
- package/src/index.ts +41 -0
- package/src/schema-field/index.ts +11 -0
- package/src/scope.ts +29 -0
- package/src/transform/core.ts +404 -0
- package/src/transform/index.ts +11 -0
- package/src/transform/transform.ts +59 -0
- package/src/transform/utils/constant.ts +79 -0
- package/src/transform/utils/func.ts +145 -0
- package/src/typings/common.ts +37 -0
- package/src/typings/vue-shim.d.ts +7 -0
- package/src/typings/vue-test-utils.d.ts +11 -0
- package/src/utils/anyof_utils.ts +95 -0
- package/src/utils/common.ts +15 -0
- package/src/validate/index.ts +648 -0
- package/src/validate/utils/constant.ts +2 -0
- package/src/vue-form/index.ts +18 -0
- package/src/vue-form/index.vue +106 -0
- package/src/vue-form/useForm.ts +112 -0
- package/tests/data/anyof.ts +40 -0
- package/tests/data/image.ts +472 -0
- package/tests/fixtures/validate.ts +63 -0
- package/tests/unit/transform.spec.ts +253 -0
- package/tests/unit/utils.spec.ts +10 -0
- package/tests/unit/validate.spec.ts +256 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="upload-button"
|
|
4
|
+
:style="{ 'pointer-events': readOnly ? 'none' : 'auto' }"
|
|
5
|
+
>
|
|
6
|
+
<el-upload
|
|
7
|
+
:show-file-list="false"
|
|
8
|
+
:on-change="onUploadChange"
|
|
9
|
+
:auto-upload="false"
|
|
10
|
+
:accept="accept"
|
|
11
|
+
v-if="!modelValue"
|
|
12
|
+
>
|
|
13
|
+
<div class="button-box">
|
|
14
|
+
<span>点击上传</span>
|
|
15
|
+
</div>
|
|
16
|
+
</el-upload>
|
|
17
|
+
|
|
18
|
+
<div v-else class="image-box">
|
|
19
|
+
<div class="image-box-1">
|
|
20
|
+
<img :src="modelValue" width="115" />
|
|
21
|
+
<span class="del-text" @click="handleDelete">删除</span>
|
|
22
|
+
<div class="mask"></div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<el-upload
|
|
26
|
+
:show-file-list="false"
|
|
27
|
+
:on-change="onUploadChange"
|
|
28
|
+
:auto-upload="false"
|
|
29
|
+
:accept="accept"
|
|
30
|
+
>
|
|
31
|
+
<span>{{ title }}</span>
|
|
32
|
+
</el-upload>
|
|
33
|
+
</div>
|
|
34
|
+
<div v-if="description" class="description">
|
|
35
|
+
{{ description }}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script lang="ts">
|
|
41
|
+
import { defineComponent, computed, ref, watch } from 'vue';
|
|
42
|
+
|
|
43
|
+
export default defineComponent({
|
|
44
|
+
name: 'UploadButton',
|
|
45
|
+
emits: ['change', 'fileUpload'],
|
|
46
|
+
props: {
|
|
47
|
+
// 图片url
|
|
48
|
+
modelValue: String,
|
|
49
|
+
title: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: '替换背景',
|
|
52
|
+
},
|
|
53
|
+
readOnly: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false,
|
|
56
|
+
},
|
|
57
|
+
accept: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: '.png,.jpg,.jpeg,.PNG,.JPG,.JPEG,.webp,.gif',
|
|
60
|
+
},
|
|
61
|
+
description: String,
|
|
62
|
+
},
|
|
63
|
+
setup(props, { emit }) {
|
|
64
|
+
const done = val => {
|
|
65
|
+
let res = null;
|
|
66
|
+
// 如果回调返回的是一个数组,则取第一张图片
|
|
67
|
+
if (Array.isArray(val)) {
|
|
68
|
+
if (val.length) {
|
|
69
|
+
res = val[0];
|
|
70
|
+
}
|
|
71
|
+
} else res = val;
|
|
72
|
+
emit('change', res);
|
|
73
|
+
};
|
|
74
|
+
const handleDelete = () => {
|
|
75
|
+
emit('change', null);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const onUploadChange = (file, fileList) => {
|
|
79
|
+
if (file?.status === 'ready') {
|
|
80
|
+
// done 上传文件的回调, 在外部上传完图片通过done回调上传结果
|
|
81
|
+
emit('fileUpload', file, done);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return { handleDelete, onUploadChange };
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<style scoped lang="scss">
|
|
90
|
+
.upload-button {
|
|
91
|
+
.button-box {
|
|
92
|
+
border-radius: 4px;
|
|
93
|
+
border: 1px dashed #d8dce6;
|
|
94
|
+
display: flex;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
align-items: center;
|
|
97
|
+
width: 161px;
|
|
98
|
+
height: 40px;
|
|
99
|
+
|
|
100
|
+
span {
|
|
101
|
+
color: #4b515e;
|
|
102
|
+
font-weight: 400;
|
|
103
|
+
font-size: 14px;
|
|
104
|
+
line-height: 20px;
|
|
105
|
+
}
|
|
106
|
+
&:hover {
|
|
107
|
+
border-color: #c79156;
|
|
108
|
+
background-color: #f9e7d3;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
}
|
|
111
|
+
&::before {
|
|
112
|
+
content: '';
|
|
113
|
+
display: block;
|
|
114
|
+
width: 20px;
|
|
115
|
+
height: 20px;
|
|
116
|
+
margin-right: 10px;
|
|
117
|
+
background-repeat: no-repeat;
|
|
118
|
+
object-fit: cover;
|
|
119
|
+
background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNSAxNS45NzI1QzE3LjI1IDE1LjcyMzggMTkgMTMuODE2MyAxOSAxMS41QzE5IDkuNDM1NTMgMTcuNjA5OCA3LjY5NTc2IDE1LjcxNDUgNy4xNjU3OUMxNC45Mzk0IDQuNzQ5MjEgMTIuNjc0IDMgMTAgM0M3LjMyNjAyIDMgNS4wNjA1OSA0Ljc0OTIxIDQuMjg1NTQgNy4xNjU3OUMyLjM5MDIxIDcuNjk1NzYgMSA5LjQzNTUzIDEgMTEuNUMxIDEzLjgxNjMgMi43NTAwMiAxNS43MjM4IDUgMTUuOTcyNVYxNkg1LjVIMTQuNUgxNVYxNS45NzI1WiIgZmlsbD0iI0ZBRjNFRSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwIDMuNUM3LjU0OTg0IDMuNSA1LjQ3MjY4IDUuMTAyNDkgNC43NjIxMiA3LjMxODM0TDQuNjc5OSA3LjU3NDcyTDQuNDIwNiA3LjY0NzJDMi43MzU0MSA4LjExODIyIDEuNSA5LjY2NTQ4IDEuNSAxMS41QzEuNSAxMy43MDkxIDMuMjkwODYgMTUuNSA1LjUgMTUuNVYxNi41QzIuNzM4NTggMTYuNSAwLjUgMTQuMjYxNCAwLjUgMTEuNUMwLjUgOS4yOTkxNiAxLjkyMTU1IDcuNDMxNTMgMy44OTU3IDYuNzYzMDhDNC44MDczMiA0LjI3NTUzIDcuMTk1NzEgMi41IDEwIDIuNUMxMi44MDQzIDIuNSAxNS4xOTI3IDQuMjc1NTYgMTYuMTA0NSA2Ljc2MjYzQzE4LjA3ODQgNy40MzE1MyAxOS41IDkuMjk5MTEgMTkuNSAxMS41QzE5LjUgMTQuMjYxNCAxNy4yNjE0IDE2LjUgMTQuNSAxNi41VjE1LjVDMTYuNzA5MSAxNS41IDE4LjUgMTMuNzA5MSAxOC41IDExLjVDMTguNSA5LjY2NTQ5IDE3LjI2NDYgOC4xMTgxNSAxNS41Nzk1IDcuNjQ2NjVMMTUuMzIwNCA3LjU3NDEzTDE1LjIzODIgNy4zMTc4OUMxNC41Mjc0IDUuMTAyNTEgMTIuNDUwMiAzLjUgMTAgMy41WiIgZmlsbD0iI0M3OTE1NiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjc0MjYgOC43MDczM0wxMy41NzExIDExLjUzNThMMTIuODYzOSAxMi4yNDI5TDEwLjAzNTUgOS40MTQ0M0w3LjIwNzEgMTIuMjQyOUw2LjQ5OTk5IDExLjUzNThMOS4zMjg0MiA4LjcwNzMzTDkuNjgxOTcgOC4zNTM3N0M5Ljg3NzIzIDguMTU4NTEgMTAuMTkzOCA4LjE1ODUxIDEwLjM4OTEgOC4zNTM3N0wxMC43NDI2IDguNzA3MzNaIiBmaWxsPSIjQzc5MTU2Ii8+CjxyZWN0IHg9IjkuNSIgeT0iOSIgd2lkdGg9IjEiIGhlaWdodD0iOCIgZmlsbD0iI0M3OTE1NiIvPgo8L3N2Zz4K');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
.image-box {
|
|
123
|
+
border-radius: 4px;
|
|
124
|
+
background-color: rgba(216, 220, 230, 0.4);
|
|
125
|
+
padding: 6px 27px 6px 18px;
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
justify-content: space-between;
|
|
129
|
+
height: 60px;
|
|
130
|
+
position: relative;
|
|
131
|
+
|
|
132
|
+
span {
|
|
133
|
+
font-family: 'PingFang SC';
|
|
134
|
+
font-style: normal;
|
|
135
|
+
font-weight: 400;
|
|
136
|
+
font-size: 14px;
|
|
137
|
+
line-height: 20px;
|
|
138
|
+
/* identical to box height */
|
|
139
|
+
|
|
140
|
+
color: #4b515e;
|
|
141
|
+
|
|
142
|
+
opacity: 0.6;
|
|
143
|
+
|
|
144
|
+
&:hover {
|
|
145
|
+
color: #c79156;
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
.image-box-1 {
|
|
151
|
+
height: 100%;
|
|
152
|
+
width: 115px;
|
|
153
|
+
position: relative;
|
|
154
|
+
img {
|
|
155
|
+
position: absolute;
|
|
156
|
+
left: 0;
|
|
157
|
+
top: 0;
|
|
158
|
+
right: 0;
|
|
159
|
+
bottom: 0;
|
|
160
|
+
height: 100%;
|
|
161
|
+
object-fit: contain;
|
|
162
|
+
}
|
|
163
|
+
.del-text {
|
|
164
|
+
font-weight: 400;
|
|
165
|
+
font-size: 9px;
|
|
166
|
+
line-height: 13px;
|
|
167
|
+
color: #fff;
|
|
168
|
+
position: absolute;
|
|
169
|
+
top: 3px;
|
|
170
|
+
right: 6px;
|
|
171
|
+
opacity: 0;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.image-box-1:hover {
|
|
176
|
+
.mask {
|
|
177
|
+
position: absolute;
|
|
178
|
+
left: 0;
|
|
179
|
+
top: 0;
|
|
180
|
+
right: 0;
|
|
181
|
+
bottom: 0;
|
|
182
|
+
background: rgba(0, 0, 0, 0.59);
|
|
183
|
+
z-index: 2;
|
|
184
|
+
border-radius: 4px;
|
|
185
|
+
}
|
|
186
|
+
.del-text {
|
|
187
|
+
opacity: 1;
|
|
188
|
+
z-index: 3;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
.description {
|
|
192
|
+
display: block;
|
|
193
|
+
font-size: 12px;
|
|
194
|
+
color: #86909c;
|
|
195
|
+
line-height: 20px;
|
|
196
|
+
margin-top: 5px;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createSchemaField } from '@formily/vue';
|
|
2
|
+
import * as formilyComponent from './components';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 生成SchemaField
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export default function () {
|
|
9
|
+
// 执行了 Vue.use(JvFormily) window.__jt_formily_components 会记录下这些组件列表, 否则读取Formily库的组件列表
|
|
10
|
+
const components = window.__jt_formily_components
|
|
11
|
+
? window.__jt_formily_components
|
|
12
|
+
: formilyComponent;
|
|
13
|
+
return createSchemaField({ components }).SchemaField;
|
|
14
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import VueForm from './vue-form/index.vue';
|
|
2
|
+
import {createField} from './schema-field';
|
|
3
|
+
import VueKonva from 'vue-konva';
|
|
4
|
+
import { FormilyValidate } from './validate'
|
|
5
|
+
export * from './typings/common';
|
|
6
|
+
export { VueForm, createField, FormilyValidate };
|
|
7
|
+
import { HotArea, AnyOf } from './components'
|
|
8
|
+
export * from './components/__builtins__';
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window{
|
|
12
|
+
__jt_formily_components: any;
|
|
13
|
+
JT_VERSION: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
window.JT_VERSION = Object.assign(
|
|
20
|
+
{
|
|
21
|
+
'__rollup__name__@__rollup__version__': '__rollup__date__',
|
|
22
|
+
},
|
|
23
|
+
window.JT_VERSION
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
install(app,options){
|
|
28
|
+
console.log("🚀formily install")
|
|
29
|
+
|
|
30
|
+
const expandComponents = options?.expandComponents ?? {}
|
|
31
|
+
const SchemaField = createField({ HotArea , AnyOf , ...expandComponents});
|
|
32
|
+
|
|
33
|
+
/** 热区编辑组件 */
|
|
34
|
+
app.use(VueKonva);
|
|
35
|
+
|
|
36
|
+
app.component('SchemaField',SchemaField);
|
|
37
|
+
/** ElementPlus */
|
|
38
|
+
// app.use(ElementPlus);
|
|
39
|
+
app.component('VueForm',VueForm)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createSchemaField } from '@formily/vue';
|
|
2
|
+
import * as formilyComponent from '../components/index';
|
|
3
|
+
/** 创建createField
|
|
4
|
+
* @expandComponents 扩展组件
|
|
5
|
+
*/
|
|
6
|
+
export function createField(expandComponents: any = {}) {
|
|
7
|
+
const components = Object.assign({}, formilyComponent, expandComponents);
|
|
8
|
+
//@ts-ignore
|
|
9
|
+
window.__jt_formily_components = components;
|
|
10
|
+
return createSchemaField({ components }).SchemaField;
|
|
11
|
+
}
|
package/src/scope.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Field } from '@formily/core';
|
|
2
|
+
|
|
3
|
+
export function middlewareFilter(field: Field, values) {
|
|
4
|
+
const options = field?.componentProps?.options || [];
|
|
5
|
+
// 中间件名称
|
|
6
|
+
const middlewareNames = [];
|
|
7
|
+
// 后面是处理在页面上的场景
|
|
8
|
+
const data =
|
|
9
|
+
field?.form?.values?.middlewares || field?.form?.values?.event?.middlewares || [];
|
|
10
|
+
|
|
11
|
+
if (Array.isArray(data)) {
|
|
12
|
+
data.forEach(it => {
|
|
13
|
+
if (it?.name) {
|
|
14
|
+
middlewareNames.push(it.name);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (options.length) {
|
|
19
|
+
const res = [];
|
|
20
|
+
options.forEach(item => {
|
|
21
|
+
if (middlewareNames.includes(item.value)) {
|
|
22
|
+
res.push({ ...item, disabled: true });
|
|
23
|
+
} else {
|
|
24
|
+
res.push({ ...item, disabled: false });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
field.setComponentProps({ options: res });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { isEqual } from 'lodash-es';
|
|
2
|
+
import { TransformCoreState } from '../typings/common';
|
|
3
|
+
import {
|
|
4
|
+
COMMON_KEYS,
|
|
5
|
+
COMPONENT_MAP,
|
|
6
|
+
FIELD_KEYS,
|
|
7
|
+
FIELD_MAP,
|
|
8
|
+
FORMILY_EXPAND_KEYS,
|
|
9
|
+
FORMILY_KEYS,
|
|
10
|
+
UniqueType,
|
|
11
|
+
} from './utils/constant';
|
|
12
|
+
import {
|
|
13
|
+
emitEnum,
|
|
14
|
+
getComponentName,
|
|
15
|
+
getXData,
|
|
16
|
+
isAnyOf,
|
|
17
|
+
isOneOf,
|
|
18
|
+
oneOfTransformEnum,
|
|
19
|
+
simpleGenerationSchemaItem,
|
|
20
|
+
} from './utils/func';
|
|
21
|
+
import { isSchemaConfig } from '../utils/common';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Formily 配置转换Core
|
|
25
|
+
*/
|
|
26
|
+
export class TransformCore {
|
|
27
|
+
private existGroup:boolean = false;
|
|
28
|
+
private state: TransformCoreState = { schema: null, ctx: null, group: false }
|
|
29
|
+
constructor(state: TransformCoreState) {
|
|
30
|
+
this.state = Object.assign({}, this.state, state ?? {});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get existEvent(){
|
|
34
|
+
return this.state.schema.properties?.event && !isEqual(this.state.schema.properties?.event,{}) && !isEqual(this.state.schema.properties?.event?.properties,{})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
compile() {
|
|
38
|
+
const result: any = this.compileItem(this.state.schema);
|
|
39
|
+
|
|
40
|
+
// 判断schema 里面是否存在自定义布局
|
|
41
|
+
if(!this.existGroup && this.state?.group){
|
|
42
|
+
// 自定义布局
|
|
43
|
+
const groupConfig = {
|
|
44
|
+
_group1:{
|
|
45
|
+
type:'void',
|
|
46
|
+
'x-decorator': 'LayoutGroup',
|
|
47
|
+
'x-decorator-props':{
|
|
48
|
+
title:'基础配置'
|
|
49
|
+
},
|
|
50
|
+
properties:{
|
|
51
|
+
props: result?.properties?.props,
|
|
52
|
+
style:result?.properties?.style
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// 是否存在自定义事件布局
|
|
57
|
+
if(this.existEvent){
|
|
58
|
+
groupConfig['_group2']={
|
|
59
|
+
type:'void',
|
|
60
|
+
'x-decorator': 'LayoutGroup',
|
|
61
|
+
'x-decorator-props':{
|
|
62
|
+
title:''
|
|
63
|
+
},
|
|
64
|
+
properties:{
|
|
65
|
+
event: result?.properties?.event,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties:{
|
|
72
|
+
...groupConfig
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// 走默认分组
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
// 编译item(字段) 🚀例如:input:{type:'string',default:''}
|
|
80
|
+
compileItem(data: any) {
|
|
81
|
+
// 防止错误格式数据,返回{}做兼容
|
|
82
|
+
if (!data || isEqual(data,{})) {
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
let result: any = {};
|
|
86
|
+
for (const key in data) {
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if (key === 'properties') {
|
|
91
|
+
result[key] = this.compileProperties(
|
|
92
|
+
data[key],
|
|
93
|
+
data['required'] ?? []
|
|
94
|
+
);
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
if (key === 'items') {
|
|
98
|
+
if('format' in data && data['format'] === 'date-time'){
|
|
99
|
+
result[key] = data[key]
|
|
100
|
+
}else{
|
|
101
|
+
result = Object.assign(
|
|
102
|
+
{},
|
|
103
|
+
result,
|
|
104
|
+
this.compileItems(data[key])
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// 对formily协议的字段保持原封不动
|
|
109
|
+
if (FORMILY_KEYS.includes(key) || key.indexOf('x-') !== -1 || FORMILY_EXPAND_KEYS.includes(key)) {
|
|
110
|
+
result[key] = data[key];
|
|
111
|
+
} else if (key.indexOf('ui:') !== -1) {
|
|
112
|
+
// 处理 VJSF ui:xxxx 字段
|
|
113
|
+
if (key === 'ui:options') {
|
|
114
|
+
if (data['ui:widget'] === 'hot-area' && 'event' in data['ui:options']) {
|
|
115
|
+
data['ui:options'].options = data['ui:options'].event?.properties?.list?.items?.properties?.handler?.properties?.name?.enum;
|
|
116
|
+
data['ui:options'].event = JSON.stringify(data['ui:options'].event);
|
|
117
|
+
}
|
|
118
|
+
this.setComponentProps(result, { ...data['ui:options'] });
|
|
119
|
+
} else if (key === 'ui:hidden') {
|
|
120
|
+
result['x-hidden'] = data[key];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (key === 'unique') {
|
|
124
|
+
result[key] = data[key];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// 处理enum
|
|
128
|
+
if ('enum' in data) {
|
|
129
|
+
result['enum'] = emitEnum(data['enum'], data['enumNames'] ?? []);
|
|
130
|
+
}
|
|
131
|
+
// 处理 x-component
|
|
132
|
+
if (!result['x-component']) {
|
|
133
|
+
result['x-component'] = getComponentName(data);
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 处理 x-decorator
|
|
138
|
+
if(!data['x-decorator'] && data['type']!== 'void'){
|
|
139
|
+
result['x-decorator'] = 'FormItem';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 处理oneOf
|
|
143
|
+
if (isOneOf(data)) {
|
|
144
|
+
this.setComponentProps(result, {
|
|
145
|
+
list: '[]', // 初始为空
|
|
146
|
+
title: data.title,
|
|
147
|
+
});
|
|
148
|
+
result['title'] = '';
|
|
149
|
+
}
|
|
150
|
+
// 处理 anyOf
|
|
151
|
+
if (isAnyOf(data)) {
|
|
152
|
+
this.setComponentProps(result, {
|
|
153
|
+
list: JSON.stringify(data.anyOf ?? []),
|
|
154
|
+
title: data.title,
|
|
155
|
+
'@fileUpload': (file, done) => {
|
|
156
|
+
this.state.ctx.emit('fileUpload', file, done);
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
result['title'] = '';
|
|
160
|
+
|
|
161
|
+
// 设置anyof 为必填项
|
|
162
|
+
result['required'] = result['required'] ?? true;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
//处理Title 并且把FormItem装饰器去掉
|
|
166
|
+
// todo 去掉x-decorator跟布局有关
|
|
167
|
+
if (['HotArea','CloudButton','InformationConfig','Qa'].includes(result['x-component'])) {
|
|
168
|
+
result['title'] = '';
|
|
169
|
+
result['x-decorator'] = null;
|
|
170
|
+
}
|
|
171
|
+
// 处理 format 额外参数
|
|
172
|
+
// if (data['format']) {
|
|
173
|
+
// if (data['format'] === 'color') {
|
|
174
|
+
// this.setComponentProps(result, { inputType: 'color' });
|
|
175
|
+
// }
|
|
176
|
+
// }
|
|
177
|
+
// if (data['ui:widget'] && data['ui:widget'] === 'el-color-picker') {
|
|
178
|
+
// this.setComponentProps(result, { inputType: 'color' });
|
|
179
|
+
// }
|
|
180
|
+
// 处理FormItem布局
|
|
181
|
+
this.setDecoratorProps(result);
|
|
182
|
+
// Event
|
|
183
|
+
this.setComponentProps(result, this.compileEvent(data));
|
|
184
|
+
|
|
185
|
+
if (result['x-component'] === 'Select') {
|
|
186
|
+
this.setComponentProps(result, { options: result['enum'] ?? [] });
|
|
187
|
+
|
|
188
|
+
// 如果不存在title 存在 inlineTitle 就设置prefix
|
|
189
|
+
if(!data['title'] && !!data?.inlineTitle){
|
|
190
|
+
this.setComponentProps(result,{ prefix: data?.inlineTitle})
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else if(result['x-component']==='UploadButton'){
|
|
194
|
+
if(result['title']&&result['title'].indexOf('背景图片')=== -1){
|
|
195
|
+
this.setComponentProps(result, { title:'替换图片' });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
// 编译 items字段
|
|
201
|
+
compileItems(data: any) {
|
|
202
|
+
// 如果items 存在 OneOf 直接编译成Select
|
|
203
|
+
if (isOneOf(data)) {
|
|
204
|
+
return {
|
|
205
|
+
enum: oneOfTransformEnum(data.oneOf),
|
|
206
|
+
'x-component': 'Select',
|
|
207
|
+
'x-component-props': {
|
|
208
|
+
'value-key': 'name',
|
|
209
|
+
multiple: true,
|
|
210
|
+
'collapse-tags': true,
|
|
211
|
+
},
|
|
212
|
+
'x-decorator': 'FormItem',
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
// 不存在properties, 说明是非对象数组
|
|
216
|
+
const xData = getXData(data) || {};
|
|
217
|
+
if (!('properties' in data)) {
|
|
218
|
+
// 不存在properties
|
|
219
|
+
return {
|
|
220
|
+
items: {
|
|
221
|
+
// properties: {
|
|
222
|
+
// input1: { ...simpleGenerationSchemaItem(data) },
|
|
223
|
+
// },
|
|
224
|
+
// type: 'void',
|
|
225
|
+
...simpleGenerationSchemaItem(data)
|
|
226
|
+
},
|
|
227
|
+
properties: {
|
|
228
|
+
add: {
|
|
229
|
+
type: 'void',
|
|
230
|
+
title:xData?.addButtonTitle ? xData?.addButtonTitle : '添加条目',
|
|
231
|
+
'x-component': 'ArrayItems.Addition',
|
|
232
|
+
'x-component-props': {
|
|
233
|
+
type: xData?.addButtonType || 'primary',
|
|
234
|
+
size: xData?.addButtonSize || 'default',
|
|
235
|
+
plain: xData?.addButtonPlain || false,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
// 处理对象数组
|
|
242
|
+
const result: any = {};
|
|
243
|
+
|
|
244
|
+
for (const key in data) {
|
|
245
|
+
if (key === 'properties') {
|
|
246
|
+
result[key] = this.compileProperties(
|
|
247
|
+
data[key],
|
|
248
|
+
data['required'] ?? []
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
if (COMMON_KEYS.includes(key)) {
|
|
252
|
+
result[key] = data[key];
|
|
253
|
+
}
|
|
254
|
+
if (FIELD_KEYS.includes(key)) {
|
|
255
|
+
result[FIELD_MAP[key]] = data[key];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if(!result?.type){
|
|
259
|
+
result['type'] = 'object'
|
|
260
|
+
}
|
|
261
|
+
if (!result?.required) {
|
|
262
|
+
result['required'] = data['required']
|
|
263
|
+
}
|
|
264
|
+
const listRes: any = { items: { ...result } };
|
|
265
|
+
// if (data['properties']) {
|
|
266
|
+
listRes['properties'] = {
|
|
267
|
+
add: {
|
|
268
|
+
type: 'void',
|
|
269
|
+
title: getXData(data)?.addButtonTitle ? getXData(data)?.addButtonTitle : '添加条目',
|
|
270
|
+
'x-component': 'ArrayItems.Addition',
|
|
271
|
+
'x-component-props':{
|
|
272
|
+
type: getXData(data)?.addButtonType || 'primary',
|
|
273
|
+
size: getXData(data)?.addButtonSize || 'default',
|
|
274
|
+
plain: getXData(data)?.addButtonPlain || false,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
// }
|
|
279
|
+
|
|
280
|
+
return listRes;
|
|
281
|
+
}
|
|
282
|
+
// 编译Properties
|
|
283
|
+
compileProperties(data: any, requireds: string[]) {
|
|
284
|
+
let result: any = {};
|
|
285
|
+
// Properties 是 item 的集合, 循环去编译item就可以
|
|
286
|
+
for (const key in data) {
|
|
287
|
+
if(!isSchemaConfig(data[key])){
|
|
288
|
+
result[key] = data[key]
|
|
289
|
+
} else if (key === 'event' && data[key]?.properties?.list) {
|
|
290
|
+
result[key] = {
|
|
291
|
+
type: 'object',
|
|
292
|
+
'x-component': 'Event',
|
|
293
|
+
'x-component-props': {
|
|
294
|
+
schema: JSON.stringify(data[key]?.properties ?? {}),
|
|
295
|
+
options: data[key]?.properties?.list?.items?.properties?.handler?.properties?.name?.enum,
|
|
296
|
+
...this.compileEvent(data,'Event')
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
} else {
|
|
300
|
+
// 编译properties的每一个item
|
|
301
|
+
result[key] = this.compileItem(data[key]);
|
|
302
|
+
// 如果是必填项,添加必填的属性
|
|
303
|
+
if (Array.isArray(requireds) && requireds.includes(key)) {
|
|
304
|
+
result[key]['required'] = true;
|
|
305
|
+
}
|
|
306
|
+
// 埋点添加unique
|
|
307
|
+
if(key === 'buryReportName'){
|
|
308
|
+
result[key]['unique'] = UniqueType.page;
|
|
309
|
+
result[key]['required']= true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if(key.indexOf('group') > -1){
|
|
313
|
+
this.existGroup = true;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** 编译自定义组件事件(非双向数据绑定事件),
|
|
320
|
+
* */
|
|
321
|
+
compileEvent(data: any, componentName?:string) {
|
|
322
|
+
const _componentName: String = componentName || getComponentName(data);
|
|
323
|
+
// todo 这里将来要优化一下,直接在组件内部将事件抛到最外层,现在要一层一层的透传出去
|
|
324
|
+
// 处理公共事件
|
|
325
|
+
const result = {};
|
|
326
|
+
result['@getData'] = (cmdname:string, done:any,cmdParams)=>{
|
|
327
|
+
this.state.ctx.emit('getData',cmdname,done,cmdParams);
|
|
328
|
+
}
|
|
329
|
+
// 处理不同组件的事件
|
|
330
|
+
switch (_componentName) {
|
|
331
|
+
case 'Event':
|
|
332
|
+
result['@fileUpload']=(file,done,config)=>{
|
|
333
|
+
// Event事件也要往外抛
|
|
334
|
+
this.state.ctx.emit('fileUpload',file,done,config);
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
case 'AnyOf':
|
|
338
|
+
result['@fileUpload']=(file,done,config)=>{
|
|
339
|
+
// Anyof事件也要往外抛
|
|
340
|
+
this.state.ctx.emit('fileUpload',file,done,config);
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
case COMPONENT_MAP.UploadWidget:
|
|
344
|
+
result['@fileUpload']=(file: any, done: any) => {
|
|
345
|
+
this.state.ctx.emit('fileUpload',file,done,data);
|
|
346
|
+
if (this.state.ctx.type?.name === 'HotArea') {
|
|
347
|
+
this.state.ctx?.exposed?.getUploadImageUrl(file,done);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
case 'CloudButton':
|
|
352
|
+
result['@openCloud']=(params,done) => {
|
|
353
|
+
this.state.ctx.emit('openCloud',{ data: params, config: data },done);
|
|
354
|
+
}
|
|
355
|
+
result['@preload']=(url)=>{
|
|
356
|
+
this.state.ctx.emit('preloadCloud',url);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
// 设置包装器的参数
|
|
362
|
+
setDecoratorProps(data: any) {
|
|
363
|
+
let decoratorProps: any = {};
|
|
364
|
+
if (data['x-component'] === 'Switch') {
|
|
365
|
+
decoratorProps['wrapperAlign'] = 'right';
|
|
366
|
+
decoratorProps['labelAlign'] = 'left';
|
|
367
|
+
} else {
|
|
368
|
+
decoratorProps['layout'] = data?.['x-decorator-props']?.layout || this.state.layout || 'vertical';
|
|
369
|
+
decoratorProps['labelAlign'] = 'left';
|
|
370
|
+
decoratorProps['labelWrap'] = true;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (data?.description) {
|
|
374
|
+
if (data['x-component'] === 'Input') {
|
|
375
|
+
this.setComponentProps(data,{ toolTip: data['description']})
|
|
376
|
+
} else {
|
|
377
|
+
decoratorProps['tooltip'] = data['description'];
|
|
378
|
+
}
|
|
379
|
+
delete data['description'];
|
|
380
|
+
}
|
|
381
|
+
// 显示星号
|
|
382
|
+
if('asterisk' in data && data['asterisk']){
|
|
383
|
+
decoratorProps['asterisk'] = true
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
data['x-decorator-props'] = Object.assign(
|
|
387
|
+
{},
|
|
388
|
+
data['x-decorator-props'] ?? {},
|
|
389
|
+
decoratorProps
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
// 设置组件的参数
|
|
393
|
+
setComponentProps(data: any, _props: any = {}) {
|
|
394
|
+
const componentProps: any = {};
|
|
395
|
+
for (const key in _props) {
|
|
396
|
+
componentProps[key] = _props[key];
|
|
397
|
+
}
|
|
398
|
+
data['x-component-props'] = Object.assign(
|
|
399
|
+
{},
|
|
400
|
+
data['x-component-props'] ?? {},
|
|
401
|
+
componentProps
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
}
|