danbaoxinzeng.vue 9.26 KB
<template>
	<a-modal :title="title" :width="1200" :centered="true" :visible="visible" v-if="visible" :confirmLoading="confirmLoading"
		:okButtonProps="{ props: { disabled: disableSubmit } }" @cancel="handleCancel" cancelText="关闭" style="top:20px;"
		:maskClosable="false">
		<a-spin :spinning="confirmLoading">
			<a-form :form="form">
				<a-card title="担保类型" :bordered="false">
					<a-row :gutter="24">
						<a-col :span="12">
							<a-form-item label="借款订单编号" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
								<a-input placeholder="请输入借款订单编号" :readOnly="onlyread"
									v-decorator="['orderNo', { initialValue: modelList ? modelList.orderNo : '', rules: [{ required: true, message: '请输入企业名称' }] }]" />
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="客户类型" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
								<a-select placeholder="请选择" :disabled="onlyread"
									v-decorator="['customerType', { initialValue: modelList ? modelList.customerType : '', rules: [{ required: true, message: '请输入客户类型' }] }]">
									<a-select-option :value="1">个人</a-select-option>
									<a-select-option :value="2">企业</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
					</a-row>
					<a-row :gutter="24">
						<a-col :span="12">
							<a-form-item label="担保类别" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
								<a-select placeholder="请选择" @change="baoChange" :disabled="onlyread"
									v-decorator="['guaranteeType', { initialValue: modelList ? modelList.guaranteeType : '', rules: [{ required: true, message: '请输入担保类别' }] }]">
									<a-select-option :value="1">保险</a-select-option>
									<a-select-option :value="2">担保人</a-select-option>
									<a-select-option :value="3">抵/质押</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="担保名称" :labelCol="{ span: 8 }" :wrapperCol="{ span: 16 }">
								<a-input placeholder="请输入担保名称" :readOnly="onlyread && disableSubmit"
									v-decorator="['guaranteeName', { initialValue: modelList ? modelList.guaranteeName : '', rules: [{ required: true, message: '请输入企业名称' }] }]" />
							</a-form-item>
						</a-col>
					</a-row>
					<!-- <a-row :gutter="24" v-show="!disableSubmit" style="float:right;margin-right:20px;">
						<a-button style="margin-right:10px;" @click="handleCancel">取消</a-button>
						<a-button type="primary" @click="handleSubmit">确定</a-button>
					</a-row> -->
				</a-card>
			</a-form>
			<a-card title="担保内容" :bordered="false">
				<Baoxian v-if="bao == 1" ref="danMobile" @handleSubmit2="handleSubmit2" :model.sync="model" :modelList.sync="modelList"
					:typeBtn.sync="typeBtn" :disableSubmit.sync="disableSubmit"
					@load="load"></Baoxian>
				<Danbaoren v-if="bao == 2" ref="danMobile" @handleSubmit2="handleSubmit2" :model2.sync="model2" :modelList.sync="modelList"
					:typeBtn.sync="typeBtn" :disableSubmit.sync="disableSubmit"
					@load="load">
				</Danbaoren>
				<Zhiya v-if="bao == 3" ref="danMobile" @handleSubmit2="handleSubmit2" :model3.sync="model3" :modelList.sync="modelList"
					:typeBtn.sync="typeBtn" :disableSubmit.sync="disableSubmit"
					@load="load"></Zhiya>
			</a-card>
		</a-spin>
		<template slot="footer">
			<a-button @click="handleCancel">关闭</a-button>
			<a-button type="primary" v-show="!disableSubmit" @click="handleSubmit">确定</a-button>
		</template>
	</a-modal>
</template>

