<template>
|
<div class="credit_query_main">
|
<el-row v-if="!isView" class="add-button">
|
<el-col :span="24">
|
<el-button
|
type="primary"
|
size="small"
|
icon="el-icon-circle-plus-outline"
|
@click="handleAddPage"
|
class="add-btn"
|
>新增配置</el-button
|
>
|
</el-col>
|
</el-row>
|
<ProTable
|
:pageInfo="pageInfo"
|
@doAction="doAction"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"
|
:noHistory="noHistory"
|
:isAutoIndex="true"
|
:list="list"
|
:header="tableHeader"
|
:loading="loading"
|
/>
|
<el-dialog
|
:title="dialogTitle"
|
:visible.sync="dialogVisible"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
width="1000"
|
center
|
custom-class="pricing_dialog"
|
>
|
<CreateForms
|
ref="credit"
|
v-if="dialogVisible"
|
:isShowOld="showOld"
|
:oldVal="oldVal"
|
:isView="isView"
|
:isShowBorder="isShowBorder"
|
:screenWidth="screenWidth"
|
:formItems="formItems"
|
:defValues="defValues"
|
:formRules="formRules"
|
@handleSelOnChange="handleSelOnChange"
|
/>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="dialogVisible = false">{{
|
isView ? "关 闭" : "取 消"
|
}}</el-button>
|
<el-button type="primary" v-if="!isView" @click="saveCreditQueryConfig"
|
>确 定</el-button
|
>
|
</span>
|
</el-dialog>
|
<el-dialog
|
title="征信查询配置删除确认"
|
:visible.sync="dialogDelVisible"
|
width="1000"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
center
|
custom-class="pricing_dialog del_dialog"
|
>
|
<div style="text-align: justify;">{{ tipContent }}</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="dialogDelVisible = false">取 消</el-button>
|
<el-button type="primary" @click="deleteCreditQueryConfig"
|
>确 定</el-button
|
>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import { CREDITQUERYSETTINGCOLUMN } from "./config/tableConfig.js";
|
import {
|
qryCreditQueryConfigList,
|
addOrUpdateCreditQueryConfig,
|
qryCreditQueryConfigDetail,
|
delCreditQueryConfig
|
} from "../../../../api/productManage.api";
|
import { DIMENSIONENUM } from "../../../../utils/optionsQueryConfig.js";
|
import ProTable from "../../../../components/ProTable.vue";
|
import CreateForms from "../../../../components/CreateForms.vue";
|
import { CREDITQUERYSETTINGFORMS } from "../../../../utils/formsConfig.js";
|
import { CREDITQUERYSETTINGDEFVALUE } from "../../../../utils/defValueConfig.js";
|
import { CREDITQUERYSETTINGRULES } from "../../../../utils/formRulesConfig.js";
|
export default {
|
props: {
|
edit: {
|
type: Boolean,
|
default: () => {
|
return false;
|
}
|
},
|
isView: {
|
type: Boolean,
|
default: () => {
|
return false;
|
}
|
},
|
isShowBorder: {
|
type: Boolean,
|
default: () => {
|
return true;
|
}
|
},
|
options: {
|
type: Object,
|
default: () => {
|
return {};
|
}
|
},
|
noHistory: {
|
type: Boolean,
|
default: () => {
|
return false;
|
}
|
}
|
},
|
components: {
|
ProTable,
|
CreateForms
|
},
|
mounted() {
|
this.initColumns();
|
(this.isView || this.edit) && this.getCreditQueryConfigList();
|
},
|
watch: {
|
options: {
|
handler(val, oldVal) {
|
this.optionsData = val;
|
this.getOptionItems(val);
|
},
|
deep: true
|
}
|
},
|
methods: {
|
// 处理变更标志显示
|
initColumns() {
|
const { objecttype } = this.$parent._data;
|
const { tableHeader, noHistory } = this;
|
const isModify = objecttype === "jbo.app.BUSINESS_TYPE_CHANGE";
|
const newTableHeader =
|
isModify && !noHistory
|
? tableHeader
|
: tableHeader.filter(col => col.prop !== "changeflag");
|
this.$set(this, "tableHeader", newTableHeader);
|
},
|
async doAction(name, item, { key, label }) {
|
if (key === "edit") {
|
this.dialogTitle = "征信查询配置修改";
|
this.serialno = item.serialno;
|
this.dialogVisible = true;
|
const infos = await this.getCreditQueryConfigDetail(item.serialno);
|
let editData = {};
|
let visibleArry = [];
|
Object.getOwnPropertyNames(infos).forEach(key => {
|
editData[key] = infos[key].value;
|
if (infos[key].visible) {
|
visibleArry.push(key);
|
}
|
});
|
const newEditFormItems = [...this.formItems].map(items => {
|
const newItem = { ...items };
|
newItem.show = visibleArry.includes(newItem.name);
|
if (
|
newItem.name === "mindcreditterm" ||
|
newItem.name === "maxdcreditterm"
|
) {
|
newItem.show = editData.termunit === "D";
|
}
|
if (
|
newItem.name === "minmcreditterm" ||
|
newItem.name === "maxmcreditterm"
|
) {
|
newItem.show = editData.termunit === "M";
|
}
|
return newItem;
|
});
|
this.formItems = newEditFormItems;
|
setTimeout(() => {
|
this.defValues = { ...editData };
|
}, 0);
|
}
|
if (key === "details") {
|
this.dialogTitle = "征信查询配置详情";
|
this.serialno = item.serialno;
|
this.dialogVisible = true;
|
const infos = await this.getCreditQueryConfigDetail(item.serialno);
|
let editData = {};
|
let visibleArry = [];
|
let oldValue = {};
|
Object.getOwnPropertyNames(infos).forEach(key => {
|
editData[key] = infos[key].value;
|
oldValue[key] = infos[key].oldValue;
|
if (infos[key].visible) {
|
visibleArry.push(key);
|
}
|
});
|
setTimeout(() => {
|
const newFormItems = [...this.formItems].map(items => {
|
const newForms = { ...items };
|
newForms.placeholder = "";
|
newForms.readonly = true;
|
newForms.show = visibleArry.includes(newForms.name);
|
return newForms;
|
});
|
this.formItems = newFormItems;
|
this.defValues = { ...editData };
|
this.oldVal = oldValue;
|
}, 0);
|
}
|
if (key === "delete") {
|
this.serialno = item.serialno;
|
this.tipContent = `请确认是否需要删除征信查询配置
|
(最低贷款期限:${item.mincreditterm},最高贷款期限:${item.maxcreditterm},还款方式:${item.paymenttype},
|
最低申请金额:${item.minapplyquota},最高申请金额:${item.maxapplyquota})`;
|
this.dialogDelVisible = true;
|
}
|
},
|
// 获取下拉选择项
|
getOptionItems(optionsMap) {
|
const { formItems } = this;
|
formItems.forEach(item => {
|
if (item.type === "select") {
|
item.options = optionsMap[DIMENSIONENUM[item.name]];
|
}
|
});
|
},
|
// 获取征信查询配置列表
|
async getCreditQueryConfigList() {
|
const { currentPage, pageSize } = this.pageInfo;
|
const { dimensionno, objectno, productid } = this.$parent._data;
|
const params = {
|
currentPage,
|
dimensionno,
|
objectno,
|
pageSize,
|
productid
|
};
|
const listRes = await qryCreditQueryConfigList(params);
|
if (!listRes || listRes.code !== "00") {
|
return;
|
}
|
const list =
|
listRes.result &&
|
listRes.result.records.map(item => {
|
const newitem = { ...item };
|
newitem.operationOption = this.isView
|
? [{ key: "details", label: "详情", value: true }]
|
: [
|
{ key: "edit", label: "修改", value: true },
|
{ key: "delete", label: "删除", value: true }
|
];
|
return newitem;
|
});
|
this.$set(this, "list", list);
|
this.pageInfo.total = listRes.result.total;
|
},
|
// 下拉选择事件处理
|
handleSelOnChange(formName, value) {
|
let newFormItems = [...this.formItems];
|
if (formName === "termunit") {
|
newFormItems.forEach(form => {
|
if (
|
form.name === "mindcreditterm" ||
|
form.name === "maxdcreditterm"
|
) {
|
form.show = value === "D";
|
}
|
if (
|
form.name === "minmcreditterm" ||
|
form.name === "maxmcreditterm"
|
) {
|
form.show = value === "M";
|
}
|
});
|
}
|
this.formItems = newFormItems;
|
},
|
// 重置表单配置项
|
setFormsItemConfig() {
|
const { showData } = this.$parent._data;
|
const newFormItems = [...this.formItems].map(form => {
|
const newForm = { ...form };
|
if (
|
newForm.name === "minmcreditterm" ||
|
newForm.name === "maxmcreditterm"
|
) {
|
newForm.show = showData.attribute3 === "M";
|
}
|
if (
|
newForm.name === "mindcreditterm" ||
|
newForm.name === "maxdcreditterm"
|
) {
|
newForm.show = showData.attribute3 === "D";
|
}
|
return newForm;
|
});
|
this.formItems = newFormItems;
|
},
|
// 新增
|
handleAddPage() {
|
this.formItems = [...CREDITQUERYSETTINGFORMS];
|
this.defValues = {
|
...CREDITQUERYSETTINGDEFVALUE
|
};
|
this.formRules = {
|
...CREDITQUERYSETTINGRULES(!this.isView)
|
};
|
this.tipContent = "";
|
this.dialogTitle = "征信查询配置新增";
|
this.screenWidth = 1000;
|
this.loading = false;
|
this.serialno = "";
|
this.isValidate = false;
|
this.setFormsItemConfig();
|
this.dialogVisible = true;
|
},
|
// 校验基本信息
|
validateForms() {
|
const creditForm = this.$refs.credit;
|
creditForm.$refs["createForm"].validate(async valid => {
|
if (valid) {
|
this.isValidate = true;
|
} else {
|
this.isValidate = false;
|
this.$message.error("请完必填项!");
|
return false;
|
}
|
});
|
},
|
// 获取显示表单对应的value值
|
getFormItemsValue(forms, values, defvalue) {
|
let newDfvalue = {};
|
Object.getOwnPropertyNames(defvalue).forEach(key => {
|
newDfvalue[key] = "";
|
});
|
const showForms = forms.filter(form => form && form.show !== false);
|
let formsValue = {};
|
showForms.forEach(form => {
|
formsValue[form.name] = values[form.name];
|
});
|
return { ...newDfvalue, ...formsValue };
|
},
|
// 保存征信查询配置新增
|
async saveCreditQueryConfig() {
|
await this.validateForms();
|
const { isValidate } = this;
|
if (!isValidate) {
|
return false;
|
}
|
const creditForm = this.$refs.credit;
|
const { dimensionno, objectno, productid } = this.$parent._data;
|
const params = {
|
...this.getFormItemsValue(
|
creditForm.formItems,
|
creditForm.formValues,
|
CREDITQUERYSETTINGDEFVALUE
|
),
|
dimensionno,
|
objectno,
|
serialno: this.serialno,
|
productid
|
};
|
const res = await addOrUpdateCreditQueryConfig(params);
|
if (!res || res.code !== "00") {
|
return false;
|
}
|
this.$message({
|
message: "保存成功!",
|
type: "success"
|
});
|
this.getCreditQueryConfigList();
|
this.dialogVisible = false;
|
},
|
// 查询征信查询配置信息
|
async getCreditQueryConfigDetail(serialno) {
|
const {
|
dimensionno,
|
objectno,
|
productid,
|
objecttype
|
} = this.$parent._data;
|
const params = {
|
dimensionno,
|
objectno,
|
productid,
|
serialno,
|
showoldvalue: objecttype === "jbo.app.BUSINESS_TYPE_CHANGE"
|
};
|
const detailRes = await qryCreditQueryConfigDetail(params);
|
if (!detailRes || detailRes.code !== "00") {
|
return;
|
}
|
return detailRes.result;
|
},
|
// 删除征信查询配置信息
|
async deleteCreditQueryConfig() {
|
const deleteRes = await delCreditQueryConfig({ serialno: this.serialno });
|
if (!deleteRes || deleteRes.code !== "00") {
|
return;
|
}
|
this.dialogDelVisible = false;
|
this.$message.success("删除成功");
|
this.getCreditQueryConfigList();
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val;
|
this.getCreditQueryConfigList();
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val;
|
this.getCreditQueryConfigList();
|
}
|
},
|
data() {
|
return {
|
list: [],
|
tableHeader: [...CREDITQUERYSETTINGCOLUMN],
|
formItems: [...CREDITQUERYSETTINGFORMS],
|
defValues: {
|
...CREDITQUERYSETTINGDEFVALUE
|
},
|
formRules: {
|
...CREDITQUERYSETTINGRULES(!this.isView)
|
},
|
tipContent: "",
|
dialogTitle: "征信查询配置新增",
|
screenWidth: 1000,
|
showOld:
|
this.$parent._data.objecttype === "jbo.app.BUSINESS_TYPE_CHANGE" &&
|
this.isView,
|
oldVal: {},
|
loading: false,
|
serialno: "",
|
isValidate: false,
|
optionsData: { ...this.options },
|
dialogVisible: false,
|
dialogDelVisible: false,
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0
|
}
|
};
|
}
|
};
|
</script>
|
<style lang="stylus" scoped>
|
.credit_query_main {
|
padding: 20px 0 0 20px;
|
& .add-button {
|
padding: 10px 0 30px 0;
|
}
|
& >>> .pricing_dialog {
|
width: 1000px;
|
& .el-dialog__body {
|
& .form_main {
|
& .el-form {
|
& .el-form-item {
|
& .el-form-item__label {
|
line-height: 32px;
|
}
|
}
|
}
|
}
|
}
|
& .el-dialog__footer {
|
& .dialog-footer {
|
& .el-button--default {
|
width: 120px;
|
height: 30px;
|
line-height: 7px;
|
border-radius: 4px;
|
border: 1px solid rgba(204, 204, 204, 1);
|
}
|
& .el-button--primary {
|
width: 120px;
|
height: 30px;
|
line-height: 7px;
|
background: #0081f0;
|
border-color: #0081f0;
|
border-radius: 4px;
|
margin-left: 40px;
|
}
|
}
|
}
|
}
|
& >>> .del_dialog {
|
width: 500px !important;
|
}
|
}
|
</style>
|