From d67c03dd84be6c9c40b2cca12f12d7ef191f590c Mon Sep 17 00:00:00 2001 From: zhangtao <1176193409@qq.com> Date: Tue, 24 May 2022 09:09:30 +0800 Subject: [PATCH 1/2] mune change --- .env.localhost | 2 +- mock/system/router.js | 6 +- src/api/login/index.js | 2 +- src/api/system/index.js | 2 +- src/components/DataTable/index.vue | 5 +- .../DataTable/tools/useDataSource.js | 16 ++++- src/components/Dialog/index.vue | 48 +------------ src/components/Modal/index.vue | 61 ++++++++++++++++ src/components/Search/index.vue | 71 +++++++++++++------ src/layout/components/Menu/index.vue | 10 +-- src/layout/components/Tags/index.vue | 6 +- src/router/routes/index.js | 12 ++-- src/store/modules/permission.js | 31 +++++--- src/views/login/index.vue | 4 +- .../system/menu/components/RoleModal.vue | 50 +++++++++++++ src/views/system/menu/index.vue | 15 ++-- src/views/system/role/index.vue | 20 ++++-- src/views/system/role/info.js | 33 +++++---- 18 files changed, 272 insertions(+), 122 deletions(-) create mode 100644 src/components/Modal/index.vue create mode 100644 src/views/system/menu/components/RoleModal.vue diff --git a/.env.localhost b/.env.localhost index 1104cf0..b919d0f 100644 --- a/.env.localhost +++ b/.env.localhost @@ -2,7 +2,7 @@ VITE_PUBLIC_PATH = '/' # 是否启用MOCK -VITE_APP_USE_MOCK = true +VITE_APP_USE_MOCK = false # proxy VITE_PROXY = [["/api-local","http://127.0.0.1:8002/api"],["/api-mock","http://127.0.0.1:8003"]] diff --git a/mock/system/router.js b/mock/system/router.js index feafafa..4ea86ec 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/login/index.js b/src/api/login/index.js index bbfa1bd..9e49e6e 100644 --- a/src/api/login/index.js +++ b/src/api/login/index.js @@ -1,4 +1,4 @@ -import { mockAxios as request } from '@/utils/http' +import { defAxios as request } from '@/utils/http' export function userLogin(data = {}) { return request({ diff --git a/src/api/system/index.js b/src/api/system/index.js index e0e5943..453f6c7 100644 --- a/src/api/system/index.js +++ b/src/api/system/index.js @@ -1,4 +1,4 @@ -import { mockAxios as request } from '@/utils/http' +import { defAxios as request } from '@/utils/http' export function getMenu() { return request({ 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/useDataSource.js b/src/components/DataTable/tools/useDataSource.js index 9df01d8..fad04b9 100644 --- a/src/components/DataTable/tools/useDataSource.js +++ b/src/components/DataTable/tools/useDataSource.js @@ -99,6 +99,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() @@ -111,6 +124,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 @@ @@ -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 @@