rt-sim-training-client/src/views/ibp/ibpDraw/ibpOperate/ibpAlarm.vue

165 lines
5.4 KiB
Vue
Raw Normal View History

2019-10-31 15:34:38 +08:00
<template>
2020-09-14 10:59:02 +08:00
<div>
<el-form ref="form" :rules="rules" :model="form" label-width="100px">
<el-form-item :label="this.$t('ibp.alarmCode')" 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.alarmWidth')" prop="alarmWidth">
<el-input-number v-model="form.alarmWidth" 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>
2022-06-10 11:23:16 +08:00
<el-form-item label="表示状态">
<el-select v-model="form.mean" placeholder="请选择">
<el-option
v-for="item in showMeanList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="方向">
<el-select v-model="form.direction" placeholder="请选择">
2022-06-10 11:23:16 +08:00
<el-option
v-for="(item, i) in directions"
:key="i"
:label="item.name"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
2020-09-14 10:59:02 +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>
2020-09-14 10:59:02 +08:00
export default {
name: 'ButtonDraft',
components: {
},
data() {
return {
isUpdate: false,
buttonText: this.$t('ibp.createNow'),
showDeleteButton: false,
form: {
code: '',
alarmWidth: '',
x: 10,
y: 10,
direction: null,
2022-06-10 11:23:16 +08:00
mean: ''
2020-09-14 10:59:02 +08:00
},
rules: {
code: [
{ required: true, message: this.$t('rules.enterTheAlarmCode'), trigger: 'blur' }
],
alarmWidth: [
{ required: true, message: this.$t('rules.enterTheAlarmWidth'), trigger: 'blur' }
]
},
directions: [
{ name: '全部', value: null},
{ name: '上行', value: true},
{ name: '下行', value: false},
],
2022-06-10 11:23:16 +08:00
showMeanList: [
{label: '信号-蜂鸣器', value: 'SIGNAL_ALARM'},
{label: '屏蔽门-蜂鸣器', value: 'PSD_ALARM'}
]
2020-09-14 10:59:02 +08:00
};
},
computed: {
},
watch: {
'$store.state.ibp.rightClickCount': function (val) {
const model = this.$store.getters['ibp/updateDeviceData'];
if (model._type === 'Alarm' ) {
this.buttonText = this.$t('global.modify');
this.showDeleteButton = true;
this.isUpdate = true;
this.form.code = model.code;
this.form.alarmWidth = model.width;
this.form.x = model.point.x;
this.form.y = model.point.y;
2022-06-10 11:23:16 +08:00
this.form.mean = model.mean;
this.form.direction = model.direction
2020-09-14 10:59:02 +08:00
}
}
},
mounted() {
},
methods: {
onSubmit(form) {
this.$refs[form].validate((valid) => {
if (valid) {
const alarmModel = {
point:{
x: this.form.x,
y: this.form.y
},
code: this.form.code,
2022-06-10 11:23:16 +08:00
mean: this.form.mean,
2020-09-14 10:59:02 +08:00
_type: 'Alarm',
width: this.form.alarmWidth,
direction: this.form.direction
2020-09-14 10:59:02 +08:00
};
this.$emit('createData', alarmModel);
this.initPage();
} else {
return false;
}
});
2019-10-31 15:34:38 +08:00
},
2020-09-14 10:59:02 +08:00
deleteDevice() {
const alarmModel = {
point:{
x: this.form.x,
y: this.form.y
2019-10-31 15:34:38 +08:00
},
2020-09-14 10:59:02 +08:00
code: this.form.code,
_type: 'Alarm',
2022-06-10 11:23:16 +08:00
mean: this.form.mean,
width: this.form.alarmWidth,
direction: this.form.direction
2019-10-31 15:34:38 +08:00
};
2020-09-14 10:59:02 +08:00
this.$emit('deleteDataModel', alarmModel );
this.initPage();
2019-10-31 15:34:38 +08:00
},
2020-09-14 10:59:02 +08:00
initPage() {
this.isUpdate = false;
this.buttonText = this.$t('ibp.createNow');
this.showDeleteButton = false;
this.form = {
code: '',
alarmWidth: '',
x: 10,
y: 10,
2022-06-10 11:23:16 +08:00
mean: '',
direction: null
2020-09-14 10:59:02 +08:00
};
2019-10-31 15:34:38 +08:00
},
2020-09-14 10:59:02 +08:00
generateCode() {
const mydate = new Date();
this.form.code = 'alarm_' + mydate.getDay() + mydate.getHours() + mydate.getMinutes() + mydate.getSeconds() + mydate.getMilliseconds() + Math.round(Math.random() * 10000);
2019-10-31 15:34:38 +08:00
}
2020-09-14 10:59:02 +08:00
}
};
2019-10-31 15:34:38 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>