diff --git a/src/views/modules/inspection/inspectionRequestList.vue b/src/views/modules/inspection/inspectionRequestList.vue index c131a81..5e5e899 100644 --- a/src/views/modules/inspection/inspectionRequestList.vue +++ b/src/views/modules/inspection/inspectionRequestList.vue @@ -101,7 +101,7 @@ style="width: 100px; height: 100px"/> - + @@ -1513,14 +1514,14 @@ export default { { userId: this.$store.state.user.name, functionId: this.functionId, - serialNumber: 'InspectionTable1InspectAddress', + serialNumber: 'InspectionTable1Status', tableId: 'InspectionTable1', tableName: '检验申请单', - columnProp: 'inspectAddress', + columnProp: 'status', headerAlign: 'center', - align: 'left', - columnLabel: '验货地址', - columnWidth: '200', + align: 'center', + columnLabel: '状态', + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, @@ -1528,17 +1529,18 @@ export default { status: true, fixed: false }, + { userId: this.$store.state.user.name, functionId: this.functionId, - serialNumber: 'InspectionTable1InspectCityShort', + serialNumber: 'InspectionTable1QcOperator', tableId: 'InspectionTable1', tableName: '检验申请单', - columnProp: 'inspectCityShort', + columnProp: 'qcOperator', headerAlign: 'center', align: 'left', - columnLabel: '城市简称', - columnWidth: '120', + columnLabel: 'QC人员', + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, @@ -1549,14 +1551,14 @@ export default { { userId: this.$store.state.user.name, functionId: this.functionId, - serialNumber: 'InspectionTable1Contact', + serialNumber: 'InspectionTable1InspectAddress', tableId: 'InspectionTable1', tableName: '检验申请单', - columnProp: 'inspectContract', + columnProp: 'inspectAddress', headerAlign: 'center', align: 'left', - columnLabel: '联系人', - columnWidth: '150', + columnLabel: '验货地址', + columnWidth: '200', columnHidden: false, columnImage: false, columnSortable: false, @@ -1567,14 +1569,14 @@ export default { { userId: this.$store.state.user.name, functionId: this.functionId, - serialNumber: 'InspectionTable1Remark', + serialNumber: 'InspectionTable1InspectCityShort', tableId: 'InspectionTable1', tableName: '检验申请单', - columnProp: 'remark', + columnProp: 'inspectCityShort', headerAlign: 'center', align: 'left', - columnLabel: '备注', - columnWidth: '150', + columnLabel: '城市简称', + columnWidth: '120', columnHidden: false, columnImage: false, columnSortable: false, @@ -1585,14 +1587,14 @@ export default { { userId: this.$store.state.user.name, functionId: this.functionId, - serialNumber: 'InspectionTable1Status', + serialNumber: 'InspectionTable1Contact', tableId: 'InspectionTable1', tableName: '检验申请单', - columnProp: 'status', + columnProp: 'inspectContract', headerAlign: 'center', - align: 'center', - columnLabel: '状态', - columnWidth: '100', + align: 'left', + columnLabel: '联系人', + columnWidth: '150', columnHidden: false, columnImage: false, columnSortable: false, @@ -1600,25 +1602,25 @@ export default { status: true, fixed: false }, - { userId: this.$store.state.user.name, functionId: this.functionId, - serialNumber: 'InspectionTable1QcOperator', + serialNumber: 'InspectionTable1Remark', tableId: 'InspectionTable1', tableName: '检验申请单', - columnProp: 'qcOperator', + columnProp: 'remark', headerAlign: 'center', align: 'left', - columnLabel: 'QC人员', - columnWidth: '100', + columnLabel: '备注', + columnWidth: '150', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: false - } + }, + ] } }, @@ -1671,9 +1673,31 @@ export default { this.height = calculatedHeight this.detailHeight = calculatedHeight this.initPageData() + // 页面首次渲染后绑定窗口变化监听,保障fixed列在窗口变化后自动重排 - rqrq + this.bindMainTableResizeListener() }) }, + beforeDestroy () { + // 组件销毁时及时解绑监听,避免重复绑定造成多次重排与性能浪费 - rqrq + this.removeMainTableResizeListener() + }, methods: { + // 统一处理主表布局重算:修复固定列与正文列在缩放/滚动后偶发错位 - rqrq + handleMainTableResize () { + this.$nextTick(() => { + if (this.$refs.mainTable) { + this.$refs.mainTable.doLayout() + } + }) + }, + // 绑定窗口尺寸监听:窗口变化后触发表格重排 - rqrq + bindMainTableResizeListener () { + window.addEventListener('resize', this.handleMainTableResize) + }, + // 解绑窗口尺寸监听:防止组件重复创建后出现重复回调 - rqrq + removeMainTableResizeListener () { + window.removeEventListener('resize', this.handleMainTableResize) + }, /** * 页面初始化入口: * - 通用模式:直接查询; @@ -1935,6 +1959,8 @@ export default { this.$nextTick(() => { if (this.$refs.mainTable) { + // 固定列与主表在数据刷新后偶发错位,先触发布局重算再处理选择态 - rqrq + this.$refs.mainTable.doLayout() this.$refs.mainTable.clearSelection() } }) @@ -3824,6 +3850,94 @@ export default { }) }, + // 操作列导出验货结果Excel:后端按模板填充后直接下载xlsx - rqrq + async exportInspectionResultExcel (row) { + // 1) 基础参数校验:确保当前行存在有效申请单号 - rqrq + if (!row || !row.requestNo) { + this.$message.warning('数据异常,无法导出验货结果Excel') + return + } + + // 2) site显式传参:业务唯一来源为前端登录态site,不再使用行数据兜底 - rqrq + const requestSite = this.$store.state.user.site + if (!requestSite) { + this.$message.warning('站点不能为空,无法导出验货结果Excel') + return + } + + // 3) 调用后端Excel导出接口,返回blob并下载为xlsx - rqrq + try { + const response = await this.$http({ + url: this.$http.adornUrl(`/inspection/exportInspectResultExcel/${row.requestNo}`), + method: 'get', + params: { site: requestSite }, + responseType: 'blob' + }) + + const responseBlob = response.data + const responseContentType = String( + (response.headers && (response.headers['content-type'] || response.headers['Content-Type'])) || '' + ).toLowerCase() + + // 4) 兼容后端异常响应:若是json/文本,读取错误信息并提示,不下载错误文件 - rqrq + if (responseContentType.includes('application/json') || responseContentType.includes('text/plain') || responseContentType.includes('text/html')) { + const errorText = await this.readBlobAsText(responseBlob) + const errorMessage = this.extractBlobErrorMessage(errorText) + this.$message.error(errorMessage || '导出验货结果Excel失败,请稍后重试') + return + } + + // 5) 下载有效Excel文件 - rqrq + const blob = new Blob([responseBlob], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) + const downloadUrl = window.URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = downloadUrl + link.download = `验货结果_${row.requestNo}.xlsx` + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + window.URL.revokeObjectURL(downloadUrl) + this.$message.success('导出验货结果Excel成功') + } catch (error) { + console.error('导出验货结果Excel失败:', error) + this.$message.error('导出验货结果Excel失败,请稍后重试') + } + }, + + // 读取Blob文本内容:用于解析后端错误响应 - rqrq + readBlobAsText (blob) { + return new Promise((resolve) => { + if (!blob) { + resolve('') + return + } + const fileReader = new FileReader() + fileReader.onload = () => resolve(String(fileReader.result || '')) + fileReader.onerror = () => resolve('') + fileReader.readAsText(blob, 'utf-8') + }) + }, + + // 提取后端错误信息:兼容 {"msg":"..."} 或纯文本错误 - rqrq + extractBlobErrorMessage (rawText) { + if (!rawText) { + return '' + } + const normalizedText = String(rawText).trim() + if (!normalizedText) { + return '' + } + try { + const parsed = JSON.parse(normalizedText) + if (parsed && parsed.msg) { + return parsed.msg + } + } catch (e) { + // 非JSON文本按原样回传 - rqrq + } + return normalizedText.length > 200 ? normalizedText.substring(0, 200) : normalizedText + }, + executeApplyChangeRequest (requestNo, changeRemark) { this.applyChangeLoading = true applyChangeInspectionRequest(requestNo, { changeRemark }).then(({ data }) => { @@ -3904,6 +4018,27 @@ export default { overflow-x: hidden; } +/* 主表固定列偶发“透明/叠层”修复:统一固定列背景并约束单元格单行,避免主表与fixed列行高漂移 - rqrq */ +.customer-css /deep/ .el-table__fixed, +.customer-css /deep/ .el-table__fixed-right, +.customer-css /deep/ .el-table__fixed-right-patch { + background-color: #fff; +} + +/* 固定列正文单元格始终白底,避免看到下层正文产生“透明”错觉 - rqrq */ +.customer-css /deep/ .el-table__fixed-body-wrapper td, +.customer-css /deep/ .el-table__fixed-right .el-table__fixed-body-wrapper td { + background-color: #fff; +} + +/* 主表与固定列统一单行展示,减少行高不一致导致的视觉错位 - rqrq */ +.customer-css /deep/ .el-table__body-wrapper .cell, +.customer-css /deep/ .el-table__fixed-body-wrapper .cell { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + /deep/ .customer-tab .el-tabs__content { padding: 5px !important; }