Compare commits

..

No commits in common. "40d57a3fc890f7087bc0a3a6238ef6e105d31907" and "c4ee11a52084955b6c343fb5ae423612e83f5910" have entirely different histories.

15 changed files with 148 additions and 204 deletions

View File

@ -63,8 +63,6 @@ export interface Item {
drivingInfo: string;
submissionInfo: string;
alarmStatus: number;
lineId: number;
lineType: string;
}
/**

View File

@ -25,7 +25,6 @@ export interface RoleInfo {
id: number;
name: string;
resList: number[];
roleConfigStr: string;
}
/**
@ -78,19 +77,6 @@ export async function getRoleInfo(id: number): Promise<RoleInfo> {
return response.data;
}
/**
*
* @param id id
* @param data
*/
export function roleConfig(id: number, data: string) {
return api.post(`${AuthBase}/config/${id}`, data, {
headers: {
'Content-Type': 'text/plain',
},
});
}
interface LinkRole {
id: number;
roleList: number[];

View File

@ -47,7 +47,7 @@ const userStore = useUserStore();
const list = reactive([
{
show: true,
path: getMonitorPath(userStore.roles).monitorPath,
path: getMonitorPath(userStore.roles),
label: '监控',
icon: 'computer',
},

View File

@ -49,22 +49,11 @@
/>
<q-card-actions align="left">
<div class="q-gutter-md">
<q-btn
color="primary"
label="确认"
:disable="operateDisabled"
type="submit"
/>
<q-btn
color="red"
label="误报"
:disable="operateDisabled"
@click="falseAlarm"
/>
<q-btn color="primary" label="确认" type="submit" />
<q-btn color="red" label="误报" @click="falseAlarm" />
<q-btn
color="primary"
label="人工接警"
:disable="operateDisabled"
@click="manualAlarm"
/>
</div>
@ -99,7 +88,7 @@
<script setup lang="ts">
import DraggableDialog from '../common/DraggableDialog.vue';
import { useLineNetStore, AlarmInfo } from 'src/stores/line-net-store';
import { computed, onMounted, ref } from 'vue';
import { onMounted, ref } from 'vue';
import { QForm, useQuasar } from 'quasar';
import { saveAlertTypeData, showAlertTypeData } from './alarmInfoEnum';
import {
@ -108,8 +97,6 @@ import {
recordManualAlarmInfoById,
} from 'src/api/AlertMock';
import { queryAlarmInfoById } from 'src/api/DecisionInfo';
import { useUserStore } from 'src/stores/user-store';
import { getMonitorPath } from 'src/router/routes';
const props = defineProps<{
alarmMeaasge?: AlarmInfo;
@ -137,7 +124,6 @@ const alarmInfo = ref({
level: '',
time: '',
lineId: '',
lineType: '',
alertObject: '',
alertType: '',
locator_device_id: '',
@ -217,7 +203,6 @@ function updata() {
];
alarmInfo.value.alertObject = messageUse.alert_object.replace(/\[|]/g, '');
alarmInfo.value.lineId = messageUse.line_id;
alarmInfo.value.lineType = messageUse.line_type;
}
async function searchByTipType() {
@ -252,15 +237,6 @@ async function searchById() {
});
}
}
const userStore = useUserStore();
const operateDisabled = computed(() => {
const config = getMonitorPath(userStore.roles);
const disabled =
config.lineType == alarmInfo.value.lineType &&
config.lineIds.includes(+alarmInfo.value.lineId);
return !disabled;
});
</script>
<style lang='scss' scoped>

View File

@ -73,8 +73,6 @@ 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;
@ -306,14 +304,11 @@ function handleSubscribe(lineApp: IGraphicApp) {
},
});
const lineNetStore = useLineNetStore();
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 []);
},
});
lineApp.subscribe({
destination: '/queue/xian/ncc/alert',
messageHandle: (message: Uint8Array) => {
const storage = alert.NccAlertInfoMessage.deserialize(message);
lineNetStore.setAlarmInfo(storage.messages as []);
},
});
}

View File

@ -35,8 +35,6 @@ 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;
@ -163,14 +161,11 @@ function handleSubscribe(lineNetApp: IGraphicApp) {
return states;
},
});
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 []);
},
});
lineNetApp.subscribe({
destination: '/queue/xian/ncc/alert',
messageHandle: (message: Uint8Array) => {
const storage = alert.NccAlertInfoMessage.deserialize(message);
lineNetStore.setAlarmInfo(storage.messages as []);
},
});
}

