<template>
|
<div class="pricing_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="pricingList"
|
: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
|
v-if="dialogVisible"
|
:screenWidth="screenWidth"
|
:isShowOld="showOld"
|
:oldVal="oldVal"
|
:isView="isView"
|
:formItems="formItems"
|
:isShowBorder="isShowBorder"
|
ref="pricingSetting"
|
: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="savePricingConfiguration"
|
>确 定</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="deletePricingConfiguration"
|
>确 定</el-button
|
>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import { DIMENSIONPRICINGSETTINGCOLUMN } from './config/tableConfig.js';
|
import {
|
addOrUpdatePricingConfiguration,
|
qryPricingConfigurationList,
|
delPricingConfiguration,
|
qryPricingConfigurationDetail
|
} from '../../../../api/productManage.api';
|
import { DIMENSIONENUM } from '../../../../utils/optionsQueryConfig.js';
|
import ProTable from '../../../../components/ProTable.vue';
|
import CreateForms from '../../../../components/CreateForms.vue';
|
import { DIMENSIONPRICINGSETTINGFORMS } from '../../../../utils/formsConfig.js';
|
import { DIMENSIONPRICINGSETTINGDEFVALUE } from '../../../../utils/defValueConfig.js';
|
import { DIMENSIONPRICINGSETTINGRULES } 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 {}
|
}
|
}
|
},
|
watch: {
|
options: {
|
handler(val, oldVal) {
|
this.optionsData = val
|
this.getOptionItems(val)
|
},
|
deep: true
|
}
|
},
|
components: {
|
ProTable,
|
CreateForms
|
},
|
mounted() {
|
this.initColumns();
|
(this.isView || this.edit) && this.getPricingConfigurationList()
|
},
|
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)
|
},
|
// 下拉选择事件处理
|
handleSelOnChange(formName, value) {
|
let newFormItems = [...this.formItems]
|
if (formName === 'rateinteresttype') {
|
const showFoelds = [
|
'interestperiod',
|
'interesttype',
|
'rateunit',
|
'rate'
|
]
|
newFormItems.forEach(form => {
|
if (showFoelds.includes(form.name)) {
|
form.show = value === '1';
|
}
|
if (form.name === 'eachratefixed') {
|
form.show = value === '2';
|
}
|
})
|
}
|
if (formName === 'poundagetype') {
|
const showFoelds = ['poundagerate', 'minpoundage', 'maxpoundage']
|
newFormItems.forEach(form => {
|
if (showFoelds.includes(form.name)) {
|
form.show = value === '1';
|
}
|
if (form.name === 'poundagefixed') {
|
form.show = value === '2';
|
}
|
if (form.name === 'poundagecharge') {
|
form.show = value !== '0';
|
}
|
if (form.name === 'poundagemonth') {
|
form.show = value !== '0';
|
}
|
})
|
}
|
if (formName === 'poundagecharge') {
|
newFormItems.forEach(form => {
|
if (form.name === 'poundagemonth') {
|
form.show = value === '5';
|
}
|
})
|
}
|
if (formName === 'platformtype') {
|
const showFoelds = ['platformrate', 'minplatform', 'maxplatform']
|
newFormItems.forEach(form => {
|
if (showFoelds.includes(form.name)) {
|
form.show = value === '1';
|
}
|
if (form.name === 'platformfixed') {
|
form.show = value === '2';
|
}
|
if (form.name === 'platformcharge') {
|
form.show = value !== '0';
|
}
|
if (form.name === 'platformmonth') {
|
form.show = value !== '0';
|
}
|
})
|
}
|
if (formName === 'platformcharge') {
|
newFormItems.forEach(form => {
|
if (form.name === 'platformmonth') {
|
form.show = value === '5';
|
}
|
})
|
}
|
if (formName === 'guarantycalculation') {
|
const showFoelds = ['guarantyrate', 'minguaranty', 'maxguaranty']
|
newFormItems.forEach(form => {
|
if (showFoelds.includes(form.name)) {
|
form.show = value === '1';
|
}
|
if (form.name === 'guarantyfixed') {
|
form.show = value === '2';
|
}
|
if (form.name === 'guarantycharge') {
|
form.show = value !== '0';
|
}
|
if (form.name === 'guarantymonth') {
|
form.show = value !== '0';
|
}
|
})
|
}
|
if (formName === 'guarantycharge') {
|
newFormItems.forEach(form => {
|
if (form.name === 'guarantymonth') {
|
form.show = value === '5';
|
}
|
})
|
}
|
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
|
},
|
async doAction(name, item, { key, label }) {
|
if (key === 'edit') {
|
this.dialogTitle = '定价配置修改';
|
this.serialno = item.serialno
|
this.dialogVisible = true
|
const infos = await this.getPricingConfigurationDetail(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.getPricingConfigurationDetail(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.paymentname})`
|
this.dialogDelVisible = true
|
}
|
},
|
// 获取下拉选择项
|
getOptionItems(optionsMap) {
|
const { formItems } = this
|
formItems.forEach(item => {
|
if (item.type === 'select') {
|
item.options = optionsMap[DIMENSIONENUM[item.name]]
|
}
|
})
|
},
|
// 获取定价配置列表
|
async getPricingConfigurationList() {
|
const { currentPage, pageSize } = this.pageInfo
|
const { dimensionno, objectno, productid } = this.$parent._data
|
const params = {
|
currentPage,
|
dimensionno,
|
objectno,
|
pageSize,
|
productid
|
}
|
const listRes = await qryPricingConfigurationList(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, 'pricingList', list)
|
this.pageInfo.total = listRes.result.total
|
},
|
// 查询产品维度定价配置信息
|
async getPricingConfigurationDetail(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 qryPricingConfigurationDetail(params)
|
if (!detailRes || detailRes.code !== '00') {
|
return
|
}
|
return detailRes.result
|
},
|
// 删除产品维度定价配置信息
|
async deletePricingConfiguration() {
|
const deleteRes = await delPricingConfiguration({
|
serialno: this.serialno
|
})
|
if (!deleteRes || deleteRes.code !== '00') {
|
return
|
}
|
this.dialogDelVisible = false
|
this.$message.success('删除成功')
|
this.getPricingConfigurationList()
|
return deleteRes.result
|
},
|
// 新增定价
|
handleAddPage() {
|
this.formItems = [...DIMENSIONPRICINGSETTINGFORMS]
|
this.defValues = {
|
...DIMENSIONPRICINGSETTINGDEFVALUE
|
}
|
this.formRules = {
|
...DIMENSIONPRICINGSETTINGRULES(!this.isView)
|
}
|
this.dialogTitle = '定价配置新增';
|
this.optionsData = {}
|
this.screenWidth = 1000
|
this.tipContent = '';
|
this.loading = false
|
this.serialno = '';
|
this.dialogVisible = false
|
this.dialogDelVisible = false
|
this.pageInfo = {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0
|
}
|
this.setFormsItemConfig()
|
this.dialogVisible = true
|
},
|
// 校验基本信息
|
validateForms() {
|
const pricingSettingForm = this.$refs.pricingSetting
|
pricingSettingForm.$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 savePricingConfiguration() {
|
await this.validateForms()
|
const { isValidate } = this
|
if (!isValidate) {
|
return false
|
}
|
const pricingSettingForm = this.$refs.pricingSetting
|
const { dimensionno, objectno, productid } = this.$parent._data
|
const params = {
|
...this.getFormItemsValue(
|
pricingSettingForm.formItems,
|
pricingSettingForm.formValues,
|
DIMENSIONPRICINGSETTINGDEFVALUE
|
),
|
dimensionno,
|
objectno,
|
productid,
|
serialno: this.serialno
|
}
|
const res = await addOrUpdatePricingConfiguration(params)
|
this.getPricingConfigurationList()
|
if (!res || res.code !== '00') {
|
return false
|
}
|
this.$message({
|
message: '保存成功!',
|
type: 'success'
|
})
|
this.dialogVisible = false
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val
|
this.getProductList()
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val
|
this.getProductList()
|
}
|
},
|
data() {
|
return {
|
pricingList: [],
|
tableHeader: [...DIMENSIONPRICINGSETTINGCOLUMN],
|
formItems: [...DIMENSIONPRICINGSETTINGFORMS],
|
defValues: {
|
...DIMENSIONPRICINGSETTINGDEFVALUE
|
},
|
formRules: {
|
...DIMENSIONPRICINGSETTINGRULES(!this.isView)
|
},
|
dialogTitle: '定价配置新增',
|
showOld:
|
this.$parent._data.objecttype === 'jbo.app.BUSINESS_TYPE_CHANGE' &&
|
this.isView,
|
oldVal: {},
|
optionsData: {},
|
screenWidth: 1000,
|
tipContent: '',
|
loading: false,
|
serialno: '',
|
dialogVisible: false,
|
dialogDelVisible: false,
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0
|
}
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.pricing_main {
|
padding: 20px 0 0 20px;
|
& .add-button {
|
padding: 10px 0 30px 0;
|
}
|
background: #fff;
|
& >>> .pricing_dialog {
|
width: 1000px;
|
height: 650px;
|
& .el-dialog__body {
|
height: 460px;
|
overflow-y: auto;
|
overflow-x: hidden;
|
& .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>
|