|
@@ -17,7 +17,7 @@
|
|
|
:on-remove="handleRemove"
|
|
|
:disabled="isLimitCpt"
|
|
|
>
|
|
|
- <el-tooltip :content="acceptTooltipCpt" placement="top" popper-class="upload-tooltip-popper">
|
|
|
+ <el-tooltip :content="acceptTooltipCpt" placement="top" popper-class="upload-tooltip-popper" :disabled="true">
|
|
|
<template v-if="layout === 'card'">
|
|
|
<div class="upload-layout-card __hover" :class="{'limit-disabled': isLimitCpt}">
|
|
|
<SvgIcon name="add" color="#0062E9" size="24"/>
|
|
@@ -27,7 +27,7 @@
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<div class="upload-layout-list_button" :class="{'limit-disabled': isLimitCpt}">
|
|
|
- <SvgIcon name="add" color="#ffffff" size="14"/>
|
|
|
+<!-- <SvgIcon name="add" color="#ffffff" size="14"/>-->
|
|
|
选择{{acceptTypeFormatCpt}}
|
|
|
<template v-if="limit > 0">(最多{{ limit }}个)</template>
|
|
|
</div>
|
|
@@ -128,7 +128,7 @@ export default defineComponent({
|
|
|
const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
|
|
|
const state = reactive({
|
|
|
paramVal: <any>props.param,
|
|
|
- loading: true,
|
|
|
+ loading: false,
|
|
|
elementLoadingBackground: inject('element-loading-background', null),
|
|
|
currentImg: {
|
|
|
show: false,
|
|
@@ -165,14 +165,14 @@ export default defineComponent({
|
|
|
if (that.$util.isValue(props.acceptType)) {
|
|
|
str += props.acceptType
|
|
|
} else {
|
|
|
- if (props.type === 'all') {
|
|
|
- str += store.state.app.uploadConfig.imgType
|
|
|
- str += ',' + store.state.app.uploadConfig.fileType
|
|
|
- } else if (props.type === 'img') {
|
|
|
- str += store.state.app.uploadConfig.imgType
|
|
|
- } else if (props.type === 'file') {
|
|
|
- str += store.state.app.uploadConfig.fileType
|
|
|
- }
|
|
|
+ // if (props.type === 'all') {
|
|
|
+ // str += store.state.app.uploadConfig.imgType
|
|
|
+ // str += ',' + store.state.app.uploadConfig.fileType
|
|
|
+ // } else if (props.type === 'img') {
|
|
|
+ // str += store.state.app.uploadConfig.imgType
|
|
|
+ // } else if (props.type === 'file') {
|
|
|
+ // str += store.state.app.uploadConfig.fileType
|
|
|
+ // }
|
|
|
}
|
|
|
return str
|
|
|
})
|
|
@@ -182,7 +182,7 @@ export default defineComponent({
|
|
|
str += `自定义文件`
|
|
|
} else {
|
|
|
if (props.type === 'all') {
|
|
|
- str += `图片、文件`
|
|
|
+ str += `文件`
|
|
|
} else if (props.type === 'img') {
|
|
|
str += `图片`
|
|
|
} else if (props.type === 'file') {
|
|
@@ -196,14 +196,14 @@ export default defineComponent({
|
|
|
if (that.$util.isValue(props.acceptType)) {
|
|
|
str += `只支持大小在0~${props.acceptMax}M内,格式为${props.acceptType}的自定义文件`
|
|
|
} else {
|
|
|
- if (props.type === 'all') {
|
|
|
- str += `只支持大小在0~${store.state.app.uploadConfig.imgMax}M内,格式为${store.state.app.uploadConfig.imgType}的图片,`
|
|
|
- str += `或大小在0~${store.state.app.uploadConfig.fileMax}M内,格式为${store.state.app.uploadConfig.fileType}的文件`
|
|
|
- } else if (props.type === 'img') {
|
|
|
- str += `只支持大小在0~${store.state.app.uploadConfig.imgMax}M内,格式为${store.state.app.uploadConfig.imgType}的图片`
|
|
|
- } else if (props.type === 'file') {
|
|
|
- str += `只支持大小在0~${store.state.app.uploadConfig.fileMax}M内,格式为${store.state.app.uploadConfig.fileType}的文件`
|
|
|
- }
|
|
|
+ // if (props.type === 'all') {
|
|
|
+ // str += `只支持大小在0~${store.state.app.uploadConfig.imgMax}M内,格式为${store.state.app.uploadConfig.imgType}的图片,`
|
|
|
+ // str += `或大小在0~${store.state.app.uploadConfig.fileMax}M内,格式为${store.state.app.uploadConfig.fileType}的文件`
|
|
|
+ // } else if (props.type === 'img') {
|
|
|
+ // str += `只支持大小在0~${store.state.app.uploadConfig.imgMax}M内,格式为${store.state.app.uploadConfig.imgType}的图片`
|
|
|
+ // } else if (props.type === 'file') {
|
|
|
+ // str += `只支持大小在0~${store.state.app.uploadConfig.fileMax}M内,格式为${store.state.app.uploadConfig.fileType}的文件`
|
|
|
+ // }
|
|
|
}
|
|
|
if (isLimitCpt.value) {
|
|
|
str = `最多上传${props.limit}个${acceptTypeFormatCpt.value}`
|
|
@@ -223,45 +223,45 @@ export default defineComponent({
|
|
|
return false
|
|
|
}
|
|
|
} else {
|
|
|
- if (props.type === 'img') {
|
|
|
- if (file.size / (1024 * 1024) > store.state.app.uploadConfig.imgMax) {
|
|
|
- ElMessage.warning(`图片大小不可超过${store.state.app.uploadConfig.imgMax}M`)
|
|
|
- return false
|
|
|
- } else if (!store.state.app.uploadConfig.imgType.split(',').some(v => file.name.includes(v))) {
|
|
|
- ElMessage.warning(`图片类型仅支持${store.state.app.uploadConfig.imgType}`)
|
|
|
- return false
|
|
|
- }
|
|
|
- } else if (props.type === 'file') {
|
|
|
- if (file.size / (1024 * 1024) > store.state.app.uploadConfig.fileMax) {
|
|
|
- ElMessage.warning(`文件大小不可超过${store.state.app.uploadConfig.fileMax}M`)
|
|
|
- return false
|
|
|
- } else if (!store.state.app.uploadConfig.fileType.split(',').some(v => file.name.includes(v))) {
|
|
|
- ElMessage.warning(`文件类型仅支持${store.state.app.uploadConfig.fileType}`)
|
|
|
- return false
|
|
|
- }
|
|
|
- } else if (props.type === 'all') {
|
|
|
- if (!acceptTypeCpt.value.split(',').some(v => file.name.includes(v))) {
|
|
|
- ElMessage.warning(`文件或图片类型仅支持${acceptTypeCpt.value}`)
|
|
|
- return false
|
|
|
- } else {
|
|
|
- if (store.state.app.uploadConfig.imgType.split(',').some(v => file.name.includes(v))) {
|
|
|
- if (file.size / (1024 * 1024) > store.state.app.uploadConfig.imgMax) {
|
|
|
- ElMessage.warning(`图片大小不可超过${store.state.app.uploadConfig.imgMax}M`)
|
|
|
- return false
|
|
|
- }
|
|
|
- } else if (store.state.app.uploadConfig.fileType.split(',').some(v => file.name.includes(v))) {
|
|
|
- if (file.size / (1024 * 1024) > store.state.app.uploadConfig.fileMax) {
|
|
|
- ElMessage.warning(`文件大小不可超过${store.state.app.uploadConfig.fileMax}M`)
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (props.type === 'img') {
|
|
|
+ // if (file.size / (1024 * 1024) > store.state.app.uploadConfig.imgMax) {
|
|
|
+ // ElMessage.warning(`图片大小不可超过${store.state.app.uploadConfig.imgMax}M`)
|
|
|
+ // return false
|
|
|
+ // } else if (!store.state.app.uploadConfig.imgType.split(',').some(v => file.name.includes(v))) {
|
|
|
+ // ElMessage.warning(`图片类型仅支持${store.state.app.uploadConfig.imgType}`)
|
|
|
+ // return false
|
|
|
+ // }
|
|
|
+ // } else if (props.type === 'file') {
|
|
|
+ // if (file.size / (1024 * 1024) > store.state.app.uploadConfig.fileMax) {
|
|
|
+ // ElMessage.warning(`文件大小不可超过${store.state.app.uploadConfig.fileMax}M`)
|
|
|
+ // return false
|
|
|
+ // } else if (!store.state.app.uploadConfig.fileType.split(',').some(v => file.name.includes(v))) {
|
|
|
+ // ElMessage.warning(`文件类型仅支持${store.state.app.uploadConfig.fileType}`)
|
|
|
+ // return false
|
|
|
+ // }
|
|
|
+ // } else if (props.type === 'all') {
|
|
|
+ // if (!acceptTypeCpt.value.split(',').some(v => file.name.includes(v))) {
|
|
|
+ // ElMessage.warning(`文件或图片类型仅支持${acceptTypeCpt.value}`)
|
|
|
+ // return false
|
|
|
+ // } else {
|
|
|
+ // if (store.state.app.uploadConfig.imgType.split(',').some(v => file.name.includes(v))) {
|
|
|
+ // if (file.size / (1024 * 1024) > store.state.app.uploadConfig.imgMax) {
|
|
|
+ // ElMessage.warning(`图片大小不可超过${store.state.app.uploadConfig.imgMax}M`)
|
|
|
+ // return false
|
|
|
+ // }
|
|
|
+ // } else if (store.state.app.uploadConfig.fileType.split(',').some(v => file.name.includes(v))) {
|
|
|
+ // if (file.size / (1024 * 1024) > store.state.app.uploadConfig.fileMax) {
|
|
|
+ // ElMessage.warning(`文件大小不可超过${store.state.app.uploadConfig.fileMax}M`)
|
|
|
+ // return false
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
return file
|
|
|
}
|
|
|
const handleRequest = async (options) => {
|
|
|
- state.loading = true
|
|
|
+ // state.loading = true
|
|
|
if (that.$util.isValue(props.acceptType)) {
|
|
|
const result: any = await props.acceptFunc(options)
|
|
|
if (result?.[props.urlKey] && result?.[props.nameKey]) {
|
|
@@ -271,35 +271,35 @@ export default defineComponent({
|
|
|
}
|
|
|
state.loading = false
|
|
|
} else {
|
|
|
- if (store.state.app.uploadConfig.imgType.split(',').some(v => options.file.name.includes(v))) {
|
|
|
- const formData = new FormData();
|
|
|
- formData.append("file", options.file);
|
|
|
- that.$api.uploadPicOnly(formData).then(res => {
|
|
|
- if (res?.code === 200) {
|
|
|
- state.paramVal = [...state.paramVal, {
|
|
|
- [props.urlKey]: res.imgPath,
|
|
|
- [props.nameKey]: res.fileName
|
|
|
- }]
|
|
|
- }
|
|
|
- state.loading = false
|
|
|
- }).catch(() => {
|
|
|
- state.loading = false
|
|
|
- })
|
|
|
- } else if (store.state.app.uploadConfig.fileType.split(',').some(v => options.file.name.includes(v))) {
|
|
|
- const formData = new FormData();
|
|
|
- formData.append("file", options.file);
|
|
|
- that.$api.uploadFile(formData).then(res => {
|
|
|
- if (res?.code === 200) {
|
|
|
- state.paramVal = [...state.paramVal, {
|
|
|
- [props.urlKey]: res.url,
|
|
|
- [props.nameKey]: res.fileName
|
|
|
- }]
|
|
|
- }
|
|
|
- state.loading = false
|
|
|
- }).catch(() => {
|
|
|
- state.loading = false
|
|
|
- })
|
|
|
- }
|
|
|
+ // if (store.state.app.uploadConfig.imgType.split(',').some(v => options.file.name.includes(v))) {
|
|
|
+ // const formData = new FormData();
|
|
|
+ // formData.append("file", options.file);
|
|
|
+ // that.$api.uploadPicOnly(formData).then(res => {
|
|
|
+ // if (res?.code === 200) {
|
|
|
+ // state.paramVal = [...state.paramVal, {
|
|
|
+ // [props.urlKey]: res.imgPath,
|
|
|
+ // [props.nameKey]: res.fileName
|
|
|
+ // }]
|
|
|
+ // }
|
|
|
+ // state.loading = false
|
|
|
+ // }).catch(() => {
|
|
|
+ // state.loading = false
|
|
|
+ // })
|
|
|
+ // } else if (store.state.app.uploadConfig.fileType.split(',').some(v => options.file.name.includes(v))) {
|
|
|
+ // const formData = new FormData();
|
|
|
+ // formData.append("file", options.file);
|
|
|
+ // that.$api.uploadFile(formData).then(res => {
|
|
|
+ // if (res?.code === 200) {
|
|
|
+ // state.paramVal = [...state.paramVal, {
|
|
|
+ // [props.urlKey]: res.url,
|
|
|
+ // [props.nameKey]: res.fileName
|
|
|
+ // }]
|
|
|
+ // }
|
|
|
+ // state.loading = false
|
|
|
+ // }).catch(() => {
|
|
|
+ // state.loading = false
|
|
|
+ // })
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
const fileTypeMapper = new Map([
|
|
@@ -356,10 +356,10 @@ export default defineComponent({
|
|
|
state.currentImg.url = ''
|
|
|
}
|
|
|
onMounted(() => {
|
|
|
- state.loading = true
|
|
|
- store.dispatch('app/LOAD_UPLOAD_CONFIG').then(() => {
|
|
|
- state.loading = false
|
|
|
- })
|
|
|
+ // state.loading = true
|
|
|
+ // store.dispatch('app/LOAD_UPLOAD_CONFIG').then(() => {
|
|
|
+ // state.loading = false
|
|
|
+ // })
|
|
|
})
|
|
|
return {
|
|
|
...toRefs(state),
|
|
@@ -391,13 +391,14 @@ export default defineComponent({
|
|
|
.el-upload-com {
|
|
|
:deep(.el-upload) {
|
|
|
.upload-layout-list_button {
|
|
|
- height: 32px;
|
|
|
+ height: 24px;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
- padding: 0 18px;
|
|
|
- background-color: #0062E9;
|
|
|
+ padding: 0 6px;
|
|
|
+ background-color: rgba(0, 133, 247, 0.2);
|
|
|
border-radius: 4px;
|
|
|
+ border: 1px solid rgba(0, 133, 247, 0.5);
|
|
|
font-size: 14px;
|
|
|
font-family: Microsoft YaHei;
|
|
|
font-weight: 400;
|
|
@@ -440,6 +441,9 @@ export default defineComponent({
|
|
|
margin: 0;
|
|
|
.el-upload-list__item {
|
|
|
transition: none;
|
|
|
+ &:hover {
|
|
|
+ background-color: #175096;
|
|
|
+ }
|
|
|
.upload-layout-list_item {
|
|
|
display: flex;
|
|
|
align-items: center;
|