|
@@ -10,6 +10,8 @@
|
|
|
|
|
|
//清单指引/精灵获取完清单数据后的回调函数
|
|
|
let doAfterLoadGuidance = null;
|
|
|
+//选项单选多选状态(按住alt为多选) 单选:0 多选:1
|
|
|
+let billsGuidanceSelMode = 0;
|
|
|
|
|
|
const billsGuidance = (function () {
|
|
|
let currentLib = null;
|
|
@@ -38,6 +40,7 @@ const billsGuidance = (function () {
|
|
|
cols: [{
|
|
|
width: 140,
|
|
|
readOnly: true,
|
|
|
+ showHint: true,
|
|
|
head: {
|
|
|
titleNames: ["项目编码"],
|
|
|
spanCols: [1],
|
|
@@ -409,7 +412,11 @@ const billsGuidance = (function () {
|
|
|
sheet.suspendPaint();
|
|
|
for(let col = 0; col < headers.length; col++){
|
|
|
if(headers[col]['rateWidth'] !== undefined && headers[col]['rateWidth'] !== null && headers[col]['rateWidth'] !== ''){
|
|
|
- sheet.setColumnWidth(col, workBookWidth * headers[col]['rateWidth'], GC.Spread.Sheets.SheetArea.colHeader)
|
|
|
+ let width = workBookWidth * headers[col]['rateWidth'];
|
|
|
+ if(headers[col]['dataCode'] === 'options'){
|
|
|
+ width = width - 70;
|
|
|
+ }
|
|
|
+ sheet.setColumnWidth(col, width, GC.Spread.Sheets.SheetArea.colHeader)
|
|
|
}
|
|
|
else {
|
|
|
if(headers[col]['headerWidth'] !== undefined && headers[col]['headerWidth'] !== null && headers[col]['headerWidth'] !== ''){
|
|
@@ -449,7 +456,6 @@ const billsGuidance = (function () {
|
|
|
setOptions(module.workBook, options);
|
|
|
buildHeader(module.workBook.getActiveSheet(), module.headers);
|
|
|
if(module === elfItem){
|
|
|
- console.log($('#zy').width());
|
|
|
setColumnWidthByRate(elfItem.workBook, $('#zy').width(), elfItem.headers)
|
|
|
}
|
|
|
bindEvent(module.workBook, module.events);
|
|
@@ -482,6 +488,9 @@ const billsGuidance = (function () {
|
|
|
initExpandStat();
|
|
|
}
|
|
|
module.controller.showTreeData();
|
|
|
+ if(module === bills){
|
|
|
+ setBillsHint(bills.tree.items, stdBillsJobData, stdBillsFeatureData);
|
|
|
+ }
|
|
|
}
|
|
|
//项目指引表焦点控制
|
|
|
//@param {Number}row @return {void}
|
|
@@ -756,15 +765,16 @@ const billsGuidance = (function () {
|
|
|
this.isEscKey=false;
|
|
|
this.displayText='';
|
|
|
}
|
|
|
- function getHtml(node, cellRect, cellStyle) {
|
|
|
+ /* function getHtml(node, cellRect, cellStyle, top) {
|
|
|
if(!node){
|
|
|
return '';
|
|
|
}
|
|
|
let height = cellRect.height;
|
|
|
+ top = top.replace('px', '');
|
|
|
let htmlArr = [];
|
|
|
let options = getOptions(node.data, bills.tree.selected.elf.datas);
|
|
|
//let optionsTitle = node.data.options.split(';').join('\n');
|
|
|
- htmlArr.push(`<div 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;">`);
|
|
|
+ htmlArr.push(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div><div id="optDiv" style="position: fixed; width: ${cellRect.width}px; top: ${top - (options.length - 2) * height - 5}px;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"
|
|
@@ -772,6 +782,39 @@ const billsGuidance = (function () {
|
|
|
}
|
|
|
htmlArr.push(`</div>`);
|
|
|
return htmlArr.join('');
|
|
|
+ }*/
|
|
|
+ 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);
|
|
|
+ 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 - (options.length - 2) * height - 5}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);
|
|
|
+ //选项复选框点击监听
|
|
|
+ $optInput.click(function () {
|
|
|
+ //单选
|
|
|
+ if(billsGuidanceSelMode === 0){
|
|
|
+ let $allInput = $optDiv.find('input');
|
|
|
+ for(let input of $allInput){
|
|
|
+ $(input).prop('checked', false);
|
|
|
+ }
|
|
|
+ $(this).prop('checked', 'checked');
|
|
|
+ } else {//多选
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $editor.append($editInput);
|
|
|
+ $editor.append($optDiv);
|
|
|
}
|
|
|
//选择后处理
|
|
|
function doAfterSel(node) {
|
|
@@ -847,8 +890,10 @@ const billsGuidance = (function () {
|
|
|
$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()];
|
|
|
- $editor.html(getHtml(node, cellRect, cellStyle));
|
|
|
+ setOptionsDiv($editor, node, cellRect, cellStyle, activeCellTop);
|
|
|
+ this.isEscKey = false;
|
|
|
}
|
|
|
}
|
|
|
OptionsCellType.prototype.deactivateEditor = function (editorContext, context) {
|
|
@@ -913,13 +958,16 @@ const billsGuidance = (function () {
|
|
|
return new OptionsCellType();
|
|
|
}
|
|
|
//初始化清单的工作内容和项目特征
|
|
|
- //@param {Number}billsLibId @return {void}
|
|
|
- function initJobAndCharacter(billsLibId){
|
|
|
+ //@param {Number}billsLibId {Function}callback @return {void}
|
|
|
+ function initJobAndCharacter(billsLibId, callback){
|
|
|
CommonAjax.post('/stdBillsEditor/getJobContent', {userId: userID, billsLibId: billsLibId}, function (datas) {
|
|
|
stdBillsJobData = datas;
|
|
|
- });
|
|
|
- CommonAjax.post('/stdBillsEditor/getItemCharacter', {userId: userID, billsLibId: billsLibId}, function (datas) {
|
|
|
- stdBillsFeatureData = datas;
|
|
|
+ CommonAjax.post('/stdBillsEditor/getItemCharacter', {userId: userID, billsLibId: billsLibId}, function (datas) {
|
|
|
+ stdBillsFeatureData = datas;
|
|
|
+ if(callback){
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
//初始化清单展开收起状态
|
|
@@ -945,7 +993,7 @@ const billsGuidance = (function () {
|
|
|
});
|
|
|
}
|
|
|
//根据编码定位至清单精灵库中
|
|
|
- //
|
|
|
+ //@param {String}code @return {void}
|
|
|
function locateAtBills(code) {
|
|
|
let nineCode = code.substring(0, 9);
|
|
|
let items = bills.tree.items;
|
|
@@ -962,6 +1010,71 @@ const billsGuidance = (function () {
|
|
|
billsInitSel(locateRow);
|
|
|
sheet.showRow(locateRow, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
}
|
|
|
+ //清单设置悬浮提示信息
|
|
|
+ //@param {Array}billsNodes(清单节点) {Array}jobs(总的工作内容数据) {Array}items(总的项目特征数据)
|
|
|
+ function setBillsHint(billsNodes, jobs, items) {
|
|
|
+ let jobsMapping = {},
|
|
|
+ itemsMapping = {};
|
|
|
+ for(let job of jobs){
|
|
|
+ jobsMapping[job.id] = job;
|
|
|
+ }
|
|
|
+ for(let item of items){
|
|
|
+ itemsMapping[item.id] = item;
|
|
|
+ }
|
|
|
+ let tagInfo = [];
|
|
|
+ for(let billsNode of billsNodes){
|
|
|
+ let hintArr = [];
|
|
|
+ let billsItems = billsNode.data.items;
|
|
|
+ if(billsItems.length > 0){
|
|
|
+ //项目特征
|
|
|
+ hintArr.push('项目特征:');
|
|
|
+ }
|
|
|
+ let itemCount = 1,
|
|
|
+ jobCount = 1;
|
|
|
+ for(let billsItem of billsItems){
|
|
|
+ let itemData = itemsMapping[billsItem.id];
|
|
|
+ if(itemData){
|
|
|
+ //特征值
|
|
|
+ let eigens = [];
|
|
|
+ for(let eigen of itemData.itemValue){
|
|
|
+ eigens.push(eigen.value);
|
|
|
+ }
|
|
|
+ eigens = eigens.join(';');
|
|
|
+ hintArr.push(`${itemCount}.${itemData.content}${eigens === '' ? '' : ': ' + eigens}`);
|
|
|
+ itemCount ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //工作内容
|
|
|
+ let billsJobs = billsNode.data.jobs;
|
|
|
+ if(billsJobs.length > 0){
|
|
|
+ hintArr.push('工作内容:');
|
|
|
+ }
|
|
|
+ for(let billsJob of billsJobs){
|
|
|
+ let jobData = jobsMapping[billsJob.id];
|
|
|
+ if(jobData){
|
|
|
+ hintArr.push(`${jobCount}.${jobData.content}`);
|
|
|
+ jobCount ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*if(billsNode.data.ruleText && billsNode.data.ruleText !== ''){
|
|
|
+ hintArr.push('工程量计算规则:');
|
|
|
+ hintArr.push(billsNode.data.ruleText);
|
|
|
+ }
|
|
|
+ if(billsNode.data.recharge && billsNode.data.recharge !== ''){
|
|
|
+ hintArr.push('补注:');
|
|
|
+ hintArr.push(billsNode.data.recharge);
|
|
|
+ }*/
|
|
|
+ if(hintArr.length > 0){
|
|
|
+ tagInfo.push({row: billsNode.serialNo(), value: hintArr.join('\n')});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let sheet = bills.workBook.getActiveSheet();
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ for(let tagI of tagInfo){
|
|
|
+ sheet.setTag(tagI.row, 0, tagI.value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
//初始选择清单指引库
|
|
|
//@param {Number}libID @return {void}
|
|
|
function libInitSel(libID){
|
|
@@ -978,32 +1091,34 @@ const billsGuidance = (function () {
|
|
|
elfItem.workBook = null;
|
|
|
}
|
|
|
initViews();
|
|
|
- //获取清单库中的工作内容和项目特征
|
|
|
- initJobAndCharacter(rstData.guidanceLib.billsLibId);
|
|
|
- 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: []}; //挂载全部数据,数据不一定全成为树节点
|
|
|
+ let callback = function () {
|
|
|
+ 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};
|
|
|
+ //清单指引
|
|
|
+ else {
|
|
|
+ $('#stdBillsGuidanceTab').text('清单指引');
|
|
|
+ //每一棵项目指引树挂在清单节点上
|
|
|
+ for(let node of bills.tree.items){
|
|
|
+ node.guidance = {tree: null, controller: null};
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- setTagForHint(bills.tree.items);
|
|
|
- //默认初始节点
|
|
|
- billsInitSel(0);
|
|
|
- if(doAfterLoadGuidance){
|
|
|
- doAfterLoadGuidance();
|
|
|
- }
|
|
|
- $.bootstrapLoading.end();
|
|
|
+ //setTagForHint(bills.tree.items);
|
|
|
+ //默认初始节点
|
|
|
+ billsInitSel(0);
|
|
|
+ if(doAfterLoadGuidance){
|
|
|
+ doAfterLoadGuidance();
|
|
|
+ }
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ };
|
|
|
+ //获取清单库中的工作内容和项目特征
|
|
|
+ initJobAndCharacter(rstData.guidanceLib.billsLibId, callback);
|
|
|
}, function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
@@ -1294,6 +1409,17 @@ const billsGuidance = (function () {
|
|
|
billsLibObj.clearHighLight(bills.workBook);
|
|
|
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}
|