sadais-piui 1.2.7-beta126 → 1.2.7-beta128
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.
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
:style="[computedLabelStyle, getLabelStyle]"
|
|
13
13
|
:class="[{ border: getWrap && getLabelWrapBorder }]"
|
|
14
14
|
>
|
|
15
|
-
<view
|
|
15
|
+
<view
|
|
16
|
+
v-if="required"
|
|
17
|
+
style="color: #ed2235;"
|
|
18
|
+
class="pi-mg-right-12"
|
|
19
|
+
:style="[requiredStyle]"
|
|
20
|
+
>
|
|
16
21
|
*
|
|
17
22
|
</view>
|
|
18
23
|
<!-- 表单项label -->
|
|
@@ -28,7 +33,11 @@
|
|
|
28
33
|
:class="[
|
|
29
34
|
{ 'pi-flex-sub': !getWrap },
|
|
30
35
|
getInputAlign,
|
|
31
|
-
{
|
|
36
|
+
{
|
|
37
|
+
'wrap': getWrap,
|
|
38
|
+
'nowrap': !getWrap,
|
|
39
|
+
'wrap-bottom': getWrap && getWrapBottomGap
|
|
40
|
+
}
|
|
32
41
|
]"
|
|
33
42
|
:style="[contentWrapStyle]"
|
|
34
43
|
>
|
|
@@ -41,7 +50,11 @@
|
|
|
41
50
|
<slot />
|
|
42
51
|
</view>
|
|
43
52
|
<view
|
|
44
|
-
v-if="
|
|
53
|
+
v-if="
|
|
54
|
+
getErrorType === 'message' &&
|
|
55
|
+
validateState === 'error' &&
|
|
56
|
+
validateMessage
|
|
57
|
+
"
|
|
45
58
|
class="form-valid"
|
|
46
59
|
>
|
|
47
60
|
<view class="form-valid-item">{{ validateMessage }}</view>
|
|
@@ -262,6 +275,7 @@ export default {
|
|
|
262
275
|
},
|
|
263
276
|
data() {
|
|
264
277
|
return {
|
|
278
|
+
componentDestroy: false,
|
|
265
279
|
initialValue: '', // 初始值
|
|
266
280
|
validateState: 'success', // 是否校验成功
|
|
267
281
|
validateMessage: '' // 校验失败的提示语
|
|
@@ -269,10 +283,16 @@ export default {
|
|
|
269
283
|
},
|
|
270
284
|
computed: {
|
|
271
285
|
getShowRightIcon() {
|
|
272
|
-
return this.$pi.expand.getPropValue(
|
|
286
|
+
return this.$pi.expand.getPropValue(
|
|
287
|
+
this.inheritProps.showRightIcon,
|
|
288
|
+
this.showRightIcon
|
|
289
|
+
)
|
|
273
290
|
},
|
|
274
291
|
getRightIcon() {
|
|
275
|
-
const rightIcon = this.$pi.lang.mergeDeep(
|
|
292
|
+
const rightIcon = this.$pi.lang.mergeDeep(
|
|
293
|
+
this.inheritProps.rightIcon,
|
|
294
|
+
this.rightIcon
|
|
295
|
+
)
|
|
276
296
|
return this.$pi.lang.mergeDeep(formItem.rightIcon, rightIcon)
|
|
277
297
|
},
|
|
278
298
|
getBorder() {
|
|
@@ -282,7 +302,10 @@ export default {
|
|
|
282
302
|
return this.$pi.expand.getPropValue(this.inheritProps.wrap, this.wrap)
|
|
283
303
|
},
|
|
284
304
|
getWrapBottomGap() {
|
|
285
|
-
return this.$pi.expand.getPropValue(
|
|
305
|
+
return this.$pi.expand.getPropValue(
|
|
306
|
+
this.inheritProps.wrapBottomGap,
|
|
307
|
+
this.wrapBottomGap
|
|
308
|
+
)
|
|
286
309
|
},
|
|
287
310
|
getLabelWrapBorder() {
|
|
288
311
|
return this.inheritProps.labelWrapBorder !== null
|
|
@@ -293,23 +316,38 @@ export default {
|
|
|
293
316
|
return this.$pi.expand.getPropValue(this.inheritProps.colon, this.colon)
|
|
294
317
|
},
|
|
295
318
|
getDisabled() {
|
|
296
|
-
return this.$pi.expand.getPropValue(
|
|
319
|
+
return this.$pi.expand.getPropValue(
|
|
320
|
+
this.inheritProps.disabled,
|
|
321
|
+
this.disabled
|
|
322
|
+
)
|
|
297
323
|
},
|
|
298
324
|
getLabelAlign() {
|
|
299
|
-
return this.$pi.expand.getPropValue(
|
|
325
|
+
return this.$pi.expand.getPropValue(
|
|
326
|
+
this.inheritProps.labelAlign,
|
|
327
|
+
this.labelAlign
|
|
328
|
+
)
|
|
300
329
|
},
|
|
301
330
|
getInputAlign() {
|
|
302
|
-
return this.$pi.expand.getPropValue(
|
|
331
|
+
return this.$pi.expand.getPropValue(
|
|
332
|
+
this.inheritProps.inputAlign,
|
|
333
|
+
this.inputAlign
|
|
334
|
+
)
|
|
303
335
|
},
|
|
304
336
|
getErrorType() {
|
|
305
337
|
return this.inheritProps.errorType
|
|
306
338
|
},
|
|
307
339
|
getPadding() {
|
|
308
|
-
const padding = this.$pi.expand.getPropValue(
|
|
340
|
+
const padding = this.$pi.expand.getPropValue(
|
|
341
|
+
this.inheritProps.padding,
|
|
342
|
+
this.padding
|
|
343
|
+
)
|
|
309
344
|
return this.$pi.common.addUnit(padding)
|
|
310
345
|
},
|
|
311
346
|
getHeight() {
|
|
312
|
-
const height = this.$pi.expand.getPropValue(
|
|
347
|
+
const height = this.$pi.expand.getPropValue(
|
|
348
|
+
this.inheritProps.height,
|
|
349
|
+
this.height
|
|
350
|
+
)
|
|
313
351
|
return this.$pi.common.addUnit(height)
|
|
314
352
|
},
|
|
315
353
|
itemStyle() {
|
|
@@ -320,7 +358,10 @@ export default {
|
|
|
320
358
|
return style
|
|
321
359
|
},
|
|
322
360
|
getLabelStyle() {
|
|
323
|
-
return this.$pi.expand.getPropValue(
|
|
361
|
+
return this.$pi.expand.getPropValue(
|
|
362
|
+
this.inheritProps.labelStyle,
|
|
363
|
+
this.labelStyle
|
|
364
|
+
)
|
|
324
365
|
},
|
|
325
366
|
getItemVerticalAlign() {
|
|
326
367
|
return this.$pi.expand.getPropValue(
|
|
@@ -374,6 +415,12 @@ export default {
|
|
|
374
415
|
mounted() {
|
|
375
416
|
this.initRulesValidation()
|
|
376
417
|
},
|
|
418
|
+
created() {
|
|
419
|
+
this.componentDestroy = false
|
|
420
|
+
},
|
|
421
|
+
beforeDestroy() {
|
|
422
|
+
this.componentDestroy = true
|
|
423
|
+
},
|
|
377
424
|
methods: {
|
|
378
425
|
handleItemClick(e) {
|
|
379
426
|
this.$emit('click', e)
|
|
@@ -409,14 +456,16 @@ export default {
|
|
|
409
456
|
let rules = this.getRules()
|
|
410
457
|
// 整体验证表单时,triggerType为空字符串
|
|
411
458
|
if (!triggerType) return rules
|
|
412
|
-
return rules.filter(
|
|
459
|
+
return rules.filter(
|
|
460
|
+
res => res.trigger && res.trigger.indexOf(triggerType) !== -1
|
|
461
|
+
)
|
|
413
462
|
},
|
|
414
463
|
getFieldValue(obj, keypath) {
|
|
415
464
|
if (obj) {
|
|
416
465
|
return keypath.split('-').reduce((prev, key) => {
|
|
417
466
|
let tmpKey = key
|
|
418
467
|
if (/^\[\d+\]$/.test(key)) {
|
|
419
|
-
|
|
468
|
+
tmpKey = tmpKey.slice(1, -1)
|
|
420
469
|
}
|
|
421
470
|
prev = prev && prev[tmpKey]
|
|
422
471
|
return prev
|
|
@@ -435,13 +484,20 @@ export default {
|
|
|
435
484
|
}
|
|
436
485
|
return new Promise((resolve, reject) => {
|
|
437
486
|
const rules = this.getFilteredRule(trigger)
|
|
438
|
-
if (
|
|
487
|
+
if (
|
|
488
|
+
this.componentDestroy ||
|
|
489
|
+
!this.prop ||
|
|
490
|
+
!rules ||
|
|
491
|
+
rules.length === 0
|
|
492
|
+
) {
|
|
439
493
|
this.validateState = 'success'
|
|
440
494
|
this.validateMessage = ''
|
|
441
495
|
console.log(TAG, '字段无需校验', this.prop)
|
|
442
496
|
return resolve(_getResolve())
|
|
443
497
|
}
|
|
444
|
-
const fieldValue = this._parent
|
|
498
|
+
const fieldValue = this._parent
|
|
499
|
+
? this.getFieldValue(this._parent.model, this.prop)
|
|
500
|
+
: undefined
|
|
445
501
|
// 设置当前的装填,标识为校验中
|
|
446
502
|
this.validateState = 'validating'
|
|
447
503
|
// 调用async-validator的方法
|
|
@@ -465,7 +521,12 @@ export default {
|
|
|
465
521
|
resolve(_getResolve())
|
|
466
522
|
})
|
|
467
523
|
.catch(({ errors, fields }) => {
|
|
468
|
-
console.log(
|
|
524
|
+
console.log('thisthisthis', this)
|
|
525
|
+
console.log(
|
|
526
|
+
TAG,
|
|
527
|
+
'表单校验失败',
|
|
528
|
+
`字段名:${this.prop},字段值:${fieldValue}`
|
|
529
|
+
)
|
|
469
530
|
console.log(TAG, '字段值:', fieldValue)
|
|
470
531
|
console.log(TAG, '错误信息', errors)
|
|
471
532
|
console.log(TAG, '校验规则', fields)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2021-08-13 11:31:57
|
|
4
|
-
* @LastEditTime: 2024-10-
|
|
4
|
+
* @LastEditTime: 2024-10-22 10:42:41
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 图片上传组件
|
|
7
7
|
* @FilePath: /piui-awesome/src/piui/components/pi-upload-img/index.vue
|
|
@@ -35,8 +35,10 @@
|
|
|
35
35
|
class="pi-rela pi-of-hidden pi-radius-8"
|
|
36
36
|
:style="[getItemStyle]"
|
|
37
37
|
>
|
|
38
|
-
<view class="file-mask">
|
|
39
|
-
|
|
38
|
+
<view class="file-mask" :class="[{'no-bg': fileIconMap[getFileType(imgField ? img[imgField] : img)]}]">
|
|
39
|
+
<image v-if="fileIconMap[getFileType(imgField ? img[imgField] : img)]" :src="fileIconMap[getFileType(imgField ? img[imgField] : img)]" mode="widthFix" style="width: 100%;"/>
|
|
40
|
+
<template v-else>
|
|
41
|
+
<pi-icon
|
|
40
42
|
:name="
|
|
41
43
|
isVideoFilename(imgField ? img[imgField] : img)
|
|
42
44
|
? 'videofill'
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
<view class="pi-mg-top-12 pi-fz-22">
|
|
49
51
|
{{ getFileType(imgField ? img[imgField] : img) }}
|
|
50
52
|
</view>
|
|
53
|
+
</template>
|
|
51
54
|
</view>
|
|
52
55
|
</view>
|
|
53
56
|
</view>
|
|
@@ -382,6 +385,13 @@ export default {
|
|
|
382
385
|
default() {
|
|
383
386
|
return uploadImg.chooseVideoOpts
|
|
384
387
|
}
|
|
388
|
+
},
|
|
389
|
+
// 文件类型和图标映射关系,对象形式({PDF: 'https://xxx'})
|
|
390
|
+
fileIconMap: {
|
|
391
|
+
type: Object,
|
|
392
|
+
default() {
|
|
393
|
+
return uploadImg.fileIconMap
|
|
394
|
+
}
|
|
385
395
|
}
|
|
386
396
|
},
|
|
387
397
|
data() {
|
|
@@ -985,6 +995,9 @@ export default {
|
|
|
985
995
|
align-items: center;
|
|
986
996
|
justify-content: center;
|
|
987
997
|
background: rgba(0, 0, 0, 0.3);
|
|
998
|
+
&.no-bg {
|
|
999
|
+
background: transparent;
|
|
1000
|
+
}
|
|
988
1001
|
}
|
|
989
1002
|
}
|
|
990
1003
|
</style>
|
package/config/uploadImg.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2021-08-13 11:29:02
|
|
4
|
-
* @LastEditTime: 2024-
|
|
4
|
+
* @LastEditTime: 2024-10-22 10:43:21
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 图片上传
|
|
7
|
-
* @FilePath: /
|
|
7
|
+
* @FilePath: /piui-awesome/src/piui/config/uploadImg.js
|
|
8
8
|
*/
|
|
9
9
|
import icon from './icon.js'
|
|
10
10
|
import cropOption from './imgCropper.js'
|
|
@@ -77,5 +77,6 @@ export default {
|
|
|
77
77
|
},
|
|
78
78
|
beforeUpload: null, // 上传之前的钩子
|
|
79
79
|
onProgress: null, // 文件上传时的钩子
|
|
80
|
-
beforeRemove: null // 删除之前的钩子
|
|
80
|
+
beforeRemove: null, // 删除之前的钩子
|
|
81
|
+
fileIconMap: {} // 文件类型和图标映射关系,对象形式({PDF: 'https://xxx'})
|
|
81
82
|
}
|