From 807df6dedd5078e0dd9f6515a8e1ea93e19a6f52 Mon Sep 17 00:00:00 2001
From: zhang_12370 <z2864490065@outlook.com>
Date: 星期三, 25 六月 2025 15:21:51 +0800
Subject: [PATCH] 文档管理 树形菜单 新增修改优化 生产加工模块的 数据tags 显示 生产人的匹配
---
src/views/basicInformation/index.vue | 124 ------------------------
src/views/production/components/ProductionDetailsTable.vue | 9 +
src/views/inspectionUpload/index.vue | 2
src/views/archiveManagement/mould/archiveDialog.vue | 1
src/components/dialog/Descriptions.vue | 34 ++++++
src/views/production/index.vue | 76 +++++++++++---
src/views/archiveManagement/index.vue | 24 +---
src/utils/production.js | 3
src/views/production/components/ProductionDialog.vue | 2
9 files changed, 106 insertions(+), 169 deletions(-)
diff --git a/src/components/dialog/Descriptions.vue b/src/components/dialog/Descriptions.vue
index eef36d5..dd53b35 100644
--- a/src/components/dialog/Descriptions.vue
+++ b/src/components/dialog/Descriptions.vue
@@ -96,6 +96,11 @@
fieldLabels: {
type: Object,
default: () => ({})
+ },
+ // 瀛楁鏄剧ず椤哄簭
+ fieldOrder: {
+ type: Array,
+ default: () => []
}
});
@@ -113,25 +118,46 @@
}
const data = { ...props.formData };
- let result = {};
+ let filteredResult = {};
// 濡傛灉鎸囧畾浜嗗寘鍚瓧娈碉紝鍒欏彧鏄剧ず杩欎簺瀛楁
if (props.includeFields.length > 0) {
props.includeFields.forEach(field => {
if (data.hasOwnProperty(field)) {
- result[field] = data[field];
+ filteredResult[field] = data[field];
}
});
} else {
// 鍚﹀垯鎺掗櫎鎸囧畾瀛楁
Object.keys(data).forEach(key => {
if (!props.excludeFields.includes(key)) {
- result[key] = data[key];
+ filteredResult[key] = data[key];
}
});
}
- return result;
+ // 濡傛灉鎸囧畾浜嗗瓧娈甸『搴忥紝鍒欐寜椤哄簭閲嶆柊缁勭粐鏁版嵁
+ if (props.fieldOrder.length > 0) {
+ const orderedResult = {};
+
+ // 鍏堟寜鎸囧畾椤哄簭娣诲姞瀛楁
+ props.fieldOrder.forEach(field => {
+ if (filteredResult.hasOwnProperty(field)) {
+ orderedResult[field] = filteredResult[field];
+ }
+ });
+
+ // 鍐嶆坊鍔犳湭鍦ㄩ『搴忎腑鎸囧畾鐨勫叾浠栧瓧娈�
+ Object.keys(filteredResult).forEach(key => {
+ if (!props.fieldOrder.includes(key)) {
+ orderedResult[key] = filteredResult[key];
+ }
+ });
+
+ return orderedResult;
+ }
+
+ return filteredResult;
});
// 鑾峰彇瀛楁鏄剧ず鏍囩
diff --git a/src/utils/production.js b/src/utils/production.js
index 35e00e5..c95241c 100644
--- a/src/utils/production.js
+++ b/src/utils/production.js
@@ -10,9 +10,7 @@
*/
export function parseCoalArray(coalString) {
if (!coalString) return [];
-
if (Array.isArray(coalString)) return coalString;
-
return String(coalString)
.replace(/^\[|\]$/g, '')
.split(',')
@@ -61,7 +59,6 @@
}
for (let i = 0; i < data.length; i++) {
- console.log(data[i])
const item = data[i];
for (const field of requiredFields) {
if (item[field] === '' || item[field] === null || item[field] === undefined) {
diff --git a/src/views/archiveManagement/index.vue b/src/views/archiveManagement/index.vue
index c3e56e4..f1fb1e2 100644
--- a/src/views/archiveManagement/index.vue
+++ b/src/views/archiveManagement/index.vue
@@ -201,15 +201,14 @@
ElMessage.error("鎿嶄綔澶辫触锛岃绋嶅悗閲嶈瘯");
}
};
-// 褰撳墠缁勪欢鐨勬暟鎹�
-const initTreeData = ref([]); // 鏍戝舰鏁版嵁
+
const centerDialogVisible = (val) => {
dialogVisible.value = val;
};
const tableSwitch = ref(false);
// 澶勭悊鑺傜偣鐐瑰嚮
const handleNodeClick = (data) => {
- initTreeData.value = data || [];
+ console.log("鐐瑰嚮鑺傜偣", data);
tableSwitch.value = true;
// 鍒囨崲鑺傜偣鏃堕噸缃埌绗竴椤�
queryParams.current = 1;
@@ -227,7 +226,7 @@
// 纭繚缁勪欢寮曠敤瀛樺湪鍚庡啀璋冪敤鏂规硶
nextTick(() => {
if (archiveDialogs.value && typeof archiveDialogs.value.initForm === 'function') {
- archiveDialogs.value.initForm(initTreeData); // 閲嶇疆琛ㄥ崟
+ archiveDialogs.value.initForm(); // 閲嶇疆琛ㄥ崟
}
});
} catch (error) {
@@ -489,15 +488,16 @@
const hasChildren = data.children;
const nodeKey = data.id || data;
const node = treeRef.value?.getNode(nodeKey);
- const isExpanded = node?.expanded;
-
- // 濡傛灉鏈夊瓙绾т笖鏈睍寮�锛屽厛灞曞紑鑺傜偣
+ const isExpanded = node?.expanded; // 濡傛灉鏈夊瓙绾т笖鏈睍寮�锛屽厛灞曞紑鑺傜偣
if (hasChildren && !isExpanded) {
- if (treeRef.value && treeRef.value.store && treeRef.value.store.nodesMap[nodeKey]) {
+ if (
+ treeRef.value &&
+ treeRef.value.store &&
+ treeRef.value.store.nodesMap[nodeKey]
+ ) {
treeRef.value.store.nodesMap[nodeKey].expanded = true;
}
}
-
const newNode = {
name: "鏂板瓙鑺傜偣",
isEdit: true,
@@ -508,12 +508,6 @@
}
data.children.push(newNode);
newName.value = "鏂板瓙鑺傜偣";
-
- // 纭繚鐖惰妭鐐瑰睍寮�
- if (node) {
- node.expanded = true;
- expandParentNodes(node);
- }
// 鏍规嵁鏄惁闇�瑕佸睍寮�鏉ュ喅瀹氬欢杩熸椂闂�
const delay = hasChildren && !isExpanded ? 200 : 50;
diff --git a/src/views/archiveManagement/mould/archiveDialog.vue b/src/views/archiveManagement/mould/archiveDialog.vue
index 18014fe..07b1e00 100644
--- a/src/views/archiveManagement/mould/archiveDialog.vue
+++ b/src/views/archiveManagement/mould/archiveDialog.vue
@@ -149,7 +149,6 @@
// 鍙戦�� emit 浜嬩欢
// 鍏抽棴瀵硅瘽妗�
- ElMessage.success("鎿嶄綔鎴愬姛");
centerDialogVisible.value = false;
} catch (error) {
ElMessage({
diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue
index caf93be..4f47266 100644
--- a/src/views/basicInformation/index.vue
+++ b/src/views/basicInformation/index.vue
@@ -146,21 +146,6 @@
:title="title"
@submit="handleSubmit"
/>
- <Descriptions
- v-model:descriptionsVisible="showDialog"
- title="渚涘簲鍟嗚鎯�"
- :formData="supplierData"
- :fieldLabels="supplierFieldLabels"
- :column="2"
- :isViewOnly="false"
- :border="true"
- :showOperations="true"
- descriptionsTitle="鍩烘湰淇℃伅"
- :fieldConfig="fieldConfig"
- :excludeFields="excludeFields"
- @edit="descriptionsHandleEdit"
- @close="handleClose"
- />
</el-card>
</div>
</template>
@@ -206,74 +191,18 @@
} from "@/api/basicInformation/coalQualityMaintenance";
const { proxy } = getCurrentInstance();
-import router from "@/router";
// ===== 鍝嶅簲寮忕姸鎬佺鐞� =====
// 寮圭獥鎺у埗鐘舵��
-const showDialog = ref(false)
-const supplierFieldLabels = {
- supplierName: '渚涘簲鍟嗗悕绉�',
- taxpayerId: '缁熶竴绀句細淇$敤浠g爜',
-}
-// 鏁版嵁瀵硅薄
-const supplierData = ref({
- supplierName: "娴嬭瘯渚涘簲鍟�",
- taxpayerId: "91320000MA1N2P3Q4R",
- contactPerson: "寮犱笁",
- contactPhone: "13800138000",
- bankAccount: "6222024200019999999",
- bankName: "涓浗宸ュ晢閾惰",
- businessAddress: "姹熻嫃鐪佽嫃宸炲競宸ヤ笟鍥尯鏄熸箹琛�328鍙�",
- contactAddress: "姹熻嫃鐪佽嫃宸炲競濮戣嫃鍖鸿鍓嶈100鍙�",
- createTime: "2024-01-15T10:30:00",
- updateTime: "2024-06-25T14:20:00",
- id: 123,
-})
-// 瀛楁閰嶇疆
-const fieldConfig = ref({
- supplierName: {
- label: '渚涘簲鍟嗗悕绉�',
- span: 2 // 璺�2鍒楁樉绀�
- },
- taxpayerId: {
- label: '缁熶竴绀句細淇$敤浠g爜'
- },
- contactPhone: {
- label: '鑱旂郴鐢佃瘽',
- formatter: (value) => value || '鏆傛棤鑱旂郴鏂瑰紡'
- },
- createTime: {
- label: '鍒涘缓鏃堕棿',
- formatter: (value) => new Date(value).toLocaleDateString('zh-CN')
- },
- businessAddress: {
- label: '璇︾粏缁忚惀鍦板潃',
- span: 2
- },
- contactAddress: {
- label: '璇︾粏鑱旂郴鍦板潃',
- span: 2
- }
-})
-// 鎺掗櫎涓嶆樉绀虹殑瀛楁
-const excludeFields = ref(["id", "updateTime", "deleted"]);
+const showDialog = ref(false);
+const currentViewData = ref({}); // 褰撳墠鏌ョ湅鐨勬暟鎹�
-// 浜嬩欢澶勭悊
-const descriptionsHandleEdit = (data) => {
- console.log("缂栬緫鏁版嵁:", data);
- // 璺宠浆鍒扮紪杈戦〉闈㈡垨鎵撳紑缂栬緫寮圭獥
-};
-
-const handleClose = () => {
- console.log("寮圭獥鍏抽棴");
-};
const dialogFormVisible = ref(false);
const form = ref({});
const title = ref("");
const copyForm = ref({});
const addOrEdit = ref("add");
-const descriptionsVisible = ref(false);
// 鏁版嵁缂撳瓨鏄犲皠
const userList = ref([]);
@@ -430,8 +359,6 @@
return matchedField ? matchedField.fieldName : numId;
};
-// ===== 璁$畻灞炴�� =====
-
/**
* 褰撳墠鏍囩椤垫槸鍚︽敮鎸佸鍑哄姛鑳�
*/
@@ -470,11 +397,6 @@
* 褰撳墠閫変腑琛屾暟閲�
*/
const selectedCount = computed(() => selectedRows.value.length);
-
-/**
- * 鏄惁鏈夐�変腑鐨勮
- */
-const hasSelectedRows = computed(() => selectedCount.value > 0);
// ===== 琛ㄦ牸鍒楅厤缃� =====
@@ -796,48 +718,6 @@
handleAddEdit(tabName.value);
};
-/**
- * 鏌ョ湅鎸夐挳鐐瑰嚮澶勭悊
- * @param {Object} row - 琛屾暟鎹�
- * @description 澶勭悊鏌ョ湅鎿嶄綔锛屾瀯寤哄湴鍧�鏁扮粍骞舵墦寮�鏌ョ湅寮圭獥
- */
-const handleView = (row) => {
- console.log("鏌ョ湅琛屾暟鎹�:", row);
- // 鎷垮埌鎵�鏈夌殑keys
- const keys = Object.keys(row);
- console.log("鎵�鏈塳eys:", keys);
- showDialog.value = true;
- // form.value = JSON.parse(JSON.stringify(row));
- // console.log("鏌ョ湅琛屾暟鎹�:", form.value);
- // // 鏋勫缓渚涘簲鍟嗕笟鍔″湴鍧�鏁扮粍
- // if (form.value.bprovinceId && form.value.bdistrictId && form.value.bcityId) {
- // form.value.bids = [row.bprovinceId, row.bcityId, row.bdistrictId];
- // }
- // // 鏋勫缓渚涘簲鍟嗚仈绯诲湴鍧�鏁扮粍
- // if (form.value.cprovinceId && form.value.cdistrictId && form.value.ccityId) {
- // form.value.cids = [row.cprovinceId, row.ccityId, row.cdistrictId];
- // }
- // // 鏋勫缓瀹㈡埛涓氬姟鍦板潃鏁扮粍
- // if (
- // form.value.businessCityId &&
- // form.value.businessDistrictId &&
- // form.value.businessProvinceId
- // ) {
- // form.value.bids = [
- // row.businessProvinceId,
- // row.businessCityId,
- // row.businessDistrictId,
- // ];
- // }
-
- // // 鏋勫缓瀹㈡埛鑱旂郴鍦板潃鏁扮粍
- // if (form.value.cityId && form.value.districtId && form.value.provinceId) {
- // form.value.cids = [row.provinceId, row.cityId, row.districtId];
- // }
-
- // addOrEdit.value = "viewRow";
- // handleAddEdit(tabName.value);
-};
/**
* 鎵归噺鍒犻櫎澶勭悊
diff --git a/src/views/inspectionUpload/index.vue b/src/views/inspectionUpload/index.vue
index 85e92a9..12bb8c8 100644
--- a/src/views/inspectionUpload/index.vue
+++ b/src/views/inspectionUpload/index.vue
@@ -66,7 +66,7 @@
</template>
</el-table-column>
</el-table>
- <el-table ref="table" :data="tableData" height="480" v-loading="tableLoading" v-if="activeTab === 'qrCode'"border style="width: 100%;height: calc(100vh - 23em)">
+ <el-table ref="table" :data="tableData" height="480" v-loading="tableLoading" v-if="activeTab === 'qrCode'" border style="width: 100%;height: calc(100vh - 23em)">
<el-table-column label="搴忓彿" type="index" width="60" align="center" />
<el-table-column prop="deviceName" label="璁惧鍚嶇О" :show-overflow-tooltip="true">
<template #default="scope">
diff --git a/src/views/production/components/ProductionDetailsTable.vue b/src/views/production/components/ProductionDetailsTable.vue
index 1db3794..8331deb 100644
--- a/src/views/production/components/ProductionDetailsTable.vue
+++ b/src/views/production/components/ProductionDetailsTable.vue
@@ -110,7 +110,7 @@
<template #default="{ row, $index }">
<el-select
clearable
- :model-value="getUserNameById(row.producer) || row.producer"
+ :model-value="getUserNameById(row.producerId) || row.producerId"
placeholder="璇烽�夋嫨鐢熶骇浜�"
@change="(value) => handleUserSelectChange(row, value)"
filterable
@@ -339,12 +339,13 @@
};
// 澶勭悊鐢ㄦ埛閫夋嫨鍙樺寲锛堟柊鏂规硶锛氬悕绉伴�夋嫨杞琁D锛�
const handleUserSelectChange = (row, selectedName) => {
+ console.log("handleUserSelectChange", row, selectedName);
// 鏍规嵁閫夋嫨鐨勫悕绉版壘鍒板搴旂殑ID
const userItem = userList.value.find(item => item.value === selectedName);
if (userItem) {
- row.producer = userItem.key; // 璁剧疆涓篒D
+ row.producerId = userItem.key; // 璁剧疆涓篒D
} else {
- row.producer = ''; // 濡傛灉娌℃壘鍒帮紝娓呯┖
+ row.producerId = ''; // 濡傛灉娌℃壘鍒帮紝娓呯┖
}
};
// 鏆撮湶鏂规硶缁欑埗缁勪欢浣跨敤
@@ -364,7 +365,7 @@
equipmentDepreciation: "",
purchasePrice: "",
totalCost: "",
- producer: "",
+ producerId: "",
...rowData,
};
tableData.value = [...tableData.value, defaultRow];
diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue
index 3b96834..8c16696 100644
--- a/src/views/production/components/ProductionDialog.vue
+++ b/src/views/production/components/ProductionDialog.vue
@@ -396,7 +396,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;
}
}
diff --git a/src/views/production/index.vue b/src/views/production/index.vue
index 223d465..1003361 100644
--- a/src/views/production/index.vue
+++ b/src/views/production/index.vue
@@ -1,5 +1,5 @@
<template>
- <div class="app-container">
+ <div>
<!-- 鎼滅储琛ㄥ崟 -->
<el-form :inline="true" :model="queryParams" class="search-form">
<el-form-item label="鎼滅储">
@@ -39,12 +39,20 @@
:border="true"
style="width: 100%;height: calc(100vh - 26em)"
>
- <template #coal="{ row }">
+ <template #coalId="{ row }">
<div class="coal-tags">
- <el-tag v-for="coal in parseCoalArray(row.coal)" :key="coal" size="small">
- {{ getCoalNameById(coal) }}
- </el-tag>
- <span v-if="!row.coal">--</span>
+ <template v-if="row.coalId">
+ <el-tag
+ v-for="coal in parseCoalArray(row.coalId)"
+ :key="coal"
+ size="small"
+ type="primary"
+ class="coal-tag"
+ >
+ {{ getDisplayCoalName(coal) }}
+ </el-tag>
+ </template>
+ <span v-else class="no-data">--</span>
</div>
</template>
</ETable> <!-- 鍒嗛〉缁勪欢 -->
@@ -70,7 +78,7 @@
</template>
<script setup>
-import {onMounted} from "vue";
+import {onMounted, ref} from "vue";
import {ElMessage} from "element-plus";
import {Plus, Delete} from "@element-plus/icons-vue";
import ProductionDialog from "./components/ProductionDialog.vue";
@@ -83,13 +91,12 @@
import {useCoalData} from "./components/useCoalData.js";
import {getCoalInfoList} from "@/api/production";
+// 鐓ょ淇℃伅鍒楄〃
+const coalInfoList = ref([]);
+
// 琛ㄦ牸鍒楅厤缃�
const columns = [
- {prop: "coalId", label: "鐓ょ", minWidth: 150,
- formatter: (row) => {
- return coalInfoList.value.find(item => item.id == row.coalId)?.coal || '--';
- }
- },
+ {prop: "coalId", label: "鐓ょ", minWidth: 150, slot: true},
{prop: "productionQuantity", label: "鐢熶骇鏁伴噺", minWidth: 120},
{prop: "laborCost", label: "浜哄伐鎴愭湰", minWidth: 150},
{prop: "energyConsumptionCost", label: "鑳借�楁垚鏈�", minWidth: 120},
@@ -124,6 +131,20 @@
// 浣跨敤鐓ょ鏁版嵁缁勫悎寮忓嚱鏁�
const {getCoalNameById, getCoalData} = useCoalData();
+// 鑾峰彇鐓ょ鏄剧ず鍚嶇О锛堝甫澶囩敤閫昏緫锛�
+const getDisplayCoalName = (coalId) => {
+ // 浼樺厛浣跨敤 useCoalData 鐨勬柟娉�
+ let name = getCoalNameById(coalId);
+
+ // 濡傛灉娌℃湁鎵惧埌锛屽皾璇曚粠 coalInfoList 涓煡鎵�
+ if (name === coalId && coalInfoList.value.length > 0) {
+ const found = coalInfoList.value.find(item => item.id == coalId);
+ name = found ? found.coal : coalId;
+ }
+
+ return name || coalId;
+};
+
// 澶勭悊鐢熶骇鏁版嵁鏇存柊
const handleProductionAndProcessing = (row, rows) => {
const index = tableData.value.findIndex(item => item.id === rows.id);
@@ -139,13 +160,26 @@
ElMessage.success("鎿嶄綔鎴愬姛");
});
};
-const coalInfoList = ref([]);
+
// 缁勪欢鎸傝浇鏃跺姞杞芥暟鎹�
onMounted(async () => {
- await getCoalData(); // 棰勫姞杞界叅绉嶆暟鎹�
- getList();
- let res = await getCoalInfoList()
- coalInfoList.value = res.data;
+ try {
+ // 骞惰鍔犺浇鐓ょ鏁版嵁鍜岃〃鏍兼暟鎹�
+ await Promise.all([
+ getCoalData(), // 棰勫姞杞界叅绉嶆暟鎹�
+ (async () => {
+ const res = await getCoalInfoList();
+ if (res.code === 200) {
+ coalInfoList.value = res.data;
+ }
+ })()
+ ]);
+
+ // 鍔犺浇琛ㄦ牸鏁版嵁
+ getList();
+ } catch (error) {
+ ElMessage.error('鏁版嵁鍔犺浇澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯');
+ }
});
</script>
@@ -187,8 +221,9 @@
display: flex;
flex-wrap: wrap;
gap: 4px;
+ align-items: center;
- .el-tag {
+ .coal-tag {
margin-right: 4px;
margin-bottom: 4px;
@@ -196,5 +231,10 @@
margin-right: 0;
}
}
+
+ .no-data {
+ color: #999;
+ font-style: italic;
+ }
}
</style>
--
Gitblit v1.9.3