From f0d123e013ce534d392e54feb706c00af7c62e9d Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 19 五月 2026 15:21:53 +0800
Subject: [PATCH] bom同一层级只能选一样的工序
---
src/views/productionManagement/processRoute/processRouteItem/index.vue | 136 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 118 insertions(+), 18 deletions(-)
diff --git a/src/views/productionManagement/processRoute/processRouteItem/index.vue b/src/views/productionManagement/processRoute/processRouteItem/index.vue
index 6d64c30..92a2fa1 100644
--- a/src/views/productionManagement/processRoute/processRouteItem/index.vue
+++ b/src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -111,6 +111,13 @@
<el-table-column label="鍗曚綅"
prop="unit"
width="100" />
+ <el-table-column label="璁¤垂绫诲瀷"
+ prop="type"
+ width="100">
+ <template #default="scope">
+ {{scope.row.type==0 ? "璁℃椂" : "璁′欢"}}
+ </template>
+ </el-table-column>
<el-table-column label="鏄惁璐ㄦ"
prop="isQuality"
width="100">
@@ -181,12 +188,16 @@
{{ item.model }}
<!-- <span v-if="item.unit" class="product-unit">{{ item.unit }}</span> -->
</div>
+ <el-tag class="product-tag"
+ :type="item.type == 1 ? 'primary' : 'success'"
+ style="margin-left: 8px;">{{ item.type==0?'璁℃椂':'璁′欢' }}</el-tag>
<el-tag type="primary"
class="product-tag"
+ style="margin-left: 8px;"
v-if="item.isQuality">璐ㄦ</el-tag>
<el-tag type="primary"
class="product-tag"
- :style="item.isQuality?'margin-left:8px':''"
+ style="margin-left: 8px;"
v-if="item.isProduction">鐢熶骇</el-tag>
</div>
<div v-else
@@ -304,7 +315,7 @@
:step="1"
controls-position="right"
style="width: 100%"
- @change="handleUnitQuantityChange(row)"
+ @change="handleUnitQuantityChange"
:disabled="!bomDataValue.isEdit || bomDataValue.dataList.some(item => (item).tempId === row.tempId)" />
</el-form-item>
</template>
@@ -322,7 +333,7 @@
:step="1"
controls-position="right"
style="width: 100%"
- :disabled="!bomDataValue.isEdit || bomDataValue.dataList.some(item => (item).tempId === row.tempId)" />
+ :disabled="true" />
</el-form-item>
</template>
</el-table-column>
@@ -423,6 +434,13 @@
<el-form-item label="鍗曚綅"
v-else>
<span>{{ form.unit }}</span>
+ </el-form-item>
+ <el-form-item label="璁¤垂绫诲瀷"
+ prop="type">
+ <el-radio-group v-model="form.type">
+ <el-radio :label="0">璁℃椂</el-radio>
+ <el-radio :label="1">璁′欢</el-radio>
+ </el-radio-group>
</el-form-item>
<el-form-item label="鏄惁璐ㄦ"
prop="isQuality">
@@ -558,6 +576,7 @@
model: "",
unit: "",
isQuality: false,
+ type: 0,
isProduction: false,
});
@@ -687,6 +706,7 @@
model: row.model || "",
unit: row.unit || "",
isQuality: row.isQuality,
+ type: row.type || 0,
isProduction: row.isProduction,
};
dialogVisible.value = true;
@@ -758,6 +778,7 @@
operationName: getProcessName(form.value.technologyOperationId),
productModelId: form.value.productModelId,
isQuality: form.value.isQuality,
+ type: form.value.type,
isProduction: form.value.isProduction,
dragSort,
})
@@ -766,6 +787,7 @@
technologyOperationId: form.value.technologyOperationId,
productModelId: form.value.productModelId,
isQuality: form.value.isQuality,
+ type: form.value.type,
isProduction: form.value.isProduction,
dragSort,
});
@@ -793,6 +815,7 @@
operationName: getProcessName(form.value.technologyOperationId),
productModelId: form.value.productModelId,
isQuality: form.value.isQuality,
+ type: form.value.type,
isProduction: form.value.isProduction,
})
: addOrUpdateProcessRouteItem1({
@@ -801,6 +824,7 @@
productModelId: form.value.productModelId,
id: form.value.id,
isQuality: form.value.isQuality,
+ type: form.value.type,
isProduction: form.value.isProduction,
});
@@ -832,6 +856,7 @@
model: "",
unit: "",
isQuality: false,
+ type: 0,
isProduction: false,
};
formRef.value?.resetFields();
@@ -1064,18 +1089,93 @@
}
});
};
+
+ const toQuantityNumber = value => {
+ const numberValue = Number(value);
+ if (!Number.isFinite(numberValue)) {
+ return 0;
+ }
+ return Number(numberValue.toFixed(2));
+ };
+
+ const syncDemandedQuantityTree = (items, parentDemandedQuantity = null) => {
+ items.forEach(item => {
+ 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 (pageType.value !== "order") {
+ return;
+ }
+
+ const rootDemandedQuantity = routeInfo.value.quantity;
+ if (
+ rootDemandedQuantity === undefined ||
+ rootDemandedQuantity === null ||
+ rootDemandedQuantity === ""
+ ) {
+ syncDemandedQuantityTree(bomDataValue.value.dataList);
+ return;
+ }
+
+ syncDemandedQuantityTree(
+ bomDataValue.value.dataList,
+ toQuantityNumber(rootDemandedQuantity)
+ );
+ };
+
const processChange = value => {
processOptions.value.forEach(item => {
if (item.id == value) {
form.value.isQuality = item.isQuality;
+ form.value.type = item.type || 0;
form.value.isProduction = item.isProduction;
}
});
};
+ const findSiblings = (items, tempId) => {
+ 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 handleBomProcessChange = (row, value) => {
row.processId = value || "";
syncProcessOperationFields(row);
+
+ // 鍚屼竴灞傜骇鍙兘閫変竴鏍风殑宸ュ簭
+ const siblings = findSiblings(bomDataValue.value.dataList, row.tempId);
+ if (siblings && value) {
+ siblings.forEach(sibling => {
+ if (sibling.tempId !== row.tempId) {
+ sibling.processId = value;
+ syncProcessOperationFields(sibling);
+ }
+ });
+ }
};
const openBomDialog = tempId => {
@@ -1091,6 +1191,7 @@
);
bomDataValue.value.dataList = data || [];
normalizeTreeData(bomDataValue.value.dataList);
+ recalculateDemandedQuantities();
} catch (err) {
console.error("鑾峰彇BOM鏁版嵁澶辫触锛�", err);
}
@@ -1186,10 +1287,8 @@
});
};
- const handleUnitQuantityChange = row => {
- if (routeInfo.value.quantity && routeInfo.value.quantity !== 0) {
- row.demandedQuantity = (row.unitQuantity || 0) * routeInfo.value.quantity;
- }
+ const handleUnitQuantityChange = () => {
+ recalculateDemandedQuantities();
};
const addchildItem = (item, tempId) => {
@@ -1210,14 +1309,12 @@
"",
operationName: "",
unitQuantity: 1,
- demandedQuantity:
- routeInfo.value.quantity && routeInfo.value.quantity !== 0
- ? 1 * routeInfo.value.quantity
- : 0,
+ demandedQuantity: 0,
children: [],
unit: "",
tempId: new Date().getTime(),
});
+ recalculateDemandedQuantities();
return true;
}
if (item.children && item.children.length > 0) {
@@ -1249,14 +1346,12 @@
"",
operationName: "",
unitQuantity: 1,
- demandedQuantity:
- routeInfo.value.quantity && routeInfo.value.quantity !== 0
- ? 1 * routeInfo.value.quantity
- : 0,
+ demandedQuantity: 0,
unit: "",
children: [],
tempId: new Date().getTime(),
});
+ recalculateDemandedQuantities();
return;
}
addchildItem(item, tempId);
@@ -1324,6 +1419,7 @@
console.log(bomDataValue.value.dataList, "bomDataValue.value.dataList");
normalizeTreeData(bomDataValue.value.dataList);
+ recalculateDemandedQuantities();
const valid = validateAllBom();
if (valid) {
@@ -1335,7 +1431,7 @@
.then(() => {
ElMessage.success("BOM淇濆瓨鎴愬姛");
bomDataValue.value.isEdit = false;
- fetchBomData();
+ refreshCurrentPage();
})
.catch(() => {
ElMessage.error("BOM淇濆瓨澶辫触");
@@ -1348,11 +1444,15 @@
}
};
- onMounted(() => {
+ const refreshCurrentPage = () => {
getRouteInfo();
getList();
getProcessList();
fetchBomData();
+ };
+
+ onMounted(() => {
+ refreshCurrentPage();
});
onUnmounted(() => {
@@ -1619,4 +1719,4 @@
line-height: 1.5;
word-break: break-all;
}
-</style>
+</style>
\ No newline at end of file
--
Gitblit v1.9.3