|
@@ -11,6 +11,10 @@
|
|
|
const billsGuidance = (function () {
|
|
|
|
|
|
const libSel = $('#stdBillsGuidanceLibSelect');
|
|
|
+ //工作内容
|
|
|
+ let stdBillsJobData = [];
|
|
|
+ //项目特征
|
|
|
+ let stdBillsFeatureData = [];
|
|
|
const bills = {
|
|
|
dom: $('#billsGuidance_bills'),
|
|
|
workBook: null,
|
|
@@ -66,6 +70,35 @@ const billsGuidance = (function () {
|
|
|
events: {
|
|
|
SelectionChanging: function (sender, info) {
|
|
|
billsInitSel(info.newSelections[0].row);
|
|
|
+ },
|
|
|
+ CellDoubleClick: function (sender, args) {
|
|
|
+ let node = bills.tree.items[args.row];
|
|
|
+ if(!node){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(node.children.length === 0){
|
|
|
+ //插入清单
|
|
|
+ let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, node);
|
|
|
+ if(insert){
|
|
|
+ //插入选中的定额
|
|
|
+ let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ insertRations(addRationDatas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ node.setExpanded(!node.expanded);
|
|
|
+ //设置展开收起状态
|
|
|
+ sessionStorage.setItem('stdBillsGuidanceExpState', bills.tree.getExpState(bills.tree.items));
|
|
|
+ renderSheetFunc(args.sheet, function () {
|
|
|
+ let iCount = node.posterityCount(), i, child;
|
|
|
+ for (i = 0; i < iCount; i++) {
|
|
|
+ child = bills.tree.items[args.row + i + 1];
|
|
|
+ args.sheet.setRowVisible(args.row + i + 1, child.visible, args.sheetArea);
|
|
|
+ }
|
|
|
+ args.sheet.invalidateLayout();
|
|
|
+ });
|
|
|
+ args.sheet.repaint();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -138,6 +171,14 @@ const billsGuidance = (function () {
|
|
|
args.sheet.endEdit(true);
|
|
|
}
|
|
|
},
|
|
|
+ CellDoubleClick: function (sender, args) {
|
|
|
+ if(guideItem.headers[args.col]['dataCode'] === 'name'){
|
|
|
+ if(!bills.tree.selected){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ insertRations(getInsertRationData([args.row]));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
const options = {
|
|
@@ -201,7 +242,6 @@ const billsGuidance = (function () {
|
|
|
return;
|
|
|
}
|
|
|
const Events = GC.Spread.Sheets.Events;
|
|
|
- let sheet = workBook.getActiveSheet();
|
|
|
for(let event in events){
|
|
|
workBook.bind(Events[event], events[event]);
|
|
|
}
|
|
@@ -216,6 +256,7 @@ const billsGuidance = (function () {
|
|
|
//默认初始可控制焦点在清单表中
|
|
|
module.workBook.focus();
|
|
|
sheet.options.isProtected = true;
|
|
|
+ sheet.name('stdBillsGuidance_bills');
|
|
|
}
|
|
|
if(module === guideItem){
|
|
|
sheet.options.isProtected = true;
|
|
@@ -250,6 +291,9 @@ const billsGuidance = (function () {
|
|
|
module.tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
|
|
|
module.controller = TREE_SHEET_CONTROLLER.createNew(module.tree, sheet, treeSetting);
|
|
|
module.tree.loadDatas(datas);
|
|
|
+ if(module === bills){
|
|
|
+ initExpandStat();
|
|
|
+ }
|
|
|
module.controller.showTreeData();
|
|
|
}
|
|
|
//项目指引表焦点控制
|
|
@@ -263,8 +307,6 @@ const billsGuidance = (function () {
|
|
|
billsNode.guidance.tree.selected = node;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
//根据项目指引的类型设置单元格类型,定额类型的项目指引为复选框
|
|
|
//@param {Array}nodes @return {void}
|
|
@@ -304,11 +346,36 @@ const billsGuidance = (function () {
|
|
|
guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
|
|
|
}
|
|
|
}
|
|
|
+ //初始化清单的工作内容和项目特征
|
|
|
+ //@param {Number}billsLibId @return {void}
|
|
|
+ function initJobAndCharacter(billsLibId){
|
|
|
+ CommonAjax.post('/stdBillsEditor/getJobContent', {userId: userID, billsLibId: billsLibId}, function (datas) {
|
|
|
+ stdBillsJobData = datas;
|
|
|
+ });
|
|
|
+ CommonAjax.post('/stdBillsEditor/getItemCharacter', {userId: userID, billsLibId: billsLibId}, function (datas) {
|
|
|
+ stdBillsFeatureData = datas;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //初始化清单展开收起状态
|
|
|
+ //@return {void}
|
|
|
+ function initExpandStat(){
|
|
|
+ //读取展开收起状态
|
|
|
+ let currentExpState = sessionStorage.getItem('stdBillsGuidanceExpState');
|
|
|
+ if(currentExpState){
|
|
|
+ bills.tree.setExpandedByState(bills.tree.items, currentExpState);
|
|
|
+ }
|
|
|
+ //非叶子节点默认收起
|
|
|
+ else{
|
|
|
+ bills.tree.setRootExpanded(bills.tree.roots, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
//初始选择清单指引库
|
|
|
//@param {Number}libID @return {void}
|
|
|
function libInitSel(libID){
|
|
|
//获取清单
|
|
|
CommonAjax.post('/billsGuidance/api/getLibWithBills', {libID: libID}, function(rstData){
|
|
|
+ //获取清单库中的工作内容和项目特征
|
|
|
+ initJobAndCharacter(rstData.guidanceLib.billsLibId);
|
|
|
initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, rstData.bills);
|
|
|
//每一棵项目指引树挂在清单节点上
|
|
|
for(let node of bills.tree.items){
|
|
@@ -322,8 +389,12 @@ const billsGuidance = (function () {
|
|
|
//@param {Array}libDats @return {void}
|
|
|
function initLibs(libDatas){
|
|
|
libSel.empty();
|
|
|
+ let selectedLib = sessionStorage.getItem('stdBillsGuidance');
|
|
|
for(let libData of libDatas){
|
|
|
- let opt = `<option value="${libData.id}">${libData.name}</option>`;
|
|
|
+ let opt = $('<option>').val(libData.id).text(libData.name);
|
|
|
+ if(selectedLib && libData.id == selectedLib){
|
|
|
+ opt.attr('selected', 'selected');
|
|
|
+ }
|
|
|
libSel.append(opt);
|
|
|
}
|
|
|
//初始默认选择
|
|
@@ -336,6 +407,48 @@ const billsGuidance = (function () {
|
|
|
initWorkBooks(modules);
|
|
|
|
|
|
}
|
|
|
+ //获取选中的行
|
|
|
+ //@return {Array}
|
|
|
+ function getCheckedRows(){
|
|
|
+ let rst = [];
|
|
|
+ let itemSheet = guideItem.workBook.getActiveSheet();
|
|
|
+ for(let row = 0; row < itemSheet.getRowCount(); row++){
|
|
|
+ let rowV = itemSheet.getValue(row, 1);
|
|
|
+ if(rowV){
|
|
|
+ rst.push(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ //获取选中的定额数据
|
|
|
+ //@param {Array}rows @return {Array}
|
|
|
+ function getInsertRationData(rows){
|
|
|
+ let rst = [];
|
|
|
+ for(let row of rows){
|
|
|
+ let node = bills.tree.selected.guidance.tree.items[row];
|
|
|
+ if(node && node.data.type === itemType.ration){
|
|
|
+ rst.push({itemQuery: {userID: userID, ID: node.data.rationID}, rationType: rationType.ration});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ //插入定额
|
|
|
+ //@return {void}
|
|
|
+ function insertRations(addRationDatas){
|
|
|
+ if(addRationDatas.length > 0){
|
|
|
+ projectObj.project.Ration.addMultiRation(addRationDatas, function () {
|
|
|
+ //恢复
|
|
|
+ let sheet = guideItem.workBook.getActiveSheet();
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ for(let row = 0; row < sheet.getRowCount(); row++){
|
|
|
+ if(sheet.getValue(row, 1)){
|
|
|
+ sheet.setValue(row, 1, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
//各按钮监听事件
|
|
|
//@return {void}
|
|
|
function bindBtn(){
|
|
@@ -348,14 +461,30 @@ const billsGuidance = (function () {
|
|
|
//更改清单指引库
|
|
|
$('#stdBillsGuidanceLibSelect').change(function () {
|
|
|
libInitSel($(this).select().val());
|
|
|
+ //记住选项
|
|
|
+ sessionStorage.setItem('stdBillsGuidance', $(this).select().val());
|
|
|
+ //清除展开收起状态sessionStorage
|
|
|
+ sessionStorage.removeItem('stdBillsGuidanceExpState');
|
|
|
});
|
|
|
//插入定额
|
|
|
$('#guidanceInsertRation').click(function () {
|
|
|
-
|
|
|
+ let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ insertRations(addRationDatas);
|
|
|
});
|
|
|
//插入清单
|
|
|
$('#guidanceInsertBills').click(function () {
|
|
|
-
|
|
|
+ //插入清单
|
|
|
+ if(!bills.tree.selected){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(bills.tree.selected.children.length === 0){
|
|
|
+ let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, bills.tree.selected);
|
|
|
+ if(insert){
|
|
|
+ //插入选中的定额
|
|
|
+ let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ insertRations(addRationDatas);
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
//刷新表
|
|
@@ -369,7 +498,7 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return {initViews, bindBtn, refreshWorkBook};
|
|
|
+ return {initViews, bindBtn, refreshWorkBook, bills};
|
|
|
})();
|
|
|
|
|
|
$(document).ready(function(){
|