From 61c2e839038e684119d03bccb24a4b7133c8a141 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期五, 09 八月 2024 14:58:42 +0800
Subject: [PATCH] fix: 修改bug

---
 src/views/authority/resource/index.vue |  309 ++++++++++++++++++++++++++-------------------------
 1 files changed, 158 insertions(+), 151 deletions(-)

diff --git a/src/views/authority/resource/index.vue b/src/views/authority/resource/index.vue
index 577485f..8cea64a 100644
--- a/src/views/authority/resource/index.vue
+++ b/src/views/authority/resource/index.vue
@@ -6,7 +6,7 @@
         <a-card
           :title="$t('menu.resource.title')"
           :bordered="false"
-          :style="{ 'width': '100%', 'height': '700px', 'overflow-y': 'auto' }"
+          style=" 'width': '100%';   height: calc(100vh - 250px); 'overflow-y': 'auto' "
         >
           <a-tree
             class="tree-demo"
@@ -138,173 +138,180 @@
 </template>
 
 <script lang="ts" setup>
-import { ref } from "vue";
-import { IconPlus } from "@arco-design/web-vue/es/icon";
-import { Resource, ResourceAdd, ResourceById, ResourceDelete, ResourceList, ResourceUpdate } from "@/api/authority";
-import Authheader from "@/views/authority/components/authheader.vue";
-import { Modal } from "@arco-design/web-vue";
+  import { ref } from 'vue';
+  import { IconPlus } from '@arco-design/web-vue/es/icon';
+  import {
+    Resource,
+    ResourceAdd,
+    ResourceById,
+    ResourceDelete,
+    ResourceList,
+    ResourceUpdate,
+  } from '@/api/authority';
+  import Authheader from '@/views/authority/components/authheader.vue';
+  import { Modal } from '@arco-design/web-vue';
 
