kouxiangtang 0.0.78 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +408 -4
- package/dist/{AttachmentUploader-Dk3pI8xI.js → AttachmentUploader-dO2PiIqG.js} +58 -48
- package/dist/AttachmentUploader-dO2PiIqG.js.map +1 -0
- package/dist/{ImageUploader-Sl6CARAH.js → ImageUploader-DJfujt_H.js} +2 -2
- package/dist/{ImageUploader-Sl6CARAH.js.map → ImageUploader-DJfujt_H.js.map} +1 -1
- package/dist/ImagesUploader-L2-m9pOt.js +132 -0
- package/dist/ImagesUploader-L2-m9pOt.js.map +1 -0
- package/dist/{RichTextEditor-BN-Grymy.js → RichTextEditor-B0009vbA.js} +2 -2
- package/dist/{RichTextEditor-BN-Grymy.js.map → RichTextEditor-B0009vbA.js.map} +1 -1
- package/dist/{config-3CmGvWbJ.js → config-4opkUG_U.js} +2 -2
- package/dist/{config-3CmGvWbJ.js.map → config-4opkUG_U.js.map} +1 -1
- package/dist/{config-kSnMLu_i.js → config-B7NLL7Za.js} +2 -2
- package/dist/{config-kSnMLu_i.js.map → config-B7NLL7Za.js.map} +1 -1
- package/dist/{config-BPF5NKbv.js → config-BOL73GVE.js} +2 -2
- package/dist/{config-BPF5NKbv.js.map → config-BOL73GVE.js.map} +1 -1
- package/dist/{config-Dfv9X_oH.js → config-B_jV9FcB.js} +3 -3
- package/dist/{config-Dfv9X_oH.js.map → config-B_jV9FcB.js.map} +1 -1
- package/dist/{config-nxWFYd4H.js → config-BbMhy1Am.js} +2 -2
- package/dist/{config-nxWFYd4H.js.map → config-BbMhy1Am.js.map} +1 -1
- package/dist/{config-DIgyOzyY.js → config-Bf2H_VXi.js} +2 -2
- package/dist/{config-DIgyOzyY.js.map → config-Bf2H_VXi.js.map} +1 -1
- package/dist/{config-BIoYHFta.js → config-BgIHsuau.js} +3 -3
- package/dist/{config-BIoYHFta.js.map → config-BgIHsuau.js.map} +1 -1
- package/dist/{config-DWQ07KGg.js → config-BnV5g1r6.js} +2 -2
- package/dist/{config-DWQ07KGg.js.map → config-BnV5g1r6.js.map} +1 -1
- package/dist/{config-B7sfuPS-.js → config-C9BwlRNg.js} +2 -2
- package/dist/{config-B7sfuPS-.js.map → config-C9BwlRNg.js.map} +1 -1
- package/dist/{config-DFY-g88P.js → config-CL0sbSSk.js} +2 -2
- package/dist/{config-DFY-g88P.js.map → config-CL0sbSSk.js.map} +1 -1
- package/dist/{config-BDUo3FW4.js → config-CXX_cyT5.js} +2 -2
- package/dist/{config-BDUo3FW4.js.map → config-CXX_cyT5.js.map} +1 -1
- package/dist/{config-D6JmkLzW.js → config-Ct-kk8lN.js} +2 -2
- package/dist/{config-D6JmkLzW.js.map → config-Ct-kk8lN.js.map} +1 -1
- package/dist/{config-urM6mrhD.js → config-DBWaP3c8.js} +2 -2
- package/dist/{config-urM6mrhD.js.map → config-DBWaP3c8.js.map} +1 -1
- package/dist/{config-Cs24dvIw.js → config-DD7Ikbt-.js} +2 -2
- package/dist/{config-Cs24dvIw.js.map → config-DD7Ikbt-.js.map} +1 -1
- package/dist/{config-CWEv8XKO.js → config-DmxS5C0R.js} +2 -2
- package/dist/{config-CWEv8XKO.js.map → config-DmxS5C0R.js.map} +1 -1
- package/dist/{config-BMegUoCu.js → config-POLpsRRx.js} +2 -2
- package/dist/{config-BMegUoCu.js.map → config-POLpsRRx.js.map} +1 -1
- package/dist/{config-CEbzlR4L.js → config-UhlNBDt2.js} +2 -2
- package/dist/{config-CEbzlR4L.js.map → config-UhlNBDt2.js.map} +1 -1
- package/dist/{config-Gr_n4RJU.js → config-jNNoK2HQ.js} +3 -3
- package/dist/{config-Gr_n4RJU.js.map → config-jNNoK2HQ.js.map} +1 -1
- package/dist/{config-7NNTCgWz.js → config-nq8OiIpn.js} +2 -2
- package/dist/{config-7NNTCgWz.js.map → config-nq8OiIpn.js.map} +1 -1
- package/dist/{index-DWaIPnvt.js → index-BDc0n3q3.js} +617 -606
- package/dist/index-BDc0n3q3.js.map +1 -0
- package/dist/kouxiangtang.js +1 -1
- package/dist/kouxiangtang.umd.cjs +8 -8
- package/dist/kouxiangtang.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/AttachmentUploader-Dk3pI8xI.js.map +0 -1
- package/dist/ImagesUploader-CD6qu0oD.js +0 -123
- package/dist/ImagesUploader-CD6qu0oD.js.map +0 -1
- package/dist/index-DWaIPnvt.js.map +0 -1
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentUploader-Dk3pI8xI.js","sources":["../src/framework/field/attachment/AttachmentUploader.vue"],"sourcesContent":["<script setup>\nimport {\n ElUpload,\n ElIcon,\n ElDialog,\n ElForm,\n ElFormItem,\n ElButton,\n ElInput,\n} from \"element-plus\";\nimport axios from \"axios\";\nimport http from \"../../utils/http\";\nimport { getConfig } from \"../../config-loader\";\nimport { ref, computed } from \"vue\";\nimport { ElLoading, ElMessage } from \"element-plus\";\nimport { Plus, Document, Close } from \"@element-plus/icons-vue\";\n\nconst emit = defineEmits([\"on-success\", \"on-remove\", \"on-change\"]);\nconst props = defineProps({\n pics: {\n type: Array,\n default() {\n return [];\n },\n },\n limit: { type: Number },\n props: {\n type: Object,\n default() {\n return {\n listType: \"picture-card\", //'text' | 'picture' | 'picture-card'\n limit: 5, //最多上传几个文件\n accept: \"image/*\",\n };\n },\n },\n});\n\nconst files = computed(() => {\n return props.pics.map((item) => {\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\n if (typeof item.name !== undefined) {\n item.fileType = fileType;\n return item;\n }\n\n if (item.url) {\n const parts = item.url.split(\"/\");\n const namedItem = {\n ...item,\n name: parts[parts.length - 1],\n fileType: fileType,\n };\n return namedItem;\n }\n\n return { ...item, name: item.id, fileType: fileType };\n });\n});\nconst dialogImageUrl = ref(\"\");\nconst dialogVisible = ref(false);\nconst imageUrl = ref(props);\nconst uploadUrl = getConfig().fileUploadUrl;\nconst header = {\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\n};\nconst compressImg = (file) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n\n return new Promise(function (resolve, reject) {\n if (!file.type.startsWith(\"image/\")) {\n resolve(file);\n return false;\n }\n reader.onload = async (e) => {\n const img = new Image();\n img.src = e.target.result;\n img.onload = () => {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n canvas.width = img.width;\n canvas.height = img.height;\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n canvas.toBlob(\n (blob) => {\n const newFile = new File([blob], file.name, {\n type: file.type,\n lastModified: Date.now(),\n });\n resolve(newFile);\n },\n file.type,\n 0.5,\n );\n };\n };\n return false;\n });\n};\nconst handleRemoveSuccess = (uploadFile) => {\n if (uploadFile.status === \"success\") {\n if (props.props.deleteUrl) {\n http\n .remove(`${props.props.deleteUrl}/${uploadFile.id}/attachment`)\n .then(() => {\n emit(\"on-remove\", uploadFile);\n });\n } else {\n emit(\"on-remove\", uploadFile);\n }\n }\n};\nconst handleExceed = () => {\n ElMessage({\n message: `最多只能上传 ${props.props.limit} 个文件!`,\n type: \"warning\",\n });\n};\nconst handlePictureCardPreview = (uploadFile) => {\n dialogImageUrl.value = uploadFile.url;\n dialogVisible.value = true;\n};\nconst handleBeforeUpload = (file) => {\n const fileName = file.name.substring(0, file.name.lastIndexOf(\".\"));\n const regex = /^[\\u4e00-\\u9fa5\\w-_]+$/;\n if (!regex.test(fileName)) {\n ElMessage({\n message: \"请勿输入特殊字符!\",\n type: \"warning\",\n });\n return false;\n }\n compressImg(file).then((newFile) => {\n if (newFile.size / 1024 / 1024 < 5) {\n uploadRequest(newFile);\n return false;\n } else {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n });\n};\n\nfunction handleFileNameChange(file, index) {\n if (!file.name) {\n ElMessage({\n message: \"附件名称不能为空!\",\n type: \"warning\",\n });\n return;\n }\n emit(\"on-change\", file);\n}\n\nfunction uploadRequest(file) {\n ElLoading.service({ text: \"上传中,请稍后\", background: \"rgba(0,0,0,0.3)\" });\n return new Promise((resolve, reject) => {\n const formData = new FormData();\n formData.append(\"file\", file);\n axios\n .post(uploadUrl, formData, {})\n .then((res) => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传成功\",\n type: \"success\",\n });\n emit(\"on-success\", res.data.data);\n resolve(res.data);\n return false;\n })\n .catch(() => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传失败\",\n type: \"warning\",\n });\n reject(\"Upload failed\");\n });\n });\n}\n</script>\n\n<template>\n <!-- 删除请求头加权限后请添加到组建中 :headers=\"header\"-->\n <el-upload\n :file-list=\"files\"\n :action=\"uploadUrl\"\n :limit=\"props.props.limit\"\n :accept=\"props.props.accept\"\n :list-type=\"props.props.listType\"\n :on-remove=\"handleRemoveSuccess\"\n :before-upload=\"handleBeforeUpload\"\n :on-exceed=\"handleExceed\"\n :on-preview=\"handlePictureCardPreview\"\n :multiple=\"true\"\n :http-request=\"\n () => {\n return false;\n }\n \"\n :show-file-list=\"props.props.listType !== 'text'\"\n :class=\"[\n 'upload-main',\n { 'disable-upload': files.length >= props.props.limit },\n ]\"\n @click.prevent\n >\n <template v-if=\"props.props.listType !== 'text'\">\n <el-icon :disabled=\"true\">\n <Plus />\n </el-icon>\n </template>\n <template v-else>\n <el-button class=\"upload-button\" type=\"primary\"> 上传附件 </el-button>\n </template>\n </el-upload>\n <el-dialog v-model=\"dialogVisible\">\n <img w-full :src=\"dialogImageUrl\" alt=\"Preview Image\" />\n </el-dialog>\n <el-form v-if=\"props.props.listType == 'text'\">\n <el-form-item v-for=\"(file, index) in files\" :key=\"index\" class=\"file-list\">\n <el-icon color=\"#73767a\" :size=\"14\">\n <Document />\n </el-icon>\n <el-input\n v-model=\"file.name\"\n @change=\"handleFileNameChange(file, index)\"\n />\n <span class=\"file-type\">.{{ file.fileType }}</span>\n <el-icon color=\"#73767a\" :size=\"12\" @click=\"handleRemoveSuccess(file)\">\n <Close />\n </el-icon>\n </el-form-item>\n </el-form>\n</template>\n<style scoped lang=\"scss\">\n:deep(.el-upload-list) {\n .el-upload-list__item-actions span {\n margin-left: 20px;\n }\n}\n\n.disable-upload {\n :deep(.el-upload--picture-card) {\n display: none !important;\n }\n\n :deep(.el-upload--text) {\n display: none !important;\n }\n\n :deep(.el-upload--picture) {\n display: none !important;\n }\n}\n.upload-main {\n flex-basis: 100%;\n}\n.file-list {\n display: flex;\n align-items: center;\n margin-top: 10px;\n .file-type {\n height: 22px;\n line-height: 22px;\n margin-right: 5px;\n background: #eeeeee;\n border-radius: 4px;\n font-size: 12px;\n padding: 0 4px;\n }\n :deep(.el-form-item__content) {\n display: contents;\n }\n :deep(.el-input__wrapper) {\n margin: 0 5px;\n }\n :deep(.el-input__inner) {\n height: 20px;\n line-height: 20px;\n }\n}\n</style>\n"],"names":["emit","__emit","props","__props","files","computed","item","fileType","parts","dialogImageUrl","ref","dialogVisible","uploadUrl","getConfig","compressImg","file","reader","resolve","reject","e","img","canvas","ctx","blob","newFile","handleRemoveSuccess","uploadFile","http","handleExceed","ElMessage","handlePictureCardPreview","handleBeforeUpload","fileName","uploadRequest","handleFileNameChange","index","ElLoading","formData","axios","res"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,UAAMA,IAAOC,GACPC,IAAQC,GAoBRC,IAAQC,EAAS,MACdH,EAAM,KAAK,IAAI,CAACI,MAAS;AAC9B,YAAMC,IAAWD,EAAK,IAAI,UAAUA,EAAK,IAAI,YAAY,GAAG,IAAI,CAAC;AACjE,UAAI,OAAOA,EAAK,SAAS;AACvB,eAAAA,EAAK,WAAWC,GACTD;AAGT,UAAIA,EAAK,KAAK;AACZ,cAAME,IAAQF,EAAK,IAAI,MAAM,GAAG;AAMhC,eALkB;AAAA,UAChB,GAAGA;AAAA,UACH,MAAME,EAAMA,EAAM,SAAS,CAAC;AAAA,UAC5B,UAAUD;AAAA,QAClB;A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;AAAA,QAChB,CAAS,GACD7B,EAAK,cAAcuC,EAAI,KAAK,IAAI,GAChCtB,EAAQsB,EAAI,IAAI,GACT,GACR,EACA,MAAM,MAAM;AACX,UAAAH,EAAU,UAAU,SACpBP,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDX,EAAO,eAAe;AAAA,QAC9B,CAAO;AAAA,MACP,CAAG;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { ref as c, computed as x, openBlock as i, createElementBlock as I, createVNode as p, unref as o, normalizeClass as k, withModifiers as E, withCtx as a, createBlock as d, createTextVNode as U, createElementVNode as T } from "vue";
|
|
2
|
-
import { ElUpload as V, ElIcon as B, ElButton as z, ElDialog as N, ElMessage as f } from "element-plus";
|
|
3
|
-
import { _ as C, p as D, h as M } from "./index-DWaIPnvt.js";
|
|
4
|
-
import "./el-progress-l0sNRNKZ.js";
|
|
5
|
-
const $ = ["src"], q = {
|
|
6
|
-
__name: "ImagesUploader",
|
|
7
|
-
props: {
|
|
8
|
-
images: {
|
|
9
|
-
type: Array,
|
|
10
|
-
default() {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
limit: { type: Number },
|
|
15
|
-
props: {
|
|
16
|
-
type: Object,
|
|
17
|
-
default() {
|
|
18
|
-
return {
|
|
19
|
-
listType: "picture-card",
|
|
20
|
-
limit: 5,
|
|
21
|
-
accept: "image/*"
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
emits: ["on-remove", "on-upload"],
|
|
27
|
-
setup(g, { emit: v }) {
|
|
28
|
-
const s = v, u = c(""), n = c(!1), t = g, m = x(() => t.images.map((e) => {
|
|
29
|
-
if (!(e != null && e.url))
|
|
30
|
-
return { ...e, name: "unknown", fileType: "unknown" };
|
|
31
|
-
const l = e.url.substring(e.url.lastIndexOf(".") + 1), r = e.url.split("/");
|
|
32
|
-
return {
|
|
33
|
-
...e,
|
|
34
|
-
name: r[r.length - 1],
|
|
35
|
-
fileType: l
|
|
36
|
-
};
|
|
37
|
-
}));
|
|
38
|
-
function y(e) {
|
|
39
|
-
t.props.deleteUrl ? M.remove(`${t.props.deleteUrl}/${e.id}/attachment`).then(() => {
|
|
40
|
-
s("on-remove", e);
|
|
41
|
-
}) : s("on-remove", e);
|
|
42
|
-
}
|
|
43
|
-
function _() {
|
|
44
|
-
f({
|
|
45
|
-
message: `最多只能上传 ${t.props.limit} 个文件!`,
|
|
46
|
-
type: "warning"
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function w(e) {
|
|
50
|
-
u.value = e.url, n.value = !0;
|
|
51
|
-
}
|
|
52
|
-
function b(e) {
|
|
53
|
-
return e.size > 5242880 ? (f({
|
|
54
|
-
message: "上传大小不能超过 5MB!",
|
|
55
|
-
type: "warning"
|
|
56
|
-
}), !1) : !0;
|
|
57
|
-
}
|
|
58
|
-
function h(e) {
|
|
59
|
-
const l = new FormData();
|
|
60
|
-
l.append("file", e.file), s("on-upload", l);
|
|
61
|
-
}
|
|
62
|
-
return (e, l) => (i(), I("div", null, [
|
|
63
|
-
p(o(V), {
|
|
64
|
-
"file-list": m.value,
|
|
65
|
-
limit: t.props.limit,
|
|
66
|
-
accept: t.props.accept,
|
|
67
|
-
"list-type": t.props.listType,
|
|
68
|
-
"on-remove": y,
|
|
69
|
-
"on-exceed": _,
|
|
70
|
-
"on-preview": w,
|
|
71
|
-
multiple: !0,
|
|
72
|
-
"before-upload": b,
|
|
73
|
-
"http-request": h,
|
|
74
|
-
"show-file-list": t.props.listType !== "text",
|
|
75
|
-
class: k([
|
|
76
|
-
"upload-main",
|
|
77
|
-
{ "disable-upload": m.value.length >= t.props.limit }
|
|
78
|
-
]),
|
|
79
|
-
onClick: l[0] || (l[0] = E(() => {
|
|
80
|
-
}, ["prevent"]))
|
|
81
|
-
}, {
|
|
82
|
-
default: a(() => [
|
|
83
|
-
t.props.listType !== "text" ? (i(), d(o(B), {
|
|
84
|
-
key: 0,
|
|
85
|
-
disabled: !0
|
|
86
|
-
}, {
|
|
87
|
-
default: a(() => [
|
|
88
|
-
p(o(D))
|
|
89
|
-
]),
|
|
90
|
-
_: 1
|
|
91
|
-
})) : (i(), d(o(z), {
|
|
92
|
-
key: 1,
|
|
93
|
-
class: "upload-button",
|
|
94
|
-
type: "primary"
|
|
95
|
-
}, {
|
|
96
|
-
default: a(() => [
|
|
97
|
-
U(" 上传附件 ")
|
|
98
|
-
]),
|
|
99
|
-
_: 1
|
|
100
|
-
}))
|
|
101
|
-
]),
|
|
102
|
-
_: 1
|
|
103
|
-
}, 8, ["file-list", "limit", "accept", "list-type", "show-file-list", "class"]),
|
|
104
|
-
p(o(N), {
|
|
105
|
-
modelValue: n.value,
|
|
106
|
-
"onUpdate:modelValue": l[1] || (l[1] = (r) => n.value = r)
|
|
107
|
-
}, {
|
|
108
|
-
default: a(() => [
|
|
109
|
-
T("img", {
|
|
110
|
-
"w-full": "",
|
|
111
|
-
src: u.value,
|
|
112
|
-
alt: "Preview Image"
|
|
113
|
-
}, null, 8, $)
|
|
114
|
-
]),
|
|
115
|
-
_: 1
|
|
116
|
-
}, 8, ["modelValue"])
|
|
117
|
-
]));
|
|
118
|
-
}
|
|
119
|
-
}, A = /* @__PURE__ */ C(q, [["__scopeId", "data-v-b0c153d3"]]);
|
|
120
|
-
export {
|
|
121
|
-
A as default
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=ImagesUploader-CD6qu0oD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ImagesUploader-CD6qu0oD.js","sources":["../src/framework/field/images/ImagesUploader.vue"],"sourcesContent":["<script setup>\nimport { ElUpload, ElDialog, ElIcon, ElButton } from \"element-plus\";\nimport { computed, ref } from \"vue\";\nimport { ElMessage } from \"element-plus\";\nimport { Plus } from \"@element-plus/icons-vue\";\nimport http from \"../../utils/http\";\n\nconst emit = defineEmits([\"on-remove\", \"on-upload\"]);\nconst dialogImageUrl = ref(\"\");\nconst dialogVisible = ref(false);\nconst props = defineProps({\n images: {\n type: Array,\n default() {\n return [];\n },\n },\n limit: { type: Number },\n props: {\n type: Object,\n default() {\n return {\n listType: \"picture-card\",\n limit: 5,\n accept: \"image/*\",\n };\n },\n },\n});\n\nconst files = computed(() => {\n return props.images.map((item) => {\n if (!item?.url) {\n return { ...item, name: \"unknown\", fileType: \"unknown\" };\n }\n\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\n const parts = item.url.split(\"/\");\n const namedItem = {\n ...item,\n name: parts[parts.length - 1],\n fileType,\n };\n return namedItem;\n });\n});\n\nfunction onRemove(uploadFile) {\n if (props.props.deleteUrl) {\n http\n .remove(`${props.props.deleteUrl}/${uploadFile.id}/attachment`)\n .then(() => {\n emit(\"on-remove\", uploadFile);\n });\n } else {\n emit(\"on-remove\", uploadFile);\n }\n}\n\nfunction onExceed() {\n ElMessage({\n message: `最多只能上传 ${props.props.limit} 个文件!`,\n type: \"warning\",\n });\n}\n\nfunction onPreview(uploadFile) {\n dialogImageUrl.value = uploadFile.url;\n dialogVisible.value = true;\n}\n\nfunction beforeUpload(uploadFile) {\n const limitSize = 1024 * 1024 * 5;\n if (uploadFile.size > limitSize) {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n\n return true;\n}\n\nfunction httpRequest(uploadFile) {\n const formData = new FormData();\n formData.append(\"file\", uploadFile.file);\n emit(\"on-upload\", formData);\n}\n</script>\n\n<template>\n <div>\n <el-upload\n :file-list=\"files\"\n :limit=\"props.props.limit\"\n :accept=\"props.props.accept\"\n :list-type=\"props.props.listType\"\n :on-remove=\"onRemove\"\n :on-exceed=\"onExceed\"\n :on-preview=\"onPreview\"\n :multiple=\"true\"\n :before-upload=\"beforeUpload\"\n :http-request=\"httpRequest\"\n :show-file-list=\"props.props.listType !== 'text'\"\n :class=\"[\n 'upload-main',\n { 'disable-upload': files.length >= props.props.limit },\n ]\"\n @click.prevent\n >\n <template v-if=\"props.props.listType !== 'text'\">\n <el-icon :disabled=\"true\">\n <Plus />\n </el-icon>\n </template>\n <template v-else>\n <el-button class=\"upload-button\" type=\"primary\"> 上传附件 </el-button>\n </template>\n </el-upload>\n <el-dialog v-model=\"dialogVisible\">\n <img w-full :src=\"dialogImageUrl\" alt=\"Preview Image\" />\n </el-dialog>\n </div>\n</template>\n<style scoped lang=\"scss\">\n:deep(.el-upload-list) {\n .el-upload-list__item-actions span {\n margin-left: 20px;\n }\n}\n\n.disable-upload {\n :deep(.el-upload--picture-card) {\n display: none !important;\n }\n\n :deep(.el-upload--text) {\n display: none !important;\n }\n\n :deep(.el-upload--picture) {\n display: none !important;\n }\n}\n.upload-main {\n flex-basis: 100%;\n}\n.file-list {\n display: flex;\n align-items: center;\n margin-top: 10px;\n .file-type {\n height: 22px;\n line-height: 22px;\n margin-right: 5px;\n background: #eeeeee;\n border-radius: 4px;\n font-size: 12px;\n padding: 0 4px;\n }\n :deep(.el-form-item__content) {\n display: contents;\n }\n :deep(.el-input__wrapper) {\n margin: 0 5px;\n }\n :deep(.el-input__inner) {\n height: 20px;\n line-height: 20px;\n }\n}\n</style>\n"],"names":["emit","__emit","dialogImageUrl","ref","dialogVisible","props","__props","files","computed","item","fileType","parts","onRemove","uploadFile","http","onExceed","ElMessage","onPreview","beforeUpload","httpRequest","formData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,UAAMA,IAAOC,GACPC,IAAiBC,EAAI,EAAE,GACvBC,IAAgBD,EAAI,EAAK,GACzBE,IAAQC,GAoBRC,IAAQC,EAAS,MACdH,EAAM,OAAO,IAAI,CAACI,MAAS;AAChC,UAAI,EAACA,KAAA,QAAAA,EAAM;AACT,eAAO,EAAE,GAAGA,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