From 3c6ff4ef9b7cf583371f5769b0820b15d5860149 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 13 五月 2026 15:06:28 +0800
Subject: [PATCH] 浪潮 1.添加仓库管理页面 2.入库、出库添加新增编辑功能并联调

---
 src/views/inventoryManagement/stockManagement/Edit.vue |  168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 168 insertions(+), 0 deletions(-)

diff --git a/src/views/inventoryManagement/stockManagement/Edit.vue b/src/views/inventoryManagement/stockManagement/Edit.vue
new file mode 100644
index 0000000..faaa338
--- /dev/null
+++ b/src/views/inventoryManagement/stockManagement/Edit.vue
@@ -0,0 +1,168 @@
+<template>
+  <div>
+    <el-dialog v-model="isShow"
+               title="缂栬緫搴撳瓨"
+               width="800"
+               @close="closeModal">
+      <el-form label-width="140px"
+               :model="formState"
+               label-position="top"
+               ref="formRef">
+        <el-form-item label="浜у搧鍚嶇О"
+                      prop="productName">
+          <el-input v-model="formState.productName" disabled />
+        </el-form-item>
+        <el-form-item label="瑙勬牸"
+                      prop="model">
+          <el-input v-model="formState.model" disabled />
+        </el-form-item>
+        <el-form-item label="鍗曚綅"
+                      prop="unit">
+          <el-input v-model="formState.unit" disabled />
+        </el-form-item>
+        <el-form-item label="鎵瑰彿"
+                      prop="batchNo">
+          <el-input v-model="formState.batchNo" disabled />
+        </el-form-item>
+        <el-form-item label="鍚堟牸搴撳瓨鏁伴噺"
+                      prop="qualifiedQuantity">
+          <el-input-number v-model="formState.qualifiedQuantity"
+                           :step="1"
+                           :min="0"
+                           style="width: 100%" />
+        </el-form-item>
+        <el-form-item label="涓嶅悎鏍煎簱瀛樻暟閲�"
+                      prop="unQualifiedQuantity">
+          <el-input-number v-model="formState.unQualifiedQuantity"
+                           :step="1"
+                           :min="0"
+                           style="width: 100%" />
+        </el-form-item>
+        <el-form-item label="搴撳瓨棰勮鏁伴噺"
+                      prop="warnNum">
+          <el-input-number v-model="formState.warnNum"
+                           :step="1"
+                           :min="0"
+                           style="width: 100%" />
+        </el-form-item>
+        <el-form-item label="澶囨敞"
+                      prop="remark">
+          <el-input v-model="formState.remark"
+                    type="textarea" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button type="primary"
+                     @click="handleSubmit">纭</el-button>
+          <el-button @click="closeModal">鍙栨秷</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup>
+  import { ref, computed, watch, getCurrentInstance } from "vue";
+  import { ElMessage } from "element-plus";
+  import { updateStockInventory } from "@/api/inventoryManagement/stockInventory.js";
+
+  const { proxy } = getCurrentInstance();
+
+  const props = defineProps({
+    visible: {
+      type: Boolean,
+      default: false,
+    },
+    record: {
+      type: Object,
+      default: () => ({}),
+    },
+  });
+
+  const emits = defineEmits(["update:visible", "completed"]);
+
+  const isShow = computed({
+    get: () => props.visible,
+    set: (val) => emits("update:visible", val),
+  });
+
+  const formRef = ref();
+
+  const formState = ref({
+    id: undefined,
+    productId: undefined,
+    productModelId: undefined,
+    productName: "",
+    model: "",
+    unit: "",
+    batchNo: "",
+    qualifiedQuantity: 0,
+    unQualifiedQuantity: 0,
+    warnNum: 0,
+    remark: "",
+  });
+
+  // 鐩戝惉寮圭獥鏄剧ず锛屽洖濉暟鎹�
+  watch(
+    () => props.visible,
+    (val) => {
+      if (val && props.record) {
+        const row = props.record;
+        console.log('缂栬緫鏁版嵁:', row);
+        formState.value.id = row.id;
+        formState.value.productId = row.productId;
+        formState.value.productModelId = row.productModelId;
+        formState.value.productName = row.productName || '';
+        formState.value.model = row.model || '';
+        formState.value.unit = row.unit || '';
+        formState.value.batchNo = row.batchNo || '';
+        formState.value.qualifiedQuantity = row.qualifiedQuantity || 0;
+        formState.value.unQualifiedQuantity = row.unQualifiedQuantity || 0;
+        formState.value.warnNum = row.warnNum || 0;
+        formState.value.remark = row.remark || '';
+      }
+    },
+    { immediate: true }
+  );
+
+  const closeModal = () => {
+    isShow.value = false;
+    resetForm();
+  };
+
+  const resetForm = () => {
+    formState.value = {
+      id: undefined,
+      productId: undefined,
+      productModelId: undefined,
+      productName: "",
+      model: "",
+      unit: "",
+      batchNo: "",
+      qualifiedQuantity: 0,
+      unQualifiedQuantity: 0,
+      warnNum: 0,
+      remark: "",
+    };
+  };
+
+  const handleSubmit = () => {
+    proxy.$refs["formRef"].validate((valid) => {
+      if (valid) {
+        const params = { ...formState.value };
+        updateStockInventory(params)
+          .then(() => {
+            ElMessage.success("缂栬緫鎴愬姛");
+            closeModal();
+            emits("completed");
+          })
+          .catch(() => {
+            ElMessage.error("缂栬緫澶辫触");
+          });
+      }
+    });
+  };
+</script>
+
+<style scoped lang="scss"></style>

--
Gitblit v1.9.3