diff --git a/src/api/wms/sellout.js b/src/api/wms/sellout.js index 37d2b36..6126e6d 100644 --- a/src/api/wms/sellout.js +++ b/src/api/wms/sellout.js @@ -8,6 +8,14 @@ export function listSellout(query) { params: query }); } +// 查询成品销售出库列表 +export function listSelloutlistRE(query) { + return request({ + url: '/wms/sellout/listRE', + method: 'get', + params: query + }); +} // 查询成品销售出库详细 export function getSellout(id) { @@ -25,6 +33,14 @@ export function addSellout(data) { data: data }); } +// 新增成品销售出库 +export function addRE(data) { + return request({ + url: '/wms/sellout/addRE', + method: 'post', + data: data + }); +} // 修改成品销售出库 export function updateSellout(data) { diff --git a/src/views/wms/odsRawOrderIn/index.vue b/src/views/wms/odsRawOrderIn/index.vue index c58f7e2..71f13fd 100644 --- a/src/views/wms/odsRawOrderIn/index.vue +++ b/src/views/wms/odsRawOrderIn/index.vue @@ -118,6 +118,15 @@ + + + + + + + @@ -287,6 +225,8 @@ import { listSellout, getSellout, + addRE, + listSelloutlistRE, delSellout, addSellout, updateSellout } from "@/api/wms/sellout"; @@ -309,11 +249,17 @@ total: 0, // 成品销售出库表格数据 selloutList: [], + materialList: [], // 领料单数据 // 弹出层标题 title: "", // 是否显示弹出层 open: false, + showMaterialDialog: false, // 领料单信息弹窗状态 + addoutorderList: [], // 查询参数 + currentPage: 1, // 当前页码 + pageSize: 10, // 每页显示的条目数 + totalMaterials: 0, // 领料单总数 queryParams: { pageNum: 1, pageSize: 10, @@ -365,12 +311,15 @@ /** 查询成品销售出库列表 */ getList() { this.loading = true; - listSellout(this.queryParams).then(response => { + listSelloutlistRE(this.queryParams).then(response => { this.selloutList = response.rows; this.total = response.total; this.loading = false; }); }, + indexMethod(index) { + return index + 1; + }, // 取消按钮 cancel() { this.open = false; @@ -424,28 +373,148 @@ this.queryParams.pageNum = 1; this.getList(); }, + handleMaterialSelectionChange(selection) { + this.selectedMaterials = selection; // 记录选中的领料单 + }, + async submitForm() { + const payload = this.addoutorderList.map(item => ({ + id: item.id, + })); + + console.log("payload:", payload); // 使用逗号分隔符来打印对象 + + try { + await this.$confirm('确认生成备货单吗?', '确认', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'info' + }); + + // 调用接口提交数据 + const response = await addRE(payload); + this.$message.success('备货单生成成功'); + this.open = false; // 关闭对话框 + this.addoutorderList = []; // 清空列表或根据需求更新 + } catch (error) { + if (error === 'cancel') { + this.$message.info('已取消提交'); + } else { + console.error('提交失败:', error); + this.$message.error('提交失败,请重试'); + } + } + this.getList(); + }, /** 重置按钮操作 */ + resetQuery() { this.resetForm("queryForm"); this.handleQuery(); }, + handleSelectionChange1(selection) { + this.ids = selection.map(item => item.id) + this.single = selection.length !== 1 + this.multiple = !selection.length + this.selectedRows = selection; + }, // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map(item => item.id) this.single = selection.length !== 1 this.multiple = !selection.length }, - /** 新增按钮操作 */ - handleAdd() { - this.reset(); - this.open = true; - this.title = "添加成品销售出库"; - }, + handlequeryform() { + this.showMaterialDialog = true; // 显示领料单信息弹窗 + this.fetchMaterials(); // 加载领料单数据 + // this.queryParams1.pageNum = 1; + // this.getList1(); + }, + handleCurrentChange(page) { + this.currentPage = page; // 更新当前页码 + this.fetchMaterials(page); // 重新加载材料数据 + }, + + /** 新增按钮操作 */ + handleAdd() { + this.reset(); + this.open = true; + this.title = "生成备货单"; + this.queryParams1 = {} + this.addoutorderList = [] + }, + async confirmMaterialSelection() { + const materialsToAdd = []; // 临时存储待添加的材料信息 + for (const material of this.selectedMaterials) { + try { + materialsToAdd.push({ + id: material.id, + deliveryOrder: material.deliveryOrder, + itemNumber: material.itemNumber, + productName: material.productName, + productCode: material.productCode, + unitOfMeasure: material.unitOfMeasure, + lotNumber: material.lotNumber, + planQuantity: material.planQuantity, + outDate: material.outDate, + attr4: material.attr4, + attr3: material.attr3, + attr6: material.attr6, + attr5: material.attr5, + attr7: material.attr7 + }); + } catch (error) { + console.error('Error fetching batches:', error); + } + } + // 将待添加的材料一次性添加到 addoutorderList 中 + this.addoutorderList = this.addoutorderList.concat(materialsToAdd); + console.log("Materials processed"); + this.showMaterialDialog = false; // 关闭领料单弹窗 + }, + deleteOutOrder(row) { + // 确认删除操作 + this.$confirm('确认删除该装运单吗?', '警告', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + // 从 addoutorderList 中删除选定的行 + this.addoutorderList = this.addoutorderList.filter(item => item !== row); + this.$message.success('删除成功!'); + }).catch(() => { + this.$message.info('已取消删除'); + }); + }, formatProductCode(code) { // 检查是否有效,去掉前7个零 if (!code) return code; // 处理 null 或 undefined 情况 return code.replace(/^0{1,7}/, ''); // 替换前1到7个0 }, + /** 重置按钮操作 */ + async fetchMaterials(pageNum = 1) { // 这里的参数名称为 pageNum + this.loading = true; // 显示加载状态 + try { + const response = await listSellout({ + ...this.queryParams, // 假设 queryParams 包含其他查询条件 + pageNum: pageNum, // 将当前页码传递给后端 + pageSize: this.pageSize // 确保将每页显示的数量传递给后端 + }); + + // 更新物料列表,并计算索引 + this.materialList = response.rows.map((item, index) => { + item.index = (pageNum - 1) * this.pageSize + index + 1; // 更新索引 + return item; + }); + + this.totalMaterials = response.total; // 更新总条目数 + } catch (error) { + console.error('获取装运单失败:', error); + this.$message.error('加载装运单失败,请稍后重试。'); + } finally { + this.loading = false; // 隐藏加载状态 + } + } + , /** 修改按钮操作 */ handleUpdate(row) { this.reset();