From 437a70bd86d8adda3da41853b8b1c2706a22fdd7 Mon Sep 17 00:00:00 2001 From: 张诺 <zhang_12370@163.com> Date: 星期四, 12 六月 2025 18:03:59 +0800 Subject: [PATCH] 优化文档管理及基础信息页面 --- src/views/archiveManagement/index.vue | 160 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 141 insertions(+), 19 deletions(-) diff --git a/src/views/archiveManagement/index.vue b/src/views/archiveManagement/index.vue index 139b1e2..d5951dc 100644 --- a/src/views/archiveManagement/index.vue +++ b/src/views/archiveManagement/index.vue @@ -92,10 +92,21 @@ </div> <div class="right"> <el-row :gutter="24"> - <el-col :span="2" :offset="20"><el-button :icon="Delete" type="danger">鍒犻櫎</el-button></el-col> - <el-col :span="2"><el-button :icon="Plus" type="primary">鏂板</el-button></el-col> + <el-col :span="2" :offset="20" + ><el-button :icon="Delete" type="danger" @click="delHandler">鍒犻櫎</el-button></el-col + > + <el-col :span="2" + ><el-button + :icon="Plus" + type="primary" + @click="add" + :disabled="!tableData.length" + >鏂板</el-button + ></el-col + > </el-row> <ETable + :maxHeight="1200" :loading="loading" :table-data="tableData" :columns="columns" @@ -107,17 +118,27 @@ </ETable> <Pagination :total="total" - :page-size="10" - :page-count="Math.ceil(total / 10)" - @page-change="currentPageChange" + :page="queryParams.current" + :limit="queryParams.pageSize" + :show-total="true" + @pagination="handlePageChange" + :layout="'total, prev, pager, next, jumper'" ></Pagination> </div> + <archiveDialog + v-model:centerDialogVisible="dialogVisible" + @centerDialogVisible="centerDialogVisible" + :row="row" + @submitForm="submitForm" + > + </archiveDialog> </el-card> </template> <script setup> -import { onMounted, ref, nextTick } from "vue"; +import { onMounted, ref, nextTick, reactive } from "vue"; import ETable from "@/components/Table/ETable.vue"; -import { ElButton, ElInput, ElIcon } from "element-plus"; +import { ElButton, ElInput, ElIcon, ElMessage } from "element-plus"; +import archiveDialog from "./mould/archiveDialog.vue"; import Pagination from "@/components/Pagination/index.vue"; import { Plus, @@ -134,6 +155,7 @@ addOrEditArchive, delArchive, } from "@/api/archiveManagement"; +const dialogVisible = ref(false); // 鎺у埗褰掓。瀵硅瘽妗嗘樉绀� const loading = ref(false); const tableData = ref([]); const treeData = ref([]); @@ -142,35 +164,131 @@ const filterText = ref(""); // 鎼滅储鍏抽敭瀛� const treeRef = ref(); // 鏍戠粍浠跺紩鐢� const total = ref(0); // 鎬昏褰曟暟 -const current = ref(1); // 褰撳墠椤电爜 const columns = [ { prop: "name", label: "鍚嶇О", minWidth: 180 }, { prop: "type", label: "绫诲瀷", minWidth: 120 }, { prop: "status", label: "鐘舵��", minWidth: 100 }, ]; +const selectedRows = reactive([]); // 瀛樺偍閫変腑琛屾暟鎹� const handleSelectionChange = (selection) => { - console.log("Selected rows:", selection); + selectedRows.splice(0, selectedRows.length, ...selection); }; - +const queryParams = reactive({ + searchText: "", + current: 1, + pageSize: 10, // 鍥哄畾姣忛〉10鏉� + treeId: null, // 褰撳墠鏍戣妭鐐笽D +}); // 鎼滅储杩囨护鍔熻兘 const handleFilter = () => { treeRef.value?.filter(filterText.value); }; - +const row = ref({}); // 褰撳墠閫変腑琛屾暟鎹� const filterNode = (value, data) => { if (!value) return true; return data.name?.toLowerCase().includes(value.toLowerCase()); }; - +const submitForm = async (res) => { + console.log("鎻愪氦琛ㄥ崟鍥炶皟:", res); + + if (res && res.code === 200) { + ElMessage.success("鎿嶄綔鎴愬姛"); + // 鍒锋柊鍒楄〃鏁版嵁 + await getArchiveListData(); + } else { + ElMessage.error("鎿嶄綔澶辫触: " + (res?.message || "鏈煡閿欒")); + } +} +const centerDialogVisible = (val) => { + console.log(val); +}; // 澶勭悊鑺傜偣鐐瑰嚮 const handleNodeClick = async (data) => { console.log("鐐瑰嚮鑺傜偣:", data); - let res = await getArchiveList(data.id); - tableData.value = res.data?.records || res.data || []; - console.log(data) + // 鍒囨崲鑺傜偣鏃堕噸缃埌绗竴椤� + queryParams.current = 1; + queryParams.treeId = data.id; + getArchiveListData(); }; -const currentPageChange = (id) => { - console.log(id); +// add +const add = () => { + row.value = {}; // 娓呯┖琛屾暟鎹紝纭繚鏄柊澧炴ā寮� + dialogVisible.value = true; + newName.value = ""; // 娓呯┖杈撳叆妗� +}; +// 澶勭悊鍒嗛〉鍙樺寲 +const handlePageChange = ({ page }) => { + console.log("鍒嗛〉鍙樺寲:", { page }); + queryParams.current = page; + // pageSize 鍥哄畾涓�20锛屼笉鍐嶄粠鍙傛暟涓幏鍙� + getArchiveListData(); +}; + +const getArchiveListData = async () => { + try { + loading.value = true; + console.log("鑾峰彇褰掓。鍒楄〃鏁版嵁", { + treeId: queryParams.treeId, + current: queryParams.current, + pageSize: queryParams.pageSize, + }); + + let res = await getArchiveList({ + treeId: queryParams.treeId, + current: queryParams.current, + size: queryParams.pageSize, + }); + + if (res.code !== 200) { + ElMessage.error("鑾峰彇鏁版嵁澶辫触: " + res.message); + tableData.value = []; + total.value = 0; + return; + } + + tableData.value = res.data?.records || res.data || []; + total.value = res.data?.total || 0; + // 纭繚鍒嗛〉鍙傛暟姝g‘鏇存柊 + if (res.data?.current) { + queryParams.current = res.data.current; + } + // pageSize 鍥哄畾涓�20锛屼笉浠庡悗绔幏鍙� + + console.log("鏁版嵁鏇存柊瀹屾垚:", { + total: total.value, + current: queryParams.current, + pageSize: queryParams.pageSize, + records: tableData.value.length, + }); + } catch (error) { + console.error("鑾峰彇褰掓。鍒楄〃澶辫触:", error); + ElMessage.error("鑾峰彇鏁版嵁澶辫触"); + tableData.value = []; + total.value = 0; + } finally { + loading.value = false; + } +}; +const delHandler = async () => { + if (selectedRows.length === 0) { + ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁"); + return; + } + try { + const ids = selectedRows.map((row) => row.id); + console.log(ids) + const { code, msg } = await delArchive(ids); + if (code !== 200) { + ElMessage.warning("鍒犻櫎澶辫触: " + msg); + } else { + ElMessage.success("鍒犻櫎鎴愬姛"); + // 鍒犻櫎鎴愬姛鍚庨噸鏂拌幏鍙栨暟鎹� + await getArchiveListData(); + } + } catch (error) { + console.error("鍒犻櫎褰掓。澶辫触:", error); + ElMessage.error("鍒犻櫎褰掓。澶辫触"); + } }; // 鍙屽嚮缂栬緫鑺傜偣 const headerDbClick = (comeTreeData) => { @@ -327,7 +445,11 @@ } }; -const handleEdit = () => {}; +const handleEdit = (rows) => { + row.value = rows; + dialogVisible.value = true; + console.log("缂栬緫鑺傜偣:", row.value); +}; // 绉婚櫎鎳掑姞杞斤紝鐩存帴鑾峰彇鏁版嵁 const getList = async () => { @@ -564,7 +686,7 @@ float: left; } } -.archive-management-card{ +.archive-management-card { margin: 0; } </style> -- Gitblit v1.9.3