Merge remote-tracking branch 'origin/develop' into local-test
local-test分支构建发布 / Docker-Build (push) Successful in 1m55s Details

# Conflicts:
#	src/components/SysMenu.vue
#	src/layouts/MainLayout.vue
#	src/pages/RoleManage.vue
#	src/pages/UserLogin.vue
#	src/router/routes.ts
This commit is contained in:
joylink_fanyuhong 2024-10-23 15:23:23 +08:00
commit 40d57a3fc8
15 changed files with 204 additions and 148 deletions

View File

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

View File

@ -25,6 +25,7 @@ export interface RoleInfo {
id: number;
name: string;
resList: number[];
roleConfigStr: string;
}
/**
@ -77,6 +78,19 @@ 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),
path: getMonitorPath(userStore.roles).monitorPath,
label: '监控',
icon: 'computer',
},

View File

@ -49,11 +49,22 @@
/>
<q-card-actions align="left">
<div class="q-gutter-md">
<q-btn color="primary" label="确认" type="submit" />
<q-btn color="red" label="误报" @click="falseAlarm" />
<q-btn
color="primary"
label="确认"
:disable="operateDisabled"
type="submit"
/>
<q-btn
color="red"
label="误报"
:disable="operateDisabled"
@click="falseAlarm"
/>
<q-btn
color="primary"
label="人工接警"
:disable="operateDisabled"
@click="manualAlarm"
/>
</div>
@ -88,7 +99,7 @@
<script setup lang="ts">
import DraggableDialog from '../common/DraggableDialog.vue';
import { useLineNetStore, AlarmInfo } from 'src/stores/line-net-store';
import { onMounted, ref } from 'vue';
import { computed, onMounted, ref } from 'vue';
import { QForm, useQuasar } from 'quasar';
import { saveAlertTypeData, showAlertTypeData } from './alarmInfoEnum';
import {
@ -97,6 +108,8 @@ 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;
@ -124,6 +137,7 @@ const alarmInfo = ref({
level: '',
time: '',
lineId: '',
lineType: '',
alertObject: '',
alertType: '',
locator_device_id: '',
@ -203,6 +217,7 @@ 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() {
@ -237,6 +252,15 @@ 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,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 []);
},
});
});
}

View File

@ -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 []);
},
});
});
}

View File

@ -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;
});

View File

@ -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;
@ -271,6 +274,13 @@ const columnDefs: QTableColumn[] = [
field: 'lineId',
align: 'center',
},
{
name: 'lineType',
label: '线路类型',
field: 'lineType',
required: true,
align: 'center',
},
{
name: 'alertObject',
label: '设备',
@ -369,10 +379,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);
});
});
});
@ -386,8 +399,12 @@ watch(
);
function updateSelect() {
const config = getMonitorPath(userStore.roles);
for (let i = 0; i < selected.value.length; i++) {
if (selected.value[i].alarmStatus !== -1) {
const canSelect =
config.lineType == selected.value[i].lineType &&
config.lineIds.includes(+selected.value[i].lineId);
if (selected.value[i].alarmStatus !== -1 || !canSelect) {
selected.value.splice(i, 1);
i--;
}
@ -532,6 +549,7 @@ 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;
@ -552,14 +570,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);
});
});
//

View File

@ -15,35 +15,21 @@
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" />
<q-btn color="primary" label="新建" @click="editFormShow = true" />
</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
: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
@ -52,37 +38,31 @@
transition-show="scale"
transition-hide="scale"
>
<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-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-actions align="right">
<q-btn color="primary" label="保存" type="submit" />
<q-btn label="取消" type="reset" v-close-popup />
</q-card-actions>
</q-card-section>
</q-form>
</q-form>
</q-card-section>
</q-card>
</q-dialog>
</div>
@ -91,18 +71,10 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue';
import { useQuasar, type QTableColumn, QForm } from 'quasar';
import {
PathItem,
RoleInfo,
createRole,
createRoleParams,
deleteRole,
pageQueryRole,
saveRoleData,
} from 'src/api/AuthApi';
import { pageQueryRole, roleConfig, RoleInfo } from 'src/api/AuthApi';
import { ApiError } from 'src/boot/axios';
import { successNotify } from 'src/utils/CommonNotify';
import AuthPathManage from './AuthPathManage.vue';
import { useUserStore } from 'src/stores/user-store';
const $q = useQuasar();
const props = withDefaults(
@ -114,8 +86,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();
});
@ -130,8 +111,6 @@ const columnDefs: QTableColumn[] = [
},
];
const operateDisabled = ref(false);
const tableRef = ref();
const rows = reactive([]);
const filter = reactive({
@ -176,53 +155,37 @@ 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;
const list = row.resList || [];
roleInfo.resList = list;
roleInfo.editPaths = list.map((item) => {
return { id: item };
});
roleInfo.roleConfigStr=row.roleConfigStr
editFormShow.value = true;
}
const operateDisabled = ref(false);
const myForm = ref<QForm | null>(null);
//
async function edieRolePath() {
const editFormShow = ref(false);
function roleConfigFn() {
myForm.value?.validate().then(async (res) => {
if (res) {
operateDisabled.value = true;
try {
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(); //
await roleConfig(+roleInfo.id, roleInfo.roleConfigStr);
editFormShow.value = false;
successNotify('保存成功!');
successNotify('修改成功');
} catch (err) {
const error = err as ApiError;
$q.notify({
@ -236,39 +199,10 @@ async function edieRolePath() {
});
}
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.editPaths = [];
roleInfo.resList = [];
roleInfo.roleConfigStr = '';
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));
router.replace(getMonitorPath(userInfo.roles).monitorPath);
} catch (err) {
visible.value = false;
const apiErr = err as ApiError;

View File

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

View File

@ -87,6 +87,7 @@ 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);
@ -121,6 +122,9 @@ 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() {
@ -183,6 +187,12 @@ 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;
@ -194,6 +204,7 @@ 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) {
@ -226,6 +237,9 @@ 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() {
@ -240,6 +254,7 @@ export namespace alert {
locator_device_id?: string;
alert_location_id?: number;
mock?: boolean;
line_type?: string;
} = {};
if (this.id != null) {
data.id = this.id;
@ -271,6 +286,9 @@ 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;
@ -297,6 +315,8 @@ 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();
}
@ -336,6 +356,9 @@ export namespace alert {
case 10:
message.mock = reader.readBool();
break;
case 11:
message.line_type = reader.readString();
break;
default: reader.skipField();
}
}

View File

@ -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;
}

View File

@ -14,6 +14,7 @@ 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 c20feed4b6ae3bdd02cb21b4cc5af03c55be869b
Subproject commit 4f9012b0795f62bf352b078ebbc1b1fffa86849d