MrShi
2024-03-08 d2bc6e096f0806b78ea92d4b90a21d3627d406c7
company/src/components/enterprise/factoryChange.vue
@@ -18,8 +18,8 @@
                            v-model="form.applyStartTime"
                            type="date"
                            :picker-options="pickerOptions"
                            value-format="yyyy-MM-dd"
                            format="yyyy 年 MM 月 dd 日"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            format="yyyy-MM-dd HH:mm:ss"
                            placeholder="选择日期">
                        </el-date-picker>
                        <span style="color: #F95601; font-size: 14px;">(次日生效投保请于17:30前提交,超时提交以保险单为准)</span>
@@ -77,7 +77,7 @@
                <el-table-column
                    prop="currentFee"
                    align="center"
                    label="当前费用(元)">
                    label="已产生费用(元)">
                </el-table-column>
                <el-table-column
                    prop="fee"
@@ -147,13 +147,15 @@
            <span v-if="item.ortherInfo">{{item.ortherInfo}}</span>
        </div>
        <!--    选择员工    -->
        <selectEmployees ref="selectEmployees" @result="getValue" />
        <selectEmployees ref="selectEmployees" @result="getValue1" />
        <!--    添加员工    -->
        <addEmployee ref="addEmployee" @result="getValue" />
        <!--    导入名单    -->
        <importEmployees ref="importEmployees" @result="getValue" />
        <!--    确认工种    -->
        <confirmJobType ref="confirmJobType" @result="getUser" />
        <!--    详单    -->
        <ApplyChangeUnitDetails1 ref="ApplyChangeUnitDetails1" @success="success" />
    </GlobalWindow>
</template>
@@ -164,13 +166,15 @@
    import addEmployee from '@/components/enterprise/addEmployee'
    import importEmployees from '@/components/enterprise/importEmployees'
    import confirmJobType from '@/components/enterprise/confirmJobType'
    import ApplyChangeUnitDetails1 from '@/components/business/ApplyChangeUnitDetails1'
    import { all } from '@/api/business/solutions'
    import { getDetail, findList } from '@/api/business/insuranceApply'
    import { create } from '@/api/business/applyChange'
    import { getDate, compareDates, getTomorrow } from '@/utils/util'
    export default {
        name: 'factoryChange',
        extends: BaseOpera,
        components: { GlobalWindow, selectEmployees, addEmployee, importEmployees, confirmJobType },
        components: { GlobalWindow, selectEmployees, addEmployee, importEmployees, confirmJobType, ApplyChangeUnitDetails1 },
        data () {
            return {
                form: {
@@ -181,6 +185,7 @@
                    applyEndTime: '',
                    factory: []
                },
                newVersionSolutionId: '',
                pickerOptions: {},
                price: '',
                endTime: '',    //    实际保险生效止期
@@ -208,6 +213,7 @@
                this.form.addDetailList = []
                this.form.delDetailList = []
                this.list = []
                this.form.factory = []
                this.form.id = null
                this.item = null
                this.form.solutionId = ''
@@ -229,6 +235,26 @@
                this.getCompany()
                this.visible = true
                // this.updatePickerOptions()
            },
            success() {
                this.form.factory.forEach(item => {
                    item.idcardNo = item.idCard
                })
                this.isWorking = true
                create({
                    applyId: this.form.id,
                    changeDetailList: this.form.factory,
                    validTime: this.form.applyStartTime,
                    type: 1
                }).then(() => {
                    this.visible = false
                    this.$tip.apiSuccess('操作成功')
                    this.$emit('success')
                }).catch(e => {
                    this.$tip.apiFailed(e)
                }).finally(() => {
                    this.isWorking = false
                })
            },
            // 获取投保详情
            getDetails() {
@@ -252,14 +278,30 @@
                    })
                getDetail(this.form.id)
                    .then(res => {
                        console.log(res)
                        this.list.push(res)
                        this.endTime = res.endTime
                        this.form.solutionId = res.solutionId
                        this.newVersionSolutionId = res.newVersionSolutionId
                        this.form.solutionsName = res.solutionsName
                        this.pickerOptions = {
                            disabledDate(time) {
                                // - 8.64e7
                                return time.getTime() > new Date(res.endTime).getTime() || time.getTime() < new Date().getTime()
                                // 当前日期大于等于生效日期并且最后一次操作时间等于空
                                if ([1,3].includes(compareDates(getDate(), res.startTime)) && !res.lastChangeDate) {
                                    return time.getTime() > new Date(res.endTime).getTime() || time.getTime() < new Date(getTomorrow()).getTime()
                                    // 当前日期小于生效日期并且最后一次操作时间等于空
                                } else if (compareDates(getDate(), res.startTime) === 2 && !res.lastChangeDate) {
                                    return time.getTime() > new Date(res.endTime).getTime() || time.getTime() < new Date(res.startTime).getTime()
                                    // 最后一次操作时间有值
                                } else if (res.lastChangeDate) {
                                    // 当前日期大于最后一次操作时间
                                    if ([1,3].includes(compareDates(getDate(), res.lastChangeDate))) {
                                        return time.getTime() > new Date(res.endTime).getTime() || time.getTime() < new Date(getTomorrow()).getTime()
                                        // 当前时间小于最后一次操作时间
                                    } else if (compareDates(getDate(), res.lastChangeDate) === 2) {
                                        return time.getTime() > new Date(res.endTime).getTime() || time.getTime() < new Date(res.lastChangeDate).getTime()
                                    }
                                }
                            }
                        };
                        this.changeSolution1(res.solutionId)
@@ -291,28 +333,29 @@
                                return
                            }
                        }
                        this.form.factory.forEach(item => {
                            item.idcardNo = item.idCard
                        })
                        this.$refs.ApplyChangeUnitDetails1.open('更换派遣单位详单', this.form.factory, {...this.list[0], applyStartTime: this.form.applyStartTime})
                        // this.form.factory.forEach(item => {
                        //     item.idcardNo = item.idCard
                        // })
                        // let arr = JSON.parse(JSON.stringify(this.form.factory))
                        // arr.forEach(item => {
                        //     item.idcardNo = item.idCard
                        // })
                        this.isWorking = true
                        create({
                            applyId: this.form.id,
                            changeDetailList: this.form.factory,
                            validTime: this.form.applyStartTime,
                            type: 1
                        }).then(() => {
                            this.visible = false
                            this.$tip.apiSuccess('操作成功')
                            this.$emit('success')
                        }).catch(e => {
                            this.$tip.apiFailed(e)
                        }).finally(() => {
                            this.isWorking = false
                        })
                        // this.isWorking = true
                        // create({
                        //     applyId: this.form.id,
                        //     changeDetailList: this.form.factory,
                        //     validTime: this.form.applyStartTime,
                        //     type: 1
                        // }).then(() => {
                        //     this.visible = false
                        //     this.$tip.apiSuccess('操作成功')
                        //     this.$emit('success')
                        // }).catch(e => {
                        //     this.$tip.apiFailed(e)
                        // }).finally(() => {
                        //     this.isWorking = false
                        // })
                    }
                })
            },
