|
@@ -9,7 +9,10 @@
|
|
|
*/
|
|
|
|
|
|
const billsGuidance = (function () {
|
|
|
-
|
|
|
+ let currentLib = null;
|
|
|
+ //库类型
|
|
|
+ const libType = {'guidance': 1, 'elf': 2}; //清单指引、清单精灵
|
|
|
+ const libTypeText = {1: '清单指引', 2: '清单精灵'};
|
|
|
const libSel = $('#stdBillsGuidanceLibSelect');
|
|
|
//工作内容
|
|
|
let stdBillsJobData = [];
|
|
@@ -114,7 +117,7 @@ const billsGuidance = (function () {
|
|
|
canAdd = ProjectController.addBills(projectObj.project, projectObj.mainController, std);
|
|
|
if(canAdd !== null || canAdd !== false){
|
|
|
//插入选中的定额
|
|
|
- let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
insertRations(addRationDatas);
|
|
|
}
|
|
|
if(canAdd === false && $.bootstrapLoading.isLoading()){
|
|
@@ -125,7 +128,7 @@ const billsGuidance = (function () {
|
|
|
canAdd = ProjectController.addBills(projectObj.project, projectObj.mainController, std);
|
|
|
if(canAdd !== null || canAdd !== false){
|
|
|
//插入选中的定额
|
|
|
- let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
insertRations(addRationDatas);
|
|
|
}
|
|
|
if(canAdd === false && $.bootstrapLoading.isLoading()){
|
|
@@ -142,7 +145,7 @@ const billsGuidance = (function () {
|
|
|
let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, node);
|
|
|
if(insert){
|
|
|
//插入选中的定额
|
|
|
- let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
insertRations(addRationDatas);
|
|
|
}
|
|
|
}
|
|
@@ -263,6 +266,73 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ const elfItem = {
|
|
|
+ dom: $('#billsGuidance_items'),
|
|
|
+ workBook: null,
|
|
|
+ tree: null,
|
|
|
+ controller: null,
|
|
|
+ treeSetting: {
|
|
|
+ treeCol: 0,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ cols: [
|
|
|
+ {
|
|
|
+ width: 250,
|
|
|
+ readOnly: true,
|
|
|
+ head: {
|
|
|
+ titleNames: ["施工工序"],
|
|
|
+ spanCols: [1],
|
|
|
+ spanRows: [1],
|
|
|
+ vAlign: [1],
|
|
|
+ hAlign: [1],
|
|
|
+ font: ["Arial"]
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ field: "name",
|
|
|
+ vAlign: 1,
|
|
|
+ hAlign: 1,
|
|
|
+ font: "Arial"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 250,
|
|
|
+ readOnly: false,
|
|
|
+ head: {
|
|
|
+ titleNames: ["选项"],
|
|
|
+ spanCols: [1],
|
|
|
+ spanRows: [1],
|
|
|
+ vAlign: [1],
|
|
|
+ hAlign: [1],
|
|
|
+ font: ["Arial"]
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ field: "options",
|
|
|
+ vAlign: 1,
|
|
|
+ hAlign: 0,
|
|
|
+ font: "Arial"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ headers: [
|
|
|
+ {name: '施工工序', dataCode: 'name', width: 250, vAlign: 'center', hAlign: 'center', formatter: '@'},
|
|
|
+ {name: '选项', dataCode: 'options', width: 250, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
+ ],
|
|
|
+ events: {
|
|
|
+ CellClick: function (sender, args) {
|
|
|
+ if(elfItem.headers[args.col]['dataCode'] === 'options' && args.sheetArea === 3){
|
|
|
+ if(!args.sheet.getCell(args.row, args.col).locked() && !args.sheet.isEditing()){
|
|
|
+ args.sheet.startEdit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ClipboardPasting: function (sender, info) {
|
|
|
+ info.cancel = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
const options = {
|
|
|
workBook: {
|
|
|
tabStripVisible: false,
|
|
@@ -348,6 +418,11 @@ const billsGuidance = (function () {
|
|
|
sheet.getRange(-1, 0, -1, 1).locked(false);
|
|
|
sheet.getRange(-1, 1, -1, 1).locked(true);
|
|
|
}
|
|
|
+ if(module === elfItem){
|
|
|
+ sheet.options.isProtected = true;
|
|
|
+ sheet.getRange(-1, 0, -1, 1).locked(true);
|
|
|
+ sheet.getRange(-1, 1, -1, 1).locked(false);
|
|
|
+ }
|
|
|
setOptions(module.workBook, options);
|
|
|
buildHeader(module.workBook.getActiveSheet(), module.headers);
|
|
|
bindEvent(module.workBook, module.events);
|
|
@@ -393,6 +468,18 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //清单精灵表焦点控制
|
|
|
+ //@param {Number}row @return {void}
|
|
|
+ function elfItemInitSel(row){
|
|
|
+ let billsNode = bills.tree.selected;
|
|
|
+ let node = null;
|
|
|
+ if(billsNode && billsNode.elf.tree){
|
|
|
+ node = billsNode.elf.tree.items[row];
|
|
|
+ if(node){
|
|
|
+ billsNode.elf.tree.selected = node;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//根据项目指引的类型设置单元格类型,定额类型的项目指引为复选框
|
|
|
//@param {Array}nodes @return {void}
|
|
|
function setItemCellType(nodes){
|
|
@@ -409,9 +496,17 @@ const billsGuidance = (function () {
|
|
|
//清单表焦点控制
|
|
|
//@param {Number}row @return {void}
|
|
|
function billsInitSel(row){
|
|
|
+ if(currentLib.type && currentLib.type === libType.elf){
|
|
|
+ billsSelElf(row);
|
|
|
+ }else {
|
|
|
+ billsSelGuidance(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //清单焦点变换-清单指引操作
|
|
|
+ //@param {Number}row @return {void}
|
|
|
+ function billsSelGuidance(row){
|
|
|
let guideSheet = guideItem.workBook.getActiveSheet();
|
|
|
cleanData(guideSheet, guideItem.headers, -1);
|
|
|
- refreshInsertRation();
|
|
|
if(!bills.tree){
|
|
|
return;
|
|
|
}
|
|
@@ -420,6 +515,7 @@ const billsGuidance = (function () {
|
|
|
return;
|
|
|
}
|
|
|
bills.tree.selected = node;
|
|
|
+ refreshInsertRation();
|
|
|
if(!node.guidance.tree){
|
|
|
CommonAjax.post('/billsGuidance/api/getItemsByBills', {guidanceLibID: libSel.val(), billsID: node.getID()}, function (rstData) {
|
|
|
initTree(node.guidance, guideSheet, guideItem.treeSetting, rstData);
|
|
@@ -435,6 +531,292 @@ const billsGuidance = (function () {
|
|
|
guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
|
|
|
}
|
|
|
}
|
|
|
+ //清单焦点变换-清单精灵操作
|
|
|
+ //@param {Number}row @return {void}
|
|
|
+ function billsSelElf(row) {
|
|
|
+ let elfSheet = elfItem.workBook.getActiveSheet();
|
|
|
+ cleanData(elfSheet, elfItem.headers, -1);
|
|
|
+ if(!bills.tree){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let node = bills.tree.items[row];
|
|
|
+ if(!node){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ bills.tree.selected = node;
|
|
|
+ refreshInsertRation();
|
|
|
+ if(!node.elf.tree){
|
|
|
+ CommonAjax.post('/billsGuidance/api/getItemsByBills', {guidanceLibID: libSel.val(), billsID: node.getID()}, function (rstData) {
|
|
|
+ //定额数据删除编号信息
|
|
|
+ for(let rData of rstData){
|
|
|
+ if(rData.type === itemType.ration){
|
|
|
+ let nameArr = rData.name.split(' ');
|
|
|
+ if(nameArr.length > 0){
|
|
|
+ nameArr.splice(0, 1);
|
|
|
+ rData.name = nameArr.join(' ');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ node.elf.datas = rstData;
|
|
|
+ //第一层节点数据
|
|
|
+ let firstLevelDatas = _.filter(rstData, function (data) {
|
|
|
+ return data.ParentID == -1;
|
|
|
+ });
|
|
|
+ //初始数据的选项显示请选择
|
|
|
+ for(let fData of firstLevelDatas){
|
|
|
+ let options = getOptions(fData, rstData);
|
|
|
+ fData.options = options.length > 0 ? '请选择' : '';
|
|
|
+ }
|
|
|
+ initTree(node.elf, elfSheet, elfItem.treeSetting, firstLevelDatas);
|
|
|
+ setOptionsCellType(node.elf.tree.items);
|
|
|
+ //elfSheet.getRange(-1, 1, -1, 1).cellType(getOptionsCellType(null, null, null));
|
|
|
+ //setItemCellType(node.guidance.tree.items);
|
|
|
+ //项目指引初始焦点
|
|
|
+ elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ node.elf.controller.showTreeData();
|
|
|
+ //elfSheet.getRange(-1, 1, -1, 1).cellType(getOptionsCellType(null, null, null));
|
|
|
+ setOptionsCellType(node.elf.tree.items);
|
|
|
+ //项目指引初始焦点
|
|
|
+ elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取施工工序含有的选项(即当前施工工序的子项),获取的顺序按照NextSiblingID排序
|
|
|
+ //@param {Object}process {Array}datas @return {Array}
|
|
|
+ function getOptions(process, datas) {
|
|
|
+ let rst = [];
|
|
|
+ if(!process || !process.ID){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ let options = _.filter(datas, function (data) {
|
|
|
+ return data.ParentID == process.ID;
|
|
|
+ });
|
|
|
+ if(options.length === 0){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ //根据NextSiblingID排序
|
|
|
+ let IDMapping = {};
|
|
|
+ for(let opt of options){
|
|
|
+ IDMapping[opt.ID] = {self: opt, next: null, pre: null};
|
|
|
+ }
|
|
|
+ for(let opt of options){
|
|
|
+ let next = IDMapping[opt.NextSiblingID] ? IDMapping[opt.NextSiblingID] : null;
|
|
|
+ if(next){
|
|
|
+ next.pre = IDMapping[opt.ID];
|
|
|
+ IDMapping[opt.ID]['next'] = next;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let first = null,
|
|
|
+ rank = 0;
|
|
|
+ for(let ID in IDMapping){
|
|
|
+ let obj = IDMapping[ID];
|
|
|
+ if(!obj.pre){
|
|
|
+ first = obj;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ while(first){
|
|
|
+ rank++;
|
|
|
+ first.self.rank = rank;
|
|
|
+ rst.push(first.self);
|
|
|
+ first = first.next;
|
|
|
+ }
|
|
|
+
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ //设置清单精灵选项单元格
|
|
|
+ //@param {Array}nodes @return {void}
|
|
|
+ function setOptionsCellType(nodes) {
|
|
|
+ let elfSheet = elfItem.workBook.getActiveSheet();
|
|
|
+ for(let node of nodes){
|
|
|
+ if(node.data.options !== ''){
|
|
|
+ elfSheet.getCell(node.serialNo(), 1).locked(false).cellType(getOptionsCellType());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ elfSheet.getCell(node.serialNo(), 1).locked(true).cellType(new GC.Spread.Sheets.CellTypes.Base());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取选项下拉多选单元格
|
|
|
+ //@param {void} @return {void}
|
|
|
+ function getOptionsCellType() {
|
|
|
+ let me = this;
|
|
|
+ let elfSheet= elfItem.workBook.getActiveSheet();
|
|
|
+ function OptionsCellType() {
|
|
|
+ this.isEscKey=false;
|
|
|
+ this.displayText='';
|
|
|
+ }
|
|
|
+ function getHtml(node, cellRect, cellStyle) {
|
|
|
+ if(!node){
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ let height = cellRect.height;
|
|
|
+ let htmlArr = [];
|
|
|
+ let options = getOptions(node.data, bills.tree.selected.elf.datas);
|
|
|
+ let optionsTitle = node.data.options.split(';').join('\n');
|
|
|
+ htmlArr.push(`<div title="${optionsTitle}" style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div><div style="background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;">`);
|
|
|
+ for(let opt of options){
|
|
|
+ htmlArr.push(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
|
|
|
+ <input rank="${opt.rank}" value="${opt.ID}" style="margin-left: 5px; vertical-align: middle" type="checkbox"
|
|
|
+ ${node.data.optionChecked && _.find(node.data.optionChecked, {ID: opt.ID}) ? 'checked' : ''}> ${opt.name ? opt.name : ''}</div>`);
|
|
|
+ }
|
|
|
+ htmlArr.push(`</div>`);
|
|
|
+ return htmlArr.join('');
|
|
|
+ }
|
|
|
+ //选择后处理
|
|
|
+ function doAfterSel(node) {
|
|
|
+ let checkedSels = $('.elf-options').find('input:checked');
|
|
|
+ let checkedNameArr = [],
|
|
|
+ optionChecked= [];
|
|
|
+ for(let checkSel of checkedSels){
|
|
|
+ let opt = _.cloneDeep(_.find(bills.tree.selected.elf.datas, {ID: $(checkSel).val()}));
|
|
|
+ opt.rank = $(checkSel).attr('rank');
|
|
|
+ checkedNameArr.push(opt.name);
|
|
|
+ optionChecked.push(opt);
|
|
|
+ }
|
|
|
+ this.displayText = checkedNameArr.length > 0 ? checkedNameArr.join(';') : '请选择';
|
|
|
+ node.data.options = this.displayText;
|
|
|
+ node.data.optionChecked = optionChecked;
|
|
|
+ //删除节点
|
|
|
+ let deleteInfo = getDeleteInfo(node, optionChecked);
|
|
|
+ for(let dInfo of deleteInfo){
|
|
|
+ if(node.tree.delete(dInfo.node)){
|
|
|
+ elfSheet.deleteRows(dInfo.deleteRow, dInfo.deleteCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //插入节点
|
|
|
+ for(let perCheked of optionChecked){
|
|
|
+ let exist = false;
|
|
|
+ for(let subNode of node.children){
|
|
|
+ if(subNode.data.ID === perCheked.ID){
|
|
|
+ exist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //不重复且不为定额时插入
|
|
|
+ if(!exist && perCheked.type !== itemType.ration){
|
|
|
+ insertNodeByData(node, perCheked);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.tree.items, false);
|
|
|
+ setOptionsCellType(node.tree.items);
|
|
|
+ refreshInsertRation();
|
|
|
+ }
|
|
|
+ //获取删除节点信息
|
|
|
+ function getDeleteInfo(node, optionChecked) {
|
|
|
+ let rst = [];
|
|
|
+ for(let subNode of node.children){
|
|
|
+ let exist = false;
|
|
|
+ for(let perChecked of optionChecked){
|
|
|
+ if(subNode.data.ID === perChecked.ID){
|
|
|
+ exist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!exist){
|
|
|
+ let deleteRow = subNode.serialNo(),
|
|
|
+ deleteCount = subNode.posterityCount() + 1;
|
|
|
+ rst.push({node: subNode, deleteRow: deleteRow, deleteCount: deleteCount});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ //插入单个节点,node:当前操作的节点
|
|
|
+ function insertNodeByData(node, data) {
|
|
|
+ let sameDepthNodes = node.children;
|
|
|
+ let insertNextSiblingID = -1,
|
|
|
+ insertParentID = node.data.ID;
|
|
|
+ data.options = getOptions(data, bills.tree.selected.elf.datas).length > 0 ? '请选择' : '';
|
|
|
+ //确定插入位置
|
|
|
+ for(let subNode of sameDepthNodes){
|
|
|
+ if(data.rank < subNode.data.rank){
|
|
|
+ insertNextSiblingID = subNode.data.ID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let newNode = node.tree.insertByData(data, insertParentID, insertNextSiblingID);
|
|
|
+ elfSheet.addRows(newNode.serialNo(), 1);
|
|
|
+ node.tree.selected = newNode;
|
|
|
+ elfSheet.setSelection(newNode.serialNo(), elfSheet.getSelections()[0].col, 1, 1);
|
|
|
+
|
|
|
+ }
|
|
|
+ OptionsCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
|
|
|
+
|
|
|
+ OptionsCellType.prototype.createEditorElement = function (context) {
|
|
|
+ let element = document.createElement("div");//这里创建的,会自动销毁
|
|
|
+ return element
|
|
|
+ };
|
|
|
+ OptionsCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
|
|
|
+ if (editorContext) {
|
|
|
+ let $editor = $(editorContext);
|
|
|
+ $editor.css("position", "fixed");
|
|
|
+ $editor.css("background", "white");
|
|
|
+ $editor.css("width", cellRect.width);
|
|
|
+ $editor.attr("gcUIElement", "gcEditingInput");
|
|
|
+ let node = bills.tree.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
|
|
|
+ $editor.html(getHtml(node, cellRect, cellStyle));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ OptionsCellType.prototype.deactivateEditor = function (editorContext, context) {
|
|
|
+
|
|
|
+ };
|
|
|
+ OptionsCellType.prototype.setEditorValue = function (editor, value, context) {
|
|
|
+ this.displayText = value;
|
|
|
+ };
|
|
|
+ OptionsCellType.prototype.getEditorValue = function (editor, context) {
|
|
|
+ let me = this;
|
|
|
+ let node = bills.tree.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
|
|
|
+ if(this.isEscKey !=true){
|
|
|
+ renderSheetFunc(elfSheet, function () {
|
|
|
+ doAfterSel.call(me, node);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.isEscKey = false;
|
|
|
+ return this.displayText;
|
|
|
+ };
|
|
|
+ OptionsCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
|
|
|
+
|
|
|
+ };
|
|
|
+ OptionsCellType.prototype.isReservedKey = function (e, context) {
|
|
|
+ //cell type handle tab key by itself
|
|
|
+ this.isEscKey = e.keyCode === GC.Spread.Commands.Key.esc;
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ /* OptionsCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
|
|
|
+ if(style.backColor){
|
|
|
+ ctx.fillStyle = style.backColor;
|
|
|
+ ctx.fillRect(x, y, w, h);
|
|
|
+ ctx.save();
|
|
|
+ }
|
|
|
+ //边长
|
|
|
+ const l = 7;
|
|
|
+ let leftPointX = x + w - 15,
|
|
|
+ rightPointX = leftPointX + l,
|
|
|
+ middlePointX = (leftPointX + rightPointX)/2;
|
|
|
+ const cos30 = Math.cos(2*Math.PI * 30 / 360);
|
|
|
+ let hL = l * cos30;
|
|
|
+ let beginY = y + h/2 - hL;
|
|
|
+ ctx.beginPath();
|
|
|
+ ctx.moveTo(leftPointX, beginY);
|
|
|
+ ctx.lineTo(rightPointX, beginY);
|
|
|
+ ctx.lineTo(middlePointX, beginY + hL);
|
|
|
+ ctx.fillStyle = 'black';
|
|
|
+ ctx.fill();
|
|
|
+ ctx.save();
|
|
|
+ };*/
|
|
|
+ // override getHitInfo to allow cell type get mouse messages
|
|
|
+ OptionsCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
+ return {
|
|
|
+ x: x,
|
|
|
+ y: y,
|
|
|
+ row: context.row,
|
|
|
+ col: context.col,
|
|
|
+ cellStyle: cellStyle,
|
|
|
+ cellRect: cellRect,
|
|
|
+ sheetArea: context.sheetArea
|
|
|
+ };
|
|
|
+ };
|
|
|
+ return new OptionsCellType();
|
|
|
+ }
|
|
|
//初始化清单的工作内容和项目特征
|
|
|
//@param {Number}billsLibId @return {void}
|
|
|
function initJobAndCharacter(billsLibId){
|
|
@@ -473,12 +855,34 @@ const billsGuidance = (function () {
|
|
|
//获取清单
|
|
|
$.bootstrapLoading.start();
|
|
|
CommonAjax.post('/billsGuidance/api/getLibWithBills', {libID: libID}, function(rstData){
|
|
|
+ currentLib = rstData.guidanceLib;
|
|
|
+ if(guideItem.workBook){
|
|
|
+ guideItem.workBook.destroy();
|
|
|
+ guideItem.workBook = null;
|
|
|
+ }
|
|
|
+ if(elfItem.workBook){
|
|
|
+ elfItem.workBook.destroy();
|
|
|
+ elfItem.workBook = null;
|
|
|
+ }
|
|
|
+ initViews();
|
|
|
//获取清单库中的工作内容和项目特征
|
|
|
initJobAndCharacter(rstData.guidanceLib.billsLibId);
|
|
|
initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, rstData.bills);
|
|
|
- //每一棵项目指引树挂在清单节点上
|
|
|
- for(let node of bills.tree.items){
|
|
|
- node.guidance = {tree: null, controller: null};
|
|
|
+ //清单精灵
|
|
|
+ if(rstData.guidanceLib.type && rstData.guidanceLib.type == libType.elf){
|
|
|
+ $('#stdBillsGuidanceTab').text('清单精灵');
|
|
|
+ //每一个清单节点下挂载一棵清单精灵树
|
|
|
+ for(let node of bills.tree.items){
|
|
|
+ node.elf = {tree: null, controller: null, datas: []}; //挂载全部数据,数据不一定全成为树节点
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //清单指引
|
|
|
+ else {
|
|
|
+ $('#stdBillsGuidanceTab').text('清单指引');
|
|
|
+ //每一棵项目指引树挂在清单节点上
|
|
|
+ for(let node of bills.tree.items){
|
|
|
+ node.guidance = {tree: null, controller: null};
|
|
|
+ }
|
|
|
}
|
|
|
setTagForHint(bills.tree.items);
|
|
|
//默认初始节点
|
|
@@ -515,7 +919,13 @@ const billsGuidance = (function () {
|
|
|
$('#billsGuidance_bills').height(height / 2);
|
|
|
$('#billsGuidance_items').height(height / 2);
|
|
|
}
|
|
|
- let modules = [bills, guideItem];
|
|
|
+ let modules = [bills];
|
|
|
+ if(currentLib.type && currentLib.type === libType.elf){
|
|
|
+ modules.push(elfItem);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ modules.push(guideItem);
|
|
|
+ }
|
|
|
initWorkBooks(modules);
|
|
|
|
|
|
}
|
|
@@ -532,6 +942,31 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
return rst;
|
|
|
}
|
|
|
+ //获取清单精灵生成的定额数据
|
|
|
+ //@return {Array}
|
|
|
+ function getInsertElfRationData(){
|
|
|
+ let rst = [];
|
|
|
+ if(!bills.tree.selected){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ if(!bills.tree.selected.elf){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ let tree = bills.tree.selected.elf.tree;
|
|
|
+ if(!tree){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ for(let node of tree.items){
|
|
|
+ if(node.children.length === 0 && node.data.optionChecked){//定额数据只能在最底层节点中
|
|
|
+ for(let perChecked of node.data.optionChecked){
|
|
|
+ if(perChecked.type === itemType.ration){
|
|
|
+ rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
//获取选中的定额数据
|
|
|
//@param {Array}rows @return {Array}
|
|
|
function getInsertRationData(rows){
|
|
@@ -550,14 +985,16 @@ const billsGuidance = (function () {
|
|
|
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, 0)){
|
|
|
- sheet.setValue(row, 0, false);
|
|
|
+ if(!currentLib.type || currentLib.type === libType.guidance){
|
|
|
+ let sheet = guideItem.workBook.getActiveSheet();
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ for(let row = 0; row < sheet.getRowCount(); row++){
|
|
|
+ if(sheet.getValue(row, 0)){
|
|
|
+ sheet.setValue(row, 0, false);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
refreshInsertRation();
|
|
|
projectObj.setActiveCell('quantity', true);
|
|
|
});
|
|
@@ -565,12 +1002,22 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
//更新插入定额按钮有效性
|
|
|
function refreshInsertRation(){
|
|
|
- //勾选了定额,插入定额按钮才有效
|
|
|
- if(getCheckedRows().length > 0){
|
|
|
- $('#guidanceInsertRation').removeClass('disabled');
|
|
|
+ if(currentLib.type && currentLib.type === libType.elf){
|
|
|
+ if(getInsertElfRationData().length > 0){
|
|
|
+ $('#guidanceInsertRation').removeClass('disabled');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $('#guidanceInsertRation').addClass('disabled');
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
- $('#guidanceInsertRation').addClass('disabled');
|
|
|
+ //勾选了定额,插入定额按钮才有效
|
|
|
+ if(getCheckedRows().length > 0){
|
|
|
+ $('#guidanceInsertRation').removeClass('disabled');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $('#guidanceInsertRation').addClass('disabled');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//展开至搜索出来点的节点
|
|
@@ -614,7 +1061,7 @@ const billsGuidance = (function () {
|
|
|
});
|
|
|
//插入定额
|
|
|
$('#guidanceInsertRation').click(function () {
|
|
|
- let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
insertRations(addRationDatas);
|
|
|
});
|
|
|
//插入清单
|
|
@@ -627,7 +1074,7 @@ const billsGuidance = (function () {
|
|
|
let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, bills.tree.selected);
|
|
|
if(insert){
|
|
|
//插入选中的定额
|
|
|
- let addRationDatas = getInsertRationData(getCheckedRows());
|
|
|
+ let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
insertRations(addRationDatas);
|
|
|
}
|
|
|
}
|
|
@@ -718,12 +1165,14 @@ const billsGuidance = (function () {
|
|
|
if(guideItem.workBook){
|
|
|
guideItem.workBook.refresh();
|
|
|
}
|
|
|
+ if(elfItem.workBook){
|
|
|
+ elfItem.workBook.refresh();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return {initViews, bindBtn, refreshWorkBook, refreshInsertRation, bills};
|
|
|
})();
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
- billsGuidance.initViews();
|
|
|
billsGuidance.bindBtn();
|
|
|
});
|