Przeglądaj źródła

优化代码结构,增加可阅读性。解决分佣方式显示错误

Guos 1 tydzień temu
rodzic
commit
fb4eda1ce7
1 zmienionych plików z 122 dodań i 164 usunięć
  1. 122 164
      src/views/store/storeConfig/userInfo.vue

+ 122 - 164
src/views/store/storeConfig/userInfo.vue

@@ -375,7 +375,7 @@
                     </div>
                   </div>
                 </div>
-                
+
                 <!-- 上传控件 - 始终显示 -->
                 <div class="upload-area-wrapper">
                   <el-upload
@@ -515,11 +515,13 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item label="分佣方式" prop="brokerageType">
-            <el-radio v-model="form.brokerageType" label="1" >每盒</el-radio>
-            <el-radio v-model="form.brokerageType" label="2" >总价</el-radio>
+          <el-form-item label="分佣方式" prop="brokerageType" disabled>
+            <el-radio-group v-model="form.brokerageType">
+              <el-radio label="1" >每盒</el-radio>
+              <el-radio label="2" >总价</el-radio>
+            </el-radio-group>
           </el-form-item>
-        </el-col>
+         </el-col>
       </el-row>
       <el-form-item label="配送方式" prop="shippingType">
         <el-checkbox-group v-model="form.shippingType" size="medium">
@@ -598,12 +600,18 @@ export default {
         businessLicense: [
           { required: true, message: '营业执照不能为空', trigger: 'blur' }
         ],
+        businessCode:[
+          { required: true, message: '营业执照编号不能为空', trigger: 'blur' }
+        ],
         drugLicense: [
           { required: true, message: '药品经营许可证不能为空', trigger: 'blur' }
         ],
         drugLicenseExpiry: [
           { required: true, message: '药品经营许可证有效期不能为空', trigger: 'blur' }
         ],
+        drugCode: [
+          { required: true, message: '药品经营许可证编号不能为空', trigger: 'blur' }
+        ],
         storeName: [
           { required: true, message: '店铺名称不能为空', trigger: 'blur' }
         ],
@@ -740,24 +748,12 @@ export default {
           currentCount = this.form.foodLicense.length;
         }
       }
-      
+
       // 只有当实际图片数量达到上限时才提示
       if (currentCount >= 3) {
         this.$message.warning('最多只能上传3张图片');
       }
     },
-    // 获取用于主展示的食品经营许可证图片
-    getFoodLicenseDisplayImage() {
-      let files = [];
-      if (this.form.foodLicense) {
-        if (typeof this.form.foodLicense === 'string') {
-          files = this.form.foodLicense.split(',').filter(url => url.trim() !== '');
-        } else if (Array.isArray(this.form.foodLicense)) {
-          files = this.form.foodLicense;
-        }
-      }
-      return files.length > 0 ? files[0] : '';
-    },
     // 删除指定索引的食品经营许可证图片
     handleDeleteFoodLicense(index) {
       this.$confirm('确定要删除这张图片吗?', '提示', {
@@ -781,34 +777,13 @@ export default {
         this.$message.info('已取消删除');
       });
     },
-    // 删除所有食品经营许可证图片
-    handleDeleteFoodLicenseAll() {
-      this.$confirm('确定要删除所有图片吗?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        // 确保彻底清空 foodLicense 字段
-        this.$set(this.form, 'foodLicense', []);
-        // 同时处理可能存在的字符串情况
-        if (typeof this.form.foodLicense === 'string') {
-          this.form.foodLicense = [];
-        }
-        // 重置上传文件列表
-        this.foodLicenseFileList = [];
-        this.$forceUpdate();
-        this.$message.success('所有图片已删除');
-      }).catch(() => {
-        this.$message.info('已取消删除');
-      });
-    },
-
     // 添加图片预览方法
     previewImage(url) {
       this.previewImageUrl = url;
       this.imagePreviewVisible = true;
     },
 
