<template>
|
<div class="list_main">
|
<SearchCondition
|
:info="formItems"
|
ref="condRef"
|
:conForm="conForm"
|
:screenWidth="screenWidth"
|
:isShowDetail="isShowDetail"
|
@handleOnSeach="handleOnSeach"
|
@handleOnRest="handleOnRest"
|
@handleClick="isShowDetail = !isShowDetail"
|
/>
|
<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="openAddPage"
|
class="add-btn"
|
>新增维度</el-button
|
>
|
</el-col>
|
</el-row>
|
<ProTable
|
:pageInfo="pageInfo"
|
@doAction="doAction"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"
|
:noHistory="noHistory"
|
:isAutoIndex="true"
|
:screenWidth="screenWidth"
|
:list="records"
|
:header="tableHeader"
|
:loading="loading"
|
/>
|
<el-dialog
|
title="维度删除确认"
|
:visible.sync="dialogDelVisible"
|
width="1000"
|
center
|
custom-class="pricing_dialog del_dialog"
|
>
|
<div>{{ delTipContent }}</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="dialogDelVisible = false">取 消</el-button>
|
<el-button type="primary" @click="deleteProductDimensions"
|
>确 定</el-button
|
>
|
</span>
|
</el-dialog>
|
<el-dialog
|
title="维度复制确认"
|
:visible.sync="copyDialogVisible"
|
width="500"
|
center
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
custom-class="pricing_dialog copy_dialog"
|
>
|
<CreateForms
|
ref="copyDim"
|
v-if="copyDialogVisible"
|
:screenWidth="900"
|
:formItems="copyFormItems"
|
:defValues="copyDefValues"
|
:formRules="copyFormRules"
|
/>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="copyDialogVisible = false" :disabled="btnLoading"
|
>取 消</el-button
|
>
|
<el-button
|
type="primary"
|
@click="copyProductDimensions"
|
:loading="btnLoading"
|
>
|
确 定
|
</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {
|
PRODIMENSIONLISTCON,
|
PRODIMENSIONLISTDEF
|
} from '../../../utils/condtionConfig';
|
import { PRODIMENSIONLISTCOLUMN } from '../../../utils/columnConfig';
|
import { COPYDIMENSIONFORM } from '../../../utils/formsConfig';
|
import { COPYDIMENSIONDEFVALUE } from '../../../utils/defValueConfig';
|
import { COPYDIMENSIONRULES } from '../../../utils/formRulesConfig';
|
import {
|
qryProductDimensionsList,
|
delProductDimensions,
|
copyProductDimensions,
|
qryCondition
|
} from '../../../api/productManage.api';
|
import ProTable from '../../../components/ProTable.vue';
|
import CreateForms from '../../../components/CreateForms.vue';
|
import SearchCondition from '../../../components/SearchCondition.vue';
|
|
export default {
|
props: {
|
edit: {
|
type: Boolean,
|
default: () => {
|
return false
|
}
|
},
|
screenWidth: {
|
type: Number,
|
default: () => {
|
return 1280
|
}
|
},
|
isView: {
|
type: Boolean,
|
default: () => {
|
return false
|
}
|
},
|
isShowBorder: {
|
type: Boolean,
|
default: () => {
|
return true
|
}
|
},
|
noHistory: {
|
type: Boolean,
|
default: () => {
|
return false
|
}
|
}
|
},
|
watch: {
|
isView: {
|
handler(val) {
|
if (val) {
|
this.isView = val
|
}
|
},
|
deep: true
|
},
|
edit: {
|
handler(val) {
|
this.getProductDimensionsList()
|
},
|
deep: true
|
}
|
},
|
data() {
|
return {
|
formItems: [...PRODIMENSIONLISTCON],
|
conForm: { ...PRODIMENSIONLISTDEF },
|
tableHeader: [...PRODIMENSIONLISTCOLUMN].filter(item => !item.filter),
|
copyFormItems: [...COPYDIMENSIONFORM],
|
copyDefValues: { ...COPYDIMENSIONDEFVALUE },
|
copyFormRules: { ...COPYDIMENSIONRULES },
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0
|
},
|
records: [],
|
condtionValue: {}, // 表单value集合
|
btnLoading: false,
|
isShowDetail: false, // 是否显示所有表单项
|
loading: false,
|
listSerialno: '',
|
dialogDelVisible: false,
|
delTipContent: '',
|
copyDialogVisible: false
|
}
|
},
|
components: {
|
SearchCondition,
|
ProTable,
|
CreateForms
|
},
|
mounted() {
|
this.initColumns();
|
(this.isView || this.edit) && this.getProductDimensionsList()
|
const opyionItems = [
|
{ name: 'dimensionStatus', code: 'EffStatus' },
|
{ name: 'tradeType', code: 'DimensionTradeType' }
|
]
|
opyionItems.forEach(item => {
|
this.getCondition(item.name, item.code)
|
})
|
},
|
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)
|
},
|
restTable(elments) {
|
const showCloums = [...PRODIMENSIONLISTCOLUMN].filter(obj => !obj.filter)
|
const newTableHeader = []
|
const showOtherCloums = PRODIMENSIONLISTCOLUMN.concat().filter(
|
obj => obj.filter
|
)
|
elments &&
|
elments
|
.filter(el => el !== '*DFT')
|
.forEach(ele => {
|
const eleCloums = showOtherCloums.filter(
|
forms => forms && forms.prop.toLocaleUpperCase() === ele
|
)
|
const orgIdCloums = showOtherCloums.filter(
|
forms => forms && forms.prop === 'orgId'
|
)
|
const hasOrgIdClounm = ele === 'CHANNELNO';
|
if (hasOrgIdClounm) {
|
newTableHeader.push(orgIdCloums[0])
|
} else {
|
newTableHeader.push(eleCloums[0])
|
}
|
})
|
this.$set(this, 'tableHeader', [...showCloums, ...newTableHeader])
|
setTimeout(() => {
|
this.initColumns()
|
}, 100)
|
},
|
/**
|
* 获取下拉选择项
|
*/
|
async getCondition(name, conditionName) {
|
const params = { conditionName }
|
const re = await qryCondition(params)
|
if (re.code && re.code === '00') {
|
const newForms = [...this.formItems].map(forms => {
|
const newForm = { ...forms }
|
if (newForm.name === name) {
|
newForm.options = re.result
|
}
|
return newForm
|
})
|
this.$set(this, 'formItems', newForms)
|
}
|
},
|
// 获取产品维度列表
|
async getProductDimensionsList() {
|
const { currentPage, pageSize } = this.pageInfo
|
const { productid, serialno } = this.$parent._data
|
const {
|
dimensionsName,
|
dimensionStatus,
|
tradeType,
|
orgId,
|
cityNo,
|
areaNo,
|
projectNo,
|
customersNo,
|
dimensionscode,
|
minStartBusinessSum,
|
minEndBusinessSum,
|
maxStartBusinessSum,
|
maxEndBusinessSum
|
} = this.condtionValue
|
const params = {
|
areano: areaNo,
|
channelno: orgId,
|
cityno: cityNo,
|
currentPage,
|
productid,
|
pageSize,
|
dimensionscode,
|
customersno: customersNo,
|
dimensionsname: dimensionsName,
|
dimensionstatus: dimensionStatus,
|
maxBusinessSumSearch: {
|
min: maxStartBusinessSum,
|
max: maxEndBusinessSum
|
},
|
minBusinessSumSearch: {
|
min: minStartBusinessSum,
|
max: minEndBusinessSum
|
},
|
objectno: serialno,
|
projectno: projectNo,
|
tradetype: tradeType
|
}
|
const res = await qryProductDimensionsList(params)
|
if (res.code && res.code === '00') {
|
const list =
|
res.result &&
|
res.result.records.map(item => {
|
const newitem = { ...item }
|
newitem.operationOption = this.isView
|
? [{ key: 'details', label: '详情', value: true }]
|
: [
|
{ key: 'edit', label: '修改', value: true },
|
{ key: 'copy', label: '复制', value: true },
|
{ key: 'delete', label: '删除', value: true }
|
]
|
return newitem
|
})
|
this.$set(this, 'records', list)
|
this.$set(this.pageInfo, 'total', res.result && res.result.total)
|
}
|
},
|
// 删除维度信息
|
async deleteProductDimensions() {
|
const res = await delProductDimensions({ serialno: this.listSerialno })
|
this.dialogDelVisible = false
|
if (res && res.code === '00') {
|
this.$message.success('删除成功!')
|
this.getProductDimensionsList()
|
}
|
},
|
// 维度信息复制
|
async copyProductDimensions(serialno) {
|
const copyDimForm = this.$refs.copyDim
|
this.btnLoading = true
|
copyDimForm.$refs['createForm'].validate(async valid => {
|
if (valid) {
|
const { productid, serialno, objecttype } = this.$parent._data
|
const { newdimensionsname, olddimensionno } = copyDimForm.formValues
|
const params = {
|
newdimensionsname,
|
objectno: serialno,
|
olddimensionno,
|
typeno: productid
|
}
|
const loading = this.$loading({
|
lock: true,
|
text: '正在复制,请耐心等待!',
|
background: 'hsla(0,0%,100%,.9)'
|
})
|
setTimeout(() => {
|
loading.close()
|
}, 30000)
|
const copyRes = await copyProductDimensions(params)
|
loading.close()
|
this.copyDialogVisible = false
|
this.btnLoading = false
|
if (!copyRes || copyRes.code !== '00') {
|
return false
|
}
|
this.$router.push({
|
name: 'dimensionEdit',
|
query: {
|
type: 'edit',
|
objecttype,
|
dimensionno: copyRes.result.dimensionno,
|
objectno: copyRes.result.objectno,
|
productid: copyRes.result.productid
|
}
|
})
|
} else {
|
this.$message.error('请输入新的维度名称!')
|
return false
|
}
|
})
|
},
|
// 更新数据
|
updateValue(value, item) {
|
const { name } = item
|
this.setOrGetFormInfo(name, { value })
|
},
|
|
// 搜索列表
|
handleOnSeach() {
|
const conRef = this.$refs.condRef
|
this.$set(this, 'condtionValue', conRef.$refs['conform'].model)
|
this.$set(this, 'pageInfo', { currentPage: 1, pageSize: 10, total: 0 })
|
this.getProductDimensionsList()
|
},
|
// 重置
|
handleOnRest(proListForm) {
|
this.$set(this, 'condtionValue', {})
|
// this.$set(this, 'pageInfo', { currentPage: 1, pageSize: 10, total: 0 })
|
// this.getProductDimensionsList()
|
},
|
|
// 表单事件回调
|
doAction(name, item, { key, label }) {
|
const { productid, serialno, objecttype } = this.$parent._data
|
const { noHistory, isShowBorder } = this
|
if (key === 'details') {
|
const { dimensionCode } = item
|
this.$router.push({
|
name: 'dimensionDetail',
|
query: {
|
dimensionno: dimensionCode,
|
objectno: serialno,
|
productid,
|
objecttype,
|
type: 'detail',
|
isShowBorder,
|
noHistory
|
}
|
})
|
return false
|
}
|
if (key === 'edit') {
|
const { dimensionCode } = item
|
this.$router.push({
|
name: 'dimensionEdit',
|
query: {
|
type: 'edit',
|
dimensionno: dimensionCode,
|
objecttype,
|
objectno: serialno,
|
productid
|
}
|
})
|
return false
|
}
|
if (key === 'delete') {
|
this.delTipContent = `请确认是否需要删除${item.dimensionCode}-${item.dimensionsName}`
|
this.listSerialno = item.relativeSerialNo
|
this.dialogDelVisible = true
|
}
|
if (key === 'copy') {
|
this.copyDialogVisible = true
|
this.listSerialno = item.relativeSerialNo
|
setTimeout(() => {
|
const copyDimForm = this.$refs.copyDim
|
copyDimForm.formValues.newdimensionsname = '';
|
copyDimForm.formValues.olddimensionno = item.dimensionCode
|
copyDimForm.formValues.dimensionsName = item.dimensionsName
|
copyDimForm.update()
|
}, 10)
|
}
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val
|
this.getProductDimensionsList()
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val
|
this.getProductDimensionsList()
|
},
|
async initProduct() {
|
if (!this.$parent.serialno) {
|
await this.$parent.handleSave('init', 'dimension')
|
if (!this.$parent.typeno) {
|
return false
|
}
|
return false
|
}
|
return true
|
},
|
async openAddPage() {
|
const isInit = await this.initProduct()
|
isInit &&
|
this.$router.push({
|
name: 'dimensionAdd',
|
query: {
|
typeno: this.$parent.typeno,
|
objectno: this.$parent.serialno
|
}
|
})
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.list_main {
|
background: #fff;
|
padding: 16px 0px 0px 20px;
|
& .add-button {
|
padding: 2px 0 30px 0;
|
}
|
& >>> .pricing_dialog {
|
width: 500px;
|
& .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;
|
}
|
}
|
}
|
}
|
& >>> .copy_dialog {
|
width: 900px !important;
|
& .el-dialog__body {
|
& .form_main {
|
& .el-form--inline {
|
& .el-form-item {
|
& .el-form-item__label {
|
line-height: 32px;
|
}
|
}
|
}
|
}
|
}
|
}
|
& >>> .del_dialog {
|
width: 450px !important;
|
& .el-dialog__body {
|
text-align: center;
|
}
|
}
|
}
|
</style>
|