@epic-designer/antd 1.0.5
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/LICENSE +21 -0
- package/dist/chunks/button.cjs +44 -0
- package/dist/chunks/button.mjs +42 -0
- package/dist/chunks/card.cjs +39 -0
- package/dist/chunks/card.mjs +37 -0
- package/dist/chunks/col.cjs +39 -0
- package/dist/chunks/col.mjs +37 -0
- package/dist/chunks/datePicker.cjs +47 -0
- package/dist/chunks/datePicker.mjs +45 -0
- package/dist/chunks/form.cjs +116 -0
- package/dist/chunks/form.mjs +114 -0
- package/dist/chunks/formItem.cjs +24 -0
- package/dist/chunks/formItem.mjs +22 -0
- package/dist/chunks/modal.cjs +136 -0
- package/dist/chunks/modal.mjs +134 -0
- package/dist/chunks/row.cjs +39 -0
- package/dist/chunks/row.mjs +37 -0
- package/dist/chunks/uploadFile.cjs +138 -0
- package/dist/chunks/uploadFile.mjs +136 -0
- package/dist/chunks/uploadImage.cjs +152 -0
- package/dist/chunks/uploadImage.mjs +150 -0
- package/dist/index.cjs +3047 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +3045 -0
- package/package.json +38 -0
- package/src/button/button.vue +19 -0
- package/src/button/index.ts +204 -0
- package/src/card/card.ts +38 -0
- package/src/card/index.ts +65 -0
- package/src/cascader/cascader.vue +24 -0
- package/src/cascader/index.ts +201 -0
- package/src/checkbox/index.ts +101 -0
- package/src/col/col.ts +38 -0
- package/src/col/index.ts +22 -0
- package/src/color-picker/index.ts +109 -0
- package/src/date-picker/datePicker.ts +48 -0
- package/src/date-picker/index.ts +301 -0
- package/src/form/form.vue +153 -0
- package/src/form/index.ts +196 -0
- package/src/form-item/formItem.vue +12 -0
- package/src/form-item/index.ts +10 -0
- package/src/index.less +33 -0
- package/src/index.ts +131 -0
- package/src/input/index.ts +171 -0
- package/src/input-number/index.ts +182 -0
- package/src/input-password/index.ts +154 -0
- package/src/modal/index.ts +20 -0
- package/src/modal/modal.vue +98 -0
- package/src/radio/index.ts +107 -0
- package/src/row/index.ts +116 -0
- package/src/row/row.ts +38 -0
- package/src/select/index.ts +231 -0
- package/src/slider/index.ts +145 -0
- package/src/switch/index.ts +143 -0
- package/src/textarea/index.ts +164 -0
- package/src/time-picker/index.ts +192 -0
- package/src/upload-file/index.ts +90 -0
- package/src/upload-file/uploadFile.vue +145 -0
- package/src/upload-image/index.ts +71 -0
- package/src/upload-image/uploadImage.vue +167 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const _hoisted_1 = { class: "epic-modal-main epic-scoped" };
|
|
7
|
+
const _hoisted_2 = { class: "epic-modal-footer" };
|
|
8
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
9
|
+
__name: "modal",
|
|
10
|
+
props: {
|
|
11
|
+
cancelText: { type: String, required: false, default: "\u5173\u95ED" },
|
|
12
|
+
componentSchema: { type: Object, required: false, default: () => ({
|
|
13
|
+
type: "modal"
|
|
14
|
+
}) },
|
|
15
|
+
hideConfirm: { type: Boolean, required: false },
|
|
16
|
+
okText: { type: String, required: false, default: "\u786E\u5B9A" }
|
|
17
|
+
},
|
|
18
|
+
emits: ["ok", "close", "update:modelValue"],
|
|
19
|
+
setup(__props, { emit: __emit }) {
|
|
20
|
+
const props = __props;
|
|
21
|
+
const emits = __emit;
|
|
22
|
+
const versionArray = antDesignVue.version.split(".");
|
|
23
|
+
const firstNumber = Number.parseInt(versionArray[0]);
|
|
24
|
+
const attrs = vue.useAttrs();
|
|
25
|
+
const dialogStyle = {
|
|
26
|
+
bottom: "30px",
|
|
27
|
+
left: "150px",
|
|
28
|
+
minHeight: "500px",
|
|
29
|
+
minWidth: "700px",
|
|
30
|
+
position: "absolute",
|
|
31
|
+
right: "150px",
|
|
32
|
+
top: "56px",
|
|
33
|
+
width: "auto"
|
|
34
|
+
};
|
|
35
|
+
const bodyStyle = {
|
|
36
|
+
height: "calc(100vh - 108px)",
|
|
37
|
+
padding: 0
|
|
38
|
+
};
|
|
39
|
+
const getComponentProps = vue.computed(() => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
return {
|
|
42
|
+
...props.componentSchema,
|
|
43
|
+
...attrs,
|
|
44
|
+
bodyStyle,
|
|
45
|
+
dialogStyle,
|
|
46
|
+
footer: null,
|
|
47
|
+
"onUpdate:open": updateModelValue,
|
|
48
|
+
"onUpdate:visible": updateModelValue,
|
|
49
|
+
open: attrs.modelValue,
|
|
50
|
+
style: "top:20px",
|
|
51
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : "",
|
|
52
|
+
visible: firstNumber > 3 ? void 0 : attrs.modelValue,
|
|
53
|
+
wrapClassName: "epic-modal-ant",
|
|
54
|
+
children: null
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const children = vue.computed(() => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
return (_b = (_a = props.componentSchema) == null ? void 0 : _a.children) != null ? _b : [];
|
|
60
|
+
});
|
|
61
|
+
function handleOk() {
|
|
62
|
+
emits("ok");
|
|
63
|
+
}
|
|
64
|
+
function updateModelValue(value = false) {
|
|
65
|
+
emits("update:modelValue", value);
|
|
66
|
+
}
|
|
67
|
+
function handleClose() {
|
|
68
|
+
emits("close");
|
|
69
|
+
}
|
|
70
|
+
return (_ctx, _cache) => {
|
|
71
|
+
return vue.openBlock(), vue.createBlock(
|
|
72
|
+
vue.unref(antDesignVue.Modal),
|
|
73
|
+
vue.normalizeProps(vue.guardReactiveProps(getComponentProps.value)),
|
|
74
|
+
{
|
|
75
|
+
default: vue.withCtx(() => [
|
|
76
|
+
vue.createElementVNode("div", _hoisted_1, [
|
|
77
|
+
vue.renderSlot(_ctx.$slots, "default", {}, () => [
|
|
78
|
+
vue.renderSlot(_ctx.$slots, "edit-node", {}, () => [
|
|
79
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
80
|
+
vue.Fragment,
|
|
81
|
+
null,
|
|
82
|
+
vue.renderList(children.value, (item) => {
|
|
83
|
+
return vue.renderSlot(_ctx.$slots, "node", { componentSchema: item });
|
|
84
|
+
}),
|
|
85
|
+
256
|
|
86
|
+
/* UNKEYED_FRAGMENT */
|
|
87
|
+
))
|
|
88
|
+
])
|
|
89
|
+
])
|
|
90
|
+
]),
|
|
91
|
+
vue.createElementVNode("div", _hoisted_2, [
|
|
92
|
+
vue.createVNode(vue.unref(antDesignVue.Space), { align: "end" }, {
|
|
93
|
+
default: vue.withCtx(() => [
|
|
94
|
+
vue.createVNode(vue.unref(antDesignVue.Button), { onClick: handleClose }, {
|
|
95
|
+
default: vue.withCtx(() => [
|
|
96
|
+
vue.createTextVNode(
|
|
97
|
+
vue.toDisplayString(props.cancelText),
|
|
98
|
+
1
|
|
99
|
+
/* TEXT */
|
|
100
|
+
)
|
|
101
|
+
]),
|
|
102
|
+
_: 1
|
|
103
|
+
/* STABLE */
|
|
104
|
+
}),
|
|
105
|
+
!props.hideConfirm ? (vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Button), {
|
|
106
|
+
key: 0,
|
|
107
|
+
type: "primary",
|
|
108
|
+
onClick: handleOk
|
|
109
|
+
}, {
|
|
110
|
+
default: vue.withCtx(() => [
|
|
111
|
+
vue.createTextVNode(
|
|
112
|
+
vue.toDisplayString(props.okText),
|
|
113
|
+
1
|
|
114
|
+
/* TEXT */
|
|
115
|
+
)
|
|
116
|
+
]),
|
|
117
|
+
_: 1
|
|
118
|
+
/* STABLE */
|
|
119
|
+
})) : vue.createCommentVNode("v-if", true)
|
|
120
|
+
]),
|
|
121
|
+
_: 1
|
|
122
|
+
/* STABLE */
|
|
123
|
+
})
|
|
124
|
+
])
|
|
125
|
+
]),
|
|
126
|
+
_: 3
|
|
127
|
+
/* FORWARDED */
|
|
128
|
+
},
|
|
129
|
+
16
|
|
130
|
+
/* FULL_PROPS */
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { defineComponent, useAttrs, computed, createBlock, openBlock, unref, normalizeProps, guardReactiveProps, withCtx, createElementVNode, renderSlot, createElementBlock, Fragment, renderList, createVNode, createCommentVNode, createTextVNode, toDisplayString } from 'vue';
|
|
2
|
+
import { version, Modal, Space, Button } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const _hoisted_1 = { class: "epic-modal-main epic-scoped" };
|
|
5
|
+
const _hoisted_2 = { class: "epic-modal-footer" };
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "modal",
|
|
8
|
+
props: {
|
|
9
|
+
cancelText: { type: String, required: false, default: "\u5173\u95ED" },
|
|
10
|
+
componentSchema: { type: Object, required: false, default: () => ({
|
|
11
|
+
type: "modal"
|
|
12
|
+
}) },
|
|
13
|
+
hideConfirm: { type: Boolean, required: false },
|
|
14
|
+
okText: { type: String, required: false, default: "\u786E\u5B9A" }
|
|
15
|
+
},
|
|
16
|
+
emits: ["ok", "close", "update:modelValue"],
|
|
17
|
+
setup(__props, { emit: __emit }) {
|
|
18
|
+
const props = __props;
|
|
19
|
+
const emits = __emit;
|
|
20
|
+
const versionArray = version.split(".");
|
|
21
|
+
const firstNumber = Number.parseInt(versionArray[0]);
|
|
22
|
+
const attrs = useAttrs();
|
|
23
|
+
const dialogStyle = {
|
|
24
|
+
bottom: "30px",
|
|
25
|
+
left: "150px",
|
|
26
|
+
minHeight: "500px",
|
|
27
|
+
minWidth: "700px",
|
|
28
|
+
position: "absolute",
|
|
29
|
+
right: "150px",
|
|
30
|
+
top: "56px",
|
|
31
|
+
width: "auto"
|
|
32
|
+
};
|
|
33
|
+
const bodyStyle = {
|
|
34
|
+
height: "calc(100vh - 108px)",
|
|
35
|
+
padding: 0
|
|
36
|
+
};
|
|
37
|
+
const getComponentProps = computed(() => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return {
|
|
40
|
+
...props.componentSchema,
|
|
41
|
+
...attrs,
|
|
42
|
+
bodyStyle,
|
|
43
|
+
dialogStyle,
|
|
44
|
+
footer: null,
|
|
45
|
+
"onUpdate:open": updateModelValue,
|
|
46
|
+
"onUpdate:visible": updateModelValue,
|
|
47
|
+
open: attrs.modelValue,
|
|
48
|
+
style: "top:20px",
|
|
49
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : "",
|
|
50
|
+
visible: firstNumber > 3 ? void 0 : attrs.modelValue,
|
|
51
|
+
wrapClassName: "epic-modal-ant",
|
|
52
|
+
children: null
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
const children = computed(() => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
return (_b = (_a = props.componentSchema) == null ? void 0 : _a.children) != null ? _b : [];
|
|
58
|
+
});
|
|
59
|
+
function handleOk() {
|
|
60
|
+
emits("ok");
|
|
61
|
+
}
|
|
62
|
+
function updateModelValue(value = false) {
|
|
63
|
+
emits("update:modelValue", value);
|
|
64
|
+
}
|
|
65
|
+
function handleClose() {
|
|
66
|
+
emits("close");
|
|
67
|
+
}
|
|
68
|
+
return (_ctx, _cache) => {
|
|
69
|
+
return openBlock(), createBlock(
|
|
70
|
+
unref(Modal),
|
|
71
|
+
normalizeProps(guardReactiveProps(getComponentProps.value)),
|
|
72
|
+
{
|
|
73
|
+
default: withCtx(() => [
|
|
74
|
+
createElementVNode("div", _hoisted_1, [
|
|
75
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
76
|
+
renderSlot(_ctx.$slots, "edit-node", {}, () => [
|
|
77
|
+
(openBlock(true), createElementBlock(
|
|
78
|
+
Fragment,
|
|
79
|
+
null,
|
|
80
|
+
renderList(children.value, (item) => {
|
|
81
|
+
return renderSlot(_ctx.$slots, "node", { componentSchema: item });
|
|
82
|
+
}),
|
|
83
|
+
256
|
|
84
|
+
/* UNKEYED_FRAGMENT */
|
|
85
|
+
))
|
|
86
|
+
])
|
|
87
|
+
])
|
|
88
|
+
]),
|
|
89
|
+
createElementVNode("div", _hoisted_2, [
|
|
90
|
+
createVNode(unref(Space), { align: "end" }, {
|
|
91
|
+
default: withCtx(() => [
|
|
92
|
+
createVNode(unref(Button), { onClick: handleClose }, {
|
|
93
|
+
default: withCtx(() => [
|
|
94
|
+
createTextVNode(
|
|
95
|
+
toDisplayString(props.cancelText),
|
|
96
|
+
1
|
|
97
|
+
/* TEXT */
|
|
98
|
+
)
|
|
99
|
+
]),
|
|
100
|
+
_: 1
|
|
101
|
+
/* STABLE */
|
|
102
|
+
}),
|
|
103
|
+
!props.hideConfirm ? (openBlock(), createBlock(unref(Button), {
|
|
104
|
+
key: 0,
|
|
105
|
+
type: "primary",
|
|
106
|
+
onClick: handleOk
|
|
107
|
+
}, {
|
|
108
|
+
default: withCtx(() => [
|
|
109
|
+
createTextVNode(
|
|
110
|
+
toDisplayString(props.okText),
|
|
111
|
+
1
|
|
112
|
+
/* TEXT */
|
|
113
|
+
)
|
|
114
|
+
]),
|
|
115
|
+
_: 1
|
|
116
|
+
/* STABLE */
|
|
117
|
+
})) : createCommentVNode("v-if", true)
|
|
118
|
+
]),
|
|
119
|
+
_: 1
|
|
120
|
+
/* STABLE */
|
|
121
|
+
})
|
|
122
|
+
])
|
|
123
|
+
]),
|
|
124
|
+
_: 3
|
|
125
|
+
/* FORWARDED */
|
|
126
|
+
},
|
|
127
|
+
16
|
|
128
|
+
/* FULL_PROPS */
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const row = vue.defineComponent({
|
|
7
|
+
props: {
|
|
8
|
+
componentSchema: {
|
|
9
|
+
default: () => ({}),
|
|
10
|
+
require: true,
|
|
11
|
+
type: Object
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
setup(props, { slots }) {
|
|
15
|
+
return () => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const componentSchema = {
|
|
18
|
+
...props.componentSchema,
|
|
19
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : ""
|
|
20
|
+
};
|
|
21
|
+
const children = componentSchema.children;
|
|
22
|
+
delete componentSchema.children;
|
|
23
|
+
return vue.h(antDesignVue.Row, componentSchema, {
|
|
24
|
+
default: () => vue.renderSlot(
|
|
25
|
+
slots,
|
|
26
|
+
"edit-node",
|
|
27
|
+
{},
|
|
28
|
+
() => children.map(
|
|
29
|
+
(subcomponentSchema) => vue.renderSlot(slots, "node", {
|
|
30
|
+
componentSchema: subcomponentSchema
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.default = row;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineComponent, h, renderSlot } from 'vue';
|
|
2
|
+
import { Row } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const row = defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
componentSchema: {
|
|
7
|
+
default: () => ({}),
|
|
8
|
+
require: true,
|
|
9
|
+
type: Object
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
setup(props, { slots }) {
|
|
13
|
+
return () => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const componentSchema = {
|
|
16
|
+
...props.componentSchema,
|
|
17
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : ""
|
|
18
|
+
};
|
|
19
|
+
const children = componentSchema.children;
|
|
20
|
+
delete componentSchema.children;
|
|
21
|
+
return h(Row, componentSchema, {
|
|
22
|
+
default: () => renderSlot(
|
|
23
|
+
slots,
|
|
24
|
+
"edit-node",
|
|
25
|
+
{},
|
|
26
|
+
() => children.map(
|
|
27
|
+
(subcomponentSchema) => renderSlot(slots, "node", {
|
|
28
|
+
componentSchema: subcomponentSchema
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export { row as default };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const epicDesigner = require('epic-designer');
|
|
5
|
+
const antDesignVue = require('ant-design-vue');
|
|
6
|
+
|
|
7
|
+
const _hoisted_1 = { class: "epic-upload-file" };
|
|
8
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
9
|
+
__name: "uploadFile",
|
|
10
|
+
props: {
|
|
11
|
+
maxCount: { type: Number, required: false, default: 99 },
|
|
12
|
+
modelValue: { type: String, required: false, default: "" }
|
|
13
|
+
},
|
|
14
|
+
emits: ["update:modelValue", "change"],
|
|
15
|
+
setup(__props, { emit: __emit }) {
|
|
16
|
+
const props = __props;
|
|
17
|
+
const emits = __emit;
|
|
18
|
+
const formItemContext = antDesignVue.Form.useInjectFormItemContext();
|
|
19
|
+
const attrs = vue.useAttrs();
|
|
20
|
+
const fileList = vue.ref([]);
|
|
21
|
+
let urlString = "";
|
|
22
|
+
vue.watch(
|
|
23
|
+
() => fileList.value,
|
|
24
|
+
(list) => {
|
|
25
|
+
urlString = list.filter((file) => file.status === "done").map((file) => file.url).join(",");
|
|
26
|
+
emits("update:modelValue", urlString);
|
|
27
|
+
emits("change", urlString);
|
|
28
|
+
formItemContext.onFieldChange();
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
vue.watch(
|
|
32
|
+
() => props.modelValue,
|
|
33
|
+
(modelValue) => {
|
|
34
|
+
if (urlString === modelValue) return;
|
|
35
|
+
if (modelValue === "") {
|
|
36
|
+
fileList.value = [];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (modelValue && fileList.value) {
|
|
40
|
+
fileList.value = modelValue.split(",").map((url) => ({
|
|
41
|
+
name: url,
|
|
42
|
+
status: "done",
|
|
43
|
+
uid: epicDesigner.getUUID(),
|
|
44
|
+
url
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{ deep: true, immediate: true }
|
|
49
|
+
);
|
|
50
|
+
function handleUpdate(e) {
|
|
51
|
+
vue.nextTick(() => {
|
|
52
|
+
fileList.value = e;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const handleChange = (info) => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
if (info.file.status === "uploading") {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (info.file.status === "done") {
|
|
61
|
+
const url = (_b = (_a = info.file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url;
|
|
62
|
+
if (!info.file.url && !url) {
|
|
63
|
+
info.file.status = "error";
|
|
64
|
+
antDesignVue.message.error("\u4E0A\u4F20\u5931\u8D25");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
info.file.url = url;
|
|
68
|
+
info.file.thumbUrl = url;
|
|
69
|
+
}
|
|
70
|
+
if (info.file.status === "error") {
|
|
71
|
+
antDesignVue.message.error("upload error");
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const beforeUpload = () => {
|
|
75
|
+
};
|
|
76
|
+
const getUploadProps = vue.computed(() => {
|
|
77
|
+
var _a;
|
|
78
|
+
return {
|
|
79
|
+
...attrs,
|
|
80
|
+
headers: (_a = epicDesigner.pluginManager.global.axiosConfig) == null ? void 0 : _a.headers,
|
|
81
|
+
"onBefore-upload": beforeUpload,
|
|
82
|
+
onChange: handleChange,
|
|
83
|
+
onPreview: handlePreview,
|
|
84
|
+
"file-list": fileList.value,
|
|
85
|
+
"onUpdate:file-list": handleUpdate
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
function handlePreview(e) {
|
|
89
|
+
console.log(e);
|
|
90
|
+
if (!e.url) return;
|
|
91
|
+
window.open(e.url, "_blank");
|
|
92
|
+
}
|
|
93
|
+
return (_ctx, _cache) => {
|
|
94
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
95
|
+
vue.createVNode(
|
|
96
|
+
vue.unref(antDesignVue.Upload),
|
|
97
|
+
vue.normalizeProps(vue.guardReactiveProps(getUploadProps.value)),
|
|
98
|
+
{
|
|
99
|
+
default: vue.withCtx(() => {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
return [
|
|
102
|
+
((_b = (_a = fileList.value) == null ? void 0 : _a.length) != null ? _b : 0) < props.maxCount ? (vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Button), {
|
|
103
|
+
key: 0,
|
|
104
|
+
class: "flex items-center"
|
|
105
|
+
}, {
|
|
106
|
+
default: vue.withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
107
|
+
vue.createElementVNode(
|
|
108
|
+
"span",
|
|
109
|
+
{ class: "icon--epic icon--epic--cloud-upload-outlined text-lg" },
|
|
110
|
+
null,
|
|
111
|
+
-1
|
|
112
|
+
/* CACHED */
|
|
113
|
+
),
|
|
114
|
+
vue.createElementVNode(
|
|
115
|
+
"div",
|
|
116
|
+
{ class: "ant-upload-text" },
|
|
117
|
+
"\u4E0A\u4F20\u6587\u4EF6",
|
|
118
|
+
-1
|
|
119
|
+
/* CACHED */
|
|
120
|
+
)
|
|
121
|
+
])]),
|
|
122
|
+
_: 1
|
|
123
|
+
/* STABLE */
|
|
124
|
+
})) : vue.createCommentVNode("v-if", true)
|
|
125
|
+
];
|
|
126
|
+
}),
|
|
127
|
+
_: 1
|
|
128
|
+
/* STABLE */
|
|
129
|
+
},
|
|
130
|
+
16
|
|
131
|
+
/* FULL_PROPS */
|
|
132
|
+
)
|
|
133
|
+
]);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { defineComponent, useAttrs, ref, watch, computed, createElementBlock, openBlock, createVNode, unref, normalizeProps, guardReactiveProps, withCtx, createBlock, createCommentVNode, createElementVNode, nextTick } from 'vue';
|
|
2
|
+
import { getUUID, pluginManager } from 'epic-designer';
|
|
3
|
+
import { Form, Upload, Button, message } from 'ant-design-vue';
|
|
4
|
+
|
|
5
|
+
const _hoisted_1 = { class: "epic-upload-file" };
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "uploadFile",
|
|
8
|
+
props: {
|
|
9
|
+
maxCount: { type: Number, required: false, default: 99 },
|
|
10
|
+
modelValue: { type: String, required: false, default: "" }
|
|
11
|
+
},
|
|
12
|
+
emits: ["update:modelValue", "change"],
|
|
13
|
+
setup(__props, { emit: __emit }) {
|
|
14
|
+
const props = __props;
|
|
15
|
+
const emits = __emit;
|
|
16
|
+
const formItemContext = Form.useInjectFormItemContext();
|
|
17
|
+
const attrs = useAttrs();
|
|
18
|
+
const fileList = ref([]);
|
|
19
|
+
let urlString = "";
|
|
20
|
+
watch(
|
|
21
|
+
() => fileList.value,
|
|
22
|
+
(list) => {
|
|
23
|
+
urlString = list.filter((file) => file.status === "done").map((file) => file.url).join(",");
|
|
24
|
+
emits("update:modelValue", urlString);
|
|
25
|
+
emits("change", urlString);
|
|
26
|
+
formItemContext.onFieldChange();
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
watch(
|
|
30
|
+
() => props.modelValue,
|
|
31
|
+
(modelValue) => {
|
|
32
|
+
if (urlString === modelValue) return;
|
|
33
|
+
if (modelValue === "") {
|
|
34
|
+
fileList.value = [];
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (modelValue && fileList.value) {
|
|
38
|
+
fileList.value = modelValue.split(",").map((url) => ({
|
|
39
|
+
name: url,
|
|
40
|
+
status: "done",
|
|
41
|
+
uid: getUUID(),
|
|
42
|
+
url
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{ deep: true, immediate: true }
|
|
47
|
+
);
|
|
48
|
+
function handleUpdate(e) {
|
|
49
|
+
nextTick(() => {
|
|
50
|
+
fileList.value = e;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const handleChange = (info) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
if (info.file.status === "uploading") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (info.file.status === "done") {
|
|
59
|
+
const url = (_b = (_a = info.file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url;
|
|
60
|
+
if (!info.file.url && !url) {
|
|
61
|
+
info.file.status = "error";
|
|
62
|
+
message.error("\u4E0A\u4F20\u5931\u8D25");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
info.file.url = url;
|
|
66
|
+
info.file.thumbUrl = url;
|
|
67
|
+
}
|
|
68
|
+
if (info.file.status === "error") {
|
|
69
|
+
message.error("upload error");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const beforeUpload = () => {
|
|
73
|
+
};
|
|
74
|
+
const getUploadProps = computed(() => {
|
|
75
|
+
var _a;
|
|
76
|
+
return {
|
|
77
|
+
...attrs,
|
|
78
|
+
headers: (_a = pluginManager.global.axiosConfig) == null ? void 0 : _a.headers,
|
|
79
|
+
"onBefore-upload": beforeUpload,
|
|
80
|
+
onChange: handleChange,
|
|
81
|
+
onPreview: handlePreview,
|
|
82
|
+
"file-list": fileList.value,
|
|
83
|
+
"onUpdate:file-list": handleUpdate
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
function handlePreview(e) {
|
|
87
|
+
console.log(e);
|
|
88
|
+
if (!e.url) return;
|
|
89
|
+
window.open(e.url, "_blank");
|
|
90
|
+
}
|
|
91
|
+
return (_ctx, _cache) => {
|
|
92
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
93
|
+
createVNode(
|
|
94
|
+
unref(Upload),
|
|
95
|
+
normalizeProps(guardReactiveProps(getUploadProps.value)),
|
|
96
|
+
{
|
|
97
|
+
default: withCtx(() => {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
return [
|
|
100
|
+
((_b = (_a = fileList.value) == null ? void 0 : _a.length) != null ? _b : 0) < props.maxCount ? (openBlock(), createBlock(unref(Button), {
|
|
101
|
+
key: 0,
|
|
102
|
+
class: "flex items-center"
|
|
103
|
+
}, {
|
|
104
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
105
|
+
createElementVNode(
|
|
106
|
+
"span",
|
|
107
|
+
{ class: "icon--epic icon--epic--cloud-upload-outlined text-lg" },
|
|
108
|
+
null,
|
|
109
|
+
-1
|
|
110
|
+
/* CACHED */
|
|
111
|
+
),
|
|
112
|
+
createElementVNode(
|
|
113
|
+
"div",
|
|
114
|
+
{ class: "ant-upload-text" },
|
|
115
|
+
"\u4E0A\u4F20\u6587\u4EF6",
|
|
116
|
+
-1
|
|
117
|
+
/* CACHED */
|
|
118
|
+
)
|
|
119
|
+
])]),
|
|
120
|
+
_: 1
|
|
121
|
+
/* STABLE */
|
|
122
|
+
})) : createCommentVNode("v-if", true)
|
|
123
|
+
];
|
|
124
|
+
}),
|
|
125
|
+
_: 1
|
|
126
|
+
/* STABLE */
|
|
127
|
+
},
|
|
128
|
+
16
|
|
129
|
+
/* FULL_PROPS */
|
|
130
|
+
)
|
|
131
|
+
]);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export { _sfc_main as default };
|