-let visible = ref(false);
-let treeData = ref([]);
-let showLine = ref(true);
-let menuTips = ref(["鏉冮檺绠$悊", "璧勬簮"]);
-const fieldNames = { value: "key", label: "value" };
-// 0鐩綍 1鑿滃崟 2鎸夐挳
-let options = ref([
-  {
-    key: "3",
-    value: "鐩綍"
-  },
-  {
-    key: "0",
-    value: "鑿滃崟"
-  },
-  {
-    key: "1",
-    value: "鎸夐挳"
-  }
-]);
-let resourceform = ref<Resource>({
-  component: "",
-  createTime: "",
-  description: "",
-  icon: "",
-  menuId: "",
-  menuName: "",
-  menuType: "",
-  orderNum: "",
-  parentId: "",
-  parentName: "",
-  children: [],
-  path: "",
-  perms: "",
-  status: "",
-  syesourcetype: "",
-  target: "",
-  updateTime: ""
-});
-
-const onIconClick = (nodeData) => {
-  if (nodeData) {
-    resourceform.value.parentId = nodeData.menuId;
-    resourceform.value.parentName = nodeData.menuName;
-  }
-  resourceform.value.component = "";
-  resourceform.value.createTime = "";
-  resourceform.value.description = "";
-  resourceform.value.icon = "";
-  resourceform.value.menuId = "";
-  resourceform.value.menuName = "";
-  resourceform.value.menuType = "";
-  resourceform.value.orderNum = "0";
-  resourceform.value.path = "";
-  resourceform.value.perms = "";
-  resourceform.value.status = "";
-  resourceform.value.syesourcetype = "";
-
-  visible.value = true;
-};
-
-const addresource = async () => {
-  await ResourceAdd({
-    ...resourceform.value
-  } as unknown as Resource).then((res) => {
-    ResourceData("");
+  let visible = ref(false);
+  let treeData = ref([]);
+  let showLine = ref(true);
+  let menuTips = ref(['鏉冮檺绠$悊', '璧勬簮']);
+  const fieldNames = { value: 'key', label: 'value' };
+  // 0鐩綍 1鑿滃崟 2鎸夐挳
+  let options = ref([
+    {
+      key: '3',
+      value: '鐩綍',
+    },
+    {
+      key: '0',
+      value: '鑿滃崟',
+    },
+    {
+      key: '1',
+      value: '鎸夐挳',
+    },
+  ]);
+  let resourceform = ref<Resource>({
+    component: '',
+    createTime: '',
+    description: '',
+    icon: '',
+    menuId: '',
+    menuName: '',
+    menuType: '',
+    orderNum: '',
+    parentId: '',
+    parentName: '',
+    children: [],
+    path: '',
+    perms: '',
+    status: '',
+    syesourcetype: '',
+    target: '',
+    updateTime: '',
   });
-};
 
-const onIconClickDelete = (nodeData) => {
-  ResourceDelete(nodeData.menuId).then(() => {
-    ResourceData("");
-  });
-};
+  const onIconClick = (nodeData) => {
+    if (nodeData) {
+      resourceform.value.parentId = nodeData.menuId;
+      resourceform.value.parentName = nodeData.menuName;
+    }
+    resourceform.value.component = '';
+    resourceform.value.createTime = '';
+    resourceform.value.description = '';
+    resourceform.value.icon = '';
+    resourceform.value.menuId = '';
+    resourceform.value.menuName = '';
+    resourceform.value.menuType = '';
+    resourceform.value.orderNum = '0';
+    resourceform.value.path = '';
+    resourceform.value.perms = '';
+    resourceform.value.status = '';
+    resourceform.value.syesourcetype = '';
 
-const showDetail = (id) => {
-  ResourceById(id).then((res) => {
-    resourceform.value = { ...res.data };
-  });
-};
-const editresource = () => {
-  ResourceUpdate({
-    ...resourceform.value
-  } as unknown as Resource).then((res) => {
-    ResourceData("");
-    Modal.success({
-      title: "淇濆瓨鎴愬姛",
-      content: "淇濆瓨鎴愬姛"
-    });
-  });
-};
-const reset = (id) => {
-  ResourceById(id).then((res) => {
-    resourceform.value = { ...res.data };
-  });
-};
+    visible.value = true;
+  };
 
-const onDrop = ({ dragNode, dropNode, dropPosition }) => {
-  const data = treeData.value;
-  ResourceUpdate({
-    orderNum: "0",
-    parentId: dropNode.menuId,
-    menuId: dragNode.menuId
-  });
-  const loop = (data, key, callback) => {
-    data.some((item, index, arr) => {
-      if (item.menuId === key) {
-        callback(item, index, arr);
-        return true;
-      }
-      if (item.children) {
-        return loop(item.children, key, callback);
-      }
-      return false;
+  const addresource = async () => {
+    await ResourceAdd({
+      ...resourceform.value,
+    } as unknown as Resource).then((res) => {
+      ResourceData('');
     });
   };
 
-  loop(data, dragNode.menuId, (_, index, arr) => {
-    arr.splice(index, 1);
-  });
-
-  if (dropPosition === 0) {
-    loop(data, dropNode.menuId, (item) => {
-      item.children = item.children || [];
-      item.children.push(dragNode);
+  const onIconClickDelete = (nodeData) => {
+    ResourceDelete(nodeData.menuId).then(() => {
+      ResourceData('');
     });
-  } else {
-    loop(data, dropNode.menuId, (_, index, arr) => {
-      arr.splice(dropPosition < 0 ? index : index + 1, 0, dragNode);
+  };
+
+  const showDetail = (id) => {
+    ResourceById(id).then((res) => {
+      resourceform.value = { ...res.data };
     });
-  }
-};
+  };
+  const editresource = () => {
+    ResourceUpdate({
+      ...resourceform.value,
+    } as unknown as Resource).then((res) => {
+      ResourceData('');
+      Modal.success({
+        title: '淇濆瓨鎴愬姛',
+        content: '淇濆瓨鎴愬姛',
+      });
+    });
+  };
+  const reset = (id) => {
+    ResourceById(id).then((res) => {
+      resourceform.value = { ...res.data };
+    });
+  };
 
-const handleCancel = (type) => {
-  if (type == 1) {
-    visible.value = false;
-  }
-};
+  const onDrop = ({ dragNode, dropNode, dropPosition }) => {
+    const data = treeData.value;
+    ResourceUpdate({
+      orderNum: '0',
+      parentId: dropNode.menuId,
+      menuId: dragNode.menuId,
+    });
+    const loop = (data, key, callback) => {
+      data.some((item, index, arr) => {
+        if (item.menuId === key) {
+          callback(item, index, arr);
+          return true;
+        }
+        if (item.children) {
+          return loop(item.children, key, callback);
+        }
+        return false;
+      });
+    };
 
-const ResourceData = async (key) => {
-  await ResourceList(key).then((res) => {
-    treeData.value = [...res.rows];
-  });
-};
+    loop(data, dragNode.menuId, (_, index, arr) => {
+      arr.splice(index, 1);
+    });
 
-ResourceData("");
+    if (dropPosition === 0) {
+      loop(data, dropNode.menuId, (item) => {
+        item.children = item.children || [];
+        item.children.push(dragNode);
+      });
+    } else {
+      loop(data, dropNode.menuId, (_, index, arr) => {
+        arr.splice(dropPosition < 0 ? index : index + 1, 0, dragNode);
+      });
+    }
+  };
+
+  const handleCancel = (type) => {
+    if (type == 1) {
+      visible.value = false;
+    }
+  };
+
+  const ResourceData = async (key) => {
+    await ResourceList(key).then((res) => {
+      treeData.value = [...res.rows];
+    });
+  };
+
+  ResourceData('');
 </script>
 
 <style scoped>
-.tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title),
-.tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title):hover {
-  animation: blinkBg 0.4s 2;
-}
-
-@keyframes blinkBg {
-  0% {
-    background-color: transparent;
+  .tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title),
+  .tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title):hover {
+    animation: blinkBg 0.4s 2;
   }
 
-  100% {
-    background-color: var(--color-primary-light-1);
+  @keyframes blinkBg {
+    0% {
+      background-color: transparent;
+    }
+
+    100% {
+      background-color: var(--color-primary-light-1);
+    }
   }
-}
 </style>

--
Gitblit v1.8.0