|
@@ -124,11 +124,53 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ //定额章节树
|
|
|
+ const section = {
|
|
|
+ dom: $('#sectionSpread'),
|
|
|
+ workBook: null,
|
|
|
+ cache: [],
|
|
|
+ tree: null,
|
|
|
+ controller: null,
|
|
|
+ treeSetting: {
|
|
|
+ treeCol: 0,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ cols: [{
|
|
|
+ width: 400,
|
|
|
+ readOnly: true,
|
|
|
+ head: {
|
|
|
+ titleNames: ["名称"],
|
|
|
+ spanCols: [1],
|
|
|
+ spanRows: [1],
|
|
|
+ vAlign: [1],
|
|
|
+ hAlign: [1],
|
|
|
+ font: ["Arial"]
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ field: "name",
|
|
|
+ vAlign: 1,
|
|
|
+ hAlign: 0,
|
|
|
+ font: "Arial"
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ headers: [
|
|
|
+ {name: '名称', dataCode: 'name', width: 400, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
+ ],
|
|
|
+ events: {
|
|
|
+ SelectionChanged: function (sender, info) {
|
|
|
+ sectionInitSel(info.newSelections[0].row)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
const ration = {
|
|
|
dom: $('#rationSpread'),
|
|
|
workBook: null,
|
|
|
- datas: [],
|
|
|
- cache: [],
|
|
|
+ datas: [],//所有的数据,搜索定额时,从所有数据中筛选
|
|
|
+ cache: [],//显示在表格上的数据,添加定额可以有效根据行识别定额
|
|
|
headers: [
|
|
|
{name: '选择', dataCode: 'select', width: 50, vAlign: 'center', hAlign: 'center'},
|
|
|
{name: '编码', dataCode: 'code', width: 110, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
@@ -247,7 +289,7 @@ const billsGuidance = (function () {
|
|
|
function cleanData(sheet, headers, rowCount){
|
|
|
renderSheetFunc(sheet, function () {
|
|
|
sheet.clear(-1, 0, -1, headers.length, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
|
|
|
- if (rowCount > 0) {
|
|
|
+ if (rowCount >= 0) {
|
|
|
sheet.setRowCount(rowCount);
|
|
|
}
|
|
|
});
|
|
@@ -391,24 +433,58 @@ const billsGuidance = (function () {
|
|
|
};
|
|
|
renderSheetFunc(sheet, fuc);
|
|
|
}
|
|
|
+ //根据定额章节树ID获取定额(从数据缓存中获取,定额数据一开始一次性拉取)
|
|
|
+ //@param {Number}sectionId {Array}rations @return {Array}
|
|
|
+ function getRationsBySectionId(sectionId, rations) {
|
|
|
+ if(!sectionId || !rations){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ return _.filter(rations, {sectionId});
|
|
|
+ }
|
|
|
+ //定额章节树焦点控制
|
|
|
+ //@param {Number}row @return {void}
|
|
|
+ function sectionInitSel(row) {
|
|
|
+ let rationSheet = ration.workBook.getActiveSheet();
|
|
|
+ let sectionNode = section.tree ? section.tree.items[row] : null;
|
|
|
+ if(sectionNode && sectionNode.children.length === 0){
|
|
|
+ let sectionRations = getRationsBySectionId(sectionNode.data.ID, ration.datas);
|
|
|
+ ration.cache = sectionRations;
|
|
|
+ showData(rationSheet, ration.headers, sectionRations);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cleanData(rationSheet, ration.headers, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
//初始化定额条目
|
|
|
//@param {Number}rationLibId @return {void}
|
|
|
function initRationItems(rationLibId){
|
|
|
$.bootstrapLoading.start();
|
|
|
- CommonAjax.post('/rationRepository/api/getRationItemsByLib', {rationLibId: rationLibId}, function (rstData) {
|
|
|
- rstData.sort(function (a, b) {
|
|
|
- let rst = 0;
|
|
|
- if(a.code > b.code){
|
|
|
- rst = 1;
|
|
|
- }
|
|
|
- else if(a.code < b.code){
|
|
|
- rst = -1;
|
|
|
- }
|
|
|
- return rst;
|
|
|
+ //获取定额章节树
|
|
|
+ let sectionSheet = section.workBook.getActiveSheet();
|
|
|
+ CommonAjax.post('/rationRepository/api/getRationTree', {rationLibId: rationLibId}, function (sectionDatas) {
|
|
|
+ //获取所有定额数据
|
|
|
+ CommonAjax.post('/rationRepository/api/getRationItemsByLib', {rationLibId: rationLibId}, function (rstData) {
|
|
|
+ section.cache = sectionDatas;
|
|
|
+ initTree(section, section.workBook.getActiveSheet(), section.treeSetting, sectionDatas);
|
|
|
+ //初始焦点在第一行(切换库)
|
|
|
+ sectionSheet.setActiveCell(0, 0);
|
|
|
+ rstData.sort(function (a, b) {
|
|
|
+ let rst = 0;
|
|
|
+ if(a.code > b.code){
|
|
|
+ rst = 1;
|
|
|
+ }
|
|
|
+ else if(a.code < b.code){
|
|
|
+ rst = -1;
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ });
|
|
|
+ ration.datas = rstData;
|
|
|
+ sectionInitSel(0);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }, function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
});
|
|
|
- ration.datas = rstData;
|
|
|
- ration.cache = rstData;
|
|
|
- showData(ration.workBook.getActiveSheet(), ration.headers, rstData);
|
|
|
+ }, function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
}
|
|
@@ -775,16 +851,40 @@ const billsGuidance = (function () {
|
|
|
return data.code.includes(searchStr);
|
|
|
});
|
|
|
}
|
|
|
+ $('.top-content').hide();
|
|
|
+ $('#searchCount').text(`搜索结果: ${ration.cache.length}`);
|
|
|
+ $('#rationSearchResult').show();
|
|
|
+ autoFlashHeight();
|
|
|
+ ration.workBook.refresh();
|
|
|
let rationSheet = ration.workBook.getActiveSheet();
|
|
|
renderSheetFunc(rationSheet, function () {
|
|
|
+ clearCheckedRation(getCheckedRationRows());
|
|
|
showData(rationSheet, ration.headers, ration.cache);
|
|
|
})
|
|
|
});
|
|
|
+ //关闭搜索
|
|
|
+ $('#rationSearchResult a').click(function () {
|
|
|
+ $('.top-content').show();
|
|
|
+ $('#rationSearchResult').hide();
|
|
|
+ autoFlashHeight();
|
|
|
+ renderSheetFunc(ration.workBook.getActiveSheet(), function () {
|
|
|
+ clearCheckedRation(getCheckedRationRows());
|
|
|
+ });
|
|
|
+ section.workBook.refresh();
|
|
|
+ ration.workBook.refresh();
|
|
|
+ $('#searchText').val('');
|
|
|
+ //恢复章节树下的定额
|
|
|
+ sectionInitSel(section.workBook.getActiveSheet().getActiveRowIndex());
|
|
|
+ });
|
|
|
+ //执行搜索
|
|
|
+ $('#searchText').keyup(function (e) {
|
|
|
+ $('#searchBtn').click();
|
|
|
+ });
|
|
|
}
|
|
|
//初始化视图
|
|
|
//@param {void} @return {void}
|
|
|
function initViews(){
|
|
|
- let modules = [bills, guideItem, ration];
|
|
|
+ let modules = [bills, guideItem, section, ration];
|
|
|
initWorkBooks(modules);
|
|
|
getLibWithBills(libID);
|
|
|
initBtn();
|