eoss-ui 0.8.48 → 0.8.49
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/lib/eoss-ui.common.js +75 -30
- package/lib/index.js +1 -1
- package/lib/upload.js +72 -27
- package/package.json +1 -1
- package/packages/upload/src/main.vue +42 -0
- package/src/index.js +1 -1
package/lib/upload.js
CHANGED
|
@@ -4750,8 +4750,8 @@ module.exports = require("spark-md5");
|
|
|
4750
4750
|
// ESM COMPAT FLAG
|
|
4751
4751
|
__webpack_require__.r(__webpack_exports__);
|
|
4752
4752
|
|
|
4753
|
-
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/main.vue?vue&type=template&id=
|
|
4754
|
-
var
|
|
4753
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/main.vue?vue&type=template&id=bf79f780&
|
|
4754
|
+
var mainvue_type_template_id_bf79f780_render = function () {
|
|
4755
4755
|
var _vm = this
|
|
4756
4756
|
var _h = _vm.$createElement
|
|
4757
4757
|
var _c = _vm._self._c || _h
|
|
@@ -5135,10 +5135,10 @@ var mainvue_type_template_id_7388a79d_render = function () {
|
|
|
5135
5135
|
: _vm._e()
|
|
5136
5136
|
}
|
|
5137
5137
|
var staticRenderFns = []
|
|
5138
|
-
|
|
5138
|
+
mainvue_type_template_id_bf79f780_render._withStripped = true
|
|
5139
5139
|
|
|
5140
5140
|
|
|
5141
|
-
// CONCATENATED MODULE: ./packages/upload/src/main.vue?vue&type=template&id=
|
|
5141
|
+
// CONCATENATED MODULE: ./packages/upload/src/main.vue?vue&type=template&id=bf79f780&
|
|
5142
5142
|
|
|
5143
5143
|
// EXTERNAL MODULE: ./src/config/api.js
|
|
5144
5144
|
var api = __webpack_require__(1);
|
|
@@ -5886,6 +5886,7 @@ var _props;
|
|
|
5886
5886
|
lists: {
|
|
5887
5887
|
deep: true,
|
|
5888
5888
|
handler: function handler(val) {
|
|
5889
|
+
if (this._isSortRebuilding) return;
|
|
5889
5890
|
this.$emit('update:fileCount', val.length);
|
|
5890
5891
|
this.$emit('getFilesAmount', val.length);
|
|
5891
5892
|
}
|
|
@@ -6326,6 +6327,19 @@ var _props;
|
|
|
6326
6327
|
|
|
6327
6328
|
console.log('files', files);
|
|
6328
6329
|
if (this.isSort) {
|
|
6330
|
+
// 同步拖拽排序后的顺序到数据层,采用先清空再重建的方式
|
|
6331
|
+
// 避免 SortableJS 移动 DOM 后与 Vue 虚拟 DOM 产生引用错位
|
|
6332
|
+
this._isSortRebuilding = true;
|
|
6333
|
+
this.lists = [];
|
|
6334
|
+
this.$nextTick(function () {
|
|
6335
|
+
_this10.lists = files;
|
|
6336
|
+
_this10._isSortRebuilding = false;
|
|
6337
|
+
// 重建完成后清除 table-body 的 newData 缓存
|
|
6338
|
+
// 使下次拖拽基于最新的 this.data 而非旧缓存
|
|
6339
|
+
_this10.$nextTick(function () {
|
|
6340
|
+
_this10._resetTableBodyCache();
|
|
6341
|
+
});
|
|
6342
|
+
});
|
|
6329
6343
|
if (this.onSort) {
|
|
6330
6344
|
this.onSort(files);
|
|
6331
6345
|
} else {
|
|
@@ -6411,11 +6425,17 @@ var _props;
|
|
|
6411
6425
|
this.onChange && this.onChange(file, fileList);
|
|
6412
6426
|
},
|
|
6413
6427
|
handleRemove: function handleRemove(file, fileList) {
|
|
6428
|
+
var _this11 = this;
|
|
6429
|
+
|
|
6414
6430
|
this.cleanupChunk(file);
|
|
6415
6431
|
this.$emit('input', fileList.length ? fileList : '');
|
|
6416
6432
|
this.$emit('remove', file, fileList);
|
|
6417
6433
|
this.$emit('change', fileList);
|
|
6418
6434
|
this.onRemove && this.onRemove(file, fileList);
|
|
6435
|
+
// 删除后重置 table-body 的排序缓存,防止再次拖拽时已删除文件从旧 newData 中复活
|
|
6436
|
+
this.$nextTick(function () {
|
|
6437
|
+
_this11._resetTableBodyCache();
|
|
6438
|
+
});
|
|
6419
6439
|
},
|
|
6420
6440
|
handleError: function handleError(err, file, fileList) {
|
|
6421
6441
|
console.log('err', err);
|
|
@@ -6450,7 +6470,7 @@ var _props;
|
|
|
6450
6470
|
// el-upload 的自定义上传实现:建立可暂停的运行态并返回受控 Promise。
|
|
6451
6471
|
// 暂停时不 resolve/reject(promise 维持 pending,文件保持"上传中"而非失败),继续时再次进入流程。
|
|
6452
6472
|
chunkUpload: function chunkUpload(options) {
|
|
6453
|
-
var
|
|
6473
|
+
var _this12 = this;
|
|
6454
6474
|
|
|
6455
6475
|
var file = options.file;
|
|
6456
6476
|
var uid = file.uid;
|
|
@@ -6465,13 +6485,13 @@ var _props;
|
|
|
6465
6485
|
return new Promise(function (resolve, reject) {
|
|
6466
6486
|
state.resolve = resolve;
|
|
6467
6487
|
state.reject = reject;
|
|
6468
|
-
|
|
6488
|
+
_this12.runChunkFlow(uid);
|
|
6469
6489
|
});
|
|
6470
6490
|
},
|
|
6471
6491
|
|
|
6472
6492
|
// 分片主流程(可被"继续"重新进入):MD5(缓存) → 秒传/断点续传检测 → 并发上传缺失分片 → 合并入库。
|
|
6473
6493
|
runChunkFlow: function runChunkFlow(uid) {
|
|
6474
|
-
var
|
|
6494
|
+
var _this13 = this;
|
|
6475
6495
|
|
|
6476
6496
|
var state = this._chunkState[uid];
|
|
6477
6497
|
if (!state) return;
|
|
@@ -6479,13 +6499,13 @@ var _props;
|
|
|
6479
6499
|
var file = options.file;
|
|
6480
6500
|
var onProgress = options.onProgress || function () {};
|
|
6481
6501
|
var baseParams = function baseParams() {
|
|
6482
|
-
return _extends({},
|
|
6502
|
+
return _extends({}, _this13.param, {
|
|
6483
6503
|
fileMd5: state.fileMd5,
|
|
6484
6504
|
fileName: file.name,
|
|
6485
6505
|
fileSize: file.size,
|
|
6486
6506
|
totalChunks: state.totalChunks,
|
|
6487
|
-
bucketCode:
|
|
6488
|
-
businessId:
|
|
6507
|
+
bucketCode: _this13.code,
|
|
6508
|
+
businessId: _this13.ownId
|
|
6489
6509
|
});
|
|
6490
6510
|
};
|
|
6491
6511
|
var isAbort = function isAbort(e) {
|
|
@@ -6493,13 +6513,13 @@ var _props;
|
|
|
6493
6513
|
};
|
|
6494
6514
|
|
|
6495
6515
|
Promise.resolve().then(function () {
|
|
6496
|
-
return state.fileMd5 ||
|
|
6516
|
+
return state.fileMd5 || _this13.computeFileMd5(file, onProgress);
|
|
6497
6517
|
}).then(function (md5) {
|
|
6498
6518
|
state.fileMd5 = md5;
|
|
6499
6519
|
if (state.paused) return null;
|
|
6500
6520
|
return util["a" /* default */].ajax({
|
|
6501
6521
|
method: 'post',
|
|
6502
|
-
url:
|
|
6522
|
+
url: _this13.chunkUrls.check,
|
|
6503
6523
|
data: baseParams(),
|
|
6504
6524
|
params: baseParams(),
|
|
6505
6525
|
headers: options.headers
|
|
@@ -6511,14 +6531,14 @@ var _props;
|
|
|
6511
6531
|
// 秒传命中:该业务桶下已存在同 MD5 文件,直接视为成功
|
|
6512
6532
|
if (info.instant) {
|
|
6513
6533
|
onProgress({ percent: 100 });
|
|
6514
|
-
|
|
6515
|
-
|
|
6534
|
+
_this13.normalizeChunkDoc(info, file.name);
|
|
6535
|
+
_this13.finishChunk(uid, {
|
|
6516
6536
|
rCode: 0,
|
|
6517
6537
|
msg: checkRes.msg || '秒传成功',
|
|
6518
6538
|
results: info
|
|
6519
6539
|
});
|
|
6520
6540
|
// 秒传文件已存在于服务端,刷新列表以展示其完整信息(含可下载/预览的 id)
|
|
6521
|
-
|
|
6541
|
+
_this13.requestFiles && _this13.getFiles();
|
|
6522
6542
|
return;
|
|
6523
6543
|
}
|
|
6524
6544
|
// 断点续传:跳过服务端已存在的分片
|
|
@@ -6534,9 +6554,9 @@ var _props;
|
|
|
6534
6554
|
});
|
|
6535
6555
|
state.controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
|
|
6536
6556
|
var signal = state.controller ? state.controller.signal : undefined;
|
|
6537
|
-
return
|
|
6557
|
+
return _this13.runChunkQueue(pending, _this13._chunkConcurrent, function (index) {
|
|
6538
6558
|
if (state.paused) return Promise.reject({ __aborted: true });
|
|
6539
|
-
return
|
|
6559
|
+
return _this13.uploadOneChunk(file, index, state.totalChunks, state.fileMd5, options.headers, signal).then(function () {
|
|
6540
6560
|
finished++;
|
|
6541
6561
|
onProgress({
|
|
6542
6562
|
percent: Math.min(95, 5 + Math.round(finished / state.totalChunks * 90))
|
|
@@ -6546,7 +6566,7 @@ var _props;
|
|
|
6546
6566
|
if (state.paused) return; // 暂停于上传阶段,维持 pending
|
|
6547
6567
|
return util["a" /* default */].ajax({
|
|
6548
6568
|
method: 'post',
|
|
6549
|
-
url:
|
|
6569
|
+
url: _this13.chunkUrls.merge,
|
|
6550
6570
|
data: baseParams(),
|
|
6551
6571
|
params: baseParams(),
|
|
6552
6572
|
headers: options.headers
|
|
@@ -6554,17 +6574,17 @@ var _props;
|
|
|
6554
6574
|
console.log('mergeRes', mergeRes);
|
|
6555
6575
|
if (mergeRes.rCode !== 0) return Promise.reject(mergeRes);
|
|
6556
6576
|
onProgress({ percent: 100 });
|
|
6557
|
-
|
|
6558
|
-
|
|
6577
|
+
_this13.normalizeChunkDoc(mergeRes.results, file.name);
|
|
6578
|
+
_this13.finishChunk(uid, mergeRes);
|
|
6559
6579
|
// 刷新列表:让刚入库的文件以与其他行一致的结构展示(时间/大小/上传人等)
|
|
6560
|
-
|
|
6580
|
+
_this13.requestFiles && _this13.getFiles();
|
|
6561
6581
|
});
|
|
6562
6582
|
});
|
|
6563
6583
|
}).catch(function (e) {
|
|
6564
6584
|
console.log('err', e);
|
|
6565
6585
|
// 暂停导致的中止:保持 pending 等待"继续";其余才算失败
|
|
6566
6586
|
if (state.paused || isAbort(e)) return;
|
|
6567
|
-
|
|
6587
|
+
_this13.failChunk(uid, e);
|
|
6568
6588
|
});
|
|
6569
6589
|
},
|
|
6570
6590
|
|
|
@@ -6677,7 +6697,7 @@ var _props;
|
|
|
6677
6697
|
|
|
6678
6698
|
// 上传单个分片(multipart/form-data);signal 用于暂停时中止
|
|
6679
6699
|
uploadOneChunk: function uploadOneChunk(file, index, totalChunks, fileMd5, headers, signal) {
|
|
6680
|
-
var
|
|
6700
|
+
var _this14 = this;
|
|
6681
6701
|
|
|
6682
6702
|
var start = index * this._chunkSize;
|
|
6683
6703
|
var end = Math.min(start + this._chunkSize, file.size);
|
|
@@ -6691,7 +6711,7 @@ var _props;
|
|
|
6691
6711
|
formData.append('bucketCode', this.code);
|
|
6692
6712
|
formData.append('businessId', this.ownId);
|
|
6693
6713
|
Object.keys(this.param || {}).forEach(function (key) {
|
|
6694
|
-
formData.append(key,
|
|
6714
|
+
formData.append(key, _this14.param[key]);
|
|
6695
6715
|
});
|
|
6696
6716
|
return util["a" /* default */].ajax({
|
|
6697
6717
|
method: 'post',
|
|
@@ -6708,10 +6728,10 @@ var _props;
|
|
|
6708
6728
|
|
|
6709
6729
|
// 分块读取文件并增量计算 MD5(避免大文件一次性读入内存)
|
|
6710
6730
|
computeFileMd5: function computeFileMd5(file, onProgress) {
|
|
6711
|
-
var
|
|
6731
|
+
var _this15 = this;
|
|
6712
6732
|
|
|
6713
6733
|
return new Promise(function (resolve, reject) {
|
|
6714
|
-
var size =
|
|
6734
|
+
var size = _this15._chunkSize;
|
|
6715
6735
|
var chunks = Math.max(1, Math.ceil(file.size / size));
|
|
6716
6736
|
var spark = new external_spark_md5_default.a.ArrayBuffer();
|
|
6717
6737
|
var reader = new FileReader();
|
|
@@ -6764,6 +6784,31 @@ var _props;
|
|
|
6764
6784
|
};
|
|
6765
6785
|
schedule();
|
|
6766
6786
|
});
|
|
6787
|
+
},
|
|
6788
|
+
|
|
6789
|
+
/**
|
|
6790
|
+
* 重置 table-body 组件内部的 newData 缓存。
|
|
6791
|
+
* table-body.js 在拖拽排序时会把结果存入 newData,后续排序优先从 newData 取数据源。
|
|
6792
|
+
* 但文件被删除后 newData 不会自动清除,导致已删除文件在下次拖拽时复活。
|
|
6793
|
+
*/
|
|
6794
|
+
_resetTableBodyCache: function _resetTableBodyCache() {
|
|
6795
|
+
if (this.listType !== 'table') return;
|
|
6796
|
+
var upload = this.$refs.upload;
|
|
6797
|
+
if (!upload) return;
|
|
6798
|
+
var tableList = upload.$children.find(function (c) {
|
|
6799
|
+
return c.$options.name === 'TableList';
|
|
6800
|
+
});
|
|
6801
|
+
if (!tableList) return;
|
|
6802
|
+
var elTable = tableList.$children.find(function (c) {
|
|
6803
|
+
return c.$options.name === 'ElTable';
|
|
6804
|
+
});
|
|
6805
|
+
if (!elTable) return;
|
|
6806
|
+
var tableBody = elTable.$children.find(function (c) {
|
|
6807
|
+
return c.$options.name === 'ElTableBody';
|
|
6808
|
+
});
|
|
6809
|
+
if (tableBody) {
|
|
6810
|
+
tableBody.newData = null;
|
|
6811
|
+
}
|
|
6767
6812
|
}
|
|
6768
6813
|
}
|
|
6769
6814
|
});
|
|
@@ -6782,7 +6827,7 @@ var componentNormalizer = __webpack_require__(3);
|
|
|
6782
6827
|
|
|
6783
6828
|
var component = Object(componentNormalizer["a" /* default */])(
|
|
6784
6829
|
src_mainvue_type_script_lang_js_,
|
|
6785
|
-
|
|
6830
|
+
mainvue_type_template_id_bf79f780_render,
|
|
6786
6831
|
staticRenderFns,
|
|
6787
6832
|
false,
|
|
6788
6833
|
null,
|
package/package.json
CHANGED
|
@@ -770,6 +770,7 @@ export default {
|
|
|
770
770
|
lists: {
|
|
771
771
|
deep: true,
|
|
772
772
|
handler(val) {
|
|
773
|
+
if (this._isSortRebuilding) return;
|
|
773
774
|
this.$emit('update:fileCount', val.length);
|
|
774
775
|
this.$emit('getFilesAmount', val.length);
|
|
775
776
|
}
|
|
@@ -1355,6 +1356,19 @@ export default {
|
|
|
1355
1356
|
handleSort(files) {
|
|
1356
1357
|
console.log('files', files);
|
|
1357
1358
|
if (this.isSort) {
|
|
1359
|
+
// 同步拖拽排序后的顺序到数据层,采用先清空再重建的方式
|
|
1360
|
+
// 避免 SortableJS 移动 DOM 后与 Vue 虚拟 DOM 产生引用错位
|
|
1361
|
+
this._isSortRebuilding = true;
|
|
1362
|
+
this.lists = [];
|
|
1363
|
+
this.$nextTick(() => {
|
|
1364
|
+
this.lists = files;
|
|
1365
|
+
this._isSortRebuilding = false;
|
|
1366
|
+
// 重建完成后清除 table-body 的 newData 缓存
|
|
1367
|
+
// 使下次拖拽基于最新的 this.data 而非旧缓存
|
|
1368
|
+
this.$nextTick(() => {
|
|
1369
|
+
this._resetTableBodyCache();
|
|
1370
|
+
});
|
|
1371
|
+
});
|
|
1358
1372
|
if (this.onSort) {
|
|
1359
1373
|
this.onSort(files);
|
|
1360
1374
|
} else {
|
|
@@ -1460,6 +1474,10 @@ export default {
|
|
|
1460
1474
|
this.$emit('remove', file, fileList);
|
|
1461
1475
|
this.$emit('change', fileList);
|
|
1462
1476
|
this.onRemove && this.onRemove(file, fileList);
|
|
1477
|
+
// 删除后重置 table-body 的排序缓存,防止再次拖拽时已删除文件从旧 newData 中复活
|
|
1478
|
+
this.$nextTick(() => {
|
|
1479
|
+
this._resetTableBodyCache();
|
|
1480
|
+
});
|
|
1463
1481
|
},
|
|
1464
1482
|
handleError(err, file, fileList) {
|
|
1465
1483
|
console.log('err', err);
|
|
@@ -1832,6 +1850,30 @@ export default {
|
|
|
1832
1850
|
};
|
|
1833
1851
|
schedule();
|
|
1834
1852
|
});
|
|
1853
|
+
},
|
|
1854
|
+
/**
|
|
1855
|
+
* 重置 table-body 组件内部的 newData 缓存。
|
|
1856
|
+
* table-body.js 在拖拽排序时会把结果存入 newData,后续排序优先从 newData 取数据源。
|
|
1857
|
+
* 但文件被删除后 newData 不会自动清除,导致已删除文件在下次拖拽时复活。
|
|
1858
|
+
*/
|
|
1859
|
+
_resetTableBodyCache() {
|
|
1860
|
+
if (this.listType !== 'table') return;
|
|
1861
|
+
const upload = this.$refs.upload;
|
|
1862
|
+
if (!upload) return;
|
|
1863
|
+
const tableList = upload.$children.find(
|
|
1864
|
+
(c) => c.$options.name === 'TableList'
|
|
1865
|
+
);
|
|
1866
|
+
if (!tableList) return;
|
|
1867
|
+
const elTable = tableList.$children.find(
|
|
1868
|
+
(c) => c.$options.name === 'ElTable'
|
|
1869
|
+
);
|
|
1870
|
+
if (!elTable) return;
|
|
1871
|
+
const tableBody = elTable.$children.find(
|
|
1872
|
+
(c) => c.$options.name === 'ElTableBody'
|
|
1873
|
+
);
|
|
1874
|
+
if (tableBody) {
|
|
1875
|
+
tableBody.newData = null;
|
|
1876
|
+
}
|
|
1835
1877
|
}
|
|
1836
1878
|
}
|
|
1837
1879
|
};
|