From 0ecd9aac7c0c803bfb1b463e8b42eb77d496e5c0 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 8 Nov 2024 10:19:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=85=E9=9A=9C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/faultQuery.ts | 11 ++-- src/pages/FaultQueryManage.vue | 96 ++++++++++++++++++++++++++-------- 2 files changed, 80 insertions(+), 27 deletions(-) diff --git a/src/api/faultQuery.ts b/src/api/faultQuery.ts index 2952f86..8383500 100644 --- a/src/api/faultQuery.ts +++ b/src/api/faultQuery.ts @@ -4,7 +4,7 @@ import { PageDto, PageQueryDto } from './ApiCommon'; const faultQueryUriBase = '/api/fault/query'; export interface FaultQueryListItem { - id: number; + id?: number; lineId: number; faultType: string; faultNameShower: string; @@ -64,13 +64,14 @@ export function faultQueryById( } export interface FaultTypeItem { - faultType: string; - typeName: string; + fts: { faultType: string; typeName: string }[]; + lineId: number; } /** * 获取故障类型 */ -export function faultQueryType() { - return api.get(`${faultQueryUriBase}/type`); +export async function faultQueryType(): Promise> { + const response = await api.get(`${faultQueryUriBase}/type`); + return response.data; } diff --git a/src/pages/FaultQueryManage.vue b/src/pages/FaultQueryManage.vue index a75dc75..2f39853 100644 --- a/src/pages/FaultQueryManage.vue +++ b/src/pages/FaultQueryManage.vue @@ -40,14 +40,17 @@ style="width: 75px" no-error-icon lazy-rules + @update:model-value="handleSelectSearchLineId" :rules="[(val) => val >= 0 || '请选择线路ID!']" /> @@ -157,11 +163,8 @@ import { createFaultQuery, FaultQueryListItem, faultQueryType, + FaultTypeItem, } from '../api/faultQuery'; -import { - showAlertTypeData, - saveAlertTypeData, -} from 'src/components/alarm/alarmInfoEnum'; import { ApiError } from 'src/boot/axios'; import { pageQuery } from 'src/api/LineInfoApi'; @@ -198,7 +201,7 @@ const columnDefs: QTableColumn[] = [ label: '故障类型', field: (row) => { if (row.faultType) { - return (showAlertTypeData as never)[row.faultType + '']; + return getFaultTypeName(row); } }, align: 'center', @@ -240,10 +243,8 @@ const pagination = ref({ }); const filter = ref({ - alertType: '全部', - areaConfigName: '', + faultType: '全部', lineId: 0, - lineType: '全部', }); const onRequest: QTable['onRequest'] = async (props) => { @@ -259,9 +260,9 @@ const onRequest: QTable['onRequest'] = async (props) => { lineId: filter.value.lineId, }); } - if (filter.value.alertType !== '全部') { + if (filter.value.faultType !== '全部') { Object.assign(params, { - alertType: (saveAlertTypeData as never)[filter.value.alertType], + faultType: filter.value.faultType, }); } let response = await faultQueryPageQuery(params); @@ -284,6 +285,7 @@ const onRequest: QTable['onRequest'] = async (props) => { onMounted(() => { queryLineInfo(); + queryAllFaultType(); setTimeout(() => { tableRef.value.requestServerInteraction(); }); @@ -327,13 +329,11 @@ async function queryLineInfo() { } } -let optionsFaultType = ref<{ label: string; value: number }[]>([]); -const searchOptionsFaultType = ['全部', ...optionsFaultType.value]; -async function handleSelectLineId() { +let allOptionsFaultType: FaultTypeItem[] = []; +let optionsFaultType = ref<{ label: string; value: string }[]>([]); +async function queryAllFaultType() { try { - const res = await faultQueryType(); - console.log(res.data, 111); - console.log(typeof res.data, 4444); + allOptionsFaultType = await faultQueryType(); } catch (err) { $q.notify({ type: 'negative', @@ -342,19 +342,71 @@ async function handleSelectLineId() { } } +function getFaultTypeName(row: FaultQueryListItem) { + for (let i = 0; i < allOptionsFaultType.length; i++) { + if (allOptionsFaultType[i].lineId == row.lineId) { + const fts = allOptionsFaultType[i].fts; + for (let j = 0; i < fts.length; j++) { + if (fts[j].faultType == row.faultType) { + return fts[j].typeName; + } + } + } + } +} + +function handleSelectLineId() { + optionsFaultType.value = []; + creatForm.faultType = ''; + for (let i = 0; i < allOptionsFaultType.length; i++) { + if (allOptionsFaultType[i].lineId == +creatForm.lineId) { + allOptionsFaultType[i].fts.forEach((item) => { + optionsFaultType.value.push({ + label: item.typeName, + value: item.faultType, + }); + }); + break; + } + } +} + +const searchOptionsFaultType = ref<{ label: string; value: string }[]>([ + { label: '全部', value: '全部' }, +]); +function handleSelectSearchLineId() { + filter.value.faultType = '全部'; + searchOptionsFaultType.value = [{ label: '全部', value: '' }]; + for (let i = 0; i < allOptionsFaultType.length; i++) { + if (allOptionsFaultType[i].lineId == +filter.value.lineId) { + allOptionsFaultType[i].fts.forEach((item) => { + searchOptionsFaultType.value.push({ + label: item.typeName, + value: item.faultType, + }); + }); + break; + } + } +} + function onCreate() { myForm.value?.validate().then(async (res) => { if (res) { operateDisabled.value = true; try { const params = { - id: +creatForm.id, lineId: +creatForm.lineId, faultType: creatForm.faultType, faultNameShower: creatForm.faultNameShower, faultDriverShower: creatForm.faultDriverShower, resultMsg: creatForm.resultMsg, }; + if (creatForm.id !== '') { + Object.assign(params, { + id: +creatForm.id, + }); + } await createFaultQuery(params); onReset(); createFormShow.value = false; @@ -391,7 +443,7 @@ async function deleteData(row: FaultQueryListItem) { }) .onOk(async () => { try { - await deleteFaultQueryById(row.id); + await deleteFaultQueryById(row.id as number); tableRef.value.requestServerInteraction(); // 刷新列表 } catch (err) { $q.notify({