approval.vue 11.4 KB
<template>
    <div class="maincontent">
        <a-modal title="创建方式" destroyOnClose :width="450" v-model="visible" :confirmLoading="confirmLoading"
            @cancel="handleCancel" :zIndex="10000" :footer="null">
            <div>
                <div class="labelClass">是否将当前项加入到项目中??</div>
                <div class="buttonClass">
                    <a-button @click="subcommitCreate" type="primary" class="yesButton">是</a-button>
                    <a-button @click="subcommitNullCreate" class="noButton">否</a-button>
                </div>
            </div>
        </a-modal>
    </div>
</template>
<script>
import { preProductGetData, postAction, saveProduct, updateProduct, getFundProductSelect } from '@/api/configApi'
export default {
    name: 'approval',
    data() {
        return {
            visible: false,
            confirmLoading: false,
            confirmDirty: false,
            title: '',
            shoping: [],
            isLimitType: 1,
            validatorRules: {
                productNo: {
                    rules: [
                        {
                            required: true,
                            message: '请输入产品编号'
                        }
                    ]
                },
                businessChannelNos: {
                    rules: [
                        {
                            required: true,
                            message: '请选择业务渠道'
                        }
                    ]
                },

                productName: {
                    rules: [
                        {
                            required: true,
                            message: '请输入产品名称'
                        }
                    ]
                },
                billOut: {
                    rules: [
                        {
                            required: true,
                            message: '请选择是否出账单'
                        }
                    ]
                },
                minInterestDay: {
                    rules: [
                        {
                            required: true,
                            message: '请填写最小计息天数'
                        }
                    ]
                },
                interestRate: {
                    rules: [
                        {
                            required: true,
                            message: '请填写产品正常利率'
                        }
                    ]
                },
                contractAuthorizationNos: {
                    rules: [
                        {
                            required: true,
                            message: '请选择授信协议类合同'
                        }
                    ]
                },
                contractCreditNos: {
                    rules: [
                        {
                            required: true,
                            message: '请选择用信协议类合同'
                        }
                    ]
                },
                fundInterestRate: {
                    rules: [
                        {
                            required: true,
                            message: '请填写资金方利率'
                        }
                    ]
                },
                fundPenaltyRate: {
                    rules: [
                        {
                            required: true,
                            message: '请填写资金方罚息利率'
                        }
                    ]
                },
                fundCompoundRate: {
                    rules: [
                        {
                            required: true,
                            message: '请填写资金方复利率'
                        }
                    ]
                },
                fundNo: {
                    rules: [
                        {
                            required: true,
                            message: '请选择资金方'
                        }
                    ]
                },
                charges: {
                    rules: [
                        {
                            required: true,
                            message: '请选择产品费用'
                        }
                    ]
                },
                penaltyRate: {
                    rules: [
                        {
                            required: true,
                            message: '请填写产品罚息利率'
                        }
                    ]
                },
                buybackFlag: {
                    rules: [
                        {
                            required: true,
                            message: '请选择回购标示'
                        }
                    ]
                },
                repaymentTemplateNo: {
                    rules: [
                        {
                            required: true,
                            message: '请选择还款模板'
                        }
                    ]
                },
                type: {
                    rules: [
                        {
                            required: true,
                            message: '请选择产品分类'
                        }
                    ]
                },
                userType: {
                    rules: [
                        {
                            required: true,
                            message: '请选择客户类型'
                        }
                    ]
                },
                limitMoneyFlag: {
                    rules: [
                        {
                            required: true,
                            message: '请选择是否有放款限额'
                        }
                    ]
                },
                term: {
                    rules: [
                        {
                            required: true,
                            message: '请输入账单期限'
                        }
                    ]
                },
                repaymentType: {
                    rules: [
                        {
                            required: true,
                            message: '请选择还款方式'
                        }
                    ]
                },
                confirmpassword: {
                    rules: [
                        {
                            required: true,
                            message: '请重新输入登陆密码!'
                        },
                        {
                            validator: this.compareToFirstPassword
                        }
                    ]
                }
            },

            model: {},

            labelCol: {
                xs: { span: 8 },
                sm: { span: 4 }
            },
            wrapperCol: {
                xs: { span: 8 },
                sm: { span: 12 }
            },
            chargeList: [],
            fundList: [],
            contractTemplateList: [],
            businessChannelList: [],
            repaymentTemplateList: [],
            isLimitClassity: 1,
            isLimitBuyBack: 1,
            form: this.$form.createForm(this)
        }
    },
    created() {
        this.initData();
        this.businessChannelData();
    },

    methods: {
        handleChangeBuyback(value) {
            this.isLimitBuyBack = value.target.value
        },
        handleChangeClassity(value) {
            this.isLimitClassity = value.target.value
        },
        handleChange(value) {
            this.isLimitType = value.target.value
        },
        initData() {
            console.log("ssssss")
            preProductGetData().then(res => {
                this.chargeList = res.result.chargeList;
                this.fundList = res.result.fundList;
                this.contractTemplateList = res.result.contractTemplateList;
                this.repaymentTemplateList = res.result.repaymentTemplateList
            })
        },
        businessChannelData() { //业务渠道
            let _p = {
                pageNo: 1,
                pageSize: 10000,
                params: {}
            }
            postAction('/config/admin/queryBusinessChannelList', _p).then(res => {
                this.businessChannelList = res.result.records.filter(item => item.status == 1)
            })
        },

        edit(record) {
            this.model = record;
            this.isLimitClassity = record.termType
            this.isLimitType = record.limitMoneyFlag
            console.log(this.isLimitType)
            this.form.resetFields();
            this.visible = true;
            this.$nextTick(() => {
                this.form.setFieldsValue(record);
            });
        },

        add(e) {
            e.stopPropagation()
            this.visible = true
            //   this.model = {};
            //   this.form.resetFields();
            //   this.visible = true;
            //   this.$nextTick(() => {
            //     this.form.setFieldsValue();
            //   });
        },
        shop(value) {
            // console.log(value)
            getFundProductSelect({ fundNo: value }).then(res => {
                if (res.status.statusCode == 0) {
                    this.shoping = res.result
                } else {

                }
            })
        },

        close() {
            this.$emit('close');
            this.visible = false;
            this.disableSubmit = false;
            this.selectedRole = [];
        },
        handleSubmit() {
            // 触发表单验证
            this.form.validateFields((err, values) => {
                if (!err) {
                    this.confirmLoading = true;
                    let formData = values, promiseFn, arr = [];
                    for (let i = 0; i < this.chargeList.length; i++) {
                        for (let j = 0; j < formData.charges.length; j++) {
                            if (formData.charges[j] == this.chargeList[i].chargeNo) {
                                let obj = {
                                    chargeNo: this.chargeList[i].chargeNo,
                                    chargeVersion: this.chargeList[i].chargeVersion
                                }
                                arr.push(obj)
                            }
                        }
                    }
                    formData.charges = arr
                    formData.productVersion = this.model.productVersion
                    if (!!this.model.id) { //编辑
                        promiseFn = updateProduct(formData);
                    } else {
                        promiseFn = saveProduct(formData)
                    }
                    promiseFn.then((res) => {
                        if (res.status.statusCode == 0) {
                            this.$message.success(res.status.statusReason);
                            this.$emit('ok');
                        } else {
                            this.$message.warning(res.status.statusReason);
                        }
                    }).finally(() => {
                        this.confirmLoading = false;
                        this.close();
                    });
                }
            })
        },
        handleCancel() {
            this.close()
        }
    }
}
</script>