From b0bd7dd3557b57a121551697a889a725da24c385 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期三, 14 一月 2026 15:26:59 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_天津军泰伟业' into dev_天津军泰伟业

---
 src/views/productionManagement/productStructure/Detail/index.vue |  293 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/views/procurementManagement/procurementLedger/index.vue      |    4 
 src/views/productionManagement/productStructure/index.vue        |   17 ++
 3 files changed, 309 insertions(+), 5 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 191dfe1..f508e08 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -1316,6 +1316,10 @@
         }
       }
 
+      if (form.value.salesLedgerId == -1) {
+        form.value.salesLedgerId = null;
+      }
+      console.log(form.value, "form.value===========");
       dialogFormVisible.value = true;
     } catch (error) {
       console.error("鎵撳紑琛ㄥ崟澶辫触:", error);
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
new file mode 100644
index 0000000..a131830
--- /dev/null
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -0,0 +1,293 @@
+<template>
+  <div class="app-container">
+    <el-button v-if="dataValue.isEdit"
+               type="primary"
+               @click="addItem"
+               style="margin-bottom: 10px">娣诲姞
+    </el-button>
+    <el-button v-if="!dataValue.isEdit"
+               type="primary"
+               @click="dataValue.isEdit = true"
+               style="margin-bottom: 10px">缂栬緫
+    </el-button>
+    <el-button v-if="dataValue.isEdit"
+               type="primary"
+               @click="cancelEdit"
+               style="margin-bottom: 10px">鍙栨秷
+    </el-button>
+    <el-button type="primary"
+               :loading="dataValue.loading"
+               @click="submit"
+               :disabled="!dataValue.isEdit"
+               style="margin-bottom: 10px">纭
+    </el-button>
+    <el-table
+        :data="tableData"
+        border
+        :preserve-expanded-content="false"
+        style="width: 100%"
+    >
+      <el-table-column type="expand">
+        <template #default="props">
+          <el-form ref="form"
+                   :model="dataValue">
+            <el-table :data="dataValue.dataList"
+                      style="width: 100%">
+              <el-table-column prop="productName"
+                               label="浜у搧"/>
+              <el-table-column prop="model"
+                               label="瑙勬牸">
+                <template #default="{ row, $index }">
+                  <el-form-item v-if="dataValue.isEdit"
+                                :prop="`dataList.${$index}.model`"
+                                :rules="[{ required: true, message: '璇烽�夋嫨瑙勬牸', trigger: ['blur','change'] }]"
+                                style="margin: 0">
+                    <el-select v-model="row.model"
+                               placeholder="璇烽�夋嫨瑙勬牸"
+                               clearable
+                               :disabled="!dataValue.isEdit"
+                               style="width: 100%"
+                               @visible-change="(v) => { if (v) openDialog($index) }">
+                      <el-option v-if="row.model"
+                                 :label="row.model"
+                                 :value="row.model" />
+                    </el-select>
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column prop="processId"
+                               label="娑堣�楀伐搴�">
+                <template #default="{ row, $index }">
+                  <el-form-item :prop="`dataList.${$index}.processId`"
+                                :rules="[{ required: true, message: '璇烽�夋嫨娑堣�楀伐搴�', trigger: 'change' }]"
+                                style="margin: 0">
+                    <el-select v-model="row.processId"
+                               placeholder="璇烽�夋嫨"
+                               filterable
+                               clearable
+                               style="width: 100%"
+                               :disabled="!dataValue.isEdit">
+                      <el-option v-for="item in dataValue.processOptions"
+                                 :key="item.id"
+                                 :label="item.name"
+                                 :value="item.id" />
+                    </el-select>
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column prop="unitQuantity"
+                               label="鍗曚綅浜у嚭鎵�闇�鏁伴噺">
+                <template #default="{ row, $index }">
+                  <el-form-item :prop="`dataList.${$index}.unitQuantity`"
+                                :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣嶄骇鍑烘墍闇�鏁伴噺', trigger: ['blur','change'] }]"
+                                style="margin: 0">
+                    <el-input-number v-model="row.unitQuantity"
+                                     :min="0"
+                                     :precision="2"
+                                     :step="1"
+                                     controls-position="right"
+                                     style="width: 100%"
+                                     :disabled="!dataValue.isEdit" />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column prop="demandedQuantity"
+                               label="闇�姹傛�婚噺">
+                <template #default="{ row, $index }">
+                  <el-form-item :prop="`dataList.${$index}.demandedQuantity`"
+                                :rules="[{ required: true, message: '璇疯緭鍏ラ渶姹傛�婚噺', trigger: ['blur','change'] }]"
+                                style="margin: 0">
+                    <el-input-number v-model="row.demandedQuantity"
+                                     :min="0"
+                                     :precision="2"
+                                     :step="1"
+                                     controls-position="right"
+                                     style="width: 100%"
+                                     :disabled="!dataValue.isEdit" />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column prop="unit"
+                               label="鍗曚綅">
+                <template #default="{ row, $index }">
+                  <el-form-item :prop="`dataList.${$index}.unit`"
+                                :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣�', trigger: ['blur','change'] }]"
+                                style="margin: 0">
+                    <el-input v-model="row.unit"
+                              placeholder="璇疯緭鍏ュ崟浣�"
+                              clearable
+                              :disabled="!dataValue.isEdit" />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column prop="diskQuantity"
+                               label="鐩樻暟锛堢洏锛�">
+                <template #default="{ row, $index }">
+                  <el-form-item :prop="`dataList.${$index}.diskQuantity`"
+                                :rules="[{ required: true, message: '璇疯緭鍏ョ洏鏁�', trigger: ['blur','change'] }]"
+                                style="margin: 0">
+                    <el-input-number v-model="row.diskQuantity"
+                                     :min="0"
+                                     :precision="0"
+                                     :step="1"
+                                     controls-position="right"
+                                     style="width: 100%"
+                                     :disabled="!dataValue.isEdit" />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column label="鎿嶄綔" fixed="right" width="100">
+                <template #default="{ row, $index }">
+                  <el-button type="danger"
+                             text
+                             @click="dataValue.dataList.splice($index, 1)">鍒犻櫎
+                  </el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-form>
+        </template>
+      </el-table-column>
+      <el-table-column label="浜у搧缂栫爜" prop="productCode" />
+      <el-table-column label="浜у搧鍚嶇О" prop="productName" />
+      <el-table-column label="瑙勬牸鍨嬪彿" prop="model" />
+      <el-table-column label="鍗曚綅" prop="unit" />
+    </el-table>
+
+    <product-select-dialog v-if="dataValue.showProductDialog"
+                           v-model:model-value="dataValue.showProductDialog"
+                           @confirm="handleProduct" />
+  </div>
+</template>
+
+<script setup lang="ts">
+import {
+  computed,
+  defineAsyncComponent,
+  defineComponent,
+  onMounted,
+  reactive,
+  ref,
+} from "vue";
+import { queryList, add } from "@/api/productionManagement/productStructure.js";
+import { list } from "@/api/productionManagement/productionProcess";
+import { ElMessage } from "element-plus";
+import {useRoute, useRouter} from "vue-router";
+
+defineComponent({
+  name: "StructureEdit",
+});
+
+const ProductSelectDialog = defineAsyncComponent(
+    () => import("@/views/basicData/product/ProductSelectDialog.vue")
+);
+const form = ref();
+
+const route = useRoute()
+const router = useRouter()
+const routeId = computed({
+  get() {
+    return route.query.id;
+  },
+
+  set(val) {
+    emit('update:router', val)
+  }
+});
+
+
+const dataValue = reactive({
+  dataList: [],
+  productOptions: [],
+  processOptions: [],
+  showProductDialog: false,
+  currentRowIndex: null,
+  loading: false,
+  isEdit: false,
+});
+
+const tableData = reactive([
+  {
+    productName: "",
+    model: "",
+    unit: "",
+    productCode: "",
+  }
+])
+
+const openDialog = index => {
+  dataValue.currentRowIndex = index;
+  dataValue.showProductDialog = true;
+};
+
+const fetchData = async () => {
+  const { data } = await queryList(routeId.value);
+  tableData[0].productName = data.productName;
+  tableData[0].model = data.model;
+  tableData[0].unit = data.unit;
+  tableData[0].productCode = data.productCode;
+  dataValue.dataList = data.productStructureList;
+};
+
+const fetchProcessOptions = async () => {
+  const { data } = await list(routeId.value);
+  dataValue.processOptions = data;
+};
+
+const handleProduct = row => {
+  if (row?.length > 1) {
+    ElMessage.error("鍙兘閫夋嫨涓�涓骇鍝�");
+  }
+  dataValue.dataList[dataValue.currentRowIndex].productName =
+      row[0].productName;
+  dataValue.dataList[dataValue.currentRowIndex].model = row[0].model;
+  dataValue.dataList[dataValue.currentRowIndex].productModelId = row[0].id;
+  dataValue.showProductDialog = false;
+};
+
+const submit = () => {
+  form.value
+      .validate(valid => {
+        dataValue.loading = true;
+        if (valid) {
+          add({
+            parentId: routeId.value,
+            productStructureList: dataValue.dataList || [],
+          }).then(res => {
+            router.push({
+              path: '/productionManagement/productionManagement/productStructure/index',
+            })
+            ElMessage.success("淇濆瓨鎴愬姛");
+            dataValue.loading = false;
+          });
+        }
+      })
+      .finally(() => {
+        dataValue.loading = false;
+      });
+};
+
+const addItem = () => {
+  dataValue.dataList.push({
+    productName: "",
+    productId: "",
+    model: undefined,
+    productModelId: undefined,
+    processId: "",
+    unitQuantity: 0,
+    demandedQuantity: 0,
+    unit: "",
+    diskQuantity: 0,
+  });
+};
+
+const cancelEdit = () => {
+  dataValue.isEdit = false;
+  dataValue.dataList = dataValue.dataList.filter(item => item.id !== undefined);
+};
+
+onMounted(() => {
+  fetchData();
+  fetchProcessOptions();
+});
+</script>
\ No newline at end of file
diff --git a/src/views/productionManagement/productStructure/index.vue b/src/views/productionManagement/productStructure/index.vue
index b17c1f0..e32ff8d 100644
--- a/src/views/productionManagement/productStructure/index.vue
+++ b/src/views/productionManagement/productStructure/index.vue
@@ -14,11 +14,7 @@
         <el-button
             type="primary"
             text
-            @click="() =>{
-              currentRow = row;
-              showEdit = true;
-            }"
-        >{{ row.productName }}
+            @click="showDetail(row.id)">{{ row.productName }}
         </el-button>
       </template>
     </PIMTable>
@@ -29,7 +25,9 @@
 <script setup>
 import {ref} from "vue";
 import {productModelList} from "@/api/basicData/productModel.js";
+import { useRouter } from 'vue-router'
 
+const router = useRouter()
 const StructureEdit = defineAsyncComponent(() => import('@/views/productionManagement/productStructure/StructureEdit.vue'))
 
 const tableColumn = ref([
@@ -89,6 +87,15 @@
   page.size = obj.limit;
   getModelList();
 };
+
+const showDetail = (id) => {
+  router.push({
+    path: '/productionManagement/productStructureDetail',
+    query: {
+      id: id
+    }
+  })
+}
 const getModelList = () => {
   tableLoading.value = true;
   productModelList({

--
Gitblit v1.9.3