From 2ee183769aef0c317e110250f57edd1319b9756a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Thu, 5 Nov 2026 14:18:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E4=BB=B7=E6=A0=BC=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/supplier/priceSheetReport.vue | 90 ++++++++++++------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/src/views/modules/supplier/priceSheetReport.vue b/src/views/modules/supplier/priceSheetReport.vue index e0642c2..2d0b28c 100644 --- a/src/views/modules/supplier/priceSheetReport.vue +++ b/src/views/modules/supplier/priceSheetReport.vue @@ -63,6 +63,7 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -197,7 +182,8 @@ export default { hasExportPermission: false, tableHeight: 520, tabState: { - priceList: createTabState(), + // columns 只给第一页签使用,内容是存储过程返回的列名 - rqrq + priceList: Object.assign(createTabState(), { columns: [] }), handlingCharge: createTabState(), paymentTerms: createTabState() } @@ -297,14 +283,20 @@ export default { state.limit = Number(page.pageSize || state.limit) state.total = Number(page.totalCount || 0) state.loaded = true + // 第一页签的行是按列顺序排列的数组,表头单独放在 columns - rqrq + if (tabName === 'priceList') { + state.columns = Array.isArray(data.columns) ? data.columns : [] + } } else { state.rows = [] state.total = 0 + if (tabName === 'priceList') state.columns = [] this.$message.error((data && data.msg) || '查询失败') } }).catch(() => { state.rows = [] state.total = 0 + if (tabName === 'priceList') state.columns = [] this.$message.error('查询失败') }).finally(() => { state.loading = false @@ -342,6 +334,18 @@ export default { this.tabState[tabName].page = value this.loadTab(tabName) }, + /** + * 价格单导出文件名。 + * 格式:new price list SRM + 年月日时分秒,例如 new price list SRM20261105140230.xlsx。 + * 时间取点击导出时的本地时间。后端响应头使用同一格式,这里显式指定是为了覆盖浏览器默认名。 + */ + buildExportFileName () { + const now = new Date() + const pad = value => String(value).padStart(2, '0') + const timestamp = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}` + return `new price list SRM${timestamp}.xlsx` + }, + // 导出仍提交当前筛选。第一页签由后端忽略分页并调用同一存储过程取全量 - rqrq handleExport () { this.exportLoading = true exportPriceSheetReport(this.buildQuery()).then(async response => { @@ -367,7 +371,8 @@ export default { const url = window.URL.createObjectURL(blob) const link = document.createElement('a') link.href = url - link.download = '价格单报表.xlsx' + // 下载名与后端响应头一致:new price list SRM + 年月日时分秒 - rqrq + link.download = this.buildExportFileName() document.body.appendChild(link) link.click() document.body.removeChild(link) @@ -382,10 +387,27 @@ export default { formatNumberCell (row, column, value) { return value === null || value === undefined || value === '' ? '' : value }, - formatDollarCell (row, column, value) { - if (value === null || value === undefined || value === '') return '' - const amount = Number(value) - return Number.isFinite(amount) ? `$${amount.toFixed(4)}` : '' + /** + * 第一页签单元格。 + * 行数据是数组,按下标取值。空值显示空白。 + * 满箱数等已经在存储过程里格式化的文本,这里不再改小数位。 + */ + formatDynamicCell (row, columnIndex) { + if (!Array.isArray(row) || columnIndex < 0 || columnIndex >= row.length) return '' + const value = row[columnIndex] + return value === null || value === undefined ? '' : value + }, + /** + * 按表头文字给动态列一个可读宽度。 + * 中文按两个字符估算,避免交期列标题被挤掉。 + */ + dynamicColumnWidth (label) { + const text = String(label || '') + let visualLength = 0 + for (let index = 0; index < text.length; index++) { + visualLength += text.charCodeAt(index) > 127 ? 2 : 1 + } + return Math.max(120, Math.min(260, visualLength * 10 + 36)) }, readBlobAsText (blob) { return new Promise(resolve => {