MrShi
2025-05-26 f0c249c2fcdb016b7313655e135c74620b5097a8
company/src/components/business/adjustment.vue
@@ -2,13 +2,13 @@
    <GlobalWindow
        :title="title"
        width="100%"
        :text="`${type === 1 ? '完成理算' : '完成核赔'}`"
        :text="`${title === '修改金额' ? '提交' : type === 1 ? '完成理算' : '完成核赔'}`"
        :visible.sync="visible"
        :confirm-working="isWorking"
        @confirm="confirm"
    >
        <div class="box">
            <el-form :model="form" ref="ruleForm" label-width="150px" class="demo-ruleForm">
            <el-form :model="form" ref="form" :rules="rules" label-width="150px" class="demo-ruleForm">
                <div class="box_item">
                    <div class="box_item_desc">主要赔付项</div>
                    <div class="box_item_list">
@@ -37,6 +37,9 @@
                        <span>¥{{totalPrice}}</span>
                    </div>
                </div>
                <el-form-item label="修改说明" prop="describe" v-if="title === '修改金额'">
                    <el-input v-model="form.describe" placeholder="请输入" type="textarea" row="5"></el-input>
                </el-form-item>
            </el-form>
        </div>
    </GlobalWindow>
@@ -45,7 +48,7 @@
<script>
    import BaseOpera from '@/components/base/BaseOpera'
    import GlobalWindow from '@/components/common/GlobalWindow'
    import { compensation, getCompensation, nuclearCompensation } from '@/api/business/settleRisk'
    import { compensation, getCompensation, nuclearCompensation, updFee } from '@/api/business/settleRisk'
    export default {
        name: 'acceptance',
        extends: BaseOpera,
@@ -53,7 +56,13 @@
        data () {
            return {
                form: {
                    id: null
                    id: null,
                    describe: ''
                },
                rules: {
                    describe: [
                        { required: true, message: '修改说明不能为空', trigger: 'blur' }
                    ]
                },
                type: '',
                list1: [],
@@ -66,6 +75,9 @@
                this.type = type
                this.title = title
                this.form.id = id
                this.$nextTick(() => {
                    this.$refs.form.resetFields();
                })
                getCompensation({ type, id: this.form.id })
                    .then(res => {
                        res.forEach(item => {
@@ -90,42 +102,60 @@
                this.totalPrice = price
            },
            confirm() {
                let arr = [...this.list1, ...this.list2]
                for (let i = 0; i < arr.length; i++) {
                    if (!arr[i].fee && arr[i].fee !== 0) {
                        return this.$message.warning(`请先完善${arr[i].name}金额`)
                this.$refs.form.validate((valid) => {
                    if (valid) {
                        let arr = [...this.list1, ...this.list2]
                        for (let i = 0; i < arr.length; i++) {
                            if (!arr[i].fee && arr[i].fee !== 0) {
                                return this.$message.warning(`请先完善${arr[i].name}金额`)
                            }
                        }
                        this.isWorking = true
                        let compensationJson = JSON.stringify(arr)
                        if (this.title === '修改金额') {
                            updFee({ id: this.form.id, compensationJson, describe: this.form.describe })
                                .then(() => {
                                    this.visible = false
                                    this.$tip.apiSuccess('操作成功')
                                    this.$emit('success')
                                })
                                .catch(e => {
                                    this.$tip.apiFailed(e)
                                })
                                .finally(() => {
                                    this.isWorking = false
                                })
                            return
                        }
                        if (this.type === 1) {
                            compensation({ id: this.form.id, compensationJson })
                                .then(() => {
                                    this.visible = false
                                    this.$tip.apiSuccess('操作成功')
                                    this.$emit('success')
                                })
                                .catch(e => {
                                    this.$tip.apiFailed(e)
                                })
                                .finally(() => {
                                    this.isWorking = false
                                })
                        } else if (this.type === 2) {
                            nuclearCompensation({ id: this.form.id, compensationJson })
                                .then(() => {
                                    this.visible = false
                                    this.$tip.apiSuccess('操作成功')
                                    this.$emit('success')
                                })
                                .catch(e => {
                                    this.$tip.apiFailed(e)
                                })
                                .finally(() => {
                                    this.isWorking = false
                                })
                        }
                    }
                }
                this.isWorking = true
                let compensationJson = JSON.stringify(arr)
                if (this.type === 1) {
                    compensation({ id: this.form.id, compensationJson })
                        .then(() => {
                            this.visible = false
                            this.$tip.apiSuccess('操作成功')
                            this.$emit('success')
                        })
                        .catch(e => {
                            this.$tip.apiFailed(e)
                        })
                        .finally(() => {
                            this.isWorking = false
                        })
                } else if (this.type === 2) {
                    nuclearCompensation({ id: this.form.id, compensationJson })
                        .then(() => {
                            this.visible = false
                            this.$tip.apiSuccess('操作成功')
                            this.$emit('success')
                        })
                        .catch(e => {
                            this.$tip.apiFailed(e)
                        })
                        .finally(() => {
                            this.isWorking = false
                        })
                }
                });
            }
        }
    }