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 @@
-
+
- {{ safeState(row).text }}
+
+ {{ safeState(row).text }}
+
@@ -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];