201 lines
7.8 KiB
Vue
201 lines
7.8 KiB
Vue
|
<template>
|
||
|
<div style="overflow-y: scroll;height: calc(100% - 46px);">
|
||
|
<el-form ref="form" :rules="rules" :model="form" label-width="120px">
|
||
|
<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">
|
||
|
<el-input-number v-model="form.width" :min="1" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="高度:" prop="height">
|
||
|
<el-input-number v-model="form.height" :min="1" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="顶部文字内容:" prop="topContext">
|
||
|
<el-input v-model="form.topContext" type="textarea" :rows="2" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="顶部字体大小:" prop="topFontSize">
|
||
|
<el-input-number v-model="form.topFontSize" :min="1" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="顶部字体颜色:" prop="topTextFill">
|
||
|
<el-color-picker v-model="form.topTextFill" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="底部文字内容:" prop="bottomContext">
|
||
|
<el-input v-model="form.bottomContext" type="textarea" :row="2" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="底部字体大小:" prop="bottomFontSize">
|
||
|
<el-input-number v-model="form.bottomFontSize" :min="1" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="底部字体颜色:" prop="bottomTextFill">
|
||
|
<el-color-picker v-model="form.bottomTextFill" />
|
||
|
</el-form-item>
|
||
|
<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:'AirConditioner',
|
||
|
data() {
|
||
|
return {
|
||
|
isUpdate:false,
|
||
|
showDeleteButton: false,
|
||
|
buttonText: '立即创建',
|
||
|
form:{
|
||
|
code:'',
|
||
|
width: 110,
|
||
|
height: 60,
|
||
|
topContext: '',
|
||
|
topFontSize: 10,
|
||
|
topTextFill: '#B4AF5B',
|
||
|
bottomContext: '',
|
||
|
bottomFontSize: 18,
|
||
|
bottomTextFill: '#FFFFFF',
|
||
|
x: 10,
|
||
|
y: 10
|
||
|
},
|
||
|
rules: {
|
||
|
width:[
|
||
|
{ required: true, message:'请输入设备图形宽度', trigger: 'blur' }
|
||
|
],
|
||
|
height: [
|
||
|
{ required: true, message: '请输入设备图形高度', trigger: 'blur'}
|
||
|
],
|
||
|
topContext: [
|
||
|
{ required: true, message: '请输入顶部文字内容', trigger: 'blur'}
|
||
|
],
|
||
|
topFontSize: [
|
||
|
{required: true, message: '请输入顶部字体大小', trigger: 'blur'}
|
||
|
],
|
||
|
topTextFill: [
|
||
|
{required: true, message: '请输入顶部字体颜色', trigger: 'blur'}
|
||
|
],
|
||
|
bottomContext: [
|
||
|
{required: true, message: '请输入底部文字内容', trigger: 'blur'}
|
||
|
],
|
||
|
bottomFontSize: [
|
||
|
{required: true, message: '请输入底部字体大小', trigger: 'blur'}
|
||
|
],
|
||
|
bottomTextFill: [
|
||
|
{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 === 'LightingGroup' ) {
|
||
|
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;
|
||
|
this.form.height = model.height;
|
||
|
this.form.topContext = model.topContext;
|
||
|
this.form.topFontSize = model.topFontSize;
|
||
|
this.form.topTextFill = model.topTextFill;
|
||
|
this.form.bottomContext = model.bottomContext;
|
||
|
this.form.bottomFontSize = model.bottomFontSize;
|
||
|
this.form.bottomTextFill = model.bottomTextFill;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
mounted() {
|
||
|
|
||
|
},
|
||
|
methods:{
|
||
|
onSubmit(form) {
|
||
|
this.$refs[form].validate((valid) => {
|
||
|
if (valid) {
|
||
|
const airConditionerModel = {
|
||
|
point: {
|
||
|
x: this.form.x,
|
||
|
y: this.form.y
|
||
|
},
|
||
|
_type: 'LightingGroup',
|
||
|
code: this.isUpdate ? this.form.code : getUID('LightingGroup', this.iscs.lightingGroupList),
|
||
|
width: this.form.width,
|
||
|
height:this.form.height,
|
||
|
topContext: this.form.topContext,
|
||
|
topFontSize: this.form.topFontSize,
|
||
|
topTextFill: this.form.topTextFill,
|
||
|
bottomContext: this.form.bottomContext,
|
||
|
bottomFontSize: this.form.bottomFontSize,
|
||
|
bottomTextFill: this.form.bottomTextFill
|
||
|
};
|
||
|
this.$emit('createDataModel', airConditionerModel);
|
||
|
this.initPage();
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
},
|
||
|
initPage() {
|
||
|
this.isUpdate = false;
|
||
|
this.buttonText = '立即创建';
|
||
|
this.showDeleteButton = false;
|
||
|
this.form = {
|
||
|
code:'',
|
||
|
width: 110,
|
||
|
height: 60,
|
||
|
topContext: '',
|
||
|
topFontSize: 10,
|
||
|
topTextFill: '#B4AF5B',
|
||
|
bottomContext: '',
|
||
|
bottomFontSize: 18,
|
||
|
bottomTextFill: '#FFFFFF',
|
||
|
x: 10,
|
||
|
y: 10
|
||
|
};
|
||
|
this.$refs.form.resetFields();
|
||
|
},
|
||
|
deleteDevice() {
|
||
|
const lightingGroupModel = {
|
||
|
point: {
|
||
|
x: this.form.x,
|
||
|
y: this.form.y
|
||
|
},
|
||
|
_type: 'LightingGroup',
|
||
|
code: this.form.code,
|
||
|
width: this.form.width,
|
||
|
height:this.form.height,
|
||
|
topContext: this.form.topContext,
|
||
|
topFontSize: this.form.topFontSize,
|
||
|
topTextFill: this.form.topTextFill,
|
||
|
bottomContext: this.form.bottomContext,
|
||
|
bottomFontSize: this.form.bottomFontSize,
|
||
|
bottomTextFill: this.form.bottomTextFill
|
||
|
};
|
||
|
this.$emit('deleteDataModel', lightingGroupModel );
|
||
|
this.initPage();
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
</script>
|