From 700aa7f13377c21987fa23ad330776a007912cde Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 29 七月 2026 13:51:35 +0800
Subject: [PATCH] refactor(srm): 优化投标模块获奖信息获取和文件上传组件

---
 src/components/upload/file-upload.vue |   44 +++++---------------------------------------
 1 files changed, 5 insertions(+), 39 deletions(-)

diff --git a/src/components/upload/file-upload.vue b/src/components/upload/file-upload.vue
index 223a299..35c7fe6 100644
--- a/src/components/upload/file-upload.vue
+++ b/src/components/upload/file-upload.vue
@@ -55,22 +55,20 @@
   maxSizeRef: maxSize,
 });
 
-/** 璁$畻褰撳墠缁戝畾鐨勫�硷紝浼樺厛浣跨敤 modelValue */
 const currentValue = computed(() => {
   return props.modelValue === undefined ? props.value : props.modelValue;
 });
 
-/** 鍒ゆ柇鏄惁浣跨敤 modelValue */
 const isUsingModelValue = computed(() => {
   return props.modelValue !== undefined;
 });
 
 const fileList = ref<UploadProps['fileList']>([]);
-const isLtMsg = ref<boolean>(true); // 鏂囦欢澶у皬閿欒鎻愮ず
-const isActMsg = ref<boolean>(true); // 鏂囦欢绫诲瀷閿欒鎻愮ず
-const isFirstRender = ref<boolean>(true); // 鏄惁绗竴娆℃覆鏌�
-const uploadNumber = ref<number>(0); // 涓婁紶鏂囦欢璁℃暟鍣�
-const uploadList = ref<any[]>([]); // 涓存椂涓婁紶鍒楄〃
+const isLtMsg = ref<boolean>(true);
+const isActMsg = ref<boolean>(true);
+const isFirstRender = ref<boolean>(true);
+const uploadNumber = ref<number>(0);
+const uploadList = ref<any[]>([]);
 
 watch(
   currentValue,
@@ -149,17 +147,10 @@
 function handleUploadError(error: any) {
   console.error('涓婁紶閿欒:', error);
   message.error($t('ui.upload.uploadError'));
-  // 涓婁紶澶辫触鏃跺噺灏戣鏁板櫒
   uploadNumber.value = Math.max(0, uploadNumber.value - 1);
 }
 
-/**
- * 涓婁紶鍓嶆牎楠�
- * @param file 寰呬笂浼犵殑鏂囦欢
- * @returns 鏄惁鍏佽涓婁紶
- */
 async function beforeUpload(file: File) {
-  // 妫�鏌ユ枃浠舵暟閲忛檺鍒�
   if (fileList.value!.length >= props.maxNumber) {
     message.error($t('ui.upload.maxNumber', [props.maxNumber]));
     return Upload.LIST_IGNORE;
@@ -170,7 +161,6 @@
   if (!isAct) {
     message.error($t('ui.upload.acceptUpload', [accept]));
     isActMsg.value = false;
-    // 闃叉寮瑰嚭澶氫釜閿欒鎻愮ず
     setTimeout(() => (isActMsg.value = true), 1000);
     return Upload.LIST_IGNORE;
   }
@@ -178,12 +168,10 @@
   if (isLt) {
     message.error($t('ui.upload.maxSizeMultiple', [maxSize]));
     isLtMsg.value = false;
-    // 闃叉寮瑰嚭澶氫釜閿欒鎻愮ず
     setTimeout(() => (isLtMsg.value = true), 1000);
     return Upload.LIST_IGNORE;
   }
 
-  // 鍙湁鍦ㄩ獙璇侀�氳繃鍚庢墠澧炲姞璁℃暟鍣�
   uploadNumber.value++;
   if (props.returnText) {
     const fileContent = await file.text();
@@ -192,23 +180,18 @@
   return true;
 }
 
-/** 鑷畾涔変笂浼犺姹� */
 async function customRequest(info: UploadRequestOption) {
   let { api } = props;
   if (!api || !isFunction(api)) {
     api = useUpload(props.directory).httpRequest;
   }
   try {
-    // 涓婁紶鏂囦欢
     const progressEvent: AxiosProgressEvent = (e) => {
       const percent = Math.trunc((e.loaded / e.total!) * 100);
       info.onProgress!({ percent });
     };
     const res = await api?.(info.file as File, progressEvent);
-
-    // 澶勭悊涓婁紶鎴愬姛鍚庣殑閫昏緫
     handleUploadSuccess(res, info.file as File);
-
     info.onSuccess!(res);
     message.success($t('ui.upload.uploadSuccess'));
   } catch (error: any) {
@@ -218,19 +201,12 @@
   }
 }
 
-/**
- * 澶勭悊涓婁紶鎴愬姛
- * @param res 涓婁紶鍝嶅簲缁撴灉
- * @param file 涓婁紶鐨勬枃浠�
- */
 function handleUploadSuccess(res: any, file: File) {
-  // 鍒犻櫎涓存椂鏂囦欢
   const index = fileList.value?.findIndex((item) => item.name === file.name);
   if (index !== -1) {
     fileList.value?.splice(index!, 1);
   }
 
-  // 娣诲姞鍒颁复鏃朵笂浼犲垪琛�
   const fileUrl = res?.url || res?.data || res;
   uploadList.value.push({
     name: res?.name || file.name,
@@ -241,13 +217,11 @@
     uid: file.name + Date.now(),
   });
 
-  // 妫�鏌ユ槸鍚︽墍鏈夋枃浠堕兘涓婁紶瀹屾垚
   if (uploadList.value.length >= uploadNumber.value) {
     fileList.value?.push(...uploadList.value);
     uploadList.value = [];
     uploadNumber.value = 0;
 
-    // 鏇存柊鍊�
     const value = getValue();
     isInnerOperate.value = true;
     emit('update:value', value);
@@ -256,10 +230,6 @@
   }
 }
 
-/**
- * 鑾峰彇褰撳墠鏂囦欢鍒楄〃鐨勫��
- * @returns 鏂囦欢 URL 鍒楄〃鎴栧瓧绗︿覆
- */
 function getValue() {
   const list = (fileList.value || [])
     .filter((item) => item?.status === UploadResultStatus.DONE)
@@ -276,10 +246,8 @@
       return props.valuePrefix ? `${props.valuePrefix}${val}` : val;
     });
 
-  // 鍗曚釜鏂囦欢鐨勬儏鍐碉紝鏍规嵁杈撳叆鍙傛暟绫诲瀷鍐冲畾杩斿洖鏍煎紡
   if (props.maxNumber === 1) {
     const singleValue = list.length > 0 ? list[0] : '';
-    // 濡傛灉鍘熷鍊兼槸瀛楃涓叉垨 modelValue 鏄瓧绗︿覆锛岃繑鍥炲瓧绗︿覆
     if (
       isString(props.value) ||
       (isUsingModelValue.value && isString(props.modelValue))
@@ -289,7 +257,6 @@
     return singleValue;
   }
 
-  // 澶氭枃浠舵儏鍐碉紝鏍规嵁杈撳叆鍙傛暟绫诲瀷鍐冲畾杩斿洖鏍煎紡
   if (isUsingModelValue.value) {
     return Array.isArray(props.modelValue) ? list : list.join(',');
   }
@@ -382,7 +349,6 @@
 </style>
 
 <style>
-/* 鏂囦欢涓婁紶鍒楄〃鏄剧ず鎵嬪瀷鍏夋爣鏍峰紡澶辨晥銆備笉鐭ラ亾涓哄暐. 鍏堣繖閲屽姞涓� */
 .ant-upload-list-text .ant-upload-list-item {
   cursor: pointer;
 }

--
Gitblit v1.9.3