Squashed commit of the following:
All checks were successful
local-test分支构建发布 / Docker-Build (push) Successful in 2m1s
All checks were successful
local-test分支构建发布 / Docker-Build (push) Successful in 2m1s
commitfb18c04248
Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Mon Oct 21 17:18:51 2024 +0800 权限角色调整 commitb6d345426f
Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Mon Oct 21 16:37:58 2024 +0800 弹框不弹--改路由 commitb8d08b40bb
Merge:2676d4d
5044db8
Author: joylink_fanyuhong <18706759286@163.com> Date: Mon Oct 21 14:56:07 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/xian-ncc-da-client into develop commit2676d4d1d8
Author: joylink_fanyuhong <18706759286@163.com> Date: Mon Oct 21 14:56:05 2024 +0800 登录流程调整 commit5044db830b
Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Mon Oct 21 11:19:08 2024 +0800 修改报警接口 commit31ae2f378d
Author: joylink_fanyuhong <18706759286@163.com> Date: Mon Oct 21 10:57:15 2024 +0800 记录调整添加接口入参 commitc7d5464276
Author: joylink_fanyuhong <18706759286@163.com> Date: Mon Oct 21 10:24:35 2024 +0800 刷新token调整 commitc77612e4dc
Author: joylink_fanyuhong <18706759286@163.com> Date: Mon Oct 21 10:20:43 2024 +0800 代码调整 commit199e775f81
Merge:e90c255
00da310
Author: joylink_fanyuhong <18706759286@163.com> Date: Fri Oct 18 17:19:42 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/xian-ncc-da-client into develop commite90c25523e
Author: joylink_fanyuhong <18706759286@163.com> Date: Fri Oct 18 17:19:40 2024 +0800 接口调整暂时提交 commit00da31059b
Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Fri Oct 18 17:04:11 2024 +0800 决策信息暂提 commit012340628a
Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Thu Oct 17 09:33:01 2024 +0800 移动报警列表+去掉接口管理
This commit is contained in:
parent
8efecc78d7
commit
c4ee11a520
@ -73,7 +73,7 @@ export interface Item {
|
||||
export async function alarmInfoListQuery(
|
||||
params: PagingQueryParams
|
||||
): Promise<PageDto<Item>> {
|
||||
const response = await api.post('/api/alertRecord/page/detail', params);
|
||||
const response = await api.get('/api/alertRecord/page/detail', { params });
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询事件信息列表
|
||||
|
@ -72,3 +72,46 @@ export async function pageQuery(
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登出
|
||||
*/
|
||||
export async function logout(): Promise<string> {
|
||||
const response = await api.post(`${UserUriBase}/logout`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
interface tokenInfo {
|
||||
token: string;
|
||||
remainingSecond: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
export async function refreshToken(): Promise<tokenInfo> {
|
||||
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<userInfo> {
|
||||
const response = await api.post(`${UserUriBase}/info`);
|
||||
return response.data;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<q-list bordered separator>
|
||||
<div v-for="(menu, ii) in list" :key="ii">
|
||||
<div v-if="menu.children">
|
||||
<div v-if="menu.children && menu.show">
|
||||
<q-expansion-item :icon="menu.icon" :label="menu.label">
|
||||
<q-card>
|
||||
<q-list bordered separator>
|
||||
@ -24,7 +24,7 @@
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div v-else-if="menu.show">
|
||||
<q-item clickable :to="menu.path" exact>
|
||||
<q-item-section avatar>
|
||||
<q-icon :name="menu.icon"></q-icon>
|
||||
@ -39,20 +39,20 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getMonitorPath } from 'src/router/routes';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
import { reactive } from 'vue';
|
||||
const userStore = useUserStore();
|
||||
|
||||
const list = reactive([
|
||||
{
|
||||
path: '/monitor',
|
||||
show: true,
|
||||
path: getMonitorPath(userStore.roles),
|
||||
label: '监控',
|
||||
icon: 'computer',
|
||||
},
|
||||
{
|
||||
path: '/alarmList',
|
||||
label: '报警列表',
|
||||
icon: 'access_alarm',
|
||||
},
|
||||
{
|
||||
show: userStore.defaultRole == 'ADMIN',
|
||||
path: '',
|
||||
label: '数据管理',
|
||||
icon: 'list_alt',
|
||||
@ -90,6 +90,7 @@ const list = reactive([
|
||||
],
|
||||
},
|
||||
{
|
||||
show: true,
|
||||
path: '',
|
||||
label: '系统管理',
|
||||
icon: 'dataset',
|
||||
@ -104,11 +105,6 @@ const list = reactive([
|
||||
label: '权限管理',
|
||||
icon: 'nature_people',
|
||||
},
|
||||
{
|
||||
path: '/sysManage/authPath',
|
||||
label: '权限接口管理',
|
||||
icon: 'menu_open',
|
||||
},
|
||||
{
|
||||
path: '/sysManage/loginRecord',
|
||||
label: '登录记录',
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
<div class="q-gutter-sm row items-center no-wrap">
|
||||
<q-btn
|
||||
v-show="route.path.includes('line/monitor/')"
|
||||
v-show="showBackMonitor"
|
||||
color="info"
|
||||
label="返回"
|
||||
@click="backConfirm"
|
||||
@ -98,11 +98,11 @@
|
||||
</q-scroll-area>
|
||||
</q-page-container>
|
||||
</q-layout>
|
||||
<commonAlarm v-if="route.path.includes('alarmList')" />
|
||||
<commonAlarm v-if="route.path.includes('alarmRecord')" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue';
|
||||
import { ref, reactive, onMounted, onUnmounted, computed } from 'vue';
|
||||
import SysMenu from 'src/components/SysMenu.vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { Dialog, DialogChainObject, useQuasar } from 'quasar';
|
||||
@ -124,6 +124,10 @@ import {
|
||||
webSocketConnect,
|
||||
closeWebSocketConnect,
|
||||
} from 'src/components/webSocketConnect';
|
||||
import { logout } from 'src/api/UserApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
import { getMonitorPath } from 'src/router/routes';
|
||||
|
||||
const leftDrawerOpen = ref(false);
|
||||
const router = useRouter();
|
||||
@ -153,6 +157,14 @@ function onLeftResize(size: { width: number; height: number }) {
|
||||
leftDrawerSize.height = size.height;
|
||||
}
|
||||
|
||||
const showBackMonitor = computed(() => {
|
||||
const userStore = useUserStore();
|
||||
const isShow =
|
||||
route.path.includes('line/monitor/') &&
|
||||
getMonitorPath(userStore.roles) == '/monitor';
|
||||
return isShow;
|
||||
});
|
||||
|
||||
const watchInteract = () => {
|
||||
lineNetStore.playAble = true;
|
||||
document.removeEventListener('click', watchInteract);
|
||||
@ -210,9 +222,18 @@ function logOut() {
|
||||
message: '确认是否登出?',
|
||||
cancel: true,
|
||||
persistent: true,
|
||||
}).onOk(() => {
|
||||
}).onOk(async () => {
|
||||
try {
|
||||
await logout();
|
||||
clearJwtToken();
|
||||
router.push({ name: 'login' });
|
||||
} catch (err) {
|
||||
const apiErr = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: apiErr.title,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,138 +0,0 @@
|
||||
<template>
|
||||
<div class="q-pa-md">
|
||||
<q-table
|
||||
ref="tableRef"
|
||||
title="报警记录"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
class="my-sticky-virtscroll-table"
|
||||
:rows="rows"
|
||||
:columns="columnDefs"
|
||||
row-key="id"
|
||||
v-model:pagination="pagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:loading="loading"
|
||||
:filter="filter"
|
||||
binary-state-sort
|
||||
@request="onRequest"
|
||||
>
|
||||
<!-- <template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
debounce="1000"
|
||||
v-model="filter.name"
|
||||
label="用户名"
|
||||
></q-input>
|
||||
<q-btn flat round color="primary" icon="search" />
|
||||
</template> -->
|
||||
<!-- <template v-slot:body-cell-roles="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-chip
|
||||
outline
|
||||
size="sm"
|
||||
color="primary"
|
||||
v-for="(item, index) in props.row.roleList"
|
||||
:key="index"
|
||||
>
|
||||
{{ item.roleName }}
|
||||
</q-chip>
|
||||
</div>
|
||||
</q-td>
|
||||
</template> -->
|
||||
<!-- <template v-slot:body-cell-operations="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="编辑角色"
|
||||
:disable="operateDisabled"
|
||||
@click="edieUserData(props.row)"
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template> -->
|
||||
</q-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { useQuasar, type QTableColumn } from 'quasar';
|
||||
import { pageQuery, Record } from '../api/LogApi';
|
||||
import { errorNotify } from '../utils/CommonNotify';
|
||||
|
||||
const $q = useQuasar();
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
sizeHeight: number;
|
||||
}>(),
|
||||
{ sizeHeight: 500 }
|
||||
);
|
||||
const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
});
|
||||
|
||||
const columnDefs: QTableColumn[] = [
|
||||
{ name: 'id', label: 'ID', field: 'id', align: 'center' },
|
||||
{
|
||||
name: 'userName',
|
||||
label: '操作人员',
|
||||
field: 'userName',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'mobile',
|
||||
label: '手机号',
|
||||
field: 'mobile',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'createDateTime',
|
||||
label: '记录时间',
|
||||
field: 'createDateTime',
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableRef = ref();
|
||||
const rows = reactive([]);
|
||||
const filter = reactive({
|
||||
name: '',
|
||||
});
|
||||
const loading = ref(false);
|
||||
const pagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
rowsNumber: 10,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line
|
||||
async function onRequest(props: any) {
|
||||
const { page, rowsPerPage, sortBy, descending } = props.pagination;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
let response = await pageQuery({
|
||||
current: page,
|
||||
size: rowsPerPage,
|
||||
});
|
||||
|
||||
pagination.value.rowsNumber = response.total;
|
||||
pagination.value.page = page;
|
||||
pagination.value.rowsPerPage = rowsPerPage;
|
||||
pagination.value.sortBy = sortBy;
|
||||
pagination.value.descending = descending;
|
||||
rows.splice(0, rows.length, ...(response.records as []));
|
||||
} catch (error: any) {
|
||||
errorNotify('获取数据失败', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
@ -73,6 +73,23 @@
|
||||
<div class="text-h6">
|
||||
{{ creatForm.id ? '编辑决策信息' : '新建决策信息' }}
|
||||
</div>
|
||||
<q-select
|
||||
outlined
|
||||
label="线路ID"
|
||||
v-model="creatForm.lineId"
|
||||
:options="optionsLineId"
|
||||
emit-value
|
||||
map-options
|
||||
options-dense
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请选择线路ID!']"
|
||||
/>
|
||||
<q-select
|
||||
outlined
|
||||
label="线路类型"
|
||||
v-model="creatForm.lineType"
|
||||
:options="optionsLineType"
|
||||
/>
|
||||
<q-select
|
||||
outlined
|
||||
label="故障类型"
|
||||
@ -111,7 +128,7 @@
|
||||
</q-card-section>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="创建" type="submit" />
|
||||
<q-btn color="primary" label="确定" type="submit" />
|
||||
<q-btn label="取消" type="reset" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
@ -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<QForm | null>(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 = '';
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="q-pa-md">
|
||||
<q-table
|
||||
ref="tableRef"
|
||||
title="报警记录"
|
||||
title="登录记录"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
class="my-sticky-virtscroll-table"
|
||||
:rows="rows"
|
||||
@ -15,6 +15,15 @@
|
||||
binary-state-sort
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:body-cell-subEventType="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-chip outline size="sm" color="primary">
|
||||
{{ getSubEventType(props.row.subEventType) }}
|
||||
</q-chip>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
<!-- <template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
@ -78,24 +87,36 @@ onMounted(() => {
|
||||
|
||||
const columnDefs: QTableColumn[] = [
|
||||
{ name: 'id', label: 'ID', field: 'id', align: 'center' },
|
||||
{
|
||||
name: 'subEventType',
|
||||
label: '操作',
|
||||
field: 'subEventType',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'faceName',
|
||||
label: '接口名称',
|
||||
field: 'faceName',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'userName',
|
||||
label: '操作人员',
|
||||
field: 'userName',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'mobile',
|
||||
label: '手机号',
|
||||
field: 'mobile',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'createDateTime',
|
||||
label: '记录时间',
|
||||
field: 'createDateTime',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'requestSuccess',
|
||||
label: '请求成功',
|
||||
field: 'requestSuccess',
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableRef = ref();
|
||||
@ -121,6 +142,7 @@ async function onRequest(props: any) {
|
||||
let response = await pageQuery({
|
||||
current: page,
|
||||
size: rowsPerPage,
|
||||
logType: 'LOGIN',
|
||||
});
|
||||
|
||||
pagination.value.rowsNumber = response.total;
|
||||
@ -135,4 +157,21 @@ async function onRequest(props: any) {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getSubEventType(type: string) {
|
||||
switch (type) {
|
||||
case 'LOGIN':
|
||||
return '登录';
|
||||
case 'LOGOUT':
|
||||
return '登出';
|
||||
case 'QUERY':
|
||||
return '查询';
|
||||
case 'SAVE_OR_UPDATE':
|
||||
return '保存';
|
||||
case 'DELETE':
|
||||
return '删除';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="q-pa-md">
|
||||
<q-table
|
||||
ref="tableRef"
|
||||
title="报警记录"
|
||||
title="操作记录"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
class="my-sticky-virtscroll-table"
|
||||
:rows="rows"
|
||||
@ -15,6 +15,15 @@
|
||||
binary-state-sort
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:body-cell-subEventType="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-chip outline size="sm" color="primary">
|
||||
{{ getSubEventType(props.row.subEventType) }}
|
||||
</q-chip>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
<!-- <template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
@ -78,24 +87,36 @@ onMounted(() => {
|
||||
|
||||
const columnDefs: QTableColumn[] = [
|
||||
{ name: 'id', label: 'ID', field: 'id', align: 'center' },
|
||||
{
|
||||
name: 'subEventType',
|
||||
label: '操作',
|
||||
field: 'subEventType',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'faceName',
|
||||
label: '接口名称',
|
||||
field: 'faceName',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'userName',
|
||||
label: '操作人员',
|
||||
field: 'userName',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'mobile',
|
||||
label: '手机号',
|
||||
field: 'mobile',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'createDateTime',
|
||||
label: '记录时间',
|
||||
field: 'createDateTime',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'requestSuccess',
|
||||
label: '请求成功',
|
||||
field: 'requestSuccess',
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableRef = ref();
|
||||
@ -121,6 +142,7 @@ async function onRequest(props: any) {
|
||||
let response = await pageQuery({
|
||||
current: page,
|
||||
size: rowsPerPage,
|
||||
logType: 'OPERATE',
|
||||
});
|
||||
|
||||
pagination.value.rowsNumber = response.total;
|
||||
@ -135,4 +157,21 @@ async function onRequest(props: any) {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getSubEventType(type: string) {
|
||||
switch (type) {
|
||||
case 'LOGIN':
|
||||
return '登录';
|
||||
case 'LOGOUT':
|
||||
return '登出';
|
||||
case 'QUERY':
|
||||
return '查询';
|
||||
case 'SAVE_OR_UPDATE':
|
||||
return '保存';
|
||||
case 'DELETE':
|
||||
return '删除';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -15,7 +15,7 @@
|
||||
binary-state-sort
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:top-right>
|
||||
<!-- <template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
debounce="1000"
|
||||
@ -43,7 +43,7 @@
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</template> -->
|
||||
</q-table>
|
||||
|
||||
<q-dialog
|
||||
@ -128,7 +128,6 @@ const columnDefs: QTableColumn[] = [
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const operateDisabled = ref(false);
|
||||
|
@ -55,13 +55,17 @@
|
||||
<script setup lang="ts">
|
||||
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;
|
||||
|
@ -39,7 +39,10 @@
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
<template v-slot:body-cell-operations="props">
|
||||
<template
|
||||
v-if="userStore.defaultRole == 'ADMIN'"
|
||||
v-slot:body-cell-operations="props"
|
||||
>
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
@ -99,6 +102,7 @@ import { pageQuery, User } from '../api/UserApi';
|
||||
import { errorNotify, successNotify } from '../utils/CommonNotify';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { pageQueryRole, userLinkRole } from 'src/api/AuthApi';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
|
||||
const $q = useQuasar();
|
||||
const props = withDefaults(
|
||||
@ -110,8 +114,17 @@ const props = withDefaults(
|
||||
const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32;
|
||||
});
|
||||
const userStore = useUserStore();
|
||||
|
||||
onMounted(() => {
|
||||
if (userStore.defaultRole == 'ADMIN') {
|
||||
columnDefs.push({
|
||||
name: 'operations',
|
||||
label: '操作',
|
||||
field: 'operations',
|
||||
align: 'center',
|
||||
});
|
||||
}
|
||||
tableRef.value.requestServerInteraction();
|
||||
getAllRole();
|
||||
});
|
||||
@ -144,7 +157,6 @@ const columnDefs: QTableColumn[] = [
|
||||
field: 'mobile',
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const tableRef = ref();
|
||||
|
@ -8,6 +8,9 @@ import {
|
||||
|
||||
import routes from './routes';
|
||||
import { getJwtToken } from 'src/configs/TokenManage';
|
||||
import { getUserInfo } from 'src/api/UserApi';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
import { handleRefreshToken } from 'src/utils/refreshToken';
|
||||
|
||||
/*
|
||||
* If not building with SSR mode, you can
|
||||
@ -42,7 +45,24 @@ export default route(function (/* { store, ssrContext } */) {
|
||||
if (!getJwtToken()) {
|
||||
next({ path: '/login' });
|
||||
} else {
|
||||
try {
|
||||
const userStore = useUserStore();
|
||||
if (!userStore.remainingSecond) {
|
||||
const userInfo = await getUserInfo();
|
||||
userStore.defaultRole = userInfo.defaultRole;
|
||||
userStore.roles = userInfo.roles;
|
||||
userStore.remainingSecond = userInfo.remainingSecond;
|
||||
setTimeout(
|
||||
() => handleRefreshToken(),
|
||||
userInfo.remainingSecond * 1000 - 10000
|
||||
);
|
||||
}
|
||||
|
||||
next();
|
||||
} catch (e) {
|
||||
console.error('获取用户信息出错:', e);
|
||||
next({ path: '/login' });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { RouteRecordRaw } from 'vue-router';
|
||||
import { role } from 'src/api/UserApi';
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
redirect: '/monitor',
|
||||
redirect: '/login',
|
||||
// component: () => import('layouts/MainLayout.vue'),
|
||||
// children: [{ path: '', component: () => import('pages/IndexPage.vue') }],
|
||||
},
|
||||
@ -108,7 +109,7 @@ const routes: RouteRecordRaw[] = [
|
||||
meta: {
|
||||
description: '报警记录',
|
||||
},
|
||||
component: () => import('pages/AlarmRecord.vue'),
|
||||
component: () => import('pages/AlarmInfoList.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -157,17 +158,6 @@ const routes: RouteRecordRaw[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/alarmList',
|
||||
component: () => import('layouts/MainLayout.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'alarmList',
|
||||
component: () => import('src/pages/AlarmInfoList.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// Always leave this as last one,
|
||||
// but you can also remove it
|
||||
@ -178,3 +168,22 @@ const routes: RouteRecordRaw[] = [
|
||||
];
|
||||
|
||||
export default routes;
|
||||
|
||||
export function getMonitorPath(roles: role[]) {
|
||||
let monitorPath = '';
|
||||
const allOCCLineIds: number[] = [];
|
||||
for (let i = 0; i < roles.length; i++) {
|
||||
const roleConfig = roles[i].roleConfig;
|
||||
for (let j = 0; j < roleConfig.length; j++) {
|
||||
if (roleConfig[j].lineType == 'NCC') {
|
||||
monitorPath = '/monitor';
|
||||
return monitorPath;
|
||||
} else {
|
||||
allOCCLineIds.push(roleConfig[j].lineId);
|
||||
}
|
||||
}
|
||||
}
|
||||
const minId = Math.min(...allOCCLineIds);
|
||||
monitorPath = `/line/monitor/${minId}`;
|
||||
return monitorPath;
|
||||
}
|
||||
|
19
src/stores/user-store.ts
Normal file
19
src/stores/user-store.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { role } from 'src/api/UserApi';
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: () => ({
|
||||
remainingSecond: 0,
|
||||
roles: [] as role[],
|
||||
defaultRole: '',
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// setRemainingSecond(remainingSecond: number) {
|
||||
// this.remainingSecond = remainingSecond;
|
||||
// },
|
||||
// setDefaultRole(defaultRole: string) {
|
||||
// this.defaultRole = defaultRole;
|
||||
// },
|
||||
},
|
||||
});
|
18
src/utils/refreshToken.ts
Normal file
18
src/utils/refreshToken.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { saveJwtToken } from 'src/configs/TokenManage';
|
||||
import { refreshToken } from 'src/api/UserApi';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
|
||||
export async function handleRefreshToken() {
|
||||
try {
|
||||
const userStore = useUserStore();
|
||||
const tokenInfo = await refreshToken();
|
||||
saveJwtToken(tokenInfo.token);
|
||||
userStore.remainingSecond = tokenInfo.remainingSecond;
|
||||
setTimeout(
|
||||
() => handleRefreshToken(),
|
||||
tokenInfo.remainingSecond * 1000 - 10000
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('刷新 token 出错:', e);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user