From c25a27347be2c46177b615426297836b30915608 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 20 六月 2025 15:19:37 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
src/views/archiveManagement/index.vue | 158 ++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 126 insertions(+), 32 deletions(-)
diff --git a/src/views/archiveManagement/index.vue b/src/views/archiveManagement/index.vue
index 139b1e2..7e7c65d 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,29 @@
</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"
+ ref="archiveDialogs"
+
+ >
+ </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 +157,7 @@
addOrEditArchive,
delArchive,
} from "@/api/archiveManagement";
+const dialogVisible = ref(false); // 鎺у埗褰掓。瀵硅瘽妗嗘樉绀�
const loading = ref(false);
const tableData = ref([]);
const treeData = ref([]);
@@ -142,35 +166,113 @@
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({
+ searchAll: "",
+ 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) => {
+ if (res && res.code === 200) {
+ ElMessage.success("鎿嶄綔鎴愬姛");
+ // 鍒锋柊鍒楄〃鏁版嵁
+ await getArchiveListData();
+ } else {
+ ElMessage.error("鎿嶄綔澶辫触: " + (res?.message || "鏈煡閿欒"));
+ }
+}
+const centerDialogVisible = (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);
+const archiveDialogs = ref(null); // 琛ㄦ牸缁勪欢寮曠敤
+// add
+const add = () => {
+ row.value = {}; // 娓呯┖琛屾暟鎹紝纭繚鏄柊澧炴ā寮�
+ dialogVisible.value = true;
+ newName.value = ""; // 娓呯┖杈撳叆妗�
+ archiveDialogs.value.initForm(); // 閲嶇疆琛ㄥ崟
+};
+// 澶勭悊鍒嗛〉鍙樺寲
+const handlePageChange = ({ page }) => {
+ queryParams.current = page;
+ // pageSize 鍥哄畾涓�20锛屼笉鍐嶄粠鍙傛暟涓幏鍙�
+ getArchiveListData();
+};
+
+const getArchiveListData = async () => {
+ try {
+ loading.value = true;
+ 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锛屼笉浠庡悗绔幏鍙�
+
+ } catch (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);
+ const { code, msg } = await delArchive(ids);
+ if (code !== 200) {
+ ElMessage.warning("鍒犻櫎澶辫触: " + msg);
+ } else {
+ ElMessage.success("鍒犻櫎鎴愬姛");
+ // 鍒犻櫎鎴愬姛鍚庨噸鏂拌幏鍙栨暟鎹�
+ await getArchiveListData();
+ }
+ } catch (error) {
+ ElMessage.error("鍒犻櫎褰掓。澶辫触");
+ }
};
// 鍙屽嚮缂栬緫鑺傜偣
const headerDbClick = (comeTreeData) => {
@@ -207,11 +309,9 @@
comeTreeData.isEdit = false;
const newValue = newName.value.trim();
if (comeTreeData.name === newValue) {
- console.log("娌℃湁淇敼鍐呭");
return;
}
if (newValue === "") {
- console.warn("杈撳叆涓嶈兘涓虹┖");
newName.value = comeTreeData.name || "鏂拌妭鐐�";
return;
}
@@ -227,10 +327,8 @@
parentId: parentId || null, // 濡傛灉娌℃湁鐖惰妭鐐癸紝鍒欎负 null
});
} catch (error) {
- console.error("瀛樺偍澶辫触", error);
comeTreeData.name = comeTreeData.name || "鏂拌妭鐐�";
}
- console.log("淇濆瓨鎴愬姛:", newValue);
};
onMounted(async () => {
@@ -243,12 +341,9 @@
};
const remove = async (node, data) => {
- console.log("鍒犻櫎鑺傜偣:", data);
if (!data || !data.id) {
- console.warn("鏃犳硶鍒犻櫎鏈畾涔夋垨鏃犳晥鐨勮妭鐐�");
return;
}
- console.log("鍒犻櫎鑺傜偣 ID:", data.id);
let { code, msg } = await delTree([data.id]);
if (code !== 200) {
ElMessage.warning("鍒犻櫎澶辫触, " + msg);
@@ -261,7 +356,6 @@
const append = async (data) => {
if (data === "") {
// 鏂板鏍硅妭鐐�
- console.log("鏂板鏍硅妭鐐�");
const newNode = {
id: Date.now(),
name: "鏂拌妭鐐�",
@@ -283,7 +377,6 @@
const node = treeRef.value?.getNode(nodeKey);
const isExpanded = node?.expanded; // 濡傛灉鏈夊瓙绾т笖鏈睍寮�锛屽厛灞曞紑鑺傜偣
if (hasChildren && !isExpanded) {
- console.log(treeRef.value, "灞曞紑鑺傜偣", nodeKey);
if (
treeRef.value &&
treeRef.value.store &&
@@ -292,7 +385,6 @@
treeRef.value.store.nodesMap[nodeKey].expanded = true;
}
}
-
const newNode = {
id: Date.now(),
name: "鏂板瓙鑺傜偣",
@@ -327,7 +419,11 @@
}
};
-const handleEdit = () => {};
+const handleEdit = (rows) => {
+ row.value = rows;
+ dialogVisible.value = true;
+ archiveDialogs.value.editForm(rows); // 璋冪敤缂栬緫鏂规硶
+};
// 绉婚櫎鎳掑姞杞斤紝鐩存帴鑾峰彇鏁版嵁
const getList = async () => {
@@ -336,11 +432,9 @@
if (res.code === 200) {
treeData.value = res.data?.records || res.data || [];
} else {
- console.error("Failed to fetch tree data:", res.message);
treeData.value = [];
}
} catch (error) {
- console.error("鑾峰彇鏍戝舰鏁版嵁澶辫触:", error);
treeData.value = [];
}
};
@@ -564,7 +658,7 @@
float: left;
}
}
-.archive-management-card{
+.archive-management-card {
margin: 0;
}
</style>
--
Gitblit v1.9.3