jiangping
2024-03-05 7b336b5d570dece2d283d33221874e8dae1a2118
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,7 @@
          applyStartTime: '',
          applyEndTime: ''
      },
      solutionName: '',
      type: '',
      pickerOptions: {}, // 存放picker options的变量
      price: '',
@@ -187,7 +192,52 @@
          '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 = []
@@ -277,52 +327,68 @@
                        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('请完善派遣单位和工种信息')
                            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
                    })
                    // 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
                    //     })
                    // }
                }
            })
@@ -386,7 +452,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) {