diff --git a/src/components/SmartTable/src/utils/TableCommon.tsx b/src/components/SmartTable/src/utils/TableCommon.tsx index 5acb3aebe..20aa55cbf 100644 --- a/src/components/SmartTable/src/utils/TableCommon.tsx +++ b/src/components/SmartTable/src/utils/TableCommon.tsx @@ -34,6 +34,30 @@ export const tableBooleanColumn = (t: Function, title: string, field: string) => }; }; +export const tableBooleanColumnClass = (title: string, field: string) => { + const { t } = useI18n(); + + return { + title: title, + field: title, + width: 100, + formatter: ({ row }) => { + const value = row[field] as boolean | null; + if (value === null) { + return ''; + } + return value ? t('common.form.yes') : t('common.form.no'); + }, + dynamicClass: ({ row }) => { + const value = row[field] as boolean | null; + if (value === null) { + return ''; + } + return value ? 'text-color--success-bold' : 'text-color--danger-bold'; + }, + }; +}; + const tableDeleteYn = (t: Function) => { const createSlot = ({ row }: any) => { const value = row.deleteYn; diff --git a/src/modules/system/views/onlineUser/OnlineUserListView.api.ts b/src/modules/system/views/onlineUser/OnlineUserListView.api.ts new file mode 100644 index 000000000..8bccd6ab3 --- /dev/null +++ b/src/modules/system/views/onlineUser/OnlineUserListView.api.ts @@ -0,0 +1,21 @@ +import { ApiServiceEnum, defHttp } from '@/utils/http/axios'; + +enum Api { + listOnlineUser = 'auth/listOnlineUser', + offline = 'auth/offline', +} + +export const listOnlineUserApi = (params) => + defHttp.post({ + service: ApiServiceEnum.SMART_AUTH, + url: Api.listOnlineUser, + data: params, + }); + +export const offlineApi = (username, token) => { + return defHttp.post({ + service: ApiServiceEnum.SMART_AUTH, + url: Api.offline, + data: { username, token }, + }); +}; diff --git a/src/modules/system/views/onlineUser/OnlineUserListView.config.ts b/src/modules/system/views/onlineUser/OnlineUserListView.config.ts new file mode 100644 index 000000000..814282ffc --- /dev/null +++ b/src/modules/system/views/onlineUser/OnlineUserListView.config.ts @@ -0,0 +1,99 @@ +import { + type SmartColumn, + type SmartSearchFormSchema, + tableBooleanColumnClass, +} from '@/components/SmartTable'; + +export const getTableColumns = (): SmartColumn[] => { + return [ + { + title: '#', + type: 'expand', + fixed: 'left', + width: 80, + slots: { + content: 'table-expand', + }, + }, + { + title: '{system.views.user.table.username}', + field: 'username', + width: 120, + fixed: 'left', + }, + { + title: '{system.views.user.table.fullName}', + field: 'fullName', + width: 120, + fixed: 'left', + }, + { + title: '{system.views.user.table.email}', + field: 'email', + minWidth: 160, + }, + { + title: '{system.views.user.table.mobile}', + field: 'mobile', + minWidth: 140, + }, + { + title: '{common.table.operation}', + field: 'operation', + width: 120, + fixed: 'right', + slots: { + default: 'table-operation', + }, + }, + ]; +}; + +export const getTableExpandColumns = (): SmartColumn[] => { + return [ + { + title: '{system.views.onlineUser.title.authType}', + field: 'authType', + width: 120, + }, + { + title: '{system.views.onlineUser.title.loginType}', + field: 'loginType', + width: 120, + }, + { + title: '{system.views.onlineUser.title.loginTime}', + field: 'loginTime', + sortable: true, + width: 170, + }, + { + title: '{system.views.onlineUser.title.loginIp}', + field: 'loginIp', + minWidth: 200, + }, + { + ...tableBooleanColumnClass('{system.views.onlineUser.title.bindIp}', 'bindIp'), + width: 120, + }, + { + title: '{common.table.operation}', + field: 'operation', + width: 120, + fixed: 'right', + slots: { + default: 'expand-table-operation', + }, + }, + ]; +}; + +export const getSearchFormSchemas = (t: Function): SmartSearchFormSchema[] => { + return [ + { + label: t('system.views.user.table.username'), + field: 'username', + component: 'Input', + }, + ]; +}; diff --git a/src/modules/system/views/onlineUser/OnlineUserListView.vue b/src/modules/system/views/onlineUser/OnlineUserListView.vue new file mode 100644 index 000000000..adfca9ad2 --- /dev/null +++ b/src/modules/system/views/onlineUser/OnlineUserListView.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/src/modules/system/views/onlineUser/lang/en_US.ts b/src/modules/system/views/onlineUser/lang/en_US.ts new file mode 100644 index 000000000..2d778cb4f --- /dev/null +++ b/src/modules/system/views/onlineUser/lang/en_US.ts @@ -0,0 +1,22 @@ +export default { + system: { + views: { + onlineUser: { + title: { + authType: 'Auth type', + loginType: 'Login type', + loginTime: 'Login time', + loginIp: 'Login IP', + bindIp: 'Bind IP', + }, + button: { + offline: 'Offline', + }, + message: { + offlineConfirm: 'Are you sure you want to go offline?', + offlineSuccess: 'Offline success', + }, + }, + }, + }, +}; diff --git a/src/modules/system/views/onlineUser/lang/zh_CN.ts b/src/modules/system/views/onlineUser/lang/zh_CN.ts new file mode 100644 index 000000000..58abc61dc --- /dev/null +++ b/src/modules/system/views/onlineUser/lang/zh_CN.ts @@ -0,0 +1,22 @@ +export default { + system: { + views: { + onlineUser: { + title: { + authType: '认证类型', + loginType: '登录类型', + loginTime: '登录时间', + loginIp: '登录IP', + bindIp: '是否绑定IP', + }, + button: { + offline: '下线', + }, + message: { + offlineConfirm: '确定要下线吗?', + offlineSuccess: '下线成功', + }, + }, + }, + }, +};