From 84b74d64ecc519882b89278f1011f7ac7525d190 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 05 三月 2024 19:23:40 +0800
Subject: [PATCH] mrshi

---
 company/src/components/enterprise/OperaInsuranceApplyWindow.vue |  126 +++++++++++++++++++++++++++---------------
 1 files changed, 81 insertions(+), 45 deletions(-)

diff --git a/company/src/components/enterprise/OperaInsuranceApplyWindow.vue b/company/src/components/enterprise/OperaInsuranceApplyWindow.vue
index ab34c40..b6ed940 100644
--- a/company/src/components/enterprise/OperaInsuranceApplyWindow.vue
+++ b/company/src/components/enterprise/OperaInsuranceApplyWindow.vue
@@ -138,6 +138,8 @@
         <importEmployees ref="importEmployees" @result="getValue" />
         <!--    纭宸ョ    -->
         <confirmJobType ref="confirmJobType" @result="getUser" />
+        <!--    鏌ョ湅璇﹀崟    -->
+        <detailsPolicyholder ref="detailsPolicyholder" @success="successEvent" />
     </GlobalWindow>
 </template>
 
@@ -148,12 +150,14 @@
 import addEmployee from '@/components/enterprise/addEmployee'
 import importEmployees from '@/components/enterprise/importEmployees'
 import confirmJobType from '@/components/enterprise/confirmJobType'
+import detailsPolicyholder from '@/components/business/detailsPolicyholder'
 import { all, getNewVersion } from '@/api/business/solutions'
+import { mapState } from 'vuex'
 import { create, getCountCyclePriceVO, getDetail, findList, updateData } from '@/api/business/insuranceApply'
 export default {
   name: 'OperaInsuranceApplyWindow2',
   extends: BaseOpera,
-  components: { GlobalWindow, selectEmployees, addEmployee, importEmployees, confirmJobType },
+  components: { GlobalWindow, selectEmployees, addEmployee, importEmployees, confirmJobType, detailsPolicyholder },
   data () {
     return {
       form: {
@@ -163,6 +167,8 @@
           applyStartTime: '',
           applyEndTime: ''
       },
+      solutionName: '',
+      type: '',
       pickerOptions: {}, // 瀛樻斁picker options鐨勫彉閲�
       price: '',
       company: [],
@@ -186,12 +192,60 @@
           'field.id': 'id'
       })
   },
