xa3_头码车识别号校验修改

This commit is contained in:
yuan 2021-07-08 11:15:04 +08:00
parent 42d0fefa71
commit 67fe7b6774
2 changed files with 272 additions and 215 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ src/utils/baseUrl.js*
*.njsproj
*.sln
debug.log
.prettierrc

View File

@ -1,7 +1,26 @@
<template>
<el-dialog v-dialogDrag :class="popClass + ' train-control'" :title="title" :visible.sync="show" width="370px" :before-close="doClose" :z-index="2000" :modal="false" :close-on-click-modal="false">
<el-form ref="form" size="small" label-width="120px" :model="formModel" :rules="rules">
<el-form-item :label="this.$t('menu.groupNumber')+this.$t('global.colon')" prop="groupNumber">
<el-dialog
v-dialogDrag
:class="popClass + ' train-control'"
:title="title"
:visible.sync="show"
width="370px"
:before-close="doClose"
:z-index="2000"
:modal="false"
:close-on-click-modal="false"
>
<el-form
ref="form"
size="small"
label-width="120px"
:model="formModel"
:rules="rulesComputed"
>
<el-form-item
:label="this.$t('menu.groupNumber') + this.$t('global.colon')"
prop="groupNumber"
>
<el-select
:id="domIdTrainNumber"
v-model="formModel.groupNumber"
@ -24,15 +43,17 @@
style="margin-left: 45px;"
@change="trainTypeChange"
>
<el-radio :label="'PLAN'">{{ $t('menu.planTrain') }}</el-radio>
<el-radio :label="'HEAD'">{{ $t('menu.headCodeTrain') }}</el-radio>
<el-radio :label="'MANUAL'" style="margin-top:5px;">{{ $t('menu.artificialTrain') }}</el-radio>
<el-radio :label="'PLAN'">{{ $t("menu.planTrain") }}</el-radio>
<el-radio :label="'HEAD'">{{ $t("menu.headCodeTrain") }}</el-radio>
<el-radio :label="'MANUAL'" style="margin-top:5px;">{{
$t("menu.artificialTrain")
}}</el-radio>
</el-radio-group>
</el-form-item>
<!-- 表号 -->
<el-form-item v-if="formModel.type == 'PLAN'" prop="serviceNumber">
<span slot="label">{{ $t('menu.serviceNumber') + '' }}</span>
<span slot="label">{{ $t("menu.serviceNumber") + "" }}</span>
<el-input
:id="domIdServerNo"
v-model="formModel.serviceNumber"
@ -41,16 +62,20 @@
</el-form-item>
<!-- 车次号 -->
<el-form-item v-if="formModel.type == 'PLAN'|| formModel.type == 'HEAD'" :label="this.$t('menu.tripNumber')+this.$t('global.colon')" prop="tripNumber">
<el-input
:id="domIdTrainNo"
v-model="formModel.tripNumber"
maxlength="4"
/>
<el-form-item
v-if="formModel.type == 'PLAN' || formModel.type == 'HEAD'"
:label="this.$t('menu.tripNumber') + this.$t('global.colon')"
prop="tripNumber"
>
<el-input :id="domIdTrainNo" v-model="formModel.tripNumber" maxlength="4" />
</el-form-item>
<!-- 目的地号 -->
<el-form-item v-if="formModel.type == 'PLAN' || formModel.type == 'HEAD'" :label="this.$t('menu.targetCode')+this.$t('global.colon')" prop="destinationCode">
<el-form-item
v-if="formModel.type == 'PLAN' || formModel.type == 'HEAD'"
:label="this.$t('menu.targetCode') + this.$t('global.colon')"
prop="destinationCode"
>
<el-input
:id="domIdTargetCode"
v-model="formModel.destinationCode"
@ -59,7 +84,11 @@
</el-form-item>
<!-- 类别 -->
<el-form-item v-if="formModel.type == 'MANUAL'" :label="this.$t('menu.category')+this.$t('global.colon')" prop="category">
<el-form-item
v-if="formModel.type == 'MANUAL'"
:label="this.$t('menu.category') + this.$t('global.colon')"
prop="category"
>
<el-select
:id="domIdTrainNumber"
v-model="formModel.category"
@ -77,10 +106,12 @@
</el-form>
<el-row justify="center" class="button-group">
<el-col :span="10" :offset="2">
<el-button :id="domIdConfirm" type="primary" :loading="loading" @click="commit">{{ $t('global.confirm') }}</el-button>
<el-button :id="domIdConfirm" type="primary" :loading="loading" @click="commit">{{
$t("global.confirm")
}}</el-button>
</el-col>
<el-col :span="8" :offset="4">
<el-button :id="domIdCancel" @click="cancel">{{ $t('global.cancel') }}</el-button>
<el-button :id="domIdCancel" @click="cancel">{{ $t("global.cancel") }}</el-button>
</el-col>
</el-row>
<notice-info ref="noticeInfo" :pop-class="popClass" />
@ -88,15 +119,15 @@
</template>
<script>
import { mapGetters } from 'vuex';
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
import Handler from '@/scripts/cmdPlugin/Handler';
import {menuOperate, commitOperate} from '@/jmapNew/theme/components/utils/menuOperate';
import {getTrainDetailBytripNumber, getTrainDetailByStNumber} from '@/api/simulation';
import NoticeInfo from '../childDialog/noticeInfo';
import { mapGetters } from "vuex";
import { OperationEvent } from "@/scripts/cmdPlugin/OperationHandler";
import Handler from "@/scripts/cmdPlugin/Handler";
import { menuOperate, commitOperate } from "@/jmapNew/theme/components/utils/menuOperate";
import { getTrainDetailBytripNumber, getTrainDetailByStNumber } from "@/api/simulation";
import NoticeInfo from "../childDialog/noticeInfo";
export default {
name: 'TrainControl',
name: "TrainControl",
components: {
NoticeInfo
},
@ -104,48 +135,23 @@ export default {
popClass: {
type: String,
default() {
return '';
return "";
}
}
},
data() {
var validateTripNum = (rule, value, callback) => {
const trip = Number.parseInt(value.substring(1));
if (this.formModel.type === 'HEAD' && this.popClass === 'xian-01__systerm' && (trip < 701 || trip > 749)) {
callback(new Error('头码车车次编号为701至749'));
} else {
callback();
}
};
return {
trainList: [],
serviceNumber:'',
serviceNumber: "",
formModel: {
tripNumber: '',
groupNumber: '',
type: 'PLAN',
serviceNumber: '',
destinationCode: '',
category: 'MM'
},
categoryList: [
{ name: 'MM', value: '01' }
],
rules: {
groupNumber: [
{ required: true, message: '请选择车组号', trigger: 'change' }
],
type: [
{ required: true, message: '请选择列车类型', trigger: 'change' }
],
tripNumber: [
{ required: true, message: '请输入车次号', trigger: 'blur' },
{ validator: validateTripNum, trigger: 'blur' }
],
destinationCode: [
{ required: true, message: '请输入目的地号', trigger: 'blur' }
]
tripNumber: "",
groupNumber: "",
type: "PLAN",
serviceNumber: "",
destinationCode: "",
category: "MM"
},
categoryList: [{ name: "MM", value: "01" }],
operation: null,
dialogShow: false,
loading: false,
@ -154,11 +160,36 @@ export default {
};
},
computed: {
...mapGetters('map', [
'map'
]),
...mapGetters("map", ["map"]),
rulesComputed() {
const validateTripNum = (rule, value, callback) => {
const trip = Number.parseInt(value.substring(1));
if (
this.formModel.type === "HEAD" &&
this.popClass === "xian-01__systerm" &&
(trip < 701 || trip > 749)
) {
callback(new Error("头码车车次编号为701至749"));
} else {
callback();
}
};
return {
groupNumber: [{ required: true, message: "请选择车组号", trigger: "change" }],
type: [{ required: true, message: "请选择列车类型", trigger: "change" }],
tripNumber: [
{
required: !(this.formModel.type === "HEAD" && this.popClass === "xian-01__systerm"),
message: "请输入车次号",
trigger: "blur"
},
{ validator: validateTripNum, trigger: "blur" }
],
destinationCode: [{ required: true, message: "请输入目的地号", trigger: "blur" }]
};
},
serverNoIsDisabled() {
if (this.popClass === 'foshan-01__systerm' && this.formModel.type === 'PLAN') {
if (this.popClass === "foshan-01__systerm" && this.formModel.type === "PLAN") {
return false;
} else {
return true;
@ -168,7 +199,7 @@ export default {
if (this.operation != OperationEvent.Train.addTrainId.menu.operation) {
return true;
}
return '';
return "";
},
show() {
return this.dialogShow && !this.$store.state.menuOperation.break;
@ -183,7 +214,7 @@ export default {
return OperationEvent.Train.editTrainId.trainNumberChange.domId;
}
}
return '';
return "";
},
domIdTrainNo() {
if (this.dialogShow) {
@ -195,7 +226,7 @@ export default {
return OperationEvent.Train.editTrainId.trainNoChange.domId;
}
}
return '';
return "";
},
domIdTrainType() {
if (this.dialogShow) {
@ -207,7 +238,7 @@ export default {
return OperationEvent.Train.editTrainId.trainTypeChange.domId;
}
}
return '';
return "";
},
domIdServerNo() {
if (this.dialogShow) {
@ -219,7 +250,7 @@ export default {
return OperationEvent.Train.editTrainId.serverNoChange.domId;
}
}
return '';
return "";
},
domIdTargetCode() {
if (this.dialogShow) {
@ -231,7 +262,7 @@ export default {
return OperationEvent.Train.editTrainId.targetCodeChange.domId;
}
}
return '';
return "";
},
domIdConfirm() {
if (this.dialogShow) {
@ -243,36 +274,45 @@ export default {
return OperationEvent.Train.editTrainId.menu.domId;
}
}
return '';
return "";
},
domIdCancel() {
return this.dialogShow ? OperationEvent.Command.cancel.menu.domId : '';
return this.dialogShow ? OperationEvent.Command.cancel.menu.domId : "";
},
title() {
if (this.operation == OperationEvent.Train.addTrainId.menu.operation) {
return '添加列车识别号';
return "添加列车识别号";
} else if (this.operation == OperationEvent.Train.editTrainId.menu.operation) {
return '修改列车识别号';
return "修改列车识别号";
}
return '';
return "";
}
},
watch: {
'formModel.tripNumber': function(val) {
if (this.popClass !== 'foshan-01__systerm' && val.length === 4 && this.formModel.type !== 'HEAD') {
"formModel.tripNumber": function(val) {
if (
this.popClass !== "foshan-01__systerm" &&
val.length === 4 &&
this.formModel.type !== "HEAD"
) {
this.trainNoChange(val);
} else if (this.popClass !== 'foshan-01__systerm' && this.formModel.type !== 'HEAD') {
} else if (this.popClass !== "foshan-01__systerm" && this.formModel.type !== "HEAD") {
this.formModel = {
groupNumber: this.formModel.groupNumber,
tripNumber: val,
type: this.formModel.type,
serviceNumber: '',
targetCode: '',
category: 'MM'
serviceNumber: "",
targetCode: "",
category: "MM"
};
} else if (this.popClass === 'foshan-01__systerm' && val.length === 2 && this.formModel.serviceNumber.length === 3 && this.formModel.type !== 'HEAD') {
} else if (
this.popClass === "foshan-01__systerm" &&
val.length === 2 &&
this.formModel.serviceNumber.length === 3 &&
this.formModel.type !== "HEAD"
) {
this.trainNoChange(val, this.formModel.serviceNumber);
} else if (this.popClass === 'foshan-01__systerm' && this.formModel.type !== 'HEAD') {
} else if (this.popClass === "foshan-01__systerm" && this.formModel.type !== "HEAD") {
const serviceNumber = this.formModel.serviceNumber;
const destinationCode = this.formModel.destinationCode;
this.formModel = {
@ -281,15 +321,19 @@ export default {
tripNumber: val,
type: this.formModel.type,
serviceNumber: serviceNumber,
targetCode: '',
category: 'MM'
targetCode: "",
category: "MM"
};
}
},
'formModel.serviceNumber': function(val) {
if (this.popClass === 'foshan-01__systerm' && val.length === 3 && this.formModel.tripNumber.length === 2) {
"formModel.serviceNumber": function(val) {
if (
this.popClass === "foshan-01__systerm" &&
val.length === 3 &&
this.formModel.tripNumber.length === 2
) {
this.trainNoChange(this.formModel.tripNumber, val);
} else if (this.popClass === 'foshan-01__systerm') {
} else if (this.popClass === "foshan-01__systerm") {
const tripNumber = this.formModel.tripNumber;
const destinationCode = this.formModel.destinationCode;
this.formModel = {
@ -298,8 +342,8 @@ export default {
destinationCode: destinationCode,
type: this.formModel.type,
serviceNumber: val,
targetCode: '',
category: 'MM'
targetCode: "",
category: "MM"
};
}
}
@ -307,40 +351,40 @@ export default {
methods: {
loadInitData(map) {},
doShow(operate, selected) {
this.$root.$emit('dialogOpen', selected);
this.$root.$emit("dialogOpen", selected);
this.selected = selected;
//
if (!this.dialogShow) {
this.operation = operate.operation;
}
const model = this.$store.getters['map/getDeviceByCode'](selected.code);
const model = this.$store.getters["map/getDeviceByCode"](selected.code);
this.serviceNumber = model.serviceNumber;
this.formModel = {
groupNumber: model.groupNumber,
tripNumber: model.tripNumber,
type: model.type ? model.type : 'PLAN',
type: model.type ? model.type : "PLAN",
serviceNumber: model.serviceNumber,
destinationCode: model.destinationCode,
category: 'MM'
category: "MM"
};
/** 加载列车数据*/
this.loadInitData(this.map);
this.dialogShow = true;
this.$nextTick(function() {
this.$store.dispatch('training/emitTipFresh');
this.$store.dispatch("training/emitTipFresh");
});
},
doClose() {
this.loading = false;
this.dialogShow = false;
this.$root.$emit('dialogClose', this.selected);
this.$store.dispatch('training/emitTipFresh');
this.$store.dispatch('map/setTrainWindowShow', false);
this.$root.$emit("dialogClose", this.selected);
this.$store.dispatch("training/emitTipFresh");
this.$store.dispatch("map/setTrainWindowShow", false);
},
trainNumberChange(groupNumber) {
const operate = {
groupNumber: groupNumber,
operation: ''
operation: ""
};
if (this.operation == OperationEvent.Train.addTrainId.menu.operation) {
operate.operation = OperationEvent.Train.addTrainId.trainNumberChange.operation;
@ -348,37 +392,37 @@ export default {
operate.operation = OperationEvent.Train.editTrainId.trainNumberChange.operation;
}
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
this.$store.dispatch("training/nextNew", operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$store.dispatch("menuOperation/handleBreakFlag", { break: true });
}
});
},
trainTypeChange(trainType) {
if (trainType === 'HEAD') {
this.formModel.serviceNumber = '';
} else if (trainType === 'PLAN' && this.serviceNumber) {
if (trainType === "HEAD") {
this.formModel.serviceNumber = "";
} else if (trainType === "PLAN" && this.serviceNumber) {
this.formModel.serviceNumber = this.serviceNumber;
}
const operate = {
type: trainType,
operation: ''
operation: ""
};
if (this.operation == OperationEvent.Train.addTrainId.menu.operation) {
operate.operation = OperationEvent.Train.addTrainId.trainTypeChange.operation;
} else if (this.operation == OperationEvent.Train.editTrainId.menu.operation) {
operate.operation = OperationEvent.Train.editTrainId.trainTypeChange.operation;
}
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
this.$store.dispatch("training/nextNew", operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$store.dispatch("menuOperation/handleBreakFlag", { break: true });
}
});
},
trainNoChange(tripNumber, serviceNumber) {
const operate = {
tripNumber: tripNumber,
operation: ''
operation: ""
};
if (this.operation == OperationEvent.Train.addTrainId.menu.operation) {
operate.operation = OperationEvent.Train.addTrainId.trainNoChange.operation;
@ -387,30 +431,35 @@ export default {
}
Handler.undo(1);
try {
if (this.popClass === 'foshan-01__systerm') {
getTrainDetailByStNumber(this.$route.query.group, {tripNumber: tripNumber, serviceNumber: serviceNumber}).then(resp => {
if (this.popClass === "foshan-01__systerm") {
getTrainDetailByStNumber(this.$route.query.group, {
tripNumber: tripNumber,
serviceNumber: serviceNumber
}).then(resp => {
if (resp.data) {
this.formModel.destinationCode = resp.data.destinationCode;
} else {
this.$message.error('未找到输入列车信息!');
this.$message.error("未找到输入列车信息!");
}
});
} else {
getTrainDetailBytripNumber(this.$route.query.group, {tripNumber:tripNumber}).then(resp => {
getTrainDetailBytripNumber(this.$route.query.group, {
tripNumber: tripNumber
}).then(resp => {
if (resp.data) {
this.formModel.serviceNumber = resp.data.serviceNumber;
this.formModel.destinationCode = resp.data.destinationCode;
} else {
this.$message.error('未找到输入列车信息!');
this.$message.error("未找到输入列车信息!");
}
});
}
} catch (e) {
this.$message.error('获取列车信息失败!');
this.$message.error("获取列车信息失败!");
}
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
this.$store.dispatch("training/nextNew", operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.$store.dispatch("menuOperation/handleBreakFlag", { break: true });
}
});
},
@ -425,29 +474,31 @@ export default {
},
//
addTrainId() {
this.$refs['form'].validate((valid) => {
this.$refs["form"].validate(valid => {
if (valid) {
const params = {
groupNumber: this.formModel.groupNumber,
type: this.formModel.type,
serviceNumber: '',
tripNumber: '',
destinationCode: ''
serviceNumber: "",
tripNumber: "",
destinationCode: ""
};
if (this.formModel.type === 'PLAN') {
if (this.formModel.type === "PLAN") {
params.serviceNumber = this.formModel.serviceNumber;
params.tripNumber = this.formModel.tripNumber;
params.destinationCode = this.formModel.destinationCode;
} else if (this.formModel.type === 'HEAD') {
} else if (this.formModel.type === "HEAD") {
params.tripNumber = this.formModel.tripNumber;
params.destinationCode = this.formModel.destinationCode;
}
commitOperate(menuOperate.TrainWindow.addTrainId, params, 2).then(({valid})=>{
commitOperate(menuOperate.TrainWindow.addTrainId, params, 2)
.then(({ valid }) => {
this.loading = false;
if (valid) {
this.doClose();
}
}).catch(() => {
})
.catch(() => {
this.loading = false;
this.doClose();
this.$refs.noticeInfo.doShow();
@ -459,29 +510,31 @@ export default {
},
//
editTrainId() {
this.$refs['form'].validate((valid) => {
this.$refs["form"].validate(valid => {
if (valid) {
const params = {
groupNumber: this.formModel.groupNumber,
type: this.formModel.type,
serviceNumber: '',
tripNumber: '',
destinationCode: ''
serviceNumber: "",
tripNumber: "",
destinationCode: ""
};
if (this.formModel.type === 'PLAN') {
if (this.formModel.type === "PLAN") {
params.serviceNumber = this.formModel.serviceNumber;
params.tripNumber = this.formModel.tripNumber;
params.destinationCode = this.formModel.destinationCode;
} else if (this.formModel.type === 'HEAD') {
} else if (this.formModel.type === "HEAD") {
params.tripNumber = this.formModel.tripNumber;
params.destinationCode = this.formModel.destinationCode;
}
commitOperate(menuOperate.TrainWindow.editTrainId, params, 2).then(({valid})=>{
commitOperate(menuOperate.TrainWindow.editTrainId, params, 2)
.then(({ valid }) => {
this.loading = false;
if (valid) {
this.doClose();
}
}).catch(() => {
})
.catch(() => {
this.loading = false;
this.doClose();
this.$refs.noticeInfo.doShow();
@ -495,11 +548,14 @@ export default {
const operate = {
operation: OperationEvent.Command.cancel.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
this.$store
.dispatch("training/nextNew", operate)
.then(({ valid }) => {
if (valid) {
this.doClose();
}
}).catch(() => {
})
.catch(() => {
this.doClose();
});
}