2020-01-19 10:05:55 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<el-form ref="form" :rules="rules" :model="form" label-width="100px">
|
|
|
|
<el-form-item v-if="isUpdate" label="编号" prop="code">
|
|
|
|
<el-input v-model="form.code" :disabled="true" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="图形宽度" prop="width">
|
2020-01-20 09:25:58 +08:00
|
|
|
<el-input-number v-model="form.width" :min="20" />
|
2020-01-19 10:05:55 +08:00
|
|
|
</el-form-item>
|
2020-05-08 10:18:47 +08:00
|
|
|
<el-form-item label="旋转角度" prop="rotateAngle">
|
|
|
|
<el-select v-model="form.rotateAngle" placeholder="请选择类型">
|
|
|
|
<el-option label="0度" value="0" />
|
|
|
|
<el-option label="90度" value="90" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2020-01-19 10:05:55 +08:00
|
|
|
<el-form-item label="X轴坐标" prop="x">
|
|
|
|
<el-input-number v-model="form.x" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="Y轴坐标" prop="y">
|
|
|
|
<el-input-number v-model="form.y" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<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>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import {getUID} from '@/iscs/utils/Uid';
|
|
|
|
export default {
|
|
|
|
name:'VolumeControlDamper',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isUpdate:false,
|
|
|
|
showDeleteButton: false,
|
|
|
|
buttonText: '立即创建',
|
|
|
|
form:{
|
|
|
|
code:'',
|
2020-05-08 10:18:47 +08:00
|
|
|
rotateAngle:'0',
|
2020-01-20 09:25:58 +08:00
|
|
|
width: 20,
|
2020-01-19 10:05:55 +08:00
|
|
|
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', [
|
2020-01-19 14:09:15 +08:00
|
|
|
'iscs'
|
2020-01-19 10:05:55 +08:00
|
|
|
])
|
|
|
|
},
|
|
|
|
watch:{
|
|
|
|
'$store.state.iscs.rightClickCount': function (val) {
|
|
|
|
const model = this.$store.getters['iscs/updateDeviceData'];
|
|
|
|
if (model._type === 'VolumeControlDamper' ) {
|
|
|
|
this.buttonText = '修改';
|
|
|
|
this.showDeleteButton = true;
|
|
|
|
this.isUpdate = true;
|
|
|
|
this.form.code = model.code;
|
|
|
|
this.form.width = model.width;
|
|
|
|
this.form.x = model.point.x;
|
|
|
|
this.form.y = model.point.y;
|
2020-05-08 10:18:47 +08:00
|
|
|
this.form.rotateAngle = model.rotateAngle;
|
2020-01-19 10:05:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
onSubmit(form) {
|
|
|
|
this.$refs[form].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const newModel = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
|
|
|
},
|
2020-01-19 14:56:22 +08:00
|
|
|
_type: 'VolumeControlDamper',
|
2020-01-19 14:09:15 +08:00
|
|
|
code: this.isUpdate ? this.form.code : getUID('VolumeControlDamper', this.iscs.volumeControlDamperList),
|
2020-01-19 10:05:55 +08:00
|
|
|
width: this.form.width,
|
2020-05-08 10:18:47 +08:00
|
|
|
rotateAngle:this.form.rotateAngle,
|
2020-01-19 10:05:55 +08:00
|
|
|
color:'#00ff00'
|
|
|
|
};
|
|
|
|
this.$emit('createDataModel', newModel);
|
|
|
|
this.initPage();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
initPage() {
|
|
|
|
this.isUpdate = false;
|
|
|
|
this.buttonText = '立即创建';
|
|
|
|
this.showDeleteButton = false;
|
|
|
|
this.form = {
|
|
|
|
code:'',
|
2020-05-08 10:18:47 +08:00
|
|
|
rotateAngle:'0',
|
2020-01-20 09:25:58 +08:00
|
|
|
width: 20,
|
2020-01-19 10:05:55 +08:00
|
|
|
x: 10,
|
|
|
|
y: 10
|
|
|
|
};
|
|
|
|
this.$refs.form.resetFields();
|
|
|
|
},
|
|
|
|
deleteDevice() {
|
|
|
|
const newModel = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
|
|
|
},
|
|
|
|
_type: 'VolumeControlDamper',
|
|
|
|
code: this.form.code,
|
|
|
|
width: this.form.width,
|
2020-05-08 10:18:47 +08:00
|
|
|
rotateAngle:this.form.rotateAngle,
|
2020-01-19 10:05:55 +08:00
|
|
|
color:'#00ff00'
|
|
|
|
};
|
|
|
|
this.$emit('deleteDataModel', newModel );
|
|
|
|
this.initPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|