2019-10-31 15:34:38 +08:00
|
|
|
<template>
|
2019-12-09 11:00:25 +08:00
|
|
|
<div>
|
|
|
|
<el-form ref="form" :rules="rules" :model="form" label-width="80px">
|
|
|
|
<el-form-item :label="this.$t('ibp.buttonCode')" prop="code">
|
|
|
|
<el-input v-model="form.code" :disabled="true">
|
|
|
|
<el-button slot="append" :disabled="isUpdate" type="primary" @click="generateCode">{{ $t('ibp.generateCode') }}</el-button>
|
|
|
|
</el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.buttonColor')" prop="buttonColor">
|
|
|
|
<el-select v-model="form.buttonColor" :placeholder="this.$t('ibp.selectTheButtonColor')">
|
|
|
|
<el-option :label="this.$t('ibp.redButton')" value="red" />
|
|
|
|
<el-option :label="this.$t('ibp.yellowButton')" value="yellow" />
|
|
|
|
<el-option :label="this.$t('ibp.greenButton')" value="green" />
|
|
|
|
<el-option :label="this.$t('ibp.blueButton')" value="blue" />
|
|
|
|
<el-option :label="this.$t('ibp.grayButton')" value="gray" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.buttonWidth')" prop="buttonWidth">
|
|
|
|
<el-input-number v-model="form.buttonWidth" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.xCoordinate')">
|
|
|
|
<el-input-number v-model="form.x" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.yCoordinate')">
|
|
|
|
<el-input-number v-model="form.y" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="操作">
|
|
|
|
<el-select v-model="form.mean" placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="item in operateMeanList"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2021-03-23 11:06:14 +08:00
|
|
|
<el-form-item v-if="form.mean === 'PRERESET'" label="关联区段" prop="sectionCode">
|
|
|
|
<el-select v-model="form.sectionCode" filterable placeholder="请选择">
|
2021-02-23 13:04:29 +08:00
|
|
|
<el-option
|
|
|
|
v-for="item in sectionList"
|
|
|
|
:key="item.code"
|
|
|
|
:label="item.name + '(' + item.code +')'"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2019-12-09 11:00:25 +08:00
|
|
|
<el-form-item>
|
|
|
|
<el-button type="primary" @click="onSubmit('form')">{{ buttonText }}</el-button>
|
|
|
|
<el-button v-show="showDeleteButton" type="danger" @click="deleteDevice">{{ $t('global.delete') }}</el-button>
|
|
|
|
<el-button v-show="showDeleteButton" @click="initPage">{{ $t('global.cancel') }}</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
2019-10-31 15:34:38 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-03-23 11:06:14 +08:00
|
|
|
import {getSectionListByCenStationCode, getSectionListByMapId } from '@/api/jmap/map';
|
2019-12-09 11:00:25 +08:00
|
|
|
export default {
|
|
|
|
name: 'ButtonDraft',
|
|
|
|
components: {
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isUpdate: false,
|
|
|
|
buttonText: this.$t('ibp.createNow'),
|
|
|
|
showDeleteButton: false,
|
|
|
|
operateMeanList: [
|
2020-09-16 10:10:13 +08:00
|
|
|
{ label: '上行扣车', value: 'SXKC' },
|
|
|
|
{ label: '下行扣车', value: 'XXKC' },
|
|
|
|
{ label: '上行终止扣车', value: 'SXZZKC' },
|
|
|
|
{ label: '下行终止扣车', value: 'XXZZKC' },
|
|
|
|
{ label: '紧急停车', value: 'JJTC' },
|
|
|
|
{ label: '取消紧急停车', value: 'QXJJTC' },
|
|
|
|
{ label: '报警切除', value: 'BJQC' },
|
|
|
|
{ label: '下行屏蔽门开门', value: 'XXKM' },
|
2021-02-23 13:04:29 +08:00
|
|
|
{ label: '上行屏蔽门开门', value: 'SXKM' },
|
2021-06-11 11:04:06 +08:00
|
|
|
{ label: '计轴复位', value: 'PRERESET' },
|
|
|
|
{ label: '计轴预复位', value: 'PRERESET_P' },
|
2019-12-09 11:00:25 +08:00
|
|
|
],
|
|
|
|
form: {
|
|
|
|
code: '',
|
|
|
|
buttonColor: 'red',
|
|
|
|
buttonWidth: 25,
|
|
|
|
x: 10,
|
2021-02-23 13:04:29 +08:00
|
|
|
y: 10,
|
|
|
|
sectionCode: '',
|
|
|
|
mean: ''
|
2019-12-09 11:00:25 +08:00
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
code: [
|
|
|
|
{ required: true, message: this.$t('ibp.enterTheButtonCode'), trigger: 'blur' }
|
|
|
|
],
|
|
|
|
buttonColor: [
|
|
|
|
{ required: true, message: this.$t('ibp.selectTheButtonColor'), trigger: 'change'}
|
|
|
|
],
|
|
|
|
buttonWidth: [
|
|
|
|
{ required: true, message: this.$t('ibp.enterTheButtonWidth'), trigger: 'blur' }
|
2021-03-23 11:06:14 +08:00
|
|
|
],
|
|
|
|
sectionCode: [
|
|
|
|
{ required: true, message: '请选择关联区段', trigger: 'blur' }
|
2019-12-09 11:00:25 +08:00
|
|
|
]
|
2021-02-23 13:04:29 +08:00
|
|
|
},
|
|
|
|
sectionList: []
|
2019-12-09 11:00:25 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$store.state.ibp.rightClickCount': function (val) {
|
|
|
|
const model = this.$store.getters['ibp/updateDeviceData'];
|
|
|
|
if (model._type === 'SquareButton' ) {
|
|
|
|
this.buttonText = this.$t('global.modify');
|
|
|
|
this.showDeleteButton = true;
|
|
|
|
this.isUpdate = true;
|
|
|
|
this.form.code = model.code;
|
|
|
|
this.form.buttonColor = model.color;
|
|
|
|
this.form.buttonWidth = model.width;
|
|
|
|
this.form.x = model.point.x;
|
|
|
|
this.form.y = model.point.y;
|
|
|
|
this.form.mean = model.mean;
|
2021-02-23 13:04:29 +08:00
|
|
|
this.form.sectionCode = model.sectionCode;
|
2019-12-09 11:00:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-02-23 13:04:29 +08:00
|
|
|
if (this.$route.query.stationCode) {
|
2021-03-23 11:06:14 +08:00
|
|
|
getSectionListByCenStationCode(this.$route.query.mapId, this.$route.query.stationCode).then(resp => {
|
2021-02-23 13:04:29 +08:00
|
|
|
this.sectionList = resp.data;
|
|
|
|
console.log(resp.data);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$message.error('获取区段列表失败!');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
getSectionListByMapId(this.$route.query.mapId).then(resp => {
|
|
|
|
this.sectionList = resp.data;
|
|
|
|
console.log(resp.data);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$message.error('获取区段列表失败!');
|
|
|
|
});
|
|
|
|
}
|
2019-12-09 11:00:25 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2021-02-23 13:04:29 +08:00
|
|
|
// consoleChange() {
|
|
|
|
// console.log(this.form.mean === 'PRERESET', this.form.mean );
|
|
|
|
// },
|
2019-12-09 11:00:25 +08:00
|
|
|
onSubmit(form) {
|
|
|
|
this.$refs[form].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const buttonModel = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
|
|
|
},
|
|
|
|
_type: 'SquareButton',
|
|
|
|
code: this.form.code,
|
|
|
|
color: this.form.buttonColor,
|
|
|
|
status: 'off',
|
|
|
|
width: this.form.buttonWidth,
|
2021-02-23 13:04:29 +08:00
|
|
|
mean: this.form.mean,
|
|
|
|
sectionCode: this.form.sectionCode
|
2019-12-09 11:00:25 +08:00
|
|
|
};
|
2020-09-14 10:59:02 +08:00
|
|
|
this.$emit('createData', buttonModel);
|
2019-12-09 11:00:25 +08:00
|
|
|
this.initPage();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2019-12-09 11:00:25 +08:00
|
|
|
deleteDevice() {
|
|
|
|
const buttonModel = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2019-12-09 11:00:25 +08:00
|
|
|
_type: 'SquareButton',
|
|
|
|
code: this.form.code,
|
|
|
|
color: this.form.buttonColor,
|
|
|
|
status: 'off',
|
|
|
|
width: this.form.buttonWidth,
|
2021-02-23 13:04:29 +08:00
|
|
|
mean: this.form.mean,
|
|
|
|
sectionCode: this.form.sectionCode
|
2019-10-31 15:34:38 +08:00
|
|
|
};
|
2019-12-09 11:00:25 +08:00
|
|
|
this.$emit('deleteDataModel', buttonModel );
|
|
|
|
this.initPage();
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2019-12-09 11:00:25 +08:00
|
|
|
initPage() {
|
|
|
|
this.isUpdate = false;
|
|
|
|
this.buttonText = this.$t('ibp.createNow');
|
|
|
|
this.showDeleteButton = false;
|
|
|
|
this.form = {
|
|
|
|
code: '',
|
|
|
|
buttonColor: 'red',
|
|
|
|
buttonWidth: 25,
|
|
|
|
x: 10,
|
|
|
|
y: 10,
|
2021-02-23 13:04:29 +08:00
|
|
|
mean: '',
|
|
|
|
sectionCode: ''
|
2019-12-09 11:00:25 +08:00
|
|
|
};
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2019-12-09 11:00:25 +08:00
|
|
|
generateCode() {
|
|
|
|
const mydate = new Date();
|
|
|
|
this.form.code = 'sButton_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
|
2019-10-31 15:34:38 +08:00
|
|
|
}
|
2019-12-09 11:00:25 +08:00
|
|
|
}
|
|
|
|
};
|
2019-10-31 15:34:38 +08:00
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|