kouxiangtang 0.1.67 → 0.1.69
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/dist/{AttachmentUploader-BY2VmOGE.js → AttachmentUploader-CGIxhZSf.js} +7 -7
- package/dist/{AttachmentUploader-BY2VmOGE.js.map → AttachmentUploader-CGIxhZSf.js.map} +1 -1
- package/dist/{ImageUploader-DCJkLQTW.js → ImageUploader-BbNg_ohz.js} +9 -9
- package/dist/{ImageUploader-DCJkLQTW.js.map → ImageUploader-BbNg_ohz.js.map} +1 -1
- package/dist/{ImagesUploader-BC0EK9qE.js → ImagesUploader-DhPd72H6.js} +63 -48
- package/dist/ImagesUploader-DhPd72H6.js.map +1 -0
- package/dist/{RichTextEditor-x1Xbn7_6.js → RichTextEditor-Dh_2ZXzZ.js} +2 -2
- package/dist/{RichTextEditor-x1Xbn7_6.js.map → RichTextEditor-Dh_2ZXzZ.js.map} +1 -1
- package/dist/{config-CEzYD1Ie.js → config-B3771Y2l.js} +2 -2
- package/dist/{config-CEzYD1Ie.js.map → config-B3771Y2l.js.map} +1 -1
- package/dist/{config-CEPoxT-s.js → config-BB44dsTE.js} +2 -2
- package/dist/{config-CEPoxT-s.js.map → config-BB44dsTE.js.map} +1 -1
- package/dist/{config-CMBZn3Km.js → config-BFC0xPvP.js} +2 -2
- package/dist/{config-CMBZn3Km.js.map → config-BFC0xPvP.js.map} +1 -1
- package/dist/{config-Jh1yifwo.js → config-BdbPBT2v.js} +2 -2
- package/dist/{config-Jh1yifwo.js.map → config-BdbPBT2v.js.map} +1 -1
- package/dist/{config-ZqnSV1Oa.js → config-BpKI2LuP.js} +2 -2
- package/dist/{config-ZqnSV1Oa.js.map → config-BpKI2LuP.js.map} +1 -1
- package/dist/{config-D8kYgBbw.js → config-CgVuaa78.js} +2 -2
- package/dist/{config-D8kYgBbw.js.map → config-CgVuaa78.js.map} +1 -1
- package/dist/{config-HFvGqnsM.js → config-CoU67a6x.js} +2 -2
- package/dist/{config-HFvGqnsM.js.map → config-CoU67a6x.js.map} +1 -1
- package/dist/{config-CxuCSgD1.js → config-CobVUqZO.js} +2 -2
- package/dist/{config-CxuCSgD1.js.map → config-CobVUqZO.js.map} +1 -1
- package/dist/{config-DGqxX7pQ.js → config-Cs82wQdE.js} +2 -2
- package/dist/{config-DGqxX7pQ.js.map → config-Cs82wQdE.js.map} +1 -1
- package/dist/{config-0tpL6UOh.js → config-CzGC70H6.js} +2 -2
- package/dist/{config-0tpL6UOh.js.map → config-CzGC70H6.js.map} +1 -1
- package/dist/{config-jIBL42h8.js → config-DABmQ7FP.js} +3 -3
- package/dist/{config-jIBL42h8.js.map → config-DABmQ7FP.js.map} +1 -1
- package/dist/{config-CivPj9pn.js → config-DBV30j7X.js} +2 -2
- package/dist/{config-CivPj9pn.js.map → config-DBV30j7X.js.map} +1 -1
- package/dist/{config-Cm-RXOeu.js → config-DFVU1Q78.js} +7 -7
- package/dist/{config-Cm-RXOeu.js.map → config-DFVU1Q78.js.map} +1 -1
- package/dist/{config-Bq9AD6oO.js → config-DGV7UyEp.js} +2 -2
- package/dist/{config-Bq9AD6oO.js.map → config-DGV7UyEp.js.map} +1 -1
- package/dist/{config-Clg5BOae.js → config-DNVU9P3U.js} +3 -3
- package/dist/{config-Clg5BOae.js.map → config-DNVU9P3U.js.map} +1 -1
- package/dist/{config-Ckry3bhy.js → config-DpboXrzy.js} +2 -2
- package/dist/{config-Ckry3bhy.js.map → config-DpboXrzy.js.map} +1 -1
- package/dist/{config-BCbHEasL.js → config-UijjpIjH.js} +2 -2
- package/dist/{config-BCbHEasL.js.map → config-UijjpIjH.js.map} +1 -1
- package/dist/{config-Oyq5iB6l.js → config-bdP64uLM.js} +2 -2
- package/dist/{config-Oyq5iB6l.js.map → config-bdP64uLM.js.map} +1 -1
- package/dist/{config-D63cyALs.js → config-pRnErWTs.js} +2 -2
- package/dist/{config-D63cyALs.js.map → config-pRnErWTs.js.map} +1 -1
- package/dist/{config-6SRW9E8s.js → config-xzJD9mct.js} +2 -2
- package/dist/{config-6SRW9E8s.js.map → config-xzJD9mct.js.map} +1 -1
- package/dist/{index-DNFSi8-n.js → index-37PxYvCK.js} +16 -16
- package/dist/{index-DNFSi8-n.js.map → index-37PxYvCK.js.map} +1 -1
- package/dist/kouxiangtang.js +1 -1
- package/dist/kouxiangtang.umd.cjs +11 -11
- package/dist/kouxiangtang.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/ImagesUploader-BC0EK9qE.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { computed as F, ref as y, openBlock as c, createElementBlock as k, Fragment as E, createVNode as r, unref as n, normalizeClass as M, withModifiers as R, withCtx as i, createBlock as f, createTextVNode as
|
|
1
|
+
import { computed as F, ref as y, openBlock as c, createElementBlock as k, Fragment as E, createVNode as r, unref as n, normalizeClass as M, withModifiers as R, withCtx as i, createBlock as f, createTextVNode as L, createElementVNode as U, renderList as O, toDisplayString as S, createCommentVNode as j } from "vue";
|
|
2
2
|
import { ElUpload as q, ElIcon as v, ElButton as W, ElDialog as G, ElForm as H, ElFormItem as J, ElInput as K, ElMessage as u, ElLoading as w } from "element-plus";
|
|
3
|
-
import { _ as Q,
|
|
3
|
+
import { _ as Q, k as X, p as Y, a as Z, m as ee, h as te, n as ae } from "./index-37PxYvCK.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
5
|
const se = ["src"], ne = { class: "file-type" }, le = {
|
|
6
6
|
__name: "AttachmentUploader",
|
|
@@ -158,7 +158,7 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
158
158
|
type: "primary"
|
|
159
159
|
}, {
|
|
160
160
|
default: i(() => [
|
|
161
|
-
|
|
161
|
+
L(" 上传附件 ")
|
|
162
162
|
]),
|
|
163
163
|
_: 1
|
|
164
164
|
}))
|
|
@@ -180,7 +180,7 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
180
180
|
}, 8, ["modelValue"]),
|
|
181
181
|
s.props.listType == "text" ? (c(), f(n(H), { key: 0 }, {
|
|
182
182
|
default: i(() => [
|
|
183
|
-
(c(!0), k(E, null,
|
|
183
|
+
(c(!0), k(E, null, O(g.value, (a, l) => (c(), f(n(J), {
|
|
184
184
|
key: l,
|
|
185
185
|
class: "file-list"
|
|
186
186
|
}, {
|
|
@@ -199,7 +199,7 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
199
199
|
"onUpdate:modelValue": (o) => a.name = o,
|
|
200
200
|
onChange: (o) => D(a)
|
|
201
201
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "onChange"]),
|
|
202
|
-
U("span", ne, "." +
|
|
202
|
+
U("span", ne, "." + S(a.fileType), 1),
|
|
203
203
|
r(n(v), {
|
|
204
204
|
color: "#73767a",
|
|
205
205
|
size: 12,
|
|
@@ -215,11 +215,11 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
215
215
|
}, 1024))), 128))
|
|
216
216
|
]),
|
|
217
217
|
_: 1
|
|
218
|
-
})) :
|
|
218
|
+
})) : j("", !0)
|
|
219
219
|
], 64));
|
|
220
220
|
}
|
|
221
221
|
}, ce = /* @__PURE__ */ Q(le, [["__scopeId", "data-v-6589fe18"]]);
|
|
222
222
|
export {
|
|
223
223
|
ce as default
|
|
224
224
|
};
|
|
225
|
-
//# sourceMappingURL=AttachmentUploader-
|
|
225
|
+
//# sourceMappingURL=AttachmentUploader-CGIxhZSf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentUploader-BY2VmOGE.js","sources":["../src/framework/field/attachment/AttachmentUploader.vue"],"sourcesContent":["<script setup>\r\nimport {\r\n ElUpload,\r\n ElIcon,\r\n ElDialog,\r\n ElForm,\r\n ElFormItem,\r\n ElButton,\r\n ElInput,\r\n} from \"element-plus\";\r\nimport axios from \"axios\";\r\nimport http from \"../../utils/http\";\r\nimport { getConfig } from \"../../config-loader\";\r\nimport { ref, computed } from \"vue\";\r\nimport { ElLoading, ElMessage } from \"element-plus\";\r\nimport { Plus, Document, Close } from \"@element-plus/icons-vue\";\r\n\r\nconst emit = defineEmits([\"on-success\", \"on-remove\", \"on-change\"]);\r\nconst props = defineProps({\r\n pics: {\r\n type: Array,\r\n default() {\r\n return [];\r\n },\r\n },\r\n limit: { type: Number },\r\n props: {\r\n type: Object,\r\n default() {\r\n return {\r\n listType: \"picture-card\", //'text' | 'picture' | 'picture-card'\r\n limit: 5, //最多上传几个文件\r\n accept: \"image/*\",\r\n };\r\n },\r\n },\r\n});\r\n\r\nconst files = computed(() => {\r\n return props.pics.map((item) => {\r\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\r\n if (typeof item.name !== undefined) {\r\n item.fileType = fileType;\r\n return item;\r\n }\r\n\r\n if (item.url) {\r\n const parts = item.url.split(\"/\");\r\n const namedItem = {\r\n ...item,\r\n name: parts[parts.length - 1],\r\n fileType: fileType,\r\n };\r\n return namedItem;\r\n }\r\n\r\n return { ...item, name: item.id, fileType: fileType };\r\n });\r\n});\r\nconst dialogImageUrl = ref(\"\");\r\nconst dialogVisible = ref(false);\r\nconst imageUrl = ref(props);\r\nconst uploadUrl = getConfig().fileUploadUrl;\r\nconst header = {\r\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\r\n};\r\nconst compressImg = (file) => {\r\n const reader = new FileReader();\r\n reader.readAsDataURL(file);\r\n\r\n return new Promise(function (resolve, reject) {\r\n if (!file.type.startsWith(\"image/\")) {\r\n resolve(file);\r\n return false;\r\n }\r\n reader.onload = async (e) => {\r\n const img = new Image();\r\n img.src = e.target.result;\r\n img.onload = () => {\r\n const canvas = document.createElement(\"canvas\");\r\n const ctx = canvas.getContext(\"2d\");\r\n canvas.width = img.width;\r\n canvas.height = img.height;\r\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\r\n canvas.toBlob(\r\n (blob) => {\r\n const newFile = new File([blob], file.name, {\r\n type: file.type,\r\n lastModified: Date.now(),\r\n });\r\n resolve(newFile);\r\n },\r\n file.type,\r\n 0.5,\r\n );\r\n };\r\n };\r\n return false;\r\n });\r\n};\r\nconst handleRemoveSuccess = (uploadFile) => {\r\n if (uploadFile.status === \"success\") {\r\n if (props.props.deleteParams) {\r\n const paramsData = props.props.deleteParams?.data\r\n ? props.props.deleteParams?.data\r\n : {};\r\n http\r\n .remove(\r\n `${props.props.deleteParams.url}/${uploadFile.id}/attachment`,\r\n paramsData,\r\n paramsData,\r\n )\r\n .then(() => {\r\n emit(\"on-remove\", uploadFile);\r\n });\r\n } else {\r\n emit(\"on-remove\", uploadFile);\r\n }\r\n }\r\n};\r\nconst handleExceed = () => {\r\n ElMessage({\r\n message: `最多只能上传 ${props.props.limit} 个文件!`,\r\n type: \"warning\",\r\n });\r\n};\r\nconst handlePictureCardPreview = (uploadFile) => {\r\n dialogImageUrl.value = uploadFile.url;\r\n dialogVisible.value = true;\r\n};\r\nconst handleBeforeUpload = (file) => {\r\n const fileName = file.name.substring(0, file.name.lastIndexOf(\".\"));\r\n const regex = /^[\\u4e00-\\u9fa5\\w\\-()(). ]+$/;\r\n if (!regex.test(fileName)) {\r\n ElMessage({\r\n message: \"请勿输入特殊字符!\",\r\n type: \"warning\",\r\n });\r\n return false;\r\n }\r\n compressImg(file).then((newFile) => {\r\n if (newFile.size / 1024 / 1024 < 5) {\r\n uploadRequest(newFile);\r\n return false;\r\n } else {\r\n ElMessage({\r\n message: \"上传大小不能超过 5MB!\",\r\n type: \"warning\",\r\n });\r\n return false;\r\n }\r\n });\r\n};\r\n\r\nfunction handleFileNameChange(file, index) {\r\n if (!file.name) {\r\n ElMessage({\r\n message: \"附件名称不能为空!\",\r\n type: \"warning\",\r\n });\r\n return;\r\n }\r\n emit(\"on-change\", file);\r\n}\r\n\r\nfunction uploadRequest(file) {\r\n ElLoading.service({ text: \"上传中,请稍后\", background: \"rgba(0,0,0,0.3)\" });\r\n return new Promise((resolve, reject) => {\r\n const formData = new FormData();\r\n formData.append(\"file\", file);\r\n axios\r\n .post(uploadUrl, formData, {})\r\n .then((res) => {\r\n ElLoading.service().close();\r\n ElMessage({\r\n message: \"上传成功\",\r\n type: \"success\",\r\n });\r\n emit(\"on-success\", res.data.data);\r\n resolve(res.data);\r\n return false;\r\n })\r\n .catch(() => {\r\n ElLoading.service().close();\r\n ElMessage({\r\n message: \"上传失败\",\r\n type: \"warning\",\r\n });\r\n reject(\"Upload failed\");\r\n });\r\n });\r\n}\r\n</script>\r\n\r\n<template>\r\n <!-- 删除请求头加权限后请添加到组建中 :headers=\"header\"-->\r\n <el-upload\r\n :file-list=\"files\"\r\n :action=\"uploadUrl\"\r\n :limit=\"props.props.limit\"\r\n :accept=\"props.props.accept\"\r\n :list-type=\"props.props.listType\"\r\n :on-remove=\"handleRemoveSuccess\"\r\n :before-upload=\"handleBeforeUpload\"\r\n :on-exceed=\"handleExceed\"\r\n :on-preview=\"handlePictureCardPreview\"\r\n :multiple=\"true\"\r\n :http-request=\"\r\n () => {\r\n return false;\r\n }\r\n \"\r\n :show-file-list=\"props.props.listType !== 'text'\"\r\n :class=\"[\r\n 'upload-main',\r\n { 'disable-upload': files.length >= props.props.limit },\r\n ]\"\r\n @click.prevent\r\n >\r\n <template v-if=\"props.props.listType !== 'text'\">\r\n <el-icon :disabled=\"true\">\r\n <Plus />\r\n </el-icon>\r\n </template>\r\n <template v-else>\r\n <el-button class=\"upload-button\" type=\"primary\"> 上传附件 </el-button>\r\n </template>\r\n </el-upload>\r\n <el-dialog v-model=\"dialogVisible\">\r\n <img w-full :src=\"dialogImageUrl\" alt=\"Preview Image\" />\r\n </el-dialog>\r\n <el-form v-if=\"props.props.listType == 'text'\">\r\n <el-form-item v-for=\"(file, index) in files\" :key=\"index\" class=\"file-list\">\r\n <el-icon color=\"#73767a\" :size=\"14\">\r\n <Document />\r\n </el-icon>\r\n <el-input\r\n v-model=\"file.name\"\r\n @change=\"handleFileNameChange(file, index)\"\r\n />\r\n <span class=\"file-type\">.{{ file.fileType }}</span>\r\n <el-icon color=\"#73767a\" :size=\"12\" @click=\"handleRemoveSuccess(file)\">\r\n <Close />\r\n </el-icon>\r\n </el-form-item>\r\n </el-form>\r\n</template>\r\n<style scoped lang=\"scss\">\r\n:deep(.el-upload-list) {\r\n .el-upload-list__item-actions span {\r\n margin-left: 20px;\r\n }\r\n}\r\n\r\n.disable-upload {\r\n :deep(.el-upload--picture-card) {\r\n display: none !important;\r\n }\r\n\r\n :deep(.el-upload--text) {\r\n display: none !important;\r\n }\r\n\r\n :deep(.el-upload--picture) {\r\n display: none !important;\r\n }\r\n}\r\n.upload-main {\r\n flex-basis: 100%;\r\n}\r\n.file-list {\r\n display: flex;\r\n align-items: center;\r\n margin-top: 10px;\r\n .file-type {\r\n height: 22px;\r\n line-height: 22px;\r\n margin-right: 5px;\r\n background: #eeeeee;\r\n border-radius: 4px;\r\n font-size: 12px;\r\n padding: 0 4px;\r\n }\r\n :deep(.el-form-item__content) {\r\n display: contents;\r\n }\r\n :deep(.el-input__wrapper) {\r\n margin: 0 5px;\r\n }\r\n :deep(.el-input__inner) {\r\n height: 20px;\r\n line-height: 20px;\r\n }\r\n}\r\n</style>\r\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","paramsData","_a","_b","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;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ACD;AAAA,MACD;AACD,MAAAhC,EAAK,aAAae,CAAI;AAAA,IACxB;AAEA,aAASqB,EAAcrB,GAAM;AAC3B,aAAAwB,EAAU,QAAQ,EAAE,MAAM,WAAW,YAAY,kBAAiB,CAAE,GAC7D,IAAI,QAAQ,CAACtB,GAASC,MAAW;AACtC,cAAMsB,IAAW,IAAI;AACrB,QAAAA,EAAS,OAAO,QAAQzB,CAAI,GAC5B0B,GACG,KAAK7B,GAAW4B,GAAU,EAAE,EAC5B,KAAK,CAACE,OACLH,EAAU,UAAU,SACpBP,EAAU;AAAA,UACR,SAAS;AAAA,UACT,MAAM;AAAA,QAChB,CAAS,GACDhC,EAAK,cAAc0C,EAAI,KAAK,IAAI,GAChCzB,EAAQyB,EAAI,IAAI,GACT,GACR,EACA,MAAM,MAAM;AACX,UAAAH,EAAU,UAAU,SACpBP,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDd,EAAO,eAAe;AAAA,QAC9B,CAAO;AAAA,MACP,CAAG;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"AttachmentUploader-CGIxhZSf.js","sources":["../src/framework/field/attachment/AttachmentUploader.vue"],"sourcesContent":["<script setup>\r\nimport {\r\n ElUpload,\r\n ElIcon,\r\n ElDialog,\r\n ElForm,\r\n ElFormItem,\r\n ElButton,\r\n ElInput,\r\n} from \"element-plus\";\r\nimport axios from \"axios\";\r\nimport http from \"../../utils/http\";\r\nimport { getConfig } from \"../../config-loader\";\r\nimport { ref, computed } from \"vue\";\r\nimport { ElLoading, ElMessage } from \"element-plus\";\r\nimport { Plus, Document, Close } from \"@element-plus/icons-vue\";\r\n\r\nconst emit = defineEmits([\"on-success\", \"on-remove\", \"on-change\"]);\r\nconst props = defineProps({\r\n pics: {\r\n type: Array,\r\n default() {\r\n return [];\r\n },\r\n },\r\n limit: { type: Number },\r\n props: {\r\n type: Object,\r\n default() {\r\n return {\r\n listType: \"picture-card\", //'text' | 'picture' | 'picture-card'\r\n limit: 5, //最多上传几个文件\r\n accept: \"image/*\",\r\n };\r\n },\r\n },\r\n});\r\n\r\nconst files = computed(() => {\r\n return props.pics.map((item) => {\r\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\r\n if (typeof item.name !== undefined) {\r\n item.fileType = fileType;\r\n return item;\r\n }\r\n\r\n if (item.url) {\r\n const parts = item.url.split(\"/\");\r\n const namedItem = {\r\n ...item,\r\n name: parts[parts.length - 1],\r\n fileType: fileType,\r\n };\r\n return namedItem;\r\n }\r\n\r\n return { ...item, name: item.id, fileType: fileType };\r\n });\r\n});\r\nconst dialogImageUrl = ref(\"\");\r\nconst dialogVisible = ref(false);\r\nconst imageUrl = ref(props);\r\nconst uploadUrl = getConfig().fileUploadUrl;\r\nconst header = {\r\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\r\n};\r\nconst compressImg = (file) => {\r\n const reader = new FileReader();\r\n reader.readAsDataURL(file);\r\n\r\n return new Promise(function (resolve, reject) {\r\n if (!file.type.startsWith(\"image/\")) {\r\n resolve(file);\r\n return false;\r\n }\r\n reader.onload = async (e) => {\r\n const img = new Image();\r\n img.src = e.target.result;\r\n img.onload = () => {\r\n const canvas = document.createElement(\"canvas\");\r\n const ctx = canvas.getContext(\"2d\");\r\n canvas.width = img.width;\r\n canvas.height = img.height;\r\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\r\n canvas.toBlob(\r\n (blob) => {\r\n const newFile = new File([blob], file.name, {\r\n type: file.type,\r\n lastModified: Date.now(),\r\n });\r\n resolve(newFile);\r\n },\r\n file.type,\r\n 0.5,\r\n );\r\n };\r\n };\r\n return false;\r\n });\r\n};\r\nconst handleRemoveSuccess = (uploadFile) => {\r\n if (uploadFile.status === \"success\") {\r\n if (props.props.deleteParams) {\r\n const paramsData = props.props.deleteParams?.data\r\n ? props.props.deleteParams?.data\r\n : {};\r\n http\r\n .remove(\r\n `${props.props.deleteParams.url}/${uploadFile.id}/attachment`,\r\n paramsData,\r\n paramsData,\r\n )\r\n .then(() => {\r\n emit(\"on-remove\", uploadFile);\r\n });\r\n } else {\r\n emit(\"on-remove\", uploadFile);\r\n }\r\n }\r\n};\r\nconst handleExceed = () => {\r\n ElMessage({\r\n message: `最多只能上传 ${props.props.limit} 个文件!`,\r\n type: \"warning\",\r\n });\r\n};\r\nconst handlePictureCardPreview = (uploadFile) => {\r\n dialogImageUrl.value = uploadFile.url;\r\n dialogVisible.value = true;\r\n};\r\nconst handleBeforeUpload = (file) => {\r\n const fileName = file.name.substring(0, file.name.lastIndexOf(\".\"));\r\n const regex = /^[\\u4e00-\\u9fa5\\w\\-()(). ]+$/;\r\n if (!regex.test(fileName)) {\r\n ElMessage({\r\n message: \"请勿输入特殊字符!\",\r\n type: \"warning\",\r\n });\r\n return false;\r\n }\r\n compressImg(file).then((newFile) => {\r\n if (newFile.size / 1024 / 1024 < 5) {\r\n uploadRequest(newFile);\r\n return false;\r\n } else {\r\n ElMessage({\r\n message: \"上传大小不能超过 5MB!\",\r\n type: \"warning\",\r\n });\r\n return false;\r\n }\r\n });\r\n};\r\n\r\nfunction handleFileNameChange(file, index) {\r\n if (!file.name) {\r\n ElMessage({\r\n message: \"附件名称不能为空!\",\r\n type: \"warning\",\r\n });\r\n return;\r\n }\r\n emit(\"on-change\", file);\r\n}\r\n\r\nfunction uploadRequest(file) {\r\n ElLoading.service({ text: \"上传中,请稍后\", background: \"rgba(0,0,0,0.3)\" });\r\n return new Promise((resolve, reject) => {\r\n const formData = new FormData();\r\n formData.append(\"file\", file);\r\n axios\r\n .post(uploadUrl, formData, {})\r\n .then((res) => {\r\n ElLoading.service().close();\r\n ElMessage({\r\n message: \"上传成功\",\r\n type: \"success\",\r\n });\r\n emit(\"on-success\", res.data.data);\r\n resolve(res.data);\r\n return false;\r\n })\r\n .catch(() => {\r\n ElLoading.service().close();\r\n ElMessage({\r\n message: \"上传失败\",\r\n type: \"warning\",\r\n });\r\n reject(\"Upload failed\");\r\n });\r\n });\r\n}\r\n</script>\r\n\r\n<template>\r\n <!-- 删除请求头加权限后请添加到组建中 :headers=\"header\"-->\r\n <el-upload\r\n :file-list=\"files\"\r\n :action=\"uploadUrl\"\r\n :limit=\"props.props.limit\"\r\n :accept=\"props.props.accept\"\r\n :list-type=\"props.props.listType\"\r\n :on-remove=\"handleRemoveSuccess\"\r\n :before-upload=\"handleBeforeUpload\"\r\n :on-exceed=\"handleExceed\"\r\n :on-preview=\"handlePictureCardPreview\"\r\n :multiple=\"true\"\r\n :http-request=\"\r\n () => {\r\n return false;\r\n }\r\n \"\r\n :show-file-list=\"props.props.listType !== 'text'\"\r\n :class=\"[\r\n 'upload-main',\r\n { 'disable-upload': files.length >= props.props.limit },\r\n ]\"\r\n @click.prevent\r\n >\r\n <template v-if=\"props.props.listType !== 'text'\">\r\n <el-icon :disabled=\"true\">\r\n <Plus />\r\n </el-icon>\r\n </template>\r\n <template v-else>\r\n <el-button class=\"upload-button\" type=\"primary\"> 上传附件 </el-button>\r\n </template>\r\n </el-upload>\r\n <el-dialog v-model=\"dialogVisible\">\r\n <img w-full :src=\"dialogImageUrl\" alt=\"Preview Image\" />\r\n </el-dialog>\r\n <el-form v-if=\"props.props.listType == 'text'\">\r\n <el-form-item v-for=\"(file, index) in files\" :key=\"index\" class=\"file-list\">\r\n <el-icon color=\"#73767a\" :size=\"14\">\r\n <Document />\r\n </el-icon>\r\n <el-input\r\n v-model=\"file.name\"\r\n @change=\"handleFileNameChange(file, index)\"\r\n />\r\n <span class=\"file-type\">.{{ file.fileType }}</span>\r\n <el-icon color=\"#73767a\" :size=\"12\" @click=\"handleRemoveSuccess(file)\">\r\n <Close />\r\n </el-icon>\r\n </el-form-item>\r\n </el-form>\r\n</template>\r\n<style scoped lang=\"scss\">\r\n:deep(.el-upload-list) {\r\n .el-upload-list__item-actions span {\r\n margin-left: 20px;\r\n }\r\n}\r\n\r\n.disable-upload {\r\n :deep(.el-upload--picture-card) {\r\n display: none !important;\r\n }\r\n\r\n :deep(.el-upload--text) {\r\n display: none !important;\r\n }\r\n\r\n :deep(.el-upload--picture) {\r\n display: none !important;\r\n }\r\n}\r\n.upload-main {\r\n flex-basis: 100%;\r\n}\r\n.file-list {\r\n display: flex;\r\n align-items: center;\r\n margin-top: 10px;\r\n .file-type {\r\n height: 22px;\r\n line-height: 22px;\r\n margin-right: 5px;\r\n background: #eeeeee;\r\n border-radius: 4px;\r\n font-size: 12px;\r\n padding: 0 4px;\r\n }\r\n :deep(.el-form-item__content) {\r\n display: contents;\r\n }\r\n :deep(.el-input__wrapper) {\r\n margin: 0 5px;\r\n }\r\n :deep(.el-input__inner) {\r\n height: 20px;\r\n line-height: 20px;\r\n }\r\n}\r\n</style>\r\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","paramsData","_a","_b","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,Q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,CAACtB,GAASC,MAAW;AACtC,cAAMsB,IAAW,IAAI;AACrB,QAAAA,EAAS,OAAO,QAAQzB,CAAI,GAC5B0B,GACG,KAAK7B,GAAW4B,GAAU,EAAE,EAC5B,KAAK,CAACE,OACLH,EAAU,UAAU,SACpBP,EAAU;AAAA,UACR,SAAS;AAAA,UACT,MAAM;AAAA,QAChB,CAAS,GACDhC,EAAK,cAAc0C,EAAI,KAAK,IAAI,GAChCzB,EAAQyB,EAAI,IAAI,GACT,GACR,EACA,MAAM,MAAM;AACX,UAAAH,EAAU,UAAU,SACpBP,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDd,EAAO,eAAe;AAAA,QAC9B,CAAO;AAAA,MACP,CAAG;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { openBlock as s, createBlock as o, unref as a, createSlots as v, withCtx as r, renderSlot as x, createVNode as m, withModifiers as I, createCommentVNode as S, createElementVNode as b, toDisplayString as B } from "vue";
|
|
2
2
|
import { ElUpload as E, ElIcon as u, ElMessage as i, ElLoading as l } from "element-plus";
|
|
3
|
-
import { _ as M,
|
|
3
|
+
import { _ as M, k as C, H as D, p as L, d as N, n as V } from "./index-37PxYvCK.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
|
-
const
|
|
5
|
+
const q = { class: "el-upload__tip" }, z = {
|
|
6
6
|
__name: "ImageUploader",
|
|
7
7
|
props: {
|
|
8
8
|
imageUrl: { type: String },
|
|
@@ -32,8 +32,8 @@ const j = { class: "el-upload__tip" }, q = {
|
|
|
32
32
|
function U() {
|
|
33
33
|
n("on-success", "");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return l.service({ text: "上传中,请稍后", background: "rgba(0,0,0,0.3)" }), new Promise((c,
|
|
35
|
+
function k(t) {
|
|
36
|
+
return l.service({ text: "上传中,请稍后", background: "rgba(0,0,0,0.3)" }), new Promise((c, w) => {
|
|
37
37
|
const d = new FormData();
|
|
38
38
|
d.append("image", t.file), V.post(p, d, {}).then((y) => {
|
|
39
39
|
l.service().close(), i({
|
|
@@ -44,7 +44,7 @@ const j = { class: "el-upload__tip" }, q = {
|
|
|
44
44
|
l.service().close(), i({
|
|
45
45
|
message: "上传失败",
|
|
46
46
|
type: "warning"
|
|
47
|
-
}),
|
|
47
|
+
}), w("Upload failed");
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -56,7 +56,7 @@ const j = { class: "el-upload__tip" }, q = {
|
|
|
56
56
|
accept: e.props.accept,
|
|
57
57
|
"on-success": h,
|
|
58
58
|
"before-upload": _,
|
|
59
|
-
"http-request":
|
|
59
|
+
"http-request": k
|
|
60
60
|
}, v({
|
|
61
61
|
default: r(() => [
|
|
62
62
|
x(t.$slots, "default", {}, void 0, !0),
|
|
@@ -94,14 +94,14 @@ const j = { class: "el-upload__tip" }, q = {
|
|
|
94
94
|
e.props.tip ? {
|
|
95
95
|
name: "tip",
|
|
96
96
|
fn: r(() => [
|
|
97
|
-
b("div",
|
|
97
|
+
b("div", q, B(e.props.tip), 1)
|
|
98
98
|
]),
|
|
99
99
|
key: "0"
|
|
100
100
|
} : void 0
|
|
101
101
|
]), 1032, ["action", "accept"]));
|
|
102
102
|
}
|
|
103
|
-
}, F = /* @__PURE__ */ M(
|
|
103
|
+
}, F = /* @__PURE__ */ M(z, [["__scopeId", "data-v-11ed7abf"]]);
|
|
104
104
|
export {
|
|
105
105
|
F as default
|
|
106
106
|
};
|
|
107
|
-
//# sourceMappingURL=ImageUploader-
|
|
107
|
+
//# sourceMappingURL=ImageUploader-BbNg_ohz.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUploader-
|
|
1
|
+
{"version":3,"file":"ImageUploader-BbNg_ohz.js","sources":["../src/framework/field/image/ImageUploader.vue"],"sourcesContent":["<script setup>\nimport { ElUpload, ElImage, ElIcon } from \"element-plus\";\nimport axios from \"axios\";\nimport { getConfig } from \"../../config-loader\";\nimport { ElLoading, ElMessage } from \"element-plus\";\nimport { Plus, Delete, Loading } from \"@element-plus/icons-vue\";\nimport HeicImage from \"../../component/HeicImage.vue\";\n\nconst emit = defineEmits([\"on-success\"]);\nconst props = defineProps({\n imageUrl: { type: String },\n props: {\n type: Object,\n default() {\n return {\n accept: \"image/*\",\n tip: \"\",\n };\n },\n },\n});\nconst uploadUrl = getConfig().imageUploadUrl;\nconst header = {\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\n};\nconst handleBeforeUpload = (uploadFile) => {\n const isLt2M = uploadFile.size / 1024 / 1024 < 5;\n if (!isLt2M) {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n};\nconst handleSuccess = (response) => {\n emit(\"on-success\", response.data.imageUrl);\n};\n\nfunction deleteImageUrl() {\n emit(\"on-success\", \"\");\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(\"image\", file.file);\n axios\n .post(uploadUrl, formData, {})\n .then((res) => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传成功\",\n type: \"success\",\n });\n resolve(res.data);\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 class=\"image-uploader\"\n :action=\"uploadUrl\"\n name=\"image\"\n :show-file-list=\"false\"\n :accept=\"props.props.accept\"\n :on-success=\"handleSuccess\"\n :before-upload=\"handleBeforeUpload\"\n :http-request=\"uploadRequest\"\n >\n <slot />\n <HeicImage\n v-if=\"props.imageUrl\"\n :src=\"props.imageUrl\"\n :preview-src-list=\"[props.imageUrl]\"\n fit=\"scale-down\"\n class=\"image\"\n width=\"146px\"\n height=\"146px\"\n hide-on-click-modal\n />\n <el-icon v-else class=\"uploader-icon\">\n <Plus />\n </el-icon>\n <el-icon\n v-if=\"props.imageUrl\"\n class=\"delete-icon\"\n @click.stop.prevent=\"deleteImageUrl\"\n >\n <Delete />\n </el-icon>\n <template v-if=\"props.props.tip\" #tip>\n <div class=\"el-upload__tip\">{{ props.props.tip }}</div>\n </template>\n </el-upload>\n</template>\n\n<style scoped lang=\"scss\">\n.image-uploader {\n :deep(.el-upload) {\n border: 1px dashed var(--el-border-color);\n border-radius: 6px;\n cursor: pointer;\n position: relative;\n overflow: hidden;\n transition: var(--el-transition-duration-fast);\n\n &:hover {\n border-color: var(--el-color-primary);\n }\n }\n\n .image {\n width: 146px;\n height: 146px;\n\n .placeholder-icon {\n width: 146px;\n height: 146px;\n font-size: 30px;\n color: #a7a7a7;\n }\n }\n\n .uploader-icon {\n font-size: 28px;\n color: #8c939d;\n width: 146px;\n height: 146px;\n text-align: center;\n }\n\n .delete-icon {\n font-size: 20px;\n color: #b7b4b4;\n position: absolute;\n top: 10px;\n right: 10px;\n }\n}\n</style>\n"],"names":["emit","__emit","props","__props","uploadUrl","getConfig","handleBeforeUpload","uploadFile","ElMessage","handleSuccess","response","deleteImageUrl","uploadRequest","file","ElLoading","resolve","reject","formData","axios","res"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQA,UAAMA,IAAOC,GACPC,IAAQC,GAYRC,IAAYC,EAAW,EAAC;AACf,IACY,gBAAa,QAAQ,OAAO;AAEvD,UAAMC,IAAqB,CAACC,MAAe;AAEzC,UAAI,EADWA,EAAW,OAAO,OAAO,OAAO;AAE7C,eAAAC,EAAU;AAAA,UACR,SAAS;AAAA,UACT,MAAM;AAAA,QACZ,CAAK,GACM;AAAA,IAEX,GACMC,IAAgB,CAACC,MAAa;AAClC,MAAAV,EAAK,cAAcU,EAAS,KAAK,QAAQ;AAAA,IAC3C;AAEA,aAASC,IAAiB;AACxB,MAAAX,EAAK,cAAc,EAAE;AAAA,IACvB;AAEA,aAASY,EAAcC,GAAM;AAC3B,aAAAC,EAAU,QAAQ,EAAE,MAAM,WAAW,YAAY,kBAAiB,CAAE,GAC7D,IAAI,QAAQ,CAACC,GAASC,MAAW;AACtC,cAAMC,IAAW,IAAI;AACrB,QAAAA,EAAS,OAAO,SAASJ,EAAK,IAAI,GAClCK,EACG,KAAKd,GAAWa,GAAU,EAAE,EAC5B,KAAK,CAACE,MAAQ;AACb,UAAAL,EAAU,UAAU,SACpBN,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDO,EAAQI,EAAI,IAAI;AAAA,QACxB,CAAO,EACA,MAAM,MAAM;AACX,UAAAL,EAAU,UAAU,SACpBN,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDQ,EAAO,eAAe;AAAA,QAC9B,CAAO;AAAA,MACP,CAAG;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import {
|
|
3
|
-
import { _ as q, H,
|
|
1
|
+
import { ref as v, computed as C, openBlock as r, createElementBlock as c, Fragment as P, renderList as T, createBlock as m, createCommentVNode as U, createElementVNode as f, withModifiers as y, createVNode as i, unref as s, withCtx as o, normalizeClass as B, createSlots as D, createTextVNode as N, toDisplayString as z } from "vue";
|
|
2
|
+
import { ElIcon as w, ElUpload as S, ElButton as $, ElDialog as M, ElMessage as h } from "element-plus";
|
|
3
|
+
import { _ as q, H, d as O, p as R, h as j } from "./index-37PxYvCK.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
|
-
const
|
|
5
|
+
const A = {
|
|
6
|
+
style: { display: "flex", "flex-wrap": "wrap" },
|
|
7
|
+
class: "images-uploader"
|
|
8
|
+
}, L = ["onClick"], F = { class: "el-upload__tip" }, G = ["src"], J = {
|
|
6
9
|
__name: "ImagesUploader",
|
|
7
10
|
props: {
|
|
8
11
|
images: {
|
|
@@ -25,8 +28,8 @@ const j = { style: { display: "flex", "flex-wrap": "wrap" } }, A = { class: "el-
|
|
|
25
28
|
}
|
|
26
29
|
},
|
|
27
30
|
emits: ["on-remove", "on-upload"],
|
|
28
|
-
setup(
|
|
29
|
-
const
|
|
31
|
+
setup(k, { emit: x }) {
|
|
32
|
+
const p = x, _ = v(""), u = v(!1), t = k, d = C(() => t.images.map((e) => {
|
|
30
33
|
if (!(e != null && e.url))
|
|
31
34
|
return { ...e, name: "unknown", fileType: "unknown" };
|
|
32
35
|
const l = e.url.substring(e.url.lastIndexOf(".") + 1), a = e.url.split("/");
|
|
@@ -36,44 +39,45 @@ const j = { style: { display: "flex", "flex-wrap": "wrap" } }, A = { class: "el-
|
|
|
36
39
|
fileType: l
|
|
37
40
|
};
|
|
38
41
|
}));
|
|
39
|
-
function
|
|
42
|
+
function g(e) {
|
|
40
43
|
var l, a;
|
|
41
44
|
if (t.props.deleteParams) {
|
|
42
|
-
const
|
|
43
|
-
|
|
45
|
+
const n = (l = t.props.deleteParams) != null && l.data ? (a = t.props.deleteParams) == null ? void 0 : a.data : {};
|
|
46
|
+
j.remove(
|
|
44
47
|
`${t.props.deleteParams.url}/${e.id}/attachment`,
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
n,
|
|
49
|
+
n
|
|
47
50
|
).then(() => {
|
|
48
|
-
|
|
51
|
+
p("on-remove", e);
|
|
49
52
|
});
|
|
50
53
|
} else
|
|
51
|
-
|
|
54
|
+
p("on-remove", e);
|
|
52
55
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
56
|
+
function I() {
|
|
57
|
+
h({
|
|
55
58
|
message: `最多只能上传 ${t.props.limit} 个文件!`,
|
|
56
59
|
type: "warning"
|
|
57
60
|
});
|
|
58
61
|
}
|
|
59
62
|
function b(e) {
|
|
60
|
-
|
|
63
|
+
_.value = e.url, u.value = !0;
|
|
61
64
|
}
|
|
62
|
-
function
|
|
63
|
-
return e.size > 5242880 ? (
|
|
65
|
+
function E(e) {
|
|
66
|
+
return e.size > 5242880 ? (h({
|
|
64
67
|
message: "上传大小不能超过 5MB!",
|
|
65
68
|
type: "warning"
|
|
66
69
|
}), !1) : !0;
|
|
67
70
|
}
|
|
68
|
-
function
|
|
71
|
+
function V(e) {
|
|
69
72
|
const l = new FormData();
|
|
70
|
-
l.append("file", e.file),
|
|
73
|
+
l.append("file", e.file), p("on-upload", l);
|
|
71
74
|
}
|
|
72
|
-
return (e, l) => (r(), c("div",
|
|
73
|
-
(r(!0), c(
|
|
74
|
-
key: a.url
|
|
75
|
+
return (e, l) => (r(), c("div", A, [
|
|
76
|
+
(r(!0), c(P, null, T(d.value, (a) => (r(), c("div", {
|
|
77
|
+
key: a.url,
|
|
78
|
+
class: "el-upload-list__item is-picture-card custom-card"
|
|
75
79
|
}, [
|
|
76
|
-
a.url ? (r(),
|
|
80
|
+
a.url ? (r(), m(H, {
|
|
77
81
|
key: 0,
|
|
78
82
|
src: a.url,
|
|
79
83
|
"preview-src-list": [a.url],
|
|
@@ -82,37 +86,48 @@ const j = { style: { display: "flex", "flex-wrap": "wrap" } }, A = { class: "el-
|
|
|
82
86
|
width: "146px",
|
|
83
87
|
height: "146px",
|
|
84
88
|
"hide-on-click-modal": ""
|
|
85
|
-
}, null, 8, ["src", "preview-src-list"])) :
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
}, null, 8, ["src", "preview-src-list"])) : U("", !0),
|
|
90
|
+
f("span", {
|
|
91
|
+
class: "el-upload-list__item-delete",
|
|
92
|
+
onClick: y((n) => g(a), ["stop"])
|
|
93
|
+
}, [
|
|
94
|
+
i(s(w), null, {
|
|
95
|
+
default: o(() => [
|
|
96
|
+
i(s(O))
|
|
97
|
+
]),
|
|
98
|
+
_: 1
|
|
99
|
+
})
|
|
100
|
+
], 8, L)
|
|
101
|
+
]))), 128)),
|
|
102
|
+
i(s(S), {
|
|
103
|
+
"file-list": d.value,
|
|
89
104
|
limit: t.props.limit,
|
|
90
105
|
accept: t.props.accept,
|
|
91
106
|
"list-type": t.props.listType,
|
|
92
|
-
"on-remove":
|
|
93
|
-
"on-exceed":
|
|
107
|
+
"on-remove": g,
|
|
108
|
+
"on-exceed": I,
|
|
94
109
|
"on-preview": b,
|
|
95
110
|
multiple: !0,
|
|
96
|
-
"before-upload":
|
|
97
|
-
"http-request":
|
|
111
|
+
"before-upload": E,
|
|
112
|
+
"http-request": V,
|
|
98
113
|
"show-file-list": !1,
|
|
99
|
-
class:
|
|
114
|
+
class: B([
|
|
100
115
|
"upload-main",
|
|
101
|
-
{ "disable-upload":
|
|
116
|
+
{ "disable-upload": d.value.length >= t.props.limit }
|
|
102
117
|
]),
|
|
103
|
-
onClick: l[0] || (l[0] =
|
|
118
|
+
onClick: l[0] || (l[0] = y(() => {
|
|
104
119
|
}, ["prevent"]))
|
|
105
120
|
}, D({
|
|
106
121
|
default: o(() => [
|
|
107
|
-
t.props.listType !== "text" ? (r(),
|
|
122
|
+
t.props.listType !== "text" ? (r(), m(s(w), {
|
|
108
123
|
key: 0,
|
|
109
124
|
disabled: !0
|
|
110
125
|
}, {
|
|
111
126
|
default: o(() => [
|
|
112
|
-
|
|
127
|
+
i(s(R))
|
|
113
128
|
]),
|
|
114
129
|
_: 1
|
|
115
|
-
})) : (r(),
|
|
130
|
+
})) : (r(), m(s($), {
|
|
116
131
|
key: 1,
|
|
117
132
|
class: "upload-button",
|
|
118
133
|
type: "primary"
|
|
@@ -128,28 +143,28 @@ const j = { style: { display: "flex", "flex-wrap": "wrap" } }, A = { class: "el-
|
|
|
128
143
|
t.props.tip ? {
|
|
129
144
|
name: "tip",
|
|
130
145
|
fn: o(() => [
|
|
131
|
-
|
|
146
|
+
f("div", F, z(t.props.tip), 1)
|
|
132
147
|
]),
|
|
133
148
|
key: "0"
|
|
134
149
|
} : void 0
|
|
135
150
|
]), 1032, ["file-list", "limit", "accept", "list-type", "class"]),
|
|
136
|
-
|
|
137
|
-
modelValue:
|
|
138
|
-
"onUpdate:modelValue": l[1] || (l[1] = (a) =>
|
|
151
|
+
i(s(M), {
|
|
152
|
+
modelValue: u.value,
|
|
153
|
+
"onUpdate:modelValue": l[1] || (l[1] = (a) => u.value = a)
|
|
139
154
|
}, {
|
|
140
155
|
default: o(() => [
|
|
141
|
-
|
|
156
|
+
f("img", {
|
|
142
157
|
"w-full": "",
|
|
143
|
-
src:
|
|
158
|
+
src: _.value,
|
|
144
159
|
alt: "Preview Image"
|
|
145
|
-
}, null, 8,
|
|
160
|
+
}, null, 8, G)
|
|
146
161
|
]),
|
|
147
162
|
_: 1
|
|
148
163
|
}, 8, ["modelValue"])
|
|
149
164
|
]));
|
|
150
165
|
}
|
|
151
|
-
},
|
|
166
|
+
}, Y = /* @__PURE__ */ q(J, [["__scopeId", "data-v-4862d1c9"]]);
|
|
152
167
|
export {
|
|
153
|
-
|
|
168
|
+
Y as default
|
|
154
169
|
};
|
|
155
|
-
//# sourceMappingURL=ImagesUploader-
|
|
170
|
+
//# sourceMappingURL=ImagesUploader-DhPd72H6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagesUploader-DhPd72H6.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, Delete } from \"@element-plus/icons-vue\";\nimport http from \"../../utils/http\";\nimport HeicImage from \"../../component/HeicImage.vue\";\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 tip: \"\",\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.deleteParams) {\n const paramsData = props.props.deleteParams?.data\n ? props.props.deleteParams?.data\n : {};\n http\n .remove(\n `${props.props.deleteParams.url}/${uploadFile.id}/attachment`,\n paramsData,\n paramsData,\n )\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 style=\"display: flex; flex-wrap: wrap\" class=\"images-uploader\">\n <div\n v-for=\"item in files\"\n :key=\"item.url\"\n class=\"el-upload-list__item is-picture-card custom-card\"\n >\n <HeicImage\n v-if=\"item.url\"\n :src=\"item.url\"\n :preview-src-list=\"[item.url]\"\n fit=\"scale-down\"\n class=\"image\"\n width=\"146px\"\n height=\"146px\"\n hide-on-click-modal\n />\n <span class=\"el-upload-list__item-delete\" @click.stop=\"onRemove(item)\">\n <el-icon>\n <Delete />\n </el-icon>\n </span>\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=\"false\"\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 <template v-if=\"props.props.tip\" #tip>\n <div class=\"el-upload__tip\">{{ props.props.tip }}</div>\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.custom-card {\n position: relative;\n width: 148px;\n height: 148px;\n margin-right: 10px;\n margin-bottom: 10px;\n border: 1px solid var(--el-border-color);\n border-radius: 6px;\n overflow: hidden;\n background: var(--el-fill-color-lighter);\n cursor: pointer;\n box-sizing: border-box;\n\n .image {\n border: none;\n border-radius: 0;\n width: 100%;\n height: 100%;\n }\n\n .el-upload-list__item-delete {\n font-size: 18px;\n color: #ff8989;\n cursor: pointer;\n position: absolute;\n display: block;\n }\n}\n\n:deep(.el-upload-list) {\n .el-upload-list__item-actions span {\n margin-left: 20px;\n }\n}\n.image {\n border: 1px dashed var(--el-border-color);\n border-radius: 6px;\n cursor: pointer;\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","paramsData","_a","_b","http","onExceed","ElMessage","onPreview","beforeUpload","httpRequest","formData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,UAAMA,IAAOC,GACPC,IAAiBC,EAAI,EAAE,GACvBC,IAAgBD,EAAI,EAAK,GACzBE,IAAQC,GAqBRC,IAAQC,EAAS,MACdH,EAAM,OAAO,IAAI,CAACI,MAAS;AAChC,UAAI,EAACA,KAAA,QAAAA,EAAM;AACT,eAAO,EAAE,GAAGA,GAAM,MAAM,WAAW,UAAU;AAG/C,YAAMC,IAAWD,EAAK,IAAI,UAAUA,EAAK,IAAI,YAAY,GAAG,IAAI,CAAC,GAC3DE,IAAQF,EAAK,IAAI,MAAM,GAAG;AAMhC,aALkB;AAAA,QAChB,GAAGA;AAAA,QACH,MAAME,EAAMA,EAAM,SAAS,CAAC;AAAA,QAC5B,UAAAD;AAAA,MACN;AAAA,IAEA,CAAG,CACF;AAED,aAASE,EAASC,GAAY;;AAC5B,UAAIR,EAAM,MAAM,cAAc;AAC5B,cAAMS,KAAaC,IAAAV,EAAM,MAAM,iBAAZ,QAAAU,EAA0B,QACzCC,IAAAX,EAAM,MAAM,iBAAZ,gBAAAW,EAA0B,OAC1B;AACJ,QAAAC,EACG;AAAA,UACC,GAAGZ,EAAM,MAAM,aAAa,GAAG,IAAIQ,EAAW,EAAE;AAAA,UAChDC;AAAA,UACAA;AAAA,QACD,EACA,KAAK,MAAM;AACV,UAAAd,EAAK,aAAaa,CAAU;AAAA,QACpC,CAAO;AAAA,MACP;AACI,QAAAb,EAAK,aAAaa,CAAU;AAAA,IAEhC;AAEA,aAASK,IAAW;AAClB,MAAAC,EAAU;AAAA,QACR,SAAS,UAAUd,EAAM,MAAM,KAAK;AAAA,QACpC,MAAM;AAAA,MACV,CAAG;AAAA,IACH;AAEA,aAASe,EAAUP,GAAY;AAC7B,MAAAX,EAAe,QAAQW,EAAW,KAClCT,EAAc,QAAQ;AAAA,IACxB;AAEA,aAASiB,EAAaR,GAAY;AAEhC,aAAIA,EAAW,OAAO,WACpBM,EAAU;AAAA,QACR,SAAS;AAAA,QACT,MAAM;AAAA,MACZ,CAAK,GACM,MAGF;AAAA,IACT;AAEA,aAASG,EAAYT,GAAY;AAC/B,YAAMU,IAAW,IAAI;AACrB,MAAAA,EAAS,OAAO,QAAQV,EAAW,IAAI,GACvCb,EAAK,aAAauB,CAAQ;AAAA,IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as rr, onMounted as ir, onBeforeUnmount as ar, ref as $n, watch as Pn, nextTick as Gn, h as or, computed as sr, openBlock as ur, createBlock as lr, unref as fr } from "vue";
|
|
2
2
|
import * as rt from "quill";
|
|
3
3
|
import Rn from "quill";
|
|
4
|
-
import { o as W, r as cr,
|
|
4
|
+
import { o as W, r as cr, n as hr, k as dr } from "./index-37PxYvCK.js";
|
|
5
5
|
import { ElMessage as Ln } from "element-plus";
|
|
6
6
|
var ue = -1, re = 1, Z = 0;
|
|
7
7
|
function at(r, a, n, u) {
|
|
@@ -1811,4 +1811,4 @@ const Wn = {
|
|
|
1811
1811
|
export {
|
|
1812
1812
|
Rr as default
|
|
1813
1813
|
};
|
|
1814
|
-
//# sourceMappingURL=RichTextEditor-
|
|
1814
|
+
//# sourceMappingURL=RichTextEditor-Dh_2ZXzZ.js.map
|