doway-coms 1.8.6 → 1.8.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doway-coms",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
@@ -264,6 +264,7 @@
264
264
  :columns="col.columns"
265
265
  :pageSize="col.pageSize"
266
266
  :immediate="col.immediate"
267
+ :percent="col.percent"
267
268
  @preSearch="preSearch"
268
269
  @selectChanged="
269
270
  (rowInfo) => {
@@ -1,33 +1,46 @@
1
1
  <template>
2
- <div class="d-control-container">
3
- <div
4
- class="d-control-label"
5
- v-if="showLabel === true"
6
- :style="{ width: labelWidth > 0 ? labelWidth + 'px' : 'none' }"
2
+ <div class="d-control-container">
3
+ <div
4
+ class="d-control-label"
5
+ v-if="showLabel === true"
6
+ :style="{ width: labelWidth > 0 ? labelWidth + 'px' : 'none' }"
7
+ >
8
+ {{ label }}
9
+ <span
10
+ v-if="rules && Object.getOwnPropertyNames(rules).length > 0"
11
+ class="d-control-label-required"
12
+ >*</span
7
13
  >
8
- {{ label
9
- }}
10
- <span
11
- v-if="rules && Object.getOwnPropertyNames(rules).length > 0"
12
- class="d-control-label-required"
13
- >*</span
14
- >
15
- <Tooltip :title="tooltip" v-if="tooltip" style="margin: 0 2px">
16
- <img src="../../styles/icon/help.png" alt="" style="width: 14px">
17
- </Tooltip>
18
- </div>
19
- <div
20
- :class="{
21
- 'd-control': showLabel === true,
22
- 'd-grid-control': showLabel === false
23
- }"
14
+ <Tooltip :title="tooltip" v-if="tooltip" style="margin: 0 2px">
15
+ <img src="../../styles/icon/help.png" alt="" style="width: 14px">
16
+ </Tooltip>
17
+ </div>
18
+ <div
19
+ :class="{
20
+ 'd-control': showLabel === true,
21
+ 'd-grid-control': showLabel === false
22
+ }"
23
+ >
24
+ <ValidationProvider
25
+ :name="label"
26
+ v-slot="v"
27
+ :rules="rules"
28
+ v-if="edit === true"
24
29
  >
25
- <ValidationProvider
26
- :name="label"
27
- v-slot="v"
28
- :rules="rules"
29
- v-if="edit === true"
30
- >
30
+ <span v-if="percent">
31
+ <InputNumber
32
+ :size="'small'"
33
+ v-model="percentValue"
34
+ @change="numberChange"
35
+ @blur="blur"
36
+ :placeholder="placeholder"
37
+ :formatter="numberFormatter"
38
+ :parser="numberParse"
39
+ style="width: 100%"
40
+ :class="{ 'd-error-input': v.errors.length > 0 }"
41
+ />
42
+ </span>
43
+ <span v-else>
31
44
  <InputNumber
32
45
  :size="'small'"
33
46
  v-model="currentValue"
@@ -39,192 +52,216 @@
39
52
  style="width: 100%"
40
53
  :class="{ 'd-error-input': v.errors.length > 0 }"
41
54
  />
42
- <div class="d-error-msg">
43
- {{ v.errors[0] }}
44
- </div>
45
- </ValidationProvider>
55
+ </span>
56
+ <div class="d-error-msg">
57
+ {{ v.errors[0] }}
58
+ </div>
59
+ </ValidationProvider>
60
+ <span v-else>
61
+ <span v-if="percent">{{ currentValue*100 }}%</span>
46
62
  <span v-else>{{ currentValue }}</span>
47
- </div>
63
+ </span>
48
64
  </div>
49
- </template>
50
-
51
- <script>
52
- import XEUtils from 'xe-utils'
53
- import { InputNumber } from 'ant-design-vue'
54
- import { ValidationProvider } from 'vee-validate'
55
- import { Tooltip } from 'ant-design-vue'
65
+ </div>
66
+ </template>
56
67
 
