Sfoglia il codice sorgente

Merge branch 'dev' of http://39.101.143.165:8090/dong_k/tenant-Platform into dev

@dongkboy 1 mese fa
parent
commit
75af017be6
1 ha cambiato i file con 88 aggiunte e 82 eliminazioni
  1. 88 82
      src/views/insurancePolicy/index.vue

+ 88 - 82
src/views/insurancePolicy/index.vue

@@ -973,7 +973,7 @@
                                     :value="item.value"></el-option>
                                 </el-select>
                                 <span v-if="props.row.kindName == '乘客责任险'">*{{ insurancePolicyForm.seatCount - 1
-                                  }}/座</span>
+                                }}/座</span>
                               </div>
                             </template>
                           </el-table-column>
@@ -1045,7 +1045,7 @@
                           <el-table-column label="产品名称" prop="productName" align="center">
                             <template #default="props">
                               <el-button link type="primary" @click="getJYXDetail(props.row)">{{ props.row.productName
-                                }}</el-button>
+                              }}</el-button>
                             </template>
                           </el-table-column>
                           <el-table-column label="数量" align="center">
@@ -1098,12 +1098,12 @@
                             <div class="Factor-item flex a-c f-c ">
                               <span class="item-header flex a-c ">交强续保</span>
                               <span>{{ ['', '新保', '续保', '转保'][Number(scope.row.quoteResult?.scoreVo?.jqRenewal)] || '--'
-                              }}</span>
+                                }}</span>
                             </div>
                             <div class="Factor-item flex a-c f-c ">
                               <span class="item-header flex a-c ">商业续保</span>
                               <span>{{ ['', '新保', '续保', '转保'][Number(scope.row.quoteResult?.scoreVo?.syRenewal)] || '--'
-                              }}</span>
+                                }}</span>
                             </div>
                             <div class="Factor-item flex a-c f-c ">
                               <span class="item-header flex a-c ">总折扣率</span>
