hbte-saas-ui 1.8.10 → 1.8.11

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.
@@ -465,6 +465,13 @@ function getNative(object, key) {
465
465
  module.exports = getNative;
466
466
 
467
467
 
468
+ /***/ }),
469
+
470
+ /***/ "0c4f":
471
+ /***/ (function(module, exports, __webpack_require__) {
472
+
473
+ // extracted by mini-css-extract-plugin
474
+
468
475
  /***/ }),
469
476
 
470
477
  /***/ "0c82":
@@ -1256,17 +1263,6 @@ _src_main_vue__WEBPACK_IMPORTED_MODULE_0__["default"].config = function (params)
1256
1263
  };
1257
1264
  /* harmony default export */ __webpack_exports__["default"] = (_src_main_vue__WEBPACK_IMPORTED_MODULE_0__["default"]);
1258
1265
 
1259
- /***/ }),
1260
-
1261
- /***/ "2070":
1262
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1263
-
1264
- "use strict";
1265
- /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_main_vue_vue_type_style_index_0_id_2c521d9c_prod_lang_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("695d");
1266
- /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_main_vue_vue_type_style_index_0_id_2c521d9c_prod_lang_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_main_vue_vue_type_style_index_0_id_2c521d9c_prod_lang_scss__WEBPACK_IMPORTED_MODULE_0__);
1267
- /* unused harmony reexport * */
1268
-
1269
-
1270
1266
  /***/ }),
1271
1267
 
1272
1268
  /***/ "2266":
@@ -24972,13 +24968,6 @@ module.exports = function isSubsetOf(other) {
24972
24968
  };
24973
24969
 
24974
24970
 
24975
- /***/ }),
24976
-
24977
- /***/ "695d":
24978
- /***/ (function(module, exports, __webpack_require__) {
24979
-
24980
- // extracted by mini-css-extract-plugin
24981
-
24982
24971
  /***/ }),
24983
24972
 
24984
24973
  /***/ "6964":
@@ -39690,6 +39679,17 @@ module.exports = function (name) {
39690
39679
  };
39691
39680
 
39692
39681
 
39682
+ /***/ }),
39683
+
39684
+ /***/ "b639":
39685
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
39686
+
39687
+ "use strict";
39688
+ /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_main_vue_vue_type_style_index_0_id_0cc572b4_prod_lang_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("0c4f");
39689
+ /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_main_vue_vue_type_style_index_0_id_0cc572b4_prod_lang_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_main_vue_vue_type_style_index_0_id_0cc572b4_prod_lang_scss__WEBPACK_IMPORTED_MODULE_0__);
39690
+ /* unused harmony reexport * */
39691
+
39692
+
39693
39693
  /***/ }),
39694
39694
 
39695
39695
  /***/ "b64e":
@@ -43670,12 +43670,12 @@ module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
43670
43670
  // ESM COMPAT FLAG
43671
43671
  __webpack_require__.r(__webpack_exports__);
43672
43672
 
