2020-06-05 13:24:38 +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" :rules="rules" :model="form" label-width="100px" style="width: 100%; padding: 10px 50px;">
|
|
|
|
<el-form-item v-if="isUpdate" label="编号:" prop="code">
|
|
|
|
<el-input v-model="form.code" :disabled="true" size="small" />
|
2020-06-05 13:24:38 +08:00
|
|
|
</el-form-item>
|
2020-08-12 11:02:47 +08:00
|
|
|
<el-form-item label="图形宽度:" prop="width">
|
|
|
|
<el-input-number v-model="form.width" :min="10" size="small" />
|
2020-06-05 13:24:38 +08:00
|
|
|
</el-form-item>
|
2020-08-12 11:02:47 +08:00
|
|
|
<el-form-item label="旋转角度:" prop="rotate">
|
|
|
|
<el-input-number v-model="form.rotate" size="small" />
|
2020-06-05 13:24:38 +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="form.x" controls-position="right" :min="1" size="small" />
|
2020-06-05 13:24:38 +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="form.y" controls-position="right" :min="1" size="small" />
|
2020-06-05 13:24:38 +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-06-05 13:24:38 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import {getUID} from '@/iscs/utils/Uid';
|
|
|
|
export default {
|
|
|
|
name:'AirConditioner',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isUpdate:false,
|
|
|
|
showDeleteButton: false,
|
|
|
|
buttonText: '立即创建',
|
|
|
|
form:{
|
|
|
|
code:'',
|
|
|
|
width: 20,
|
|
|
|
rotate: 0,
|
|
|
|
x: 10,
|
|
|
|
y: 10
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
code: [
|
|
|
|
{ required: true, message:'请生成设备图形的编码', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
width:[
|
|
|
|
{ required: true, message:'请输入设备图形宽度', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
x: [
|
|
|
|
{ required: true, message: '请输入设备图形的X轴坐标', trigger: 'blur' }
|
|
|
|
],
|
|
|
|
y: [
|
|
|
|
{ required: true, message: '请输入设备图形的Y轴坐标', trigger: 'blur' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed:{
|
|
|
|
...mapGetters('iscs', [
|
|
|
|
'iscs'
|
|
|
|
])
|
|
|
|
},
|
|
|
|
watch:{
|
|
|
|
'$store.state.iscs.rightClickCount': function (val) {
|
|
|
|
const model = this.$store.getters['iscs/updateDeviceData'];
|
|
|
|
if (model._type === 'Stairs' ) {
|
|
|
|
this.buttonText = '修改';
|
|
|
|
this.showDeleteButton = true;
|
|
|
|
this.isUpdate = true;
|
|
|
|
this.form.code = model.code;
|
|
|
|
this.form.width = model.width;
|
|
|
|
this.form.rotate = model.rotate || 0;
|
|
|
|
this.form.x = model.point.x;
|
|
|
|
this.form.y = model.point.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
onSubmit(form) {
|
|
|
|
this.$refs[form].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const model = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
|
|
|
},
|
|
|
|
_type: 'Stairs',
|
|
|
|
code: this.isUpdate ? this.form.code : getUID('Stairs', this.iscs.stairsList || []),
|
|
|
|
width: this.form.width,
|
|
|
|
rotate: this.form.rotate
|
|
|
|
};
|
|
|
|
this.$emit('createDataModel', model);
|
|
|
|
this.initPage();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
initPage() {
|
|
|
|
this.isUpdate = false;
|
|
|
|
this.buttonText = '立即创建';
|
|
|
|
this.showDeleteButton = false;
|
|
|
|
this.form = {
|
|
|
|
code:'',
|
|
|
|
width: 20,
|
|
|
|
x: 10,
|
|
|
|
y: 10
|
|
|
|
};
|
|
|
|
this.$refs.form.resetFields();
|
|
|
|
},
|
|
|
|
deleteDevice() {
|
|
|
|
const airConditionerModel = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
|
|
|
},
|
|
|
|
_type: 'Stairs',
|
|
|
|
code: this.form.code,
|
|
|
|
width: this.form.width
|
|
|
|
};
|
|
|
|
this.$emit('deleteDataModel', airConditionerModel );
|
|
|
|
this.initPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|