diff --git a/src/api/AlertMock.ts b/src/api/AlertMock.ts index 0f48670..f5d004d 100644 --- a/src/api/AlertMock.ts +++ b/src/api/AlertMock.ts @@ -73,7 +73,7 @@ export interface Item { export async function alarmInfoListQuery( params: PagingQueryParams ): Promise> { - const response = await api.post('/api/alertRecord/page/detail', params); + const response = await api.get('/api/alertRecord/page/detail', { params }); return response.data; } diff --git a/src/api/DecisionInfo.ts b/src/api/DecisionInfo.ts index ad4ff66..0d594db 100644 --- a/src/api/DecisionInfo.ts +++ b/src/api/DecisionInfo.ts @@ -6,6 +6,8 @@ const AlertTipUriBase = '/api/alertTip'; interface AlarmInfoCreateParams { id: number; + lineId: number; + lineType: string; alertType: string; tipTimeIds: string[]; areaConfigId: number; @@ -15,6 +17,8 @@ interface AlarmInfoCreateParams { export interface AlarmInfoListItem { id: number; + lineId: number; + lineType: string; alertType: string; timeConfigList: TimeConfigItem[]; areaConfigId: number; diff --git a/src/api/LogApi.ts b/src/api/LogApi.ts index 59c7381..e054910 100644 --- a/src/api/LogApi.ts +++ b/src/api/LogApi.ts @@ -5,14 +5,22 @@ const LogUriBase = '/api/log'; export interface Record { id: number; + faceName: string; eventType: string; + subEventType: string; + uri: string; + method: string; + parameters: string; + requestSuccess: boolean; + userName: string; fromUserId: number; mobile: string; - userName: string; createDateTime: string; } -export class PagingQueryParams extends PageQueryDto {} +export class PagingQueryParams extends PageQueryDto { + logType = 'logType'; +} /** * 分页查询事件信息列表 diff --git a/src/api/UserApi.ts b/src/api/UserApi.ts index b3f09c4..e4d2bb1 100644 --- a/src/api/UserApi.ts +++ b/src/api/UserApi.ts @@ -72,3 +72,46 @@ export async function pageQuery( }); return response.data; } + +/** + * 用户登出 + */ +export async function logout(): Promise { + const response = await api.post(`${UserUriBase}/logout`); + return response.data; +} + +interface tokenInfo { + token: string; + remainingSecond: number; +} + +/** + * 刷新token + */ +export async function refreshToken(): Promise { + const response = await api.post(`${UserUriBase}/refresh/token`); + return response.data; +} + +export interface role { + id: number; + name: string; + roleConfig: { + lineId: number; + lineType: string; + }[]; +} +interface userInfo { + remainingSecond: number; + roles: role[]; + defaultRole: string; +} + +/** + * 获取用户信息 + */ +export async function getUserInfo(): Promise { + const response = await api.post(`${UserUriBase}/info`); + return response.data; +} diff --git a/src/components/SysMenu.vue b/src/components/SysMenu.vue index d05e70c..9e569ae 100644 --- a/src/components/SysMenu.vue +++ b/src/components/SysMenu.vue @@ -1,7 +1,7 @@ diff --git a/src/pages/DecisionInfoManage.vue b/src/pages/DecisionInfoManage.vue index 309ba7c..b9896a1 100644 --- a/src/pages/DecisionInfoManage.vue +++ b/src/pages/DecisionInfoManage.vue @@ -73,6 +73,23 @@
{{ creatForm.id ? '编辑决策信息' : '新建决策信息' }}
+ + - + @@ -169,6 +186,7 @@ import { } from 'src/components/alarm/alarmInfoEnum'; import { ApiError } from 'src/boot/axios'; import { ShowTipTimeConfig, TipTimeConfig } from 'src/api/AlarmTipTimeConfig'; +import { pageQuery } from 'src/api/LineInfoApi'; const $q = useQuasar(); @@ -191,6 +209,20 @@ const columnDefs: QTableColumn[] = [ required: true, align: 'center', }, + { + name: 'lineId', + label: '线路', + field: 'lineId', + required: true, + align: 'center', + }, + { + name: 'lineType', + label: '线路类型', + field: 'lineType', + required: true, + align: 'center', + }, { name: 'alertType', label: '故障类型', @@ -283,6 +315,7 @@ const onRequest: QTable['onRequest'] = async (props) => { }; onMounted(() => { + queryLineInfo(); setTimeout(() => { tableRef.value.requestServerInteraction(); }); @@ -306,6 +339,8 @@ const createFormShow = ref(false); const myForm = ref(null); const creatForm = reactive({ id: '', + lineId: '', + lineType: 'NCC', alertType: '', tipTimeIds: [], areaConfigId: '', @@ -313,6 +348,25 @@ const creatForm = reactive({ submissionInfo: '', }); +const optionsLineId = ref<{ label: string; value: number }[]>([]); +async function queryLineInfo() { + try { + let response = await pageQuery({ + current: 1, + size: 50, + }); + response.records.forEach((info) => { + optionsLineId.value.push({ label: info.name, value: info.lineId }); + }); + } catch (err) { + const error = err as ApiError; + $q.notify({ + type: 'negative', + message: error.title, + }); + } +} +const optionsLineType = ['NCC', 'OCC']; const optionsAlertType = [ '蓝显', '全线蓝显', @@ -372,6 +426,8 @@ function onCreate() { }); const params = { id: +creatForm.id, + lineId: +creatForm.lineId, + lineType: creatForm.lineType, alertType: (saveAlertTypeData as never)[creatForm.alertType], tipTimeIds: tipTimeIds, areaConfigId: areaConfigId as number, @@ -403,6 +459,8 @@ function onCreate() { function editData(row: AlarmInfoListItem) { creatForm.id = row.id + ''; + creatForm.lineId = row.lineId + ''; + creatForm.lineType = row.lineType; creatForm.alertType = (showAlertTypeData as never)[row.alertType + '']; creatForm.tipTimeIds = row.timeConfigList?.map( (timeConfig) => (ShowTipTimeConfig as never)[timeConfig.timeType + ''] @@ -440,6 +498,8 @@ async function deleteData(row: AlarmInfoListItem) { function onReset() { creatForm.id = ''; + creatForm.lineId = ''; + creatForm.lineType = 'NCC'; creatForm.alertType = ''; creatForm.tipTimeIds = []; creatForm.areaConfigId = ''; diff --git a/src/pages/LoginRecord.vue b/src/pages/LoginRecord.vue index e7a312b..4a1a42e 100644 --- a/src/pages/LoginRecord.vue +++ b/src/pages/LoginRecord.vue @@ -2,7 +2,7 @@
+ import { useQuasar } from 'quasar'; import { ApiError } from 'src/boot/axios'; -import { login } from 'src/api/UserApi'; +import { getUserInfo, login } from 'src/api/UserApi'; import { clearJwtToken, saveJwtToken } from 'src/configs/TokenManage'; import { reactive, ref } from 'vue'; import { useRouter } from 'vue-router'; +import { useUserStore } from 'src/stores/user-store'; +import { handleRefreshToken } from 'src/utils/refreshToken'; +import { getMonitorPath } from 'src/router/routes'; const $q = useQuasar(); const router = useRouter(); +const userStore = useUserStore(); const loginInfo = reactive({ account: '', @@ -74,7 +78,15 @@ async function doLogin() { clearJwtToken(); const token = await login(loginInfo); saveJwtToken(token); - router.push({ name: 'home' }); + const userInfo = await getUserInfo(); + userStore.roles = userInfo.roles; + userStore.defaultRole = userInfo.defaultRole; + userStore.remainingSecond = userInfo.remainingSecond; + setTimeout( + () => handleRefreshToken(), + userInfo.remainingSecond * 1000 - 10000 + ); + router.replace(getMonitorPath(userInfo.roles)); } catch (err) { visible.value = false; const apiErr = err as ApiError; diff --git a/src/pages/UserManage.vue b/src/pages/UserManage.vue index 4ed20d3..0df199a 100644 --- a/src/pages/UserManage.vue +++ b/src/pages/UserManage.vue @@ -39,7 +39,10 @@
-