<script>
import { changPassword } from '@/api/api'
import { saveOrUpdateGuaranteeInfoMain, getGuaranteeInfoList } from '@/api/configApi'
import Baoxian from './baoxian.vue'
import Zhiya from './zhiya.vue';
import Danbaoren from './danbaoren.vue';
export default {
	name: "PasswordModal",
	components: { Baoxian, Zhiya, Danbaoren },
	data() {
		return {
			visible: false,
			confirmLoading: false,
			confirmDirty: false,
			title: "",
			typeBtn: "add",
			xinzeng: {},
			dbList: [],
			onlyread: false,
			disableSubmit: true,
			model: [],
			model2: [],
			model3: [],
			modelList: [],
			labelCol: {
				xs: { span: 24 },
				sm: { span: 5 }
			},
			wrapperCol: {
				xs: { span: 24 },
				sm: { span: 16 }
			},
			form: this.$form.createForm(this),
			id: "",
			bao: '1',
			recordOrderNo: "",
			guaranteeType: '',
			guarantee: '',
			order: '',
			ss: ''
		};
	},
	created() {
		console.log("created");
	},
	methods: {
		edit(username, id, orderNo, ca) {
			//   console.log(username)
			this.id = id
			this.recordOrderNo = orderNo
			this.guaranteeType = username.guaranteeInfoMainResponse.guaranteeType
			console.log(username)
			// alert(ca)
			if (ca == 1) {
				this.typeBtn = "edit";
			} else {
				this.typeBtn = "aa";
			}
			this.ss = "edit"
			this.form.resetFields();
			this.visible = true;
			let lis = username.guaranteeInfoFollowResponseList
			this.modelList = username.guaranteeInfoMainResponse
			this.model = lis.filter(item => item.guaranteeType == 1)
			this.model2 = lis.filter(item => item.guaranteeType == 2)
			this.model3 = lis.filter(item => item.guaranteeType == 3)
			this.bao = username.guaranteeInfoMainResponse.guaranteeType
			this.$nextTick(() => {
				this.form.setFieldsValue(username)
			})
		},
		add(username) {
			// alert("111111")
			this.typeBtn = "add";
			this.ss = "add"
			this.form.resetFields();
			this.onlyread = false
			this.bao = 1
			this.model = []
			this.model2 = []
			this.model3 = []
			this.modelList = []
			// this.$refs.danMobile.newTable = []
			this.visible = true;
			this.$nextTick(() => {
				this.form.setFieldsValue();
			});
		},
		onChange() { this.close(); },
		close() {
			this.$emit("close");
			this.visible = false;
			this.disableSubmit = false;
			this.selectedRole = [];
		},
		handleSubmit() {
			// 触发表单验证
			this.form.validateFields((err, values) => {
				console.log(err, values);
				if (!err) {
					this.confirmLoading = true;
					if (this.ss == "add") {
						var li = {
							guaranteeFollowListRequest: this.$refs.danMobile.newTable,
							guaranteeInfoMain: {
								orderNo: values.orderNo,
								customerType: values.customerType,
								guaranteeType: values.guaranteeType,
								guaranteeName: values.guaranteeName,
							}
						}
					} else if (this.ss == "edit") {
						var li = {
							guaranteeInfoMain: {
								orderNo: values.orderNo,
								customerType: values.customerType,
								guaranteeType: values.guaranteeType,
								guaranteeName: values.guaranteeName,
								id: this.id
							}
						}
					}
					let formData = Object.assign(li);
					this.confirmLoading = false;
					// let formData = values
					saveOrUpdateGuaranteeInfoMain(formData)
						.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();
						});
				}
			});
		},
		handleSubmit2() {
			// 触发表单验证
			this.form.validateFields((err, values) => {
				if (!err) {
					// this.confirmLoading = true;
					let l = { id: this.id };
					let b = { flag: 2 }
					this.order = values.orderNo
					this.guarantee = values.guaranteeType
					var formData = Object.assign(values, l, b);
					this.$refs.danMobile.add(formData)
					this.confirmLoading = false;
					// this.close();
					// let formData = values
					// saveOrUpdateGuaranteeInfoMain(formData)
					// 	.then(res => {
					// 		if (res.status.statusCode == 0) {
					// 			// this.$message.success(res.status.statusReason);
					// 			this.$emit("ok");
					// 			this.$refs.danMobile.add(formData)
					// 		}
					// 		else {
					// 			this.$message.warning(res.status.statusReason);
					// 		}
					// 	})
					// 	.finally(() => {
					// 		this.confirmLoading = false;
					// 		// this.close();
					// 	});
				}
			});
		},
		baoChange(value) {
			this.bao = value
		},
		success() {
			this.form.validateFields((err, values) => {
				this.dbList = values
				//alert(values)
			});
		},
		load() {
			var _p = { orderNo: this.recordOrderNo, guaranteeType: this.guaranteeType }
			getGuaranteeInfoList(_p).then(res => {
				if (res.status.statusCode == 0) {
					let lis = res.result.guaranteeInfoFollowResponseList
					this.modelList = res.result.guaranteeInfoMainResponse
					if (this.guaranteeType == 1) {
						this.model = lis.filter(item => item.guaranteeType == 1)
						this.$refs.danMobile.newTable = lis.filter(item => item.guaranteeType == 1)
					} else if (this.guaranteeType == 2) {
						this.model2 = lis.filter(item => item.guaranteeType == 2)
						this.$refs.danMobile.newTable = lis.filter(item => item.guaranteeType == 2)
					} else if (this.guaranteeType == 3) {
						this.model3 = lis.filter(item => item.guaranteeType == 3)
						this.$refs.danMobile.newTable = lis.filter(item => item.guaranteeType == 3)
					}
					this.bao = res.result.guaranteeInfoMainResponse.guaranteeType
					this.$nextTick(() => {
						this.form.setFieldsValue(res.result)
					})
				} else {
					this.$message.warning(res.status.statusReason)
				}
			})
		},
		tableUp(res) {

		},
		handleCancel() {
			this.close();
		}
	},
}
</script>