|
@@ -1076,7 +1076,7 @@ $(document).ready(function() {
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
if (tab.attr('content') === '#std-chapter') {
|
|
|
if (!stdChapter) {
|
|
|
- stdChapter = new stdLib('#std-chapter-spread', 'chapter', {
|
|
|
+ stdChapter = new stdLib('#std-chapter', 'chapter', {
|
|
|
id: 'chapter_id',
|
|
|
pid: 'pid',
|
|
|
order: 'order',
|
|
@@ -1095,12 +1095,12 @@ $(document).ready(function() {
|
|
|
headRowHeight: [40],
|
|
|
defaultRowHeight: 21,
|
|
|
});
|
|
|
- stdChapter.loadLib(1);
|
|
|
+ stdChapter.loadLib($('select', '#std-chapter').val());
|
|
|
}
|
|
|
stdChapter.spread.refresh();
|
|
|
} else if (tab.attr('content') === '#std-bills') {
|
|
|
if (!stdBills) {
|
|
|
- stdBills = new stdLib('#std-bills-spread', 'bills', {
|
|
|
+ stdBills = new stdLib('#std-bills', 'bills', {
|
|
|
id: 'bill_id',
|
|
|
pid: 'pid',
|
|
|
order: 'order',
|
|
@@ -1109,7 +1109,7 @@ $(document).ready(function() {
|
|
|
keys: ['id', 'list_id', 'bill_id']
|
|
|
}, {
|
|
|
cols: [
|
|
|
- {title: '清单编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
+ {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
{title: '名称', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
|
|
|
{title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
|
|
|
],
|
|
@@ -1119,14 +1119,14 @@ $(document).ready(function() {
|
|
|
headRowHeight: [40],
|
|
|
defaultRowHeight: 21,
|
|
|
});
|
|
|
- stdBills.loadLib(1);
|
|
|
+ stdBills.loadLib($('select', '#std-bills').val());
|
|
|
}
|
|
|
stdBills.spread.refresh();
|
|
|
} else if (tab.attr('content') === '#deal-bills') {
|
|
|
if (!dealBills) {
|
|
|
dealBills = new DealBills('#deal-bills-spread', {
|
|
|
cols: [
|
|
|
- {title: '清单编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
|
|
|
+ {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
|
|
|
{title: '名称', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
|
|
|
{title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
|
|
|
{title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
|
|
@@ -1180,7 +1180,8 @@ $(document).ready(function() {
|
|
|
|
|
|
class stdLib {
|
|
|
constructor(selector, stdType, treeSetting, spreadSetting) {
|
|
|
- this.obj = $(selector)[0];
|
|
|
+ const self = this;
|
|
|
+ this.obj = $(selector + '-spread')[0];
|
|
|
this.url = '/std/' + stdType;
|
|
|
this.treeSetting = treeSetting;
|
|
|
treeSetting.preUrl = this.url;
|
|
@@ -1218,13 +1219,26 @@ $(document).ready(function() {
|
|
|
});
|
|
|
});
|
|
|
this.pathTree = createNewPathTree('base', this.treeSetting);
|
|
|
+ this.cacheLib = [];
|
|
|
+ $('select', selector).change(function () {
|
|
|
+ self.loadLib(parseInt(this.value));
|
|
|
+ });
|
|
|
}
|
|
|
loadLib (listId) {
|
|
|
- const self = this;
|
|
|
- postData(this.url+'/get-data', {list_id: listId}, function (data) {
|
|
|
- self.pathTree.loadDatas(data);
|
|
|
- SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
|
|
|
+ const cacheData = this.cacheLib.find(function (lib) {
|
|
|
+ return lib.id === listId;
|
|
|
});
|
|
|
+ if (cacheData) {
|
|
|
+ this.pathTree.loadDatas(cacheData.data);
|
|
|
+ SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'tree', this.pathTree);
|
|
|
+ } else {
|
|
|
+ const self = this;
|
|
|
+ postData(this.url+'/get-data', {list_id: listId}, function (data) {
|
|
|
+ self.cacheLib.push({id: listId, data: data});
|
|
|
+ self.pathTree.loadDatas(data);
|
|
|
+ SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
class DealBills {
|