57
- export default {
58
- name: 'BaseNumberInput',
59
- components:{
60
- InputNumber,
61
- ValidationProvider,
62
- Tooltip,
68
+ <script>
69
+ import XEUtils from 'xe-utils'
70
+ import { InputNumber } from 'ant-design-vue'
71
+ import { ValidationProvider } from 'vee-validate'
72
+ import { Tooltip } from 'ant-design-vue'
63
73
 
74
+ export default {
75
+ name: 'BaseNumberInput',
76
+ components:{
77
+ InputNumber,
78
+ ValidationProvider,
79
+ Tooltip,
80
+
81
+ },
82
+ data() {
83
+ return {
84
+ testValue: 0,
85
+ filterValue: '',
86
+ isInputChanged: false,
87
+ inputTimeout: null,
88
+ searchRows: [],
89
+ filterCols: [],
90
+ gridLoading: false,
91
+ gridPagerConfig: {
92
+ total: 0,
93
+ currentPage: 1,
94
+ pageSize: 10
95
+ },
96
+ percentValue: 0,
97
+ }
64
98
  },
65
- data() {
66
- return {
67
- testValue: 0,
68
- filterValue: '',
69
- isInputChanged: false,
70
- inputTimeout: null,
71
- searchRows: [],
72
- filterCols: [],
73
- gridLoading: false,
74
- gridPagerConfig: {
75
- total: 0,
76
- currentPage: 1,
77
- pageSize: 10
99
+ computed: {
100
+ currentValue: {
101
+ // 动态计算currentValue的值
102
+ get: function() {
103
+ if (this.percent) {
104
+ this.percentValue = this.value*100
105
+ }
106
+ return this.value // 将props中的value赋值给currentValue
107
+ },
108
+ set: function(val) {
109
+ if (val === '') {
110
+ val = 0
78
111
  }
112
+ if (XEUtils.isNumber(val)) {
113
+ this.$emit('input', val)
114
+ }
115
+ // 通过$emit触发父组件
116
+ }
117
+ }
118
+ },
119
+ props: {
120
+ showLabel: {
121
+ type: Boolean,
122
+ default: function() {
123
+ return true
79
124
  }
80
125
  },
81
- computed: {
82
- currentValue: {
83
- // 动态计算currentValue的值
84
- get: function() {
85
- return this.value // 将props中的value赋值给currentValue
86
- },
87
- set: function(val) {
88
- if (val === '') {
89
- val = 0
90
- }
91
- if (XEUtils.isNumber(val)) {
92
- this.$emit('input', val)
93
- }
94
- // 通过$emit触发父组件
95
- }
126
+ labelWidth: {
127
+ type: Number,
128
+ default: function() {
129
+ return 0
96
130
  }
97
131
  },
98
- props: {
99
- showLabel: {
100
- type: Boolean,
101
- default: function() {
102
- return true
103
- }
104
- },
105
- labelWidth: {
106
- type: Number,
107
- default: function() {
108
- return 0
109
- }
110
- },
111
- value: {
112
- type: Number,
113
- default: function() {
114
- return 0
115
- }
116
- },
117
- max: {
118
- //最大值
119
- type: Number,
120
- default: function() {
121
- return null
122
- }
123
- },
124
- min: {
125
- //最小值
126
- type: Number,
127
- default: function() {
128
- return 0
129
- }
130
- },
131
- precision: {
132
- //小数位精度
133
- type: Number,
134
- default: function() {
135
- return 0
136
- }
137
- },
138
- rules: {
139
- type: Object,
140
- default: function() {
141
- return null
142
- }
143
- },
144
- edit: {
145
- type: Boolean,
146
- default: function() {
147
- return false
148
- }
149
- },
150
- name: {
151
- type: String,
152
- default: function() {
153
- return ''
154
- }
155
- },
156
- label: {
157
- type: String,
158
- default: function() {
159
- return ''
160
- }
161
- },
162
- placeholder: {
163
- type: String,
164
- default: function() {
165
- return ''
166
- }
167
- },
168
- tooltip: {
169
- type: String,
170
- default: function() {
171
- return ''
172
- }
132
+ value: {
133
+ type: Number,
134
+ default: function() {
135
+ return 0
173
136
  }
174
137
  },
175
- created() {},
176
- methods: {
177
- numberChange(value) {
178
- this.$emit('change')
179
- },
180
- blur() {
181
- this.$emit('blur')
182
- },
183
- numberFormatter(value) {
138
+ max: {
139
+ //最大值
140
+ type: Number,
141
+ default: function() {
142
+ return null
143
+ }
144
+ },
145
+ min: {
146
+ //最小值
147
+ type: Number,
148
+ default: function() {
149
+ return 0
150
+ }
151
+ },
152
+ precision: {
153
+ //小数位精度
154
+ type: Number,
155
+ default: function() {
156
+ return 0
157
+ }
158
+ },
159
+ rules: {
160
+ type: Object,
161
+ default: function() {
162
+ return null
163
+ }
164
+ },
165
+ edit: {
166
+ type: Boolean,
167
+ default: function() {
168
+ return false
169
+ }
170
+ },
171
+ name: {
172
+ type: String,
173
+ default: function() {
174
+ return ''
175
+ }
176
+ },
177
+ label: {
178
+ type: String,
179
+ default: function() {
180
+ return ''
181
+ }
182
+ },
183
+ placeholder: {
184
+ type: String,
185
+ default: function() {
186
+ return ''
187
+ }
188
+ },
189
+ tooltip: {
190
+ type: String,
191
+ default: function() {
192
+ return ''
193
+ }
194
+ },
195
+ percent: {
196
+ type: Boolean,
197
+ default: function() {
198
+ return false
199
+ }
200
+ },
201
+ },
202
+ created() {},
203
+ methods: {
204
+ numberChange(value) {
205
+ if (this.percent) {
206
+ this.currentValue = value/100
207
+ }
208
+ this.$emit('change')
209
+ },
210
+ blur() {
211
+ this.$emit('blur')
212
+ },
213
+ numberFormatter(value) {
214
+ // 百分比格式化
215
+ if (this.percent) {
216
+ return value + '%'
217
+ }
218
+ return value
219
+ },
220
+ numberParse(value) {
221
+ // 百分比格式化
222
+ if (this.percent) {
223
+ value.replace('%', '')
224
+ }
225
+ if (value === null || value === '') {
184
226
  return value
185
- },
186
- numberParse(value) {
187
- if (value === null || value === '') {
188
- return value
189
- }
190
- let returnValue = value
191
- let tempPrecision = XEUtils.toNumber(this.precision)
192
- let reg = new RegExp(
193
- '^((-?)|(-?([1-9]{1}\\d*)|-?([0]{1})))(\\.(\\d){0,' +
194
- tempPrecision +
195
- '})?$'
196
- )
197
- if (!reg.test(value)) {
198
- //小数点验证不通过
199
- returnValue = XEUtils.floor(value, tempPrecision)
200
- }
201
- if (
202
- this.max !== null &&
203
- this.max !== undefined &&
204
- XEUtils.toNumber(returnValue) > this.max
205
- ) {
206
- returnValue = this.max
207
- }
208
- if (
209
- this.min !== null &&
210
- this.min !== undefined &&
211
- XEUtils.toNumber(returnValue) < this.min
212
- ) {
213
- returnValue = this.min
214
- }
215
- return returnValue
216
227
  }
228
+ let returnValue = value
229
+ let tempPrecision = XEUtils.toNumber(this.precision)
230
+ let reg = new RegExp(
231
+ '^((-?)|(-?([1-9]{1}\\d*)|-?([0]{1})))(\\.(\\d){0,' +
232
+ tempPrecision +
233
+ '})?$'
234
+ )
235
+ if (!reg.test(value)) {
236
+ //小数点验证不通过
237
+ returnValue = XEUtils.floor(value, tempPrecision)
238
+ }
239
+ if (
240
+ this.max !== null &&
241
+ this.max !== undefined &&
242
+ XEUtils.toNumber(returnValue) > this.max
243
+ ) {
244
+ returnValue = this.max
245
+ }
246
+ if (
247
+ this.min !== null &&
248
+ this.min !== undefined &&
249
+ XEUtils.toNumber(returnValue) < this.min
250
+ ) {
251
+ returnValue = this.min
252
+ }
253
+ return returnValue
217
254
  }
218
255
  }
219
- </script>
220
-
221
- <style lang="scss" scoped></style>
222
- <style>
223
- .ant-input-number-handler-wrap {
224
- display: none;
225
- }
226
- </style>
227
- <style lang="less">
228
- @import '../../styles/default.less';
229
- </style>
230
-
256
+ }
257
+ </script>
258
+
259
+ <style lang="scss" scoped></style>
260
+ <style>
261
+ .ant-input-number-handler-wrap {
262
+ display: none;
263
+ }
264
+ </style>
265
+ <style lang="less">
266
+ @import '../../styles/default.less';
267
+ </style>