<template>
|
<div class="discount_plan_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="discountList"
|
:header="tableHeader"
|
:loading="loading"
|
/>
|
<el-dialog
|
:title="dialogTitle"
|
v-loading="dLoading"
|
element-loading-text="拼命加载中"
|
element-loading-spinner="el-icon-loading"
|
element-loading-background="rgba(0, 0, 0, 0.8)"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
:visible.sync="dialogVisible"
|
width="1000"
|
center
|
custom-class="pricing_dialog"
|
>
|
<CreateForms
|
ref="discount"
|
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="saveDiscountConfiguration"
|
>确 定</el-button
|
>
|
</span>
|
</el-dialog>
|
<el-dialog
|
title="贴息方案配置删除确认"
|
:visible.sync="dialogDelVisible"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
width="1000"
|
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="deleteDiscountConfiguration"
|
>确 定</el-button
|
>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import { DISCOUNTPLANSETTINGCOLUMN } from './config/tableConfig.js';
|
import {
|
addOrUpdateDiscountConfiguration,
|
qryDiscountConfigurationList,
|
delDiscountConfiguration,
|
qryDiscountConfigurationDetail
|
} from '../../../../api/productManage.api';
|
import { DIMENSIONENUM } from '../../../../utils/optionsQueryConfig.js';
|
import ProTable from '../../../../components/ProTable.vue';
|
import CreateForms from '../../../../components/CreateForms.vue';
|
import { DISCOUNTPLANSETTINGFORMS } from '../../../../utils/formsConfig.js';
|
import { DISCOUNTPLANSETTINGDEFVALUE } from '../../../../utils/defValueConfig.js';
|
import { DISCOUNTPLANSETTINGRULES } from '../../../../utils/formRulesConfig.js';
|
export default {
|
props: {
|
edit: {
|
type: Boolean,
|
default: () => {
|
return false
|
}
|
},
|
isView: {
|
type: Boolean,
|
default: () => {
|
return false
|
}
|
},
|
noHistory: {
|
type: Boolean,
|
default: () => {
|
return false
|
}
|
},
|
isShowBorder: {
|
type: Boolean,
|
default: () => {
|
return true
|
}
|
},
|
options: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
}
|
},
|
components: {
|
ProTable,
|
CreateForms
|
},
|
mounted() {
|
this.initColumns();
|
(this.isView || this.edit) && this.getDiscountConfigurationList()
|
},
|
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.getDiscountConfigurationDetail(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)
|
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.getDiscountConfigurationDetail(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})`
|
this.dialogDelVisible = true
|
}
|
},
|
// 获取下拉选择项
|
getOptionItems(optionsMap) {
|
const { formItems } = this
|
formItems.forEach(item => {
|
if (item.type === 'select') {
|
item.options = optionsMap[DIMENSIONENUM[item.name]]
|
}
|
})
|
},
|
// 获取贴息方案列表
|
async getDiscountConfigurationList() {
|
const { currentPage, pageSize } = this.pageInfo
|
const { dimensionno, objectno, productid } = this.$parent._data
|
const params = {
|
currentPage,
|
dimensionno,
|
objectno,
|
pageSize,
|
productid
|
}
|
const listRes = await qryDiscountConfigurationList(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, 'discountList', list)
|
this.pageInfo.total = listRes.result.total
|
},
|
// 查询贴息方案配置详情
|
async getDiscountConfigurationDetail(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 qryDiscountConfigurationDetail(params)
|
if (!detailRes || detailRes.code !== '00') {
|
return
|
}
|
return detailRes.result
|
},
|
// 删除贴息方案配置
|
async deleteDiscountConfiguration() {
|
const deleteRes = await delDiscountConfiguration({
|
serialno: this.serialno
|
})
|
if (!deleteRes || deleteRes.code !== '00') {
|
return
|
}
|
this.dialogDelVisible = false
|
this.$message.success('删除成功')
|
this.getDiscountConfigurationList()
|
},
|
// 下拉选择事件处理
|
handleSelOnChange(formName, value) {
|
let newFormItems = [...this.formItems]
|
if (formName === 'isallpostedinterest') {
|
newFormItems.forEach(form => {
|
if (form.name === 'discountterm') {
|
form.show = value === '4';
|
}
|
if (form.name === 'discountrate') {
|
form.show = value === '2' || value === '4';
|
}
|
if (form.name === 'discountsum') {
|
form.show = value === '3';
|
}
|
})
|
}
|
if (formName === 'isallpostedpoundage') {
|
newFormItems.forEach(form => {
|
if (form.name === 'poundagerate') {
|
form.show = value === '2';
|
}
|
if (form.name === 'poundagesum') {
|
form.show = value === '3';
|
}
|
})
|
}
|
if (formName === 'isallpostedservice') {
|
newFormItems.forEach(form => {
|
if (form.name === 'servicerate') {
|
form.show = value === '2';
|
}
|
if (form.name === 'servicesum') {
|
form.show = value === '3';
|
}
|
})
|
}
|
if (formName === 'isallpostedguaranty') {
|
newFormItems.forEach(form => {
|
if (form.name === 'guarantyrate') {
|
form.show = value === '2';
|
}
|
if (form.name === 'guarantysum') {
|
form.show = value === '3';
|
}
|
})
|
}
|
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.dLoading = false
|
this.formItems = [...DISCOUNTPLANSETTINGFORMS]
|
this.defValues = {
|
...DISCOUNTPLANSETTINGDEFVALUE
|
}
|
this.formRules = {
|
...DISCOUNTPLANSETTINGRULES(!this.isView)
|
}
|
this.dialogTitle = '贴息方案配置新增';
|
this.tipContent = '';
|
this.serialno = '';
|
this.screenWidth = 1000
|
this.loading = false
|
this.dialogDelVisible = false
|
this.setFormsItemConfig()
|
this.dialogVisible = true
|
},
|
// 校验基本信息
|
validateForms() {
|
const discountForm = this.$refs.discount
|
discountForm.$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.show !== false)
|
let formsValue = {}
|
showForms.forEach(form => {
|
formsValue[form.name] = values[form.name]
|
})
|
return { ...newDfvalue, ...formsValue }
|
},
|
// 保存贴息方案配置新增
|
async saveDiscountConfiguration() {
|
await this.validateForms()
|
const { isValidate } = this
|
if (!isValidate) {
|
return false
|
}
|
const discountForm = this.$refs.discount
|
const { dimensionno, objectno, productid } = this.$parent._data
|
const params = {
|
...this.getFormItemsValue(
|
discountForm.formItems,
|
discountForm.formValues,
|
DISCOUNTPLANSETTINGDEFVALUE
|
),
|
dimensionno,
|
objectno,
|
productid,
|
serialno: this.serialno
|
}
|
const res = await addOrUpdateDiscountConfiguration(params)
|
if (!res || res.code !== '00') {
|
return false
|
}
|
this.$message({
|
message: '保存成功!',
|
type: 'success'
|
})
|
this.getDiscountConfigurationList()
|
this.dialogVisible = false
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val
|
this.getDiscountConfigurationList()
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val
|
this.getDiscountConfigurationList()
|
}
|
},
|
data() {
|
return {
|
discountList: [],
|
tableHeader: [...DISCOUNTPLANSETTINGCOLUMN],
|
formItems: [...DISCOUNTPLANSETTINGFORMS],
|
defValues: {
|
...DISCOUNTPLANSETTINGDEFVALUE
|
},
|
formRules: {
|
...DISCOUNTPLANSETTINGRULES(!this.isView)
|
},
|
dialogTitle: '贴息方案配置新增',
|
tipContent: '',
|
serialno: '',
|
showOld:
|
this.$parent._data.objecttype === 'jbo.app.BUSINESS_TYPE_CHANGE' &&
|
this.isView,
|
oldVal: {},
|
screenWidth: 1000,
|
loading: false,
|
dLoading: true,
|
dialogDelVisible: false,
|
dialogVisible: false,
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0
|
}
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.discount_plan_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: 540px !important;
|
height: 250px !important;
|
& .el-dialog__body {
|
height: 80px;
|
overflow-y: auto;
|
overflow-x: hidden;
|
}
|
}
|
}
|
</style>
|