From af9bd8d2f33bdac39400a94c46db45f48094d8cc Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 01 九月 2026 23:18:28 +0800
Subject: [PATCH] fix: bom结构支持拖拉拽

---
 src/views/productionManagement/productionProcess/ProcessSelectDialog.vue |  159 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 159 insertions(+), 0 deletions(-)

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