form-designer-xinyi 1.0.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/.eslintrc.js +10 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +6 -0
- package/LICENSE +21 -0
- package/README.md +236 -0
- package/docs/.vitepress/config.ts +158 -0
- package/docs/.vitepress/theme/custom.css +38 -0
- package/docs/.vitepress/theme/index.ts +7 -0
- package/docs/.vitepress/theme/style.css +36 -0
- package/docs/guide/about/about.md +25 -0
- package/docs/guide/action/customFunctions.md +560 -0
- package/docs/guide/action/publicMethods.md +25 -0
- package/docs/guide/components/EBuilder.md +544 -0
- package/docs/guide/components/EDesigner.md +117 -0
- package/docs/guide/extensions/actionBar.md +55 -0
- package/docs/guide/extensions/component.md +113 -0
- package/docs/guide/extensions/icon.md +41 -0
- package/docs/guide/extensions/rightSidebar.md +57 -0
- package/docs/guide/start/dark-mode.md +149 -0
- package/docs/guide/start/i18n-cn.md +39 -0
- package/docs/guide/start/index.md +59 -0
- package/docs/guide/start/layoutGuide.md +0 -0
- package/docs/guide/start/quick-start.md +179 -0
- package/docs/guide/start/theme.md +122 -0
- package/docs/guide/utils/pageManager.md +97 -0
- package/docs/guide/utils/pluginManager.md +227 -0
- package/docs/index.md +41 -0
- package/docs/package.json +14 -0
- package/docs/public/dark.png +0 -0
- package/docs/public/favicon.ico +0 -0
- package/docs/public/icons/demo.css +539 -0
- package/docs/public/icons/demo_index.html +589 -0
- package/docs/public/icons/iconfont.css +379 -0
- package/docs/public/icons/iconfont.js +1 -0
- package/docs/public/icons/iconfont.json +646 -0
- package/docs/public/icons/iconfont.ttf +0 -0
- package/docs/public/icons/iconfont.woff +0 -0
- package/docs/public/icons/iconfont.woff2 +0 -0
- package/docs/public/layout.jpg +0 -0
- package/docs/public/logo.png +0 -0
- package/docs/public/theme.jpg +0 -0
- package/docs/updateLog.md +364 -0
- package/docs/vite.config.ts +18 -0
- package/docs//345/210/235/345/247/213/345/214/226/345/270/203/345/261/200.jpg +0 -0
- package/docs//350/256/276/350/256/241/345/231/250/344/273/213/347/273/215.md +21 -0
- package/docs//350/256/276/350/256/241/345/231/250/345/270/203/345/261/200.jpg +0 -0
- package/examples/README.md +18 -0
- package/examples/index.html +13 -0
- package/examples/package.json +27 -0
- package/examples/public/favicon.ico +0 -0
- package/examples/src/App.vue +5 -0
- package/examples/src/assets/logo.png +0 -0
- package/examples/src/layout/baseLayout.vue +3 -0
- package/examples/src/layout/components/Header/index.vue +102 -0
- package/examples/src/layout/components/Main/Maximize.vue +77 -0
- package/examples/src/layout/components/Main/index.vue +16 -0
- package/examples/src/layout/components/Menu/index.vue +49 -0
- package/examples/src/layout/index.vue +26 -0
- package/examples/src/main.ts +6 -0
- package/examples/src/router/index.ts +98 -0
- package/examples/src/style/reset.css +253 -0
- package/examples/src/style.less +44 -0
- package/examples/src/views/builder/basic/index.vue +182 -0
- package/examples/src/views/builder/disableDisplay/index.vue +153 -0
- package/examples/src/views/builder/disableDisplay copy/index.vue +111 -0
- package/examples/src/views/builder/loadData/index.vue +195 -0
- package/examples/src/views/builder/sum/index.vue +127 -0
- package/examples/src/views/designer/basic/index.vue +22 -0
- package/examples/src/views/designer/loadData/index.vue +186 -0
- package/examples/src/vite-env.d.ts +1 -0
- package/examples/tsconfig.json +27 -0
- package/examples/tsconfig.node.json +10 -0
- package/examples/vite.config.ts +28 -0
- package/package.json +44 -0
- package/packages/core/LICENSE +21 -0
- package/packages/core/components/asyncLoader/index.less +92 -0
- package/packages/core/components/asyncLoader/index.vue +7 -0
- package/packages/core/components/builder/index.ts +3 -0
- package/packages/core/components/builder/src/builder.vue +217 -0
- package/packages/core/components/builder/src/types.ts +4 -0
- package/packages/core/components/designer/index.ts +3 -0
- package/packages/core/components/designer/src/designer.vue +258 -0
- package/packages/core/components/designer/src/index.less +81 -0
- package/packages/core/components/designer/src/modules/actionBar/index.less +79 -0
- package/packages/core/components/designer/src/modules/actionBar/index.vue +44 -0
- package/packages/core/components/designer/src/modules/attributeView/attributeView.vue +104 -0
- package/packages/core/components/designer/src/modules/attributeView/eventView.vue +76 -0
- package/packages/core/components/designer/src/modules/attributeView/index.less +36 -0
- package/packages/core/components/designer/src/modules/attributeView/styleView.vue +103 -0
- package/packages/core/components/designer/src/modules/componentView/index.less +52 -0
- package/packages/core/components/designer/src/modules/componentView/index.vue +118 -0
- package/packages/core/components/designer/src/modules/editContainer/editNodeItem.vue +74 -0
- package/packages/core/components/designer/src/modules/editContainer/editScreenContainer.vue +142 -0
- package/packages/core/components/designer/src/modules/editContainer/index.less +129 -0
- package/packages/core/components/designer/src/modules/editContainer/index.vue +37 -0
- package/packages/core/components/designer/src/modules/editContainer/nodeItem.vue +91 -0
- package/packages/core/components/designer/src/modules/editContainer/previewJson.vue +61 -0
- package/packages/core/components/designer/src/modules/editContainer/previewWidgets.vue +373 -0
- package/packages/core/components/designer/src/modules/editContainer/toolbar.vue +248 -0
- package/packages/core/components/designer/src/modules/header/index.less +16 -0
- package/packages/core/components/designer/src/modules/header/index.vue +60 -0
- package/packages/core/components/designer/src/modules/outline/index.less +7 -0
- package/packages/core/components/designer/src/modules/outline/outline.vue +39 -0
- package/packages/core/components/designer/src/modules/preview/index.less +0 -0
- package/packages/core/components/designer/src/modules/preview/index.vue +71 -0
- package/packages/core/components/designer/src/modules/rightSidebar/breadcrumb.vue +30 -0
- package/packages/core/components/designer/src/modules/rightSidebar/index.less +75 -0
- package/packages/core/components/designer/src/modules/rightSidebar/index.vue +58 -0
- package/packages/core/components/designer/src/modules/sourceCode/index.less +7 -0
- package/packages/core/components/designer/src/modules/sourceCode/index.vue +34 -0
- package/packages/core/components/designer/src/types.ts +9 -0
- package/packages/core/components/icon/index.ts +2 -0
- package/packages/core/components/icon/src/icon.vue +15 -0
- package/packages/core/components/node/index.ts +2 -0
- package/packages/core/components/node/src/node.vue +350 -0
- package/packages/core/components/tree/index.ts +2 -0
- package/packages/core/components/tree/src/index.less +106 -0
- package/packages/core/components/tree/src/tree.vue +113 -0
- package/packages/core/components/tree/src/treeNodeItem.vue +87 -0
- package/packages/core/components/tree/src/treeNodes.vue +68 -0
- package/packages/core/extensions/EActionEditor/index.less +172 -0
- package/packages/core/extensions/EActionEditor/index.vue +160 -0
- package/packages/core/extensions/EActionEditor/src/EActionEditorItem.vue +133 -0
- package/packages/core/extensions/EActionEditor/src/EActionModal.vue +258 -0
- package/packages/core/extensions/EActionEditor/src/EArgsEditor.vue +61 -0
- package/packages/core/extensions/EActionEditor/src/EScriptEdit.vue +26 -0
- package/packages/core/extensions/EColEditor/index.less +24 -0
- package/packages/core/extensions/EColEditor/index.vue +65 -0
- package/packages/core/extensions/EInputSize/index.vue +59 -0
- package/packages/core/extensions/EOptionsEditor/index.vue +52 -0
- package/packages/core/extensions/EOptionsEditor/optionItem.vue +72 -0
- package/packages/core/extensions/ERuleEditor/ERuleItem.vue +137 -0
- package/packages/core/extensions/ERuleEditor/data.ts +24 -0
- package/packages/core/extensions/ERuleEditor/index.less +17 -0
- package/packages/core/extensions/ERuleEditor/index.vue +154 -0
- package/packages/core/extensions/ERuleEditor/types.ts +17 -0
- package/packages/core/extensions/MonacoEditor/index.ts +31 -0
- package/packages/core/extensions/MonacoEditor/index.vue +147 -0
- package/packages/core/extensions/Page/index.ts +23 -0
- package/packages/core/extensions/Page/index.vue +27 -0
- package/packages/core/extensions/index.ts +73 -0
- package/packages/core/index.less +27 -0
- package/packages/core/index.ts +35 -0
- package/packages/core/package.json +59 -0
- package/packages/core/static/icons/demo.css +539 -0
- package/packages/core/static/icons/demo_index.html +2281 -0
- package/packages/core/static/icons/iconfont.css +372 -0
- package/packages/core/static/icons/iconfont.js +1 -0
- package/packages/core/static/icons/iconfont.json +646 -0
- package/packages/core/static/icons/iconfont.ttf +0 -0
- package/packages/core/static/icons/iconfont.woff +0 -0
- package/packages/core/static/icons/iconfont.woff2 +0 -0
- package/packages/core/static/logo.png +0 -0
- package/packages/core/theme/var.less +175 -0
- package/packages/core/tsconfig.json +19 -0
- package/packages/core/types/epic-designer.ts +75 -0
- package/packages/epic-designer/.babelrc +9 -0
- package/packages/epic-designer/.eslintrc.cjs +76 -0
- package/packages/epic-designer/LICENSE +21 -0
- package/packages/epic-designer/README.md +239 -0
- package/packages/epic-designer/index.ts +13 -0
- package/packages/epic-designer/package.json +75 -0
- package/packages/epic-designer/shims-vue.d.ts +4 -0
- package/packages/epic-designer/tsconfig.json +19 -0
- package/packages/epic-designer/uno.config.ts +79 -0
- package/packages/script/package.json +17 -0
- package/packages/script/src/check-compiled.ts +22 -0
- package/packages/script/tsconfig.json +10 -0
- package/packages/ui/LICENSE +21 -0
- package/packages/ui/antd/button/button.vue +16 -0
- package/packages/ui/antd/button/index.ts +202 -0
- package/packages/ui/antd/card/card.ts +31 -0
- package/packages/ui/antd/card/index.ts +63 -0
- package/packages/ui/antd/cascader/cascader.vue +23 -0
- package/packages/ui/antd/cascader/index.ts +197 -0
- package/packages/ui/antd/checkbox/index.ts +99 -0
- package/packages/ui/antd/col/col.ts +31 -0
- package/packages/ui/antd/col/index.ts +22 -0
- package/packages/ui/antd/color-picker/index.ts +107 -0
- package/packages/ui/antd/date-picker/datePicker.ts +47 -0
- package/packages/ui/antd/date-picker/index.ts +302 -0
- package/packages/ui/antd/form/form.vue +118 -0
- package/packages/ui/antd/form/index.ts +195 -0
- package/packages/ui/antd/form-item/formItem.vue +15 -0
- package/packages/ui/antd/form-item/index.ts +11 -0
- package/packages/ui/antd/formLogic/actionEdit.vue +72 -0
- package/packages/ui/antd/formLogic/actionItem.vue +46 -0
- package/packages/ui/antd/formLogic/conditionEdit.vue +111 -0
- package/packages/ui/antd/formLogic/conditionItem.vue +150 -0
- package/packages/ui/antd/formLogic/drawer.vue +124 -0
- package/packages/ui/antd/formLogic/formLogic.vue +33 -0
- package/packages/ui/antd/formLogic/index.ts +11 -0
- package/packages/ui/antd/formLogic/types.ts +25 -0
- package/packages/ui/antd/index.less +33 -0
- package/packages/ui/antd/index.ts +323 -0
- package/packages/ui/antd/input/index.ts +169 -0
- package/packages/ui/antd/input-number/index.ts +181 -0
- package/packages/ui/antd/input-password/index.ts +152 -0
- package/packages/ui/antd/modal/index.ts +19 -0
- package/packages/ui/antd/modal/modal.vue +82 -0
- package/packages/ui/antd/radio/index.ts +105 -0
- package/packages/ui/antd/row/index.ts +114 -0
- package/packages/ui/antd/row/row.ts +31 -0
- package/packages/ui/antd/select/index.ts +228 -0
- package/packages/ui/antd/slider/index.ts +142 -0
- package/packages/ui/antd/switch/index.ts +141 -0
- package/packages/ui/antd/textarea/index.ts +162 -0
- package/packages/ui/antd/time-picker/index.ts +189 -0
- package/packages/ui/antd/upload-file/index.ts +88 -0
- package/packages/ui/antd/upload-file/uploadFile.ts +117 -0
- package/packages/ui/antd/upload-image/index.ts +69 -0
- package/packages/ui/antd/upload-image/uploadImage.vue +148 -0
- package/packages/ui/elementPlus/button/button.ts +25 -0
- package/packages/ui/elementPlus/button/index.ts +128 -0
- package/packages/ui/elementPlus/card/card.ts +36 -0
- package/packages/ui/elementPlus/card/index.ts +50 -0
- package/packages/ui/elementPlus/cascader/index.ts +216 -0
- package/packages/ui/elementPlus/checkbox/checkbox.ts +31 -0
- package/packages/ui/elementPlus/checkbox/index.ts +140 -0
- package/packages/ui/elementPlus/col/col.ts +31 -0
- package/packages/ui/elementPlus/col/index.ts +21 -0
- package/packages/ui/elementPlus/collapse/collapse.ts +32 -0
- package/packages/ui/elementPlus/collapse/index.ts +41 -0
- package/packages/ui/elementPlus/collapse-item/collapseItem.ts +31 -0
- package/packages/ui/elementPlus/collapse-item/index.ts +12 -0
- package/packages/ui/elementPlus/color-picker/index.ts +110 -0
- package/packages/ui/elementPlus/date-picker/index.ts +218 -0
- package/packages/ui/elementPlus/form/form.vue +99 -0
- package/packages/ui/elementPlus/form/index.ts +147 -0
- package/packages/ui/elementPlus/formItem/formItem.vue +15 -0
- package/packages/ui/elementPlus/formItem/index.ts +11 -0
- package/packages/ui/elementPlus/index.less +79 -0
- package/packages/ui/elementPlus/index.ts +84 -0
- package/packages/ui/elementPlus/input/index.ts +179 -0
- package/packages/ui/elementPlus/input-number/index.ts +145 -0
- package/packages/ui/elementPlus/modal/index.ts +18 -0
- package/packages/ui/elementPlus/modal/modal.ts +68 -0
- package/packages/ui/elementPlus/radio/index.ts +121 -0
- package/packages/ui/elementPlus/radio/radio.ts +32 -0
- package/packages/ui/elementPlus/row/index.ts +105 -0
- package/packages/ui/elementPlus/row/row.ts +32 -0
- package/packages/ui/elementPlus/select/index.ts +283 -0
- package/packages/ui/elementPlus/select/select.ts +31 -0
- package/packages/ui/elementPlus/slider/index.ts +237 -0
- package/packages/ui/elementPlus/switch/index.ts +159 -0
- package/packages/ui/elementPlus/textarea/index.ts +154 -0
- package/packages/ui/elementPlus/upload-file/index.ts +86 -0
- package/packages/ui/elementPlus/upload-file/uploadFile.ts +114 -0
- package/packages/ui/elementPlus/upload-image/index.ts +86 -0
- package/packages/ui/elementPlus/upload-image/uploadImage.ts +151 -0
- package/packages/ui/hooks/index.ts +1 -0
- package/packages/ui/hooks/logic.ts +129 -0
- package/packages/ui/index.ts +22 -0
- package/packages/ui/naiveUi/button/button.ts +25 -0
- package/packages/ui/naiveUi/button/index.ts +146 -0
- package/packages/ui/naiveUi/card/card.ts +32 -0
- package/packages/ui/naiveUi/card/index.ts +25 -0
- package/packages/ui/naiveUi/cascader/index.ts +218 -0
- package/packages/ui/naiveUi/checkbox/checkbox.ts +27 -0
- package/packages/ui/naiveUi/checkbox/index.ts +114 -0
- package/packages/ui/naiveUi/col/col.ts +30 -0
- package/packages/ui/naiveUi/col/index.ts +21 -0
- package/packages/ui/naiveUi/collapse/collapse.ts +31 -0
- package/packages/ui/naiveUi/collapse/index.ts +40 -0
- package/packages/ui/naiveUi/collapse-item/collapseItem.ts +31 -0
- package/packages/ui/naiveUi/collapse-item/index.ts +12 -0
- package/packages/ui/naiveUi/color-picker/index.ts +179 -0
- package/packages/ui/naiveUi/date-picker/index.ts +210 -0
- package/packages/ui/naiveUi/form/form.vue +85 -0
- package/packages/ui/naiveUi/form/index.ts +141 -0
- package/packages/ui/naiveUi/form-item/formItem.vue +15 -0
- package/packages/ui/naiveUi/form-item/index.ts +10 -0
- package/packages/ui/naiveUi/index.less +33 -0
- package/packages/ui/naiveUi/index.ts +80 -0
- package/packages/ui/naiveUi/input/index.ts +215 -0
- package/packages/ui/naiveUi/input-number/index.ts +141 -0
- package/packages/ui/naiveUi/modal/index.ts +18 -0
- package/packages/ui/naiveUi/modal/modal.ts +83 -0
- package/packages/ui/naiveUi/radio/index.ts +94 -0
- package/packages/ui/naiveUi/radio/radio.ts +27 -0
- package/packages/ui/naiveUi/row/index.ts +105 -0
- package/packages/ui/naiveUi/row/row.ts +31 -0
- package/packages/ui/naiveUi/select/index.ts +193 -0
- package/packages/ui/naiveUi/slider/index.ts +181 -0
- package/packages/ui/naiveUi/switch/index.ts +133 -0
- package/packages/ui/naiveUi/upload-file/index.ts +82 -0
- package/packages/ui/naiveUi/upload-file/uploadFile.ts +78 -0
- package/packages/ui/naiveUi/upload-image/index.ts +82 -0
- package/packages/ui/naiveUi/upload-image/uploadImage.ts +152 -0
- package/packages/ui/package.json +18 -0
- package/packages/ui/tsconfig.json +19 -0
- package/packages/utils/LICENSE +21 -0
- package/packages/utils/common/common.ts +18 -0
- package/packages/utils/common/component.ts +22 -0
- package/packages/utils/common/data.ts +682 -0
- package/packages/utils/common/element.ts +166 -0
- package/packages/utils/common/index.ts +6 -0
- package/packages/utils/common/string.ts +18 -0
- package/packages/utils/common/theme.ts +84 -0
- package/packages/utils/index.ts +3 -0
- package/packages/utils/manager/index.ts +3 -0
- package/packages/utils/manager/pageManager.ts +157 -0
- package/packages/utils/manager/pluginManager.ts +586 -0
- package/packages/utils/manager/revoke.ts +128 -0
- package/packages/utils/package.json +7 -0
- package/packages/utils/shareStore/index.ts +30 -0
- package/packages/utils/tsconfig.json +19 -0
- package/packages/utils/vite.config.ts +39 -0
- package/pnpm-workspace.yaml +5 -0
- package/turbo.json +20 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ComponentConfigModel } from "@epic-designer/utils";
|
|
2
|
+
export default {
|
|
3
|
+
component: () => import("./uploadFile"),
|
|
4
|
+
groupName: "表单",
|
|
5
|
+
icon: "epic-icon-upload",
|
|
6
|
+
defaultSchema: {
|
|
7
|
+
label: "上传文件",
|
|
8
|
+
type: "upload-file",
|
|
9
|
+
field: "uploadFile",
|
|
10
|
+
input: true,
|
|
11
|
+
componentProps: {
|
|
12
|
+
action: "https://epic.kcz66.com/static/upload-img.json",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
config: {
|
|
16
|
+
attribute: [
|
|
17
|
+
{
|
|
18
|
+
label: "字段名",
|
|
19
|
+
type: "input",
|
|
20
|
+
field: "field",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "标题",
|
|
24
|
+
type: "input",
|
|
25
|
+
field: "label",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "请求地址",
|
|
29
|
+
type: "input",
|
|
30
|
+
field: "componentProps.action",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "上传文件字段",
|
|
34
|
+
type: "input",
|
|
35
|
+
field: "componentProps.name",
|
|
36
|
+
componentProps: {
|
|
37
|
+
placeholder: "请输入",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "允许上传最大数量",
|
|
42
|
+
type: "number",
|
|
43
|
+
field: "componentProps.max",
|
|
44
|
+
componentProps: {
|
|
45
|
+
min: 0,
|
|
46
|
+
placeholder: "请输入",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: "展示文件列表",
|
|
51
|
+
type: "switch",
|
|
52
|
+
field: "componentProps.showFileList",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "多选",
|
|
56
|
+
type: "switch",
|
|
57
|
+
field: "componentProps.multiple",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: "禁用",
|
|
61
|
+
type: "switch",
|
|
62
|
+
field: "componentProps.disabled",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "隐藏",
|
|
66
|
+
type: "switch",
|
|
67
|
+
field: "componentProps.hidden",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: "表单校验",
|
|
71
|
+
type: "ERuleEditor",
|
|
72
|
+
layout: "vertical",
|
|
73
|
+
field: "rules",
|
|
74
|
+
describe: "校验规则需要配合表单使用",
|
|
75
|
+
componentProps: {
|
|
76
|
+
ruleType: "array",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
bindModel: "modelValue",
|
|
82
|
+
} as ComponentConfigModel;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type PropType, defineComponent, h, nextTick, ref, watch } from 'vue'
|
|
2
|
+
import { NUpload, NButton } from 'naive-ui'
|
|
3
|
+
import type { UploadFileInfo } from 'naive-ui'
|
|
4
|
+
import { type OnFinish, type OnError } from 'naive-ui/es/upload/src/interface'
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: Array as PropType<UploadFileInfo []>,
|
|
10
|
+
default: () => []
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
emits: ['update:modelValue'],
|
|
14
|
+
setup (props, { emit, attrs }) {
|
|
15
|
+
const fileList = ref<UploadFileInfo[]>([])
|
|
16
|
+
watch(fileList, (e) => {
|
|
17
|
+
emit('update:modelValue', e)
|
|
18
|
+
})
|
|
19
|
+
// 处理传递进来的值
|
|
20
|
+
watch(
|
|
21
|
+
() => props.modelValue,
|
|
22
|
+
(e) => {
|
|
23
|
+
if ((e != null) && e.length > 0 && (fileList.value != null)) {
|
|
24
|
+
// props modelValue 等于 data 不进行处理
|
|
25
|
+
if (fileList.value === e) return
|
|
26
|
+
fileList.value.length = 0
|
|
27
|
+
fileList.value.push(...e)
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{ deep: true, immediate: true }
|
|
31
|
+
)
|
|
32
|
+
function handleUpdate (e: UploadFileInfo[]): void {
|
|
33
|
+
console.log('onChange called->', e)
|
|
34
|
+
nextTick(() => { fileList.value = e })
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const handleError: OnError = ({ file, event }) => {
|
|
38
|
+
console.log('OnError called->', file, event)
|
|
39
|
+
}
|
|
40
|
+
const handleSuccess: OnFinish = ({ file, event }) => {
|
|
41
|
+
console.log('OnFinish called->', file, event)
|
|
42
|
+
const resInfo = event?.target as any
|
|
43
|
+
const resData = JSON.parse(resInfo.response ?? '{}')
|
|
44
|
+
file.url = resData.data?.url
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
return h('div', null, {
|
|
49
|
+
default: () => [
|
|
50
|
+
h(NUpload, {
|
|
51
|
+
...attrs,
|
|
52
|
+
'onUpdate:file-list': handleUpdate,
|
|
53
|
+
"file-list": fileList.value,
|
|
54
|
+
onError: handleError,
|
|
55
|
+
onFinish: handleSuccess,
|
|
56
|
+
'default-upload': true
|
|
57
|
+
}, {
|
|
58
|
+
default: () => [
|
|
59
|
+
h(
|
|
60
|
+
NButton,
|
|
61
|
+
{},
|
|
62
|
+
{
|
|
63
|
+
default: () => [
|
|
64
|
+
h('span', {
|
|
65
|
+
class: 'iconfont epic-icon-shangchuan1',
|
|
66
|
+
style: { 'margin-right': '2px' }
|
|
67
|
+
}),
|
|
68
|
+
h('span', null, { default: () => '上传文件' })
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
})
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ComponentConfigModel } from "@epic-designer/utils";
|
|
2
|
+
export default {
|
|
3
|
+
component: () => import("./uploadImage"),
|
|
4
|
+
groupName: "表单",
|
|
5
|
+
icon: "epic-icon-image",
|
|
6
|
+
defaultSchema: {
|
|
7
|
+
label: "上传图片",
|
|
8
|
+
type: "upload-image",
|
|
9
|
+
field: "uploadImage",
|
|
10
|
+
input: true,
|
|
11
|
+
componentProps: {
|
|
12
|
+
action: "https://epic.kcz66.com/static/upload-img.json",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
config: {
|
|
16
|
+
attribute: [
|
|
17
|
+
{
|
|
18
|
+
label: "字段名",
|
|
19
|
+
type: "input",
|
|
20
|
+
field: "field",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "标题",
|
|
24
|
+
type: "input",
|
|
25
|
+
field: "label",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "请求地址",
|
|
29
|
+
type: "input",
|
|
30
|
+
field: "componentProps.action",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "上传文件字段",
|
|
34
|
+
type: "input",
|
|
35
|
+
field: "componentProps.name",
|
|
36
|
+
componentProps: {
|
|
37
|
+
placeholder: "请输入",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "允许上传最大数量",
|
|
42
|
+
type: "number",
|
|
43
|
+
field: "componentProps.max",
|
|
44
|
+
componentProps: {
|
|
45
|
+
min: 0,
|
|
46
|
+
placeholder: "请输入",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: "展示文件列表",
|
|
51
|
+
type: "switch",
|
|
52
|
+
field: "componentProps.showFileList",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "多选",
|
|
56
|
+
type: "switch",
|
|
57
|
+
field: "componentProps.multiple",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: "禁用",
|
|
61
|
+
type: "switch",
|
|
62
|
+
field: "componentProps.disabled",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "隐藏",
|
|
66
|
+
type: "switch",
|
|
67
|
+
field: "componentProps.hidden",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: "表单校验",
|
|
71
|
+
type: "ERuleEditor",
|
|
72
|
+
layout: "vertical",
|
|
73
|
+
field: "rules",
|
|
74
|
+
describe: "校验规则需要配合表单使用",
|
|
75
|
+
componentProps: {
|
|
76
|
+
ruleType: "array",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
bindModel: "modelValue",
|
|
82
|
+
} as ComponentConfigModel;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type PropType, defineComponent, h, nextTick, ref, watch } from "vue";
|
|
2
|
+
import { NUpload } from "naive-ui";
|
|
3
|
+
import type { UploadFileInfo } from "naive-ui";
|
|
4
|
+
import type { OnFinish, OnError } from "naive-ui/es/upload/src/interface";
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: Array as PropType<UploadFileInfo[]>,
|
|
10
|
+
default: () => [],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
emits: ["update:modelValue"],
|
|
14
|
+
setup(props, { emit, attrs }) {
|
|
15
|
+
const fileList = ref<UploadFileInfo[]>([]);
|
|
16
|
+
|
|
17
|
+
// const imgUrl = ref('')
|
|
18
|
+
// const visible = ref(false)
|
|
19
|
+
// const setVisible = (value: boolean): void => {
|
|
20
|
+
// visible.value = value
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
watch(fileList, (e) => {
|
|
24
|
+
emit("update:modelValue", e);
|
|
25
|
+
});
|
|
26
|
+
// 处理传递进来的值
|
|
27
|
+
watch(
|
|
28
|
+
() => props.modelValue,
|
|
29
|
+
(e) => {
|
|
30
|
+
if (e != null && e.length > 0 && fileList.value != null) {
|
|
31
|
+
// props modelValue 等于 data 不进行处理
|
|
32
|
+
if (fileList.value === e) return;
|
|
33
|
+
fileList.value.length = 0;
|
|
34
|
+
fileList.value.push(...e);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{ deep: true, immediate: true }
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
function handleUpdate(e: UploadFileInfo[]): void {
|
|
41
|
+
console.log("onChange called->", e);
|
|
42
|
+
nextTick(() => {
|
|
43
|
+
fileList.value = e;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 处理数据结果
|
|
48
|
+
// const handleChange = (info: UploadChangeParam): void => {
|
|
49
|
+
// if (info.file.status === 'uploading') {
|
|
50
|
+
// return
|
|
51
|
+
// }
|
|
52
|
+
//
|
|
53
|
+
// if (info.file.status === 'done') {
|
|
54
|
+
// // Get this url from response in real world.
|
|
55
|
+
// const url: string | undefined = info.file.response?.data?.url
|
|
56
|
+
// if (!info.file.url && !url) {
|
|
57
|
+
// info.file.status = 'error'
|
|
58
|
+
// message.error('上传失败')
|
|
59
|
+
// return
|
|
60
|
+
// }
|
|
61
|
+
// // 赋值url
|
|
62
|
+
// info.file.url = url
|
|
63
|
+
// info.file.thumbUrl = url
|
|
64
|
+
// }
|
|
65
|
+
//
|
|
66
|
+
// if (info.file.status === 'error') {
|
|
67
|
+
// message.error('upload error')
|
|
68
|
+
// }
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
const handleSuccess: OnFinish = ({ file, event }) => {
|
|
72
|
+
console.log("OnFinish called->", file, event);
|
|
73
|
+
const resInfo = event?.target as any;
|
|
74
|
+
const resData = JSON.parse(resInfo.response ?? "{}");
|
|
75
|
+
file.url = resData.data?.url;
|
|
76
|
+
};
|
|
77
|
+
const handleError: OnError = ({ file, event }) => {
|
|
78
|
+
console.log("OnError called->", file, event);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// 上传前处理
|
|
82
|
+
// const beforeUpload = (file: any): void => {
|
|
83
|
+
// const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
|
84
|
+
// if (!isJpgOrPng) {
|
|
85
|
+
// message.error('您只能上传JPG/PNG文件!');
|
|
86
|
+
// }
|
|
87
|
+
// const isLt2M = file.size / 1024 / 1024 < 2;
|
|
88
|
+
// if (!isLt2M) {
|
|
89
|
+
// message.error('图片大小超过 2MB!');
|
|
90
|
+
// }
|
|
91
|
+
// return isJpgOrPng && isLt2M;
|
|
92
|
+
// }
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 预览功能
|
|
96
|
+
* @param {*} e
|
|
97
|
+
*/
|
|
98
|
+
// const handlePreview: OnPreview = (file) => {
|
|
99
|
+
// console.log(file)
|
|
100
|
+
// if (!file.url) return
|
|
101
|
+
// imgUrl.value = file.url
|
|
102
|
+
// setVisible(true)
|
|
103
|
+
// }
|
|
104
|
+
|
|
105
|
+
return () => {
|
|
106
|
+
// const type = attrs.type;
|
|
107
|
+
return h(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
class: "epic-upload-image",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
default: () => [
|
|
114
|
+
h(
|
|
115
|
+
NUpload,
|
|
116
|
+
{
|
|
117
|
+
...attrs,
|
|
118
|
+
"list-type": "image-card",
|
|
119
|
+
accept: "image/gif,image/jpeg,image/jpg,image/png,image/svg",
|
|
120
|
+
"onUpdate:file-list": handleUpdate,
|
|
121
|
+
"file-list": fileList.value,
|
|
122
|
+
onFinish: handleSuccess,
|
|
123
|
+
onError: handleError,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
default: () => [
|
|
127
|
+
h(
|
|
128
|
+
"div",
|
|
129
|
+
{ style: { "text-align": "center" } },
|
|
130
|
+
{
|
|
131
|
+
default: () => [
|
|
132
|
+
h("span", {
|
|
133
|
+
class: "iconfont epic-icon-shangchuan1 text-md",
|
|
134
|
+
style: { "margin-right": "2px" },
|
|
135
|
+
}),
|
|
136
|
+
h(
|
|
137
|
+
"div",
|
|
138
|
+
{ class: "ant-upload-text" },
|
|
139
|
+
{ default: () => "点击上传" }
|
|
140
|
+
),
|
|
141
|
+
],
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
],
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
],
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@epic-designer/ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "epic-designer base ui",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
},
|
|
8
|
+
"author": "kchengz",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"ant-design-vue": "^4.2.1",
|
|
11
|
+
"element-plus": "^2.7.2",
|
|
12
|
+
"naive-ui": "^2.38.1",
|
|
13
|
+
"vite-plugin-dts": "^3.9.0"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"dayjs": "^1.11.11"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"useDefineForClassFields": true,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "Node",
|
|
8
|
+
"jsx": "preserve",
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"lib": ["ESNext", "DOM"],
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"skipLibCheck": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["./**/*", "*.ts", "*.json", "*.cjs"],
|
|
18
|
+
"exclude": ["node_modules", "dist", "vite.config.ts"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 kchengz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 防抖函数
|
|
3
|
+
* @param handler
|
|
4
|
+
* @param delay
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function debounce(handler: Function, delay: number) {
|
|
8
|
+
let timer: any = null;
|
|
9
|
+
return (...args: any[]) => {
|
|
10
|
+
if (timer) {
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
}
|
|
13
|
+
timer = setTimeout(() => {
|
|
14
|
+
|
|
15
|
+
handler.apply(this, args);
|
|
16
|
+
}, delay);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineAsyncComponent,
|
|
3
|
+
type AsyncComponentLoader,
|
|
4
|
+
type Component,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* * 异步加载组件
|
|
10
|
+
* @param loader
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export const loadAsyncComponent = (
|
|
14
|
+
loader: AsyncComponentLoader<any>,
|
|
15
|
+
loadingComponent?: Component
|
|
16
|
+
): any =>
|
|
17
|
+
defineAsyncComponent({
|
|
18
|
+
loader,
|
|
19
|
+
loadingComponent,
|
|
20
|
+
delay: 80,
|
|
21
|
+
});
|
|
22
|
+
|