From 4dee4cb5b31a7f1dcd2c7b3d72f74b78d2fe3f29 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 18 九月 2026 15:56:41 +0800
Subject: [PATCH] fix: 质检是否入库
---
src/views/productionManagement/productStructure/Detail/index.vue | 540 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 485 insertions(+), 55 deletions(-)
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 3a76e48..6899eb0 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -22,16 +22,34 @@
border
:preserve-expanded-content="false"
:default-expand-all="true"
- style="width: 100%">
+ style="width: 100%"
+ @expand-change="handleOuterExpandChange">
<el-table-column type="expand">
<template #default="props">
<el-form ref="form"
:model="dataValue">
- <el-table :data="dataValue.dataList"
+ <div v-if="dataValue.isEdit"
+ class="drag-tip">
+ <el-icon><Rank /></el-icon>
+ <span>鎷栧姩鎵嬫焺璋冩暣缁撴瀯:鍚屽眰绾х洿鎺ユ嫋鍔ㄦ帓搴�;鎷栧埌鏌愯姝d笅鏂规垚涓哄叾瀛愮骇;鎷栧埌鍒楄〃鏈�鍓嶆垚涓轰竴绾�</span>
+ </div>
+ <el-table ref="tableRef"
+ :data="dataValue.dataList"
row-key="tempId"
default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
+ @expand-change="handleTreeExpandChange"
style="width: 100%">
+ <el-table-column v-if="dataValue.isEdit"
+ width="44"
+ align="center">
+ <template #default="{ row }">
+ <div class="drag-handle"
+ title="鎷栧姩璋冩暣椤哄簭:鎷栧埌鏌愯姝d笅鏂规垚涓哄叾瀛愮骇,鎷栧埌鍒楄〃鏈�鍓嶆垚涓轰竴绾�">
+ <el-icon><Rank /></el-icon>
+ </div>
+ </template>
+ </el-table-column>
<el-table-column prop="productName"
label="浜у搧" />
<el-table-column prop="model"
@@ -59,17 +77,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%"
- :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>
@@ -81,10 +102,10 @@
style="margin: 0">
<el-input-number v-model="row.unitQuantity"
:min="0"
- :precision="2"
:step="1"
controls-position="right"
style="width: 100%"
+ @change="handleUnitQuantityChange"
:disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
</el-form-item>
</template>
@@ -98,11 +119,10 @@
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 || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
+ :disabled="true" />
</el-form-item>
</template>
</el-table-column>
@@ -115,7 +135,7 @@
<el-input v-model="row.unit"
placeholder="璇疯緭鍏ュ崟浣�"
clearable
- :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
+ :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
</el-form-item>
</template>
</el-table-column>
@@ -148,7 +168,11 @@
</el-table>
<product-select-dialog v-if="dataValue.showProductDialog"
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>
@@ -157,15 +181,23 @@
computed,
defineAsyncComponent,
defineComponent,
+ nextTick,
+ onBeforeUnmount,
onMounted,
reactive,
ref,
+ watch,
} from "vue";
- import { queryList, add } from "@/api/productionManagement/productStructure.js";
+ import {
+ queryList,
+ 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";
+ import Sortable from "sortablejs";
+ import { Rank } from "@element-plus/icons-vue";
defineComponent({
name: "StructureEdit",
@@ -174,8 +206,16 @@
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();
+ const tableRef = ref();
+ let tableSortable = null;
const route = useRoute();
const router = useRouter();
@@ -206,11 +246,325 @@
productOptions: [],
processOptions: [],
showProductDialog: false,
+ showProcessDialog: false,
currentRowIndex: null,
currentRowName: null,
+ currentProcessRow: null,
loading: false,
isEdit: false,
});
+
+ const normalizeListData = (source: any) => {
+ if (Array.isArray(source)) {
+ return source;
+ }
+ if (Array.isArray(source?.records)) {
+ return source.records;
+ }
+ return [];
+ };
+
+ const getProcessOptionById = (id: any) => {
+ if (id === undefined || id === null || id === "") {
+ return null;
+ }
+ return (
+ normalizeListData(dataValue.processOptions).find(
+ option => String(option.id) === String(id)
+ ) || null
+ );
+ };
+
+ const syncProcessOperationFields = (item: any) => {
+ const processId = item.processId ?? item.operationId ?? "";
+ if (!processId) {
+ item.processId = "";
+ item.operationId = "";
+ item.processName = "";
+ item.operationName = "";
+ return;
+ }
+
+ const option = getProcessOptionById(processId);
+ const processName =
+ option?.name || item.processName || item.operationName || "";
+
+ item.processId = processId;
+ item.operationId = processId;
+ item.processName = processName;
+ item.operationName = processName;
+ };
+
+ const normalizeTreeData = (items: any[]) => {
+ items.forEach((item: any) => {
+ item.tempId = item.tempId || item.id || `${Date.now()}_${Math.random()}`;
+ syncProcessOperationFields(item);
+ if (Array.isArray(item.children) && item.children.length > 0) {
+ normalizeTreeData(item.children);
+ }
+ });
+ };
+
+ const toQuantityNumber = (value: any) => {
+ const numberValue = Number(value);
+ if (!Number.isFinite(numberValue)) {
+ return 0;
+ }
+ return Number(numberValue.toFixed(4));
+ };
+
+ const syncDemandedQuantityTree = (
+ items: any[],
+ parentDemandedQuantity: number | null = null
+ ) => {
+ items.forEach((item: any) => {
+ if (parentDemandedQuantity !== null) {
+ item.demandedQuantity = toQuantityNumber(
+ parentDemandedQuantity * toQuantityNumber(item.unitQuantity)
+ );
+ }
+
+ if (Array.isArray(item.children) && item.children.length > 0) {
+ syncDemandedQuantityTree(
+ item.children,
+ toQuantityNumber(item.demandedQuantity)
+ );
+ }
+ });
+ };
+
+ const recalculateDemandedQuantities = () => {
+ if (!isOrderPage.value) {
+ return;
+ }
+
+ syncDemandedQuantityTree(dataValue.dataList);
+ };
+
+ // ===== 鎷栨嫿鎺掑簭 =====
+ // 鎸夊綋鍓� DOM 琛岄『搴忓睍寮�鎴愭墎骞冲垪琛�(缂栬緫妯″紡涓嬪己鍒跺叏閮ㄥ睍寮�,淇濊瘉琛岄『搴忎笌鏁版嵁涓�鑷�)
+ const buildFlatTree = () => {
+ const flat = [];
+ const walk = (items, depth, parentNode) => {
+ items.forEach(node => {
+ flat.push({ node, depth, parentArray: items, parentNode });
+ if (Array.isArray(node.children) && node.children.length > 0) {
+ walk(node.children, depth + 1, node);
+ }
+ });
+ };
+ walk(dataValue.dataList, 0, null);
+ return flat;
+ };
+
+ const removeNodeByTempId = (items, tempId) => {
+ for (let i = 0; i < items.length; i++) {
+ if (String(items[i].tempId) === String(tempId)) {
+ items.splice(i, 1);
+ return true;
+ }
+ if (
+ Array.isArray(items[i].children) &&
+ removeNodeByTempId(items[i].children, tempId)
+ ) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ const updateParentRef = (node, parent) => {
+ node.parentTempId = parent?.tempId ?? "";
+ node.parentId = parent?.id ?? "";
+ };
+
+ const handleSortEnd = evt => {
+ const { oldIndex, newIndex } = evt;
+ if (
+ typeof oldIndex !== "number" ||
+ typeof newIndex !== "number" ||
+ oldIndex === newIndex
+ ) {
+ return;
+ }
+ const flat = buildFlatTree();
+ if (oldIndex < 0 || oldIndex >= flat.length) return;
+ const dragged = flat[oldIndex];
+
+ // 鎷栨斁鍚庝綅浜庤鎷栬涓婃柟涓�琛岀殑鏁版嵁(鎸夋渶缁� DOM 椤哄簭鎹㈢畻鍒板師鎵佸钩鍒楄〃)
+ let aEntry = null;
+ if (newIndex > oldIndex) {
+ aEntry = flat[newIndex];
+ } else if (newIndex > 0) {
+ aEntry = flat[newIndex - 1];
+ }
+
+ if (!aEntry) {
+ // 鎷栧埌鍒楄〃鏈�鍓� 鈫� 鎴愪负涓�绾�
+ removeNodeByTempId(dataValue.dataList, dragged.node.tempId);
+ dataValue.dataList.unshift(dragged.node);
+ updateParentRef(dragged.node, null);
+ } else if (aEntry.depth < dragged.depth) {
+ // 鎷栧埌鏌愯姝d笅鏂� 鈫� 鎴愪负璇ヨ鐨勫瓙绾�
+ removeNodeByTempId(dataValue.dataList, dragged.node.tempId);
+ if (!aEntry.node.children) {
+ aEntry.node.children = [];
+ }
+ aEntry.node.children.push(dragged.node);
+ updateParentRef(dragged.node, aEntry.node);
+ } else {
+ // 鍚岀骇鎻掑叆:鍚戜笂鎵剧涓�涓繁搴︿笉瓒呰繃琚嫋琛岀殑鑺傜偣
+ let i = flat.indexOf(aEntry);
+ while (i >= 0 && flat[i].depth > dragged.depth) {
+ i--;
+ }
+ const eEntry = flat[i];
+ // 鎷栧洖鑷繁鐨勫瓙鏍戝唴 鈫� 涓嶅鐞�(闃叉褰㈡垚寰幆)
+ if (!eEntry || eEntry.node.tempId === dragged.node.tempId) {
+ return;
+ }
+ removeNodeByTempId(dataValue.dataList, dragged.node.tempId);
+ const siblings = eEntry.parentArray;
+ const idx = siblings.indexOf(eEntry.node);
+ siblings.splice(idx + 1, 0, dragged.node);
+ updateParentRef(dragged.node, eEntry.parentNode);
+ }
+
+ recalculateDemandedQuantities();
+ };
+
+ const initSortable = () => {
+ if (!tableRef.value) return;
+ const tbody = tableRef.value.$el.querySelector(".el-table__body tbody");
+ if (!tbody) return;
+ tableSortable?.destroy();
+ tableSortable = new Sortable(tbody, {
+ animation: 150,
+ handle: ".drag-handle",
+ disabled: !dataValue.isEdit,
+ ghostClass: "sortable-ghost",
+ onEnd: handleSortEnd,
+ });
+ };
+
+ const expandAllTree = () => {
+ const table = tableRef.value;
+ if (!table) return;
+ const walk = items => {
+ items.forEach(item => {
+ if (Array.isArray(item.children) && item.children.length > 0) {
+ table.toggleRowExpansion(item, true);
+ walk(item.children);
+ }
+ });
+ };
+ walk(dataValue.dataList);
+ };
+
+ // 缂栬緫妯″紡涓嬩笉鍏佽鎶樺彔,淇濊瘉鎷栨嫿鏃� DOM 琛岄『搴忎笌 dataList 涓�鑷�
+ const handleTreeExpandChange = (row, expanded) => {
+ if (dataValue.isEdit && expanded === false) {
+ nextTick(() => {
+ tableRef.value?.toggleRowExpansion(row, true);
+ });
+ }
+ };
+
+ // 澶栧眰琛屾姌鍙犲悗鍐呭浼氶攢姣�,閲嶆柊灞曞紑鏃堕噸鏂板垵濮嬪寲鎷栨嫿
+ const handleOuterExpandChange = (row, expandedRows) => {
+ if (Array.isArray(expandedRows) && expandedRows.some(r => r === row)) {
+ nextTick(() => initSortable());
+ }
+ };
+
+ watch(
+ () => dataValue.isEdit,
+ val => {
+ tableSortable?.option("disabled", !val);
+ if (val) {
+ nextTick(() => {
+ initSortable();
+ expandAllTree();
+ });
+ }
+ }
+ );
+
+ const buildSubmitTree = (items: any[]) => {
+ return items.map((item: any) => {
+ const current = { ...item };
+ syncProcessOperationFields(current);
+ current.children = Array.isArray(current.children)
+ ? buildSubmitTree(current.children)
+ : [];
+ return current;
+ });
+ };
+
+ const findSiblings = (items: any[], tempId: string): any[] | null => {
+ if (!items || items.length === 0) return null;
+ // 妫�鏌ュ綋鍓嶅眰绾�
+ if (items.some(item => item.tempId === tempId)) {
+ return items;
+ }
+ // 閫掑綊鏌ユ壘瀛愮骇
+ for (const item of items) {
+ if (item.children && item.children.length > 0) {
+ const result = findSiblings(item.children, tempId);
+ if (result) return result;
+ }
+ }
+ return null;
+ };
+
+ const handleProcessChange = (row: any, value: any) => {
+ row.processId = value || "";
+ syncProcessOperationFields(row);
+
+ // 妫�鏌ュ悓涓�灞傜骇鏄惁宸茬粡鏈夊叾浠栦笉鍚岀殑宸ュ簭琚�変腑
+ const siblings = findSiblings(dataValue.dataList, row.tempId);
+ if (siblings && value) {
+ const hasDifferentProcess = siblings.some(sibling => {
+ return sibling.tempId !== row.tempId && sibling.processId && sibling.processId !== value;
+ });
+ if (hasDifferentProcess) {
+ ElMessage.warning("鍚屼竴灞傜骇宸插瓨鍦ㄤ笉鍚岀殑宸ュ簭锛岃鍏堢粺涓�宸ュ簭鍚庡啀杩涜淇敼");
+ }
+ }
+ };
+
+ 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();
+ };
const tableData = reactive([
{
@@ -231,48 +585,47 @@
// 璁㈠崟鎯呭喌锛氫娇鐢ㄨ鍗曠殑浜у搧缁撴瀯鎺ュ彛
const { data } = await listProcessBom({ orderId: routeOrderId.value });
dataValue.dataList = (data as any) || [];
+ normalizeTreeData(dataValue.dataList);
+ recalculateDemandedQuantities();
} else {
// 闈炶鍗曟儏鍐碉細浣跨敤鍘熸潵鐨勬帴鍙�
const { data } = await queryList(routeId.value);
dataValue.dataList = (data as any) || [];
- // 涓烘墍鏈夐」鍙婂叾瀛愰」璁剧疆name灞炴��
- const setNameRecursively = (items: any[]) => {
- items.forEach((item: any) => {
- item.tempId = item.id;
- item.processName =
- dataValue.processOptions.find(option => option.id === item.processId)
- ?.name || "";
- if (item.children && item.children.length > 0) {
- setNameRecursively(item.children);
- }
- });
- };
- setNameRecursively(dataValue.dataList);
+ console.log(dataValue);
+ normalizeTreeData(dataValue.dataList);
console.log(dataValue.dataList, "dataValue.dataList");
}
};
const fetchProcessOptions = async () => {
- const { data } = await list();
- dataValue.processOptions = data as any;
+ const { data } = await listAll();
+ console.log(data, "dataValue.dataList");
+ dataValue.processOptions = normalizeListData(data);
};
const handleProduct = (row: any) => {
- if (row?.length > 1) {
- ElMessage.error("鍙兘閫夋嫨涓�涓骇鍝�");
+ if (!Array.isArray(row) || row.length === 0) {
+ ElMessage.warning("璇烽�夋嫨涓�涓骇鍝�");
+ return;
}
- const productData = row[0];
+ // 鍙厑璁镐竴涓細濡傛灉涓婃父杩斿洖浜嗗涓紝榛樿浣跨敤鏈�鍚庝竴娆¢�夋嫨骞惰鐩栧綋鍓嶅��
+ const productData = row[row.length - 1];
// 鏈�澶栧眰缁勪欢涓紝涓庡綋鍓嶄骇鍝佺浉鍚岀殑浜у搧鍙兘鏈変竴涓�
- const isTopLevel = dataValue.dataList.some(item => (item as any).tempId === dataValue.currentRowName);
+ const isTopLevel = dataValue.dataList.some(
+ item => (item as any).tempId === dataValue.currentRowName
+ );
if (isTopLevel) {
- if (productData.productName === tableData[0].productName &&
- productData.model === tableData[0].model) {
+ if (
+ productData.productName === tableData[0].productName &&
+ productData.model === tableData[0].model
+ ) {
// 鏌ユ壘鏄惁宸茬粡鏈夊叾浠栭《灞傝宸茬粡鏄繖涓骇鍝�
- const hasOther = dataValue.dataList.some(item =>
- (item as any).tempId !== dataValue.currentRowName &&
- (item as any).productName === tableData[0].productName &&
- (item as any).model === tableData[0].model
+ const hasOther = dataValue.dataList.some(
+ item =>
+ (item as any).tempId !== dataValue.currentRowName &&
+ (item as any).productName === tableData[0].productName &&
+ (item as any).model === tableData[0].model
);
if (hasOther) {
ElMessage.warning("鏈�澶栧眰鍜屽綋鍓嶄骇鍝佷竴鏍风殑涓�绾у彧鑳芥湁涓�涓�");
@@ -319,8 +672,41 @@
const validateAll = () => {
let isValid = true;
+ // 鏍¢獙涓�缁勫厔寮熻妭鐐圭殑宸ュ簭鏄惁閮界浉鍚�
+ const checkProcessUniqueness = (items: any[]) => {
+ if (!items || items.length === 0 || !isValid) return;
+
+ // 鑾峰彇绗竴涓潪绌虹殑宸ュ簭ID浣滀负鍙傝��
+ const firstProcessId = items.find(item => item.processId)?.processId;
+
+ // 濡傛灉鏈夊伐搴廔D锛屾鏌ユ墍鏈夐」鏄惁閮戒娇鐢ㄧ浉鍚岀殑宸ュ簭
+ if (firstProcessId) {
+ for (const item of items) {
+ if (item.processId && item.processId !== firstProcessId) {
+ const option1 = getProcessOptionById(firstProcessId);
+ const option2 = getProcessOptionById(item.processId);
+ const processName1 = option1?.name || "鏈煡宸ュ簭";
+ const processName2 = option2?.name || "鏈煡宸ュ簭";
+ ElMessage.error(
+ `褰撳墠灞傜骇涓嬪伐搴忎笉涓�鑷达紝璇蜂娇鐢ㄧ浉鍚岀殑宸ュ簭銆傚瓨鍦ㄣ��${processName1}銆嶅拰銆�${processName2}銆峘
+ );
+ isValid = false;
+ return;
+ }
+ }
+ }
+
+ // 閫掑綊鏍¢獙瀛愮骇鐨勫厔寮熻妭鐐�
+ for (const item of items) {
+ if (item.children && item.children.length > 0) {
+ checkProcessUniqueness(item.children);
+ }
+ }
+ };
+
// 鏍¢獙鍑芥暟
const validateItem = (item: any, isTopLevel = false) => {
+ if (!isValid) return;
// 鏍¢獙褰撳墠椤圭殑蹇呭~瀛楁
if (!item.model) {
ElMessage.error("璇烽�夋嫨瑙勬牸");
@@ -348,7 +734,7 @@
// return;
// }
- // 閫掑綊鏍¢獙瀛愰」
+ // 閫掑綊鏍¢獙瀛愰」瀛楁
if (item.children && item.children.length > 0) {
item.children.forEach(child => {
validateItem(child, false);
@@ -356,7 +742,11 @@
}
};
- // 閬嶅巻鎵�鏈夐《灞傞」
+ // 1. 棣栧厛鏍¢獙鍚屼竴鐖剁骇涓嬬殑鍚屽眰娑堣�楀伐搴忔槸鍚﹀敮涓�
+ checkProcessUniqueness(dataValue.dataList);
+ if (!isValid) return false;
+
+ // 2. 鐒跺悗閬嶅巻鏍¢獙鎵�鏈夐《灞傞」鐨勫瓧娈靛繀濉儏鍐�
dataValue.dataList.forEach(item => {
validateItem(item, true);
});
@@ -366,19 +756,19 @@
const submit = () => {
dataValue.loading = true;
+ normalizeTreeData(dataValue.dataList);
+ recalculateDemandedQuantities();
// 鍏堣繘琛岃〃鍗曟牎楠�
const valid = validateAll();
console.log(dataValue.dataList, "dataValue.dataList");
if (valid) {
- add({
+ addBomDetail({
bomId: routeId.value,
- children: dataValue.dataList || [],
+ children: buildSubmitTree(dataValue.dataList || []),
})
.then(res => {
- router.push({
- path: "/productionManagement/productionManagement/productStructure/index",
- });
+ router.go(-1);
ElMessage.success("淇濆瓨鎴愬姛");
dataValue.loading = false;
})
@@ -390,7 +780,7 @@
}
};
- const removeItem = (tempId:string) => {
+ const removeItem = (tempId: string) => {
// 鍏堝皾璇曚粠椤跺眰鍒犻櫎
const topIndex = dataValue.dataList.findIndex(item => item.tempId === tempId);
if (topIndex !== -1) {
@@ -436,13 +826,16 @@
productModelId: undefined,
processId: "",
processName: "",
- unitQuantity: 0,
+ operationId: "",
+ operationName: "",
+ unitQuantity: 1,
demandedQuantity: 0,
unit: "",
children: [],
tempId: new Date().getTime(),
});
+ recalculateDemandedQuantities();
return;
}
addchildItem(item, tempId);
@@ -462,12 +855,16 @@
model: undefined,
productModelId: undefined,
processId: "",
- unitQuantity: 0,
+ processName: "",
+ operationId: "",
+ operationName: "",
+ unitQuantity: 1,
demandedQuantity: 0,
children: [],
unit: "",
tempId: new Date().getTime(),
});
+ recalculateDemandedQuantities();
return true;
}
if (item.children && item.children.length > 0) {
@@ -512,5 +909,38 @@
// 鍏堝姞杞藉伐搴忛�夐」锛屽啀鍔犺浇鏁版嵁锛岀‘淇漞l-select鑳藉姝g‘鍥炴樉
await fetchProcessOptions();
await fetchData();
+ await nextTick();
+ initSortable();
});
-</script>
\ No newline at end of file
+
+ onBeforeUnmount(() => {
+ tableSortable?.destroy();
+ tableSortable = null;
+ });
+</script>
+
+<style scoped>
+ .drag-tip {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ margin-bottom: 8px;
+ font-size: 12px;
+ color: #909399;
+ }
+
+ .drag-handle {
+ cursor: move;
+ color: #909399;
+ text-align: center;
+ }
+
+ .drag-handle:hover {
+ color: var(--el-color-primary);
+ }
+
+ :deep(.sortable-ghost) {
+ opacity: 0.6;
+ background-color: #f5f7fa !important;
+ }
+</style>
\ No newline at end of file
--
Gitblit v1.9.3