From aaf943ada13005f2b22d01e3d7080b8740d9aa96 Mon Sep 17 00:00:00 2001 From: zhang_12370 <z2864490065@outlook.com> Date: 星期二, 15 七月 2025 15:09:49 +0800 Subject: [PATCH] 添加待入库功能及优化配煤计算器 --- src/views/archiveManagement/index.vue | 298 +++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 175 insertions(+), 123 deletions(-) diff --git a/src/views/archiveManagement/index.vue b/src/views/archiveManagement/index.vue index af8c450..81d3a18 100644 --- a/src/views/archiveManagement/index.vue +++ b/src/views/archiveManagement/index.vue @@ -5,23 +5,22 @@ <div class="tree-header"> <h3>鏂囨。绠$悊</h3> <el-button icon="Plus" size="small" type="primary" @click="append('')" - >鏂板 - </el-button - > + >鏂板 + </el-button> </div> <!-- 鎼滅储妗� --> <div class="search-box"> <el-input - v-model="filterText" - clearable - placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" - size="small" - @input="handleFilter" + v-model="filterText" + clearable + placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" + size="small" + @input="handleFilter" > <template #prefix> <el-icon> - <Search/> + <Search /> </el-icon> </template> </el-input> @@ -29,62 +28,63 @@ <div class="tree-container"> <el-tree - ref="treeRef" - :data="treeData" - :default-expand-all="false" - :expand-on-click-node="false" - :filter-node-method="filterNode" - :props="props" - class="custom-tree" - node-key="id" - @node-click="handleNodeClick" + ref="treeRef" + :data="treeData" + :default-expand-all="false" + :expand-on-click-node="false" + :filter-node-method="filterNode" + :props="props" + class="custom-tree" + node-key="id" + @node-click="handleNodeClick" > <template #default="{ node, data }"> - <div class="tree-node-content" @dblclick="headerDbClick(node,data)"> + <div + class="tree-node-content" + @dblclick="headerDbClick(node, data)" + > <div class="node-icon"> <el-icon - v-if="!node.isLeaf" - :class="{ expanded: node.expanded }" + v-if="!node.isLeaf" + :class="{ expanded: node.expanded }" > - <Folder/> + <Folder /> </el-icon> <el-icon v-else> - <Document/> + <Document /> </el-icon> </div> <div class="node-label"> <span v-if="!data.isEdit" class="label-text">{{ - node.label - }}</span> + node.label + }}</span> <el-input - v-else - :ref="(el) => setInputRef(el, data)" - v-model="newName" - autofocus - class="tree-input" - placeholder="璇疯緭鍏ヨ妭鐐瑰悕绉�" - size="small" - @blur="(event) => handleInputBlur(event, data, node)" - @keyup.enter=" - (event) => handleInputBlur(event, data, node) - " + v-else + :ref="(el) => setInputRef(el, data)" + v-model="newName" + autofocus + class="tree-input" + placeholder="璇疯緭鍏ヨ妭鐐瑰悕绉�" + size="small" + @blur="(event) => handleInputBlur(event, data, node)" + @keyup.enter="(event) => handleInputBlur(event, data, node)" /> </div> <div v-show="!data.isEdit" class="node-actions"> <el-button - icon="Plus" - link - size="small" - title="鏂板瀛愯妭鐐�" - @click.stop="append(data)" + icon="Plus" + link + size="small" + title="鏂板瀛愯妭鐐�" + @click.stop="append(data)" ></el-button> <el-button - icon="Delete" - link - size="small" - title="鍒犻櫎" - @click.stop="remove(node, data)" + icon="Delete" + link + size="small" + title="鍒犻櫎" + @click.stop="remove(node, data)" ></el-button> </div> </div> @@ -95,65 +95,104 @@ </div> <div class="right"> <el-row :gutter="24"> - <el-col :offset="20" :span="2" - > - <el-button :icon="Delete" type="danger" @click="delHandler">鍒犻櫎</el-button> - </el-col - > - <el-col :span="2" - > - <el-button - :disabled="!tableSwitch" - :icon="Plus" - type="primary" - @click="add" - >鏂板 - </el-button + <el-col :span="10"> + <div> + <el-input + style="float: left; width: 50%" + v-model="searchText" + placeholder="璇疯緭鍏ュ叧閿瓧鏌ヨ鏂囦欢" + clearable + @input="handleSearch" + @clear="handleSearch" + > + <template #prefix> + <el-icon> + <Search /> + </el-icon> + </template> + <template #suffix> + <el-button @click="handleSearch" link style="border: none"> + <span>鎼滅储</span> + </el-button> + </template> + </el-input> + </div> + </el-col> + <el-col :offset="8" :span="3"> + <el-button :icon="Delete" type="danger" @click="delHandler" + >鍒犻櫎</el-button > - </el-col - > + </el-col> + <el-col :span="3"> + <el-button + :disabled="!tableSwitch" + :icon="Plus" + type="primary" + @click="add" + >鏂板 + </el-button> + </el-col> </el-row> <ETable - :border="true" - :columns="columns" - :loading="loading" - :maxHeight="1200" - :show-selection="true" - :table-data="tableData" - @edit="handleEdit" - @selection-change="handleSelectionChange" + :border="true" + :columns="columns" + :loading="loading" + :maxHeight="1200" + :show-selection="true" + :table-data="tableData" + @edit="handleEdit" + @selection-change="handleSelectionChange" + style="height: calc(65vh);" > </ETable> <Pagination - :layout="'total, prev, pager, next, jumper'" - :limit="queryParams.pageSize" - :page="queryParams.current" - :show-total="true" - :total="total" - @pagination="handlePageChange" + :layout="'total, prev, pager, next, jumper'" + :limit="queryParams.pageSize" + :page="queryParams.current" + :show-total="true" + :total="total" + @pagination="handlePageChange" ></Pagination> </div> <archiveDialog - ref="archiveDialogs" - v-model:centerDialogVisible="dialogVisible" - :row="row" - @centerDialogVisible="centerDialogVisible" - @submitForm="submitForm" - + ref="archiveDialogs" + v-model:centerDialogVisible="dialogVisible" + :row="row" + @centerDialogVisible="centerDialogVisible" + @submitForm="submitForm" > </archiveDialog> </el-card> </template> <script setup> -import {nextTick, onMounted, reactive, ref} from "vue"; +import { nextTick, onMounted, reactive, ref } from "vue"; import ETable from "@/components/Table/ETable.vue"; -import {ElButton, ElIcon, ElInput, ElMessage, ElMessageBox} from "element-plus"; +import { + ElButton, + ElIcon, + ElInput, + ElMessage, + ElMessageBox, +} from "element-plus"; import archiveDialog from "./mould/archiveDialog.vue"; import Pagination from "@/components/Pagination/index.vue"; -import {Delete, Document, Folder, Plus, Search,} from "@element-plus/icons-vue"; -import {addOrEditTree, delArchive, delTree, getArchiveList, getTree,} from "@/api/archiveManagement"; +import { + Delete, + Document, + Folder, + Plus, + Search, +} from "@element-plus/icons-vue"; +import { + addOrEditTree, + delArchive, + delTree, + getArchiveList, + getTree, +} from "@/api/archiveManagement"; // ===== 鍝嶅簲寮忕姸鎬佺鐞� ===== +const searchText = ref(""); const dialogVisible = ref(false); const loading = ref(false); const tableData = ref([]); @@ -171,9 +210,9 @@ // ===== 閰嶇疆甯搁噺 ===== const columns = [ - {prop: "name", label: "鍚嶇О", minWidth: 180}, - {prop: "type", label: "绫诲瀷", minWidth: 120}, - {prop: "status", label: "鐘舵��", minWidth: 100}, + { prop: "name", label: "鍚嶇О", minWidth: 180 }, + { prop: "type", label: "绫诲瀷", minWidth: 120 }, + { prop: "status", label: "鐘舵��", minWidth: 100 }, ]; const queryParams = reactive({ @@ -199,11 +238,18 @@ ElMessage.success(msg); }; +// 鎼滅储鏌ヨ鍑芥暟 +const handleSearch = () => { + queryParams.searchAll = searchText.value; + queryParams.current = 1; // 閲嶇疆鍒扮涓�椤� + getArchiveListData(); +}; + const showConfirm = (message, title = "纭鎿嶄綔") => { return ElMessageBox.confirm(message, title, { - confirmButtonText: '纭畾', - cancelButtonText: '鍙栨秷', - type: 'warning', + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", }); }; @@ -228,7 +274,8 @@ const getList = async () => { try { const res = await getTree(); - treeData.value = res.code === 200 ? (res.data?.records || res.data || []) : []; + treeData.value = + res.code === 200 ? res.data?.records || res.data || [] : []; } catch (error) { handleError(error, "鑾峰彇鏍戠粨鏋勬暟鎹け璐�"); treeData.value = []; @@ -242,6 +289,7 @@ treeId: queryParams.treeId, current: queryParams.current, size: queryParams.pageSize, + searchAll: queryParams.searchAll, }); if (res.code !== 200) { @@ -250,10 +298,10 @@ total.value = 0; return; } - + tableData.value = res.data?.records || res.data || []; total.value = res.data?.total || 0; - + if (res.data?.current) { queryParams.current = res.data.current; } @@ -306,17 +354,17 @@ row.value = isEdit ? { ...rowData } : {}; newName.value = ""; dialogVisible.value = true; - + nextTick(() => { if (archiveDialogs.value) { - const method = isEdit ? 'editForm' : 'initForm'; - if (typeof archiveDialogs.value[method] === 'function') { + const method = isEdit ? "editForm" : "initForm"; + if (typeof archiveDialogs.value[method] === "function") { archiveDialogs.value[method](isEdit ? rowData : rowClickData.value); } } }); } catch (error) { - handleError(error, `鎵撳紑${isEdit ? '缂栬緫' : '鏂板'}鐣岄潰澶辫触`); + handleError(error, `鎵撳紑${isEdit ? "缂栬緫" : "鏂板"}鐣岄潰澶辫触`); } }; @@ -331,11 +379,14 @@ } try { - await showConfirm(`纭畾瑕佸垹闄ら�変腑鐨� ${selectedRows.length} 鏉¤褰曞悧锛焋, '鍒犻櫎纭'); - + await showConfirm( + `纭畾瑕佸垹闄ら�変腑鐨� ${selectedRows.length} 鏉¤褰曞悧锛焋, + "鍒犻櫎纭" + ); + const ids = selectedRows.map((row) => row.id); const { code, msg } = await delArchive(ids); - + if (code !== 200) { ElMessage.error("鍒犻櫎澶辫触: " + msg); return; @@ -344,9 +395,8 @@ showSuccess("鍒犻櫎鎴愬姛"); await getArchiveListData(); selectedRows.splice(0, selectedRows.length); - } catch (error) { - if (error !== 'cancel') { + if (error !== "cancel") { handleError(error, "鍒犻櫎鎿嶄綔澶辫触"); } } @@ -359,10 +409,10 @@ } try { - await showConfirm(`纭畾瑕佸垹闄よ妭鐐� "${data.name}" 鍚楋紵`, '鍒犻櫎纭'); - + await showConfirm(`纭畾瑕佸垹闄よ妭鐐� "${data.name}" 鍚楋紵`, "鍒犻櫎纭"); + const { code, msg } = await delTree([data.id]); - + if (code !== 200) { ElMessage.error("鍒犻櫎澶辫触: " + msg); return; @@ -370,9 +420,8 @@ showSuccess("鍒犻櫎鎴愬姛"); await getList(); - } catch (error) { - if (error !== 'cancel') { + if (error !== "cancel") { handleError(error, "鍒犻櫎鑺傜偣澶辫触"); } } @@ -405,37 +454,38 @@ const handleInputBlur = async (event, comeTreeData, node) => { try { - if (!comeTreeData.isEdit || (event.relatedTarget?.tagName === "BUTTON")) return; - + if (!comeTreeData.isEdit || event.relatedTarget?.tagName === "BUTTON") + return; + comeTreeData.isEdit = false; const newValue = newName.value.trim(); - + if (comeTreeData.name === newValue) return; - + if (!newValue) { newName.value = comeTreeData.name || "鏂拌妭鐐�"; ElMessage.warning("鑺傜偣鍚嶇О涓嶈兘涓虹┖"); return; } - + const parentId = node?.parent?.data?.id || null; - + const result = await addOrEditTree({ name: newValue, parentId, id: comeTreeData.id || null, }); - + if (result.code === 200) { comeTreeData.name = newValue; if (!comeTreeData.id && result.data) { comeTreeData.id = result.data.id || result.data; } showSuccess("淇濆瓨鎴愬姛"); - + const currentNodeId = comeTreeData.id; await getList(); - + nextTick(() => { if (currentNodeId && treeRef.value) { const targetNode = treeRef.value.getNode(currentNodeId); @@ -449,7 +499,6 @@ comeTreeData.name = comeTreeData.name || "鏂拌妭鐐�"; ElMessage.error("淇濆瓨澶辫触: " + (result.msg || "鏈煡閿欒")); } - } catch (error) { handleError(error, "淇濆瓨鑺傜偣澶辫触"); comeTreeData.name = comeTreeData.name || "鏂拌妭鐐�"; @@ -489,14 +538,14 @@ const nodeKey = data.id || data; const node = treeRef.value?.getNode(nodeKey); const isExpanded = node?.expanded; - + // 濡傛灉鏈夊瓙绾т笖鏈睍寮�锛屽厛灞曞紑鑺傜偣 if (hasChildren && !isExpanded && treeRef.value?.store?.nodesMap[nodeKey]) { treeRef.value.store.nodesMap[nodeKey].expanded = true; } - + const newNode = createNewNode("鏂板瓙鑺傜偣"); - + if (!data.children) { data.children = []; } @@ -509,7 +558,10 @@ }; // ===== 鐢熷懡鍛ㄦ湡 ===== -onMounted(getList); +onMounted(()=>{ + getList(); + getArchiveListData(); +}); </script> <style lang="scss" scoped> .custom-tree-node { -- Gitblit v1.9.3