Ben Lin
2024-11-08 3d2c48733b86a03fc2e5a1f12ac3667ab0863b80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<template>
  <Card title="快捷导航">
    <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>
      </span>
    </CardGrid>
  </Card>
</template>
<script lang="ts" setup>
  import { Card, CardGrid } from 'ant-design-vue';
  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();
 
  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: `ASSEMBLY_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>