订阅路径修改
This commit is contained in:
parent
2a7cf2e186
commit
330f7cc809
@ -25,6 +25,7 @@ export interface RoleInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
resList: number[];
|
||||
roleConfigStr: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ const userStore = useUserStore();
|
||||
const list = reactive([
|
||||
{
|
||||
show: true,
|
||||
path: getMonitorPath(userStore.roles),
|
||||
path: getMonitorPath(userStore.roles).monitorPath,
|
||||
label: '监控',
|
||||
icon: 'computer',
|
||||
},
|
||||
|
@ -73,6 +73,8 @@ import {
|
||||
import { Notify, QNotifyUpdateOptions } from 'quasar';
|
||||
import { useLineNetStore } from 'src/stores/line-net-store';
|
||||
import { alert } from 'src/protos/alertInfo';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
import { getMonitorPath } from 'src/router/routes';
|
||||
|
||||
let lineApp: IGraphicApp | null = null;
|
||||
|
||||
@ -304,11 +306,14 @@ function handleSubscribe(lineApp: IGraphicApp) {
|
||||
},
|
||||
});
|
||||
const lineNetStore = useLineNetStore();
|
||||
lineApp.subscribe({
|
||||
destination: '/queue/xian/ncc/alert',
|
||||
messageHandle: (message: Uint8Array) => {
|
||||
const storage = alert.NccAlertInfoMessage.deserialize(message);
|
||||
lineNetStore.setAlarmInfo(storage.messages as []);
|
||||
},
|
||||
const userStore = useUserStore();
|
||||
getMonitorPath(userStore.roles).destinations.forEach((destination) => {
|
||||
lineApp.subscribe({
|
||||
destination,
|
||||
messageHandle: (message: Uint8Array) => {
|
||||
const storage = alert.NccAlertInfoMessage.deserialize(message);
|
||||
lineNetStore.setAlarmInfo(storage.messages as []);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ import { getWebsocketUrl } from 'src/configs/UrlManage';
|
||||
import { getJwtToken } from 'src/configs/TokenManage';
|
||||
import { alert } from 'src/protos/alertInfo';
|
||||
import { Notify } from 'quasar';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
import { getMonitorPath } from 'src/router/routes';
|
||||
|
||||
let lineNetApp: IGraphicApp | null = null;
|
||||
|
||||
@ -161,11 +163,14 @@ function handleSubscribe(lineNetApp: IGraphicApp) {
|
||||
return states;
|
||||
},
|
||||
});
|
||||
lineNetApp.subscribe({
|
||||
destination: '/queue/xian/ncc/alert',
|
||||
messageHandle: (message: Uint8Array) => {
|
||||
const storage = alert.NccAlertInfoMessage.deserialize(message);
|
||||
lineNetStore.setAlarmInfo(storage.messages as []);
|
||||
},
|
||||
const userStore = useUserStore();
|
||||
getMonitorPath(userStore.roles).destinations.forEach((destination) => {
|
||||
lineNetApp.subscribe({
|
||||
destination,
|
||||
messageHandle: (message: Uint8Array) => {
|
||||
const storage = alert.NccAlertInfoMessage.deserialize(message);
|
||||
lineNetStore.setAlarmInfo(storage.messages as []);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ const showBackMonitor = computed(() => {
|
||||
const userStore = useUserStore();
|
||||
const isShow =
|
||||
route.path.includes('line/monitor/') &&
|
||||
getMonitorPath(userStore.roles) == '/monitor';
|
||||
getMonitorPath(userStore.roles).lineType == 'NCC';
|
||||
return isShow;
|
||||
});
|
||||
|
||||
|
@ -237,6 +237,8 @@ import {
|
||||
webSocketConnect,
|
||||
closeWebSocketConnect,
|
||||
} from 'src/components/webSocketConnect';
|
||||
import { getMonitorPath } from 'src/router/routes';
|
||||
import { useUserStore } from 'src/stores/user-store';
|
||||
|
||||
const $q = useQuasar();
|
||||
const lineNetStore = useLineNetStore();
|
||||
@ -246,6 +248,7 @@ const props = withDefaults(
|
||||
}>(),
|
||||
{ sizeHeight: 500 }
|
||||
);
|
||||
const userStore = useUserStore();
|
||||
|
||||
const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32;
|
||||
@ -369,10 +372,13 @@ async function onRequest(props: any) {
|
||||
|
||||
onMounted(() => {
|
||||
queryLineInfo();
|
||||
destinations = getMonitorPath(userStore.roles).destinations;
|
||||
setTimeout(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
lineNetStore.alarmInfoListTable = tableRef.value;
|
||||
socket = webSocketConnect(destination, handler);
|
||||
destinations.forEach((destination) => {
|
||||
socket = webSocketConnect(destination, handler);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -552,14 +558,16 @@ function openAlarmDialog(row: any) {
|
||||
}
|
||||
|
||||
let socket: StompMessagingClient | null = null;
|
||||
const destination = '/queue/xian/ncc/alert';
|
||||
let destinations: string[] = [];
|
||||
function handler(message: Uint8Array) {
|
||||
const storage = alert.NccAlertInfoMessage.deserialize(message);
|
||||
lineNetStore.setAlarmInfo(storage.messages as []);
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
closeWebSocketConnect(socket, destination);
|
||||
destinations.forEach((destination) => {
|
||||
closeWebSocketConnect(socket, destination);
|
||||
});
|
||||
});
|
||||
|
||||
//报警统计
|
||||
|
@ -159,18 +159,19 @@ async function onRequest(props: any) {
|
||||
interface RoleItemInfo extends Omit<RoleInfo, 'id'> {
|
||||
id: string;
|
||||
editPaths: { id: number }[];
|
||||
config: string;
|
||||
roleConfigStr: string;
|
||||
}
|
||||
const roleInfo = reactive<RoleItemInfo>({
|
||||
id: '',
|
||||
editPaths: [],
|
||||
name: '',
|
||||
resList: [],
|
||||
config: '',
|
||||
roleConfigStr: '',
|
||||
});
|
||||
function edieRoleData(row: RoleInfo) {
|
||||
roleInfo.id = row.id + '';
|
||||
roleInfo.name = row.name;
|
||||
roleInfo.roleConfigStr=row.roleConfigStr
|
||||
editFormShow.value = true;
|
||||
}
|
||||
|
||||
@ -182,7 +183,7 @@ function roleConfigFn() {
|
||||
if (res) {
|
||||
operateDisabled.value = true;
|
||||
try {
|
||||
await roleConfig(+roleInfo.id, roleInfo.config);
|
||||
await roleConfig(+roleInfo.id, roleInfo.roleConfigStr);
|
||||
editFormShow.value = false;
|
||||
successNotify('修改成功');
|
||||
} catch (err) {
|
||||
@ -201,7 +202,7 @@ function roleConfigFn() {
|
||||
function onReset() {
|
||||
roleInfo.id = '';
|
||||
roleInfo.name = '';
|
||||
roleInfo.config = '';
|
||||
roleInfo.roleConfigStr = '';
|
||||
myForm.value?.resetValidation();
|
||||
}
|
||||
</script>
|
||||
|
@ -86,7 +86,7 @@ async function doLogin() {
|
||||
() => handleRefreshToken(),
|
||||
userInfo.remainingSecond * 1000 - 10000
|
||||
);
|
||||
router.replace(getMonitorPath(userInfo.roles));
|
||||
router.replace(getMonitorPath(userInfo.roles).monitorPath);
|
||||
} catch (err) {
|
||||
visible.value = false;
|
||||
const apiErr = err as ApiError;
|
||||
|
@ -170,20 +170,43 @@ const routes: RouteRecordRaw[] = [
|
||||
export default routes;
|
||||
|
||||
export function getMonitorPath(roles: role[]) {
|
||||
let monitorPath = '';
|
||||
const allOCCLineIds: number[] = [];
|
||||
const configInfo: {
|
||||
monitorPath: string;
|
||||
lineIds: number[];
|
||||
lineType: string;
|
||||
destinations: string[];
|
||||
} = {
|
||||
monitorPath: '',
|
||||
lineIds: [],
|
||||
lineType: '',
|
||||
destinations: [],
|
||||
};
|
||||
let 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;
|
||||
configInfo.monitorPath = '/monitor';
|
||||
configInfo.lineIds = roleConfig.map((config) => {
|
||||
configInfo.destinations.push(
|
||||
`/queue/xian/NCC/${config.lineId}/alert`
|
||||
);
|
||||
return config.lineId;
|
||||
});
|
||||
configInfo.lineType = 'NCC';
|
||||
return configInfo;
|
||||
} else {
|
||||
allOCCLineIds.push(roleConfig[j].lineId);
|
||||
}
|
||||
}
|
||||
}
|
||||
allOCCLineIds = [...new Set(allOCCLineIds)];
|
||||
const minId = Math.min(...allOCCLineIds);
|
||||
monitorPath = `/line/monitor/${minId}`;
|
||||
return monitorPath;
|
||||
configInfo.monitorPath = `/line/monitor/${minId}`;
|
||||
configInfo.lineIds = allOCCLineIds;
|
||||
configInfo.lineType = 'OCC';
|
||||
allOCCLineIds.forEach((lineId) => {
|
||||
configInfo.destinations.push(`/queue/xian/OCC/${lineId}/alert`);
|
||||
});
|
||||
return configInfo;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user