@@ -2757,6 +2757,7 @@ const getSchemeResult = (bool: false) => {
     if (res.data?.optionalScheme) {
       list.push(res.data.optionalScheme)
     }
+    list = list.map(v => ({ ...v, drivings: v.drivings.map(k => ({ ...k, minQuantity: k.quantity })) }))
     if (list.length > 0) {
       list.forEach((item: any) => {
         item.checked = false
@@ -3223,7 +3224,7 @@ const handleUnderwritingClose = (bool: any, dataObj: any) => {
     insOrderRightsInfoDto.value.totalPriceCount = dataObj.totalPriceCount;
   }
   underwritingShow.value = false
-  if(!bool) return
+  if (!bool) return
   if (bool?.code == 200) {
     ElMessage({
       message: bool.msg,
@@ -3404,101 +3405,106 @@ const handleRecognition = (achor: any) => {
   })
 }
 
-
-// 提交相关
-let loading = ref(false)  // 提交加载状态
-/**
- * 处理保险单提交
- * 验证表单数据并提交给后端
- * @param InsurancePolicyRefs 表单引用实例
- * @param scope 当前行作用域
- */
-const handleSubmit = async (InsurancePolicyRefs: FormInstance | undefined, scope: any) => {
-  insurancePolicyForm.value.order.insuranceCompanyCode = scope.id
+const validate = async (quoteList) => {
   if (!Number(insurancePolicyForm.value.purchasePrice)) {
     ElMessage({
       message: '请重新选择车型',
       type: 'warning'
     })
-    return
+    return false
   }
-  const valid = await validateForm(InsurancePolicyRefs)
+  const valid = await validateForm(InsurancePolicyRefs.value)
   if (!valid) {
     ElMessage({
       message: '请完整填写相关信息',
       type: 'warning'
     })
-  } else {
-    paramValidate()//数据处理
-    // 先保存影像资料
-    api.insurancePolicyApi.imageSave({
-      order: {
-        quoteNo: insurancePolicyForm.value.order.quoteNo
-      },
-      imageVoList: insurancePolicyForm.value.imageVoList
-    }).then((res: any) => {
-      if (res.code == 200) {
-        ElMessage({
-          message: res.msg,
-          type: 'success'
-        })
-        // 再进行报价
-        quoteData.value.map((val: any, index: any) => {
-          if (val.id == scope.id) {
-            quoteInsurance(val.id, index, val)
-          }
-          return val;
-        })
-      }
+    return false
+  }
+  for (let i = 0; i < quoteList.length; i++) {
+    const element = quoteList[i];
+    const product = element.projectList?.find((v, index) => element.productIndex === index)
+    const noMatchObj = product.drivings.find(v => v.minQuantity && Number(v.quantity ?? 0) < Number(v.minQuantity))
+    ElMessage({
+      message: `${noMatchObj.productName}最低需要买${noMatchObj.minQuantity}份`,
+      type: 'warning'
     })
+    return false;
   }
+
+  return true
+}
+
+// 提交相关
+let loading = ref(false)  // 提交加载状态
+/**
+ * 处理保险单提交
+ * 验证表单数据并提交给后端
+ * @param InsurancePolicyRefs 表单引用实例
+ * @param scope 当前行作用域
+ */
+const handleSubmit = async (InsurancePolicyRefs: FormInstance | undefined, scope: any) => {
+  insurancePolicyForm.value.order.insuranceCompanyCode = scope.id
+  const quoteList = quoteData.value.filter(v => v.id === scope.id)
+  const valid = await validate(quoteList)
+  if (!valid) return
+  paramValidate()//数据处理
+  // 先保存影像资料
+  api.insurancePolicyApi.imageSave({
+    order: {
+      quoteNo: insurancePolicyForm.value.order.quoteNo
+    },
+    imageVoList: insurancePolicyForm.value.imageVoList
+  }).then((res: any) => {
+    if (res.code == 200) {
+      ElMessage({
+        message: res.msg,
+        type: 'success'
+      })
+      // 再进行报价
+      quoteData.value.map((val: any, index: any) => {
+        if (val.id == scope.id) {
+          quoteInsurance(val.id, index, val)
+        }
+        return val;
+      })
+    }
+  })
 }
 /**
  * 批量报价
  */
 const batchQuotes = async (InsurancePolicyRefs: FormInstance | undefined) => {
-  if (!Number(insurancePolicyForm.value.purchasePrice)) {
-    ElMessage({
-      message: '请重新选择车型',
-      type: 'warning'
-    })
-    return
-  }
-  const valid = await validateForm(InsurancePolicyRefs)
-  if (!valid) {
-    ElMessage({
-      message: '请完整填写相关信息',
-      type: 'warning'
-    })
-  } else {
-    paramValidate()//数据处理
-    // 先保存影像资料
-    api.insurancePolicyApi.imageSave({
-      order: {
-        quoteNo: insurancePolicyForm.value.order.quoteNo
-      },
-      imageVoList: insurancePolicyForm.value.imageVoList
-    }).then((res: any) => {
-      if (res.code == 200) {
-        ElMessage({
-          message: res.msg,
-          type: 'success'
-        })
-        // 再进行报价
-        quoteData.value.map((val: any, index: any) => {
-          if (val.checked) {
-            quoteInsurance(val.id, index, val)
-          }
-          return val;
-        })
-      } else {
-        ElMessage({
-          message: res.msg,
-          type: 'warning'
-        })
-      }
-    })
-  }
+  const quoteList = quoteData.value.filter(v => v.checked)
+  const valid = await validate(quoteList)
+  if (!valid) return
+  paramValidate()//数据处理
+  // 先保存影像资料
+  api.insurancePolicyApi.imageSave({
+    order: {
+      quoteNo: insurancePolicyForm.value.order.quoteNo
+    },
+    imageVoList: insurancePolicyForm.value.imageVoList
+  }).then((res: any) => {
+    if (res.code == 200) {
+      ElMessage({
+        message: res.msg,
+        type: 'success'
+      })
+      // 再进行报价
+      quoteData.value.map((val: any, index: any) => {
+        if (val.checked) {
+          quoteInsurance(val.id, index, val)
+        }
+        return val;
+      })
+    } else {
+      ElMessage({
+        message: res.msg,
+        type: 'warning'
+      })
+    }
+  })
 }
 /**
  * 表单完整验证函数(包含基础验证和 Element Plus 表单校验)