diff --git a/src/api/faultManage/actAlarm.ts b/src/api/faultManage/actAlarm.ts index 6eb1a9a4..7e4cd61e 100644 --- a/src/api/faultManage/actAlarm.ts +++ b/src/api/faultManage/actAlarm.ts @@ -1,42 +1,38 @@ import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { request } from '@/plugins/http-fetch'; +import { toRaw } from 'vue'; import { parseObjLineToHump } from '@/utils/parse-utils'; import { parseDateToStr } from '@/utils/date-utils'; import useUserStore from '@/store/modules/user'; +import { ConsoleSqlOutlined } from '@ant-design/icons-vue'; /** * 查询列表 * @param query 查询参数 * @returns object */ -export async function listAct(query: Record) { - let filterData = ''; - let totalSQL = `select count(*) as total from alarm where alarm_status='1' ${filterData} `; - let rowsSQL = `select * from alarm where alarm_status='1' ${filterData}`; - +export async function listAct(query: Record,filterSQl:string) { + let totalSQL = `select count(*) as total from alarm where alarm_status='1' ${filterSQl} `; + let rowsSQL = `select * from alarm where alarm_status='1' ${filterSQl}`; // 查询 let querySQL = ''; - if (query.alarm_code) { - querySQL += ` and alarm_code = '${query.alarm_code}' `; - } - if (query.alarm_type) { - querySQL += ` and alarm_type = '${query.alarm_type}' `; - } - if (query.pv_flag) { - querySQL += ` and pv_flag = '${query.pv_flag}' `; - } - if (query.orig_severity) { - querySQL += ` and orig_severity in (${query.orig_severity} )`; - } - if (query.ne_id) { - querySQL += ` and ne_id like '%${query.ne_id}%' `; - } - if (query.ne_name) { - querySQL += ` and ne_name like '%${query.ne_name}%' `; - } - if (query.ne_type) { - querySQL += ` and ne_type like '%${query.ne_type}%' `; - } + querySQL += query.alarm_code + ? ` and alarm_code = '${query.alarm_code}' ` + : ''; + querySQL += query.alarm_type + ? ` and alarm_type = '${query.alarm_type}' ` + : ''; + querySQL += query.pv_flag ? ` and pv_flag = '${query.pv_flag}' ` : ''; + querySQL += query.orig_severity + ? ` and orig_severity in('${query.orig_severity}' )` + : ''; + querySQL += query.ne_id ? ` and ne_id like '%${query.ne_id}%' ` : ''; + querySQL += query.ne_name ? ` and ne_name like '%${query.ne_name}%' ` : ''; + querySQL += query.ne_type ? ` and ne_type like '%${query.ne_type}%' ` : ''; + querySQL += + query.beginTime && query.endTime + ? ` and event_time BETWEEN '${query.beginTime}' and ' ${query.endTime}'` + : ''; // 分页 const pageNum = (query.pageNum - 1) * query.pageSize; @@ -123,6 +119,78 @@ export function cancelConfirm(data: (string | number)[]) { }); } +/** + * 设置告警显示过滤 + * @param data 鉴权对象 + * @returns object + */ +export function showPass(data: Record) { + let querySQL = ''; + querySQL += data.alarm_code ? ` and alarm_code != ${data.alarm_code} ` : ''; + querySQL += data.alarm_type + ? ` and alarm_type !=\\' ${data.alarm_type} \\'` + : ''; + querySQL += data.pv_flag ? ` and pv_flag !=\\'${data.pv_flag} \\'` : ''; + querySQL += data.orig_severity + ? ` and orig_severity !=\\'${data.orig_severity}\\'` + : ''; + querySQL += data.ne_id ? ` and ne_id !=\\'${data.ne_id}\\' ` : ''; + querySQL += data.ne_type ? ` and ne_type !=\\'${data.ne_type}\\' ` : ''; + + let toBackJson = { + data: { + value: querySQL, + value_json: JSON.stringify(data), + }, + }; + + return request({ + url: `/databaseManagement/v1/omc_db/config?WHERE=config_tag='displayFilter'`, + method: 'put', + data: toBackJson, + }); +} +/** + * 获取告警显示过滤条件 + * @param data 鉴权对象 + * @returns object + */ +export function getPass() { + return request({ + url: `/databaseManagement/v1/select/omc_db/config`, + method: 'get', + params: { + SQL: "SELECT value_json,value FROM config WHERE config_tag ='displayFilter'", + }, + }); +} + +/** + * 清除告警信息 + * @param data 鉴权对象 + * @returns object + */ +export function clearAlarm(data: Record) { + var time = new Date(); + const userName = useUserStore().userName; + let finalData = { + data: { + clear_time: parseDateToStr(time), + clear_type: '2', + alarm_status: '0', + clear_user: userName, + }, + }; + + return request({ + url: `/databaseManagement/v1/update/omc_db/alarm?WHERE=id in(${data.join( + ',' + )})`, + method: 'put', + data: finalData, + }); +} + /** * 手工同步 * @param data 鉴权对象 @@ -130,7 +198,7 @@ export function cancelConfirm(data: (string | number)[]) { */ export function listSync() { return request({ - url: `/faultManagement/v1/elementType/all/objectType/alarms)`, + url: `/faultManagement/v1/elementType/all/objectType/alarms`, method: 'get', }); } diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 0ba26a19..8c03cb8e 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -135,8 +135,9 @@ const useUserStore = defineStore('user', { // this.profile = JSON.parse(user.profile); try { this.profile = JSON.parse(user.profile); + } catch (error) { - console.log(error); + console.error(error); this.profile = { critical: '#FF5722', major: '#FFB800', diff --git a/src/utils/execl-utils.ts b/src/utils/execl-utils.ts index 009f02b3..2ae12b3c 100644 --- a/src/utils/execl-utils.ts +++ b/src/utils/execl-utils.ts @@ -21,7 +21,6 @@ export const xlsxUrl = `${ */ export async function readLoalXlsx(id: string): Promise[]> { let fileBolb = await (await fetch(`${xlsxUrl}/${id}.xlsx`)).arrayBuffer(); - console.log(fileBolb.byteLength) if(!fileBolb.byteLength){ fileBolb = await (await fetch(`${xlsxUrl}/all.xlsx`)).arrayBuffer(); } diff --git a/src/views/faultManage/active-alarm/index.vue b/src/views/faultManage/active-alarm/index.vue index 99a98e74..c913460e 100644 --- a/src/views/faultManage/active-alarm/index.vue +++ b/src/views/faultManage/active-alarm/index.vue @@ -13,6 +13,9 @@ import { updateConfirm, cancelConfirm, listSync, + clearAlarm, + showPass, + getPass, } from '@/api/faultManage/actAlarm'; import useNeInfoStore from '@/store/modules/neinfo'; import useI18n from '@/hooks/useI18n'; @@ -20,10 +23,13 @@ import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { readLoalXlsx } from '@/utils/execl-utils'; const { t } = useI18n(); const route = useRoute(); - +type RangeValue = [Dayjs, Dayjs]; /**路由标题 */ let title = ref((route.meta.title as string) ?? '标题'); +/**记录开始结束时间 */ +let queryRangePicker = ref<[string, string]>(['', '']); + /**查询参数 */ let queryParams = reactive({ /**告警设备类型 */ @@ -35,9 +41,11 @@ let queryParams = reactive({ /**告警编号 */ alarm_code: '', /**告警级别 */ - orig_severity: "'Critical','Major','Minor','Warning','Event'", + orig_severity: '', + beginTime: '', + endTime: '', /**告警产生时间 */ - eventTime: '', + eventTime: (queryRangePicker.value = ['', '']), /**虚拟化标识 */ pv_flag: '', /**告警类型 */ @@ -51,10 +59,23 @@ let queryParams = reactive({ /**查询参数重置 */ function fnQueryReset() { queryParams = Object.assign(queryParams, { - imsi: '', - msisdn: '', - pageNum: 1, - pageSize: 20, + /**告警设备类型 */ + ne_type: '', + /**告警网元名称 */ + ne_name: '', + /**告警网元标识 */ + ne_id: '', + /**告警编号 */ + alarm_code: '', + /**告警级别 */ + orig_severity: '', + /**告警产生时间 */ + eventTime: (queryRangePicker.value = ['', '']), + /**虚拟化标识 */ + pv_flag: '', + /**告警类型 */ + alarm_type: '', + /**当前页数 */ }); tablePagination.current = 1; tablePagination.pageSize = 20; @@ -84,6 +105,12 @@ let tableState: TabeStateType = reactive({ selectedRowKeys: [], }); +/**过滤设置 */ +let filterState: any = reactive({ + data: {}, + sql: '', +}); + /**帮助文档表格状态 */ let alarmTableState: TabeStateType = reactive({ loading: false, @@ -117,21 +144,8 @@ let tableColumns: ColumnsType = [ }, { title: t('views.faultManage.activeAlarm.origLevel'), - dataIndex: 'origSeverity', align: 'center', - customRender(opt) { - let levelName: any = { - Critical: '严重告警', - Major: '主要告警', - Minor: '次要告警', - Warning: '警告告警', - Event: '事件告警', - }; - if (levelName[opt.value]) { - return levelName[opt.value]; - } - return opt.value; - }, + key:'origSeverity', }, { title: t('views.faultManage.activeAlarm.alarmCode'), @@ -214,7 +228,6 @@ let alarmTableColumns: ColumnsType = [ title: t('views.faultManage.activeAlarm.addInfo'), dataIndex: '告警帮助信息', align: 'center', - }, { title: t('views.faultManage.activeAlarm.alarmType'), @@ -304,41 +317,46 @@ function fnTableSize({ key }: MenuInfo) { /**表格所需option */ const actAlarmOption = reactive({ pvFlag: [ - { label: 'PNF', value: "'PNF'" }, - { label: 'VNF', value: "'VNF'" }, + { label: 'PNF', value: 'PNF' }, + { label: 'VNF', value: 'VNF' }, ], alarmType: [ { label: t('views.faultManage.activeAlarm.communicationAlarm'), - value: "'CommunicationAlarm'", + value: 'CommunicationAlarm', }, { label: t('views.faultManage.activeAlarm.equipmentAlarm'), - value: "'EquipmentAlarm'", + value: 'EquipmentAlarm', }, { label: t('views.faultManage.activeAlarm.processingFailure'), - value: "'ProcessingFailure'", + value: 'ProcessingFailure', }, { label: t('views.faultManage.activeAlarm.environmentalAlarm'), - value: "'EnvironmentalAlarm'", + value: 'EnvironmentalAlarm', }, { label: t('views.faultManage.activeAlarm.qualityOfServiceAlarm'), - value: "'QualityOfServiceAlarm'", + value: 'QualityOfServiceAlarm', }, ], origSeverity: [ - { - label: t('views.faultManage.activeAlarm.all'), - value: "'Critical','Major','Minor','Warning','Event'", - }, - { label: t('views.faultManage.activeAlarm.critical'), value: "'Critical'" }, - { label: t('views.faultManage.activeAlarm.major'), value: "'Major'" }, - { label: t('views.faultManage.activeAlarm.minor'), value: "'Minor'" }, - { label: t('views.faultManage.activeAlarm.warning'), value: "'Warning'" }, - { label: t('views.faultManage.activeAlarm.eventAlarm'), value: "'Event'" }, + { label: t('views.faultManage.activeAlarm.critical'), value: 'Critical' }, + { label: t('views.faultManage.activeAlarm.major'), value: 'Major' }, + { label: t('views.faultManage.activeAlarm.minor'), value: 'Minor' }, + { label: t('views.faultManage.activeAlarm.warning'), value: 'Warning' }, + { label: t('views.faultManage.activeAlarm.eventAlarm'), value: 'Event' }, + ], + clearType: [ + { label: '告警未清除', value: 0 }, + { label: '自动清除', value: 1 }, + { label: '手动清除', value: 2 }, + ], + ackState: [ + { label: '未确认', value: 0 }, + { label: '已确认', value: 1 }, ], }); @@ -348,10 +366,14 @@ type ModalStateType = { visibleByView: boolean; /**新增框或修改框是否显示 */ visibleByEdit: boolean; + /**显示过滤设置是否显示 */ + visibleByShowSet: boolean; /**标题 */ title: string; /**表单数据 */ from: Record; + /**表单数据 */ + showSetFrom: Record; /**确定按钮 loading */ confirmLoading: boolean; }; @@ -360,6 +382,7 @@ type ModalStateType = { let modalState: ModalStateType = reactive({ visibleByView: false, visibleByEdit: false, + visibleByShowSet: false, title: '全部信息', from: { alarmId: '', @@ -386,6 +409,14 @@ let modalState: ModalStateType = reactive({ ackTime: '', origSeverity: '', }, + showSetFrom: { + ne_type: '', + ne_id: '', + alarm_type: '', + orig_severity: '', + alarm_code: '', + pv_flag: '', + }, confirmLoading: false, }); @@ -399,18 +430,18 @@ function fnModalVisibleByVive(row: Record) { modalState.visibleByView = true; } -/**抽屉 网元详细信息 */ +/**告警帮助文档抽屉 初始设置 */ const visible = ref(false); const closeDrawer = () => { visible.value = false; }; + /**抽屉 告警帮助文档详细信息 */ function fnModalVisibleBy(code: string) { const result = readLoalXlsx(code); result .then(res => { - console.log(res); if (!res.length) { visible.value = false; } @@ -460,6 +491,35 @@ function fnModalOk() { }); } +/** + * 对话框弹出确认执行 设置显示过滤 + */ +function fnShowModalOk() { + modalState.confirmLoading = true; + const from = toRaw(modalState.showSetFrom); + const result = showPass(from); + const hide = message.loading({ content: t('common.loading') }); + result + .then(res => { + if (res.code === RESULT_CODE_SUCCESS) { + message.success({ + content: t('common.msgSuccess', { msg: modalState.title }), + duration: 3, + }); + modalState.visibleByShowSet = false; + fnGetList(); + } else { + message.error({ + content: `${res.msg}`, + duration: 3, + }); + } + }) + .finally(() => { + hide(); + modalState.confirmLoading = false; + }); +} /**表格状态 */ const state = reactive<{ selectedRowKeys: (string | number)[]; @@ -520,8 +580,7 @@ function fnSync() { content: `手工同步成功`, duration: 2, }); - console.log(toRaw(res)); - return false; + tablePagination.total = res.total; tableState.data = res.rows; } else { @@ -533,6 +592,56 @@ function fnSync() { }); } +/** + * 清除 + */ +function fnClear() { + Modal.confirm({ + title: 'Tip', + content: `是否清除该告警?`, + onOk() { + const hide = message.loading('请稍等...', 0); + clearAlarm(state.selectedRowKeys).then(res => { + hide(); + if (res.code === RESULT_CODE_SUCCESS) { + message.success({ + content: `清除成功`, + duration: 2, + }); + fnGetList(); + } else { + message.error({ + content: `${res.msg}`, + duration: 2, + }); + } + }); + }, + }); +} + +/** + * 显示过滤 + */ +function fnShowSet() { + if (modalState.confirmLoading) return; + const hide = message.loading('正在打开...', 0); + modalState.confirmLoading = true; + getPass().then(res => { + modalState.confirmLoading = false; + hide(); + if (res.code === RESULT_CODE_SUCCESS) { + let realJson = res.data.data[0]['config'][0].value_json + ? JSON.parse(res.data.data[0]['config'][0].value_json) + : {}; + modalState.showSetFrom = Object.assign(modalState.showSetFrom, realJson); + modalState.title = '显示过滤设置'; + modalState.visibleByShowSet = true; + } else { + message.error(`获取显示过滤设置失败`, 2); + } + }); +} /** * 对话框弹出关闭执行函数 * 进行表达规则校验 @@ -540,30 +649,43 @@ function fnSync() { function fnModalCancel() { modalState.visibleByEdit = false; modalState.visibleByView = false; + modalState.visibleByShowSet = false; } /**查询列表 */ function fnGetList() { if (tableState.loading) return; tableState.loading = true; - listAct(toRaw(queryParams)).then(res => { - if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) { - // 取消勾选 - if (state.selectedRowKeys.length > 0) { - state.selectedRowKeys = []; - } - tablePagination.total = res.total; - tableState.data = res.rows; - } else { - tablePagination.total = 0; - tableState.data = []; + if (!queryRangePicker.value) { + queryRangePicker.value = ['', '']; + } + queryParams.beginTime = queryRangePicker.value[0]; + queryParams.endTime = queryRangePicker.value[1]; + getPass().then(res => { + if (res.code === RESULT_CODE_SUCCESS) { + let sql = res.data.data[0]['config'][0].value + ? res.data.data[0]['config'][0].value + : ''; + filterState.sql = sql; } - tableState.loading = false; + listAct(toRaw(queryParams), filterState.sql).then(res => { + if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) { + // 取消勾选 + if (state.selectedRowKeys.length > 0) { + state.selectedRowKeys = []; + } + tablePagination.total = res.total; + tableState.data = res.rows; + } else { + tablePagination.total = 0; + tableState.data = []; + } + tableState.loading = false; + }); }); } const profile = useUserStore().profile; - onMounted(() => { fnGetList(); }); @@ -660,6 +782,7 @@ onMounted(() => { v-model:value="queryParams.orig_severity" placeholder="Select alarm Type" show-search + allow-clear :options="actAlarmOption.origSeverity" /> @@ -669,7 +792,13 @@ onMounted(() => { :label="t('views.faultManage.activeAlarm.eventTime')" name="eventTime" > - + @@ -728,6 +857,23 @@ onMounted(() => { {{ t('views.faultManage.activeAlarm.syncMyself') }} + + + + {{ t('views.faultManage.activeAlarm.clear') }} + + + + + {{ t('views.faultManage.activeAlarm.disPlayFilfter') }} + @@ -783,42 +929,6 @@ onMounted(() => { :height="700" placement="bottom" > - { :data-source="alarmTableState.data" :size="alarmTableState.size" :pagination="false" - :scroll="{ x: true , y: 450 }" + :scroll="{ x: true, y: 450 }" > @@ -849,6 +959,9 @@ onMounted(() => { :scroll="{ x: true }" >