更新
This commit is contained in:
parent
caa20e195e
commit
acebf9911d
@ -107,6 +107,7 @@
|
||||
<el-table-column type="selection" width="80" align="center"/>
|
||||
<el-table-column label="名称" align="center" prop="waresName" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="配件添加人" align="center" prop="addUserName" width="180"/>
|
||||
<el-table-column label="售价" align="center" prop="salePrice" width="180"/>
|
||||
<el-table-column label="领料数量" v-if="type" align="center" prop="waresCount" width="180">
|
||||
<div class="item" slot-scope="scope">
|
||||
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.waresCount"
|
||||
|
||||
@ -315,6 +315,7 @@
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
:class="{ 'gray-text': scope.row.ifBilled == '1' }"
|
||||
icon="el-icon-tickets"
|
||||
@click="scope.row.ifBilled == '1' ? showBilled(scope.row) : unbilled(scope.row)"
|
||||
>
|
||||
@ -1176,6 +1177,11 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 已开票按钮文字置灰样式 */
|
||||
.gray-text {
|
||||
color: #909399 !important;
|
||||
}
|
||||
|
||||
.item {
|
||||
.item__input {
|
||||
display: none;
|
||||
|
||||
@ -13,6 +13,16 @@
|
||||
<div slot="header" class="clearfix">
|
||||
<i class="el-icon-plus" />
|
||||
<span>工单信息</span>
|
||||
<!-- A/B单切换控件,仅在存在B单时显示 -->
|
||||
<el-switch
|
||||
v-if="hasBOrder"
|
||||
style="float: right; padding: 3px 0"
|
||||
v-model="showABMode"
|
||||
active-text="显示A+B单"
|
||||
inactive-text="仅显示A单"
|
||||
@change="handleModeChange"
|
||||
>
|
||||
</el-switch>
|
||||
</div>
|
||||
<!-- 卡片内容 -->
|
||||
<div>
|
||||
@ -208,6 +218,9 @@
|
||||
<div slot="header" class="clearfix">
|
||||
<i class="el-icon-plus" />
|
||||
<span>合计</span>
|
||||
<span v-if="hasBOrder && showABMode" style="float: right; color: #409EFF; font-size: 14px;">
|
||||
(包含A+B单)
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<el-descriptions
|
||||
@ -267,12 +280,12 @@
|
||||
<div class="button-container">
|
||||
<PrintButton
|
||||
ref="printButton"
|
||||
print-title="打印结算单"
|
||||
print-title="结算单"
|
||||
@click="handlePrint"
|
||||
>
|
||||
<template #printContent>
|
||||
<div class="print-content">
|
||||
<h1 style="text-align: center">打印结算单</h1>
|
||||
<h1 style="text-align: center">结算单</h1>
|
||||
<h2>工单信息</h2>
|
||||
<table
|
||||
class="print-table"
|
||||
@ -693,7 +706,13 @@ export default {
|
||||
totalCount: 0,
|
||||
totalMoney: 0,
|
||||
otherInfo: {},
|
||||
loading: false // 添加加载状态
|
||||
loading: false, // 添加加载状态
|
||||
// A/B单切换相关
|
||||
showABMode: false, // 是否显示AB单
|
||||
hasBOrder: false, // 是否有B单
|
||||
bprojects: [], // B单项目数据
|
||||
bwares: [], // B单配件数据
|
||||
bother: [] // B单附加信息数据
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
@ -705,13 +724,21 @@ export default {
|
||||
this.reset();
|
||||
this.loading = true; // 开启加载状态
|
||||
getTicketsById(row.id).then(res => {
|
||||
this.allList = res.data.items;
|
||||
this.computed();
|
||||
this.projects = this.allList.filter((item) => item.project);
|
||||
this.wares = this.allList.filter((item) => item.ware);
|
||||
this.others = this.allList.filter((item) => item.other);
|
||||
// 获取A单数据
|
||||
this.allList = res.data.items || [];
|
||||
this.info = row;
|
||||
this.otherInfo = res.data;
|
||||
|
||||
// 获取B单数据(假设API返回中包含B单数据)
|
||||
const bItems = res.data.bitems || [];
|
||||
this.hasBOrder = bItems && bItems.length > 0;
|
||||
this.bprojects = bItems.filter((item) => item.project);
|
||||
this.bwares = bItems.filter((item) => item.ware);
|
||||
this.bother = bItems.filter((item) => item.other);
|
||||
|
||||
// 根据默认模式更新显示数据
|
||||
this.updateDisplayData();
|
||||
|
||||
this.dialogVisible = true;
|
||||
this.loading = false; // 关闭加载状态
|
||||
resolve();
|
||||
@ -726,22 +753,106 @@ export default {
|
||||
await updateShow(this.info.id, this.info.partShow);
|
||||
} catch {}
|
||||
},
|
||||
// 处理A/B单切换
|
||||
handleModeChange() {
|
||||
// 根据切换状态重新计算显示的数据
|
||||
this.updateDisplayData();
|
||||
},
|
||||
// 更新显示数据,根据切换模式决定是否包含B单数据
|
||||
updateDisplayData() {
|
||||
// 初始化显示数据为A单数据
|
||||
let displayProjects = this.allList.filter((item) => item.project);
|
||||
let displayWares = this.allList.filter((item) => item.ware);
|
||||
let displayOthers = this.allList.filter((item) => item.other);
|
||||
|
||||
// 如果开启AB模式,且有B单数据,合并数据
|
||||
if (this.showABMode) {
|
||||
// 合并B单项目
|
||||
if (this.bprojects && this.bprojects.length > 0) {
|
||||
displayProjects = [...displayProjects, ...this.bprojects];
|
||||
}
|
||||
|
||||
// 合并B单配件
|
||||
if (this.bwares && this.bwares.length > 0) {
|
||||
displayWares = [...displayWares, ...this.bwares];
|
||||
}
|
||||
|
||||
// 合并B单附加信息
|
||||
if (this.bother && this.bother.length > 0) {
|
||||
displayOthers = [...displayOthers, ...this.bother];
|
||||
}
|
||||
}
|
||||
|
||||
// 更新显示数据
|
||||
this.projects = displayProjects;
|
||||
this.wares = displayWares;
|
||||
this.others = displayOthers;
|
||||
|
||||
// 重新计算总金额和总数量
|
||||
this.computed();
|
||||
},
|
||||
reset() {
|
||||
this.info = {};
|
||||
this.projects = [];
|
||||
this.wares = [];
|
||||
this.others = [];
|
||||
this.allList = [];
|
||||
this.showABMode = false;
|
||||
this.hasBOrder = false;
|
||||
this.bprojects = [];
|
||||
this.bwares = [];
|
||||
this.bother = [];
|
||||
},
|
||||
computed() {
|
||||
this.totalCount = 0;
|
||||
this.totalMoney = 0;
|
||||
if (this.allList && this.allList.length > 0) {
|
||||
this.totalCount = this.allList.reduce((acc, cur) => {
|
||||
return acc + cur.itemCount;
|
||||
|
||||
// 根据显示模式决定使用哪些数据进行计算
|
||||
let itemsToCalculate = [...this.allList];
|
||||
|
||||
// 如果开启AB模式,且有B单数据,合并计算
|
||||
if (this.showABMode) {
|
||||
// 合并B单项目
|
||||
if (this.bprojects && this.bprojects.length > 0) {
|
||||
this.bprojects.forEach(project => {
|
||||
itemsToCalculate.push({
|
||||
...project,
|
||||
itemCount: project.itemCount || 0,
|
||||
itemMoney: project.itemMoney || 0
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 合并B单配件
|
||||
if (this.bwares && this.bwares.length > 0) {
|
||||
this.bwares.forEach(ware => {
|
||||
itemsToCalculate.push({
|
||||
...ware,
|
||||
itemCount: ware.itemCount || 0,
|
||||
itemMoney: ware.itemMoney || 0
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 合并B单附加信息
|
||||
if (this.bother && this.bother.length > 0) {
|
||||
this.bother.forEach(other => {
|
||||
itemsToCalculate.push({
|
||||
...other,
|
||||
itemCount: other.itemCount || 0,
|
||||
itemMoney: other.itemMoney || 0
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 计算总数量和总金额
|
||||
if (itemsToCalculate && itemsToCalculate.length > 0) {
|
||||
this.totalCount = itemsToCalculate.reduce((acc, cur) => {
|
||||
return acc + (cur.itemCount || 0);
|
||||
}, 0);
|
||||
this.totalMoney = this.allList.reduce((acc, cur) => {
|
||||
return acc + cur.itemMoney;
|
||||
this.totalMoney = itemsToCalculate.reduce((acc, cur) => {
|
||||
return acc + (cur.itemMoney || 0);
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user