Jelajahi Sumber

修改导航菜单

zs 1 tahun lalu
induk
melakukan
b166ccaf3b
5 mengubah file dengan 105 tambahan dan 13 penghapusan
  1. 40 3
      src/layout/index.vue
  2. 9 9
      src/layout/site.js
  3. 3 1
      src/router/index.js
  4. 40 0
      src/store/api/system/tags.js
  5. 13 0
      src/views/company/index.vue

+ 40 - 3
src/layout/index.vue

@@ -10,9 +10,23 @@
           </div>
         </el-col>
         <el-col :span="14">
-          <a-tabs size="small" v-model:activeKey="current" @tabClick="selectMenu">
-            <a-tab-pane v-for="item in menuList" :key="item.href" :tab="item.title"> </a-tab-pane>
-          </a-tabs>
+          <el-menu :default-active="current" mode="horizontal" @select="selectMenu">
+            <template v-for="item in data" :key="item._id">
+              <template v-if="item.type === '0'">
+                <el-sub-menu :index="item._id" :class="[current == item.href ? 'current' : '']">
+                  <template #title>
+                    <span @click="selectMenu(item.href)">{{ item.title }}</span>
+                  </template>
+                  <el-menu-item v-for="tag in item.children" :key="tag._id" :index="tag.href">{{
+                    tag.title
+                  }}</el-menu-item>
+                </el-sub-menu>
+              </template>
+              <template v-else-if="item.type === '1'">
+                <el-menu-item :index="item.href"> {{ item.title }}</el-menu-item>
+              </template>
+            </template>
+          </el-menu>
         </el-col>
         <el-col :span="4">
           <el-row :gutter="20">
@@ -98,16 +112,30 @@
 <script setup>
 import { siteInfo, footInfo, menuList } from '@/layout/site'
 import { Search, Edit, User, Bell } from '@element-plus/icons-vue'
+// 接口
+import { TagsStore } from '@/store/api/system/tags'
+const store = TagsStore()
 const router = useRouter()
 const route = useRoute()
 const current = ref(route.name || 'home')
 import { UserStore } from '@/store/user'
 const userStore = UserStore()
 const user = computed(() => userStore.user)
+const data = ref([])
 // 图片引入
 import code from '@/assets/code.png'
 import unit from '@/assets/unit.png'
 
+// 请求
+onMounted(async () => {
+  await search()
+})
+
+const search = async () => {
+  const res = await store.query({ is_use: '0' })
+  if (res.errcode == '0' && res.total > 0) data.value = res.data
+  else data.value = menuList
+}
 const selectMenu = (item) => {
   current.value = item
   router.push({ path: `/${item}` })
@@ -149,6 +177,11 @@ provide('selectMenu', selectMenu)
     padding: 10px 80px;
     background: #ffffff;
 
+    .current {
+      border-bottom: 2px solid #409eff;
+      color: #409eff !important;
+    }
+
     .top_1 {
       display: flex;
       align-items: center;
@@ -185,6 +218,10 @@ provide('selectMenu', selectMenu)
       border: 0 !important;
     }
 
+    :deep(.el-menu) {
+      border: none !important;
+    }
+
     .top_3 {
       display: flex;
       justify-content: space-between;

+ 9 - 9
src/layout/site.js

@@ -23,13 +23,13 @@ export const footInfo = {
 }
 // 菜单设置
 export const menuList = [
-  { title: '首页', href: 'home', English: 'Home' },
-  { title: '政策新闻', href: 'news', English: 'Policy News' },
-  { title: '新闻资讯', href: 'brain', English: 'News Information' },
-  { title: '供需商城', href: 'demand', English: 'Demand Mall' },
-  { title: '专家智库', href: 'expert', English: 'Expert Tank' },
-  { title: '优质企业', href: 'company', English: 'Authorized Operator' },
-  { title: '项目精选', href: 'project', English: 'Project Selection' },
-  { title: '创新大赛', href: 'innovation', English: 'Innovation Competition' },
-  { title: '成果展示', href: 'achievement', English: 'Achievement Display' }
+  { _id: '1', title: '首页', href: 'home', English: 'Home', type: '0' },
+  { _id: '2', title: '政策新闻', href: 'news', English: 'Policy News', type: '0' },
+  { _id: '3', title: '新闻资讯', href: 'brain', English: 'News Information', type: '0' },
+  { _id: '4', title: '供需商城', href: 'demand', English: 'Demand Mall', type: '0' },
+  { _id: '5', title: '专家智库', href: 'expert', English: 'Expert Tank', type: '0' },
+  { _id: '6', title: '优质企业', href: 'company', English: 'Authorized Operator', type: '0' },
+  { _id: '7', title: '项目精选', href: 'project', English: 'Project Selection', type: '0' },
+  { _id: '8', title: '创新大赛', href: 'innovation', English: 'Innovation Competition', type: '0' },
+  { _id: '9', title: '成果展示', href: 'achievement', English: 'Achievement Display', type: '0' }
 ]

+ 3 - 1
src/router/index.js

@@ -140,5 +140,7 @@ router.beforeEach(async (to, from, next) => {
     next()
   } else next()
 })
-
+router.afterEach(() => {
+  window.scrollTo(0, 0)
+})
 export default router

+ 40 - 0
src/store/api/system/tags.js

@@ -0,0 +1,40 @@
+import { defineStore } from 'pinia'
+import { AxiosWrapper } from '@/utils/axios-wrapper'
+import { get } from 'lodash-es'
+const url = '/tags'
+const axios = new AxiosWrapper()
+
+export const TagsStore = defineStore('tags', () => {
+  const query = async ({ skip = 0, limit = undefined, ...info } = {}) => {
+    let cond = {}
+    if (skip) cond.skip = skip
+    if (limit) cond.limit = limit
+    cond = { ...cond, ...info }
+    const res = await axios.$get(`${url}`, cond)
+    return res
+  }
+  const fetch = async (payload) => {
+    const res = await axios.$get(`${url}/${payload}`)
+    return res
+  }
+  const create = async (payload) => {
+    const res = await axios.$post(`${url}`, payload)
+    return res
+  }
+  const update = async (payload) => {
+    const id = get(payload, 'id', get(payload, '_id'))
+    const res = await axios.$post(`${url}/${id}`, payload)
+    return res
+  }
+  const del = async (payload) => {
+    const res = await axios.$delete(`${url}/${payload}`)
+    return res
+  }
+  return {
+    query,
+    fetch,
+    create,
+    update,
+    del
+  }
+})

+ 13 - 0
src/views/company/index.vue

@@ -272,6 +272,19 @@ const searchList = ref([
       { value: '4', label: '建筑业' },
       { value: '5', label: '批发和零售业' }
     ]
+  },
+  {
+    title: '企业状态',
+    list: [
+      { value: '0', label: '存续、在业' },
+      { value: '1', label: '迁出' },
+      { value: '2', label: '迁入' },
+      { value: '3', label: '停业' },
+      { value: '4', label: '吊销' },
+      { value: '5', label: '清算' },
+      { value: '6', label: '撤销' },
+      { value: '7', label: '注销' }
+    ]
   }
 ])
 // 查看