From 2e22f851a064f1ceb2d5c81f079a8a921080ca8d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 15 Jul 2026 08:18:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BB=93=E5=BA=93=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E6=8A=A5=E8=A1=A8=E6=94=AF=E6=8C=81=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E7=8A=B6=E6=80=81=E8=AE=BE=E5=AE=9A=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=B8=8A=E4=B8=8B=E9=99=90=E5=B9=B6=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E8=87=AA=E5=8A=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- src/api/model/mtm.js | 9 +++ src/views/statistics/material_wh_summary.vue | 80 +++++++++++++++++++- 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/src/api/model/mtm.js b/src/api/model/mtm.js index f040f893..9cabf4f2 100644 --- a/src/api/model/mtm.js +++ b/src/api/model/mtm.js @@ -94,6 +94,15 @@ export default { ); }, }, + setSafe: { + name: "设置安全库存上下限", + req: async function (id, data) { + return await http.put( + `${config.API_URL}/mtm/material/${id}/set_safe/`, + data + ); + }, + }, update: { name: "更新", req: async function (id, data) { diff --git a/src/views/statistics/material_wh_summary.vue b/src/views/statistics/material_wh_summary.vue index c40ddc58..53c10e8a 100644 --- a/src/views/statistics/material_wh_summary.vue +++ b/src/views/statistics/material_wh_summary.vue @@ -17,6 +17,7 @@ end-placeholder="截止时间(当周周末)" :clearable="false" style="margin-right: 12px;" + @change="fetchData" /> 查询 分组维度: 物料型号(model) @@ -52,9 +53,12 @@ - + @@ -100,6 +104,28 @@ + + + + + + {{ safeDialog.block }} / {{ safeDialog.model }} + + + {{ fmtNum(safeDialog.stock) }} + + + + + + + + + + @@ -125,6 +151,16 @@ export default { ds1: [], ds2: [], ds3: [], + safeDialog: { + visible: false, + saving: false, + material_id: null, + block: "", + model: "", + stock: 0, + count_safe: undefined, + count_safe_upper: undefined, + }, }; }, computed: { @@ -236,6 +272,46 @@ export default { this.loading = false; }); }, + // 打开设定弹窗(按型号代表物料 material_id 设置) + openSafe(row) { + if (!row.material_id) { + this.$message.warning("该型号暂无可设定的物料"); + return; + } + const lo = row["安全库存下限"]; + const hi = row["安全库存上限"]; + this.safeDialog = { + visible: true, + saving: false, + material_id: row.material_id, + block: row["区块"], + model: row["型号"], + stock: row["库存量"], + count_safe: lo === null || lo === undefined || lo === "" ? undefined : this.num(lo), + count_safe_upper: hi === null || hi === undefined || hi === "" ? undefined : this.num(hi), + }; + }, + saveSafe() { + const d = this.safeDialog; + if (d.count_safe != null && d.count_safe_upper != null && Number(d.count_safe) > Number(d.count_safe_upper)) { + this.$message.warning("下限不能大于上限"); + return; + } + d.saving = true; + this.$API.mtm.material.setSafe + .req(d.material_id, { + count_safe: d.count_safe === undefined ? null : d.count_safe, + count_safe_upper: d.count_safe_upper === undefined ? null : d.count_safe_upper, + }) + .then(() => { + this.$message.success("设置成功"); + d.visible = false; + this.fetchData(); + }) + .finally(() => { + d.saving = false; + }); + }, mergeFirstCol(rows, key, rowIndex, columnIndex) { if (columnIndex !== 0) return; const cur = rows[rowIndex] && rows[rowIndex][key];