Przeglądaj źródła

进件页面修改

shizhongqi 4 tygodni temu
rodzic
commit
e13a4aa38a

+ 8 - 2
ghsApp/src/admin/lakala/lakala-components/AttachmentCard.vue

@@ -1,3 +1,4 @@
+<!-- 进件附件卡片:供商家上传和预览指定资料,并兼容未上传及历史空附件数据。 -->
 <template>
   <view class="attachment" @click="$emit('upload')">
     <view>
@@ -12,9 +13,14 @@
 export default {
   props: { title: { type: String, default: '' }, imgType: { type: String, default: '' }, items: { type: Array, default: () => [] } },
   computed: {
-    item() { return this.items.find(v => v.imgType === this.imgType); },
+    /** 获取当前卡片对应的有效附件;未上传或存在历史空数据时返回 undefined */
+    item() {
+      return this.items.find(v => v && v.imgType === this.imgType);
+    },
+    /** 生成附件预览地址;无附件时返回空字符串,避免初始化阶段访问空对象 */
     imageSrc() {
-      const path = this.item.ossPath || '';
+      const path = (this.item && this.item.ossPath) || '';
+      if (!path) return '';
       if (/^https?:\/\//.test(path)) return path;
       return `${this.$constant.imgUrl}/${path}`;
     }

+ 34 - 13
ghsApp/src/admin/lakala/lakalaOnboarding.vue

@@ -1,3 +1,4 @@
+<!-- 拉卡拉商户进件页:供商家录入、上传并提交开户审核资料,统一处理草稿和附件状态。 -->
 <template>
   <view class="page" v-if="loaded">
     <view v-if="mode !== 'settlement-change'" class="steps">
@@ -230,14 +231,13 @@ export default {
       const pad = n => (n < 10 ? '0' : '') + n;
       return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
     },
-    /** 执照/身份证有效期未填时默认当天,减少用户重复选择 */
+    /** 为未填写的有效期设置默认值;已保存的长期值必须保留,避免草稿重新打开后被覆盖 */
     applyDefaultExpiryDates() {
       const today = this.getTodayDateStr();
-      if (!this.form.license.legalIdEnd || this.form.license.legalIdEnd == '9999-12-31') {
+      if (!this.form.license.legalIdEnd) {
         this.$set(this.form.license, 'legalIdEnd', today);
       }
-      if (!this.form.license.licenseEnd || this.form.license.licenseEnd == '9999-12-31') {
-        //this.$set(this.form.license, 'licenseEnd', today);
+      if (!this.form.license.licenseEnd) {
         this.$set(this.form.license, 'licenseEnd', '2100-01-01');
       }
     },
@@ -315,6 +315,14 @@ export default {
         const pad = n => (n < 10 ? '0' : '') + Number(n);
         return `${dot[1]}-${pad(dot[2])}-${pad(dot[3])}`;
       }
+      const datestr = str.match(/^(\d{4})(\d{1,2})(\d{1,2})$/);
+      if (datestr) {
+        const pad = n => (n < 10 ? '0' : '') + Number(n);
+        return `${datestr[1]}-${pad(datestr[2])}-${pad(datestr[3])}`;
+      }
+      if (str === '长期') {
+        return '9999-12-31';
+      }
       return str;
     },
     /** 统一省市区、支行等选项结构;兼容 camelCase 与 snake_case 字段 */
@@ -392,6 +400,7 @@ export default {
       if (missing) uni.showToast({ title: '请填写完整必填信息', icon: 'none' });
       return !missing;
     },
+    /** 上传单张进件附件;成功后替换同类型附件并按需触发 OCR,接口未返回附件数据时不修改表单 */
     async uploadAttachment(section, imgType, isOcr) {
       const path = await this.chooseImage();
       if (!path) return;
@@ -400,6 +409,10 @@ export default {
         const content = await this.toBase64(path);
         const useLakalaOcr = isOcr && imgType === 'BUSINESS_LICENCE';
         const res = await uploadFile({ id: this.id, content, imgType, isOcr: useLakalaOcr ? 1 : 0 });
+        if (!res || !res.data || typeof res.data !== 'object' || Array.isArray(res.data)) {
+          uni.showToast({ title: '上传结果异常,请重试', icon: 'none' });
+          return;
+        }
         const list = this.form[section].attachments || [];
         const attachment = this.normalizeAttachment(res.data);
         const oldIndex = list.findIndex(v => v.imgType === imgType);
@@ -413,19 +426,26 @@ export default {
         uni.hideLoading();
       }
     },
+    /** 统一单个附件字段;输入为接口附件对象,输出为可安全渲染和提交的附件对象,不修改原对象 */
     normalizeAttachment(attachment) {
-      return Object.assign({}, attachment, {
-        lakalaUrl: attachment.lakalaUrl || attachment.url || '',
-        batchNo: attachment.batchNo || '',
-        imgType: attachment.imgType || '',
-        ocrStatus: attachment.ocrStatus || attachment.status || '',
-        ocrResult: attachment.ocrResult || attachment.ocr || null
+      const source = attachment && typeof attachment === 'object' ? attachment : {};
+      return Object.assign({}, source, {
+        ossPath: source.ossPath || '',
+        lakalaUrl: source.lakalaUrl || '',
+        batchNo: source.batchNo || '',
+        imgType: source.imgType || '',
+        ocrStatus: source.ocrStatus || '',
+        ocrResult: source.ocrResult || null
       });
     },
+    /** 清洗草稿中的附件数组;过滤历史空项,并通过 Vue 响应式写回各业务区块 */
     normalizeFormAttachments() {
       ['license', 'settlement', 'shop'].forEach(section => {
         const list = (this.form[section] && this.form[section].attachments) || [];
-        this.$set(this.form[section], 'attachments', list.map(item => this.normalizeAttachment(item)));
+        const attachments = Array.isArray(list)
+          ? list.filter(item => item && typeof item === 'object' && !Array.isArray(item)).map(item => this.normalizeAttachment(item))
+          : [];
+        this.$set(this.form[section], 'attachments', attachments);
       });
     },
     chooseImage() {
@@ -484,7 +504,8 @@ export default {
           registeredAddress: result.biz_license_address[0] || '',
           businessContent: result.biz_license_scope || this.form.license.businessContent,
           legalName: result.biz_license_owner_name || this.form.license.legalName,
-          licenseStart: this.normalizeDateStr(result.biz_license_start_time) || this.form.license.licenseStart
+          licenseStart: this.normalizeDateStr(result.biz_license_start_time) || this.form.license.licenseStart,
+          licenseEnd: '9999-12-31',
         });
         if (!this.form.merchant.address) this.$set(this.form.merchant, 'address', result.biz_license_address || '');
       } else if (type === 'ID_CARD_FRONT') {
@@ -496,7 +517,7 @@ export default {
         const target = section === 'license' ? this.form.license : this.form.settlement;
         if (validity.length >= 2) {
           this.$set(target, section === 'license' ? 'legalIdStart' : 'accountIdStart', this.normalizeDateStr(validity[0]));
-          this.$set(target, section === 'license' ? 'legalIdEnd' : 'accountIdEnd', this.normalizeDateStr(validity.slice(1).join('-')));
+          this.$set(target, section === 'license' ? 'legalIdEnd' : 'accountIdEnd', this.normalizeDateStr(validity.slice(1)));
         }
       } else if (type === 'BANK_CARD') {
         this.$set(this.form.settlement, 'accountNo', result.card_number || result.bank_card_number || this.form.settlement.accountNo);