diff --git a/src/components/DataTable/tools/Tags.vue b/src/components/DataTable/tools/Tags.vue new file mode 100644 index 0000000..8226bcc --- /dev/null +++ b/src/components/DataTable/tools/Tags.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/src/components/DataTable_back/index.vue b/src/components/DataTable_back/index.vue deleted file mode 100644 index a9abc57..0000000 --- a/src/components/DataTable_back/index.vue +++ /dev/null @@ -1,134 +0,0 @@ - - - - diff --git a/src/components/DataTable_back/tools/props.js b/src/components/DataTable_back/tools/props.js deleted file mode 100644 index 8d952a0..0000000 --- a/src/components/DataTable_back/tools/props.js +++ /dev/null @@ -1,35 +0,0 @@ -import { NDataTable } from 'naive-ui' - -export const tableProps = { - ...NDataTable.props, - /* 初始化接口请求 */ - request: { - type: Function, - default: null - }, - /* 分页信息 */ - pagination: { - type: [Object, Boolean], - default: () => {} - }, - /* 分页设置信息 */ - paginationSetting: { - type: Object, - default: () => { - return { - // 当前页的字段名 - pageField: 'page', - // 每页数量字段名 - sizeField: 'pageSize', - // 接口返回的数据字段名 - listField: 'list', - // 接口返回总页数字段名 - totalField: 'pageCount', - // 默认分页数量 - defaultPageSize: 10, - // 可切换每页数量集合 - pageSizes: [10, 20, 30, 40, 50] - } - } - } -} diff --git a/src/components/DataTable_back/tools/useDataSource.js b/src/components/DataTable_back/tools/useDataSource.js deleted file mode 100644 index 5b6e611..0000000 --- a/src/components/DataTable_back/tools/useDataSource.js +++ /dev/null @@ -1,99 +0,0 @@ -import { ref, unref, computed, onMounted } from 'vue' -import { isBoolean } from '@/utils/is' - -export function useDataSource(propsRef, { getPaginationInfo, setPagination, setLoading, tableData }, emit) { - const dataSourceRef = ref([]) - - async function fetch(opt) { - try { - // setLoading(true) - const { request, pagination } = unref(propsRef) - /* 无接口请求中断 */ - if (!request) return - /* 获取分页信息 */ - const paginationSetting = propsRef.paginationSetting - const pageField = paginationSetting.pageField - const sizeField = paginationSetting.sizeField - const totalField = paginationSetting.totalField - const listField = paginationSetting.listField - - let pageParams = {} - const { page = 1, pageSize = 10 } = unref(getPaginationInfo) - if ((isBoolean(pagination) && !pagination) || isBoolean(getPaginationInfo)) { - pageParams = {} - } else { - pageParams[pageField] = (opt && opt[pageField]) || page - pageParams[sizeField] = pageSize - } - - const params = { - ...pageParams - } - const res = await request(params) - console.log('res', res) - const resultTotal = res[totalField] || 0 - const currentPage = res[pageField] - - // // 如果数据异常,需获取正确的页码再次执行 - // if (resultTotal) { - // if (page > resultTotal) { - // setPagination({ - // [pageField]: resultTotal - // }) - // fetch(opt) - // } - // } - const resultInfo = res[listField] ? res[listField] : [] - dataSourceRef.value = resultInfo - setPagination({ - [pageField]: currentPage, - [totalField]: resultTotal - }) - // if (opt && opt[pageField]) { - // setPagination({ - // [pageField]: opt[pageField] || 1 - // }) - // } - emit('fetch-success', { - items: unref(resultInfo), - resultTotal - }) - } catch (error) { - console.error(error) - // emit('fetch-error', error) - // dataSourceRef.value = [] - } finally { - setLoading(false) - } - } - - const getDataSourceRef = computed(() => { - const dataSource = unref(dataSourceRef) - if (!dataSource || dataSource.length === 0) { - return unref(dataSourceRef) - } - return unref(dataSourceRef) - }) - - function getDataSource() { - console.log(getDataSourceRef.value) - return getDataSourceRef.value - } - - function setTableData(values) { - dataSourceRef.value = values - } - - onMounted(() => { - setTimeout(() => { - fetch() - }, 15) - }) - - return { - fetch, - getDataSourceRef, - getDataSource, - setTableData - } -} diff --git a/src/components/DataTable_back/tools/usePagination.js b/src/components/DataTable_back/tools/usePagination.js deleted file mode 100644 index 6c449bc..0000000 --- a/src/components/DataTable_back/tools/usePagination.js +++ /dev/null @@ -1,34 +0,0 @@ -import { computed, unref, ref } from 'vue' -import { isBoolean } from '@/utils/is' - -export function usePagination(refProps) { - const configRef = ref({}) - const show = ref(true) - console.log('configRef', configRef) - console.log('refProps', refProps) - const getPaginationInfo = computed(() => { - const { pagination, paginationSetting } = unref(refProps) - if (!unref(show) || (isBoolean(pagination) && !pagination)) { - return false - } - return { - pageSize: paginationSetting.defaultPageSize, - pageSizes: paginationSetting.pageSizes, - showSizePicker: true, - showQuickJumper: true, - ...(isBoolean(pagination) ? {} : pagination), - ...unref(configRef), - pageCount: unref(configRef)[paginationSetting.totalField] - } - }) - - function setPagination(info) { - const paginationInfo = unref(getPaginationInfo) - configRef.value = { - ...(!isBoolean(paginationInfo) ? paginationInfo : {}), - ...info - } - } - - return { getPaginationInfo, setPagination } -} diff --git a/src/layout/components/Menu/index.vue b/src/layout/components/Menu/index.vue index 70a7e45..5571a5d 100644 --- a/src/layout/components/Menu/index.vue +++ b/src/layout/components/Menu/index.vue @@ -29,8 +29,6 @@ const getMenuOptions = computed(() => { return generateOptions(permissionStore.routes, '') }) -console.log('getMenuOptions', getMenuOptions) - function resolvePath(basePath, path) { if (isExternal(path)) return path return ( diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index 50099b5..fe3acda 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -114,7 +114,6 @@ 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/user/index.vue b/src/views/system/user/index.vue index 5ea6e4e..0df2d95 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -3,29 +3,28 @@ - +