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 @@ @@ -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 @@