View File

@ -161,7 +161,7 @@ const showBackMonitor = computed(() => {
const userStore = useUserStore();
const isShow =
route.path.includes('line/monitor/') &&
getMonitorPath(userStore.roles).lineType == 'NCC';
getMonitorPath(userStore.roles) == '/monitor';
return isShow;
});

View File

@ -237,8 +237,6 @@ 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();
@ -248,7 +246,6 @@ const props = withDefaults(
}>(),
{ sizeHeight: 500 }
);
const userStore = useUserStore();
const tableHeight = computed(() => {
return props.sizeHeight - 32;
@ -274,13 +271,6 @@ const columnDefs: QTableColumn[] = [
field: 'lineId',
align: 'center',
},
{
name: 'lineType',
label: '线路类型',
field: 'lineType',
required: true,
align: 'center',
},
{
name: 'alertObject',
label: '设备',
@ -379,13 +369,10 @@ async function onRequest(props: any) {
onMounted(() => {
queryLineInfo();
destinations = getMonitorPath(userStore.roles).destinations;
setTimeout(() => {
tableRef.value.requestServerInteraction();
lineNetStore.alarmInfoListTable = tableRef.value;
destinations.forEach((destination) => {
socket = webSocketConnect(destination, handler);
});
socket = webSocketConnect(destination, handler);
});
});
@ -399,12 +386,8 @@ watch(
);
function updateSelect() {
const config = getMonitorPath(userStore.roles);
for (let i = 0; i < selected.value.length; i++) {
const canSelect =
config.lineType == selected.value[i].lineType &&
config.lineIds.includes(+selected.value[i].lineId);
if (selected.value[i].alarmStatus !== -1 || !canSelect) {
if (selected.value[i].alarmStatus !== -1) {
selected.value.splice(i, 1);
i--;
}
@ -549,7 +532,6 @@ function openAlarmDialog(row: any) {
row.alert_time = row.alertTime;
row.alert_type = row.alertType;
row.line_id = row.lineId;
row.line_type = row.lineType;
row.alert_object = row.alertObject;
row.alert_tip_id = row.alertTipId;
row.alert_location_id = row.alertLocationId;
@ -570,16 +552,14 @@ function openAlarmDialog(row: any) {
}
let socket: StompMessagingClient | null = null;
let destinations: string[] = [];
const destination = '/queue/xian/ncc/alert';
function handler(message: Uint8Array) {
const storage = alert.NccAlertInfoMessage.deserialize(message);
lineNetStore.setAlarmInfo(storage.messages as []);
}
onUnmounted(() => {
destinations.forEach((destination) => {
closeWebSocketConnect(socket, destination);
});
closeWebSocketConnect(socket, destination);
});
//

View File

@ -15,21 +15,35 @@
binary-state-sort
@request="onRequest"
>
<template
v-if="userStore.defaultRole == 'ADMIN'"
v-slot:body-cell-operations="props"
>
<!-- <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" />
<q-btn color="primary" label="新建" @click="editFormShow = true" />
</template>
<template v-slot:body-cell-operations="props">
<q-td :props="props">
<div class="q-gutter-sm row justify-center">
<q-btn
:disable="operateDisabled"
color="primary"
label="配置"
label="编辑"
@click="edieRoleData(props.row)"
:disable="props.row.id == 1"
/>
<q-btn
color="red"
:disable="operateDisabled || [1, 2].includes(props.row.id)"
label="删除"
@click="deleteRoleData(props.row)"
/>
</div>
</q-td>
</template>
</template> -->
</q-table>
<q-dialog
@ -38,31 +52,37 @@
transition-show="scale"
transition-hide="scale"
>
</q-dialog>
<q-dialog
v-model="editFormShow"
persistent
transition-show="scale"
transition-hide="scale"
>
<q-card style="width: 300px">
<q-card-section>
<q-form
ref="myForm"
@submit="roleConfigFn"
@reset="onReset"
class="q-gutter-md"
>
<div class="text-h6">配置角色信息</div>
<q-input outlined disable label="角色" v-model="roleInfo.name" />
<q-input outlined label="配置" v-model="roleInfo.config" />
<q-card style="width: 1400px; max-width: 80vw">
<q-form
ref="myForm"
@submit="edieRolePath"
@reset="onReset"
class="q-gutter-md"
>
<q-card-section>
<div class="text-h5">{{ roleInfo.id ? '编辑' : '新建' }}</div>
<div class="q-pa-md">
<q-input
outlined
dense
label="角色名称"
v-model="roleInfo.name"
lazy-rules
:rules="[(val) => val.length > 0 || '请输入角色名称!']"
style="width: 300px"
/>
</div>
<AuthPathManage
:sizeHeight="600"
:selects="roleInfo.editPaths || []"
@selectsed="pathSelectsed"
/>
<q-card-actions align="right">
<q-btn color="primary" label="保存" type="submit" />
<q-btn label="取消" type="reset" v-close-popup />
</q-card-actions>
</q-form>
</q-card-section>
</q-card-section>
</q-form>
</q-card>
</q-dialog>
</div>
@ -71,10 +91,18 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue';
import { useQuasar, type QTableColumn, QForm } from 'quasar';
import { pageQueryRole, roleConfig, RoleInfo } from 'src/api/AuthApi';
import {
PathItem,
RoleInfo,
createRole,
createRoleParams,
deleteRole,
pageQueryRole,
saveRoleData,
} from 'src/api/AuthApi';
import { ApiError } from 'src/boot/axios';
import { successNotify } from 'src/utils/CommonNotify';
import { useUserStore } from 'src/stores/user-store';
import AuthPathManage from './AuthPathManage.vue';
const $q = useQuasar();
const props = withDefaults(
@ -86,17 +114,8 @@ 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();
});
@ -111,6 +130,8 @@ const columnDefs: QTableColumn[] = [
},
];
const operateDisabled = ref(false);
const tableRef = ref();
const rows = reactive([]);
const filter = reactive({
@ -155,37 +176,53 @@ async function onRequest(props: any) {
}
}
//
const editFormShow = ref(false);
interface RoleItemInfo extends Omit<RoleInfo, 'id'> {
id: string;
editPaths: { id: number }[];
roleConfigStr: string;
}
const roleInfo = reactive<RoleItemInfo>({
id: '',
editPaths: [],
name: '',
resList: [],
roleConfigStr: '',
});
//
function edieRoleData(row: RoleInfo) {
roleInfo.id = row.id + '';
roleInfo.name = row.name;
roleInfo.roleConfigStr=row.roleConfigStr
const list = row.resList || [];
roleInfo.resList = list;
roleInfo.editPaths = list.map((item) => {
return { id: item };
});
editFormShow.value = true;
}
const operateDisabled = ref(false);
const myForm = ref<QForm | null>(null);
const editFormShow = ref(false);
function roleConfigFn() {
//
async function edieRolePath() {
myForm.value?.validate().then(async (res) => {
if (res) {
operateDisabled.value = true;
try {
await roleConfig(+roleInfo.id, roleInfo.roleConfigStr);
const params: createRoleParams = {
name: roleInfo.name,
resList: roleInfo.resList,
};
if (roleInfo.id) {
const cloneParams = Object.assign(params, { id: +roleInfo.id });
await saveRoleData(cloneParams);
} else {
await createRole(params);
}
onReset();
tableRef.value.requestServerInteraction(); //
editFormShow.value = false;
successNotify('修改成功');
successNotify('保存成功!');
} catch (err) {
const error = err as ApiError;
$q.notify({
@ -199,10 +236,39 @@ function roleConfigFn() {
});
}
function deleteRoleData(row: RoleInfo) {
operateDisabled.value = true;
$q.dialog({
title: '确认',
message: `确认删除角色 "${row.name}" 吗?`,
cancel: true,
})
.onOk(async () => {
try {
await deleteRole(row.id);
tableRef.value.requestServerInteraction(); //
} catch (err) {
const error = err as ApiError;
$q.notify({
type: 'negative',
message: error.title,
});
}
})
.onDismiss(() => {
operateDisabled.value = false;
});
}
function onReset() {
roleInfo.id = '';
roleInfo.name = '';
roleInfo.roleConfigStr = '';
roleInfo.editPaths = [];
roleInfo.resList = [];
myForm.value?.resetValidation();
}
function pathSelectsed(val: PathItem[]) {
roleInfo.resList = val.map((item) => item.id);
}
</script>

View File

@ -86,7 +86,7 @@ async function doLogin() {
() => handleRefreshToken(),
userInfo.remainingSecond * 1000 - 10000
);
router.replace(getMonitorPath(userInfo.roles).monitorPath);
router.replace(getMonitorPath(userInfo.roles));
} catch (err) {
visible.value = false;
const apiErr = err as ApiError;

View File

@ -239,15 +239,10 @@ function edieUserData(row: User) {
userInfo.name = row.name;
userInfo.mobile = row.mobile;
userInfo.registerTime = row.registerTime;
if (row?.roleList) {
userInfo.roleList = row.roleList;
userInfo.Rids = row.roleList.map((item) => {
return item.roleId;
});
} else {
userInfo.roleList = [];
userInfo.Rids = [];
}
userInfo.roleList = row.roleList;
userInfo.Rids = row.roleList.map((item) => {
return item.roleId;
});
editFormShow.value = true;
}

View File

@ -87,7 +87,6 @@ export namespace alert {
locator_device_id?: string;
alert_location_id?: number;
mock?: boolean;
line_type?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -122,9 +121,6 @@ export namespace alert {
if ("mock" in data && data.mock != undefined) {
this.mock = data.mock;
}
if ("line_type" in data && data.line_type != undefined) {
this.line_type = data.line_type;
}
}
}
get id() {
@ -187,12 +183,6 @@ export namespace alert {
set mock(value: boolean) {
pb_1.Message.setField(this, 10, value);
}
get line_type() {
return pb_1.Message.getFieldWithDefault(this, 11, "") as string;
}
set line_type(value: string) {
pb_1.Message.setField(this, 11, value);
}
static fromObject(data: {
id?: string;
level?: string;
@ -204,7 +194,6 @@ export namespace alert {
locator_device_id?: string;
alert_location_id?: number;
mock?: boolean;
line_type?: string;
}): Message {
const message = new Message({});
if (data.id != null) {
@ -237,9 +226,6 @@ export namespace alert {
if (data.mock != null) {
message.mock = data.mock;
}
if (data.line_type != null) {
message.line_type = data.line_type;
}
return message;
}
toObject() {
@ -254,7 +240,6 @@ export namespace alert {
locator_device_id?: string;
alert_location_id?: number;
mock?: boolean;
line_type?: string;
} = {};
if (this.id != null) {
data.id = this.id;
@ -286,9 +271,6 @@ export namespace alert {
if (this.mock != null) {
data.mock = this.mock;
}
if (this.line_type != null) {
data.line_type = this.line_type;
}
return data;
}
serialize(): Uint8Array;
@ -315,8 +297,6 @@ export namespace alert {
writer.writeInt64(9, this.alert_location_id);
if (this.mock != false)
writer.writeBool(10, this.mock);
if (this.line_type.length)
writer.writeString(11, this.line_type);
if (!w)
return writer.getResultBuffer();
}
@ -356,9 +336,6 @@ export namespace alert {
case 10:
message.mock = reader.readBool();
break;
case 11:
message.line_type = reader.readString();
break;
default: reader.skipField();
}
}

View File

@ -170,43 +170,20 @@ const routes: RouteRecordRaw[] = [
export default routes;
export function getMonitorPath(roles: role[]) {
const configInfo: {
monitorPath: string;
lineIds: number[];
lineType: string;
destinations: string[];
} = {
monitorPath: '',
lineIds: [],
lineType: '',
destinations: [],
};
let allOCCLineIds: number[] = [];
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') {
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;
monitorPath = '/monitor';
return monitorPath;
} else {
allOCCLineIds.push(roleConfig[j].lineId);
}
}
}
allOCCLineIds = [...new Set(allOCCLineIds)];
const minId = Math.min(...allOCCLineIds);
configInfo.monitorPath = `/line/monitor/${minId}`;
configInfo.lineIds = allOCCLineIds;
configInfo.lineType = 'OCC';
allOCCLineIds.forEach((lineId) => {
configInfo.destinations.push(`/queue/xian/OCC/${lineId}/alert`);
});
return configInfo;
monitorPath = `/line/monitor/${minId}`;
return monitorPath;
}

View File

@ -14,7 +14,6 @@ export interface AlarmInfo {
alert_time: string;
alert_tip_id: number;
line_id: string;
line_type: string;
alert_object: string;
alert_type: number;
locator_device_id: string;

@ -1 +1 @@
Subproject commit 4f9012b0795f62bf352b078ebbc1b1fffa86849d
Subproject commit c20feed4b6ae3bdd02cb21b4cc5af03c55be869b