|
@@ -20,6 +20,21 @@ $(document).ready(function() {
|
|
|
this.expandCache = cache ? _.uniq(cache.split(',')) : [];
|
|
|
this.curFilingKey = 'cur-filing-' + window.location.pathname.split('/')[2];
|
|
|
$('#filing').height($(".sjs-height-0").height()-$('.d-flex',".sjs-height-0").height());
|
|
|
+ this.fileOrderKey = 'fileOrder';
|
|
|
+ this.fileOrder = getLocalCache(this.fileOrderKey) || 'create_time|desc';
|
|
|
+ }
|
|
|
+ refreshFileOrderButton() {
|
|
|
+ const orderBy = this.fileOrder.split('|');
|
|
|
+ const field = orderBy[0], sort = orderBy[1];
|
|
|
+ const buttons = $('[name=file-sort]');
|
|
|
+ for (const b of buttons) {
|
|
|
+ const curField = b.getAttribute('field');
|
|
|
+ if (curField === field) {
|
|
|
+ $(b).html(`<i class="fa fa-sort-amount-${sort}" aria-hidden="true"></i>`).attr('tag', `${curField}|${sort === 'asc' ? 'desc' : 'asc'}`);
|
|
|
+ } else {
|
|
|
+ $(b).html('<i class="fa fa-sort" aria-hidden="true">').attr('tag', `${curField}|desc`);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
calcTotalFileCount() {
|
|
|
this.dragTree.recursiveFun(this.dragTree.children, x => {
|
|
@@ -135,7 +150,7 @@ $(document).ready(function() {
|
|
|
const needFiles = Math.min(page*this.pageCount, node.source_node.file_count);
|
|
|
if (node.source_node.files && needFiles <= node.source_node.files.length) return;
|
|
|
|
|
|
- const files = await postDataAsync('file/load', { filing_id: node.id, page, count: this.pageCount });
|
|
|
+ const files = await postDataAsync('file/load', { filing_id: node.id, page, count: this.pageCount, order: this.fileOrder });
|
|
|
files.forEach(x => {
|
|
|
const file = node.source_node.files.find(f => {return x.id === f.id; });
|
|
|
if (file) {
|
|
@@ -144,9 +159,9 @@ $(document).ready(function() {
|
|
|
node.source_node.files.push(x);
|
|
|
}
|
|
|
});
|
|
|
- node.source_node.files.sort((x, y) => {
|
|
|
- return x.create_time - y.create_time;
|
|
|
- });
|
|
|
+ // node.source_node.files.sort((x, y) => {
|
|
|
+ // return x.create_time - y.create_time;
|
|
|
+ // });
|
|
|
}
|
|
|
addSiblingFiling(node) {
|
|
|
const self = this;
|
|
@@ -226,8 +241,8 @@ $(document).ready(function() {
|
|
|
formData.append('file[]', file);
|
|
|
}
|
|
|
postDataWithFile('file/upload', formData, function (data) {
|
|
|
- filingObj.curFiling.source_node.files.unshift(...data.files);
|
|
|
filingObj.updateFilingFileCount(filingObj.curFiling, data.filing.file_count);
|
|
|
+ filingObj.curFiling.source_node.files.unshift(...data.files);
|
|
|
filingObj.refreshPages();
|
|
|
filingObj.refreshFilesTable();
|
|
|
if (callback) callback();
|
|
@@ -389,6 +404,20 @@ $(document).ready(function() {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ _clearAllFileCache() {
|
|
|
+ const nodes = this.filingTree.getNodes();
|
|
|
+ for (const node of nodes) {
|
|
|
+ if (node.children && node.children.length > 0) continue;
|
|
|
+ if (node.source_node.files) node.source_node.files.length = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ changeFileOrder(fileOrder) {
|
|
|
+ this.fileOrder = fileOrder;
|
|
|
+ setLocalCache(this.fileOrderKey, fileOrder);
|
|
|
+ this.refreshFileOrderButton();
|
|
|
+ this._clearAllFileCache();
|
|
|
+ this.setCurFiling(this.curFiling);
|
|
|
+ }
|
|
|
}
|
|
|
const levelTreeSetting = {
|
|
|
treeId: 'filing',
|
|
@@ -516,6 +545,10 @@ $(document).ready(function() {
|
|
|
|
|
|
filingObj.addChildFiling(filingObj.curFiling);
|
|
|
});
|
|
|
+ $('[name=file-sort]').click(function() {
|
|
|
+ const tag = this.getAttribute('tag');
|
|
|
+ filingObj.changeFileOrder(tag);
|
|
|
+ });
|
|
|
// $('#del-filing-btn').click(() => {
|
|
|
// if (!filingObj.curFiling) return;
|
|
|
// if (filingObj.curFiling.source_node.is_fixed) {
|