From 0ad2c4106d6f570e0ca63c8fe5093e6f97492534 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期六, 11 十月 2025 17:44:10 +0800
Subject: [PATCH] yys 1.修改销售出库-煤种选中问题 2.采购管理增加车牌字段
---
src/views/production/components/ProductionDialog.vue | 308 ++++++++++++++++++++++++++++++--------------------
1 files changed, 183 insertions(+), 125 deletions(-)
diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue
index 0cd330e..4a21fa4 100644
--- a/src/views/production/components/ProductionDialog.vue
+++ b/src/views/production/components/ProductionDialog.vue
@@ -1,25 +1,30 @@
<template>
<el-dialog
- v-model="dialogVisible"
- :title="dialogType === 'add' ? '鏂板鐢熶骇鍔犲伐' : '缂栬緫鐢熶骇鍔犲伐'"
- width="1200px"
- :close-on-click-modal="false"
- @close="handleClose"
+ v-model="dialogVisible"
+ :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"
- ><el-icon> <Plus /> </el-icon>閫夋嫨鏁版嵁</el-button
+ >
+ <el-icon>
+ <Plus/>
+ </el-icon>
+ 閫夋嫨鏁版嵁
+ </el-button
>
</el-col>
<el-col :span="4">
<el-button
- type="danger"
- @click="removeSelectedData"
- :disabled="tableData.length === 0"
+ type="danger"
+ @click="removeSelectedData"
+ :disabled="tableData.length === 0"
>
<el-icon>
- <Delete />
+ <Delete/>
</el-icon>
娓呯┖宸查��
</el-button>
@@ -34,23 +39,24 @@
</el-col>
</el-row>
<ETableModify
- :columns="columns"
- :showOperations="false"
- height="200"
- @cell-edit="handleCellEdit"
- :tableData="tableData"
- :showOverflowTooltip="false"
- @row-click="handleRowClick"
- :editableColumns="['usedQuantity']"
- @delete="handleRemoveItem"
+ :columns="columns"
+ :showOperations="dialogType !== 'viewRow'"
+ height="200"
+ @cell-edit="handleCellEdit"
+ :tableData="tableData"
+ :showOverflowTooltip="false"
+ @row-click="handleRowClick"
+ :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 />
+ <Plus/>
</el-icon>
鏂板
</el-button>
@@ -65,60 +71,66 @@
</el-col> -->
</el-row>
<ProductionDetailsTable
- v-model="detailsTableData"
- :border="false"
- :show-operations="true"
- :auto-calculate="true"
- @input-change="handleDetailsChange"
- @delete-row="handleDeleteRow"
+ v-model="detailsTableData"
+ :border="false"
+ :show-operations="dialogType !== 'viewRow'"
+ :auto-calculate="true"
+ @input-change="handleDetailsChange"
+ @delete-row="handleDeleteRow"
+ :dialogType="dialogType"
/>
</div>
<template #footer>
<div class="dialog-footer">
<el-button
- @click="handleClose"
- v-if="dialogType === 'add' || dialogType === 'edit'"
- >鍙� 娑�</el-button
+ @click="handleClose"
+ >{{ dialogType === 'viewRow' ? '鍏� 闂�' : '鍙� 娑�' }}
+ </el-button
>
<!-- <el-button @click="handleReset" v-if="dialogType === 'edit'"
>閲� 缃�</el-button
> -->
- <el-button type="primary" :loading="loading" @click="handleSubmit"
- >纭� 瀹�</el-button
+ <el-button
+ v-if="dialogType !== 'viewRow'"
+ type="primary"
+ :loading="loading"
+ @click="handleSubmit"
+ >纭� 瀹�
+ </el-button
>
</div>
</template>
</el-dialog>
<el-dialog
- v-model="innerVisible"
- width="1000"
- title="閫夋嫨閰嶇疆鏁版嵁"
- center
- append-to-body
+ v-model="innerVisible"
+ width="1000"
+ title="閫夋嫨閰嶇疆鏁版嵁"
+ center
+ append-to-body
>
<div style="margin-bottom: 10px">
<el-alert
- v-if="tableData.length > 0"
- :title="`褰撳墠宸查�夋嫨 ${tableData.length} 鏉℃暟鎹甡"
- type="info"
- :closable="false"
- show-icon
+ v-if="tableData.length > 0"
+ :title="`褰撳墠宸查�夋嫨 ${tableData.length} 鏉℃暟鎹甡"
+ type="info"
+ :closable="false"
+ show-icon
/>
</div>
<ETable
- :showIndex="false"
- :showOverflowTooltip="false"
- @selection-change="handleSelectionChange"
- :showOperations="false"
- ref="etableRef"
- :columns="formalDatabaseColumns"
- :tableData="formalDatabaseData"
- :defaultSelectedIds="selectedIds"
- :rowKey="'id'"
- height="400"
- @cell-edit="handleCellEdit"
- :show-selection="true"
+ :showIndex="false"
+ :showOverflowTooltip="false"
+ @selection-change="handleSelectionChange"
+ :showOperations="false"
+ ref="etableRef"
+ :columns="formalDatabaseColumns"
+ :tableData="formalDatabaseData"
+ :defaultSelectedIds="selectedIds"
+ :rowKey="'id'"
+ height="400"
+ @cell-edit="handleCellEdit"
+ :show-selection="true"
/>
<el-row :gutter="24" style="margin-top: 15px">
<el-col :span="12">
@@ -129,9 +141,9 @@
<el-col :span="12" style="text-align: right">
<el-button @click="innerVisible = false">鍙栨秷</el-button>
<el-button
- type="primary"
- @click="handleSelectData"
- :disabled="formalDatabaseSelectedData.length === 0"
+ type="primary"
+ @click="handleSelectData"
+ :disabled="formalDatabaseSelectedData.length === 0"
>
纭畾娣诲姞
</el-button>
@@ -141,34 +153,36 @@
</template>
<script setup>
-import { ref, reactive, watch, onMounted, nextTick, computed } from "vue";
+import {ref, reactive, watch, onMounted, nextTick, computed} from "vue";
import ETable from "@/components/Table/ETable.vue";
import ETableModify from "@/components/Table/EtableModify.vue";
import ProductionDetailsTable from "./ProductionDetailsTable.vue";
-import { ElMessage, ElMessageBox, ElAlert, ElText } from "element-plus";
-import { Delete, Warning, Plus } from "@element-plus/icons-vue";
+import {ElMessage, ElMessageBox, ElAlert, ElText} from "element-plus";
+import {Delete, Warning, Plus} from "@element-plus/icons-vue";
import {
getOfficialAll,
addOrEditPM,
+ getCoalInfoList,
deleteProductionInventory,
} from "@/api/production/index.js";
-import { validateFormData, validateNumber, deepClone, createDefaultProductionRow } from "@/utils/production";
-import { useCoalData } from "./useCoalData";
+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";
// Props 鍜� Emits
const props = defineProps({
- visible: { type: Boolean, default: false },
- type: { type: String, default: "add" },
- rowData: { type: Object, default: () => ({}) },
+ visible: {type: Boolean, default: false},
+ type: {type: String, default: "add"},
+ rowData: {type: Object, default: () => ({})},
});
-const dialogVisible = defineModel("visible", { type: Boolean, default: false });
+const dialogVisible = defineModel("visible", {type: Boolean, default: false});
const emit = defineEmits(["update:visible", "success", "update:productionAndProcessing"]);
// 鐢ㄦ埛淇℃伅鍜岀叅绉嶆暟鎹�
const userStore = useUserStore();
-const { getCoalNameById } = useCoalData();
+const {getCoalNameById} = useCoalData();
let userInfo;
// 瀵硅瘽妗嗙姸鎬�
@@ -185,10 +199,16 @@
const selectedIds = ref([]);
const currentRow = ref(null);
const copyForm = ref(null);
+const coalList = ref([])
+const supplierList = ref([]);
// 琛ㄦ牸鍒楅厤缃�
const columns = [
- { label: "鐓ょ", prop: "coal", minwidth: 120 },
- { label: "搴撳瓨鏁伴噺", prop: "inventoryQuantity", minwidth: 100 },
+ {prop: "coalId", label: "鐓ょ", minwidth: 60,
+ formatter: (row) => {
+ return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--";
+ }
+ },
+ {label: "搴撳瓨鏁伴噺", prop: "inventoryQuantity", minwidth: 100},
{
label: "浣跨敤鏁伴噺",
prop: "usedQuantity",
@@ -199,18 +219,21 @@
];
const formalDatabaseColumns = ref([
- { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150 },
- { prop: "coal", label: "鐓ょ绫诲瀷", minwidth: 60 },
- { prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", minwidth: 80 },
- { prop: "unit", label: "鍗曚綅", minwidth: 20 },
- { prop: "priceExcludingTax", label: "鍗曚环锛堜笉鍚◣锛�", minwidth: 80 },
- { prop: "createTime", label: "鐧昏鏃ユ湡", width: 200 },
+ {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},
+ {prop: "createTime", label: "鐧昏鏃ユ湡", width: 200},
]);
// 宸ュ叿鍑芥暟
const debugIdMatching = () => {
if (formalDatabaseData.value.length > 0 && selectedIds.value.length > 0) {
const matchedRows = formalDatabaseData.value.filter((row) =>
- selectedIds.value.includes(row.id)
+ selectedIds.value.includes(row.id)
);
}
};
@@ -219,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("鑾峰彇閰嶇疆鏁版嵁澶辫触");
}
};
@@ -252,7 +301,7 @@
try {
etableRef.value.clearSelection();
const rowsToSelect = formalDatabaseData.value.filter((row) =>
- ids.includes(row.id)
+ ids.includes(row.id)
);
if (rowsToSelect.length > 0) {
etableRef.value.setRowsSelection(rowsToSelect, true);
@@ -264,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);
+ .map((item) => item.officialId)
+ .filter((id) => id);
selectedIds.value = existingOfficialIds;
+
+ // 鍔犺浇鍩虹鏁版嵁
+ await loadBasicData();
};
// 鐩戝惉瀵硅瘽妗嗙姸鎬侊紝鍦ㄦ墦寮�鏃惰缃�変腑鐘舵��
watch(innerVisible, (newVal) => {
@@ -319,8 +374,8 @@
// 鏇存柊selectedIds锛岀‘淇濆寘鍚墍鏈夊綋鍓峵ableData涓殑officialId
const allOfficialIds = tableData.value
- .map((item) => item.officialId)
- .filter((id) => id);
+ .map((item) => item.officialId)
+ .filter((id) => id);
selectedIds.value = allOfficialIds;
// 鍏抽棴閫夋嫨瀵硅瘽妗�
@@ -348,13 +403,13 @@
// 楠岃瘉鐢熶骇鏄庣粏鏁版嵁
const detailsValidation = validateFormData(detailsTableData.value, [
"coalId",
- "productionQuantity",
+ "productionQuantity",
"laborCost",
"energyConsumptionCost",
"equipmentDepreciation",
"purchasePrice"
]);
-
+
if (!detailsValidation.isValid) {
ElMessage.warning(detailsValidation.message);
return;
@@ -369,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;
}
}
@@ -400,13 +455,13 @@
const handleCellEdit = (row, prop, value) => {
if (prop === "usedQuantity") {
const validation = validateNumber(value, 0, Number(row.inventoryQuantity));
-
+
if (!validation.isValid) {
ElMessage.warning(validation.message);
row.usedQuantity = validation.value;
return;
}
-
+
row.usedQuantity = validation.value;
}
};
@@ -425,12 +480,13 @@
}
};
-// 鑾峰彇鐢ㄦ埛淇℃伅
+// 鑾峰彇鐢ㄦ埛淇℃伅骞跺姞杞藉熀纭�鏁版嵁
onMounted(async () => {
try {
userInfo = await userStore.getInfo();
+ await loadBasicData();
} catch (error) {
- ElMessage.error("鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛岃閲嶈瘯");
+ ElMessage.error("鍒濆鍖栧け璐ワ紝璇烽噸璇�");
}
});
@@ -445,15 +501,15 @@
// 鍒犻櫎鍗曚釜宸查�夋暟鎹」
const handleRemoveItem = (row) => {
const index = tableData.value.findIndex(
- (item) => item.officialId === row.officialId
+ (item) => item.officialId === row.officialId
);
if (index > -1) {
tableData.value.splice(index, 1);
// 鏇存柊selectedIds
const updatedOfficialIds = tableData.value
- .map((item) => item.officialId)
- .filter((id) => id);
+ .map((item) => item.officialId)
+ .filter((id) => id);
selectedIds.value = updatedOfficialIds;
ElMessage.success("宸插垹闄ら�変腑椤�");
}
@@ -470,21 +526,22 @@
cancelButtonText: "鍙栨秷",
type: "warning",
})
- .then(async () => {
- if (dialogType.value === "edit") {
- let res = await deleteProductionInventory({
- productionInventoryList: tableData.value,
- });
- emit("update:productionAndProcessing", tableData.value, copyForm.value);
- }
- // [Vue warn]: Component emitted event "update:productionAndProcessing" but it is neither declared in the emits option nor as an "onUpdate:productionAndProcessing" prop.
+ .then(async () => {
+ if (dialogType.value === "edit") {
+ let res = await deleteProductionInventory({
+ productionInventoryList: tableData.value,
+ });
+ emit("update:productionAndProcessing", tableData.value, copyForm.value);
+ }
+ // [Vue warn]: Component emitted event "update:productionAndProcessing" but it is neither declared in the emits option nor as an "onUpdate:productionAndProcessing" prop.
- formalDatabaseSelectedData.value = [];
- tableData.value = [];
- selectedIds.value = [];
- ElMessage.success("宸叉竻绌烘墍鏈夋暟鎹�");
- })
- .catch(() => {});
+ formalDatabaseSelectedData.value = [];
+ tableData.value = [];
+ selectedIds.value = [];
+ ElMessage.success("宸叉竻绌烘墍鏈夋暟鎹�");
+ })
+ .catch(() => {
+ });
};
// 璁$畻鎬讳娇鐢ㄩ噺
@@ -507,6 +564,7 @@
.el-row > .el-col > h1 {
font-weight: bolder;
}
+
.empty-table > .el-row {
margin-bottom: 12px;
}
--
Gitblit v1.9.3