43673
- // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"3c7c6be7-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/main.vue?vue&type=template&id=2c521d9c
43674
- var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{key:_vm.key,staticClass:"hb-upload"},[_c('div',{directives:[{name:"layout-flex",rawName:"v-layout-flex",value:({ gutter: 20, maxWidth: 280 }),expression:"{ gutter: 20, maxWidth: 280 }"}],staticClass:"hb-upload-wrapper"},[_vm._l((_vm.list),function(item,index){return _c('div',{key:index,staticClass:"unit-item-wrapper"},[_c('div',{staticClass:"file unit-item",on:{"click":function($event){return _vm.viewFile(item)}}},[_c('HbSvg',{attrs:{"iconClass":_vm._f("fileIcon")(true,_vm.getSuffix(item.fileName)),"fontSize":"44px"}}),_c('div',{staticClass:"right"},[_c('div',{staticClass:"title"},[_vm._v(" "+_vm._s(item.fileName)+" ")]),_c('div',{staticClass:"info"},[_c('div',{staticClass:"time"},[_vm._v(_vm._s(item.createTime))]),_c('div',{staticClass:"icon"},[(_vm.showCover)?_c('i',{staticClass:"icon-main-huanyuan mr10",on:{"click":function($event){$event.stopPropagation();return _vm.openCover(index)}}}):_vm._e(),(_vm.showDownLoad(item))?_c('i',{staticClass:"icon-main-xiazai mr10",on:{"click":function($event){$event.stopPropagation();return _vm.downloadFile(item)}}}):_vm._e(),(_vm.showRemove)?_c('i',{staticClass:"icon-main-shanchu",on:{"click":function($event){$event.stopPropagation();return _vm.remove(index, item.fileName)}}}):_vm._e()])])])],1),_vm._t("default",null,{"fileData":item})],2)}),(_vm.editAble)?_c('div',{staticClass:"upload unit-item"},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.netDisc),expression:"netDisc"}],staticClass:"netdisc",on:{"click":_vm.openNetDisc}},[_vm._v("选择网盘地址")]),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.link),expression:"link"}],staticClass:"link",on:{"click":_vm.openLink}},[_vm._v("自定义链接")]),_c('div',{staticClass:"local-file",on:{"click":_vm.openFile}},[_c('i',{staticClass:"el-icon-plus"}),_vm._v(" 上传附件 "),_c('input',{ref:"input",staticClass:"hidden",attrs:{"type":"file","multiple":""},on:{"change":_vm.chooseFile}})]),(_vm.maxUpload)?_c('div',{staticClass:"maxUploadShow"},[_vm._v(_vm._s(_vm.list.length)+" / "+_vm._s(_vm.maxUpload))]):_vm._e()]):_vm._e(),_c('input',{ref:"coverInput",staticClass:"hidden",attrs:{"type":"file"},on:{"change":function (ev) { return _vm.coverFile(ev); }}})],2),_c('NetDisc',{ref:"netDisc",on:{"submit":_vm.addNet}}),_c('CustomLink',{ref:"customLink",on:{"submit":_vm.addLink}})],1)}
43673
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"3c7c6be7-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/main.vue?vue&type=template&id=0cc572b4
43674
+ var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{key:_vm.key,staticClass:"hb-upload"},[_c('div',{directives:[{name:"layout-flex",rawName:"v-layout-flex",value:({ gutter: 20, maxWidth: 280 }),expression:"{ gutter: 20, maxWidth: 280 }"}],staticClass:"hb-upload-wrapper"},[_vm._l((_vm.list),function(item,index){return _c('div',{key:item.fileUrl || item.id || index,staticClass:"unit-item-wrapper"},[_c('div',{staticClass:"file unit-item",on:{"click":function($event){return _vm.viewFile(item)}}},[_c('HbSvg',{attrs:{"iconClass":_vm._f("fileIcon")(true,_vm.getSuffix(item.fileName)),"fontSize":"44px"}}),_c('div',{staticClass:"right"},[_c('div',{staticClass:"title"},[_vm._v(" "+_vm._s(item.fileName)+" ")]),_c('div',{staticClass:"info"},[_c('div',{staticClass:"time"},[_vm._v(_vm._s(item.createTime))]),_c('div',{staticClass:"icon"},[(_vm.showCover)?_c('i',{staticClass:"icon-main-huanyuan mr10",on:{"click":function($event){$event.stopPropagation();return _vm.openCover(index)}}}):_vm._e(),(_vm.showDownLoad(item))?_c('i',{staticClass:"icon-main-xiazai mr10",on:{"click":function($event){$event.stopPropagation();return _vm.downloadFile(item)}}}):_vm._e(),(_vm.showRemove)?_c('i',{staticClass:"icon-main-shanchu",on:{"click":function($event){$event.stopPropagation();return _vm.remove(index, item.fileName)}}}):_vm._e()])])])],1),_vm._t("default",null,{"fileData":item})],2)}),_vm._l((_vm.uploadingList),function(item,index){return _c('div',{key:'uploading-' + index,staticClass:"unit-item-wrapper"},[_c('div',{staticClass:"file unit-item"},[_c('HbSvg',{attrs:{"iconClass":_vm._f("fileIcon")(true,_vm.getSuffix(item.fileName)),"fontSize":"44px"}}),_c('div',{staticClass:"right",staticStyle:{"flex-direction":"row","align-items":"center"}},[_c('div',{staticStyle:{"flex":"1","overflow":"hidden","margin-right":"10px"}},[_c('div',{staticClass:"title"},[_vm._v(_vm._s(item.fileName))]),_c('div',{staticClass:"info"},[_vm._v(" "+_vm._s(item.status === "transmitSuccess" ? "处理中..." : "上传中...")+" ")])]),_c('div',{staticClass:"progress-wrapper"},[_c('el-progress',{attrs:{"type":"circle","percentage":Math.floor(item.progress * 100),"width":50,"stroke-width":4}}),(item.status === 'padding' || item.status === 'inline')?_c('i',{staticClass:"el-icon-close cancel-btn",on:{"click":function($event){$event.stopPropagation();return _vm.cancelUpload(item)}}}):_vm._e()],1)])],1)])}),(_vm.editAble)?_c('div',{staticClass:"upload unit-item"},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.netDisc),expression:"netDisc"}],staticClass:"netdisc",on:{"click":_vm.openNetDisc}},[_vm._v(" 选择网盘地址 ")]),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.link),expression:"link"}],staticClass:"link",on:{"click":_vm.openLink}},[_vm._v("自定义链接")]),_c('div',{staticClass:"local-file",on:{"click":_vm.openFile}},[_c('i',{staticClass:"el-icon-plus"}),_vm._v(" 上传附件 "),_c('input',{ref:"input",staticClass:"hidden",attrs:{"type":"file","multiple":""},on:{"change":_vm.chooseFile}})]),(_vm.maxUpload)?_c('div',{staticClass:"maxUploadShow"},[_vm._v(" "+_vm._s(_vm.list.length)+" / "+_vm._s(_vm.maxUpload)+" ")]):_vm._e()]):_vm._e(),_c('input',{ref:"coverInput",staticClass:"hidden",attrs:{"type":"file"},on:{"change":function (ev) { return _vm.coverFile(ev); }}})],2),_c('NetDisc',{ref:"netDisc",on:{"submit":_vm.addNet}}),_c('CustomLink',{ref:"customLink",on:{"submit":_vm.addLink}})],1)}
43675
43675
  var staticRenderFns = []
