代码调整

This commit is contained in:
joylink_cuiweidong 2022-05-16 17:39:43 +08:00
parent 62c2a3dbda
commit fe71d218a9

View File

@ -0,0 +1,205 @@
<template>
<el-dialog
v-dialogDrag
class="chengdou-03__systerm train-set-plan"
:title="title"
:visible.sync="show"
width="360px"
:before-close="doClose"
:z-index="2000"
:modal="false"
:close-on-click-modal="false"
>
<el-row>
<el-col :span="11">车次号</el-col>
<el-col :span="11" :offset="1">上下行</el-col>
</el-row>
<el-row>
<el-col :span="11">
<el-input v-model="addModel.tripNumber" size="mini" @blur="handleTripNumber" />
<div class="tripNumberTips">{{ messageTip1 }}</div>
</el-col>
<el-col :span="11" :offset="1">
<el-select v-model="addModel.right" size="mini">
<el-option :value="true" :label="rightTrueLabel" />
<el-option :value="false" :label="rightFalseLabel" />
</el-select>
<div class="tripNumberTips">{{ messageTip2 }}</div>
</el-col>
</el-row>
<el-row justify="center" class="button-group">
<el-col :span="10">
<el-button :id="domIdConfirm" type="primary" :loading="loading" @click="commit">确定</el-button>
</el-col>
<el-col :span="8" :offset="5">
<el-button :id="domIdCancel" @click="cancel"> </el-button>
</el-col>
</el-row>
<notice-info ref="noticeInfo" pop-class="chengdou-03__systerm" />
</el-dialog>
</template>
<script>
import { mapGetters } from 'vuex';
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
import NoticeInfo from '@/jmapNew/theme/components/menus/childDialog/noticeInfo';
import {menuOperate, commitOperate} from '@/jmapNew/theme/components/utils/menuOperate';
import {mouseCancelState} from '@/jmapNew/theme/components/utils/menuItemStatus';
export default {
name: 'TrainSetPlan',
components: {
NoticeInfo
},
data() {
return {
trainNoList: [],
selected: null,
messageTip1:'',
messageTip2:'',
addModel: {
tripNumber: '',
right: '',
sectionCode: ''
},
dialogShow: false,
loading: false
};
},
computed: {
...mapGetters('map', [
'mapConfig'
]),
show() {
return this.dialogShow && !this.$store.state.menuOperation.break;
},
domIdCancel() {
return this.dialogShow ? OperationEvent.Command.cancel.menu.domId : '';
},
domIdConfirm() {
return this.dialogShow ? OperationEvent.Train.editTrainId.menu.domId : '';
},
title() {
return '模拟车次输入';
},
rightTrueLabel() {
return this.mapConfig.upRight ? '上行' : '下行';
},
rightFalseLabel() {
return this.mapConfig.upRight ? '下行' : '上行';
}
},
watch:{},
methods: {
doShow(operate, selected) {
this.$root.$emit('dialogOpen', selected);
this.selected = selected;
//
this.addModel.sectionCode = selected.code;
this.dialogShow = true;
this.$nextTick(function () {
this.$store.dispatch('training/emitTipFresh');
});
},
doClose() {
this.loading = false;
this.dialogShow = false;
this.addModel = {
tripNumber: '',
right: '',
sectionCode: ''
};
this.$store.dispatch('training/emitTipFresh');
this.$store.dispatch('map/setTrainWindowShow', false);
mouseCancelState(this.selected);
},
handleTripNumber() {
const figuresOfServiceNumber = 3;
// this.$store.state.map.mapConfig.figuresOfServiceNumber;
let tripNumber = parseInt(this.addModel.tripNumber);
if (tripNumber) {
tripNumber = Math.abs(tripNumber);
if (tripNumber.toString().length > figuresOfServiceNumber) {
this.messageTip1 = '车次号长度最多' + figuresOfServiceNumber + '位';
} else {
tripNumber = tripNumber.toString().padStart(figuresOfServiceNumber, '0');
this.addModel.tripNumber = tripNumber;
this.messageTip1 = '';
}
} else {
this.addModel.tripNumber = '';
this.messageTip1 = '请输入车次号';
}
},
commit() {
const figuresOfServiceNumber = 3;
let result = false;
const value = parseInt(this.addModel.tripNumber);
if (value.toString().length > figuresOfServiceNumber) {
result = false;
} else {
result = true;
}
if (this.addModel.tripNumber && result) {
if (!this.addModel.right) {
this.messageTip2 = '请选择上下行';
return;
}
const params = {
tripNumber: this.addModel.tripNumber,
sectionCode: this.addModel.sectionCode,
right: this.addModel.right
};
this.messageTip1 = '';
this.loading = true;
commitOperate(menuOperate.Section.addSpareTrain, params, 2).then(({valid})=>{
this.loading = false;
if (valid) {
this.doClose();
}
}).catch(() => {
this.loading = false;
this.doClose();
this.$refs.noticeInfo.doShow();
});
} else {
if (this.addModel.tripNumber) {
this.messageTip1 = '该车次号长度最多' + figuresOfServiceNumber + '位';
} else {
this.messageTip1 = '请输入车次号';
}
}
},
cancel() {
const operate = {
operation: OperationEvent.Command.cancel.menu.operation
};
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.doClose();
}
}).catch(() => { this.doClose(); });
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/deep/ .el-row {
margin: 10px
}
.ningbo-01__systerm .el-dialog .base-label {
// background: rgba(0, 0, 0, x);
position: relative;
left: -5px;
top: -18px;
padding: 0 5px;
background-color: #F0F0F0;
}
.tripNumberTips{
margin-top: 7px;
color: #f00;
font-size: 13px;
}
</style>