@newview/file-ui 1.1.45 → 1.1.47

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/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.47
2
+ 1、UploadFile优化doBeforeUpload,增加对应'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'格式文件的文件名长度检测,
3
+
4
+
1
5
  ## 1.1.43
2
6
  1、ComFormUp 修改构件选择相关配置
3
7
 
package/dist/file-ui.js CHANGED
@@ -353,19 +353,32 @@ let UploadFileInstance$1 = class UploadFileInstance extends BaseInstance {
353
353
  __publicField(this, "doBeforeUpload", (file) => {
354
354
  return new Promise(async (resolve, reject) => {
355
355
  let flag = true;
356
+ const allowedExtensions = ["doc", "docx", "ppt", "pptx", "xls", "xlsx"];
357
+ const fileName = file.name;
358
+ const temp = fileName.split(".");
359
+ const ext = temp[temp.length - 1].toLowerCase();
360
+ if (allowedExtensions.includes(ext)) {
361
+ const fileNameWithoutExt = fileName.slice(0, -(ext.length + 1));
362
+ if (fileNameWithoutExt.length > 20) {
363
+ this.message.warning("文件名长度不能超过20个字符");
364
+ flag = false;
365
+ return reject();
366
+ }
367
+ }
356
368
  if (this.props.uploadQuantity > 0) {
357
- let apiResult = await this.fileInfoApi.getEntities(QueryWrapper.create().eq("Token", this.currentToken));
369
+ let apiResult = await this.fileInfoApi.getEntities(
370
+ QueryWrapper.create().eq("Token", this.currentToken)
371
+ );
358
372
  const result = this.utilities.parseApiResult(apiResult);
359
373
  if (result && result.length >= this.props.uploadQuantity) {
360
374
  this.message.warning(`仅能上传${this.props.uploadQuantity}个附件`);
361
375
  flag = false;
362
376
  }
363
- } else {
364
- flag = true;
365
377
  }
366
378
  if (flag) {
367
379
  this.message.info("文件上传中,请稍等");
368
380
  this.multipartUpload(file);
381
+ resolve(true);
369
382
  } else {
370
383
  reject();
371
384
  }