故障指导与退出服务

This commit is contained in:
joylink_zhaoerwei 2024-11-08 15:06:07 +08:00
parent 50b80fef68
commit a57d89a7f3
3 changed files with 153 additions and 60 deletions

View File

@ -18,7 +18,7 @@ export interface FaultQueryInfo<T = unknown> {
export class PagingQueryParams extends PageQueryDto { export class PagingQueryParams extends PageQueryDto {
lineId?: string; lineId?: string;
faultType?: string; faultType?: string[];
faultName?: string; faultName?: string;
} }

View File

@ -34,44 +34,30 @@
</q-table> </q-table>
</template> </template>
<template v-slot:titleButton> <template v-slot:titleButton>
<div> <q-btn
<q-select square
outlined color="purple"
label="故障类型" style="margin-right: 10px"
v-model="creatForm.alertType" icon="search"
:options="optionsFaultType" @click="reset"
emit-value >
map-options
:rules="[(val) => val.length > 0 || '请选择故障类型!']"
/>
<q-input
outlined
label="消息名称"
type="textarea"
v-model="creatForm.faultNameShower"
lazy-rules
/>
</div>
<q-btn square color="purple" style="margin-right: 10px" icon="search">
<q-popup-edit <q-popup-edit
ref="popupEdit" ref="popupEdit"
v-model="searchAreaName" v-model="noUse"
:cover="false" :cover="false"
:offset="[0, 10]" :offset="[0, 10]"
v-slot="scope"
> >
<q-input <q-select
color="accent"
v-model="scope.value"
label="区域名称"
dense dense
autofocus label="故障类型"
@keyup.enter="scope.set" multiple
> v-model="filter.faultTypes"
<template v-slot:prepend> emit-value
<q-icon name="search" color="accent" /> map-options
</template> :options="searchOptionsFaultType"
</q-input> @update:model-value="searchTable"
style="min-width: 130px"
/>
</q-popup-edit> </q-popup-edit>
</q-btn> </q-btn>
</template> </template>
@ -79,12 +65,16 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { IAreaConfigListItem, getDeviceAreaList } from 'src/api/ConfigApi'; import { reactive, ref } from 'vue';
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import DraggableDialog from '../common/DraggableDialog.vue'; import DraggableDialog from '../common/DraggableDialog.vue';
import { QTable, useQuasar } from 'quasar'; import { QTable, useQuasar } from 'quasar';
import { deviceTypeMap } from 'src/api/TrainApi'; import {
FaultQueryListItem,
faultQueryPageQuery,
faultQueryType,
FaultTypeItem,
} from 'src/api/faultQuery';
const props = defineProps<{ const props = defineProps<{
dialogTitle: string; dialogTitle: string;
@ -92,25 +82,57 @@ const props = defineProps<{
const $q = useQuasar(); const $q = useQuasar();
const lineId = useRoute().params.lineId as string; const lineId = useRoute().params.lineId as string;
let faultName = ref('');
const tableRef = ref<QTable>(); const tableRef = ref<QTable>();
const columns: QTable['columns'] = [ const columns: QTable['columns'] = [
{ name: 'id', label: 'ID', field: 'id', align: 'center' },
{ name: 'lineId', label: '线路ID', field: 'lineId', align: 'center' },
{ {
name: 'areaName', name: 'id',
label: '名称', label: '编号',
field: 'areaName', field: 'id',
required: true,
align: 'center', align: 'center',
}, },
{ {
name: 'deviceType', name: 'lineId',
label: '设备类型', label: '线路',
field: (row) => deviceTypeMap[row.deviceType as keyof typeof deviceTypeMap], field: 'lineId',
required: true,
align: 'center',
},
{
name: 'faultType',
label: '故障类型',
field: (row) => {
if (row.faultType) {
return getFaultTypeName(row);
}
},
align: 'center',
},
{
name: 'faultNameShower',
label: '消息名称',
field: 'faultNameShower',
required: true,
align: 'center',
},
{
name: 'faultDriverShower',
label: '司机处理结果',
field: 'faultDriverShower',
required: true,
align: 'center',
},
{
name: 'resultMsg',
label: '司机关键点',
field: 'resultMsg',
required: true,
align: 'center', align: 'center',
}, },
]; ];
const rows = ref<IAreaConfigListItem[]>([]); const rows = reactive([]);
const loading = ref(false); const loading = ref(false);
const pagination = ref({ const pagination = ref({
sortBy: 'desc', sortBy: 'desc',
@ -120,28 +142,30 @@ const pagination = ref({
rowsNumber: 10, rowsNumber: 10,
}); });
const searchAreaName = ref(''); const filter = reactive({
watch( faultTypes: [],
() => searchAreaName.value, });
() => {
tableRef.value?.requestServerInteraction();
}
);
const onRequest: QTable['onRequest'] = async (props) => { const onRequest: QTable['onRequest'] = async (props) => {
const { page, rowsPerPage } = props.pagination; const { page, rowsPerPage } = props.pagination;
loading.value = true; loading.value = true;
try { try {
const resp = await getDeviceAreaList({ const params = {
lineId,
current: page, current: page,
size: rowsPerPage, size: rowsPerPage,
areaName: searchAreaName.value, lineId,
}); faultName: faultName.value,
};
if (filter.faultTypes.length) {
Object.assign(params, {
faultType: filter.faultTypes,
});
}
let resp = await faultQueryPageQuery(params);
pagination.value.page = resp.current; pagination.value.page = resp.current;
pagination.value.rowsNumber = resp.total; pagination.value.rowsNumber = resp.total;
pagination.value.rowsPerPage = resp.size; pagination.value.rowsPerPage = resp.size;
rows.value = resp.records; rows.splice(0, rows.length, ...(resp.records as []));
} catch (err) { } catch (err) {
$q.notify({ $q.notify({
type: 'negative', type: 'negative',
@ -152,7 +176,70 @@ const onRequest: QTable['onRequest'] = async (props) => {
} }
}; };
async function queryAllFaultType() {
try {
allOptionsFaultType = await faultQueryType();
handleSelectFaultType();
} catch (err) {
$q.notify({
type: 'negative',
message: '无法获取指定线路的故障类型配置',
});
}
}
let allOptionsFaultType: FaultTypeItem[] = [];
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;
}
}
}
}
}
const searchOptionsFaultType = ref([{ label: '全部', value: '' }]);
function handleSelectFaultType() {
for (let i = 0; i < allOptionsFaultType.length; i++) {
if (allOptionsFaultType[i].lineId == +lineId) {
allOptionsFaultType[i].fts.forEach((item) => {
if (
(props.dialogTitle == '故障指导' &&
item.faultType.includes('FAULT_EMERGENCY_GUIDE')) ||
(props.dialogTitle == '退出服务' &&
item.faultType.includes('FAULT_EXIT_SERVICE'))
) {
searchOptionsFaultType.value.push({
label: item.typeName,
value: item.faultType,
});
}
});
break;
}
}
}
function searchTable() {
tableRef.value?.requestServerInteraction();
}
const noUse = ref('');
function reset() {
filter.faultTypes = [];
}
const onDialogShow = () => { const onDialogShow = () => {
if (props.dialogTitle == '故障指导') {
faultName.value = '指导关键点';
} else {
faultName.value = '退出服务';
}
queryAllFaultType();
tableRef.value?.requestServerInteraction(); tableRef.value?.requestServerInteraction();
}; };
</script> </script>
@ -171,4 +258,9 @@ const onDialogShow = () => {
white-space: pre-wrap; white-space: pre-wrap;
font-size: 14px; font-size: 14px;
} }
.button-container {
display: flex;
justify-content: center;
margin-top: 10px;
}
</style> </style>

View File

@ -45,6 +45,7 @@
/> />
<q-select <q-select
dense dense
multiple
label="故障类型" label="故障类型"
v-model="filter.faultType" v-model="filter.faultType"
emit-value emit-value
@ -243,7 +244,7 @@ const pagination = ref({
}); });
const filter = ref({ const filter = ref({
faultType: '', faultType: [],
lineId: 0, lineId: 0,
}); });
@ -260,7 +261,7 @@ const onRequest: QTable['onRequest'] = async (props) => {
lineId: filter.value.lineId, lineId: filter.value.lineId,
}); });
} }
if (filter.value.faultType !== '') { if (filter.value.faultType.length) {
Object.assign(params, { Object.assign(params, {
faultType: filter.value.faultType, faultType: filter.value.faultType,
}); });
@ -376,7 +377,7 @@ const searchOptionsFaultType = ref<{ label: string; value: string }[]>([
{ label: '全部', value: '' }, { label: '全部', value: '' },
]); ]);
function handleSelectSearchLineId() { function handleSelectSearchLineId() {
filter.value.faultType = ''; filter.value.faultType = [];
searchOptionsFaultType.value = [{ label: '全部', value: '' }]; searchOptionsFaultType.value = [{ label: '全部', value: '' }];
if (filter.value.lineId == 0) { if (filter.value.lineId == 0) {
handleSelectAllFaultType(); handleSelectAllFaultType();