+    //店铺logo
     handleAvatarSuccess(res, file) {
       if (res.code == 200) {
         this.form.logoUrl = res.url
@@ -824,11 +799,8 @@ export default {
       }
       return isLt1M
     },
-
+    //关闭
     close() {
-      //原有方法
-      // this.$store.dispatch('tagsView/delView', this.$route)
-      // this.$router.push({ path: '/index' })
       this.$store.dispatch('tagsView/delView', this.$route)
       // 检查当前路径,避免重复跳转
       if (this.$route.path !== '/index') {
@@ -946,123 +918,114 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-          // 如果存在营业执照且不为空,先进行校验
-          if (this.form.businessLicense) {
-            businessLicenseCheck({ imageUrl: this.form.businessLicense }).then(checkResponse => {
-              if (checkResponse.data.flag === false) {
-                this.$message.error(checkResponse.data.message || '营业执照校验失败');
-                return;
-              }
-              // 校验通过,继续提交流程
-              this.submitFormData();
-            }).catch(error => {
-              this.$message.error('营业执照校验异常');
-            });
-          } else {
-            // 无营业执照直接提交
+          // 营业执照是必填项,直接进行校验
+          businessLicenseCheck({ imageUrl: this.form.businessLicense }).then(checkResponse => {
+            if (checkResponse.data.flag === false) {
+              this.$message.error(checkResponse.data.message || '营业执照校验失败');
+              return;
+            }
+            // 校验通过,继续提交流程
             this.submitFormData();
-          }
+          }).catch(error => {
+            this.$message.error('营业执照校验异常');
+          });
         }
       });
     },
 
     /** 提交按钮 */
     submitFormData() {
-      this.$refs["form"].validate(valid => {
-        if (valid) {
-          // 处理表单数据
-          const formData = Object.assign({}, this.form);
-          // 特别处理 foodLicense 字段,将其转换为逗号分隔的字符串
-          if (Array.isArray(formData.foodLicense)) {
-            formData.foodLicense = formData.foodLicense.join(',');
-          } else if (!formData.foodLicense) {
-            formData.foodLicense = ''; // 确保空值处理
-          }
-          // 处理城市ID
-          if (formData.cityIds) {
-            formData.cityIds = formData.cityIds.toString();
-          }
-          // 处理配送方式
-          if (formData.shippingType) {
-            formData.shippingType = formData.shippingType.toString();
-          }
-          // 处理日期范围字段
-          const dateRangeFields = [
-            'drugLicenseExpiry',
-            'medicalDevice2Expiry',
-            'medicalDevice1Expiry',
-            'medicalDevice3Expiry',
-            'foodLicenseExpiry',
-            'medicalLicenseExpiry',
-            'businessLicenseExpire'
-          ];
-          dateRangeFields.forEach(field => {
-            if (formData[field] && formData[field].length === 2) {
-              formData[`${field}Start`] = formData[field][0];
-              formData[`${field}End`] = formData[field][1];
-            }
-          });
-          //其他上传的日期检查
-          const agreementFields = [
-            {
-              expiryField: 'settlementAgreementExpiry',
-              startField: 'settlementAgreementStart',
-              endField: 'settlementAgreementEnd',
-              agreementField: 'settlementAgreement',
-              message: '其它资质-入驻协议,有效期开始日期或结束日期不能为空!'
-            },
-            {
-              expiryField: 'qualityAssuranceAgreementExpiry',
-              startField: 'qualityAssuranceAgreementStart',
-              endField: 'qualityAssuranceAgreementEnd',
-              agreementField: 'qualityAssuranceAgreement',
-              message: '质量保证协议,有效期开始日期或结束日期不能为空!'
-            },
-            {
-              expiryField: 'otherSpecialQualificationExpiry',
-              startField: 'otherSpecialQualificationStart',
-              endField: 'otherSpecialQualificationEnd',
-              agreementField: 'otherSpecialQualification',
-              message: '其它特殊资质,有效期开始日期或结束日期不能为空!'
-            }
-          ];
-          for (const field of agreementFields) {
-            if (formData[field.expiryField] && formData[field.expiryField].length === 2) {
-              formData[field.startField] = formData[field.expiryField][0];
-              formData[field.endField] = formData[field.expiryField][1];
-            } else {
-              if (formData[field.agreementField] != null) {
-                return this.$message.warning(field.message);
-              }
-            }
+      const formData = Object.assign({}, this.form);
+      // 特别处理 foodLicense 字段,将其转换为逗号分隔的字符串
+      if (Array.isArray(formData.foodLicense)) {
+        formData.foodLicense = formData.foodLicense.join(',');
+      } else if (!formData.foodLicense) {
+        formData.foodLicense = ''; // 确保空值处理
+      }
+      // 处理城市ID
+      if (formData.cityIds) {
+        formData.cityIds = formData.cityIds.toString();
+      }
+      // 处理配送方式
+      if (formData.shippingType) {
+        formData.shippingType = formData.shippingType.toString()
+      }
+      // 处理日期范围字段
+      const dateRangeFields = [
+        'drugLicenseExpiry',
+        'medicalDevice2Expiry',
+        'medicalDevice1Expiry',
+        'medicalDevice3Expiry',
+        'foodLicenseExpiry',
+        'medicalLicenseExpiry',
+        'businessLicenseExpire'
+      ]
+      dateRangeFields.forEach(field => {
+        if (formData[field] && formData[field].length === 2) {
+          formData[`${field}Start`] = formData[field][0]
+          formData[`${field}End`] = formData[field][1]
+        }
+      })
+      //其他上传的日期检查
+      const agreementFields = [
+        {
+          expiryField: 'settlementAgreementExpiry',
+          startField: 'settlementAgreementStart',
+          endField: 'settlementAgreementEnd',
+          agreementField: 'settlementAgreement',
+          message: '其它资质-入驻协议,有效期开始日期或结束日期不能为空!'
+        },
+        {
+          expiryField: 'qualityAssuranceAgreementExpiry',
+          startField: 'qualityAssuranceAgreementStart',
+          endField: 'qualityAssuranceAgreementEnd',
+          agreementField: 'qualityAssuranceAgreement',
+          message: '质量保证协议,有效期开始日期或结束日期不能为空!'
+        },
+        {
+          expiryField: 'otherSpecialQualificationExpiry',
+          startField: 'otherSpecialQualificationStart',
+          endField: 'otherSpecialQualificationEnd',
+          agreementField: 'otherSpecialQualification',
+          message: '其它特殊资质,有效期开始日期或结束日期不能为空!'
+        }
+      ]
+      for (const field of agreementFields) {
+        if (formData[field.expiryField] && formData[field.expiryField].length === 2) {
+          formData[field.startField] = formData[field.expiryField][0]
+          formData[field.endField] = formData[field.expiryField][1]
+        } else {
+          if (formData[field.agreementField] != null) {
+            return this.$message.warning(field.message)
           }
+        }
+      }
 
-          // 优化开关值转换逻辑,使用更简洁的方式设置永久有效标志位
-          formData.isBusinessLicensePermanent = this.switchValue ? 1 : 0;
-          formData.isMedicalDevice1ExpiryPermanent = this.switchMedicalValue ? 1 : 0;
-          formData.isMedicalDevice2ExpiryPermanent = this.medicalDevice2ExpiryValue ? 1 : 0;
-          formData.isMedicalLicenseExpiryPermanent = this.medicalLicenseExpiryValue ? 1 : 0;
-          // 补充缺失的永久有效标志位设置
-          formData.isDrugLicensePermanent = this.drugLicenseValue ? 1 : 0;
-          formData.isMedicalDevice3ExpiryPermanent = this.medicalDevice3ExpiryValue ? 1 : 0;
-          formData.isFoodLicenseExpiryPermanent = this.foodLicenseExpiryValue ? 1 : 0;
+      // 优化开关值转换逻辑,使用更简洁的方式设置永久有效标志位
+      formData.isBusinessLicensePermanent = this.switchValue ? 1 : 0
+      formData.isMedicalDevice1ExpiryPermanent = this.switchMedicalValue ? 1 : 0
+      formData.isMedicalDevice2ExpiryPermanent = this.medicalDevice2ExpiryValue ? 1 : 0
+      formData.isMedicalLicenseExpiryPermanent = this.medicalLicenseExpiryValue ? 1 : 0
+      // 补充缺失的永久有效标志位设置
+      formData.isDrugLicensePermanent = this.drugLicenseValue ? 1 : 0
+      formData.isMedicalDevice3ExpiryPermanent = this.medicalDevice3ExpiryValue ? 1 : 0
+      formData.isFoodLicenseExpiryPermanent = this.foodLicenseExpiryValue ? 1 : 0
 
-          if (formData.storeId != null) {
-            updateStore(formData).then(response => {
-              this.msgSuccess("修改成功");
-              this.open = false;
-              this.getList();
-            });
-          } else {
-            addStore(formData).then(response => {
-              this.msgSuccess("新增成功");
-              this.open = false;
-              this.getList();
-            });
-          }
-        }
-      });
+      if (formData.storeId != null) {
+        updateStore(formData).then(response => {
+          this.msgSuccess('修改成功')
+          this.open = false
+          this.getList()
+        })
+      } else {
+        addStore(formData).then(response => {
+          this.msgSuccess('新增成功')
+          this.open = false
+          this.getList()
+        })
+      }
     },
+    //城市控制
     handleCityChange(value) {
       var nodes = this.$refs.citySelect.getCheckedNodes()
       this.form.address = nodes[0].pathLabels[0] + nodes[0].pathLabels[1] + nodes[0].pathLabels[2]
@@ -1079,6 +1042,10 @@ export default {
       this.reset()
       getStoreInfo().then(response => {
         this.form = response.data;
+        // 确保 brokerageType 是字符串类型
+        if (this.form.brokerageType) {
+          this.form.brokerageType = this.form.brokerageType.toString();
+        }
         // 处理食品经营许可证字段,将逗号分隔的字符串转换为数组
         if (this.form.foodLicense) {
           if (typeof this.form.foodLicense === 'string') {
@@ -1091,24 +1058,15 @@ export default {
         } else {
           this.form.foodLicense = [];
         }
-        if (this.form.isBusinessLicensePermanent == 1) {
-          this.switchValue = true;
-        }
-        if (this.form.isMedicalDevice1ExpiryPermanent == 1) {
-          this.switchMedicalValue = true;
-        }
-        if (this.form.isMedicalDevice2ExpiryPermanent == 1) {
-          this.medicalDevice2ExpiryValue = true;
-        }
-        if (this.form.isMedicalLicenseExpiryPermanent == 1) {
-          this.medicalLicenseExpiryValue = true;
-        }
+        this.switchValue = this.form.isBusinessLicensePermanent == 1;
+        this.switchMedicalValue = this.form.isMedicalDevice1ExpiryPermanent == 1;
+        this.medicalDevice2ExpiryValue = this.form.isMedicalDevice2ExpiryPermanent == 1;
+        this.medicalLicenseExpiryValue = this.form.isMedicalLicenseExpiryPermanent == 1;
         if (this.form.drugScopeHasFrozen === undefined) {
           this.form.drugScopeHasFrozen = null;
         }
         this.open = true;
         this.title = "修改店铺";
-
         let str = this.form.shippingType
         this.form.shippingType = str.split(",")
         this.form.cityIds = ((this.form.cityIds).split(",")).map(Number)
@@ -1424,4 +1382,4 @@ export default {
   cursor: pointer;
   font-size: 14px;
 }
-</style>
+</style>