From 907db73a040fbaa0443fc2a18ca49c75404cf30a Mon Sep 17 00:00:00 2001 From: ijiuyueya <2628619875@qq.com> Date: Tue, 23 May 2023 13:30:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebSite/src/components/UploadFile/index.vue | 67 ++++++++++++------- .../index.vue | 15 ++--- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/WebSite/src/components/UploadFile/index.vue b/WebSite/src/components/UploadFile/index.vue index d9d845fa..c8a61a4a 100644 --- a/WebSite/src/components/UploadFile/index.vue +++ b/WebSite/src/components/UploadFile/index.vue @@ -15,12 +15,7 @@ :on-change="fileChange" :on-remove="removeFile" :http-request="uploadFile" - accept=" - .zip ,.jpg ,.png ,.jpeg, - .xls,.XLS, - .xlsx,.XLSX, - .bmp,.gif,.txt,.doc,.pdf,.pptx,.docx - " + :accept="accept" > <el-button size="small" type="primary">閫夋嫨鏂囦欢</el-button> <template #tip> @@ -63,24 +58,40 @@ export default { type: String, default: '涓婁紶', }, + accept: { + type: Object, + }, }, emits: ['update:modelValue', 'upload-handler'], setup(props, context) { const loading = ref(false); const acceptType = [ - 'zip','ZIP', - 'jpg','JPG', - 'png','PNG', - 'jpeg','JPEG', - 'xls','XLS', - 'xlsx','XLSX', - 'bmp','BMP', - 'gif','GIF', - 'txt','TXT', - 'doc','DOC', - 'pdf','PDF', - 'pptx','PPTX', - 'docx','DOCX', + '.zip', + '.ZIP', + '.jpg', + '.JPG', + '.png', + '.PNG', + '.jpeg', + '.JPEG', + '.xls', + '.XLS', + '.xlsx', + '.XLSX', + '.bmp', + '.BMP', + '.gif', + '.GIF', + '.txt', + '.TXT', + '.doc', + '.DOC', + '.pdf', + '.PDF', + '.pptx', + '.PPTX', + '.docx', + '.DOCX', ]; const uploadFileDialog = computed({ get() { @@ -93,11 +104,19 @@ export default { let list = ref([]); const fileChange = (file, fileList) => { const startIndex = file.name.lastIndexOf('.'); - const surfixName = file.name.substring(startIndex + 1); - if (!acceptType.includes(surfixName)) { - const index = fileList.findIndex((item) => file.uid == item.uid); - fileList.splice(index, 1); - return ElMessage.warning('璇蜂笂浼犳纭牸寮忕殑鏂囦欢'); + const surfixName = file.name.substring(startIndex); + if (props.accept != undefined) { + if (!props.accept.includes(surfixName)) { + const index = fileList.findIndex((item) => file.uid == item.uid); + fileList.splice(index, 1); + return ElMessage.warning('璇蜂笂浼犳纭牸寮忕殑鏂囦欢'); + } + } else { + if (!acceptType.includes(surfixName)) { + const index = fileList.findIndex((item) => file.uid == item.uid); + fileList.splice(index, 1); + return ElMessage.warning('璇蜂笂浼犳纭牸寮忕殑鏂囦欢'); + } } if (file.size > 104857600) { const index = fileList.findIndex((item) => file.uid === item.uid); diff --git a/WebSite/src/views/item-entry/exante-performance-evaluation-function-edit/index.vue b/WebSite/src/views/item-entry/exante-performance-evaluation-function-edit/index.vue index 3bddc782..1067107a 100644 --- a/WebSite/src/views/item-entry/exante-performance-evaluation-function-edit/index.vue +++ b/WebSite/src/views/item-entry/exante-performance-evaluation-function-edit/index.vue @@ -152,8 +152,7 @@ plain type="primary" icon="plus" - size="small" title="涓婁紶闄勪欢鐨勭被鍨�:(.zip ,.jpg ,.png ,.jpeg, .xls,.XLS, .xlsx,.XLSX, - .bmp,.gif,.txt,.doc,.pdf,.pptx,.docx)" + size="small" @click="uploadDialog1 = true" >鏂板</el-button > <UploadFile @@ -194,13 +193,14 @@ plain type="primary" icon="plus" - size="small" title="锛堟壙璇哄強瀹℃牳淇℃伅閮ㄥ垎璇风瀛楃洊绔犲悗鍦ㄧ郴缁熶腑涓婁紶JPG銆丳NG鏍煎紡鐨勭収鐗囨垨PDF鏂囦欢锛�" + size="small" @click="uploadDialog2 = true" >鏂板闄勪欢</el-button > <span>锛堟壙璇哄強瀹℃牳淇℃伅閮ㄥ垎璇风瀛楃洊绔犲悗鍦ㄧ郴缁熶腑涓婁紶JPG銆丳NG鏍煎紡鐨勭収鐗囨垨PDF鏂囦欢锛�</span> <UploadFile v-model:modelValue="uploadDialog2" @upload-handler="uploadHandler2" + :accept="accept" > </UploadFile> <el-table @@ -230,14 +230,6 @@ </template> </el-table-column> </el-table> - <!-- <el-button - plain - style="padding-top: 0px;" - type="primary" - icon="view" - size="small" - >鏌ョ湅绀轰緥鍥�</el-button - > --> </el-form-item> <el-form-item> <el-button @@ -279,6 +271,7 @@ export default { const route = useRoute(); const router = useRouter(); const data = reactive({ + accept:['.jpg','.JPG','.png','.PNG','.pdf','.PDF'], tag:false, flag: 0, disabledPreview: false, -- GitLab