|
|
@@ -149,7 +149,7 @@
|
|
|
<el-table-column
|
|
|
v-if="isColumnVisible('customerName')"
|
|
|
label="客户名称"
|
|
|
- align="center"
|
|
|
+ align="left"
|
|
|
prop="customerName"
|
|
|
min-width="180"
|
|
|
show-overflow-tooltip
|
|
|
@@ -1603,6 +1603,65 @@ const generateQuoteTemplate = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): s
|
|
|
return str.split('').join(' ');
|
|
|
};
|
|
|
|
|
|
+ // 辅助函数:将数字转换为人民币大写(适用于展示合计金额)
|
|
|
+ const numberToRMBUpper = (n: number | string): string => {
|
|
|
+ const num = Number(n) || 0;
|
|
|
+ if (num === 0) return '零元整';
|
|
|
+ const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
|
|
+ const unitMajor = ['', '万', '亿'];
|
|
|
+ const unitMinor = ['', '拾', '佰', '仟'];
|
|
|
+ let head = num < 0 ? '负' : '';
|
|
|
+ let money = Math.abs(Math.round(num * 100));
|
|
|
+ const integer = Math.floor(money / 100);
|
|
|
+ const dec = money % 100;
|
|
|
+
|
|
|
+ let s = '';
|
|
|
+ // integer part
|
|
|
+ if (integer > 0) {
|
|
|
+ let intStr = '';
|
|
|
+ let unitPos = 0;
|
|
|
+ let temp = integer;
|
|
|
+ while (temp > 0) {
|
|
|
+ let section = temp % 10000;
|
|
|
+ let sectionStr = '';
|
|
|
+ let pos = 0;
|
|
|
+ // iterate only while there are digits in this section to avoid leading zeros
|
|
|
+ while (section > 0 && pos < 4) {
|
|
|
+ const v = section % 10;
|
|
|
+ if (v !== 0) {
|
|
|
+ sectionStr = digit[v] + (pos ? unitMinor[pos] : '') + sectionStr;
|
|
|
+ } else if (sectionStr && !sectionStr.startsWith('零')) {
|
|
|
+ sectionStr = '零' + sectionStr;
|
|
|
+ }
|
|
|
+ section = Math.floor(section / 10);
|
|
|
+ pos++;
|
|
|
+ }
|
|
|
+ if (sectionStr) {
|
|
|
+ const major = unitMajor[unitPos] || '';
|
|
|
+ intStr = sectionStr + major + intStr;
|
|
|
+ }
|
|
|
+ temp = Math.floor(temp / 10000);
|
|
|
+ unitPos++;
|
|
|
+ }
|
|
|
+ s += intStr.replace(/零+/g, '零').replace(/零$/, '');
|
|
|
+ s += '元';
|
|
|
+ } else {
|
|
|
+ s += '零元';
|
|
|
+ }
|
|
|
+
|
|
|
+ // decimal part
|
|
|
+ if (dec === 0) {
|
|
|
+ s += '整';
|
|
|
+ } else {
|
|
|
+ const jiao = Math.floor(dec / 10);
|
|
|
+ const fen = dec % 10;
|
|
|
+ if (jiao > 0) s += digit[jiao] + '角';
|
|
|
+ if (fen > 0) s += digit[fen] + '分';
|
|
|
+ }
|
|
|
+
|
|
|
+ return head + s;
|
|
|
+ };
|
|
|
+
|
|
|
// 计算产品总金额
|
|
|
const productTotal =
|
|
|
quote.productList?.reduce((sum, item) => {
|
|
|
@@ -1653,13 +1712,13 @@ const generateQuoteTemplate = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): s
|
|
|
const productRows =
|
|
|
quote.productList
|
|
|
?.map(
|
|
|
- (product, index) => `
|
|
|
+ (product, index) => `
|
|
|
<tr>
|
|
|
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${index + 1}</td>
|
|
|
<td style="padding: 8px; border: 1px solid #000;">${product.productName || ''}</td>
|
|
|
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.model || ''}</td>
|
|
|
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${getDictLabel(product.unit)}</td>
|
|
|
- <td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.quantity || 0}</td>
|
|
|
+ <td style="padding: 8px; border: 1px solid #000; text-align: center;">${formatNumber(product.quantity, 2)}</td>
|
|
|
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatNumber(product.price)}</td>
|
|
|
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatNumber(product.taxAmount)}</td>
|
|
|
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatNumber(product.subtotal)}</td>
|
|
|
@@ -1739,7 +1798,9 @@ const generateQuoteTemplate = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): s
|
|
|
<!-- 合计行 -->
|
|
|
<tr>
|
|
|
<td colspan="2" style="padding: 8px; border: 1px solid #000; background-color: #fff; text-align: center;"><strong>合计(元):</strong></td>
|
|
|
- <td colspan="8" style="padding: 8px; border: 1px solid #000; text-align: center; font-size: 16px;">${formatNumber(productTotal)}</td>
|
|
|
+ <td colspan="8" style="padding: 8px; border: 1px solid #000; text-align: center; font-size: 16px;">
|
|
|
+ ${numberToRMBUpper(productTotal)}(¥${formatNumber(productTotal)})
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|