|
|
@@ -9,20 +9,21 @@
|
|
|
*/
|
|
|
|
|
|
/*
|
|
|
-* 造价书下方清单精灵
|
|
|
+* 造价书下方清单精灵、清单指引
|
|
|
* */
|
|
|
//选项单选多选状态(按住alt为多选) 单选:0 多选:1
|
|
|
let billsGuidanceSelMode = 0;
|
|
|
|
|
|
-const BillsElf = (function() {
|
|
|
- //清单精灵树挂载的地方,selected:当前选中的清单,mapping:以前九位清单编码为索引, 'xxx' : {elf: {datas, tree, controller}}
|
|
|
+const BillsSub = (function() {
|
|
|
+ //清单子树挂载的地方,selected:当前选中的清单,mapping:以前九位清单编码为索引, 'xxx' : {sub: {datas, tree, controller}}
|
|
|
let bills = {selected: null, mapping: {}};
|
|
|
const itemType = {
|
|
|
job: 0,
|
|
|
ration: 1
|
|
|
};
|
|
|
+ // 清单精灵
|
|
|
const elfItem = {
|
|
|
- dom: $('#elfItems'),
|
|
|
+ dom: $('#billsSubItems'),
|
|
|
workBook: null,
|
|
|
tree: null,
|
|
|
controller: null,
|
|
|
@@ -92,6 +93,88 @@ const BillsElf = (function() {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ // 清单指引
|
|
|
+ const guideItem = {
|
|
|
+ dom: $('#billsSubItems'),
|
|
|
+ workBook: null,
|
|
|
+ tree: null,
|
|
|
+ controller: null,
|
|
|
+ treeSetting: {
|
|
|
+ treeCol: 1,
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ cols: [
|
|
|
+ {
|
|
|
+ width: 420,
|
|
|
+ readOnly: false,
|
|
|
+ head: {
|
|
|
+ titleNames: ["项目指引"],
|
|
|
+ spanCols: [1],
|
|
|
+ spanRows: [1],
|
|
|
+ vAlign: [1],
|
|
|
+ hAlign: [1],
|
|
|
+ font: ["Arial"]
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ field: "name",
|
|
|
+ vAlign: 1,
|
|
|
+ hAlign: 0,
|
|
|
+ font: "Arial"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 35,
|
|
|
+ readOnly: false,
|
|
|
+ head: {
|
|
|
+ titleNames: ["选择"],
|
|
|
+ spanCols: [1],
|
|
|
+ spanRows: [1],
|
|
|
+ vAlign: [1],
|
|
|
+ hAlign: [1],
|
|
|
+ font: ["Arial"]
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ field: "select",
|
|
|
+ vAlign: 1,
|
|
|
+ hAlign: 1,
|
|
|
+ font: "Arial"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ headers: [
|
|
|
+ {name: '项目指引', dataCode: 'name', width: 300, vAlign: 'center', hAlign: 'left', formatter: '@'},
|
|
|
+ {name: '选择', dataCode: 'select', width: 35, vAlign: 'center', hAlign: 'center', formatter: '@'},
|
|
|
+ ],
|
|
|
+ rowHeaderWidth:25,
|
|
|
+ events: {
|
|
|
+ /*EditStarting: function (sender, args) {
|
|
|
+ if(!bills.tree || guideItem.headers[args.col]['dataCode'] === 'name'){
|
|
|
+ args.cancel = true;
|
|
|
+ }
|
|
|
+ },*/
|
|
|
+ ButtonClicked: function (sender, args) {
|
|
|
+ if(args.sheet.isEditing()){
|
|
|
+ args.sheet.endEdit(true);
|
|
|
+ }
|
|
|
+ //refreshInsertRation();
|
|
|
+ },
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 目前的模块:清单精灵或清单指引,默认是清单指引
|
|
|
+ let curModule = guideItem;
|
|
|
+ // 切换目前的模块
|
|
|
+ // 1:清单指引 2:清单精灵
|
|
|
+ function switchModule(type) {
|
|
|
+ curModule = elfItem;
|
|
|
+ /* curModule = type === 1
|
|
|
+ ? guideItem
|
|
|
+ : elfItem;*/
|
|
|
+ }
|
|
|
+
|
|
|
const options = {
|
|
|
workBook: {
|
|
|
tabStripVisible: false,
|
|
|
@@ -193,20 +276,20 @@ const BillsElf = (function() {
|
|
|
//建表
|
|
|
//@param {Object}module @return {void}
|
|
|
function buildSheet() {
|
|
|
- if(!elfItem.workBook){
|
|
|
- elfItem.workBook = new GC.Spread.Sheets.Workbook(elfItem.dom[0], {sheetCount: 1});
|
|
|
- sheetCommonObj.spreadDefaultStyle(elfItem.workBook);
|
|
|
- let sheet = elfItem.workBook.getActiveSheet();
|
|
|
- sheet.options.isProtected = true;
|
|
|
+ console.log(curModule);
|
|
|
+ if(!curModule.workBook){
|
|
|
+ curModule.workBook = new GC.Spread.Sheets.Workbook(curModule.dom[0], {sheetCount: 1});
|
|
|
+ sheetCommonObj.spreadDefaultStyle(curModule.workBook);
|
|
|
+ let sheet = curModule.workBook.getActiveSheet();
|
|
|
+ /*sheet.options.isProtected = true;
|
|
|
sheet.getRange(-1, 0, -1, 1).locked(true);
|
|
|
- sheet.getRange(-1, 1, -1, 1).locked(false);
|
|
|
- if(elfItem.rowHeaderWidth) {
|
|
|
- sheet.setColumnWidth(0, elfItem.rowHeaderWidth, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ sheet.getRange(-1, 1, -1, 1).locked(false);*/
|
|
|
+ if(curModule.rowHeaderWidth) {
|
|
|
+ sheet.setColumnWidth(0, curModule.rowHeaderWidth, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
}
|
|
|
- setOptions(elfItem.workBook, options);
|
|
|
- buildHeader(elfItem.workBook.getActiveSheet(), elfItem.headers);
|
|
|
- //setColumnWidthByRate(elfItem.workBook, $('#elfItems').width(), elfItem.headers);
|
|
|
- bindEvent(elfItem.workBook, elfItem.events);
|
|
|
+ setOptions(curModule.workBook, options);
|
|
|
+ buildHeader(curModule.workBook.getActiveSheet(), curModule.headers);
|
|
|
+ bindEvent(curModule.workBook, curModule.events);
|
|
|
}
|
|
|
}
|
|
|
//刷新表
|
|
|
@@ -216,9 +299,9 @@ const BillsElf = (function() {
|
|
|
if ($('#qdjl').is(':visible')) {
|
|
|
let totalHeight = $('#qdjl').height(),
|
|
|
elfToolsHeight = $('#qdjlTools').height();
|
|
|
- $('#elfItems').height(totalHeight - elfToolsHeight);
|
|
|
- if (elfItem.workBook) {
|
|
|
- elfItem.workBook.refresh();
|
|
|
+ $('#billsSubItems').height(totalHeight - elfToolsHeight);
|
|
|
+ if (curModule.workBook) {
|
|
|
+ curModule.workBook.refresh();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -247,32 +330,35 @@ const BillsElf = (function() {
|
|
|
function elfItemInitSel(row){
|
|
|
let billsNode = bills.selected;
|
|
|
let node = null;
|
|
|
- if(billsNode && billsNode.elf.tree){
|
|
|
- node = billsNode.elf.tree.items[row];
|
|
|
+ if(billsNode && billsNode.sub.tree){
|
|
|
+ node = billsNode.sub.tree.items[row];
|
|
|
if(node){
|
|
|
- billsNode.elf.tree.selected = node;
|
|
|
+ billsNode.sub.tree.selected = node;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //清单焦点变换-清单精灵操作,获取清单前九位编码的标准清单清单精灵选项
|
|
|
+ //清单焦点变换-清单子界面操作,获取清单前九位编码的标准清单清单精灵选项 或 清单指引数据
|
|
|
//@param {String}code @return {void}
|
|
|
- function billsSelElf(code) {
|
|
|
- let elfSheet = elfItem.workBook.getActiveSheet();
|
|
|
- cleanData(elfSheet, elfItem.headers, -1);
|
|
|
+ function billsSelSub(code) {
|
|
|
+ console.log(bills);
|
|
|
+ let sheet = curModule.workBook.getActiveSheet();
|
|
|
+ cleanData(sheet, curModule.headers, -1);
|
|
|
if (!code || code === '') {
|
|
|
return;
|
|
|
}
|
|
|
let nineCode = code.substr(0, 9);
|
|
|
//查看此清单映射是否存在此编码映射数据,不存在,则新建映射
|
|
|
if (!bills.mapping[nineCode]) {
|
|
|
- bills.mapping[nineCode] = {elf: {datas: [], tree: null, controller: null}};
|
|
|
+ bills.mapping[nineCode] = {sub: {datas: [], tree: null, controller: null}};
|
|
|
}
|
|
|
let node = bills.mapping[nineCode];
|
|
|
bills.selected = node;
|
|
|
- if(!node.elf.tree){
|
|
|
+ if(!node.sub.tree){
|
|
|
let guidanceLibID;
|
|
|
if (projectObj.project.projectInfo.engineeringInfo && projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib) {
|
|
|
- guidanceLibID = projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib[0] ? projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib[0].id : null;
|
|
|
+ guidanceLibID = projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib[0]
|
|
|
+ ? projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib[0].id
|
|
|
+ : null;
|
|
|
}
|
|
|
CommonAjax.post('/billsGuidance/api/getItemsByCode', {guidanceLibID: guidanceLibID, code: nineCode}, function (rstData) {
|
|
|
//定额数据删除编号信息,(编码后+空格才会去除编码)
|
|
|
@@ -285,7 +371,7 @@ const BillsElf = (function() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- node.elf.datas = rstData;
|
|
|
+ node.sub.datas = rstData;
|
|
|
//第一层节点数据
|
|
|
let firstLevelDatas = _.filter(rstData, function (data) {
|
|
|
return data.ParentID == -1;
|
|
|
@@ -298,11 +384,11 @@ const BillsElf = (function() {
|
|
|
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);
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ initTree(node.sub, sheet, elfItem.treeSetting, firstLevelDatas);
|
|
|
//初始选择选项
|
|
|
let initOptsOpr = [];
|
|
|
- for(let elfNode of node.elf.tree.items){
|
|
|
+ for(let elfNode of node.sub.tree.items){
|
|
|
if(elfNode.data.optionsData.length > 0){
|
|
|
initOptsOpr.push({node: elfNode, data: elfNode.data.optionsData[0]});
|
|
|
}
|
|
|
@@ -310,19 +396,18 @@ const BillsElf = (function() {
|
|
|
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);
|
|
|
+ TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, sheet, node.sub.tree.items, false);
|
|
|
+ setOptionsCellType(node.sub.tree.items);
|
|
|
//项目指引初始焦点
|
|
|
- elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
|
|
|
+ elfItemInitSel(sheet.getActiveRowIndex() ? sheet.getActiveRowIndex() : 0);
|
|
|
});
|
|
|
});
|
|
|
- }
|
|
|
- else{
|
|
|
- renderSheetFunc(elfSheet, function () {
|
|
|
- node.elf.controller.showTreeData();
|
|
|
- setOptionsCellType(node.elf.tree.items);
|
|
|
+ } else{
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
+ node.sub.controller.showTreeData();
|
|
|
+ setOptionsCellType(node.sub.tree.items);
|
|
|
//项目指引初始焦点
|
|
|
- elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
|
|
|
+ elfItemInitSel(sheet.getActiveRowIndex() ? sheet.getActiveRowIndex() : 0);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -412,9 +497,9 @@ const BillsElf = (function() {
|
|
|
let insertNextSiblingID = -1,
|
|
|
insertParentID = node.data.ID;
|
|
|
//当前操作节点的选项
|
|
|
- let nodeOpts = getOptions(node.data, bills.selected.elf.datas);
|
|
|
- let subOpts = getOptions(data, bills.selected.elf.datas);
|
|
|
- let dataDepth = getOptionDepth(data, bills.selected.elf.datas);
|
|
|
+ let nodeOpts = getOptions(node.data, bills.selected.sub.datas);
|
|
|
+ let subOpts = getOptions(data, bills.selected.sub.datas);
|
|
|
+ let dataDepth = getOptionDepth(data, bills.selected.sub.datas);
|
|
|
if(subOpts.length >0 && subOpts[0].type !== itemType.ration){
|
|
|
if((dataDepth + 1) % 2 === 0){
|
|
|
//排序后的数据
|
|
|
@@ -423,9 +508,9 @@ const BillsElf = (function() {
|
|
|
for(let subOpt of subOpts){
|
|
|
for(let subNode of sameDepthNodes){
|
|
|
//同层节点原本选项数据
|
|
|
- let subNodeOptData = _.find(bills.selected.elf.datas, {ID: subNode.data.ID});
|
|
|
+ let subNodeOptData = _.find(bills.selected.sub.datas, {ID: subNode.data.ID});
|
|
|
//同层节点原本父选项数据
|
|
|
- let subNodeOptParent = _.find(bills.selected.elf.datas, {ID: subNodeOptData.ParentID});
|
|
|
+ let subNodeOptParent = _.find(bills.selected.sub.datas, {ID: subNodeOptData.ParentID});
|
|
|
let subNodeOptParentWithRank = _.find(nodeOpts, {ID: subNodeOptParent.ID});
|
|
|
//父项顺序决定插入位置
|
|
|
if(dataWithRank.rank < subNodeOptParentWithRank.rank){
|
|
|
@@ -440,7 +525,7 @@ const BillsElf = (function() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- let sub2Opts = getOptions(subOpt, bills.selected.elf.datas);
|
|
|
+ let sub2Opts = getOptions(subOpt, bills.selected.sub.datas);
|
|
|
subOpt.options = sub2Opts.length > 0 ? sub2Opts[0].name : '';
|
|
|
let cloneOpt = _.cloneDeep(subOpt);//不改变原本的数据,比如ParentID
|
|
|
cloneOpt.optionChecked = sub2Opts.length > 0 ? [_.cloneDeep(sub2Opts[0])] : [];
|
|
|
@@ -473,7 +558,7 @@ const BillsElf = (function() {
|
|
|
return '';
|
|
|
}
|
|
|
let height = cellRect.height;
|
|
|
- let options = getOptions(node.data, bills.selected.elf.datas);
|
|
|
+ let options = getOptions(node.data, bills.selected.sub.datas);
|
|
|
top = options.length > 6 ? top - 6 * height : top - options.length * height;
|
|
|
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+5 : height*options.length+5}px; font-size: 0.9rem;"></div>`);
|
|
|
@@ -510,7 +595,7 @@ const BillsElf = (function() {
|
|
|
let checkedNameArr = [],
|
|
|
optionChecked= [];
|
|
|
for(let checkSel of checkedSels){
|
|
|
- let opt = _.cloneDeep(_.find(bills.selected.elf.datas, {ID: $(checkSel).val()}));
|
|
|
+ let opt = _.cloneDeep(_.find(bills.selected.sub.datas, {ID: $(checkSel).val()}));
|
|
|
opt.rank = $(checkSel).attr('rank');
|
|
|
checkedNameArr.push(opt.name);
|
|
|
optionChecked.push(opt);
|
|
|
@@ -527,7 +612,7 @@ const BillsElf = (function() {
|
|
|
//插入节点
|
|
|
for(let perCheked of optionChecked){
|
|
|
let exist = false;
|
|
|
- let subOpts = getOptions(perCheked, bills.selected.elf.datas);
|
|
|
+ let subOpts = getOptions(perCheked, bills.selected.sub.datas);
|
|
|
for(let subNode of node.children){
|
|
|
for(let subOpt of subOpts){
|
|
|
if(subNode.data.ID === subOpt.ID){
|
|
|
@@ -550,7 +635,7 @@ const BillsElf = (function() {
|
|
|
for(let subNode of node.children){
|
|
|
let exist = false;
|
|
|
for(let perChecked of optionChecked){
|
|
|
- let subOpts = getOptions(perChecked, bills.selected.elf.datas);
|
|
|
+ let subOpts = getOptions(perChecked, bills.selected.sub.datas);
|
|
|
for(let subOpt of subOpts){
|
|
|
if(subNode.data.ID === subOpt.ID){
|
|
|
exist = true;
|
|
|
@@ -579,7 +664,7 @@ const BillsElf = (function() {
|
|
|
$editor.attr("gcUIElement", "gcEditingInput");
|
|
|
//编辑文本框距离浏览器的top
|
|
|
let top = $('.header').height() + $('#zaojiashu').find('.toolsbar').height() + $('#top_div').height() + $('#bottom_div_ul').height() + $('#qdjlTools').height() + $('.resize-y').height();
|
|
|
- let node = bills.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
|
|
|
+ let node = bills.selected.sub.tree.items[elfSheet.getActiveRowIndex()];
|
|
|
setOptionsDiv($editor, node, cellRect, cellStyle, top + cellRect.y);
|
|
|
this.isEscKey = false;
|
|
|
}
|
|
|
@@ -592,7 +677,7 @@ const BillsElf = (function() {
|
|
|
};
|
|
|
OptionsCellType.prototype.getEditorValue = function (editor, context) {
|
|
|
let me = this;
|
|
|
- let node = bills.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
|
|
|
+ let node = bills.selected.sub.tree.items[elfSheet.getActiveRowIndex()];
|
|
|
if(this.isEscKey !=true){
|
|
|
renderSheetFunc(elfSheet, function () {
|
|
|
doAfterSel.call(me, node);
|
|
|
@@ -649,10 +734,10 @@ const BillsElf = (function() {
|
|
|
//@return {Array}
|
|
|
function getInsertElfRationData(){
|
|
|
let rst = [];
|
|
|
- if(!bills.selected || !bills.selected.elf){
|
|
|
+ if(!bills.selected || !bills.selected.sub){
|
|
|
return rst;
|
|
|
}
|
|
|
- let tree = bills.selected.elf.tree;
|
|
|
+ let tree = bills.selected.sub.tree;
|
|
|
if(!tree){
|
|
|
return rst;
|
|
|
}
|
|
|
@@ -676,7 +761,7 @@ const BillsElf = (function() {
|
|
|
}
|
|
|
//选项下子选项是定额
|
|
|
else {
|
|
|
- let rationOpts = getOptions(perChecked, bills.selected.elf.datas);
|
|
|
+ let rationOpts = getOptions(perChecked, bills.selected.sub.datas);
|
|
|
for(let ration of rationOpts){
|
|
|
if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
|
|
|
rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
|
|
|
@@ -691,10 +776,10 @@ const BillsElf = (function() {
|
|
|
//@return {Array}
|
|
|
function getInsertElfSingleRation() {
|
|
|
let rst = [];
|
|
|
- if (!bills.selected || !bills.selected.elf) {
|
|
|
+ if (!bills.selected || !bills.selected.sub) {
|
|
|
return rst;
|
|
|
}
|
|
|
- let tree = bills.selected.elf.tree;
|
|
|
+ let tree = bills.selected.sub.tree;
|
|
|
if (!tree) {
|
|
|
return rst;
|
|
|
}
|
|
|
@@ -718,7 +803,7 @@ const BillsElf = (function() {
|
|
|
if (firstOptionChecked.type === itemType.ration && !existTheRation(firstOptionChecked.rationID)) {
|
|
|
rst.push({itemQuery: {userID: userID, ID: firstOptionChecked.rationID}, rationType: rationType.ration});
|
|
|
} else {
|
|
|
- let rationOpts = getOptions(firstOptionChecked, bills.selected.elf.datas);
|
|
|
+ let rationOpts = getOptions(firstOptionChecked, bills.selected.sub.datas);
|
|
|
for(let ration of rationOpts){
|
|
|
if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
|
|
|
rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
|
|
|
@@ -757,9 +842,16 @@ const BillsElf = (function() {
|
|
|
insertRations(addRationDatas);
|
|
|
});
|
|
|
}
|
|
|
- return {buildSheet, refreshWorkBook, billsSelElf, setColumnWidthByRate, bindListener};
|
|
|
+ return {
|
|
|
+ switchModule,
|
|
|
+ buildSheet,
|
|
|
+ refreshWorkBook,
|
|
|
+ billsSelSub,
|
|
|
+ setColumnWidthByRate,
|
|
|
+ bindListener
|
|
|
+ };
|
|
|
})();
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
- BillsElf.bindListener();
|
|
|
+ BillsSub.bindListener();
|
|
|
});
|