Преглед изворни кода

fix: 修改添加方案驾意险、险种的数据交互

wuguojie пре 1 година
родитељ
комит
fcf65d5aa0

+ 34 - 3
src/layouts/components/DrivingType/index.vue

@@ -26,9 +26,9 @@
           <el-button link type="primary">清空</el-button>
           <el-button link type="primary">清空</el-button>
         </div>
         </div>
         <div class="selectedList">
         <div class="selectedList">
-          <div style="display: flex; align-items: center; justify-content: space-between; margin: 10px" v-for="JYX in selectedList" :key="JYX.id">
+          <div style="display: flex; align-items: center; justify-content: space-between; margin: 10px" v-for="(JYX, index) in selectedList" :key="JYX.id">
             <span>{{ JYX.productName }}</span>
             <span>{{ JYX.productName }}</span>
-            <el-icon><Close /></el-icon>
+            <el-icon style="cursor: pointer;" @click="handleDel(JYX, index)"><Close /></el-icon>
           </div>
           </div>
         </div>
         </div>
       </el-col>
       </el-col>
@@ -86,6 +86,33 @@ const handleType = (item, index) => {
     }
     }
   })
   })
 }
 }
+// 删除
+const handleDel = (item, index) => {
+  selectedList.value.splice(index, 1)
+  JYXList.value?.forEach(sub => {
+    if(sub.id === item.id) {
+      sub.checked = false
+    }
+  })
+}
+
+// 编辑
+const initEditData = (data) => {
+  JYXList.value.forEach(item => {
+    item.checked = false
+  })
+  let list = [...JYXList.value]
+  if(data && data.length > 0) {
+    data.forEach(item => {
+      item.checked = true
+    })
+    JYXList.value = list.map(a => {
+      let obj = data.find(b => b.id === a.id)
+      return obj || a
+    })
+    selectedList.value = JYXList.value.filter(a => a.checked)
+  }
+}
 
 
 // 取消
 // 取消
 const handleCancel = () => {
 const handleCancel = () => {
@@ -93,13 +120,17 @@ const handleCancel = () => {
 }
 }
 // 保存
 // 保存
 const handleConfirm = () => {
 const handleConfirm = () => {
-  emits('close', selectedList.value)
+  emits('close', JYXList.value)
 }
 }
 
 
 onMounted(() => {
 onMounted(() => {
   initJYX()
   initJYX()
 })
 })
 
 
+defineExpose({
+  initEditData
+})
+
 </script>
 </script>
 
 
 <style scoped lang="scss">
 <style scoped lang="scss">

+ 22 - 13
src/layouts/components/InsuranceType/index.vue

@@ -105,19 +105,28 @@ const handleConfirm = () => {
 
 
 // 修改数据
 // 修改数据
 const initEditData = (data) => {
 const initEditData = (data) => {
-  console.log('已选中的数据', data)
-  console.log(111, typeList.value)
-  insuranceTypeList.value = [...typeList.value]
-  console.log(222, insuranceTypeList.value)
-  // const result = insuranceTypeList.value.map(item1 => {
-  //   const item2 = data.find(item => item.id === item1.id);
-  //   return item2 || item1; // 如果找到匹配项则替换,否则保留原值
-  // });
-  const result = typeList.value.filter(item1 =>
-    !data.some(item2 => item1.id === item2.id)
-  );
-  console.log(333, insuranceTypeList.value)
-  insuranceTypeList.value = [...data, ...result]
+  insuranceTypeList.value.forEach(item => {
+    item.checked = false
+    item.options.forEach(sub => {
+      sub.checked = false
+    })
+  })
+  if(data && data.length > 0) {
+    data.forEach(item => {
+      item.checked = true
+      item.options.forEach(sub => {
+        if(item.quota === sub.value) {
+          sub.checked = true
+        }
+      })
+    })
+    let list = [...insuranceTypeList.value]
+    insuranceTypeList.value = list.map(a => {
+      let obj = data.find(b => b.id === a.id)
+      return obj || a
+    })
+  }
+
 }
 }
 
 
 onMounted(() => {
 onMounted(() => {

+ 14 - 7
src/views/quoteConfig/project/modules/projectAdd.vue

@@ -21,7 +21,7 @@
           </el-form-item>
           </el-form-item>
           <div style="display: flex;">
           <div style="display: flex;">
             <span style="width: 10%"><a style="color: red">*</a>规则条件</span>
             <span style="width: 10%"><a style="color: red">*</a>规则条件</span>
-            <div class="ruleList">
+<!--            <div class="ruleList">
               <div class="ruleItem">
               <div class="ruleItem">
                 <el-input placeholder="请填写" style="width: 300px"></el-input>&nbsp;
                 <el-input placeholder="请填写" style="width: 300px"></el-input>&nbsp;
                 <el-select style="width: 100px">
                 <el-select style="width: 100px">
@@ -32,7 +32,8 @@
                 <el-input placeholder="请填写" style="width: 300px"></el-input>&nbsp;
                 <el-input placeholder="请填写" style="width: 300px"></el-input>&nbsp;
                 <el-icon><CircleCloseFilled /></el-icon>&nbsp;
                 <el-icon><CircleCloseFilled /></el-icon>&nbsp;
               </div>
               </div>
-            </div>
+            </div>-->
+            <rule-condition :ruleConditionVisible="false"></rule-condition>
           </div>
           </div>
           <el-button style="margin: 10px 10%" plain type="primary" icon="plus">添加条件</el-button>
           <el-button style="margin: 10px 10%" plain type="primary" icon="plus">添加条件</el-button>
           <el-descriptions>
           <el-descriptions>
@@ -59,7 +60,7 @@
                       title="选择驾意险"
                       title="选择驾意险"
                       width="700"
                       width="700"
                     >
                     >
-                      <driving @close="handleDrivingClose(item, $event)"></driving>
+                      <driving ref="DrivingTypeRef" @close="handleDrivingClose(item, $event)"></driving>
                     </el-dialog>
                     </el-dialog>
                   </div>
                   </div>
                   <el-table
                   <el-table
@@ -150,8 +151,10 @@ import api from "@/api";
 import { ElMessage } from "element-plus";
 import { ElMessage } from "element-plus";
 import insurance from '../../../../layouts/components/InsuranceType/index.vue'
 import insurance from '../../../../layouts/components/InsuranceType/index.vue'
 import driving from '../../../../layouts/components/DrivingType/index.vue'
 import driving from '../../../../layouts/components/DrivingType/index.vue'
+import rule from '../../../../components/ruleConditionContainer/index.vue'
 
 
 const InsuranceTypeRef = ref(null)
 const InsuranceTypeRef = ref(null)
+const DrivingTypeRef = ref(null)
 
 
 let projectAddFrom = ref({
 let projectAddFrom = ref({
   rulesList: [],
   rulesList: [],
@@ -242,16 +245,20 @@ const insuranceTypeDel = (item, row) => {
 let drivingShow = ref(false)
 let drivingShow = ref(false)
 const handleDriving = (item, index) => {
 const handleDriving = (item, index) => {
   drivingShow.value = true
   drivingShow.value = true
+  nextTick(() => {
+    DrivingTypeRef.value[index].initEditData(item.drivingList)
+  })
 }
 }
 const handleDrivingClose = (item, list ) => {
 const handleDrivingClose = (item, list ) => {
   if(list && list.length > 0) {
   if(list && list.length > 0) {
-    list.forEach(sub => {
+    let selectList = list.filter(a => a.checked)
+    selectList.forEach(sub => {
       sub.drivingIntentionId = sub.id
       sub.drivingIntentionId = sub.id
-      sub.selectedStatus = '1'
-      sub.quantity = '1'
+      sub.selectedStatus = sub.selectedStatus?sub.selectedStatus:'1'
+      sub.quantity = sub.quantity?sub.quantity:'1'
     })
     })
+    item.drivingList = selectList
   }
   }
-  item.drivingList = list
   drivingShow.value = false
   drivingShow.value = false
 }
 }
 const drivingTypeDel = (item, row) => {
 const drivingTypeDel = (item, row) => {