From 5634a0605b69dd420ba5eeb14ff3d822022855bf Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 01 九月 2026 18:13:35 +0800
Subject: [PATCH] fix: bom选择工序更换成表单选择

---
 src/views/productionManagement/productStructure/Detail/index.vue         |   70 ++++++++++++++---
 src/api/productionManagement/productionProcess.js                        |    8 ++
 src/views/productionManagement/productionProcess/ProcessSelectDialog.vue |  159 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 223 insertions(+), 14 deletions(-)

diff --git a/src/api/productionManagement/productionProcess.js b/src/api/productionManagement/productionProcess.js
index 783f584..09cbff9 100644
--- a/src/api/productionManagement/productionProcess.js
+++ b/src/api/productionManagement/productionProcess.js
@@ -26,6 +26,14 @@
     params: query,
   });
 }
+
+export function listAll() {
+  return request({
+    url: "/technologyOperation/listPage",
+    method: "get",
+    params: { current: -1, size: -1 },
+  });
+}
 export function add(data) {
   return request({
     url: "/technologyOperation/add",
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index ec18ddf..3dcccf7 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -59,18 +59,20 @@
                   <el-form-item v-if="dataValue.isEdit"
                                 :rules="dataValue.dataList.some(item => (item as any).tempId === row.tempId) ? [] : [{ required: true, message: '璇烽�夋嫨娑堣�楀伐搴�', trigger: 'change' }]"
                                 style="margin: 0">
-                    <el-select v-model="row.processId"
-                               placeholder="璇烽�夋嫨"
-                               filterable
-                               clearable
-                               style="width: 100%"
-                               @change="value => handleProcessChange(row, value)"
-                               :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)">
-                      <el-option v-for="item in dataValue.processOptions"
-                                 :key="item.id"
-                                 :label="item.name"
-                                 :value="item.id" />
-                    </el-select>
+                    <el-input v-model="row.processName"
+                              readonly
+                              placeholder="璇烽�夋嫨娑堣�楀伐搴�"
+                              clearable
+                              style="width: 100%"
+                              :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)"
+                              @click="openProcessDialog(row, $event)"
+                              @clear="clearProcess(row)">
+                      <template #append>
+                        <el-button icon="Search"
+                                   :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)"
+                                   @click="openProcessDialog(row)" />
+                      </template>
+                    </el-input>
                   </el-form-item>
                 </template>
               </el-table-column>
@@ -150,6 +152,9 @@
                            v-model:model-value="dataValue.showProductDialog"
                            :single="true"
                            @confirm="handleProduct" />
+    <process-select-dialog v-if="dataValue.showProcessDialog"
+                           v-model:model-value="dataValue.showProcessDialog"
+                           @confirm="handleProcessConfirm" />
   </div>
 </template>
 
@@ -167,7 +172,7 @@
     addBomDetail,
   } from "@/api/productionManagement/productStructure.js";
   import { listProcessBom } from "@/api/productionManagement/productionOrder.js";
-  import { list } from "@/api/productionManagement/productionProcess";
+  import { listAll } from "@/api/productionManagement/productionProcess";
   import { ElMessage } from "element-plus";
   import { useRoute, useRouter } from "vue-router";
 
@@ -177,6 +182,12 @@
 
   const ProductSelectDialog = defineAsyncComponent(
     () => import("@/views/basicData/product/ProductSelectDialog.vue")
+  );
+  const ProcessSelectDialog = defineAsyncComponent(
+    () =>
+      import(
+        "@/views/productionManagement/productionProcess/ProcessSelectDialog.vue"
+      )
   );
   const emit = defineEmits(["update:router"]);
   const form = ref();
@@ -210,8 +221,10 @@
     productOptions: [],
     processOptions: [],
     showProductDialog: false,
+    showProcessDialog: false,
     currentRowIndex: null,
     currentRowName: null,
+    currentProcessRow: null,
     loading: false,
     isEdit: false,
   });
@@ -346,6 +359,35 @@
     }
   };
 
+  const openProcessDialog = (row: any, event?: Event) => {
+    // 鐐瑰嚮娓呴櫎鎸夐挳鏃朵笉寮圭獥
+    const target = event?.target as HTMLElement | undefined;
+    if (target && target.closest(".el-input__clear")) {
+      return;
+    }
+    dataValue.currentProcessRow = row;
+    dataValue.showProcessDialog = true;
+  };
+
+  const clearProcess = (row: any) => {
+    row.processId = "";
+    row.operationId = "";
+    row.processName = "";
+    row.operationName = "";
+  };
+
+  const handleProcessConfirm = (processRow: any) => {
+    const row = dataValue.currentProcessRow;
+    if (!row) {
+      return;
+    }
+    row.processId = processRow.id;
+    row.operationId = processRow.id;
+    row.processName = processRow.name;
+    row.operationName = processRow.name;
+    handleProcessChange(row, processRow.id);
+  };
+
   const handleUnitQuantityChange = () => {
     recalculateDemandedQuantities();
   };
@@ -382,7 +424,7 @@
   };
 
   const fetchProcessOptions = async () => {
-    const { data } = await list({});
+    const { data } = await listAll();
     console.log(data, "dataValue.dataList");
     dataValue.processOptions = normalizeListData(data);
   };
