Browse Source

事件修改

wangqin
zhoule 7 months ago
parent
commit
53df2ff9f2
  1. 219
      ruoyi-ui/src/views/JiHeExpressway/pages/control/event/commandDispatch/Cards/EventInformation/components/EditEventInformationDialog/index.vue

219
ruoyi-ui/src/views/JiHeExpressway/pages/control/event/commandDispatch/Cards/EventInformation/components/EditEventInformationDialog/index.vue

@ -1,10 +1,10 @@
<template>
<Dialog v-model="modelVisible" title="修改事件信息" width="1100px" top="10%">
<div class="EditEventInformationDialog">
<Form class="form" :formList="formConfigList" v-model="fData" labelWidth="120px" />
<Form class="form" ref="FormConfigRef" :formList="formConfigList" v-model="fData" labelWidth="120px" />
<div class="footer">
<Button @click.native="onSubmit">保存</Button>
<Button @click.native="onSubmit" :loading="submitting">保存</Button>
<Button style="background: #c9c9c9" @click.native="modelVisible = false">关闭</Button>
</div>
</div>
@ -17,6 +17,7 @@ import Form from "@screen/components/FormConfig";
import Button from "@screen/components/Buttons/Button.vue";
import request from "@/utils/request";
import { tabConfigList } from "./data.js";
import { Message } from "element-ui";
const eventInfo = {
id: "60f022d95a7c4b6cada2d780246543d8",
@ -132,9 +133,10 @@ export default {
},
data() {
return {
formConfigList: {},
// tabConfigList,
formConfigList: [],
submitting: false,
fData: {},
resultEventData: {},
eventId: '1a91d65cc31f4a9d90122888edb31043',
roads: [],
direction: [],
@ -159,78 +161,161 @@ export default {
},
methods: {
initData() {
let configList = tabConfigList.find(item => item.label == '交通事故')
this.formConfigList = configList.formConfig.list
let info = eventInfo;
if (info.stakeMark instanceof Array) {
async initData() {
let infoData = await request({
url: `/dc/system/event/eventSubclass/1/60f022d95a7c4b6cada2d780246543d8`,//
method: "get",
})
if (infoData.code != 200) return Message.error(infoData?.msg);
this.resultEventData = { ...infoData.data };
let info = infoData.data;
if (typeof info.stakeMark == 'string') {
let numbers = info.stakeMark.match(/\d+/g).map(Number);
// console.log('numbers', numbers);
info.stakeMark = numbers;
}
this.fData = info;
let configList = tabConfigList.find(item => item.label == this.fData.eventName)
this.formConfigList = configList.formConfig.list
this.fData = info;
// Promise.all([
// //
// request({
// url: `/business/road/query`,
// method: "get",
// })
// .then((result) => {
// if (result.code != 200) return Message.error(result?.msg);
// result.data.forEach((it) => {
// this.roads.push({ key: it.id, label: it.roadName });
// });
// })
// .catch((err) => {
// Message.error("4", err);
// }),
// //
// request({
// url: `/system/dict/data/type/iot_event_direction`,
// method: "get",
// })
// .then((result) => {
// if (result.code != 200) return Message.error(result?.msg);
// result.data.forEach((it) => {
// this.direction.push({ key: it.dictValue, label: it.dictLabel });
// });
// })
// .catch((err) => {
// Message.error("5", err);
// }),
// // 1 2 3 4 5 6
// request({
// url: `/business/facility/query`,
// method: "get",
// })
// .then((result) => {
// if (result.code != 200) return Message.error(result?.msg);
// result.data.forEach((it) =>
// this.lwss.push({
// key: it.id,
// label: it.facilityName,
// type: it.facilityType,
// })
// );
// })
// .catch((err) => {
// console.log("err", err);
// Message.error("6", err);
// }),
// ]);
// request({
// url: `/dc/system/event/eventSubclass/1/60f022d95a7c4b6cada2d780246543d8`,//
// method: "get",
// }).then(async (result) => {
// if (result.code != 200) return Message.error(result?.msg);
// // this.formData = result.data;
// })
await Promise.all([
//
request({
url: `/business/road/query`,
method: "get",
})
.then((result) => {
if (result.code != 200) return Message.error(result?.msg);
this.roads = [];
result.data.forEach((it) => {
this.roads.push({ key: it.id, label: it.roadName });
});
})
.catch((err) => {
Message.error("查询失败4", err);
}),
//
request({
url: `/system/dict/data/type/iot_event_direction`,
method: "get",
})
.then((result) => {
if (result.code != 200) return Message.error(result?.msg);
this.direction = []
result.data.forEach((it) => {
this.direction.push({ key: it.dictValue, label: it.dictLabel });
});
})
.catch((err) => {
Message.error("查询失败5", err);
}),
// 1 2 3 4 5 6
request({
url: `/business/facility/query`,
method: "get",
})
.then((result) => {
if (result.code != 200) return Message.error(result?.msg);
this.lwss = [];
result.data.forEach((it) =>
this.lwss.push({
key: it.id,
label: it.facilityName,
type: it.facilityType,
})
);
})
.catch((err) => {
console.log("err", err);
Message.error("查询失败6", err);
}),
])
this.formConfigList.forEach((it) => {
if (it.key == "direction") {
it.options.options = this.direction;
}
if (it.key == "roadId") {
it.options.options = this.roads;
}
if (it.key == "dcEventServiceArea.facilityId") {
it.options.options = this.lwss.filter((ss) => ss.type == 6);
}
});
},
onSubmit() {
this.modelVisible = false;
this.$refs.FormConfigRef.validate().then((formData) => {
this.submitting = true;
let eventType = this.resultEventData.eventType;
formData.eventType == eventType;
if ((eventType == 1 || eventType == 2) && Array.isArray(formData.lang)) {
formData.lang = formData.lang.join(",");
}
if (eventType == 3 && formData.dcEventTrafficControl.facilityId instanceof Array) {
let ids = formData.dcEventTrafficControl.facilityId;
formData.dcEventTrafficControl.facilityIds = ids
formData.dcEventTrafficControl.facilityId = ''
}
if (formData.endStakeMark && formData.endStakeMark[0] != null) {
let endStakeMark = formData.endStakeMark;
let strMark = endStakeMark && endStakeMark.length > 0 ? "K" + endStakeMark[0] + "+" + endStakeMark[1] : "";
if (eventType == 4) {
formData.dcEventTrafficCongestion.endStakeMark = strMark;
}
if (eventType == 7) {
formData.dcEventConstruction.endStakeMark = strMark;
}
if (eventType == 10) {
formData.dcEventAbnormalWeather.endStakeMark = strMark;
}
formData.endStakeMark = "";
} else {
formData.endStakeMark = "";
}
let stakeMark = formData.stakeMark;
// console.log('formData', {
// ...formData,
// id: this.resultEventData.id,
// eventState: this.resultEventData.eventState,
// stakeMark: (stakeMark && stakeMark[0] != null) ? ((stakeMark && stakeMark.length > 0) ? ('K' + stakeMark[0] + '+' + stakeMark[1]) : '') : '',
// })
// this.submitting = false;
// return;
request({
url: `/dc/system/event`,
method: "put",
data: {
...formData,
id: this.resultEventData.id,
eventState: this.resultEventData.eventState,
stakeMark:
stakeMark && stakeMark[0] != null
? stakeMark && stakeMark.length > 0
? "K" + stakeMark[0] + "+" + stakeMark[1]
: ""
: "",
},
})
.then((result) => {
if (result.code != 200) return Message.error(result?.msg);
Message.success("提交成功");
this.modelVisible = false;
})
.catch(() => {
Message.error("提交失败");
})
.finally(() => {
this.submitting = false;
});
});
}
}
};

Loading…
Cancel
Save