sadais-piui 1.2.7-beta164 → 1.2.7-beta166

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.
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <view
3
+ :id="formItemId"
3
4
  class="pi-form-item"
4
5
  :style="[customStyle, itemStyle]"
5
6
  :class="getFormItemClass"
@@ -282,6 +283,13 @@ export default {
282
283
  }
283
284
  },
284
285
  computed: {
286
+ formItemId() {
287
+ // 移除标点符号,只保留英文和数字
288
+ const itemId = this.prop
289
+ ? String(this.prop).replace(/[^a-zA-Z0-9]/g, '')
290
+ : ''
291
+ return `form-item-${itemId}`
292
+ },
285
293
  getShowRightIcon() {
286
294
  return this.$pi.expand.getPropValue(
287
295
  this.inheritProps.showRightIcon,
@@ -469,6 +477,7 @@ export default {
469
477
  validation(trigger) {
470
478
  const _getResolve = () => {
471
479
  return {
480
+ formItemId: this.formItemId,
472
481
  prop: this.prop,
473
482
  validateState: this.validateState,
474
483
  validateMessage: this.validateMessage
@@ -479,10 +479,19 @@ export default {
479
479
  return this.disabled || (parent && parent.getDisabled)
480
480
  },
481
481
  actionSheetItems() {
482
+ const hasImage = this.fileTypes.includes('image');
483
+ const hasVideo = this.fileTypes.includes('video');
484
+ const mediaTypesTitle = hasImage && hasVideo
485
+ ? '图片/视频'
486
+ : hasImage
487
+ ? '图片'
488
+ : hasVideo
489
+ ? '视频'
490
+ : '';
482
491
  return [
483
492
  {
484
493
  id: 1,
485
- text: '选择媒体图片/视频'
494
+ text: `选择媒体${mediaTypesTitle}`
486
495
  },
487
496
  {
488
497
  id: 2,
@@ -676,7 +685,17 @@ export default {
676
685
  isRightType
677
686
  )
678
687
  if (!isRightType) {
679
- this.$toast(`请选择${this.getExtension.join('/')}文件上传`)
688
+ uni.showModal({
689
+ title: '文件类型错误',
690
+ content: `请选择${this.getExtension.join('、')}类型的文件上传`,
691
+ showCancel: false,
692
+ confirmText: '好的',
693
+ success: (res) => {
694
+ if (res.confirm) {
695
+ this.handleChoose()
696
+ }
697
+ }
698
+ })
680
699
  }
681
700
  return isRightType
682
701
  },
@@ -978,13 +997,17 @@ export default {
978
997
  this.showCustomTakePhoto = true
979
998
  },
980
999
  async handleChooseFile() {
981
- const { sizeType, sourceType, crop } = this.getChooseFileOpts
1000
+ const { sizeType, sourceType, crop, extension } = this.getChooseFileOpts
982
1001
  try {
1002
+ const hasImage = this.fileTypes.includes('image');
1003
+ const hasVideo = this.fileTypes.includes('video');
1004
+ const type = hasImage && hasVideo ? 'all' : hasImage ? 'image' : 'video';
1005
+
983
1006
  const [cancel, result] = await uni.chooseFile({
984
1007
  count: this.getUploadMaxCount,
985
- sizeType,
1008
+ type,
986
1009
  sourceType,
987
- crop
1010
+ extension
988
1011
  })
989
1012
 
990
1013
  if (cancel && cancel?.errMsg === 'chooseFile:fail cancel') {
@@ -1149,13 +1172,22 @@ export default {
1149
1172
  }
1150
1173
  },
1151
1174
  async handleChooseMedia() {
1152
- const { sourceType } =
1153
- this.type === 'video' ? this.getChooseVideoOpts : this.getChooseFileOpts
1154
-
1155
- this.handleUniChooseMedia(
1156
- this.type === 'video' ? ['video'] : ['mix'],
1157
- sourceType
1158
- )
1175
+ if(this.type === 'all') {
1176
+ // 选择图片/视频
1177
+ const hasImage = this.fileTypes.includes('image');
1178
+ const hasVideo = this.fileTypes.includes('video');
1179
+ const sourceType = this.getChooseFileOpts.sourceType;
1180
+ if(hasImage && hasVideo) {
1181
+ this.handleUniChooseMedia(['mix'], sourceType);
1182
+ } else if(hasImage) {
1183
+ this.handleUniChooseMedia(['image'], sourceType);
1184
+ } else if(hasVideo) {
1185
+ this.handleUniChooseMedia(['video'], sourceType);
1186
+ }
1187
+ } else {
1188
+ // 选择视频
1189
+ this.handleUniChooseMedia(['video'], this.getChooseVideoOpts.sourceType);
1190
+ }
1159
1191
  },
1160
1192
  async handleUniChooseMedia(mediaType, sourceType) {
1161
1193
  const { maxDuration, camera } =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta164",
3
+ "version": "1.2.7-beta166",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {