rt-sim-training-client/src/views/iscs/iscsDraw/icscComponents/picture.vue

155 lines
5.3 KiB
Vue
Raw Normal View History

2020-09-22 18:03:46 +08:00
<template>
<div style="overflow-y: scroll;height: calc(100% - 46px); width: 100%;">
<el-form ref="form" :rules="rules" :model="form" label-width="80px" style="width: 100%;padding: 10px 50px;">
2020-09-23 10:22:52 +08:00
<!-- <el-form-item label="大小:" prop="size">
2020-09-22 18:03:46 +08:00
<el-input-number v-model="form.size" controls-position="right" :min="1" size="small" />
2020-09-23 10:22:52 +08:00
</el-form-item> -->
2020-09-22 18:03:46 +08:00
<el-form-item label="图片类型:" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" size="small">
<el-option v-for="(item, index) in typeList" :key="index" :label="item.name" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="宽度:" prop="width">
<el-input-number v-model="form.width" controls-position="right" :min="1" size="small" />
</el-form-item>
<el-form-item label="高度:" prop="height">
<el-input-number v-model="form.height" controls-position="right" :min="1" size="small" />
</el-form-item>
<el-form-item label="X轴坐标:">
<el-input-number v-model="form.x" controls-position="right" :min="1" size="small" />
</el-form-item>
<el-form-item label="Y轴坐标:">
<el-input-number v-model="form.y" controls-position="right" :min="1" size="small" />
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="onSubmit('form')">{{ buttonText }}</el-button>
<el-button v-show="showDeleteButton" size="small" type="danger" @click="deleteDevice">删除</el-button>
<el-button v-show="showDeleteButton" size="small" @click="initPage">取消</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import {getUID} from '@/iscs/utils/Uid';
export default {
name: 'IscsPicture',
components: {
},
data() {
return {
isUpdate: false,
buttonText: '立即创建',
showDeleteButton: false,
form: {
code: '',
type: '',
size: 10,
width: 50,
height: 50,
x: 10,
y: 10
},
typeList: [
2020-09-23 10:22:52 +08:00
{ name: '车头', value: 'psdLeft' },
2020-09-23 18:44:00 +08:00
{ name: '车尾', value: 'psdRight' },
2020-09-27 16:12:25 +08:00
{ name: '车厢', value: 'psdSystem' },
{ name: 'APF', value: 'APF'}
],
2020-09-22 18:03:46 +08:00
rules: {
strokeColor: [
{ required: true, message: '请选择边框颜色', trigger: 'change' }
],
fillColor: [
{ required: true, message: '请选择矩形填充颜色', trigger: 'change'}
]
}
};
},
computed:{
...mapGetters('iscs', [
'iscs'
])
},
watch:{
'$store.state.iscs.rightClickCount': function (val) {
const model = this.$store.getters['iscs/updateDeviceData'];
if (model._type === 'IscsPicture' ) {
this.buttonText = '修改';
this.showDeleteButton = true;
this.isUpdate = true;
this.form.code = model.code;
this.form.type = model.type;
this.form.size = model.size;
this.form.width = model.width;
this.form.height = model.height;
this.form.x = model.point.x;
this.form.y = model.point.y;
}
}
},
mounted() {},
methods: {
onSubmit(form) {
this.$refs[form].validate((valid) => {
if (valid) {
const rectModel = {
point: {
x: this.form.x,
y: this.form.y
},
2020-09-23 10:22:52 +08:00
code: this.isUpdate ? this.form.code : getUID('IscsPicture', this.iscs.iscsPictureList),
2020-09-22 18:03:46 +08:00
_type: 'IscsPicture',
type: this.form.type,
size: this.form.size,
width: this.form.width,
height: this.form.height
};
this.$emit('createDataModel', rectModel);
this.initPage();
} else {
return false;
}
});
},
deleteDevice() {
const rectModel = {
point: {
x: this.form.x,
y: this.form.y
},
code: this.form.code,
_type: 'IscsPicture',
type: this.form.type,
size: this.form.size
};
this.$emit('deleteDataModel', rectModel);
},
initPage() {
this.isUpdate = false;
this.buttonText = '立即创建';
this.showDeleteButton = false;
this.form = {
code: '',
type: '',
size: 10,
width: 50,
height: 50,
x: 10,
y: 10
};
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.button_box{
width: 100%;
background: #f0f0f0;
overflow: hidden;
}
</style>