+    computed: {
+      ...mapState(['userInfo'])
+    },
     methods: {
+      successEvent() {
+          let arr = JSON.parse(JSON.stringify(this.tableData))
+          arr.forEach(item => {
+              item.idcardNo = item.idCard
+          })
+          this.isWorking = true
+          // if (!this.form.id) {
+              create({
+                  applyDetailList: arr,
+                  applyStartTime: this.form.applyStartTime,
+                  applyEndTime: this.form.applyEndTime,
+                  solutionId: this.form.solutionId
+              }).then(() => {
+                  this.visible = false
+                  this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
+                  this.$emit('success')
+              })
+                  .catch(e => {
+                      this.$tip.apiFailed(e)
+                  })
+                  .finally(() => {
+                      this.isWorking = false
+                  })
+          // } else {
+          //     updateData({
+          //         id: this.form.id,
+          //         applyDetailList: arr,
+          //         applyStartTime: this.form.applyStartTime,
+          //         applyEndTime: this.form.applyEndTime,
+          //         solutionId: this.form.solutionId
+          //     }).then(() => {
+          //         this.visible = false
+          //         this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
+          //         this.$emit('success')
+          //     }).catch(e => {
+          //         this.$tip.apiFailed(e)
+          //     })
+          //         .finally(() => {
+          //             this.isWorking = false
+          //         })
+          // }
+      },
       open (title, target) {
           this.title = title
           this.tableData = []
           this.form.id = null
           this.item = null
+          if (target.type) {
+              this.type = target.type
+          }
           this.form.solutionId = ''
           this.form.applyStartTime = ''
           this.form.applyEndTime = ''
@@ -216,8 +270,15 @@
             findList({ applyId: this.form.id })
                 .then(res => {
                     res.forEach(item => {
+                        console.log(item)
                         item.idCard = item.idcardNo
                         item.fee = ''
+                        if (this.type === 1) {
+                            item.duName = ''
+                            item.duId = ''
+                            item.worktypeId = ''
+                            item.workTypeName = ''
+                        }
                     })
                     this.tableData = res
                 })
@@ -252,7 +313,7 @@
             }
             this.seleData.forEach(item => {
                 this.tableData.forEach((row, index) => {
-                    if (item === row.name) {
+                    if (item === row.idCard) {
                         this.tableData.splice(index, 1)
                     }
                 })
@@ -266,52 +327,27 @@
                         return
                     }
                     for (let i = 0; i < this.tableData.length; i++) {
-                        console.log(this.tableData[i].worktypeId, this.tableData[i].duId)
+                        console.log(this.tableData[i].worktypeId)
+                        console.log(this.tableData[i].duId)
                         if (!this.tableData[i].worktypeId || !this.tableData[i].duId) {
                             this.$message.warning('璇峰畬鍠勬淳閬e崟浣嶅拰宸ョ淇℃伅')
                             return
                         }
                     }
-                    let arr = JSON.parse(JSON.stringify(this.tableData))
-                    arr.forEach(item => {
-                        item.idcardNo = item.idCard
+
+                    let price = 0
+                    this.tableData.forEach(item => {
+                        price = price + item.fee
                     })
-                    this.isWorking = true
-                    if (!this.form.id) {
-                        create({
-                            applyDetailList: arr,
-                            applyStartTime: this.form.applyStartTime,
-                            applyEndTime: this.form.applyEndTime,
-                            solutionId: this.form.solutionId
-                        }).then(() => {
-                            this.visible = false
-                            this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
-                            this.$emit('success')
-                        })
-                            .catch(e => {
-                                this.$tip.apiFailed(e)
-                            })
-                            .finally(() => {
-                                this.isWorking = false
-                            })
-                    } else {
-                        updateData({
-                            id: this.form.id,
-                            applyDetailList: arr,
-                            applyStartTime: this.form.applyStartTime,
-                            applyEndTime: this.form.applyEndTime,
-                            solutionId: this.form.solutionId
-                        }).then(() => {
-                            this.visible = false
-                            this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
-                            this.$emit('success')
-                        }).catch(e => {
-                            this.$tip.apiFailed(e)
-                        })
-                        .finally(() => {
-                            this.isWorking = false
-                        })
-                    }
+                    this.$refs.detailsPolicyholder.open('鎶曚繚璇︽儏鍗�', {
+                        companyName: this.userInfo.company.name,
+                        solutionName: this.item.name,
+                        applyStartTime: this.form.applyStartTime,
+                        applyEndTime: this.form.applyEndTime,
+                        insureNum: this.tableData.length,
+                        totalPrice: price,
+                        detailList: this.tableData
+                    })
 
                 }
             })
@@ -375,7 +411,7 @@
               this.$message.warning('璇峰厛閫夋嫨淇濋櫓鏂规')
               return
           }
-          this.$refs.importEmployees.open('涓婁紶鍚嶅崟', { arr: this.tableData, price: this.price })
+          this.$refs.importEmployees.open('涓婁紶鍚嶅崟', { arr: this.tableData, solutionId: this.form.solutionId, type: 1, price: this.price })
       },
       // 鍒囨崲鏂规
       changeSolution(e) {
@@ -427,7 +463,7 @@
       getUser(obj) {
           this.seleData.forEach(id => {
               this.tableData.forEach(row => {
-                   if (id === row.id) {
+                   if (id === row.idCard) {
                        row.workTypeName = obj.workTypeName
                        row.worktypeId = obj.worktypeId
                        row.duName = obj.duName
@@ -482,7 +518,7 @@
           return sexAndAge.age
       },
       handleSelectionChange (e) {
-          this.seleData = e.map(item => item.id)
+          this.seleData = e.map(item => item.idCard)
       },
       getValue(list) {
           this.tableData.push(...list)

--
Gitblit v1.9.3