43676
43676
 
43677
43677
 
43678
- // CONCATENATED MODULE: ./packages/upload/src/main.vue?vue&type=template&id=2c521d9c
43678
+ // CONCATENATED MODULE: ./packages/upload/src/main.vue?vue&type=template&id=0cc572b4
43679
43679
 
43680
43680
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
43681
43681
  var es_array_push = __webpack_require__("14d9");
@@ -43683,6 +43683,9 @@ var es_array_push = __webpack_require__("14d9");
43683
43683
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.constructor.js
43684
43684
  var es_iterator_constructor = __webpack_require__("e9f5");
43685
43685
 
43686
+ // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.find.js
43687
+ var es_iterator_find = __webpack_require__("f665");
43688
+
43686
43689
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.for-each.js
43687
43690
  var es_iterator_for_each = __webpack_require__("7d54");
43688
43691
 
@@ -44025,6 +44028,55 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44025
44028
 
44026
44029
 
44027
44030
 
44031
+
44032
+ //
44033
+ //
44034
+ //
44035
+ //
44036
+ //
44037
+ //
44038
+ //
44039
+ //
44040
+ //
44041
+ //
44042
+ //
44043
+ //
44044
+ //
44045
+ //
44046
+ //
44047
+ //
44048
+ //
44049
+ //
44050
+ //
44051
+ //
44052
+ //
44053
+ //
44054
+ //
44055
+ //
44056
+ //
44057
+ //
44058
+ //
44059
+ //
44060
+ //
44061
+ //
44062
+ //
44063
+ //
44064
+ //
44065
+ //
44066
+ //
44067
+ //
44068
+ //
44069
+ //
44070
+ //
44071
+ //
44072
+ //
44073
+ //
44074
+ //
44075
+ //
44076
+ //
44077
+ //
44078
+ //
44079
+ //
44028
44080
  //
44029
44081
  //
44030
44082
  //
@@ -44075,16 +44127,48 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44075
44127
  //
44076
44128
  //
44077
44129
  //
44130
+ //
44131
+ //
44132
+ //
44133
+ //
44134
+ //
44135
+ //
44136
+ //
44137
+ //
44138
+ //
44139
+ //
44140
+ //
44141
+ //
44142
+
44078
44143
 
