333
This commit is contained in:
parent
6ddd9cfa69
commit
342ef5eff7
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog"
|
||||
title="定价详情" width="1600px">
|
||||
title="定价详情" width="60%">
|
||||
<el-descriptions :column="1" border size="small" label-class-name="label-style">
|
||||
<el-descriptions-item label="客户名称">{{ form.custName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="网点名称">{{ form.netName }}</el-descriptions-item>
|
||||
|
|
@ -8,38 +8,21 @@
|
|||
<el-descriptions-item label="价格执行时间">{{ form.priceExecuteTime }}</el-descriptions-item>
|
||||
<el-descriptions-item label="网点编码">{{ form.netCode }}</el-descriptions-item>
|
||||
<el-descriptions-item label="日均单量">{{ form.avgOrderNum }}</el-descriptions-item>
|
||||
<el-descriptions-item label="重量段">{{ form.weightSegment }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注">{{ form.remark }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-table :data="form.quoteList" border size="small" style="width: 100%">
|
||||
<af-table-column prop="分区" label="分区" ></af-table-column>
|
||||
<af-table-column prop="报价类型" label="报价类型" ></af-table-column>
|
||||
<el-table-column label="0-0.5kg">
|
||||
<af-table-column prop="0-0.5kg单票价" label="单票价"></af-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="0.5-1kg">
|
||||
<af-table-column prop="0.5-1kg单票价" label="单票价"></af-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="1.01-2kg">
|
||||
<af-table-column prop="1.01-2kg单票价" label="单票价"></af-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="2.01-3kg">
|
||||
<af-table-column prop="2.01-3kg单票价" label="单票价"></af-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="3-10kg">
|
||||
<af-table-column prop="3-10kg首重3kg" label="首重"></af-table-column>
|
||||
<af-table-column prop="3-10kg续重/kg" label="续重/kg" ></af-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="10-20kg">
|
||||
<af-table-column prop="10-20kg首重3kg" label="首重" ></af-table-column>
|
||||
<af-table-column prop="10-20kg续重/kg" label="续重/kg" ></af-table-column>
|
||||
<el-table :data="form.quoteList" :span-method="objectSpanMethod" border size="small" style="width: 100%">
|
||||
<el-table-column prop="分区" align="center" width="100px" label="分区"></el-table-column>
|
||||
<el-table-column prop="报价类型" align="center" width="100px" label="报价类型"></el-table-column>
|
||||
<el-table-column v-for="(group, gIndex) in mergedTableHeaders" :key="gIndex" align="center" :label="group.parent">
|
||||
<el-table-column v-for="(col, cIndex) in group.children" :key="cIndex" align="center" :prop="col.field"
|
||||
:label="col.label" />
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
|
||||
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="cancel">取消</el-button>
|
||||
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
|
||||
<!-- <el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button> -->
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
|
@ -47,15 +30,10 @@
|
|||
<script>
|
||||
import { add, edit } from '@/api/quotation'
|
||||
export default {
|
||||
props: {
|
||||
isAdd: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false, dialog: false,
|
||||
spanData: {},
|
||||
form: {
|
||||
id: '',
|
||||
custName: '',
|
||||
|
|
@ -64,8 +42,8 @@ export default {
|
|||
preChargeNo: '',
|
||||
avgOrderNum: '',
|
||||
priceExecuteTime: '',
|
||||
weightSegment: '',
|
||||
quoteType: '',
|
||||
weightSegment: {},
|
||||
quoteType: {},
|
||||
quiteList: [],
|
||||
remark: ''
|
||||
},
|
||||
|
|
@ -73,31 +51,97 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'form.quoteList': {
|
||||
handler(newVal) {
|
||||
if (newVal && newVal.length) {
|
||||
this.spanData = this.getSpanData(newVal);
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
mergedTableHeaders() {
|
||||
const weightMap = this.form.weightSegment;
|
||||
const quoteMap = this.form.quoteType;
|
||||
|
||||
const result = [];
|
||||
let lastParent = null; // 保存上一个有效的 parent(weightLabel)
|
||||
|
||||
Object.keys(quoteMap).slice(2).forEach(key => {
|
||||
const weightLabel = weightMap[key];
|
||||
const quoteLabel = quoteMap[key] || '';
|
||||
if (quoteLabel) {
|
||||
// 如果当前 weightLabel 为空,使用上一个有效值
|
||||
const currentParent = weightLabel ? weightLabel : lastParent;
|
||||
if (currentParent) {
|
||||
const field = 'headerC' + key;
|
||||
|
||||
|
||||
// 如果是新 parent,新建一个组
|
||||
if (!result.length || result[result.length - 1].parent !== currentParent) {
|
||||
result.push({
|
||||
parent: currentParent,
|
||||
children: [{ label: quoteLabel, field }]
|
||||
});
|
||||
} else {
|
||||
|
||||
// 否则追加子列到已有组
|
||||
result[result.length - 1].children.push({ label: quoteLabel, field });
|
||||
}
|
||||
// 更新 lastParent
|
||||
lastParent = currentParent;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getSpanData(data) {
|
||||
const spanData = {};
|
||||
data.forEach((row, index) => {
|
||||
const key = row['分区'];
|
||||
if (!spanData[key]) {
|
||||
spanData[key] = { start: index, count: 0 };
|
||||
}
|
||||
spanData[key].count++;
|
||||
});
|
||||
console.log(spanData);
|
||||
return spanData;
|
||||
},
|
||||
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
|
||||
// 只对“分区”列进行合并
|
||||
if (columnIndex === 0) {
|
||||
const key = row['分区'];
|
||||
console.log(row)
|
||||
const spanInfo = this.spanData[key];
|
||||
if (spanInfo && spanInfo.start === rowIndex) {
|
||||
return {
|
||||
rowspan: spanInfo.count,
|
||||
colspan: 1
|
||||
};
|
||||
}
|
||||
else if (spanInfo && spanInfo.start < rowIndex) {
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 其他列不合并
|
||||
return {
|
||||
rowspan: 1,
|
||||
colspan: 1
|
||||
};
|
||||
},
|
||||
cancel() {
|
||||
this.resetForm()
|
||||
},
|
||||
doSubmit() {
|
||||
this.loading = true
|
||||
if (this.isAdd) {
|
||||
this.doAdd()
|
||||
} else this.doEdit()
|
||||
},
|
||||
doAdd() {
|
||||
add(this.form).then(res => {
|
||||
this.resetForm()
|
||||
this.$notify({
|
||||
title: '添加成功',
|
||||
type: 'success',
|
||||
duration: 2500
|
||||
})
|
||||
this.loading = false
|
||||
this.$parent.init()
|
||||
}).catch(err => {
|
||||
this.loading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
doEdit() {
|
||||
edit(this.form).then(res => {
|
||||
this.resetForm()
|
||||
|
|
|
|||
|
|
@ -191,6 +191,8 @@ export default {
|
|||
},
|
||||
detail(data) {
|
||||
const quoteList = JSON.parse(data.quoteList);
|
||||
const quoteType = JSON.parse(data.quoteType);
|
||||
const weightSegment = JSON.parse(data.weightSegment);
|
||||
const _this = this.$refs.detail;
|
||||
_this.form = {
|
||||
id: data.id,
|
||||
|
|
@ -200,8 +202,8 @@ export default {
|
|||
preChargeNo: data.preChargeNo,
|
||||
avgOrderNum: data.avgOrderNum,
|
||||
priceExecuteTime: data.priceExecuteTime,
|
||||
weightSegment: data.weightSegment,
|
||||
quoteType: data.quoteType,
|
||||
weightSegment: weightSegment,
|
||||
quoteType: quoteType,
|
||||
quoteList: Array.isArray(quoteList) ? quoteList : [],
|
||||
remark: data.remark
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user