| | |
| | | </el-descriptions> |
| | | |
| | | <h3 style="margin-top: 20px;">订单明细</h3> |
| | | <!-- 明细表格搜索栏 --> |
| | | <div class="search-container" style="margin: 20px 0; padding: 15px; background: #f5f7fa; border-radius: 4px;"> |
| | | <el-form :inline="true" class="search-form"> |
| | | <div class="search-item"> |
| | | <span class="search-label">客户SKU:</span> |
| | | <el-input |
| | | v-model="detailSearch.standby3" |
| | | placeholder="请输入客户SKU" |
| | | clearable |
| | | style="width: 180px;" |
| | | @input="handleDetailSearch" |
| | | @keyup.enter.native="handleDetailSearch" |
| | | ></el-input> |
| | | </div> |
| | | <div class="search-item"> |
| | | <span class="search-label">采购单号:</span> |
| | | <el-input |
| | | v-model="detailSearch.boxType3" |
| | | placeholder="请输入采购单号" |
| | | clearable |
| | | style="width: 180px;" |
| | | @input="handleDetailSearch" |
| | | @keyup.enter.native="handleDetailSearch" |
| | | ></el-input> |
| | | </div> |
| | | <!-- <div class="search-actions" style="margin-left: auto;">--> |
| | | <!-- <el-button type="primary" icon="el-icon-search" @click="handleDetailSearch">搜索</el-button>--> |
| | | <!-- <el-button icon="el-icon-refresh" @click="handleDetailReset">重置</el-button>--> |
| | | <!-- </div>--> |
| | | </el-form> |
| | | </div> |
| | | <el-table |
| | | border |
| | | :data="tableDataB" |
| | | ref="detailTable" |
| | | :data="filteredTableDataB" |
| | | style="width: 100%" |
| | | v-loading="detailLoading"> |
| | | <el-table-column prop="id" label="id" min-width="50" align="center"></el-table-column> |
| | |
| | | <el-table-column prop="anfme" label="数量" min-width="80" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-input-number |
| | | v-model="scope.row.anfme" |
| | | v-model="scope.row.anfmeRow" |
| | | :min="0" |
| | | :precision="0" |
| | | controls-position="right" |
| | |
| | | cstmrName: '', |
| | | settle: '' |
| | | }, |
| | | detailSearch: { |
| | | standby3: '', |
| | | boxType3: '' |
| | | }, |
| | | // 新增:用于缓存原始明细数据(分页加载后的完整当前页数据) |
| | | originalTableDataB: [], |
| | | // 排序相关 |
| | | orderByField: '', |
| | | orderByType: 'asc', |
| | |
| | | }, |
| | | created() { |
| | | this.init(); |
| | | }, |
| | | computed: { |
| | | // 明细表格过滤后的数据 |
| | | filteredTableDataB() { |
| | | if (!this.originalTableDataB || this.originalTableDataB.length === 0) { |
| | | return []; |
| | | } |
| | | |
| | | let data = this.originalTableDataB; |
| | | |
| | | // 客户SKU 模糊搜索(不区分大小写) |
| | | if (this.detailSearch.standby3 && this.detailSearch.standby3.trim()) { |
| | | const keyword = this.detailSearch.standby3.trim().toLowerCase(); |
| | | data = data.filter(item => |
| | | item.standby3 && item.standby3.toLowerCase().includes(keyword) |
| | | ); |
| | | } |
| | | |
| | | // 采购单号 模糊搜索 |
| | | if (this.detailSearch.boxType3 && this.detailSearch.boxType3.trim()) { |
| | | const keyword = this.detailSearch.boxType3.trim().toLowerCase(); |
| | | data = data.filter(item => |
| | | item.boxType3 && item.boxType3.toLowerCase().includes(keyword) |
| | | ); |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | }, |
| | | methods: { |
| | | init() { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 获取子表B数据 |
| | | getTableDataB(orderNo) { |
| | | let that = this; |
| | | that.detailLoading = true; |
| | | |
| | | let params = { |
| | | order_no: orderNo, |
| | | curr: that.detailCurrentPage, |
| | | limit: that.detailPageSize |
| | | }; |
| | | |
| | | $.ajax({ |
| | | url: baseUrl + "/order/pakin/orderDetl/list/auth", |
| | | headers: { |
| | |
| | | if (res.code === 200 || res.success) { |
| | | that.tableDataB = res.data.records || []; |
| | | that.detailTotal = res.data.total || 0; |
| | | |
| | | // 初始化数量缓存 |
| | | that.modifiedQuantities = {}; |
| | | that.originalTableDataB = [...res.data.records || []]; // 新增:保存原始数据用于过滤 |
| | | // ============ 新增:设置数量默认值为 ERP下发数量 - 待下发数量 ============ |
| | | that.tableDataB.forEach(item => { |
| | | // 假设后端返回的字段名是 erpAnfme(ERP下发数量)和 sortingAnfme(待下发数量) |
| | | // 如果字段名不同,请替换成实际的 |
| | | const erpQty = parseInt(item.anfme) || 0; // ERP下发数量 |
| | | const pendingQty = parseInt(item.sortingAnfme) || 0; // 待下发数量 |
| | | |
| | | // 计算默认数量:ERP总量 - 已待下发 = 还可修改/下发的数量 |
| | | const defaultQty = erpQty - pendingQty; |
| | | |
| | | // 设置输入框默认值(确保 >= 0) |
| | | that.$set(item, 'anfmeRow', Math.max(0, defaultQty)); |
| | | |
| | | // 同时初始化 modifiedQuantities 缓存 |
| | | const itemKey = that.getItemKey(item); |
| | | that.$set(that.modifiedQuantities, itemKey, item.anfme); |
| | | that.$set(that.modifiedQuantities, itemKey, Math.max(0, defaultQty)); |
| | | }); |
| | | // ========================================================================== |
| | | |
| | | } else { |
| | | that.$message.error(res.msg || '获取数据失败'); |
| | | that.tableDataB = []; |
| | |
| | | }, |
| | | error: function() { |
| | | that.detailLoading = false; |
| | | // 模拟数据 |
| | | // 模拟数据也加上默认值逻辑(可选) |
| | | that.mockTableBData(); |
| | | // 如果你有 mock 数据,也建议在这里加上同样的计算逻辑 |
| | | } |
| | | }); |
| | | }, |
| | | // // 获取子表B数据 |
| | | // getTableDataB(orderNo) { |
| | | // let that = this; |
| | | // that.detailLoading = true; |
| | | // |
| | | // let params = { |
| | | // order_no: orderNo, |
| | | // curr: that.detailCurrentPage, |
| | | // limit: that.detailPageSize |
| | | // }; |
| | | // |
| | | // $.ajax({ |
| | | // url: baseUrl + "/order/pakin/orderDetl/list/auth", |
| | | // headers: { |
| | | // 'token': localStorage.getItem('token') |
| | | // }, |
| | | // data: params, |
| | | // dataType: 'json', |
| | | // contentType: 'application/json;charset=UTF-8', |
| | | // method: 'get', |
| | | // success: function (res) { |
| | | // if (res.code === 200 || res.success) { |
| | | // that.tableDataB = res.data.records || []; |
| | | // that.detailTotal = res.data.total || 0; |
| | | // |
| | | // // 初始化数量缓存 |
| | | // that.modifiedQuantities = {}; |
| | | // that.tableDataB.forEach(item => { |
| | | // const itemKey = that.getItemKey(item); |
| | | // that.$set(that.modifiedQuantities, itemKey, item.anfme); |
| | | // }); |
| | | // } else { |
| | | // that.$message.error(res.msg || '获取数据失败'); |
| | | // that.tableDataB = []; |
| | | // that.detailTotal = 0; |
| | | // } |
| | | // that.detailLoading = false; |
| | | // }, |
| | | // error: function() { |
| | | // that.detailLoading = false; |
| | | // // 模拟数据 |
| | | // that.mockTableBData(); |
| | | // } |
| | | // }); |
| | | // }, |
| | | |
| | | // 获取商品唯一标识 |
| | | getItemKey(item) { |
| | |
| | | |
| | | // 提交修改到后台 |
| | | submitModify(orderNo, id, anfme,inspect) { |
| | | // 显示加载状态 |
| | | const loadingInstance = this.$loading({ |
| | | lock: true, |
| | | text: '提交修改中...', |
| | |
| | | url: baseUrl + "/order/pakin/orderDetl/batch/report/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: top.reObject({ |
| | | orderNo: orderNo, // 组货单号 |
| | | id: id, // id |
| | | anfme: anfme, // 箱号 |
| | | inspect: inspect // 箱号 |
| | | orderNo: orderNo, |
| | | id: id, |
| | | anfme: anfme, |
| | | inspect: inspect, // 0 或 1 |
| | | }), |
| | | method: 'POST', |
| | | success: (res) => { |
| | | loadingInstance.close(); |
| | | |
| | | if (res.code === 200 || res.success) { |
| | | this.$message({ |
| | | message: `修改成功!订单号: ${orderNo}, id: ${id}`, |
| | | type: 'success', |
| | | duration: 3000 |
| | | }); |
| | | |
| | | this.getTableDataB(groupOrderNo); |
| | | this.getTableDataB(orderNo);// |
| | | // 不需要重新加载整页数据(避免丢失用户修改的数量) |
| | | } else { |
| | | this.$message.error(res.msg || '修改失败'); |
| | | } |
| | |
| | | this.detailDialogVisible = true; |
| | | this.detailCurrentPage = 1; |
| | | this.settleA = row.settle; |
| | | // 清空缓存 |
| | | this.modifiedQuantities = {}; |
| | | this.deletedRecords = []; |
| | | |
| | | // 新增:清空明细搜索 |
| | | this.detailSearch.standby3 = ''; |
| | | this.detailSearch.boxType3 = ''; |
| | | |
| | | this.getTableDataB(row.orderNo); |
| | | }, |
| | | |