From 9cbbaff2974a40a2706c44e1b906d021eb733d63 Mon Sep 17 00:00:00 2001 From: xlsea Date: Wed, 11 Sep 2024 16:37:35 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E5=AD=97=E5=85=B8ho?= =?UTF-8?q?oks=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/custom/dict-radio.vue | 2 +- src/components/custom/dict-select.vue | 2 +- src/components/custom/dict-tag.vue | 30 +++++++++++++ src/hooks/business/dict.ts | 8 +++- src/styles/scss/custom.scss | 5 +++ src/styles/scss/global.scss | 1 + src/typings/api/system.api.d.ts | 2 +- src/typings/components.d.ts | 1 + src/views/system/menu/index.vue | 19 ++++----- .../menu/modules/menu-operate-drawer.vue | 16 +------ src/views/system/user/index.vue | 42 +++++++++++-------- .../user/modules/user-operate-drawer.vue | 4 +- src/views/system/user/modules/user-search.vue | 14 +++++-- 13 files changed, 94 insertions(+), 52 deletions(-) create mode 100644 src/components/custom/dict-tag.vue create mode 100644 src/styles/scss/custom.scss diff --git a/src/components/custom/dict-radio.vue b/src/components/custom/dict-radio.vue index 92c4bbbb..cf83004b 100644 --- a/src/components/custom/dict-radio.vue +++ b/src/components/custom/dict-radio.vue @@ -9,7 +9,7 @@ interface Props { } const props = withDefaults(defineProps(), { - immediate: true + immediate: false }); const value = defineModel('value', { required: false }); diff --git a/src/components/custom/dict-select.vue b/src/components/custom/dict-select.vue index da3db62f..06264d26 100644 --- a/src/components/custom/dict-select.vue +++ b/src/components/custom/dict-select.vue @@ -12,7 +12,7 @@ interface Props { } const props = withDefaults(defineProps(), { - immediate: true + immediate: false }); const value = defineModel('value', { required: true }); diff --git a/src/components/custom/dict-tag.vue b/src/components/custom/dict-tag.vue new file mode 100644 index 00000000..9404a140 --- /dev/null +++ b/src/components/custom/dict-tag.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/hooks/business/dict.ts b/src/hooks/business/dict.ts index 6c513f1f..1d803a2e 100644 --- a/src/hooks/business/dict.ts +++ b/src/hooks/business/dict.ts @@ -40,6 +40,11 @@ export function useDict(dictType: string, immediate: boolean = true) { options.value = data.value.map(dict => ({ label: dict.dictLabel!, value: dict.dictValue! })); } + function transformDictData(dictValue: string): Api.System.DictData | undefined { + if (!data.value.length || !dictValue) return undefined; + return data.value.find(dict => dict.dictValue === dictValue); + } + if (immediate) { getData().then(() => { getRecord(); @@ -64,6 +69,7 @@ export function useDict(dictType: string, immediate: boolean = true) { options, getData, getRecord, - getOptions + getOptions, + transformDictData }; } diff --git a/src/styles/scss/custom.scss b/src/styles/scss/custom.scss new file mode 100644 index 00000000..ce4deb6d --- /dev/null +++ b/src/styles/scss/custom.scss @@ -0,0 +1,5 @@ +.table-search { + .n-collapse { + --n-title-font-size: 15px !important; + } +} diff --git a/src/styles/scss/global.scss b/src/styles/scss/global.scss index e99a7812..2085a1d1 100644 --- a/src/styles/scss/global.scss +++ b/src/styles/scss/global.scss @@ -1 +1,2 @@ @import './scrollbar.scss'; +@import './custom.scss'; diff --git a/src/typings/api/system.api.d.ts b/src/typings/api/system.api.d.ts index 296da4b3..bb7c6266 100644 --- a/src/typings/api/system.api.d.ts +++ b/src/typings/api/system.api.d.ts @@ -270,7 +270,7 @@ declare namespace Api { /** 是否默认(Y是 N否) */ isDefault: string; /** 表格回显样式 */ - listClass: string; + listClass: NaiveUI.ThemeColor; /** 备注 */ remark: string; }>; diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index ba3b2ef8..914ff762 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -16,6 +16,7 @@ declare module 'vue' { DarkModeContainer: typeof import('./../components/common/dark-mode-container.vue')['default'] DictRadio: typeof import('./../components/custom/dict-radio.vue')['default'] DictSelect: typeof import('./../components/custom/dict-select.vue')['default'] + DictTag: typeof import('./../components/custom/dict-tag.vue')['default'] ExceptionBase: typeof import('./../components/common/exception-base.vue')['default'] FullScreen: typeof import('./../components/common/full-screen.vue')['default'] IconAntDesignEnterOutlined: typeof import('~icons/ant-design/enter-outlined')['default'] diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index ea668ee4..fc9cea7a 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -4,16 +4,19 @@ import { useBoolean, useLoading } from '@sa/hooks'; import type { DataTableColumns, TreeInst, TreeOption } from 'naive-ui'; import { NButton, NIcon, NInput, NPopconfirm, NTooltip } from 'naive-ui'; import { fetchDeleteMenu, fetchGetMenuList } from '@/service/api/system'; -import SvgIcon from '@/components/custom/svg-icon.vue'; import { useAppStore } from '@/store/modules/app'; import { menuIsFrameRecord, menuTypeRecord } from '@/constants/business'; -import ButtonIcon from '@/components/custom/button-icon.vue'; import { $t } from '@/locales'; import { handleMenuTree } from '@/utils/ruoyi'; -import StatusTag from '@/components/custom/status-tag.vue'; import { useDict } from '@/hooks/business/dict'; +import SvgIcon from '@/components/custom/svg-icon.vue'; +import DictTag from '@/components/custom/dict-tag.vue'; +import ButtonIcon from '@/components/custom/button-icon.vue'; import MenuOperateDrawer from './modules/menu-operate-drawer.vue'; +useDict('sys_show_hide'); +useDict('sys_normal_disable'); + const appStore = useAppStore(); const editingData = ref(); const operateType = ref('add'); @@ -207,7 +210,7 @@ const btnColumns: DataTableColumns = [ minWidth: 80, align: 'center', render(row) { - return ; + return ; } }, { @@ -259,8 +262,6 @@ const btnColumns: DataTableColumns = [ } } ]; - -const { record: showHideRecord } = useDict('sys_show_hide'); - - - - - + - - - - - + diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 1c25eb48..82a6be23 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -4,6 +4,8 @@ import { fetchBatchDeleteUser, fetchGetUserList } from '@/service/api/system'; import { $t } from '@/locales'; import { useAppStore } from '@/store/modules/app'; import { useTable, useTableOperate } from '@/hooks/common/table'; +import DictTag from '@/components/custom/dict-tag.vue'; +import { useDict } from '@/hooks/business/dict'; import UserOperateDrawer from './modules/user-operate-drawer.vue'; import UserSearch from './modules/user-search.vue'; @@ -11,6 +13,9 @@ defineOptions({ name: 'UserList' }); +useDict('sys_user_sex'); +useDict('sys_normal_disable'); + const appStore = useAppStore(); const { @@ -49,35 +54,42 @@ const { align: 'center', width: 64 }, - { - key: 'deptId', - title: '部门', - align: 'center', - minWidth: 120 - }, { key: 'userName', title: '用户名称', align: 'center', - minWidth: 120 + minWidth: 120, + ellipsis: true }, { key: 'nickName', title: '用户昵称', align: 'center', - minWidth: 120 + minWidth: 120, + ellipsis: true + }, + { + key: 'deptName', + title: '部门', + align: 'center', + minWidth: 120, + ellipsis: true }, { key: 'phonenumber', title: '手机号码', align: 'center', - minWidth: 120 + minWidth: 120, + ellipsis: true }, { key: 'status', - title: '帐号状态', + title: '状态', align: 'center', - minWidth: 120 + minWidth: 80, + render(row) { + return ; + } }, { key: 'createTime', @@ -85,12 +97,6 @@ const { align: 'center', minWidth: 120 }, - { - key: 'remark', - title: '备注', - align: 'center', - minWidth: 120 - }, { key: 'operate', title: $t('common.operate'), @@ -142,7 +148,7 @@ async function edit(userId: CommonType.IdType) {