generated from Leo_Ding/web-template
菜单逻辑修改
This commit is contained in:
parent
cda200998e
commit
77446544f6
@ -10,4 +10,4 @@ export const updateUser = (_, params) => request.basic.put(`/api/v1/current/user
|
||||
// 更新用户密码
|
||||
export const updatePassword = (_, params) => request.basic.put(`/api/v1/current/password`, params)
|
||||
// 用户权限菜单
|
||||
export const getUserMenu = () => request.basic.get('/api/v1/current/menus')
|
||||
export const getUserMenu = (params) => request.basic.get('/api/v1/current/menus', params)
|
||||
|
||||
@ -3,7 +3,7 @@ import * as layouts from '@/layouts'
|
||||
* 白名单
|
||||
* @type {string[]}
|
||||
*/
|
||||
export const whiteList = ['login', 'logout', '404', 'users','plateform'] // no redirect whitelist
|
||||
export const whiteList = ['login', 'logout', '404', 'users','platform'] // no redirect whitelist
|
||||
|
||||
/**
|
||||
* 未找到页面路由
|
||||
@ -48,8 +48,8 @@ export const constantRoutes = [
|
||||
component: () => import('@/views/exception/404.vue'),
|
||||
},
|
||||
{
|
||||
path: '/plateform',
|
||||
name: 'plateform',
|
||||
path: '/platform',
|
||||
name: 'platform',
|
||||
component: () => import('@/views/login/platForm.vue'),
|
||||
meta: {
|
||||
title: '平台选择',
|
||||
|
||||
@ -6,6 +6,7 @@ import home from './home'
|
||||
// import exception from './exception'
|
||||
// import admin from './admin'
|
||||
import system from './system'
|
||||
import platform from './platform'
|
||||
// import link from './link'
|
||||
// import iframe from './iframe'
|
||||
// import other from './other'
|
||||
@ -19,6 +20,7 @@ export default [
|
||||
// ...exception,
|
||||
// ...admin,
|
||||
...system,
|
||||
...platform,
|
||||
// ...link,
|
||||
// ...iframe,
|
||||
// ...other,
|
||||
|
||||
10
src/router/routes/platform.js
Normal file
10
src/router/routes/platform.js
Normal file
@ -0,0 +1,10 @@
|
||||
export default [
|
||||
{
|
||||
path: '/platform',
|
||||
name: 'platform',
|
||||
component: () => import('@/views/login/platForm.vue'),
|
||||
meta: {
|
||||
title: '平台选择',
|
||||
},
|
||||
},
|
||||
]
|
||||
@ -37,10 +37,10 @@ const useAppStore = defineStore('app', {
|
||||
* 初始化
|
||||
* @returns {Promise}
|
||||
*/
|
||||
init() {
|
||||
init(params) {
|
||||
const routerStore = useRouterStore()
|
||||
return new Promise((resolve) => {
|
||||
Promise.all([routerStore.getRouterList()])
|
||||
Promise.all([routerStore.getRouterList(params)])
|
||||
.then(() => {
|
||||
this.complete = true
|
||||
resolve()
|
||||
|
||||
@ -20,11 +20,12 @@ const useRouterStore = defineStore('router', {
|
||||
* 获取路由列表
|
||||
* @returns {Promise}
|
||||
*/
|
||||
getRouterList() {
|
||||
getRouterList(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
try {
|
||||
const { success, data } = await apis.user.getUserMenu().catch(() => {
|
||||
|
||||
const { success, data } = await apis.user.getUserMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
@ -42,6 +43,7 @@ const useRouterStore = defineStore('router', {
|
||||
})
|
||||
this.routes = routes
|
||||
this.menuList = menuList
|
||||
console.log(indexRoute)
|
||||
this.indexRoute = indexRoute
|
||||
resolve()
|
||||
}
|
||||
|
||||
@ -117,13 +117,7 @@ async function handleLogin() {
|
||||
})
|
||||
loading.value = false
|
||||
if (config('http.code.success') === success) {
|
||||
// 加载完成
|
||||
if (appStore.complete) {
|
||||
goIndex()
|
||||
} else {
|
||||
await appStore.init()
|
||||
goIndex()
|
||||
}
|
||||
router.push('/platform')
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -150,10 +144,13 @@ function getFirstValidRoute() {
|
||||
* 去首页
|
||||
*/
|
||||
function goIndex() {
|
||||
console.log('goIndex')
|
||||
// router.replace({path:'/platform'})
|
||||
if (redirect.value) {
|
||||
location.href = redirect.value
|
||||
} else {
|
||||
const indexRoute = getFirstValidRoute()
|
||||
console.log(indexRoute)
|
||||
if (!indexRoute) return
|
||||
router.push(indexRoute)
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<p>呼叫中心</p>
|
||||
</div>
|
||||
<div value="SUPERVISION" class="paltform_icon">
|
||||
<div value="SUPERVISION" class="paltform_icon" @click="handleSelect('jianguan')">
|
||||
<div class="paltform_icon_1">
|
||||
<img :src="jianguan" alt="" srcset="" width="70" height="70">
|
||||
</div>
|
||||
@ -60,23 +60,64 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Modal, notification } from 'ant-design-vue'
|
||||
import { computed, onMounted, ref, onBeforeMount } from 'vue'
|
||||
import StarBackground from '@/components/StartBackground/index.vue'
|
||||
import tel from '@/assets/imgs/tel2.png'
|
||||
import jianguan from '@/assets/imgs/jianguan3.png'
|
||||
import yunying from '@/assets/imgs/yunying.png'
|
||||
import { useAppStore, useRouterStore, useUserStore } from '@/store'
|
||||
import { template } from 'lodash-es'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import storage from '@/utils/storage'
|
||||
defineOptions({
|
||||
name: 'login',
|
||||
name: 'PlatForm',
|
||||
})
|
||||
const appStore = useAppStore()
|
||||
const routerStore = useRouterStore()
|
||||
const router = useRouter()
|
||||
// 在组件挂载前设置 body 类名
|
||||
onBeforeMount(() => {
|
||||
document.body.className = 'body-bg'
|
||||
})
|
||||
const plateformList = ref([
|
||||
{ title: '呼叫中心', icon: tel },
|
||||
{ title: '监管平台', icon: jianguan },
|
||||
{ title: '运营平台', icon: yunying },
|
||||
])
|
||||
async function handleSelect(type) {
|
||||
storage.local.setItem('platform', type)
|
||||
// 加载完成
|
||||
if (appStore.complete) {
|
||||
goIndex()
|
||||
} else {
|
||||
await appStore.init({ platform: type })
|
||||
goIndex()
|
||||
}
|
||||
}
|
||||
async function goIndex() {
|
||||
console.log('goIndex')
|
||||
const indexRoute = getFirstValidRoute()
|
||||
console.log(indexRoute)
|
||||
if (!indexRoute) return
|
||||
router.push(indexRoute)
|
||||
notification.success({
|
||||
message: t('welcome'),
|
||||
description: `${timeFix()},${t('home')}`,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取首页路由
|
||||
* @return {*}
|
||||
*/
|
||||
function getFirstValidRoute() {
|
||||
const indexRoute = routerStore.indexRoute
|
||||
if (!indexRoute) {
|
||||
Modal.warning({
|
||||
title: '系统提示',
|
||||
content: '没有任何权限,请联系系统管理员',
|
||||
onOk: () => {
|
||||
window.location.reload()
|
||||
},
|
||||
})
|
||||
}
|
||||
return indexRoute
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.body-bg {
|
||||
|
||||
@ -1,50 +1,27 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:width="640"
|
||||
:open="modal.open"
|
||||
:title="modal.title"
|
||||
:confirm-loading="modal.confirmLoading"
|
||||
:after-close="onAfterClose"
|
||||
:cancel-text="cancelText"
|
||||
:ok-text="okText"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel">
|
||||
<a-form
|
||||
layout="vertical"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules">
|
||||
<a-modal :width="640" :open="modal.open" :title="modal.title" :confirm-loading="modal.confirmLoading"
|
||||
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
|
||||
<a-form layout="vertical" ref="formRef" :model="formData" :rules="formRules">
|
||||
<a-card class="mb-8-2">
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.menu.form.parent_name')"
|
||||
name="parent_id">
|
||||
<a-tree-select
|
||||
v-model:value="formData.parent_id"
|
||||
tree-default-expand-all></a-tree-select>
|
||||
<a-form-item :label="$t('pages.system.menu.form.parent_name')" name="parent_id">
|
||||
<a-tree-select v-model:value="formData.parent_id" tree-default-expand-all></a-tree-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.menu.form.type')"
|
||||
name="type">
|
||||
<a-radio-group
|
||||
v-model:value="formData.type"
|
||||
<a-form-item :label="$t('pages.system.menu.form.type')" name="type">
|
||||
<a-radio-group v-model:value="formData.type"
|
||||
:options="menuTypeEnum.getOptions()"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.menu.form.name')"
|
||||
name="name">
|
||||
<a-form-item :label="$t('pages.system.menu.form.name')" name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.menu.resource.form.path')"
|
||||
name="path">
|
||||
<a-form-item :label="$t('pages.system.menu.resource.form.path')" name="path">
|
||||
<a-input v-model:value="formData.path"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
@ -61,70 +38,44 @@
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.menu.form.status')"
|
||||
name="status">
|
||||
<a-radio-group
|
||||
v-model:value="formData.status"
|
||||
<a-form-item :label="$t('pages.system.menu.form.status')" name="status">
|
||||
<a-radio-group v-model:value="formData.status"
|
||||
:options="statusTypeEnum.getOptions()"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
style="width: 200px"
|
||||
:label="$t('pages.system.menu.form.sequence')"
|
||||
<a-form-item style="width: 200px" :label="$t('pages.system.menu.form.sequence')"
|
||||
name="sequence">
|
||||
<a-input
|
||||
:defaultValue="0"
|
||||
type="number"
|
||||
v-model:value="formData.sequence"></a-input>
|
||||
<a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.menu.form.description')"
|
||||
name="description">
|
||||
<a-form-item :label="$t('pages.system.menu.form.description')" name="description">
|
||||
<a-input v-model:value="formData.description"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.menu.form.properties')"
|
||||
name="properties">
|
||||
<a-form-item :label="$t('pages.system.menu.form.properties')" name="properties">
|
||||
<a-textarea v-model:value="formData.properties"></a-textarea>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-card :title="$t('pages.system.menu.resource.form.title')">
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="formData.resources"
|
||||
:pagination="false"
|
||||
row-key="id">
|
||||
<a-table :columns="columns" :data-source="formData.resources" :pagination="false" row-key="id">
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'types'">
|
||||
<a-form-item :label="$t('pages.system.menu.resource.form.method')">
|
||||
<a-input-group
|
||||
style="display: inline-block; vertical-align: middle"
|
||||
:compact="true">
|
||||
<a-input-group style="display: inline-block; vertical-align: middle" :compact="true">
|
||||
<a-form-item-rest>
|
||||
<a-select
|
||||
v-model:value="record.method"
|
||||
:default-value="record.method || 'GET'"
|
||||
<a-select v-model:value="record.method" :default-value="record.method || 'GET'"
|
||||
style="width: 100px">
|
||||
<a-select-option
|
||||
v-for="item of reqType"
|
||||
:key="item"
|
||||
:value="item"
|
||||
>{{ item }}</a-select-option
|
||||
>
|
||||
<a-select-option v-for="item of reqType" :key="item" :value="item">{{ item
|
||||
}}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item-rest>
|
||||
<a-input
|
||||
v-model:value="record.path"
|
||||
:style="{ width: 'calc(100% - 100px)' }" />
|
||||
<a-input v-model:value="record.path" :style="{ width: 'calc(100% - 100px)' }" />
|
||||
</a-input-group>
|
||||
</a-form-item>
|
||||
</template>
|
||||
@ -134,11 +85,7 @@
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<a-button
|
||||
@click="handleAddApi"
|
||||
block
|
||||
class="mt-8-2"
|
||||
type="dashed">
|
||||
<a-button @click="handleAddApi" block class="mt-8-2" type="dashed">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
@ -160,6 +107,7 @@ import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
@ -236,6 +184,7 @@ function handleOk() {
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
params.platform=storage.local.getItem('platform')
|
||||
result = await apis.menu.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
|
||||
@ -36,8 +36,7 @@
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-card>
|
||||
<i class="iconfont icon-gonggao" style="color: red;"></i>
|
||||
<span>引入阿里巴巴图标</span>
|
||||
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
@ -113,6 +112,7 @@ import { usePagination, useForm } from '@/hooks'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
defineOptions({
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
name: 'menu',
|
||||
@ -143,9 +143,11 @@ async function getMenuList() {
|
||||
try {
|
||||
showLoading()
|
||||
// const { current } = paginationState
|
||||
const platform=storage.local.getItem('platform')
|
||||
const { data, success, total } = await apis.menu
|
||||
.getMenuList({
|
||||
...searchFormData.value,
|
||||
platform
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
@ -166,7 +168,7 @@ async function getMenuList() {
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetForm()
|
||||
// resetForm()
|
||||
resetPagination()
|
||||
getMenuList()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user