@@ -321,7 +364,11 @@
                    this.$message.warning('请先选择保险方案')
                    return
                }
                this.$refs.selectEmployees.open('选取员工', { arr: this.form.delDetailList, price: this.price, insuranceApplyId: this.form.id })
                if (!this.form.applyStartTime) {
                    this.$message.warning('请先选择批单生效起期')
                    return
                }
                this.$refs.selectEmployees.open('选取员工', { arr: this.form.delDetailList, price: this.price, insuranceApplyId: this.form.id, validTime: this.form.applyStartTime })
            },
            addUser() {
                if (!this.form.solutionId) {
@@ -376,7 +423,7 @@
                    this.$message.warning('请选择员工')
                    return
                }
                this.$refs.confirmJobType.open('确认工种', { solutionId: this.form.solutionId })
                this.$refs.confirmJobType.open('确认工种', { solutionId: this.newVersionSolutionId })
            },
            // 查询全部方案
            getCompany() {
@@ -412,9 +459,36 @@
            handleSelectionChange (e) {
                this.seleData = e.map(item => item.memberName)
            },
            // 选取员工
            getValue1 (list) {
                let arr = JSON.parse(JSON.stringify(list))
                arr.forEach(item => {
                    item.oldDuId = item.duId
                    item.oldDuName = item.duName
                    item.oldWorkTypeName = item.workTypeName
                    item.oldWorktypeId = item.worktypeId
                    item.duId = ''
                    item.duName = ''
                    item.workTypeName = ''
                    item.worktypeId = ''
                })
                for (let a = 0; a < arr.length; a++) {
                    for (let b = 0; b < this.form.factory.length; b++) {
                        if (arr[a].id === this.form.factory[b].id) {
                            this.$message.warning(`${arr[a].companyName}员工重复!`)
                            return
                        }
                    }
                }
                this.form.factory.push(...arr)
            },
            getValue(list) {
                let arr = JSON.parse(JSON.stringify(list))
                arr.forEach(item => {
                    item.oldDuId = item.duId
                    item.oldDuName = item.duName