|
|
@@ -12,6 +12,16 @@ $(document).ready(function() {
|
|
|
this.spread = SpreadJsObj.createNewSpread($('#filing-spread')[0]);
|
|
|
this.spread.options.showHorizontalScrollbar = false; // 隐藏水平滚动条
|
|
|
this.sheet = this.spread.getActiveSheet();
|
|
|
+ this.treeIcons = {
|
|
|
+ folder: new Image(),
|
|
|
+ leaf: new Image(),
|
|
|
+ };
|
|
|
+ const refreshTreeIcon = () => { this.spread.refresh(); };
|
|
|
+ this.treeIcons.folder.onload = refreshTreeIcon;
|
|
|
+ this.treeIcons.leaf.onload = refreshTreeIcon;
|
|
|
+ this.treeIcons.folder.src = '/public/images/filesjs-folder.png';
|
|
|
+ this.treeIcons.leaf.src = '/public/images/filesjs-leaf.png';
|
|
|
+ const treeIcons = this.treeIcons;
|
|
|
|
|
|
// 初始化 PathTree,使用 zh_filing 原有字段映射
|
|
|
this.filingTree = createNewPathTree('base', {
|
|
|
@@ -33,7 +43,12 @@ $(document).ready(function() {
|
|
|
return data.name;
|
|
|
},
|
|
|
getIcon: function(data) {
|
|
|
- return data.is_leaf ? 'file' : 'folder';
|
|
|
+ const fallback = data.is_leaf ? 'file' : 'folder';
|
|
|
+ return {
|
|
|
+ image: data.is_leaf ? treeIcons.leaf : treeIcons.folder,
|
|
|
+ fallback,
|
|
|
+ size: 18,
|
|
|
+ };
|
|
|
},
|
|
|
},
|
|
|
{ title: '文件数', colSpan: '1', rowSpan: '1', field: 'total_file_count', hAlign: 1, width: 70, formatter: '@' },
|
|
|
@@ -166,6 +181,7 @@ $(document).ready(function() {
|
|
|
const convertedData = this._convertData(filing);
|
|
|
this.filingTree.loadDatas(convertedData);
|
|
|
SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.filingTree);
|
|
|
+ this.resizeSpreadColumns();
|
|
|
|
|
|
// 恢复上次选中的节点
|
|
|
const curCache = getLocalCache(this.curFilingKey);
|
|
|
@@ -180,6 +196,26 @@ $(document).ready(function() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据目录区域宽度调整树表列宽,拖动分隔条时保持 SpreadJS 填满容器。
|
|
|
+ */
|
|
|
+ resizeSpreadColumns() {
|
|
|
+ const containerWidth = Math.floor($('#filing-spread').innerWidth() || 0);
|
|
|
+ if (containerWidth <= 0) return;
|
|
|
+
|
|
|
+ const rowHeaderWidth = 25;
|
|
|
+ const fileCountWidth = 70;
|
|
|
+ const scrollbarWidth = 18;
|
|
|
+ const borderWidth = 2;
|
|
|
+ const nameWidth = Math.max(
|
|
|
+ containerWidth - rowHeaderWidth - fileCountWidth - scrollbarWidth - borderWidth,
|
|
|
+ 60
|
|
|
+ );
|
|
|
+ this.sheet.setColumnWidth(0, nameWidth);
|
|
|
+ this.sheet.setColumnWidth(1, fileCountWidth);
|
|
|
+ this.spread.refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 绑定事件
|
|
|
*/
|
|
|
_bindEvents() {
|
|
|
@@ -1835,7 +1871,7 @@ $(document).ready(function() {
|
|
|
* 侧边工具栏展开/收起
|
|
|
*/
|
|
|
const refreshSideLayout = function() {
|
|
|
- filingSjs.spread.refresh();
|
|
|
+ filingSjs.resizeSpreadColumns();
|
|
|
if (fileReference) fileReference.spread.refresh();
|
|
|
};
|
|
|
|
|
|
@@ -1880,6 +1916,7 @@ $(document).ready(function() {
|
|
|
{title: '备注', field: 'remark', hAlign: 1, width: 150, formatter: '@'}
|
|
|
],
|
|
|
emptyRows: 0, headRows: 1, headRowHeight: [32], defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑', font: '12px 微软雅黑',
|
|
|
headColWidth: [30], selectedBackColor: '#fffacd', readOnly: true,
|
|
|
localCache: { key: 'file_detail_reference', colWidth: true },
|
|
|
},
|
|
|
@@ -1898,12 +1935,15 @@ $(document).ready(function() {
|
|
|
// 左右拖拽分隔条
|
|
|
$.divResizer({
|
|
|
select: '#file-right-spr',
|
|
|
- callback: function() { filingSjs.spread.refresh(); },
|
|
|
+ callback: function() { filingSjs.resizeSpreadColumns(); },
|
|
|
});
|
|
|
$.divResizer({
|
|
|
select: '#right-spr',
|
|
|
callback: refreshSideLayout,
|
|
|
});
|
|
|
+ $(window).off('resize.filesjsFiling').on('resize.filesjsFiling', function() {
|
|
|
+ filingSjs.resizeSpreadColumns();
|
|
|
+ });
|
|
|
|
|
|
// ========== 事件委托绑定 ==========
|
|
|
|