@newview/file-ui 1.1.26 → 1.1.27

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,6 @@
1
+ ## 1.1.27
2
+ 1. UploadFile 新增控制上传附件的数量
3
+
1
4
  ## 1.1.26
2
5
  1. UploadFile 预览时根据token重新查一遍数据
3
6
 
package/dist/file-ui.js CHANGED
@@ -254,6 +254,11 @@ const propDefine$6 = {
254
254
  //只读状态且无附件信息下的显示
255
255
  type: String,
256
256
  default: "暂无附件"
257
+ },
258
+ // 控制附件上传的个数
259
+ uploadQuantity: {
260
+ type: Number,
261
+ default: 0
257
262
  }
258
263
  };
259
264
  const _sfc_main$6 = defineComponent({
@@ -335,8 +340,27 @@ let UploadFileInstance$1 = class UploadFileInstance extends BaseInstance {
335
340
  * 上传之前
336
341
  */
337
342
  __publicField(this, "doBeforeUpload", () => {
338
- this.message.info("文件上传中,请稍等");
339
- this.uploading.value = true;
343
+ return new Promise(async (resolve, reject) => {
344
+ let flag = true;
345
+ if (this.props.uploadQuantity > 0) {
346
+ let apiResult = await this.fileInfoApi.getEntities(QueryWrapper.create().eq("Token", this.currentToken));
347
+ const result = this.utilities.parseApiResult(apiResult);
348
+ if (result && result.length >= this.props.uploadQuantity) {
349
+ this.message.warning(`仅能上传${this.props.uploadQuantity}个附件`);
350
+ flag = false;
351
+ }
352
+ } else {
353
+ flag = true;
354
+ }
355
+ if (flag) {
356
+ resolve(() => {
357
+ });
358
+ this.message.info("文件上传中,请稍等");
359
+ this.uploading.value = true;
360
+ } else {
361
+ reject();
362
+ }
363
+ });
340
364
  });
341
365
  /**
342
366
  * 移除
@@ -19786,8 +19810,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
19786
19810
  readonly: _ctx.getPropValue(item.uploadFileProp, "readonly") || _ctx.onlyView,
19787
19811
  token: _ctx.formModel[item.model],
19788
19812
  multiple: _ctx.getPropValue(item.uploadFileProp, "multiple"),
19813
+ uploadQuantity: _ctx.getPropValue(item.uploadFileProp, "uploadQuantity", 0),
19789
19814
  onReturnFileList: ($event) => _ctx.tokenList($event, item)
19790
- }, null, 8, ["readonly", "token", "multiple", "onReturnFileList"])) : createCommentVNode("", true),
19815
+ }, null, 8, ["readonly", "token", "multiple", "uploadQuantity", "onReturnFileList"])) : createCommentVNode("", true),
19791
19816
  item.type === "TextEditor" ? (openBlock(), createBlock(_component_TextEditor, {
19792
19817
  key: 1,
19793
19818
  ref: "textEditorRef",