Ver código fonte

1.修复商品为空检验问题

Guos 1 mês atrás
pai
commit
fb2f58901b
1 arquivos alterados com 39 adições e 102 exclusões
  1. 39 102
      src/views/hisStore/platformProduct/index.vue

+ 39 - 102
src/views/hisStore/platformProduct/index.vue

@@ -228,39 +228,11 @@
         </el-button>
       </el-col>
 
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="primary"-->
-<!--          plain-->
-<!--          icon="el-icon-refresh"-->
-<!--          size="mini"-->
-<!--          :disabled="multiple"-->
-<!--          @click="handleSync"-->
-<!--          v-hasPermi="['store:storeProduct:sync']"-->
-<!--        >同步-->
-<!--        </el-button>-->
-<!--      </el-col>-->
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="danger"-->
-<!--          plain-->
-<!--          icon="el-icon-close"-->
-<!--          size="mini"-->
-<!--          :disabled="multiple"-->
-<!--          @click="handleBatchOff"-->
-<!--          v-hasPermi="['store:storeProduct:updateIsShow']"-->
-<!--        >批量下架-->
-<!--        </el-button>-->
-<!--      </el-col>-->
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
     <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
       <el-tab-pane label="全部商品" name="-1"></el-tab-pane>
-<!--      <el-tab-pane label="出售中" name="1"></el-tab-pane>-->
-<!--      <el-tab-pane label="待上架" name="0"></el-tab-pane>-->
-<!--      <el-tab-pane label="待审核" name="3"></el-tab-pane>-->
-<!--      <el-tab-pane label="已驳回" name="4"></el-tab-pane>-->
     </el-tabs>
 
     <el-table height="500" border v-loading="loading" :data="storeProductList"
@@ -306,15 +278,6 @@
         </template>
       </el-table-column>
 
-<!--      <el-table-column label="同步状态" align="center" prop="pushStatus">-->
-<!--        <template slot-scope="scope">-->
-<!--          <el-tag :type="scope.row.pushStatus === 1 ? 'success' : scope.row.pushStatus === 2 ? 'danger' : 'warning'">-->
-<!--            {{-->
-<!--              scope.row.pushStatus === 0 ? '推送中' : scope.row.pushStatus === 1 ? '成功' : scope.row.pushStatus === 2 ? '失败' : '未同步'-->
-<!--            }}-->
-<!--          </el-tag>-->
-<!--        </template>-->
-<!--      </el-table-column>-->
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200px">
         <template slot-scope="scope">
           <el-button
