From 2e217b787931233134f5a656b3bc2503ed034eb7 Mon Sep 17 00:00:00 2001
From: sen <sen@qq.com>
Date: 星期二, 03 二月 2026 15:47:57 +0800
Subject: [PATCH] 增加开票,抬头关联发票抬头管理
---
ui/admin-ui3/src/components/GenerateBillDialog/index.vue | 162 +++++++++++++++++++++++++++++++++++------------------
1 files changed, 107 insertions(+), 55 deletions(-)
diff --git a/ui/admin-ui3/src/components/GenerateBillDialog/index.vue b/ui/admin-ui3/src/components/GenerateBillDialog/index.vue
index be29b90..7fee583 100644
--- a/ui/admin-ui3/src/components/GenerateBillDialog/index.vue
+++ b/ui/admin-ui3/src/components/GenerateBillDialog/index.vue
@@ -1,7 +1,8 @@
<template>
- <el-dialog v-model="visible" title="鐢熸垚搴旀敹璐﹀崟" width="1000px" destroy-on-close @closed="handleClosed">
+ <el-dialog v-model="visible" :title="type === 'receivable' ? '鐢熸垚搴旀敹璐﹀崟' : '鐢熸垚搴斾粯璐﹀崟'" width="1000px" destroy-on-close
+ @closed="handleClosed">
<div class="dialog-content">
- <h3 class="section-title">鏄惁鏍规嵁浠ヤ笅鏁版嵁鐢熸垚搴旀敹璐﹀崟</h3>
+ <h3 class="section-title">鏄惁鏍规嵁浠ヤ笅鏁版嵁鐢熸垚{{ type === 'receivable' ? '搴旀敹' : '搴斾粯' }}璐﹀崟</h3>
<el-form :model="formData" ref="formRef" label-position="left" label-width="80px">
<el-row :gutter="20">
@@ -23,25 +24,29 @@
</el-col>
</el-row>
</el-form>
+
<el-descriptions :column="3" border class="mb-6">
- <el-descriptions-item label="鍗曟嵁鏁伴噺">
- {{ statistics.documentCount }}
+ <el-descriptions-item label="鍗曟嵁鏁伴噺">{{ statistics.documentCount }}</el-descriptions-item>
+
+ <el-descriptions-item label="姹囩巼 (娓竵鍏戜汉姘戝竵)">{{ statistics.rate }}</el-descriptions-item>
+ <el-descriptions-item label="姹囩巼 (浜烘皯甯佸厬娓竵)">{{ statistics.rateRmb }}</el-descriptions-item>
+
+
+ <el-descriptions-item :label="type === 'receivable' ? '搴旀敹浜烘皯甯�' : '搴斾粯浜烘皯甯�'">
+ <span class="text-bold">{{ statistics.receivable }}</span>
</el-descriptions-item>
- <el-descriptions-item label="姹囩巼 (娓竵鍏戜汉姘戝竵)">
- {{ statistics.rate }}
+ <el-descriptions-item :label="type === 'receivable' ? '搴旀敹娓竵' : '搴斾粯娓竵'">
+ <span class="text-bold">{{ statistics.amountReceivable }}</span>
</el-descriptions-item>
- <!-- <el-descriptions-item label="姹囩巼 (浜烘皯甯佸厬娓竵)">
- {{ statistics.rateInverse || '-' }}
- </el-descriptions-item> -->
- <el-descriptions-item label="搴旀敹閲戦">
- <span class="text-bold">{{ statistics.totalReceivableAmount }}</span>
- </el-descriptions-item>
- <el-descriptions-item label="搴旀敹閲戦 (浠ヤ汉姘戝竵璁�)">
+ <el-descriptions-item :label="(type === 'receivable' ? '搴旀敹鎬婚噾棰�' : '搴斾粯鎬婚噾棰�') + ' (浠ヤ汉姘戝竵璁�)'">
<span class="text-primary">{{ statistics.totalAmountRmb }}</span>
</el-descriptions-item>
- <el-descriptions-item label="搴旀敹閲戦 (浠ユ腐甯佽)">
+
+ <el-descriptions-item :label="(type === 'receivable' ? '搴旀敹鎬婚噾棰�' : '搴斾粯鎬婚噾棰�') + ' (浠ユ腐甯佽)'">
<span class="text-success">{{ statistics.totalAmountHkd }}</span>
</el-descriptions-item>
+
+
</el-descriptions>
<div class="table-header">
@@ -53,22 +58,23 @@
<template #default="scope">
{{ dictFormat(sys_system, scope.row.sourceSystem) }}
</template>
- </el-table-column><!-- sys_system -->
+ </el-table-column>
<el-table-column prop="businessSector" align="center" label="涓氬姟鏉垮潡" width="120">
<template #default="scope">
{{ dictFormat(sys_business, scope.row.businessSector) }}
</template>
</el-table-column>
- <!-- sys_business -->
<el-table-column prop="documentType" align="center" label="鍗曟嵁绫诲瀷" width="120">
<template #default="scope">
{{ dictFormat(sys_receipts, scope.row.documentType) }}
</template>
- </el-table-column><!-- sys_receipts -->
+ </el-table-column>
<el-table-column prop="documentNo" align="center" label="鍗曟嵁缂栧彿" width="150" />
- <el-table-column prop="customerName" align="center" label="瀹㈡埛鍚嶇О" width="150" />
+ <el-table-column :prop="type === 'receivable' ? 'customerName' : 'supplierName'" align="center"
+ :label="type === 'receivable' ? '瀹㈡埛鍚嶇О' : '渚涘簲鍟嗗悕绉�'" width="150" />
<el-table-column prop="projectName" align="center" label="椤圭洰鍚嶇О" width="150" />
- <el-table-column prop="receivableAmount" align="center" label="搴旀敹閲戦" />
+ <el-table-column :prop="type === 'receivable' ? 'receivableAmount' : 'payableAmount'" align="center"
+ :label="type === 'receivable' ? '搴旀敹閲戦' : '搴斾粯閲戦'" />
<el-table-column prop="currency" align="center" label="甯佸埗" width="100">
<template #default="scope">
{{ dictFormat(sys_currency, scope.row.currency) }}
@@ -101,6 +107,8 @@
const dictFormat = (dict: any, value: any) => {
return proxy.selectDictLabel(dict, value);
}
+// 澧炲姞绫诲瀷鍖哄垎
+const type = ref<'receivable' | 'payable'>('receivable');
// 瀹氫箟鎺ュ彛缁撴瀯
interface StatisticsData {
documentCount: number;
@@ -124,53 +132,92 @@
const emit = defineEmits(['confirm']);
// 鏆撮湶缁欑埗缁勪欢鐨勬墦寮�鏂规硶
-const open = (data: any, selectionList: any[]) => {
+// 淇敼 open 鏂规硶锛屽鍔� mode 鍙傛暟
+const open = (data: any, selectionList: any[], mode: 'receivable' | 'payable' = 'receivable') => {
+ type.value = mode;
visible.value = true;
+
if (data) {
- Object.assign(statistics.value, data);
-
+ // 1. 澶勭悊鏄庣粏鏁版嵁鎷嗗垎锛堜綘鍘熸湁鐨勯�昏緫锛�
+ let processedList = [];
if (selectionList && selectionList.length > 0) {
- detailList.value = selectionList.flatMap(item => {
- if (!item.receivableAmountStr) return [item];
-
- // 1. 鎷嗗垎澶氫釜甯佺瀛楃涓�
- const amountParts = item.receivableAmountStr.trim().split(/\s+/);
-
+ processedList = selectionList.flatMap(item => {
+ const amountStr = mode === 'receivable' ? item.receivableAmountStr : item.payableAmountStr;
+ if (!amountStr) return [item];
+ const amountParts = amountStr.trim().split(/\s+/);
return amountParts.map(part => {
- // 2. 姝e垯瑙f瀽鎻愬彇鏁板�煎拰甯佺鍚嶇О
- // ([\d.]+) 鍖归厤鏁板瓧鍜屽皬鏁扮偣
- // ([\u4e00-\u9fa5]+) 鍖归厤涓枃瀛楃锛堝竵绉嶏級
const match = part.match(/([\d.]+)([\u4e00-\u9fa5]+)/);
-
- let amount = item.receivableAmount; // 榛樿鍊�
- let currencyValue = item.currency; // 榛樿鍊�
-
+ let amount = mode === 'receivable' ? item.receivableAmount : item.payableAmount;
+ let currencyValue = item.currency;
if (match) {
- amount = parseFloat(match[1]); // 鎻愬彇鐨勬暟瀛�
- const currencyName = match[2]; // 鎻愬彇鐨勫竵绉嶆枃瀛楋紝濡� "娓竵"
-
- // 3. 鏍规嵁鎻愬彇鐨勬枃瀛楀尮閰嶅瓧鍏镐腑鐨� Value
- // 鍋囪瀛楀吀 sys_currency.value: 0 鏄汉姘戝竵, 1 鏄腐甯� (璇锋牴鎹偍瀹為檯瀛楀吀鍊艰皟鏁�)
- if (currencyName.includes('浜烘皯甯�')) {
- currencyValue = 'RMB'; // 瀵瑰簲瀛楀吀鐨勪汉姘戝竵value
- } else if (currencyName.includes('娓竵')) {
- currencyValue = 'HKD'; // 瀵瑰簲瀛楀吀鐨勬腐甯乿alue
- }
+ amount = parseFloat(match[1]);
+ const currencyName = match[2];
+ if (currencyName.includes('浜烘皯甯�')) currencyValue = 'RMB';
+ else if (currencyName.includes('娓竵')) currencyValue = 'HKD';
}
-
- // 4. 杩斿洖鏂板璞★紝瑕嗙洊閲戦鍜屽竵鍒�
- return {
- ...item,
- receivableAmount: amount, // 璧嬪�兼彁鍙栫殑鏁板瓧
- currency: currencyValue, // 璧嬪�煎尮閰嶅埌鐨勫瓧鍏窱D
- receivableAmountStr: part // 淇濇寔鎷嗗垎鍚庣殑鏂囨湰
- };
+ const newItem = { ...item };
+ if (mode === 'receivable') newItem.receivableAmount = amount;
+ else newItem.payableAmount = amount;
+ newItem.currency = currencyValue;
+ return newItem;
});
});
- } else {
- detailList.value = [];
}
+
+ detailList.value = processedList;
+
+ // 2. 鎵ц璁$畻閫昏緫
+ const calcRes = calculateStatistics(processedList, mode);
+
+ const rateHkdToRmb = data.rate || 0; // 娓竵鍏戜汉姘戝竵 (渚嬪 0.91)
+
+ // 璁$畻 浜烘皯甯佸厬娓竵 (1 / 0.91)锛屼繚鐣�4浣嶅皬鏁�
+ const rateRmbToHkd = rateHkdToRmb !== 0
+ ? Number((1 / rateHkdToRmb).toFixed(4))
+ : 0;
+
+ // 3. 缁勮鏈�缁堢殑 statistics 瀵硅薄
+ const currentRate = data.rate || 0;
+ statistics.value = {
+ ...data,
+ rateRmb: rateRmbToHkd,
+ ...calcRes, // 灏嗚绠楀嚭鐨� receivable 鍜� amountReceivable 鍚堝苟杩涘幓
+ // 鑷姩璁$畻鎬婚噾棰濓紙浠ヤ汉姘戝竵涓哄噯 = 浜烘皯甯侀儴鍒� + 娓竵閮ㄥ垎 * 姹囩巼锛�
+ totalAmountRmb: Number((calcRes.receivable + calcRes.amountReceivable * currentRate).toFixed(2)),
+ // 鑷姩璁$畻鎬婚噾棰濓紙浠ユ腐甯佷负鍑� = 娓竵閮ㄥ垎 + 浜烘皯甯侀儴鍒� / 姹囩巼锛�
+ totalAmountHkd: currentRate !== 0
+ ? Number((calcRes.amountReceivable + calcRes.receivable / currentRate).toFixed(2))
+ : 0
+ };
}
+};
+
+/**
+ * 璁$畻璐﹀崟缁熻鏁版嵁
+ * @param list 鎷嗗垎鍚庣殑鏄庣粏鍒楄〃
+ * @param mode 褰撳墠妯″紡锛氬簲鏀舵垨搴斾粯
+ */
+const calculateStatistics = (list: any[], mode: 'receivable' | 'payable') => {
+ let rmbTotal = 0;
+ let hkdTotal = 0;
+
+ list.forEach(item => {
+ // 鏍规嵁妯″紡纭畾鍙栧�煎瓧娈�
+ const amount = mode === 'receivable' ? item.receivableAmount : item.payableAmount;
+ const val = Number(amount) || 0;
+
+ if (item.currency === 'RMB') {
+ rmbTotal += val;
+ } else if (item.currency === 'HKD') {
+ hkdTotal += val;
+ }
+ });
+
+ // 杩斿洖璁$畻缁撴灉锛屼繚鐣欎袱浣嶅皬鏁帮紙閬垮厤娴偣璇樊锛�
+ return {
+ receivable: Number(rmbTotal.toFixed(2)), // 瀵瑰簲浣犳ā鏉夸腑鐨� statistics.receivable
+ amountReceivable: Number(hkdTotal.toFixed(2)) // 瀵瑰簲浣犳ā鏉夸腑鐨� statistics.amountReceivable
+ };
};
// 3. 纭鐢熸垚鎸夐挳閫昏緫
const handleConfirm = async () => {
@@ -242,4 +289,9 @@
width: 180px;
background-color: #f5f7fa;
}
+::v-deep .el-descriptions__body .el-descriptions__table.is-bordered .el-descriptions__cell {
+ border: var(--el-descriptions-table-border);
+ padding: 8px 11px;
+ width: 200px;
+}
</style>
\ No newline at end of file
--
Gitblit v1.8.0