openatc-components 0.0.111 → 0.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,7 @@
21
21
  <el-input-number :min="0" :controls="false"
22
22
  ref="refNumber-x"
23
23
  v-model="basicCoodInfo.x"
24
+ @change="handleChangePosX"
24
25
  @input.native="eventChange('x')" />
25
26
  </el-form-item>
26
27
  <el-form-item
@@ -29,6 +30,7 @@
29
30
  <el-input-number :min="0" :controls="false"
30
31
  ref="refNumber-y"
31
32
  v-model="basicCoodInfo.y"
33
+ @change="handleChangePosY"
32
34
  @input.native="eventChange('y')" />
33
35
  </el-form-item>
34
36
  <el-form-item
@@ -38,6 +40,7 @@
38
40
  <el-input-number :min="0" :max="360" :controls="false"
39
41
  ref="refNumber-angle"
40
42
  v-model="basicCoodInfo.angle"
43
+ @change="handleChangeAngle"
41
44
  @input.native="eventChange('angle')" />
42
45
  </el-form-item>
43
46
  </el-form>
@@ -80,9 +83,54 @@ export default {
80
83
  },
81
84
  methods: {
82
85
  eventChange (field) {
86
+ // 解决change事件只在失去焦点时响应,此处,可以监听到实时变化
83
87
  const key = this.$refs[`refNumber-${field}`].displayValue
84
- this.basicCoodInfo[field] = Number(key)
85
- this.$emit('handleChangeBasicCoord', this.basicCoodInfo)
88
+ if (this.checkOnlyNum(key)) {
89
+ this.basicCoodInfo[field] = field === 'angle' ? this.checkMinMaxNum(key) : Number(key)
90
+ this.$emit('handleChangeBasicCoord', this.basicCoodInfo)
91
+ }
92
+ },
93
+ handleChangePosX (Xvalue) {
94
+ // 解决用上下箭头控制数字改变
95
+ if (this.checkOnlyNum(Xvalue)) {
96
+ this.basicCoodInfo['x'] = Number(Xvalue)
97
+ this.$emit('handleChangeBasicCoord', this.basicCoodInfo)
98
+ }
99
+ },
100
+ handleChangePosY (Yvalue) {
101
+ // 解决用上下箭头控制数字改变
102
+ if (this.checkOnlyNum(Yvalue)) {
103
+ this.basicCoodInfo['y'] = Number(Yvalue)
104
+ this.$emit('handleChangeBasicCoord', this.basicCoodInfo)
105
+ }
106
+ },
107
+ handleChangeAngle (angle) {
108
+ // 解决用上下箭头控制数字改变
109
+ if (this.checkOnlyNum(angle)) {
110
+ this.basicCoodInfo['angle'] = this.checkMinMaxNum(angle)
111
+ this.$emit('handleChangeBasicCoord', this.basicCoodInfo)
112
+ }
113
+ },
114
+ checkOnlyNum (numString) {
115
+ // eslint-disable-next-line no-new-wrappers
116
+ let num = new Number(numString)
117
+ if (num.toString() === 'NaN') {
118
+ // 校验输入非数字则不生效
119
+ return false
120
+ } else {
121
+ return true
122
+ }
123
+ },
124
+ checkAngleMinMaxNum (numString) {
125
+ // 控制角度范围
126
+ let num = Number(numString)
127
+ if (num > 360) {
128
+ return 360
129
+ } else if (num < 0) {
130
+ return 0
131
+ } else {
132
+ return num
133
+ }
86
134
  },
87
135
  isShowAngleSetting () {
88
136
  this.showAngle = true