44079
44144
 
44080
44145
 
44146
+ // 提取文件图标映射配置,避免在过滤器中重复创建,提升性能
44147
+ const FILE_ICON_MAP = [{
44148
+ suffix: [".jpg", ".jpeg", ".png", ".gif"],
44149
+ icon: "icon-color-JPG"
44150
+ }, {
44151
+ suffix: [".doc", ".docx"],
44152
+ icon: "icon-color-wendang"
44153
+ }, {
44154
+ suffix: [".xls", ".xlsx"],
44155
+ icon: "icon-color-excel"
44156
+ }, {
44157
+ suffix: ".pdf",
44158
+ icon: "icon-color-pdf"
44159
+ }, {
44160
+ suffix: ".txt",
44161
+ icon: "icon-color-txt"
44162
+ }];
44081
44163
  /* harmony default export */ var mainvue_type_script_lang_js = ({
44082
44164
  name: "HbUpload",
44083
44165
  componentName: "HbUpload",
44084
44166
  data() {
44085
44167
  return {
44086
44168
  key: Math.random(),
44087
- coverIndex: 0 // 要覆盖的文件索引
44169
+ coverIndex: 0,
44170
+ // 要覆盖的文件索引
44171
+ uploadingList: [] // 正在上传的文件列表
44088
44172
  };
44089
44173
  },
44090
44174
  props: {
@@ -44111,8 +44195,34 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44111
44195
  maxUpload: {
44112
44196
  type: Number,
44113
44197
  default: 0
44198
+ },
44199
+ _simpleUploadThreshold: {
44200
+ type: Number,
44201
+ default: 50 * 1024 * 1024 // 50MB
44114
44202
  }
44115
44203
  },
44204
+ created() {
44205
+ // 监听阿里OSS的上传进度和状态变化
44206
+ // 注意:这里使用的是 window 全局事件,可能会影响页面上其他相同组件实例
44207
+ // 建议:如果可能有多个实例,应确保事件携带唯一标识符
44208
+ window.addEventListener("netdiscItemProgress", this.onUploadProgress);
44209
+ window.addEventListener("netdiscItemStatusChange", this.onUploadStatusChange);
44210
+ },
44211
+ beforeDestroy() {
44212
+ // 取消上传 : 传输中或排队中的文件
44213
+ this.uploadingList.forEach(item => {
44214
+ if (item.status === "padding" || item.status === "inline") {
44215
+ window.dispatchEvent(new CustomEvent("netdiscCancelUpload", {
44216
+ bubbles: false,
44217
+ detail: {
44218
+ file: item.file
44219
+ }
44220
+ }));
44221
+ }
44222
+ });
44223
+ window.removeEventListener("netdiscItemProgress", this.onUploadProgress);
44224
+ window.removeEventListener("netdiscItemStatusChange", this.onUploadStatusChange);
44225
+ },
44116
44226
  methods: {
44117
44227
  viewFile(item) {
44118
44228
  if (!item.onlineUrl) {
@@ -44139,27 +44249,62 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44139
44249
  this.$refs.coverInput.click();
44140
44250
  },
44141
44251
  coverFile(ev) {
44142
- console.log(ev.target.files[0]);
44143
- let files = new FormData();
44144
- files.append("files[0]", ev.target.files[0]);
44145
- this.$http.post("/sysFiles/uploads", files).then(res => {
44146
- this.$message.success("上传成功");
44147
- //处理返回的数据
44148
- let coverList = res.map(item => ({
44149
- fileName: item.fileName,
44150
- fileType: "1",
44151
- fileUrl: item.fileUrl,
44152
- downUrl: item.downUrl,
44153
- onlineUrl: item.onlineUrl,
44154
- fileSize: item.fileSize
44155
- }));
44156
- const coverOriginData = this.$lodash.cloneDeep(this.list[this.coverIndex]);
44157
- this.list.splice(this.coverIndex, 1, coverList[0]);
44158
- this.$emit("coverSuccess", {
44159
- index: this.coverIndex,
44160
- fileList: this.list,
44161
- coverOriginData
44252
+ const file = ev.target.files[0];
44253
+ if (!file) return;
44254
+
44255
+ // Check if there's already an active cover upload for this index
44256
+ const existingCover = this.uploadingList.find(item => item.isCover && item.coverIndex === this.coverIndex && (item.status === "padding" || item.status === "inline"));
44257
+ if (existingCover) {
44258
+ this.$confirm("当前正在覆盖该文件,是否取消之前的上传并开始新的覆盖?", "提示", {
44259
+ confirmButtonText: "确定",
44260
+ cancelButtonText: "取消",
44261
+ type: "warning"
44262
+ }).then(() => {
44263
+ // Cancel the previous upload
44264
+ this.cancelUpload(existingCover, false); // Pass false to skip confirm dialog inside cancelUpload
44265
+ this.startCoverUpload(file);
44266
+ }).catch(() => {
44267
+ // Do nothing, keep the old upload
44268
+ ev.target.value = "";
44162
44269
  });
44270
+ } else {
44271
+ this.startCoverUpload(file);
44272
+ }
44273
+ ev.target.value = "";
44274
+ },
44275
+ // 点击覆盖按钮 执行阿里OSS上传操作
44276
+ startCoverUpload(file) {
44277
+ const uploadItem = {
44278
+ fileName: file.name,
44279
+ fileSize: file.size,
44280
+ progress: 0,
44281
+ status: "padding",
44282
+ file: file,
44283
+ // Keep reference
44284
+ isCover: true,
44285
+ // Mark as cover operation
44286
+ coverIndex: this.coverIndex // Store the index
44287
+ };
44288
+ this.uploadingList.push(uploadItem);
44289
+ // 通过后端接口获取到上传阿里所需token
44290
+ this.getSTSToken().then(res => {
44291
+ window.dispatchEvent(new CustomEvent("netdiscUpload", {
44292
+ bubbles: false,
44293
+ detail: {
44294
+ type: "file",
44295
+ fileList: [file],
44296
+ path: [],
44297
+ token: res,
44298
+ _unUploadByNetdisc: true,
44299
+ // 不是在网盘上传的文件
44300
+ _doNotOpenUploader: true,
44301
+ // 不需要打开上传进度
44302
+ _simpleUploadThreshold: this._simpleUploadThreshold // 简单上传与分片上传的阈值
44303
+ }
44304
+ }));
44305
+ }).catch(() => {
44306
+ this.$message.error("ali-oss token获取失败");
44307
+ this.removeFromUploading(uploadItem);
44163
44308
  });
44164
44309
  },
44165
44310
  openNetDisc() {
@@ -44183,16 +44328,102 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44183
44328
  }
44184
44329
  this.$refs.input.click();
44185
44330
  },
44331
+ // 选择文件 执行上传阿里OSS操作
44186
44332
  chooseFile(ev) {
44187
44333
  let fileList = Array.from(ev.target.files);
44188
- console.log(ev);
44189
- let files = new FormData();
44190
- fileList.forEach((item, index) => {
44191
- files.append(`files[${index}]`, item);
44334
+ fileList.forEach(file => {
44335
+ this.uploadingList.push({
44336
+ fileName: file.name,
44337
+ fileSize: file.size,
44338
+ progress: 0,
44339
+ status: "padding",
44340
+ file: file // Keep reference
44341
+ });
44192
44342
  });
44193
- this.$http.post("/sysFiles/uploads", files).then(res => {
44194
- this.$message.success("上传成功");
44195
- //处理返回的数据
44343
+ // 通过后端接口获取到上传阿里所需token
44344
+ this.getSTSToken().then(res => {
44345
+ window.dispatchEvent(new CustomEvent("netdiscUpload", {
44346
+ bubbles: false,
44347
+ detail: {
44348
+ type: "file",
44349
+ fileList: fileList,
44350
+ path: [],
44351
+ token: res,
44352
+ _unUploadByNetdisc: true,
44353
+ // 不是在网盘上传的文件
44354
+ _doNotOpenUploader: true,
44355
+ // 不需要打开上传进度
44356
+ _simpleUploadThreshold: this._simpleUploadThreshold // 简单上传与分片上传的阈值
44357
+ }
44358
+ }));
44359
+ }).catch(() => {
44360
+ this.$message.error("ali-oss token获取失败");
44361
+ // Remove from uploading list if token fails
44362
+ fileList.forEach(file => {
44363
+ const index = this.uploadingList.findIndex(i => i.file === file);
44364
+ if (index > -1) this.uploadingList.splice(index, 1);
44365
+ });
44366
+ });
44367
+ ev.target.value = "";
44368
+ },
44369
+ getSTSToken() {
44370
+ return this.$http.get("/ndRecord/getStsToken", {
44371
+ baseURL: "/platform"
44372
+ }).then(res => {
44373
+ let token = {
44374
+ region: "oss-cn-hangzhou",
44375
+ accessKeyId: res.credentials.accessKeyId,
44376
+ accessKeySecret: res.credentials.accessKeySecret,
44377
+ stsToken: res.credentials.securityToken,
44378
+ bucket: res.bucket
44379
+ };
44380
+ return Promise.resolve(token);
44381
+ }).catch(error => {
44382
+ return Promise.reject(error);
44383
+ });
44384
+ },
44385
+ // 监听阿里上传进度
44386
+ onUploadProgress(e) {
44387
+ const {
44388
+ file,
44389
+ progress
44390
+ } = e.detail;
44391
+ const item = this.uploadingList.find(i => i.file === file);
44392
+ if (item) {
44393
+ item.progress = progress;
44394
+ }
44395
+ },
44396
+ // 监听阿里上传状态变化
44397
+ onUploadStatusChange(e) {
44398
+ const {
44399
+ file,
44400
+ status
44401
+ } = e.detail;
44402
+ const item = this.uploadingList.find(i => i.file === file);
44403
+ if (item) {
44404
+ item.status = status;
44405
+ if (status === "transmitSuccess") {
44406
+ this.handleUploadSuccess(item); // 上传阿里成功
44407
+ } else if (status === "failed") {
44408
+ this.$message.error(`${item.fileName} 上传失败`);
44409
+ this.removeFromUploading(item); // 上传阿里失败
44410
+ } else if (status === "cancel") {
44411
+ this.removeFromUploading(item); // 上传阿里取消
44412
+ }
44413
+ }
44414
+ },
44415
+ // 上传阿里成功 执行保存文件信息操作
44416
+ handleUploadSuccess(item) {
44417
+ const payload = [{
44418
+ fileName: item.fileName,
44419
+ fileSize: item.fileSize,
44420
+ fileSuffix: this.getSuffix(item.fileName),
44421
+ fileType: "1",
44422
+ fileUrl: item.file.path
44423
+ }];
44424
+ // 经过后端拿到上传到阿里的文件的信息
44425
+ this.$http.post("/sysFiles/getSysFilesVo", payload).then(res => {
44426
+ // 处理返回的数据
44196
44427
  let addList = res.map(item => ({
44197
44428
  fileName: item.fileName,
44198
44429
  fileType: "1",
@@ -44201,15 +44432,36 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44201
44432
  onlineUrl: item.onlineUrl,
44202
44433
  fileSize: item.fileSize
44203
44434
  }));
44204
- addList.forEach(item => {
44205
- this.list.push(item);
44206
- });
44207
- this.$emit("uploadSuccess", {
44208
- fileList: this.list,
44209
- addData: this.$lodash.cloneDeep(addList)
44210
- });
44435
+ if (item.isCover) {
44436
+ const coverOriginData = this.$lodash.cloneDeep(this.list[item.coverIndex]);
44437
+ this.list.splice(item.coverIndex, 1, addList[0]);
44438
+ this.$emit("coverSuccess", {
44439
+ index: item.coverIndex,
44440
+ fileList: this.list,
44441
+ coverOriginData
44442
+ });
44443
+ } else {
44444
+ addList.forEach(item => {
44445
+ this.list.push(item);
44446
+ });
44447
+ this.$emit("uploadSuccess", {
44448
+ fileList: this.list,
44449
+ addData: this.$lodash.cloneDeep(addList)
44450
+ });
44451
+ }
44452
+ this.removeFromUploading(item);
44453
+ }).catch(() => {
44454
+ this.$message.error("保存文件信息失败");
44455
+ this.removeFromUploading(item);
44211
44456
  });
44212
44457
  },
44458
+ // 移除正在进行阿里上传的文件项
44459
+ removeFromUploading(item) {
44460
+ const index = this.uploadingList.indexOf(item);
44461
+ if (index > -1) {
44462
+ this.uploadingList.splice(index, 1);
44463
+ }
44464
+ },
44213
44465
  addLink(data) {
44214
44466
  if (this.maxUpload && this.list.length + 1 > this.maxUpload) {
44215
44467
  this.$message.error("最多上传" + this.maxUpload + "个文件");
@@ -44242,6 +44494,29 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44242
44494
  });
44243
44495
  }).catch(() => {});
44244
44496
  },
44497
+ // 取消上传阿里
44498
+ cancelUpload(item, confirm = true) {
44499
+ const doCancel = () => {
44500
+ window.dispatchEvent(new CustomEvent("netdiscCancelUpload", {
44501
+ bubbles: false,
44502
+ detail: {
44503
+ file: item.file
44504
+ }
44505
+ }));
44506
+ this.removeFromUploading(item);
44507
+ };
44508
+ if (confirm) {
44509
+ this.$confirm(`确定要取消上传 ${item.fileName} 吗?`, "提示", {
44510
+ confirmButtonText: "确定",
44511
+ cancelButtonText: "取消",
44512
+ type: "warning"
44513
+ }).then(() => {
44514
+ doCancel();
44515
+ }).catch(() => {});
44516
+ } else {
44517
+ doCancel();
44518
+ }
44519
+ },
44245
44520
  rerendering() {
44246
44521
  this.key = Math.random();
44247
44522
  }
@@ -44275,30 +44550,14 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44275
44550
  },
44276
44551
  filters: {
44277
44552
  fileIcon(isFile, fileType) {
44278
- var _fileMap$find;
44553
+ var _FILE_ICON_MAP$find;
44279
44554
  if (!isFile) {
44280
44555
  return "icon-color-wenjianjia";
44281
44556
  }
44282
44557
  const lowerFileType = fileType.toLowerCase();
44283
- const fileMap = [{
44284
- suffix: [".jpg", ".jpeg", ".png", ".gif"],
44285
- icon: "icon-color-JPG"
44286
- }, {
44287
- suffix: [".doc", ".docx"],
44288
- icon: "icon-color-wendang"
44289
- }, {
44290
- suffix: [".xls", ".xlsx"],
44291
- icon: "icon-color-excel"
44292
- }, {
44293
- suffix: ".pdf",
44294
- icon: "icon-color-pdf"
44295
- }, {
44296
- suffix: ".txt",
44297
- icon: "icon-color-txt"
44298
- }];
44299
- const iconClass = (_fileMap$find = fileMap.find(item => {
44558
+ const iconClass = (_FILE_ICON_MAP$find = FILE_ICON_MAP.find(item => {
44300
44559
  return typeof item.suffix === "string" ? item.suffix === lowerFileType : item.suffix.includes(lowerFileType);
44301
- })) === null || _fileMap$find === void 0 ? void 0 : _fileMap$find.icon;
44560
+ })) === null || _FILE_ICON_MAP$find === void 0 ? void 0 : _FILE_ICON_MAP$find.icon;
44302
44561
  return iconClass || "icon-color-qita1";
44303
44562
  }
44304
44563
  },
@@ -44309,8 +44568,8 @@ var CustomLink_component = Object(componentNormalizer["a" /* default */])(
44309
44568
  });
44310
44569
  // CONCATENATED MODULE: ./packages/upload/src/main.vue?vue&type=script&lang=js
44311
44570
  /* harmony default export */ var src_mainvue_type_script_lang_js = (mainvue_type_script_lang_js);
44312
- // EXTERNAL MODULE: ./packages/upload/src/main.vue?vue&type=style&index=0&id=2c521d9c&prod&lang=scss
44313
- var mainvue_type_style_index_0_id_2c521d9c_prod_lang_scss = __webpack_require__("2070");
44571
+ // EXTERNAL MODULE: ./packages/upload/src/main.vue?vue&type=style&index=0&id=0cc572b4&prod&lang=scss
44572
+ var mainvue_type_style_index_0_id_0cc572b4_prod_lang_scss = __webpack_require__("b639");
44314
44573
 
44315
44574
  // CONCATENATED MODULE: ./packages/upload/src/main.vue
44316
44575