张诺
2 天以前 7619d415522ab3dc3299d6a2a9f5c9964a692d3f
src/views/archiveManagement/index.vue
@@ -191,8 +191,6 @@
  return data.name?.toLowerCase().includes(value.toLowerCase());
};
const submitForm = async (res) => {
  console.log("提交表单回调:", res);
  if (res && res.code === 200) {
    ElMessage.success("操作成功");
    // 刷新列表数据
@@ -202,11 +200,9 @@
  }
}
const centerDialogVisible = (val) => {
  console.log(val);
};
// 处理节点点击
const handleNodeClick = async (data) => {
  console.log("点击节点:", data);
  // 切换节点时重置到第一页
  queryParams.current = 1;
  queryParams.treeId = data.id;
@@ -222,7 +218,6 @@
};
// 处理分页变化
const handlePageChange = ({ page }) => {
  console.log("分页变化:", { page });
  queryParams.current = page;
  // pageSize 固定为20,不再从参数中获取
  getArchiveListData();
@@ -231,12 +226,6 @@
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,
@@ -258,14 +247,7 @@
    }
    // 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;
@@ -280,7 +262,6 @@
  }
  try {
    const ids = selectedRows.map((row) => row.id);
    console.log(ids)
    const { code, msg } = await delArchive(ids);
    if (code !== 200) {
      ElMessage.warning("删除失败: " + msg);
@@ -290,7 +271,6 @@
      await getArchiveListData();
    }
  } catch (error) {
    console.error("删除归档失败:", error);
    ElMessage.error("删除归档失败");
  }
};
@@ -329,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;
  }
@@ -349,10 +327,8 @@
      parentId: parentId || null, // 如果没有父节点,则为 null
    });
  } catch (error) {
    console.error("存储失败", error);
    comeTreeData.name = comeTreeData.name || "新节点";
  }
  console.log("保存成功:", newValue);
};
onMounted(async () => {
@@ -365,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);
@@ -383,7 +356,6 @@
const append = async (data) => {
  if (data === "") {
    // 新增根节点
    console.log("新增根节点");
    const newNode = {
      id: Date.now(),
      name: "新节点",
@@ -405,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 &&
@@ -414,7 +385,6 @@
        treeRef.value.store.nodesMap[nodeKey].expanded = true;
      }
    }
    const newNode = {
      id: Date.now(),
      name: "新子节点",
@@ -453,7 +423,6 @@
  row.value = rows;
  dialogVisible.value = true;
  archiveDialogs.value.editForm(rows); // 调用编辑方法
  // console.log("编辑行数据:", archiveDialogs.value);
};
// 移除懒加载,直接获取数据
@@ -463,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 = [];
  }
};