diff --git a/src/views/productionManagement/productionProcess/ProcessSelectDialog.vue b/src/views/productionManagement/productionProcess/ProcessSelectDialog.vue
new file mode 100644
index 0000000..9ece5b8
--- /dev/null
+++ b/src/views/productionManagement/productionProcess/ProcessSelectDialog.vue
@@ -0,0 +1,159 @@
+<template>
+  <el-dialog v-model="visible" title="閫夋嫨宸ュ簭" width="800px" destroy-on-close :close-on-click-modal="false">
+    <el-form :inline="true" :model="query" class="mb-2">
+      <el-form-item label="宸ュ簭鍚嶇О">
+        <el-input v-model="query.name" placeholder="杈撳叆宸ュ簭鍚嶇О" clearable @keyup.enter="onSearch" style="width: 180px" />
+      </el-form-item>
+      <el-form-item label="宸ュ簭缂栫爜">
+        <el-input v-model="query.no" placeholder="杈撳叆宸ュ簭缂栫爜" clearable @keyup.enter="onSearch" style="width: 180px" />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="onSearch">鎼滅储</el-button>
+        <el-button @click="onReset">閲嶇疆</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-table ref="tableRef" v-loading="loading" :data="tableData" height="380" highlight-current-row row-key="id"
+      @current-change="handleCurrentChange" @row-dblclick="onConfirm">
+      <el-table-column type="index" label="搴忓彿" width="60" />
+      <el-table-column prop="no" label="宸ュ簭缂栫爜" min-width="130" />
+      <el-table-column prop="name" label="宸ュ簭鍚嶇О" min-width="150" />
+      <el-table-column prop="isQuality" label="鏄惁璐ㄦ" min-width="90">
+        <template #default="{ row }">
+          <el-tag size="small" :type="row.isQuality ? 'warning' : 'info'">{{ row.isQuality ? '鏄�' : '鍚�' }}</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column prop="isProduction" label="鏄惁鐢熶骇" min-width="90">
+        <template #default="{ row }">
+          <el-tag size="small" :type="row.isProduction ? 'success' : 'info'">{{ row.isProduction ? '鏄�' : '鍚�' }}</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column prop="remark" label="澶囨敞" min-width="120" show-overflow-tooltip />
+    </el-table>
+
+    <div class="mt-3 flex justify-end">
+      <el-pagination background layout="total, sizes, prev, pager, next, jumper" :total="total"
+        v-model:page-size="page.pageSize" v-model:current-page="page.pageNum" :page-sizes="[10, 20, 50, 100]"
+        @size-change="onPageChange" @current-change="onPageChange" />
+    </div>
+
+    <template #footer>
+      <el-button type="primary" :disabled="!selectedRow" @click="onConfirm">纭畾</el-button>
+      <el-button @click="close()">鍙栨秷</el-button>
+    </template>
+  </el-dialog>
+</template>
+
+<script setup lang="ts">
+  import { computed, reactive, ref, watch } from "vue";
+  import { ElMessage } from "element-plus";
+  import { listPage } from "@/api/productionManagement/productionProcess";
+
+  export type ProcessRow = {
+    id: number;
+    no?: string;
+    name: string;
+    isQuality?: boolean;
+    isProduction?: boolean;
+    remark?: string;
+  };
+
+  const props = defineProps<{
+    modelValue: boolean;
+  }>();
+
+  const emit = defineEmits(["update:modelValue", "confirm"]);
+
+  const visible = computed({
+    get: () => props.modelValue,
+    set: v => emit("update:modelValue", v),
+  });
+
+  const query = reactive({
+    name: "",
+    no: "",
+  });
+
+  const page = reactive({
+    pageNum: 1,
+    pageSize: 10,
+  });
+
+  const loading = ref(false);
+  const tableData = ref<ProcessRow[]>([]);
+  const total = ref(0);
+  const selectedRow = ref<ProcessRow | null>(null);
+  const tableRef = ref();
+
+  function close() {
+    visible.value = false;
+  }
+
+  function handleCurrentChange(row: ProcessRow) {
+    selectedRow.value = row;
+  }
+
+  function onSearch() {
+    page.pageNum = 1;
+    loadData();
+  }
+
+  function onReset() {
+    query.name = "";
+    query.no = "";
+    onSearch();
+  }
+
+  function onPageChange() {
+    loadData();
+  }
+
+  function onConfirm() {
+    if (!selectedRow.value) {
+      ElMessage.warning("璇烽�夋嫨涓�涓伐搴�");
+      return;
+    }
+    emit("confirm", selectedRow.value);
+    close();
+  }
+
+  async function loadData() {
+    loading.value = true;
+    try {
+      selectedRow.value = null;
+      if (tableRef.value) {
+        tableRef.value.setCurrentRow(null);
+      }
+      const { data } = await listPage({
+        current: page.pageNum,
+        size: page.pageSize,
+        name: query.name.trim(),
+        no: query.no.trim(),
+      });
+      const records = data?.records ?? (Array.isArray(data) ? data : []);
+      tableData.value = Array.isArray(records) ? records : [];
+      total.value = Number(data?.total ?? tableData.value.length);
+    } catch (e) {
+      console.error("鍔犺浇宸ュ簭鍒楄〃澶辫触", e);
+      tableData.value = [];
+      total.value = 0;
+    } finally {
+      loading.value = false;
+    }
+  }
+
+  // 鐩戝惉寮圭獥鎵撳紑锛岄噸缃煡璇㈡潯浠跺拰椤电爜锛坕mmediate锛氱粍浠跺垱寤烘椂 modelValue 宸蹭负 true锛屼篃绔嬪嵆鍔犺浇锛�
+  watch(
+    () => props.modelValue,
+    visible => {
+      if (visible) {
+        selectedRow.value = null;
+        query.name = "";
+        query.no = "";
+        page.pageNum = 1;
+        loadData();
+      }
+    },
+    { immediate: true }
+  );
+</script>
\ No newline at end of file

--
Gitblit v1.9.3