|
@@ -10,14 +10,11 @@
|
|
|
|
|
|
//清单指引/精灵获取完清单数据后的回调函数
|
|
//清单指引/精灵获取完清单数据后的回调函数
|
|
let doAfterLoadGuidance = null;
|
|
let doAfterLoadGuidance = null;
|
|
-//选项单选多选状态(按住alt为多选) 单选:0 多选:1
|
|
|
|
-let billsGuidanceSelMode = 0;
|
|
|
|
|
|
|
|
const billsGuidance = (function () {
|
|
const billsGuidance = (function () {
|
|
let currentLib = null;
|
|
let currentLib = null;
|
|
//库类型
|
|
//库类型
|
|
const libType = {'guidance': 1, 'elf': 2}; //清单指引、清单精灵
|
|
const libType = {'guidance': 1, 'elf': 2}; //清单指引、清单精灵
|
|
- const libTypeText = {1: '清单指引', 2: '清单精灵'};
|
|
|
|
const libSel = $('#stdBillsGuidanceLibSelect');
|
|
const libSel = $('#stdBillsGuidanceLibSelect');
|
|
//工作内容
|
|
//工作内容
|
|
let stdBillsJobData = [];
|
|
let stdBillsJobData = [];
|
|
@@ -100,9 +97,6 @@ const billsGuidance = (function () {
|
|
],
|
|
],
|
|
rowHeaderWidth:25,
|
|
rowHeaderWidth:25,
|
|
events: {
|
|
events: {
|
|
- SelectionChanging: function (sender, info) {
|
|
|
|
- billsInitSel(info.newSelections[0].row);
|
|
|
|
- },
|
|
|
|
CellDoubleClick: function (sender, args) {
|
|
CellDoubleClick: function (sender, args) {
|
|
if(!bills.tree){
|
|
if(!bills.tree){
|
|
return;
|
|
return;
|
|
@@ -536,418 +530,6 @@ 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);
|
|
|
|
- if(!bills.tree){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- let node = bills.tree.items[row];
|
|
|
|
- if(!node){
|
|
|
|
- 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);
|
|
|
|
- setItemCellType(node.guidance.tree.items);
|
|
|
|
- //项目指引初始焦点
|
|
|
|
- guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- node.guidance.controller.showTreeData();
|
|
|
|
- setItemCellType(node.guidance.tree.items);
|
|
|
|
- //项目指引初始焦点
|
|
|
|
- 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;
|
|
|
|
- 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 ? options[0].name : '';
|
|
|
|
- //下挂的选项
|
|
|
|
- fData.optionsData = options && options.length > 0 ? _.cloneDeep(options) : [];
|
|
|
|
- fData.optionChecked = options && options.length > 0 ? [_.cloneDeep(options[0])] : [];
|
|
|
|
- }
|
|
|
|
- renderSheetFunc(elfSheet, function () {
|
|
|
|
- initTree(node.elf, elfSheet, elfItem.treeSetting, firstLevelDatas);
|
|
|
|
- //初始选择选项
|
|
|
|
- let initOptsOpr = [];
|
|
|
|
- for(let elfNode of node.elf.tree.items){
|
|
|
|
- if(elfNode.data.optionsData.length > 0){
|
|
|
|
- initOptsOpr.push({node: elfNode, data: elfNode.data.optionsData[0]});
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for(let opr of initOptsOpr){
|
|
|
|
- insertNodeByData(opr.node, opr.data);
|
|
|
|
- }
|
|
|
|
- TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.elf.tree.items, false);
|
|
|
|
- setOptionsCellType(node.elf.tree.items);
|
|
|
|
- //项目指引初始焦点
|
|
|
|
- elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
|
|
|
|
- refreshInsertRation();
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- renderSheetFunc(elfSheet, function () {
|
|
|
|
- node.elf.controller.showTreeData();
|
|
|
|
- setOptionsCellType(node.elf.tree.items);
|
|
|
|
- //项目指引初始焦点
|
|
|
|
- elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
|
|
|
|
- refreshInsertRation();
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //获取选项的深度
|
|
|
|
- //@param {Object}opt {Array}options(当前清单所有选项) @return {Array}
|
|
|
|
- function getOptionDepth(opt, options) {
|
|
|
|
- let parent = _.find(options, {ID: opt.ParentID});
|
|
|
|
- let depth = 0;
|
|
|
|
- while (parent){
|
|
|
|
- depth++;
|
|
|
|
- parent = _.find(options, {ID: parent.ParentID});
|
|
|
|
- }
|
|
|
|
- return depth;
|
|
|
|
- }
|
|
|
|
- //获取施工工序含有的选项(即当前施工工序的子项),获取的顺序按照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.optionsData && node.data.optionsData.length > 0){
|
|
|
|
- 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 {Object}node(当前操作的节点) {Object}data(选项) @return {void}
|
|
|
|
- function insertNodeByData(node, data) {
|
|
|
|
- let elfSheet = elfItem.workBook.getActiveSheet();
|
|
|
|
- let sameDepthNodes = node.children;
|
|
|
|
- let insertNextSiblingID = -1,
|
|
|
|
- insertParentID = node.data.ID;
|
|
|
|
- //当前操作节点的选项
|
|
|
|
- let nodeOpts = getOptions(node.data, bills.tree.selected.elf.datas);
|
|
|
|
- let subOpts = getOptions(data, bills.tree.selected.elf.datas);
|
|
|
|
- let dataDepth = getOptionDepth(data, bills.tree.selected.elf.datas);
|
|
|
|
- if(subOpts.length >0 && subOpts[0].type !== itemType.ration){
|
|
|
|
- if((dataDepth + 1) % 2 === 0){
|
|
|
|
- //排序后的数据
|
|
|
|
- let dataWithRank = _.find(nodeOpts, {ID: data.ID});
|
|
|
|
- //确定插入位置
|
|
|
|
- for(let subOpt of subOpts){
|
|
|
|
- for(let subNode of sameDepthNodes){
|
|
|
|
- //同层节点原本选项数据
|
|
|
|
- let subNodeOptData = _.find(bills.tree.selected.elf.datas, {ID: subNode.data.ID});
|
|
|
|
- //同层节点原本父选项数据
|
|
|
|
- let subNodeOptParent = _.find(bills.tree.selected.elf.datas, {ID: subNodeOptData.ParentID});
|
|
|
|
- let subNodeOptParentWithRank = _.find(nodeOpts, {ID: subNodeOptParent.ID});
|
|
|
|
- //父项顺序决定插入位置
|
|
|
|
- if(dataWithRank.rank < subNodeOptParentWithRank.rank){
|
|
|
|
- insertNextSiblingID = subNode.data.ID;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- //父项顺序相同,根据子项顺序决定插入位置
|
|
|
|
- else if(dataWithRank.rank = subNodeOptParentWithRank.rank){
|
|
|
|
- if(subOpt.rank < subNode.data.rank){
|
|
|
|
- insertNextSiblingID = subNode.data.ID;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- let sub2Opts = getOptions(subOpt, bills.tree.selected.elf.datas);
|
|
|
|
- subOpt.options = sub2Opts.length > 0 ? sub2Opts[0].name : '';
|
|
|
|
- let cloneOpt = _.cloneDeep(subOpt);//不改变原本的数据,比如ParentID
|
|
|
|
- cloneOpt.optionChecked = sub2Opts.length > 0 ? [_.cloneDeep(sub2Opts[0])] : [];
|
|
|
|
- cloneOpt.optionsData = sub2Opts.length > 0 ? _.cloneDeep(sub2Opts) : [];
|
|
|
|
- let newNode = node.tree.insertByData(cloneOpt, insertParentID, insertNextSiblingID);
|
|
|
|
- elfSheet.addRows(newNode.serialNo(), 1);
|
|
|
|
- node.tree.selected = newNode;
|
|
|
|
- elfSheet.setSelection(newNode.serialNo(), elfSheet.getSelections()[0].col, 1, 1);
|
|
|
|
- if(sub2Opts.length > 0 && sub2Opts[0].type !== itemType.ration){
|
|
|
|
- insertNodeByData(newNode, sub2Opts[0]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- insertNodeByData(node, subOpts[0]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //获取选项下拉多选单元格
|
|
|
|
- //@param {void} @return {void}
|
|
|
|
- function getOptionsCellType() {
|
|
|
|
- let me = this;
|
|
|
|
- let elfSheet= elfItem.workBook.getActiveSheet();
|
|
|
|
- function OptionsCellType() {
|
|
|
|
- this.isEscKey=false;
|
|
|
|
- this.displayText='';
|
|
|
|
- }
|
|
|
|
- function setOptionsDiv($editor, node, cellRect, cellStyle, top) {
|
|
|
|
- if(!node){
|
|
|
|
- return '';
|
|
|
|
- }
|
|
|
|
- let height = cellRect.height;
|
|
|
|
- top = top.replace('px', '');
|
|
|
|
- let options = getOptions(node.data, bills.tree.selected.elf.datas);
|
|
|
|
- top = options.length - 2 > 4 ? top - 4 * height : top - (options.length - 2) * height - 5;
|
|
|
|
- let $editInput = $(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div>`),
|
|
|
|
- $optDiv = $(`<div style="position: fixed; width: ${cellRect.width}px; top: ${top}px;background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;"></div>`);
|
|
|
|
- for(let opt of options){
|
|
|
|
- let $opt = $(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis"></div>`),
|
|
|
|
- $optInput = $(`<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.text(`${opt.name ? opt.name : ''}`);
|
|
|
|
- $opt.prepend($optInput);
|
|
|
|
- $optDiv.append($opt);
|
|
|
|
- //选项复选框点击监听
|
|
|
|
- $opt.click(function () {
|
|
|
|
- //单选
|
|
|
|
- if(billsGuidanceSelMode === 0){
|
|
|
|
- let $allInput = $optDiv.find('input');
|
|
|
|
- for(let input of $allInput){
|
|
|
|
- $(input).prop('checked', false);
|
|
|
|
- }
|
|
|
|
- $($optInput).prop('checked', 'checked');
|
|
|
|
- elfItem.workBook.getSheet(0).endEdit();
|
|
|
|
- } else {//多选
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- $editor.append($editInput);
|
|
|
|
- $editor.append($optDiv);
|
|
|
|
- }
|
|
|
|
- //选择后处理
|
|
|
|
- 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 deleteNodes = getDeleteNodes(node, optionChecked);
|
|
|
|
- for(let dNode of deleteNodes){
|
|
|
|
- elfSheet.deleteRows(dNode.serialNo(), dNode.posterityCount() + 1);
|
|
|
|
- node.tree.delete(dNode);
|
|
|
|
- }
|
|
|
|
- //插入节点
|
|
|
|
- for(let perCheked of optionChecked){
|
|
|
|
- let exist = false;
|
|
|
|
- let subOpts = getOptions(perCheked, bills.tree.selected.elf.datas);
|
|
|
|
- for(let subNode of node.children){
|
|
|
|
- for(let subOpt of subOpts){
|
|
|
|
- if(subNode.data.ID === subOpt.ID){
|
|
|
|
- exist = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //不重复且不为定额时插入
|
|
|
|
- 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 getDeleteNodes(node, optionChecked) {
|
|
|
|
- let rst = [];
|
|
|
|
- for(let subNode of node.children){
|
|
|
|
- let exist = false;
|
|
|
|
- for(let perChecked of optionChecked){
|
|
|
|
- let subOpts = getOptions(perChecked, bills.tree.selected.elf.datas);
|
|
|
|
- for(let subOpt of subOpts){
|
|
|
|
- if(subNode.data.ID === subOpt.ID){
|
|
|
|
- exist = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(!exist){
|
|
|
|
- rst.push(subNode);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return rst;
|
|
|
|
- }
|
|
|
|
- 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 activeCellTop = $editor.parent().parent().css('top');
|
|
|
|
- let node = bills.tree.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
|
|
|
|
- setOptionsDiv($editor, node, cellRect, cellStyle, activeCellTop);
|
|
|
|
- this.isEscKey = false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- 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 {Function}callback @return {void}
|
|
//@param {Number}billsLibId {Function}callback @return {void}
|
|
function initJobAndCharacter(billsLibId, callback){
|
|
function initJobAndCharacter(billsLibId, callback){
|
|
@@ -998,7 +580,6 @@ const billsGuidance = (function () {
|
|
let sheet = bills.workBook.getActiveSheet();
|
|
let sheet = bills.workBook.getActiveSheet();
|
|
let locateRow = locateBills ? locateBills.serialNo() : 0;
|
|
let locateRow = locateBills ? locateBills.serialNo() : 0;
|
|
sheet.setActiveCell(locateRow, 0);
|
|
sheet.setActiveCell(locateRow, 0);
|
|
- billsInitSel(locateRow);
|
|
|
|
sheet.showRow(locateRow, GC.Spread.Sheets.VerticalPosition.center);
|
|
sheet.showRow(locateRow, GC.Spread.Sheets.VerticalPosition.center);
|
|
}
|
|
}
|
|
//清单设置悬浮提示信息
|
|
//清单设置悬浮提示信息
|
|
@@ -1084,25 +665,6 @@ const billsGuidance = (function () {
|
|
initViews();
|
|
initViews();
|
|
let callback = function () {
|
|
let callback = function () {
|
|
initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, rstData.bills);
|
|
initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, rstData.bills);
|
|
- //清单精灵
|
|
|
|
- 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);
|
|
|
|
- //默认初始节点
|
|
|
|
- billsInitSel(0);
|
|
|
|
if(doAfterLoadGuidance){
|
|
if(doAfterLoadGuidance){
|
|
doAfterLoadGuidance();
|
|
doAfterLoadGuidance();
|
|
}
|
|
}
|
|
@@ -1151,105 +713,6 @@ const billsGuidance = (function () {
|
|
initWorkBooks(modules);
|
|
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, 0);
|
|
|
|
- if(rowV){
|
|
|
|
- rst.push(row);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- 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){
|
|
|
|
- for(let perChecked of node.data.optionChecked){
|
|
|
|
- //选项直接是定额
|
|
|
|
- if(perChecked.type === itemType.ration){
|
|
|
|
- rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
|
|
|
|
- }
|
|
|
|
- //选项下子选项是定额
|
|
|
|
- else {
|
|
|
|
- let rationOpts = getOptions(perChecked, bills.tree.selected.elf.datas);
|
|
|
|
- for(let ration of rationOpts){
|
|
|
|
- if(ration.type === itemType.ration){
|
|
|
|
- rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- 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 () {
|
|
|
|
- //恢复
|
|
|
|
- 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);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //更新插入定额按钮有效性
|
|
|
|
- function refreshInsertRation(){
|
|
|
|
- if(currentLib.type && currentLib.type === libType.elf){
|
|
|
|
- if(getInsertElfRationData().length > 0){
|
|
|
|
- $('#guidanceInsertRation').removeClass('disabled');
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- $('#guidanceInsertRation').addClass('disabled');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- //勾选了定额,插入定额按钮才有效
|
|
|
|
- if(getCheckedRows().length > 0){
|
|
|
|
- $('#guidanceInsertRation').removeClass('disabled');
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- $('#guidanceInsertRation').addClass('disabled');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
//展开至搜索出来点的节点
|
|
//展开至搜索出来点的节点
|
|
//@param {Array}nodes @return {void}
|
|
//@param {Array}nodes @return {void}
|
|
function expandSearchNodes(nodes){
|
|
function expandSearchNodes(nodes){
|
|
@@ -1289,41 +752,6 @@ const billsGuidance = (function () {
|
|
//清除展开收起状态sessionStorage
|
|
//清除展开收起状态sessionStorage
|
|
sessionStorage.removeItem('stdBillsGuidanceExpState');
|
|
sessionStorage.removeItem('stdBillsGuidanceExpState');
|
|
});
|
|
});
|
|
- //插入定额
|
|
|
|
- $('#guidanceInsertRation').click(function () {
|
|
|
|
- let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
|
- insertRations(addRationDatas);
|
|
|
|
- });
|
|
|
|
- //插入清单
|
|
|
|
- $('#guidanceInsertBills').click(function () {
|
|
|
|
- //插入清单
|
|
|
|
- if(!bills.tree || !bills.tree.selected){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if(bills.tree.selected.children.length === 0){
|
|
|
|
- let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, bills.tree.selected);
|
|
|
|
- /*if(insert){
|
|
|
|
- //插入选中的定额
|
|
|
|
- let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
|
- insertRations(addRationDatas);
|
|
|
|
- }*/
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- //插入清单和定额
|
|
|
|
- $('#guidanceInsertBillsAndRation').click(function () {
|
|
|
|
- //插入清单
|
|
|
|
- if(!bills.tree || !bills.tree.selected){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if(bills.tree.selected.children.length === 0){
|
|
|
|
- let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, bills.tree.selected);
|
|
|
|
- if(insert){
|
|
|
|
- //插入选中的定额
|
|
|
|
- let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
|
|
|
|
- insertRations(addRationDatas);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
//搜索
|
|
//搜索
|
|
$('#stdBillsGuidanceSearch>div>button').click(function () {
|
|
$('#stdBillsGuidanceSearch>div>button').click(function () {
|
|
if(!bills.tree){
|
|
if(!bills.tree){
|
|
@@ -1355,8 +783,6 @@ const billsGuidance = (function () {
|
|
renderSheetFunc(billsSheet, function () {
|
|
renderSheetFunc(billsSheet, function () {
|
|
bills.controller.setTreeSelected(result[0]);
|
|
bills.controller.setTreeSelected(result[0]);
|
|
billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
|
|
billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
|
|
- billsInitSel(result[0].serialNo());
|
|
|
|
-
|
|
|
|
for (let node of result) {
|
|
for (let node of result) {
|
|
billsSheet.getRange(node.serialNo(), -1, 1, -1).backColor('lemonChiffon');
|
|
billsSheet.getRange(node.serialNo(), -1, 1, -1).backColor('lemonChiffon');
|
|
}
|
|
}
|
|
@@ -1371,12 +797,10 @@ const billsGuidance = (function () {
|
|
if (resultIndex === result.length - 1) {
|
|
if (resultIndex === result.length - 1) {
|
|
bills.controller.setTreeSelected(result[0]);
|
|
bills.controller.setTreeSelected(result[0]);
|
|
billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
|
|
billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
|
|
- billsInitSel(result[0].serialNo());
|
|
|
|
billsSheet.showRow(result[0].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
|
|
billsSheet.showRow(result[0].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
|
|
} else {
|
|
} else {
|
|
bills.controller.setTreeSelected(result[resultIndex + 1]);
|
|
bills.controller.setTreeSelected(result[resultIndex + 1]);
|
|
billsSheet.setSelection(result[resultIndex + 1].serialNo(), sel[0].col, 1, 1);
|
|
billsSheet.setSelection(result[resultIndex + 1].serialNo(), sel[0].col, 1, 1);
|
|
- billsInitSel(result[resultIndex + 1].serialNo());
|
|
|
|
billsSheet.showRow(result[resultIndex + 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
|
|
billsSheet.showRow(result[resultIndex + 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -1400,17 +824,6 @@ const billsGuidance = (function () {
|
|
billsLibObj.clearHighLight(bills.workBook);
|
|
billsLibObj.clearHighLight(bills.workBook);
|
|
refreshWorkBook();
|
|
refreshWorkBook();
|
|
});
|
|
});
|
|
- //监听alt建,确定选项单选多选状态
|
|
|
|
- /* $('#billsGuidance_items').keydown(function(e){
|
|
|
|
- if(e.keyCode === 18){
|
|
|
|
- billsGuidanceSelMode = 1;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- $('#billsGuidance_items').keyup(function(e){
|
|
|
|
- if(e.keyCode === 18){
|
|
|
|
- billsGuidanceSelMode = 0;
|
|
|
|
- }
|
|
|
|
- });*/
|
|
|
|
}
|
|
}
|
|
//刷新表
|
|
//刷新表
|
|
//@return {void}
|
|
//@return {void}
|
|
@@ -1426,7 +839,7 @@ const billsGuidance = (function () {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return {initViews, bindBtn, refreshWorkBook, refreshInsertRation, setColumnWidthByRate, locateAtBills, bills, elfItem};
|
|
|
|
|
|
+ return {initViews, bindBtn, refreshWorkBook, setColumnWidthByRate, locateAtBills, bills, elfItem};
|
|
})();
|
|
})();
|
|
|
|
|
|
$(document).ready(function(){
|
|
$(document).ready(function(){
|