Ben Lin
2025-03-05 043701d5a28df6a0ea596ed7e4198676480bcc60
src/views/dashboard/workbench/components/QuickNav.vue
@@ -1,6 +1,10 @@
<template>
  <Card title="快捷导航">
    <CardGrid v-for="item in navItems" :key="item.title" @click="changeItem(item.url)">
    <CardGrid
      v-for="item in navItems"
      :key="item.title"
      @click="changeItem(item.url, item.isnormal)"
    >
      <span class="flex flex-col items-center">
        <Icon :icon="item.icon" :color="item.color" size="20" />
        <span class="text-md mt-2 truncate">{{ item.title }}</span>
@@ -13,11 +17,68 @@
  import { navItems } from './data';
  import Icon from '@/components/Icon/Icon.vue';
  import { useGo } from '/@/hooks/web/usePage';
  import { onMounted } from 'vue';
  import { getEntity } from '/@/api/tigerapi/system';
  import { isNullOrUnDef } from '/@/utils/is';
  import { useUserStore } from '/@/store/modules/user';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { iV_USER_MENU } from '/@/api/tigerapi/model/vModel';
  const go = useGo();
  const { createErrorModal } = useMessage();
  function changeItem(url) {
    go(url);
    console.log('url', url);
  onMounted(() => {});
  /**
   * @desc 跳转方法
   * @param {string} url - 地址
   * @param {boolean} isnormal - 是否普通跳转
   */
  function changeItem(url: string, isnormal: boolean) {
    const roles: iV_USER_MENU[] = useUserStore().getUserInfo.roles;
    if (!roles.some((q) => !isNullOrUnDef(q.PATH) && q.PATH.includes(url))) {
      createErrorModal({
        title: '警告',
        content: '没有访问权限',
        getContainer: () => document.body,
      });
      return;
    }
    if (!isnormal) {
      let id = {};
      if (url.split('/').length > 1 && url.split('/')[1] == 'LC') {
        getEntity({
          sqlcmd: `CODE_NAME ='${url.split('/')[0]}'`,
          entityName: 'SYS_LOW_CODE',
          order: '',
        }).then((data) => {
          var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON);
          let colSlots = [] as string[];
          for (const i in searchForms) {
            if (!isNullOrUnDef(searchForms[i]['colSlot'])) {
              colSlots.push('form-' + searchForms[i]['colSlot']);
            }
          }
          var _cruds = JSON.parse(data.Data.Items[0].FORM_JSON);
          let crudColSlots = [] as string[];
          for (const i in _cruds) {
            if (!isNullOrUnDef(_cruds[i]['colSlot'])) {
              crudColSlots.push(_cruds[i]['colSlot']);
            }
          }
          id = { ID: url.split('/')[0], colSlots: colSlots, crudColSlots: crudColSlots };
          go(`/${url}/${encodeURI(JSON.stringify(id))}`);
        });
      } else if (
        (url.split('/').length > 1 && url.split('/')[1] == 'High') ||
        url.split('/')[1] == 'CP'
      ) {
        id = { Name: url.split('/')[0] };
        go(`/${url}/${encodeURI(JSON.stringify(id))}`);
      }
    } else {
      go(url);
    }
  }
</script>