From 04105e6d4d235c8c722cd69d7d56eab478378514 Mon Sep 17 00:00:00 2001
From: xyc <3422692813@qq.com>
Date: Fri, 15 Aug 2025 14:57:14 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B00815?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tickets/Components/TicketItemShow.vue | 102 +++++++++++-------
.../repair/tickets/Components/TicketsShow.vue | 20 +++-
2 files changed, 85 insertions(+), 37 deletions(-)
diff --git a/src/views/repair/tickets/Components/TicketItemShow.vue b/src/views/repair/tickets/Components/TicketItemShow.vue
index 296170e..5cc4ef9 100644
--- a/src/views/repair/tickets/Components/TicketItemShow.vue
+++ b/src/views/repair/tickets/Components/TicketItemShow.vue
@@ -31,7 +31,14 @@
-
+
+
+
+
+ {{ scope.row.itemProfitRate * 100 }}%
+
+
@@ -53,36 +60,36 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -125,7 +132,7 @@ export default {
type: String,
default: null
},
- isEdit:{
+ isEdit: {
type: Boolean,
}
},
@@ -134,14 +141,14 @@ export default {
loading: !(this.list && this.list.length) && !this.isEdit,
dialogVisible: false,
item: {},
- formRules:{
+ formRules: {
itemPrice: [{required: true, message: '单价不能为空', trigger: 'blur'}],
itemCount: [{required: true, message: '数量不能为空', trigger: 'blur'}],
itemDiscount: [{required: true, message: "折扣不能为空", trigger: 'blur'}]
},
formLoading: false,
// 需要计算的列
- includeColumn: ['itemMoney', 'itemCount']
+ includeColumn: ['itemMoney', 'itemCount', 'itemProfit', 'itemProfitRate']
}
},
computed: {
@@ -159,7 +166,7 @@ export default {
}
},
methods: {
- async editItem(row){
+ async editItem(row) {
this.resetForm('formRef')
try {
const res = await getItemById(row.id)
@@ -167,40 +174,63 @@ export default {
this.dialogVisible = true
this.item['repair'] = null
this.item['adviser'] = null
- }catch{}
+ } catch {
+ }
},
- async submitForm(){
+ async submitForm() {
try {
await this.$refs.formRef.validate()
await updateById(this.item)
this.dialogVisible = false
this.$modal.msgSuccess("修改成功")
this.$emit('success', this.item.ticketId)
- }catch{}
+ } catch {
+ }
},
- getSummaries(param){
- const { columns, data } = param;
- const sums = [];
- columns.forEach((column, index) => {
- if (index === 0) {
- sums[index] = '合计';
- return;
- }
- const values = data.map(item => Number(item[column.property]));
- if (this.includeColumn.includes(column.property)) {
- sums[index] = values.reduce((prev, curr) => {
- const value = Number(curr);
- if (!isNaN(value)) {
- return prev + curr;
- } else {
- return prev;
- }
- }, 0);
- sums[index];
- }
- });
- return sums;
+ getSummaries(param) {
+ const {columns, data} = param;
+ const sums = [];
+ columns.forEach((column, index) => {
+ if (index === 0) {
+ sums[index] = '合计';
+ return;
}
+
+ if (this.includeColumn.includes(column.property)) {
+ const values = data.map(item => Number(item[column.property]));
+ sums[index] = values.reduce((prev, curr) => {
+ const value = Number(curr);
+ if (!isNaN(value)) {
+ return prev + curr;
+ } else {
+ return prev;
+ }
+ }, 0);
+
+ // 特殊处理毛利率字段
+ if (column.property === 'itemProfitRate') {
+ // 计算总毛利率 = (总毛利 / 总金额) * 100%
+ const totalProfit = data.reduce((sum, item) => {
+ const profit = Number(item.itemProfit);
+ return !isNaN(profit) ? sum + profit : sum;
+ }, 0);
+
+ const totalMoney = data.reduce((sum, item) => {
+ const money = Number(item.itemMoney);
+ return !isNaN(money) ? sum + money : sum;
+ }, 0);
+
+ if (totalMoney !== 0) {
+ sums[index] = ((totalProfit / totalMoney) * 100).toFixed(2) + '%';
+ } else {
+ sums[index] = '0%';
+ }
+ }
+ }
+ });
+ return sums;
+}
+
}
}
diff --git a/src/views/repair/tickets/Components/TicketsShow.vue b/src/views/repair/tickets/Components/TicketsShow.vue
index 4277517..d61a2a1 100644
--- a/src/views/repair/tickets/Components/TicketsShow.vue
+++ b/src/views/repair/tickets/Components/TicketsShow.vue
@@ -245,6 +245,22 @@
+
+
+
+
+ 含工时项目毛利率
+
+ {{ otherInfo.profitRate * 100 }}%
+
+
+
+ 不含工时项目的毛利率
+
+ {{ otherInfo.profitRateNo * 100}}%
+
+
+