2020-01-16 18:06:00 +08:00
|
|
|
<template>
|
2020-08-12 11:02:47 +08:00
|
|
|
<div style="overflow-y: scroll;height: calc(100% - 46px); width: 100%;">
|
|
|
|
<el-form ref="form" :rule="rules" :model="addModel" label-width="100px" style="width: 100%;padding: 10px 50px;">
|
|
|
|
<el-form-item v-if="isUpdate" label="编号:" prop="code">
|
|
|
|
<el-input v-model="addModel.code" size="small" :disabled="true" />
|
2020-01-16 18:06:00 +08:00
|
|
|
</el-form-item>
|
2020-08-12 11:02:47 +08:00
|
|
|
<el-form-item label="图形宽度:" prop="width">
|
|
|
|
<el-input-number v-model="addModel.width" size="small" />
|
2020-01-16 18:06:00 +08:00
|
|
|
</el-form-item>
|
2020-08-12 11:02:47 +08:00
|
|
|
<el-form-item label="X轴坐标:" prop="x">
|
|
|
|
<el-input-number v-model="addModel.x" size="small" />
|
2020-01-16 18:06:00 +08:00
|
|
|
</el-form-item>
|
2020-08-12 11:02:47 +08:00
|
|
|
<el-form-item label="Y轴坐标:" prop="y">
|
|
|
|
<el-input-number v-model="addModel.y" size="small" />
|
2020-01-16 18:06:00 +08:00
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
2020-08-12 11:02:47 +08:00
|
|
|
<el-button type="primary" size="small" @click="onSubmit('form')">{{ buttonText }}</el-button>
|
|
|
|
<el-button v-show="showDeleteButton" size="small" type="danger" @click="deleteDevice">{{ $t('global.delete') }}</el-button>
|
|
|
|
<el-button v-show="showDeleteButton" size="small" @click="initPage">{{ $t('global.cancel') }}</el-button>
|
2020-01-16 18:06:00 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-01-19 14:03:32 +08:00
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import {getUID} from '@/iscs/utils/Uid';
|
2020-01-16 18:06:00 +08:00
|
|
|
export default {
|
2020-01-19 14:03:32 +08:00
|
|
|
name: 'EndDoor',
|
2020-01-16 18:06:00 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
addModel:{
|
|
|
|
code: '',
|
|
|
|
width: 25,
|
|
|
|
x: 10,
|
|
|
|
y: 10
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
width:[{ required: true, message:'请输入设备图形宽度', trigger: 'blur' }],
|
|
|
|
x: [{ required: true, message: '请输入设备图形的X轴坐标', trigger: 'blur' }],
|
|
|
|
y: [{ required: true, message: '请输入设备图形的Y轴坐标', trigger: 'blur' }]
|
|
|
|
},
|
2020-01-19 14:03:32 +08:00
|
|
|
isUpdate: false,
|
2020-01-16 18:06:00 +08:00
|
|
|
showDeleteButton: false,
|
|
|
|
buttonText: '立即创建'
|
|
|
|
};
|
|
|
|
},
|
2020-01-19 14:03:32 +08:00
|
|
|
computed:{
|
|
|
|
...mapGetters('iscs', [
|
2020-01-19 14:15:09 +08:00
|
|
|
'iscs'
|
2020-01-19 14:03:32 +08:00
|
|
|
])
|
|
|
|
},
|
|
|
|
watch:{
|
|
|
|
'$store.state.iscs.rightClickCount': function (val) {
|
|
|
|
const model = this.$store.getters['iscs/updateDeviceData'];
|
|
|
|
if (model._type === 'EndDoor' ) {
|
|
|
|
this.buttonText = '修改';
|
|
|
|
this.showDeleteButton = true;
|
|
|
|
this.isUpdate = true;
|
|
|
|
this.addModel.code = model.code;
|
|
|
|
this.addModel.width = model.width;
|
|
|
|
this.addModel.x = model.point.x;
|
|
|
|
this.addModel.y = model.point.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-01-16 18:06:00 +08:00
|
|
|
methods: {
|
|
|
|
onSubmit(form) {
|
|
|
|
this.$refs[form].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const maButtonModel = {
|
|
|
|
point: {
|
|
|
|
x: this.addModel.x,
|
|
|
|
y: this.addModel.y
|
|
|
|
},
|
2020-02-05 17:43:15 +08:00
|
|
|
code: this.isUpdate ? this.addModel.code : getUID('EndDoor', this.iscs.endDoorList),
|
2020-01-19 14:03:32 +08:00
|
|
|
_type: 'EndDoor',
|
2020-01-16 18:06:00 +08:00
|
|
|
width: this.addModel.width
|
|
|
|
};
|
|
|
|
this.$emit('createDataModel', maButtonModel);
|
|
|
|
this.initPage();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
deleteDevice() {
|
|
|
|
const maButtonModel = {
|
|
|
|
point: {
|
|
|
|
x: this.addModel.x,
|
|
|
|
y: this.addModel.y
|
|
|
|
},
|
|
|
|
code: this.addModel.code,
|
2020-01-19 14:03:32 +08:00
|
|
|
_type: 'EndDoor',
|
2020-01-16 18:06:00 +08:00
|
|
|
width: this.addModel.width
|
|
|
|
};
|
|
|
|
this.$emit('deleteDataModel', maButtonModel);
|
|
|
|
this.initPage();
|
|
|
|
},
|
|
|
|
initPage() {
|
|
|
|
this.isUpdate = false;
|
|
|
|
this.buttonText = '立即创建';
|
|
|
|
this.showDeleteButton = false;
|
|
|
|
this.addModel = {
|
|
|
|
code: '',
|
|
|
|
width: 25,
|
|
|
|
x: 10,
|
|
|
|
y: 10
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|