@@ -1170,50 +1133,14 @@ export default {
   watch: {
     businessArr(val) {
       this.form.business = val.join(',');
-      this.$nextTick(() => {
-        // 1. 组件层面清除校验
-        if (this.$refs.form) {
-          this.$refs.form.clearValidate('business');
-        }
-        // 2. DOM层面强制移除错误提示
-        const errorDom = document.querySelector('.el-form-item__error[style*="business"]');
-        if (errorDom) {
-          errorDom.style.display = 'none'; // 隐藏提示
-          // 或彻底移除:errorDom.remove();
-        }
-      });
     },
       // 生产许可证
       licenseArr(val) {
         this.form.license = val.join(',');
-        this.$nextTick(() => {
-          // 1. 组件层面清除校验
-          if (this.$refs.form) {
-            this.$refs.form.clearValidate('license');
-          }
-          // 2. DOM层面强制移除错误提示
-          const errorDom = document.querySelector('.el-form-item__error[style*="license"]');
-          if (errorDom) {
-            errorDom.style.display = 'none'; // 隐藏提示
-            // 或彻底移除:errorDom.remove();
-          }
-        });
       },
       // 注册证书
       certificateArr(val) {
         this.form.certificate = val.join(',');
-        this.$nextTick(() => {
-          // 1. 组件层面清除校验
-          if (this.$refs.form) {
-            this.$refs.form.clearValidate('certificate');
-          }
-          // 2. DOM层面强制移除错误提示
-          const errorDom = document.querySelector('.el-form-item__error[style*="certificate"]');
-          if (errorDom) {
-            errorDom.style.display = 'none'; // 隐藏提示
-            // 或彻底移除:errorDom.remove();
-          }
-        });
       },
       // 其他字段(如drugImageArr等)按相同逻辑补充
       drugImageArr(val) {
@@ -1344,20 +1271,6 @@ export default {
         if (newVal && this.form.storeId && this.isFormInitialized) {
           this.debounceCheckStoreLicense();
         }
-        // 动态调整批号的验证规则
-        // this.$nextTick(() => {
-        //   if (this.isMedicalDeviceCategory) {
-        //     // 是器械时,批号为必填
-        //     if (!this.rules.batchNumber?.some(rule => rule.required)) {
-        //       this.rules.batchNumber = [{ required: true, message: "批号不能为空", trigger: "blur" }, ...(this.rules.batchNumber || [])];
-        //     }
-        //   } else {
-        //     // 非器械时,移除批号必填规则
-        //     if (this.rules.batchNumber) {
-        //       this.rules.batchNumber = this.rules.batchNumber.filter(rule => !rule.required);
-        //     }
-        //   }
-        // });
       },
       immediate: true
     },
@@ -1682,18 +1595,18 @@ export default {
         // businessLink: [
         //   { required: true, message: "非首营链接不能为空!", trigger: "change" }
         // ],
-        business: [
-          { required: true, message: "生产企业营业执照不能为空!", trigger: ["blur", "change"] },
-          { whitespace: true, message: "生产企业营业执照不能为空白!", trigger: ["blur", "change"] }
-        ],
-        license: [
-          { required: true, message: "生产企业的生产许可证/备案凭证不能为空!", trigger: ["blur", "change"] },
-          { whitespace: true, message: "生产企业的生产许可证/备案凭证不能为空白!", trigger: ["blur", "change"]}
-        ],
-        certificate: [
-          { required: true, message: "商品注册证/备案凭证不能为空!", trigger: ["blur", "change"] },
-          { whitespace: true, message: "商品注册证/备案凭证不能为空白!", trigger: ["blur", "change"]}
-        ],
+        // business: [
+        //   { required: true, message: "生产企业营业执照不能为空!", trigger: ["blur", "change"] },
+        //   { whitespace: true, message: "生产企业营业执照不能为空白!", trigger: ["blur", "change"] }
+        // ],
+        // license: [
+        //   { required: true, message: "生产企业的生产许可证/备案凭证不能为空!", trigger: ["blur", "change"] },
+        //   { whitespace: true, message: "生产企业的生产许可证/备案凭证不能为空白!", trigger: ["blur", "change"]}
+        // ],
+        // certificate: [
+        //   { required: true, message: "商品注册证/备案凭证不能为空!", trigger: ["blur", "change"] },
+        //   { whitespace: true, message: "商品注册证/备案凭证不能为空白!", trigger: ["blur", "change"]}
+        // ],
         businessExpire: [
           { required: true, message: "生产企业营业执照有效期不能为空!", trigger: "change" }
         ],
@@ -2524,23 +2437,47 @@ export default {
       // 1. 先执行 Element UI 的表单验证
       this.$refs["form"].validate(valid => {
         if (valid) {
-          // 4. 检查店铺许可证权限
+          // 2. 手动验证三个证书字段
+          const manualErrors = this.validateCertificates();
+          if (manualErrors.length > 0) {
+            this.$message.error(manualErrors.join('\n'));
+            return;
+          }
+          // 3. 检查店铺许可证权限
           if (this.storeLicenseCheckFailed) {
             this.$message.error('当前店铺无权限经营该类商品,请重新选择分类或店铺');
             return;
           }
-          // 5. 统一校验所有证书是否过期
+          // 4. 统一校验所有证书是否过期
           const expireError = this.checkAllCertificatesExpire();
           if (expireError) {
             this.$message.error(expireError);
             return;
           }
-          // 6. 执行提交逻辑
+          // 5. 执行提交逻辑
           this.executeSubmit();
         }
       });
     },
 
+    // 新增方法:手动验证证书字段
+    validateCertificates() {
+      const errors = [];
+      // 验证生产企业营业执照
+      if (!this.form.business || this.form.business.trim() === '') {
+        errors.push('生产企业营业执照不能为空!');
+      }
+      // 验证生产企业的生产许可证/备案凭证
+      if (!this.form.license || this.form.license.trim() === '') {
+        errors.push('生产企业的生产许可证/备案凭证不能为空!');
+      }
+      // 验证商品注册证/备案凭证
+      if (!this.form.certificate || this.form.certificate.trim() === '') {
+        errors.push('商品注册证/备案凭证不能为空!');
+      }
+      return errors;
+    },
+
     //具体的提交逻辑
     executeSubmit() {
       let checkBoolean = false;