diff --git a/mock/system/router.js b/mock/system/router.js
index 763f07e..9b99b23 100644
--- a/mock/system/router.js
+++ b/mock/system/router.js
@@ -3,7 +3,7 @@ const asyncRoutes = [
path: '/system',
component: 'Layout',
redirect: '/system/menu',
- name: 'System',
+ title: 'System',
meta: {
title: '系统管理'
},
@@ -11,7 +11,7 @@ const asyncRoutes = [
{
path: 'menu',
component: 'views/system/menu/index',
- name: 'SystemMenu',
+ title: 'SystemMenu',
meta: {
title: '菜单管理'
}
@@ -19,7 +19,7 @@ const asyncRoutes = [
{
path: 'user',
component: 'views/system/user/index',
- name: 'SystemUser',
+ title: 'SystemUser',
meta: {
title: '用户管理'
}
diff --git a/src/api/auth/index.js b/src/api/auth/index.js
index 0e9a3f5..f896d02 100644
--- a/src/api/auth/index.js
+++ b/src/api/auth/index.js
@@ -14,3 +14,10 @@ export const refreshToken = () => {
method: 'post'
})
}
+
+export function getMenu() {
+ return request({
+ url: '/index/getMenuList',
+ method: 'GET'
+ })
+}
diff --git a/src/components/DataTable/index.vue b/src/components/DataTable/index.vue
index 9632329..b9c31d1 100644
--- a/src/components/DataTable/index.vue
+++ b/src/components/DataTable/index.vue
@@ -76,7 +76,7 @@ export default {
/* tableData-start */
const tableData = ref([])
- const { getDataSourceRef, getRowKey, reload } = useDataSource(getProps, { getPaginationInfo, setPagination, tableData, setLoading }, emit)
+ const { getDataSourceRef, getRowKey, reload, reFetch } = useDataSource(getProps, { getPaginationInfo, setPagination, tableData, setLoading }, emit)
const isRequest = !!unref(getProps).request
const getBindProps = computed(() => {
return {
@@ -97,7 +97,8 @@ export default {
pagination,
updatePage,
updatePageSize,
- reload
+ reload,
+ reFetch
}
}
}
diff --git a/src/components/DataTable/tools/props.js b/src/components/DataTable/tools/props.js
index 876a8b7..3d86f04 100644
--- a/src/components/DataTable/tools/props.js
+++ b/src/components/DataTable/tools/props.js
@@ -30,7 +30,7 @@ export const tableProps = {
// 每页数量字段名
sizeField: 'limit',
// 接口返回的数据字段名
- listField: 'list',
+ listField: 'records',
// 接口返回总页数字段名
totalField: 'total',
// 默认分页数量
diff --git a/src/components/DataTable/tools/useDataSource.js b/src/components/DataTable/tools/useDataSource.js
index acc77af..c0ed56a 100644
--- a/src/components/DataTable/tools/useDataSource.js
+++ b/src/components/DataTable/tools/useDataSource.js
@@ -105,6 +105,19 @@ export function useDataSource(propsRef, { getPaginationInfo, setPagination, setL
await fetch(opt)
}
+ async function reFetch(opt) {
+ console.log('opt', opt)
+ const { paginationSetting } = unref(propsRef)
+ const pageField = paginationSetting.pageField
+ const sizeField = paginationSetting.sizeField
+ const pageSize = paginationSetting.pageSize
+ setPagination({
+ [pageField]: 1,
+ [sizeField]: pageSize
+ })
+ await fetch(opt)
+ }
+
onMounted(() => {
setTimeout(() => {
fetch()
@@ -117,6 +130,7 @@ export function useDataSource(propsRef, { getPaginationInfo, setPagination, setL
getDataSource,
setTableData,
getRowKey,
- reload
+ reload,
+ reFetch
}
}
diff --git a/src/components/Dialog/index.vue b/src/components/Dialog/index.vue
index c1422b1..2d527fe 100644
--- a/src/components/Dialog/index.vue
+++ b/src/components/Dialog/index.vue
@@ -1,52 +1,6 @@
diff --git a/src/components/Modal/index.vue b/src/components/Modal/index.vue
new file mode 100644
index 0000000..3fabb34
--- /dev/null
+++ b/src/components/Modal/index.vue
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/Search/index.vue b/src/components/Search/index.vue
index 276f9cf..8d785eb 100644
--- a/src/components/Search/index.vue
+++ b/src/components/Search/index.vue
@@ -2,13 +2,25 @@
-
-
+
+
-
-
+
+
+
+
+
+
+ 查询
+ 重置
+ {{ showItemNum === getFormOptions.info.length - 1 ? '收起' : '展开' }}
+
@@ -25,36 +37,49 @@ export default {
default: () => []
}
},
+ emits: ['search'],
setup(props, { emit }) {
- // const formOption = reactive({
- // form: {
-
- // }
- // })
- const getFormRef = computed(() => {
- const { info } = unref(props)
- const form = ref({})
- info.forEach((item) => {
+ const showItemNum = ref(3)
+ const len = ref(props.info.length - 1)
+ const showButton = ref(!!(showItemNum.value < len.value))
+ /* 获取传递的props */
+ const data = reactive({
+ info: toRaw(props.info)
+ })
+ const form = ref({})
+ /* 初始化搜索表单信息 */
+ function initForm() {
+ data.info.forEach((item) => {
form.value[item.key] = ''
})
- return unref(form)
- })
- console.log(getFormRef)
+ }
+
const getFormOptions = computed(() => {
return {
- form: unref(getFormRef),
+ form: unref(form),
labelWidth: 'auto',
labelPlacement: 'left',
inline: true,
info: [...unref(props).info]
}
})
- function getFormInfo() {
- console.log(getFormOptions)
+ function handleSearch() {
+ emit('search', getFormOptions.value.form)
+ }
+ function handleReset() {
+ initForm()
+ emit('search', getFormOptions.value.form)
+ }
+ function showMoreItem() {
+ showItemNum.value = showItemNum.value === len.value ? 3 : len.value
}
return {
+ showItemNum,
+ showButton,
getFormOptions,
- getFormInfo
+ handleSearch,
+ handleReset,
+ showMoreItem
}
}
}
@@ -71,5 +96,11 @@ export default {
.n-select{
width: 200px;
}
+ transition: all 10s;
+}
+.form__button{
+ button+button{
+ margin-left: 20px;
+ }
}
diff --git a/src/layout/components/Menu/index.vue b/src/layout/components/Menu/index.vue
index ca193ce..70a7e45 100644
--- a/src/layout/components/Menu/index.vue
+++ b/src/layout/components/Menu/index.vue
@@ -1,7 +1,7 @@
@@ -29,6 +29,8 @@ const getMenuOptions = computed(() => {
return generateOptions(permissionStore.routes, '')
})
+console.log('getMenuOptions', getMenuOptions)
+
function resolvePath(basePath, path) {
if (isExternal(path)) return path
return (
@@ -43,10 +45,10 @@ function resolvePath(basePath, path) {
function generateOptions(routes, basePath) {
const options = []
routes.forEach((route) => {
- if (route.name && !route.isHidden) {
+ if (route.title && !route.isHidden) {
const curOption = {
- label: (route.meta && route.meta.title) || route.name,
- key: route.name,
+ label: (route.meta && route.meta.title) || route.title,
+ key: route.title,
path: resolvePath(basePath, route.path)
}
if (route.children && route.children.length) {
diff --git a/src/router/routes/index.js b/src/router/routes/index.js
index 8b716be..bbf3be0 100644
--- a/src/router/routes/index.js
+++ b/src/router/routes/index.js
@@ -4,7 +4,7 @@ import Home from '@/views/dashboard/index.vue'
export const basicRoutes = [
{
path: '/login',
- name: 'Login',
+ title: 'Login',
component: () => import('@/views/login/index.vue'),
isHidden: true,
meta: {
@@ -13,16 +13,16 @@ export const basicRoutes = [
},
{
path: '/',
- name: 'Dashboard',
+ title: '控制台',
component: Layout,
redirect: '/home',
meta: {
- title: 'Dashboard'
+ title: '控制台'
},
children: [
{
path: 'home',
- name: 'Home',
+ title: 'Home',
component: Home,
meta: {
title: '首页',
@@ -34,7 +34,7 @@ export const basicRoutes = [
]
export const NOT_FOUND_ROUTE = {
- name: 'NOT_FOUND',
+ title: 'NOT_FOUND',
path: '/:pathMatch(.*)*',
redirect: '/404',
isHidden: true
@@ -42,7 +42,7 @@ export const NOT_FOUND_ROUTE = {
export const REDIRECT_ROUTE = {
path: '/redirect',
- name: 'Redirect',
+ title: 'Redirect',
component: Layout,
meta: {
title: 'Redirect',
diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js
index ed49742..50099b5 100644
--- a/src/store/modules/permission.js
+++ b/src/store/modules/permission.js
@@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { asyncRoutes, basicRoutes } from '@/router/routes'
-import { getMenu } from '@/api/system/menu'
+import { getMenu } from '@/api/auth/index'
import Layout from '@/layout/index.vue'
import modules from '@/utils/module.js'
@@ -53,19 +53,36 @@ function dataArrayToRoutes(routes) {
const res = []
routes.forEach(item => {
const tmp = { ...item }
- // 如果有component配置
- if (tmp.component) {
+ // // 如果有component配置
+ // if (tmp.component) {
+ // // Layout引入
+ // if (tmp.component === 'Layout') {
+ // tmp.component = Layout
+ // } else {
+ // const sub_view = tmp.component.replace(/^\/*/g, '')
+ // const component = `../${sub_view}.vue`
+ // tmp.component = modules[component]
+ // }
+ // if (tmp.children) {
+ // tmp.children = dataArrayToRoutes(tmp.children)
+ // }
+ // }
+ // 如果pid为0
+ if (tmp.pid === 0) {
// Layout引入
- if (tmp.component === 'Layout') {
- tmp.component = Layout
- } else {
- const sub_view = tmp.component.replace(/^\/*/g, '')
- const component = `../${sub_view}.vue`
- tmp.component = modules[component]
- }
+ tmp.component = Layout
if (tmp.children) {
tmp.children = dataArrayToRoutes(tmp.children)
}
+ } else {
+ const sub_view = tmp.component.replace(/^\/*/g, '')
+ const component = `../${sub_view}.vue`
+ tmp.component = modules[component]
+ }
+ tmp.name = tmp.title
+ tmp.meta = {
+ ...tmp.meta,
+ title: tmp.title
}
res.push(tmp)
})
@@ -97,6 +114,7 @@ export const usePermissionStore = defineStore('permission', {
const res = await getMenu()
if (res.code === 0) {
const result = dataArrayToRoutes(res.data)
+ console.log(result)
this.accessRoutes = result
return Promise.resolve(result)
} else {
diff --git a/src/views/system/menu/components/RoleModal.vue b/src/views/system/menu/components/RoleModal.vue
new file mode 100644
index 0000000..c81f9f9
--- /dev/null
+++ b/src/views/system/menu/components/RoleModal.vue
@@ -0,0 +1,50 @@
+
+
+
+ 111
+
+
+
+
+
+
diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue
index e0b819e..6703fbb 100644
--- a/src/views/system/menu/index.vue
+++ b/src/views/system/menu/index.vue
@@ -3,24 +3,27 @@
-
- 添加角色
+
+ 添加菜单
+
+