From 52b3b54470ecc3c80d816a9891b651ce7f5a0eaa Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期六, 11 十月 2025 13:39:27 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_NEW' into dev_NEW
---
src/views/production/components/ProductionDialog.vue | 117 +++++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 83 insertions(+), 34 deletions(-)
diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue
index 124e32f..4a21fa4 100644
--- a/src/views/production/components/ProductionDialog.vue
+++ b/src/views/production/components/ProductionDialog.vue
@@ -1,12 +1,12 @@
<template>
<el-dialog
v-model="dialogVisible"
- :title="dialogType === 'add' ? '鏂板鐢熶骇鍔犲伐' : '缂栬緫鐢熶骇鍔犲伐'"
+ :title="dialogType === 'add' ? '鏂板鐢熶骇鍔犲伐' : dialogType === 'viewRow' ? '鏌ョ湅鐢熶骇鍔犲伐' : '缂栬緫鐢熶骇鍔犲伐'"
width="1200px"
:close-on-click-modal="false"
@close="handleClose"
>
- <el-row :gutter="10" style="margin-bottom: 10px">
+ <el-row :gutter="10" style="margin-bottom: 10px" v-if="dialogType !== 'viewRow'">
<el-col :span="3">
<el-button type="primary" @click="handlData"
>
@@ -40,20 +40,21 @@
</el-row>
<ETableModify
:columns="columns"
- :showOperations="false"
+ :showOperations="dialogType !== 'viewRow'"
height="200"
@cell-edit="handleCellEdit"
:tableData="tableData"
:showOverflowTooltip="false"
@row-click="handleRowClick"
- :editableColumns="['usedQuantity']"
+ :editableColumns="dialogType === 'viewRow' ? [] : ['usedQuantity']"
+ :editableCells="dialogType !== 'viewRow'"
@delete="handleRemoveItem"
/>
<div class="empty-table">
<h1>鐢熶骇鏄庣粏</h1>
<el-row :gutter="10">
<el-col :span="2">
- <el-button type="primary" @click="addNewRow">
+ <el-button type="primary" @click="addNewRow" v-if="dialogType !== 'viewRow'">
<el-icon>
<Plus/>
</el-icon>
@@ -72,10 +73,11 @@
<ProductionDetailsTable
v-model="detailsTableData"
:border="false"
- :show-operations="true"
+ :show-operations="dialogType !== 'viewRow'"
:auto-calculate="true"
@input-change="handleDetailsChange"
@delete-row="handleDeleteRow"
+ :dialogType="dialogType"
/>
</div>
@@ -83,14 +85,17 @@
<div class="dialog-footer">
<el-button
@click="handleClose"
- v-if="dialogType === 'add' || dialogType === 'edit'"
- >鍙� 娑�
+ >{{ dialogType === 'viewRow' ? '鍏� 闂�' : '鍙� 娑�' }}
</el-button
>
<!-- <el-button @click="handleReset" v-if="dialogType === 'edit'"
>閲� 缃�</el-button
> -->
- <el-button type="primary" :loading="loading" @click="handleSubmit"
+ <el-button
+ v-if="dialogType !== 'viewRow'"
+ type="primary"
+ :loading="loading"
+ @click="handleSubmit"
>纭� 瀹�
</el-button
>
@@ -157,8 +162,10 @@
import {
getOfficialAll,
addOrEditPM,
+ getCoalInfoList,
deleteProductionInventory,
} from "@/api/production/index.js";
+import { getSupplyList } from "@/api/procureMent/index.js"
import {validateFormData, validateNumber, deepClone, createDefaultProductionRow} from "@/utils/production";
import {useCoalData} from "./useCoalData";
import useUserStore from "@/store/modules/user";
@@ -192,9 +199,15 @@
const selectedIds = ref([]);
const currentRow = ref(null);
const copyForm = ref(null);
+const coalList = ref([])
+const supplierList = ref([]);
// 琛ㄦ牸鍒楅厤缃�
const columns = [
- {label: "鐓ょ", prop: "coal", minwidth: 120},
+ {prop: "coalId", label: "鐓ょ", minwidth: 60,
+ formatter: (row) => {
+ return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--";
+ }
+ },
{label: "搴撳瓨鏁伴噺", prop: "inventoryQuantity", minwidth: 100},
{
label: "浣跨敤鏁伴噺",
@@ -206,8 +219,11 @@
];
const formalDatabaseColumns = ref([
- {prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150},
- {prop: "coal", label: "鐓ょ绫诲瀷", minwidth: 60},
+ {prop: "coalId", label: "鐓ょ", minwidth: 60,
+ formatter: (row) => {
+ return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--";
+ }
+ },
{prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", minwidth: 80},
{prop: "unit", label: "鍗曚綅", minwidth: 20},
{prop: "priceExcludingTax", label: "鍗曚环锛堜笉鍚◣锛�", minwidth: 80},
@@ -226,25 +242,51 @@
currentRow.value = row;
};
+// 鑾峰彇鍩虹鏁版嵁锛堢叅绉嶅拰渚涘簲鍟嗭級
+const loadBasicData = async () => {
+ try {
+ const [coalResponse, supplierResponse] = await Promise.all([
+ getCoalInfoList(),
+ getSupplyList()
+ ]);
+
+ coalList.value = coalResponse.data || [];
+ supplierList.value = supplierResponse.data || [];
+ } catch (error) {
+ ElMessage.error("鑾峰彇鍩虹鏁版嵁澶辫触");
+ }
+};
+
// 鑾峰彇閰嶇疆鏁版嵁
const handlData = async () => {
innerVisible.value = true;
- let res = await getOfficialAll();
- if (res.code === 200) {
- formalDatabaseData.value = res.data;
- const existingOfficialIds = tableData.value
- .map((item) => item.officialId)
- .filter((id) => id);
- selectedIds.value = existingOfficialIds;
- debugIdMatching();
- nextTick(() => {
- setTimeout(() => {
- if (etableRef.value && existingOfficialIds.length > 0) {
- etableRef.value.setDefaultSelection();
- }
- }, 100);
- });
- } else {
+
+ // 纭繚鍩虹鏁版嵁宸插姞杞�
+ if (coalList.value.length === 0 || supplierList.value.length === 0) {
+ await loadBasicData();
+ }
+
+ try {
+ const OfficialAll = await getOfficialAll();
+
+ if (OfficialAll.code === 200) {
+ formalDatabaseData.value = OfficialAll.data;
+ const existingOfficialIds = tableData.value
+ .map((item) => item.officialId)
+ .filter((id) => id);
+ selectedIds.value = existingOfficialIds;
+ debugIdMatching();
+ nextTick(() => {
+ setTimeout(() => {
+ if (etableRef.value && existingOfficialIds.length > 0) {
+ etableRef.value.setDefaultSelection();
+ }
+ }, 100);
+ });
+ } else {
+ ElMessage.error("鑾峰彇閰嶇疆鏁版嵁澶辫触");
+ }
+ } catch (error) {
ElMessage.error("鑾峰彇閰嶇疆鏁版嵁澶辫触");
}
};
@@ -271,22 +313,28 @@
};
// 鍒濆鍖栧拰缂栬緫鍒濆鍖�
-const Initialization = () => {
+const Initialization = async () => {
tableData.value = [];
detailsTableData.value = [];
copyForm.value = null;
dialogType.value = "add";
+
+ // 鍔犺浇鍩虹鏁版嵁
+ await loadBasicData();
};
-const editInitialization = (data) => {
+const editInitialization = async (type, data) => {
copyForm.value = deepClone(data);
tableData.value = data.productionInventoryList || [];
detailsTableData.value = data.productionList || [];
- dialogType.value = "edit";
+ dialogType.value = type;
const existingOfficialIds = tableData.value
.map((item) => item.officialId)
.filter((id) => id);
selectedIds.value = existingOfficialIds;
+
+ // 鍔犺浇鍩虹鏁版嵁
+ await loadBasicData();
};
// 鐩戝惉瀵硅瘽妗嗙姸鎬侊紝鍦ㄦ墦寮�鏃惰缃�変腑鐘舵��
watch(innerVisible, (newVal) => {
@@ -376,7 +424,7 @@
for (let i = 0; i < tableData.value.length; i++) {
const element = tableData.value[i];
if (element.usedQuantity == 0 || element.usedQuantity === null) {
- ElMessage.warning(`璇峰~鍐欎娇鐢ㄦ暟閲�: ${element.coal}`);
+ ElMessage.warning(`璇峰~鍐欑敓浜у姞宸ョ叅绉嶇殑浣跨敤鏁伴噺`);
return;
}
}
@@ -432,12 +480,13 @@
}
};
-// 鑾峰彇鐢ㄦ埛淇℃伅
+// 鑾峰彇鐢ㄦ埛淇℃伅骞跺姞杞藉熀纭�鏁版嵁
onMounted(async () => {
try {
userInfo = await userStore.getInfo();
+ await loadBasicData();
} catch (error) {
- ElMessage.error("鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛岃閲嶈瘯");
+ ElMessage.error("鍒濆鍖栧け璐ワ紝璇烽噸璇�");
}
});
--
Gitblit v1.9.3