Forráskód Böngészése

💊 添加附件删除功能及时间处理优化

快乐的梦鱼 1 hónapja
szülő
commit
64bb57836c

+ 6 - 1
src/api/collect/AssessmentContent.ts

@@ -4,6 +4,7 @@ import { transformSomeToArray } from '../Utils';
 import ApiCofig from '@/common/config/ApiCofig';
 import { appendGetUrlParams } from '@imengyu/imengyu-utils';
 import { useAuthStore } from '@/stores/auth';
+import dayjs from 'dayjs';
 
 /**
  * 自查评估 / 传承协议相关接口(ShowDoc)
@@ -439,7 +440,7 @@ export class SelfAssessmentDetail extends DataModel<SelfAssessmentDetail> {
   address = '' as string|null;
   content : Record<string, any>|null = null;
   weigh = 0 as number;
-  awardTime = new Date();
+  awardTime = dayjs();
   deductContent = '' as string|null;
   deductPoints = 0 as number;
   points = 0 as number;
@@ -820,6 +821,10 @@ export class AssessmentContentApi extends AppServerRequestModule<DataModel> {
     return normalizePaginated<CheckAnnexListItem>(CheckAnnexListItem, res.data as KeyValue);
   }
 
+  async delAnnex(id: number) {
+    return this.post('/ich/check/delAnnex', { id }, '删除证明材料');
+  }
+
   async getInheritorBasic(userId?: number) {
     const res = await this.post('/ich/check/basic', {
       user_id: userId,

+ 36 - 1
src/pages/collect/assessment/components/EvaluationFormBlock.vue

@@ -89,6 +89,7 @@
           :multiple="true"
           :custom-request="(options: any) => annexCustomRequest(item.id, options)"
           :before-upload="beforeAnnexUpload"
+          @remove="(file: any) => handleAnnexRemove(item.id, file)"
           @update:file-list="(list: any) => setAnnexFileList(item.id, list)"
         >
           <template #itemRender="{ originNode, file }">
@@ -311,7 +312,7 @@ const tailFormOptionsBase: IDynamicFormOptions = {
           name: 'inheritorSign',
           type: 'sign',
           additionalProps: {
-            upload: signUploadCo,
+            uploadCo: signUploadCo,
           } as SignProps,
         },
       ],
@@ -478,6 +479,40 @@ function promptAnnexDesc(initialDesc: string, title: string) {
   });
 }
 
+async function handleAnnexRemove(itemId: number, file: any): Promise<boolean> {
+  if (file?.status !== 'done')
+    return true;
+  const res = file?.response ?? {};
+  const annexId = Number(res.id ?? file.uid);
+  if (!annexId) {
+    message.warning('附件信息不完整,无法删除');
+    return false;
+  }
+  return new Promise((resolve) => {
+    Modal.confirm({
+      title: '确认删除',
+      content: '确定要删除该佐证材料吗?',
+      okText: '删除',
+      okType: 'danger',
+      cancelText: '取消',
+      async onOk() {
+        try {
+          await AssessmentContentApi.delAnnex(annexId);
+          await loadAnnexListByItem(itemId);
+          message.success('删除成功');
+          resolve(true);
+        } catch (err) {
+          message.error(err instanceof Error ? err.message : String(err));
+          resolve(false);
+        }
+      },
+      onCancel() {
+        resolve(false);
+      },
+    });
+  });
+}
+
 async function editAnnexDesc(itemId: number, file: any, isAfterUpload = false) {
   const formId = props.currentForm.id;
   if (!formId)