132 lines
4.3 KiB
Vue
132 lines
4.3 KiB
Vue
<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;">
|
|
<el-form-item label="半径:" prop="r">
|
|
<el-input-number v-model="form.r" size="small" controls-position="right" :min="1" />
|
|
</el-form-item>
|
|
<el-form-item label="填充色:" prop="fillColor">
|
|
<el-color-picker v-model="form.fillColor" size="small" />
|
|
</el-form-item>
|
|
<el-form-item label="X轴坐标:">
|
|
<el-input-number v-model="form.x" controls-position="right" size="small" :min="1" />
|
|
</el-form-item>
|
|
<el-form-item label="Y轴坐标:">
|
|
<el-input-number v-model="form.y" controls-position="right" size="small" :min="1" />
|
|
</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: 'ArcStatus',
|
|
components: {
|
|
},
|
|
data() {
|
|
return {
|
|
isUpdate: false,
|
|
buttonText: '立即创建',
|
|
showDeleteButton: false,
|
|
form: {
|
|
code: '',
|
|
fillColor: '',
|
|
r: 7,
|
|
x: 10,
|
|
y: 10
|
|
},
|
|
rules: {
|
|
r: [
|
|
{ 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 === 'ArcStatus' ) {
|
|
this.buttonText = '修改';
|
|
this.showDeleteButton = true;
|
|
this.isUpdate = true;
|
|
this.form.code = model.code;
|
|
this.form.fillColor = model.fillColor;
|
|
this.form.r = model.r;
|
|
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
|
|
},
|
|
code: this.isUpdate ? this.form.code : getUID('ArcStatus', this.iscs.arcStatusList),
|
|
_type: 'ArcStatus',
|
|
fillColor: this.form.fillColor,
|
|
r: this.form.r
|
|
};
|
|
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: 'ArcStatus',
|
|
fillColor: this.form.fillColor,
|
|
r: this.form.r
|
|
};
|
|
this.$emit('deleteDataModel', rectModel);
|
|
},
|
|
initPage() {
|
|
this.isUpdate = false;
|
|
this.buttonText = '立即创建';
|
|
this.showDeleteButton = false;
|
|
this.form = {
|
|
code: '',
|
|
fillColor: '',
|
|
r: 7,
|
|
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>
|