增加故障查询
This commit is contained in:
parent
fbb08bb9e3
commit
0ecd9aac7c
@ -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<Array<FaultTypeItem>> {
|
||||
const response = await api.get(`${faultQueryUriBase}/type`);
|
||||
return response.data;
|
||||
}
|
||||
|
@ -40,14 +40,17 @@
|
||||
style="width: 75px"
|
||||
no-error-icon
|
||||
lazy-rules
|
||||
@update:model-value="handleSelectSearchLineId"
|
||||
:rules="[(val) => val >= 0 || '请选择线路ID!']"
|
||||
/>
|
||||
<q-select
|
||||
dense
|
||||
label="故障类型"
|
||||
v-model="filter.alertType"
|
||||
v-model="filter.faultType"
|
||||
emit-value
|
||||
map-options
|
||||
:options="searchOptionsFaultType"
|
||||
style="width: 130px"
|
||||
style="min-width: 130px"
|
||||
/>
|
||||
<q-btn color="primary" label="查询" type="submit" />
|
||||
<q-btn
|
||||
@ -104,13 +107,13 @@
|
||||
emit-value
|
||||
map-options
|
||||
lazy-rules
|
||||
@update:model-value="handleSelectLineId"
|
||||
:rules="[(val) => val > 0 || '请选择线路ID!']"
|
||||
@blur="handleSelectLineId"
|
||||
/>
|
||||
<q-select
|
||||
outlined
|
||||
label="故障类型"
|
||||
v-model="creatForm.alertType"
|
||||
v-model="creatForm.faultType"
|
||||
:options="optionsFaultType"
|
||||
emit-value
|
||||
map-options
|
||||
@ -121,6 +124,7 @@
|
||||
label="消息名称"
|
||||
v-model="creatForm.faultNameShower"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入消息名称!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
@ -128,6 +132,7 @@
|
||||
label="司机处理结果"
|
||||
v-model="creatForm.faultDriverShower"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入司机处理结果!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
@ -135,6 +140,7 @@
|
||||
label="司机关键点"
|
||||
v-model="creatForm.resultMsg"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入司机关键点!']"
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user