| | |
| | | gap: 10px; |
| | | margin-left: auto; |
| | | } |
| | | /* 确认上报按钮样式 */ |
| | | .confirm-report-btn { |
| | | border: 2px solid #F56C6C; |
| | | color: #F56C6C; |
| | | font-weight: bold; |
| | | background-color: transparent; |
| | | padding: 10px 20px; |
| | | } |
| | | .confirm-report-btn:hover { |
| | | background-color: #F56C6C; |
| | | color: white; |
| | | } |
| | | .dialog-footer { |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | align-items: center; |
| | | gap: 10px; |
| | | margin-top: 20px; |
| | | } |
| | | /* 二次确认对话框样式 */ |
| | | .confirm-dialog .el-message-box__message { |
| | | text-align: center; |
| | | font-size: 16px; |
| | | line-height: 1.5; |
| | | } |
| | | .confirm-dialog .el-message-box__status { |
| | | font-size: 24px !important; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body> |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <div slot="footer"> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button |
| | | class="confirm-report-btn" |
| | | @click="showConfirmDialog" |
| | | :loading="reportLoading"> |
| | | 确认上报 |
| | | </el-button> |
| | | <el-button @click="closeDetailDialog">关闭</el-button> |
| | | </div> |
| | | </el-dialog> |
| | |
| | | // 加载状态 |
| | | loading: false, |
| | | detailLoading: false, |
| | | reportLoading: false, |
| | | // 原始数据备份(用于搜索) |
| | | originalTableDataA: [] |
| | | }, |
| | |
| | | }, |
| | | methods: { |
| | | init() { |
| | | this.getTableDataA(); |
| | | |
| | | setInterval(() => { |
| | | this.getTableDataA(); |
| | | }, 2000); |
| | | }, 5000); |
| | | }, |
| | | |
| | | // 获取主表A数据 |
| | |
| | | }); |
| | | }, |
| | | |
| | | // 搜索处理[1,5](@ref) |
| | | // 显示二次确认对话框 |
| | | showConfirmDialog() { |
| | | if (!this.currentRow) { |
| | | this.$message.error('没有选择要上报的数据'); |
| | | return; |
| | | } |
| | | |
| | | const groupOrderNo = this.currentRow.A1; |
| | | |
| | | this.$confirm( |
| | | `是否确认开始上报组货单号 <strong style="color: #F56C6C; font-size: 16px;">${groupOrderNo}</strong>?<br/><br/>将生成实际组货单,单一组货单号只能操作一次!!!`, |
| | | '确认上报', |
| | | { |
| | | confirmButtonText: '确认上报', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | dangerouslyUseHTMLString: true, |
| | | customClass: 'confirm-dialog', |
| | | confirmButtonClass: 'confirm-report-btn', |
| | | beforeClose: (action, instance, done) => { |
| | | if (action === 'confirm') { |
| | | instance.confirmButtonLoading = true; |
| | | this.confirmReport(groupOrderNo, done); |
| | | } else { |
| | | done(); |
| | | } |
| | | } |
| | | } |
| | | ).then(() => { |
| | | // 确认上报后的处理在beforeClose中完成 |
| | | }).catch(() => { |
| | | this.$message({ |
| | | type: 'info', |
| | | message: '已取消操作' |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | // 确认上报 |
| | | confirmReport(groupOrderNo, done) { |
| | | this.reportLoading = true; |
| | | |
| | | // 调用后台API上报数据 |
| | | $.ajax({ |
| | | url: baseUrl + "/api/report/confirm", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: JSON.stringify({ |
| | | A1: groupOrderNo // 传递组货单号 |
| | | }), |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'post', |
| | | success: (res) => { |
| | | this.reportLoading = false; |
| | | if (typeof done === 'function') { |
| | | done(); |
| | | } |
| | | |
| | | if (res.code === 200 || res.success) { |
| | | this.$message({ |
| | | message: `组货单号 ${groupOrderNo} 上报成功`, |
| | | type: 'success', |
| | | duration: 3000 |
| | | }); |
| | | // 上报成功后关闭弹窗 |
| | | setTimeout(() => { |
| | | this.closeDetailDialog(); |
| | | }, 1500); |
| | | } else { |
| | | this.$message.error(res.message || '上报失败'); |
| | | } |
| | | }, |
| | | error: (error) => { |
| | | this.reportLoading = false; |
| | | if (typeof done === 'function') { |
| | | done(); |
| | | } |
| | | console.error('上报失败:', error); |
| | | // 模拟上报成功(实际项目中应删除此部分) |
| | | this.mockReportSuccess(groupOrderNo); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 模拟上报成功(实际项目中应删除) |
| | | mockReportSuccess(groupOrderNo) { |
| | | this.$message({ |
| | | message: `组货单号 ${groupOrderNo} 上报成功(模拟)`, |
| | | type: 'success', |
| | | duration: 3000 |
| | | }); |
| | | // 上报成功后关闭弹窗 |
| | | setTimeout(() => { |
| | | this.closeDetailDialog(); |
| | | }, 1500); |
| | | }, |
| | | |
| | | // 搜索处理 |
| | | handleSearch() { |
| | | this.currentPage = 1; |
| | | this.loading = true; |
| | |
| | | // 如果搜索条件为空,显示所有数据 |
| | | this.getTableDataA(); |
| | | } else { |
| | | // 使用前端过滤进行搜索[2,4](@ref) |
| | | // 使用前端过滤进行搜索 |
| | | this.filterTableData(); |
| | | } |
| | | }, |
| | | |
| | | // 前端过滤表格数据[2,4](@ref) |
| | | // 前端过滤表格数据 |
| | | filterTableData() { |
| | | let that = this; |
| | | // 模拟API调用 - 实际项目中可以调用后端搜索接口 |
| | |
| | | }); |
| | | }, |
| | | |
| | | // 前端过滤备选方案[2,4](@ref) |
| | | // 前端过滤备选方案 |
| | | frontendFilter() { |
| | | const filteredData = this.originalTableDataA.filter(item => { |
| | | // 检查每个搜索条件[4](@ref) |
| | | // 检查每个搜索条件 |
| | | const matchA1 = !this.searchForm.A1 || |
| | | (item.A1 && item.A1.toString().toLowerCase().includes(this.searchForm.A1.toLowerCase())); |
| | | const matchA2 = !this.searchForm.A2 || |
| | |
| | | this.loading = false; |
| | | }, |
| | | |
| | | // 重置搜索条件[5](@ref) |
| | | // 重置搜索条件 |
| | | handleReset() { |
| | | this.searchForm = { |
| | | A1: '', |
| | |
| | | this.detailDialogVisible = false; |
| | | this.currentRow = null; |
| | | this.tableDataB = []; |
| | | this.reportLoading = false; |
| | | }, |
| | | |
| | | // 主表分页大小改变 |
| | |
| | | { A1: '1001', A2: '示例数据A2-1', A3: '示例数据A3-1', A4: '示例数据A4-1' }, |
| | | { A1: '1002', A2: '示例数据A2-2', A3: '示例数据A3-2', A4: '示例数据A4-2' }, |
| | | { A1: '1003', A2: '示例数据A2-3', A3: '示例数据A3-3', A4: '示例数据A4-3' }, |
| | | { A1: '10033', A2: '示例数据A2-3', A3: '示例数据A3-3', A4: '示例数据A4-3' }, |
| | | { A1: '100333', A2: '示例数据A2-3', A3: '示例数据A3-3', A4: '示例数据A4-3' }, |
| | | { A1: '10032', A2: '示例数据A2-3', A3: '示例数据A3-3', A4: '示例数据A4-3' }, |
| | | { A1: '10031', A2: '示例数据A2-3', A3: '示例数据A3-3', A4: '示例数据A4-3' }, |
| | | { A1: '100312', A2: '示例数据A2-3', A3: '示例数据A3-3', A4: '示例数据A4-3' }, |
| | | { A1: '1003123', A2: '示例数据A2-3', A3: '示例数据A3-3', A4: '示例数据A4-3' }, |
| | | { A1: '1004', A2: '示例数据A2-4', A3: '示例数据A3-4', A4: '示例数据A4-4' } |
| | | ]; |
| | | this.originalTableDataA = JSON.parse(JSON.stringify(this.tableDataA)); // 备份原始数据 |