@kaiyinchem/ky-uniui 1.0.3

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.
@@ -0,0 +1,457 @@
1
+ <!--基本的选型按钮和表单左右排列的-->
2
+ <template>
3
+ <view
4
+ :class="{
5
+ top: align === 'top',
6
+ left: align === 'left',
7
+ 'left-top': align === 'left top',
8
+ 'no-border': noBorder,
9
+ 'no-arrow': noArrow || isInput,
10
+ textarea: type === 'textarea',
11
+ small,
12
+ gray,
13
+ slots: Object.keys($slots).length || isInput,
14
+ }"
15
+ :style="{ background }"
16
+ class="opt-item"
17
+ @click.stop="onClick"
18
+ >
19
+
20
+ <view class="opt-item-main">
21
+ <view class="opt-left">
22
+ <text v-if="icon && icon.indexOf('img') < 0" :style="{color: iconColor}" class="opt-icon iconfont">{{ icon }}</text>
23
+ <image v-if="icon && icon.indexOf('img') > -1" :src="icon" class="opt-img"></image>
24
+ <view :style="{width: labelWidth + 'rpx'}" class="opt-txt">
25
+ <text v-if="required" class="opt-require">*</text>
26
+ <text class="opt-label">{{ label }}</text>
27
+ </view>
28
+ </view>
29
+
30
+ <view class="opt-right">
31
+
32
+ <template v-if="!hasSlots">
33
+ <text v-if="right !== '' && type !== 'date'" class="opt-val">{{ right }}</text>
34
+ <!--由于不支持动态设置type,只能这样了-->
35
+ <view v-if="!right && isInput" class="opt-val opt-input">
36
+ <input
37
+ v-if="type === 'text'"
38
+ :placeholder="placeholder || `请输入${label}`"
39
+ :disabled="disabled"
40
+ :maxlength="maxlength"
41
+ type="text"
42
+ v-model="content"
43
+ placeholder-class="input-placeholder"
44
+ class="opt-uni-input"
45
+ @input="onInput"
46
+ @focus="$emit('focus')"
47
+ @blur="$emit('blur')"
48
+ />
49
+ <input
50
+ v-if="type === 'number'"
51
+ :placeholder="placeholder || `请输入${label}`"
52
+ :disabled="disabled"
53
+ :maxlength="maxlength"
54
+ type="number"
55
+ v-model="content"
56
+ placeholder-class="input-placeholder"
57
+ class="opt-uni-input"
58
+ @input="onInput"
59
+ @focus="$emit('focus')"
60
+ @blur="$emit('blur')"
61
+ />
62
+ <input
63
+ v-if="type === 'digit'"
64
+ :placeholder="placeholder || `请输入${label}`"
65
+ :disabled="disabled"
66
+ :maxlength="maxlength"
67
+ type="digit"
68
+ v-model="content"
69
+ placeholder-class="input-placeholder"
70
+ class="opt-uni-input"
71
+ @input="onInput"
72
+ @focus="$emit('focus')"
73
+ @blur="$emit('blur')"
74
+ />
75
+ <view v-if="type === 'textarea'" class="opt-textarea">
76
+ <textarea
77
+ :placeholder="placeholder || `请输入${label}`"
78
+ :disabled="disabled"
79
+ :maxlength="maxlength"
80
+ placeholder-class="input-placeholder"
81
+ v-model="content"
82
+ class="opt-uni-textarea"
83
+ @input="onInput"
84
+ @focus="$emit('focus')"
85
+ @blur="$emit('blur')"
86
+ >
87
+ </textarea>
88
+ </view>
89
+ </view>
90
+
91
+ <!--日期-->
92
+ <picker
93
+ v-if="type === 'date'"
94
+ :start="start"
95
+ :end="end"
96
+ :value="content"
97
+ mode="date"
98
+ style="width: 100%;"
99
+ @change="onDateChange"
100
+ >
101
+ <text class="opt-val">{{ content || placeholder || `请选择${label}` }}</text>
102
+ </picker>
103
+
104
+ </template>
105
+
106
+ <view v-else class="opt-val">
107
+ <slot></slot>
108
+ </view>
109
+
110
+ <text v-if="suffix && !$slots.suffix" class="opt-suffix">{{ suffix }}</text>
111
+ <view v-if="$slots.suffix" class="opt-suffix">
112
+ <slot name="suffix"></slot>
113
+ </view>
114
+
115
+ <text v-if="!isInput && !noArrow" :class="{'rotate': rotate}" class="opt-arrow iconfont">&#xe62a;</text>
116
+ </view>
117
+ </view>
118
+
119
+ </view>
120
+ </template>
121
+
122
+ <script>
123
+ export default {
124
+ emits:['click', 'focus', 'blur', 'update:value'],
125
+ props: {
126
+ // 左边显示的文本
127
+ label: {
128
+ type: String,
129
+ default: ''
130
+ },
131
+ // 右边显示的文本
132
+ right: {
133
+ default: ''
134
+ },
135
+ icon: {
136
+ type: String,
137
+ default: '',
138
+ },
139
+ iconColor: {
140
+ type: String,
141
+ default: '#999999',
142
+ },
143
+ value: {
144
+ type: [String, Number, Object, Array, Date],
145
+ default: '',
146
+ },
147
+ placeholder: {
148
+ type: String,
149
+ default: '',
150
+ },
151
+ noArrow: {
152
+ default: false,
153
+ type: Boolean
154
+ },
155
+ // 箭头旋转
156
+ rotate: {
157
+ default: false,
158
+ type: Boolean
159
+ },
160
+ disabled: {
161
+ default: false,
162
+ type: Boolean
163
+ },
164
+ align: {
165
+ type: String,
166
+ default: 'center',
167
+ },
168
+ noBorder: {
169
+ type: Boolean,
170
+ default: false,
171
+ },
172
+ small: {
173
+ type: Boolean,
174
+ default: false,
175
+ },
176
+ gray: {
177
+ type: Boolean,
178
+ default: false,
179
+ },
180
+ required: {
181
+ type: Boolean,
182
+ default: false,
183
+ },
184
+ /**
185
+ * 组件类型, text, number, digit, textarea, date
186
+ */
187
+ type: {
188
+ type: String,
189
+ default: 'text',
190
+ },
191
+ background: {
192
+ type: String,
193
+ default: '',
194
+ },
195
+ maxlength: {
196
+ type: [ String, Number],
197
+ default: 99,
198
+ },
199
+ labelWidth: {
200
+ type: [String, Number],
201
+ default: '',
202
+ },
203
+ // 兼容小程序,判断是否输入框,不然没法玩
204
+ isInput: {
205
+ type: Boolean,
206
+ default: false,
207
+ },
208
+ suffix: {
209
+ type: String,
210
+ default: '',
211
+ },
212
+ start: {
213
+ type: String,
214
+ default: '',
215
+ },
216
+ end: {
217
+ type: String,
218
+ default: (new Date().getFullYear() + 1) + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),
219
+ }
220
+ },
221
+ data() {
222
+ return {
223
+ content: '',
224
+ hasSlots: false,
225
+ }
226
+ },
227
+ mounted() {
228
+
229
+ this.$nextTick(function() {
230
+ this.hasSlots = Object.keys(this.$slots).filter(e => e !== 'suffix').length
231
+ })
232
+
233
+ this.content = this.value
234
+ },
235
+ watch: {
236
+ value(newVal) {
237
+ this.content = newVal
238
+ }
239
+ },
240
+ methods: {
241
+ onInput({ detail }) {
242
+ this.$emit('update:value', detail.value)
243
+ },
244
+ onClick() {
245
+ this.$emit('click')
246
+ },
247
+ onDateChange({ detail }) {
248
+ const val = detail.value.replace(/-/g, '/')
249
+ this.content = val
250
+ this.$emit('update:value', val)
251
+ },
252
+ }
253
+ }
254
+ </script>
255
+
256
+ <style scoped lang="scss">
257
+ .opt-item {
258
+ padding: 0 24rpx;
259
+ background: var(--bg-white);
260
+ .opt-item-main {
261
+ padding: 12rpx 0;
262
+ flex: 1;
263
+ display: flex;
264
+ flex-direction: row;
265
+ align-items: center;
266
+ position: relative;
267
+ justify-content: space-between;
268
+ border-bottom: 1px solid var(--border-1);
269
+ }
270
+ .opt-suffix {
271
+ display: inline-block;
272
+ margin-left: 12rpx;
273
+ color: var(--color-gray);
274
+ flex-shrink: 0;
275
+ }
276
+
277
+ &.textarea {
278
+ display: block;
279
+ justify-content: initial;
280
+ &.left {
281
+ .opt-item-main {
282
+ align-items: flex-start;
283
+ }
284
+ .opt-textarea {
285
+ margin-top: 0;
286
+ flex: 1;
287
+ }
288
+ .opt-right {
289
+ display: flex;
290
+ flex: 1;
291
+ }
292
+ }
293
+ .opt-textarea {
294
+ padding: 24rpx;
295
+ display: flex;
296
+ background-color: var(--bg-gray);
297
+ border-radius: 12rpx;
298
+ .opt-uni-textarea {
299
+ flex: 1;
300
+ height: 120rpx;
301
+ width: 100%;
302
+ line-height: normal
303
+ }
304
+ }
305
+ .opt-left {
306
+ display: block;
307
+ flex: none;
308
+ }
309
+ .opt-right {
310
+ display: block;
311
+ flex: none;
312
+ justify-content: initial;
313
+ }
314
+ }
315
+
316
+ &:active {
317
+ background-color: var(--bg-gray);
318
+ }
319
+ &.slots {
320
+ &:active {
321
+ background-color: var(--bg-gray)!important;
322
+ }
323
+ .opt-val {
324
+ width: 100%;
325
+ }
326
+ }
327
+ &.no-arrow {
328
+ &:active {
329
+ background-color: var(--bg-white)!important;
330
+ }
331
+ .opt-val {
332
+ margin-right: 0;
333
+ }
334
+ }
335
+ &.small {
336
+ padding: 15rpx 24rpx;
337
+ .opt-txt, .opt-val {
338
+ font-size: 24rpx;
339
+ }
340
+ .opt-icon, .opt-img {
341
+ font-size: 30rpx;
342
+ width: 30rpx;
343
+ }
344
+ }
345
+ &.gray {
346
+ .opt-txt {
347
+ color: var(--color-gray);
348
+ }
349
+ .opt-val {
350
+ color: var(--color-dark);
351
+ }
352
+ }
353
+ &.left-top {
354
+ align-items: flex-start;
355
+ justify-content: flex-start;
356
+ .opt-right {
357
+ justify-content: flex-start;
358
+ }
359
+ }
360
+ &.top {
361
+ align-items: flex-start;
362
+ }
363
+ &.end {
364
+ align-items: flex-end;
365
+ }
366
+ &.left {
367
+ justify-content: flex-start;
368
+ .opt-txt {
369
+ width: 140rpx;
370
+ }
371
+ .opt-right {
372
+ justify-content: flex-start;
373
+ }
374
+ .opt-val {
375
+ text-align: left;
376
+ }
377
+ }
378
+ /* #ifndef MP-WEIXIN */
379
+ &:last-child .opt-item-main {
380
+ border: 0;
381
+ }
382
+ /* #endif */
383
+
384
+ &.no-border .opt-item-main {
385
+ border: 0;
386
+ }
387
+ .opt-left {
388
+ flex-shrink: 0;
389
+ display: flex;
390
+ align-items: center;
391
+ margin-right: 24rpx;
392
+ }
393
+ .opt-right {
394
+ flex: 1;
395
+ display: flex;
396
+ align-items: center;
397
+ position: relative;
398
+ justify-content: flex-end;
399
+ min-height: 65rpx;
400
+ }
401
+ .opt-icon, .opt-img {
402
+ display: inline-block;
403
+ font-size: 38rpx;
404
+ width: 38rpx;
405
+ color: var(--color-gray);
406
+ margin-right: 12rpx;
407
+ }
408
+ .opt-img {
409
+ height: 38rpx;
410
+ }
411
+ .opt-txt {
412
+ display: flex;
413
+ align-items: center;
414
+ color: var(--color-dark);
415
+ }
416
+ .opt-arrow {
417
+ display: block;
418
+ font-size: 26rpx;
419
+ color: var(--color-gray);
420
+ position: absolute;
421
+ right: 0;
422
+ transition: all 0.3s;
423
+ &.rotate {
424
+ transform: rotate(90deg)
425
+ }
426
+ }
427
+ .opt-val{
428
+ flex: 1;
429
+ display: block;
430
+ text-align: right;
431
+ margin-right: 48rpx;
432
+ color: var(--color-gray);
433
+ }
434
+ .opt-require {
435
+ color: #FF152D;
436
+ }
437
+ .opt-date {
438
+ display: flex;
439
+ align-items: center;
440
+ }
441
+ .opt-input {
442
+ margin-right: 0;
443
+ height: 100%;
444
+ min-height: 65rpx;
445
+ line-height: 65rpx;
446
+ background: var(--bg-gray);
447
+ color: inherit;
448
+ display: flex;
449
+ align-items: center;
450
+ border-radius: 8rpx;
451
+ .opt-uni-input {
452
+ flex: 1;
453
+ padding: 0 1em;
454
+ }
455
+ }
456
+ }
457
+ </style>
@@ -0,0 +1,93 @@
1
+ <!--cchekbox组件 2020-9-28 zzc添加-->
2
+ <template>
3
+ <view :class="{
4
+ small: size === 'small',
5
+ large: size === 'large',
6
+ normal: size === 'normal',
7
+ disabled,
8
+ }"
9
+ class="pop-check">
10
+ <text v-if="!active" class="no iconfont" >&#xe619;</text>
11
+ <text v-else class="primary-color yes iconfont">&#xe61b;</text>
12
+ <text v-if="label" :class="{ 'primary-color': active }" class="check-label">{{ label }}</text>
13
+ </view>
14
+ </template>
15
+
16
+ <script>
17
+ export default {
18
+ props: {
19
+ checked: {
20
+ type: Boolean,
21
+ default: false,
22
+ },
23
+ label: {
24
+ type: String,
25
+ default: ''
26
+ },
27
+ // small, normal, large
28
+ size: {
29
+ type: String,
30
+ default: ''
31
+ },
32
+ disabled: {
33
+ type: Boolean,
34
+ default: false,
35
+ }
36
+ },
37
+ data() {
38
+ return {
39
+ active: false
40
+ }
41
+ },
42
+ mounted() {
43
+ this.active = this.checked
44
+ },
45
+ watch: {
46
+ checked(v) {
47
+ this.active = v
48
+ }
49
+ },
50
+ }
51
+ </script>
52
+
53
+ <style scoped lang="scss">
54
+ .pop-check {
55
+ display: flex;
56
+ align-items: center;
57
+ height: 40rpx;
58
+ &.disabled {
59
+ text {
60
+ color: var(--color-gray);
61
+ }
62
+ }
63
+ &.small {
64
+ height: 34rpx;
65
+ .iconfont {
66
+ font-size: 34rpx;
67
+ }
68
+ .check-label {
69
+ font-size: 24rpx;
70
+ }
71
+ }
72
+ &.large {
73
+ height: 60rpx;
74
+ .iconfont {
75
+ font-size: 60rpx;
76
+ }
77
+ .check-label {
78
+ font-size: 32rpx;
79
+ }
80
+ }
81
+ .iconfont {
82
+ display: inline-block;
83
+ font-size: 40rpx;
84
+ &.no {
85
+ color: var(--color-light-gray);
86
+ }
87
+ }
88
+ .check-label {
89
+ display: inline-block;
90
+ margin-left: 12rpx;
91
+ }
92
+ }
93
+ </style>