Browse Source

feat enum优化合并重复枚举类

wangqin
qingzhengli 8 months ago
parent
commit
a20a38cca6
  1. 71
      ruoyi-ui/src/views/JiHeExpressway/pages/control/event/plan/addAndEditDialog/index.vue
  2. 127
      ruoyi-ui/src/views/JiHeExpressway/utils/enum.js

71
ruoyi-ui/src/views/JiHeExpressway/pages/control/event/plan/addAndEditDialog/index.vue

@ -4,47 +4,24 @@
<ElForm :model="formData" inline :rules="rules" ref="ruleForm"> <ElForm :model="formData" inline :rules="rules" ref="ruleForm">
<div class="first"> <div class="first">
<el-form-item prop="eventCategory"> <el-form-item prop="eventCategory">
<el-radio-group <el-radio-group v-model="formData.eventCategory" @input="changeRadio">
v-model="formData.eventCategory"
@input="changeRadio"
>
<el-radio-button :label="1">交通事件</el-radio-button> <el-radio-button :label="1">交通事件</el-radio-button>
<el-radio-button :label="2">感知事件</el-radio-button> <el-radio-button :label="2">感知事件</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item required label="预案名称:" prop="planName"> <el-form-item required label="预案名称:" prop="planName">
<el-input <el-input v-model="formData.planName" placeholder="请输入预案名称"></el-input>
v-model="formData.planName"
placeholder="请输入预案名称"
></el-input>
</el-form-item> </el-form-item>
<el-form-item required label="事件类型:" prop="eventType"> <el-form-item required label="事件类型:" prop="eventType">
<el-select <el-select v-model="formData.eventType" placeholder="请选择事件类型" @change="changeEventType">
v-model="formData.eventType" <el-option v-for="item in eventOptions" :key="item.value" :label="item.label" :value="item.value">
placeholder="请选择事件类型"
@change="changeEventType"
>
<el-option
v-for="item in eventOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="触发类型:" prop="triggerMechanism"> <el-form-item label="触发类型:" prop="triggerMechanism">
<el-select <el-select v-model="formData.triggerMechanism" placeholder="请选择触发类型">
v-model="formData.triggerMechanism" <el-option v-for="item in mechanismOptions" :key="item.value" :label="item.label" :value="item.value">
placeholder="请选择触发类型"
>
<el-option
v-for="item in mechanismOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -56,11 +33,7 @@
<div class="text"><i style="color: red">*</i>执行操作:</div> <div class="text"><i style="color: red">*</i>执行操作:</div>
</el-col> </el-col>
<el-col :span="22"> <el-col :span="22">
<FormTable <FormTable ref="secondFormTable" :tableData="secondFormData" :type="1"></FormTable>
ref="secondFormTable"
:tableData="secondFormData"
:type="1"
></FormTable>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
@ -70,11 +43,7 @@
<div class="text"><i style="color: red">*</i>恢复操作:</div> <div class="text"><i style="color: red">*</i>恢复操作:</div>
</el-col> </el-col>
<el-col :span="22"> <el-col :span="22">
<FormTable <FormTable ref="thirdFormTable" :tableData="thirdFormData" :type="2"></FormTable>
ref="thirdFormTable"
:tableData="thirdFormData"
:type="2"
></FormTable>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
@ -82,17 +51,9 @@
</div> </div>
<template #footer> <template #footer>
<Button <Button style="background: #c9c9c9; padding: 0 24px"
style="background: #c9c9c9; padding: 0 24px" @click.native="(modelVisible = false), (submitting = false)">取消</Button>
@click.native="(modelVisible = false), (submitting = false)" <Button style="padding: 0 24px" @click.native="handleSubmit" :loading="submitting">保存</Button>
>取消</Button
>
<Button
style="padding: 0 24px"
@click.native="handleSubmit"
:loading="submitting"
>保存</Button
>
</template> </template>
</Dialog> </Dialog>
</template> </template>
@ -111,7 +72,7 @@ import {
gzmsMap, gzmsMap,
eventSubClassMap, eventSubClassMap,
trafficKV, trafficKV,
perceptionKV, WarningTypeList as perceptionKV,
} from "@screen/utils/enum.js"; } from "@screen/utils/enum.js";
const typeMap = { const typeMap = {
@ -141,7 +102,7 @@ export default {
visible: Boolean, visible: Boolean,
detail: { detail: {
type: Object, type: Object,
default: () => {}, default: () => { },
}, },
}, },
data() { data() {
@ -201,7 +162,7 @@ export default {
}, },
}; };
}, },
mounted() {}, mounted() { },
computed: { computed: {
modelVisible: { modelVisible: {
get() { get() {
@ -212,7 +173,7 @@ export default {
this.eventOptions = typeMap[this.detail.eventCategory]; this.eventOptions = typeMap[this.detail.eventCategory];
this.mechanismOptions = this.mechanismOptions =
eventSubClassMap[this.detail.eventCategory || 1][ eventSubClassMap[this.detail.eventCategory || 1][
this.detail.eventType this.detail.eventType
]; ];
this.initData(this.detail.id); this.initData(this.detail.id);
} else { } else {
@ -327,7 +288,7 @@ export default {
this.eventOptions = typeMap[value]; this.eventOptions = typeMap[value];
this.changeEventType(1); this.changeEventType(1);
}, },
handleChange() {}, handleChange() { },
formatData(it, value = 1, id = "") { formatData(it, value = 1, id = "") {
let data = { ...it, actionType: value, emergencyPlansId: id }; let data = { ...it, actionType: value, emergencyPlansId: id };
if ( if (

127
ruoyi-ui/src/views/JiHeExpressway/utils/enum.js

@ -163,21 +163,7 @@ export const WarningType = {
99: "其他事件", 99: "其他事件",
}; };
// 交通事件主类 //========= 感知事件 主类(key vulue) [{value: 1, label: '交通拥堵'}]=========
export const trafficType = {
1: "交通事故",
2: "车辆故障",
3: "交通管制",
4: "交通拥堵",
5: "非法上路",
6: "路障清除",
7: "施工建设",
8: "服务区异常",
9: "设施设备隐患",
10: "异常天气",
11: "其他事件",
};
export const WarningTypeList = Object.keys(WarningType).map((key) => { export const WarningTypeList = Object.keys(WarningType).map((key) => {
return { return {
value: key * 1, value: key * 1,
@ -185,6 +171,11 @@ export const WarningTypeList = Object.keys(WarningType).map((key) => {
}; };
}); });
// 交通事件主类 {1: "交通事故" } 格式
export const trafficType = Object.keys(EventTopics).reduce((prev, now) => {
return { ...prev, [EventTopics[now]]: now };
}, {});
// 感知事件主类的子类(上方) warningSubclass // 感知事件主类的子类(上方) warningSubclass
export const WarningSubclass = { export const WarningSubclass = {
1: { 1: {
@ -262,104 +253,14 @@ export const WarningSubclass = {
}, },
}; };
//========= 交通事件 主类(key vulue)========= //========= 交通事件 主类(key vulue) =========
export const trafficKV = [ export const trafficKV = Object.keys(trafficType).map((key) => {
{ return {
value: 1, value: key * 1,
label: "交通事故", label: trafficType[key],
}, };
{ });
value: 2,
label: "车辆故障",
},
{
value: 3,
label: "交通管制",
},
{
value: 4,
label: "交通拥堵",
},
{
value: 5,
label: "非法上路",
},
{
value: 6,
label: "路障清除",
},
{
value: 7,
label: "施工建设",
},
{
value: 8,
label: "服务区异常",
},
{
value: 9,
label: "设施设备隐患",
},
{
value: 10,
label: "异常天气",
},
{
value: 11,
label: "其他事件",
},
];
//========= 感知事件 主类(key vulue)=========
export const perceptionKV = [
{
value: 1,
label: "交通拥堵",
},
{
value: 2,
label: "行人",
},
{
value: 3,
label: "非机动车",
},
{
value: 4,
label: "停车",
},
{
value: 5,
label: "违规驾驶",
},
{
value: 6,
label: "路障",
},
{
value: 7,
label: "道路施工",
},
{
value: 8,
label: "异常天气",
},
{
value: 9,
label: "护栏碰撞",
},
{
value: 10,
label: "交通事故",
},
{
value: 11,
label: "车辆故障",
},
{
value: 99,
label: "其他事件",
},
];
//交通事件、感知事件 子类(key vulue)预案使用 //交通事件、感知事件 子类(key vulue)预案使用
export const eventSubClassMap = { export const eventSubClassMap = {
1: { 1: {

Loading…
Cancel
Save