|
@@ -17,10 +17,20 @@ let billsGuidanceSelMode = 0;
|
|
|
const BillsSub = (function() {
|
|
const BillsSub = (function() {
|
|
|
//清单子树挂载的地方,selected:当前选中的清单,mapping:以前九位清单编码为索引, 'xxx' : {sub: {datas, tree, controller}}
|
|
//清单子树挂载的地方,selected:当前选中的清单,mapping:以前九位清单编码为索引, 'xxx' : {sub: {datas, tree, controller}}
|
|
|
let bills = {selected: null, mapping: {}};
|
|
let bills = {selected: null, mapping: {}};
|
|
|
|
|
+ // 指引类型
|
|
|
const itemType = {
|
|
const itemType = {
|
|
|
|
|
+ // 工作内容
|
|
|
job: 0,
|
|
job: 0,
|
|
|
|
|
+ // 定额
|
|
|
ration: 1
|
|
ration: 1
|
|
|
};
|
|
};
|
|
|
|
|
+ // 库类型
|
|
|
|
|
+ const libType = {
|
|
|
|
|
+ // 清单指引
|
|
|
|
|
+ guidance: 1,
|
|
|
|
|
+ // 清单精灵
|
|
|
|
|
+ elf: 2
|
|
|
|
|
+ };
|
|
|
// 清单精灵
|
|
// 清单精灵
|
|
|
const elfItem = {
|
|
const elfItem = {
|
|
|
dom: $('#billsSubItems'),
|
|
dom: $('#billsSubItems'),
|
|
@@ -100,7 +110,7 @@ const BillsSub = (function() {
|
|
|
tree: null,
|
|
tree: null,
|
|
|
controller: null,
|
|
controller: null,
|
|
|
treeSetting: {
|
|
treeSetting: {
|
|
|
- treeCol: 1,
|
|
|
|
|
|
|
+ treeCol: 0,
|
|
|
emptyRows: 0,
|
|
emptyRows: 0,
|
|
|
headRows: 1,
|
|
headRows: 1,
|
|
|
headRowHeight: [40],
|
|
headRowHeight: [40],
|
|
@@ -108,7 +118,7 @@ const BillsSub = (function() {
|
|
|
cols: [
|
|
cols: [
|
|
|
{
|
|
{
|
|
|
width: 420,
|
|
width: 420,
|
|
|
- readOnly: false,
|
|
|
|
|
|
|
+ readOnly: true,
|
|
|
head: {
|
|
head: {
|
|
|
titleNames: ["项目指引"],
|
|
titleNames: ["项目指引"],
|
|
|
spanCols: [1],
|
|
spanCols: [1],
|
|
@@ -169,10 +179,28 @@ const BillsSub = (function() {
|
|
|
// 切换目前的模块
|
|
// 切换目前的模块
|
|
|
// 1:清单指引 2:清单精灵
|
|
// 1:清单指引 2:清单精灵
|
|
|
function switchModule(type) {
|
|
function switchModule(type) {
|
|
|
- curModule = elfItem;
|
|
|
|
|
- /* curModule = type === 1
|
|
|
|
|
- ? guideItem
|
|
|
|
|
- : elfItem;*/
|
|
|
|
|
|
|
+ let libText;
|
|
|
|
|
+ if (type === libType.guidance) {
|
|
|
|
|
+ curModule = guideItem;
|
|
|
|
|
+ libText = '清单指引';
|
|
|
|
|
+ // 动态按钮
|
|
|
|
|
+ $('#guidanceInsertRation').show();
|
|
|
|
|
+ $('#elfInsertRation').hide();
|
|
|
|
|
+ $('#elfInsertSingle').hide();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ curModule = elfItem;
|
|
|
|
|
+ libText = '清单精灵';
|
|
|
|
|
+ // 动态按钮
|
|
|
|
|
+ $('#guidanceInsertRation').hide();
|
|
|
|
|
+ $('#elfInsertRation').show();
|
|
|
|
|
+ $('#elfInsertSingle').show();
|
|
|
|
|
+ }
|
|
|
|
|
+ $('#qdjlTools').show();
|
|
|
|
|
+ // 库名称、清单子菜单名称动态显示
|
|
|
|
|
+ $('#stdBillsGuidanceTab').text(libText);
|
|
|
|
|
+ $('#linkQDJL').text(libText);
|
|
|
|
|
+ // 监听按钮事件
|
|
|
|
|
+ bindListener();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const options = {
|
|
const options = {
|
|
@@ -337,10 +365,90 @@ const BillsSub = (function() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 清单精灵数据初始化
|
|
|
|
|
+ function initElf(sheet, elf, treeData) {
|
|
|
|
|
+ //定额数据删除编号信息,(编码后+空格才会去除编码)
|
|
|
|
|
+ for(let rData of treeData){
|
|
|
|
|
+ if(rData.type === itemType.ration){
|
|
|
|
|
+ let nameArr = rData.name.split(' ');
|
|
|
|
|
+ if(nameArr.length > 1){
|
|
|
|
|
+ nameArr.splice(0, 1);
|
|
|
|
|
+ rData.name = nameArr.join(' ');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ elf.sub.datas = treeData;
|
|
|
|
|
+ //第一层节点数据
|
|
|
|
|
+ let firstLevelDatas = _.filter(treeData, function (data) {
|
|
|
|
|
+ return data.ParentID == -1;
|
|
|
|
|
+ });
|
|
|
|
|
+ //第一层初始数据的选项显示
|
|
|
|
|
+ for(let fData of firstLevelDatas){
|
|
|
|
|
+ let options = getOptions(fData, treeData);
|
|
|
|
|
+ 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(sheet, function () {
|
|
|
|
|
+ initTree(elf.sub, sheet, elfItem.treeSetting, firstLevelDatas);
|
|
|
|
|
+ //初始选择选项
|
|
|
|
|
+ let initOptsOpr = [];
|
|
|
|
|
+ for(let elfNode of elf.sub.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, sheet, elf.sub.tree.items, false);
|
|
|
|
|
+ setOptionsCellType(elf.sub.tree.items);
|
|
|
|
|
+ //项目指引初始焦点
|
|
|
|
|
+ elfItemInitSel(sheet.getActiveRowIndex() ? sheet.getActiveRowIndex() : 0);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 已经初始化过的清单精灵数据,重新展示
|
|
|
|
|
+ function reshowElf(sheet, elf) {
|
|
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
|
|
+ elf.sub.controller.showTreeData();
|
|
|
|
|
+ setOptionsCellType(elf.sub.tree.items);
|
|
|
|
|
+ //清单精灵初始焦点
|
|
|
|
|
+ elfItemInitSel(sheet.getActiveRowIndex() ? sheet.getActiveRowIndex() : 0);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //根据项目指引的类型设置单元格类型,定额类型的项目指引为复选框
|
|
|
|
|
+ //@param {Array}nodes @return {void}
|
|
|
|
|
+ function setItemCellType(nodes){
|
|
|
|
|
+ //设置单元格类型
|
|
|
|
|
+ const base = new GC.Spread.Sheets.CellTypes.Base();
|
|
|
|
|
+ const checkBox = new GC.Spread.Sheets.CellTypes.CheckBox();
|
|
|
|
|
+ const sheet = guideItem.workBook.getActiveSheet();
|
|
|
|
|
+ renderSheetFunc(sheet, function(){
|
|
|
|
|
+ for(let node of nodes){
|
|
|
|
|
+ sheet.setCellType(node.serialNo(), 1, node.data.type === itemType.ration ? checkBox : base);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 清单指引数据初始化
|
|
|
|
|
+ function initGuidance(sheet, guidance, treeData) {
|
|
|
|
|
+ guidance.sub.datas = treeData;
|
|
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
|
|
+ initTree(guidance.sub, sheet, guideItem.treeSetting, treeData);
|
|
|
|
|
+ //TREE_SHEET_HELPER.refreshTreeNodeData(guideItem.treeSetting, sheet, guidance.sub.tree.items, false);
|
|
|
|
|
+ setItemCellType(guidance.sub.tree.items);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 已经初始化过的清单指引数据,重新展示
|
|
|
|
|
+ function reshowGuidance(sheet, guidance) {
|
|
|
|
|
+ renderSheetFunc(sheet, function () {
|
|
|
|
|
+ guidance.sub.controller.showTreeData();
|
|
|
|
|
+ setItemCellType(guidance.sub.tree.items);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
//清单焦点变换-清单子界面操作,获取清单前九位编码的标准清单清单精灵选项 或 清单指引数据
|
|
//清单焦点变换-清单子界面操作,获取清单前九位编码的标准清单清单精灵选项 或 清单指引数据
|
|
|
//@param {String}code @return {void}
|
|
//@param {String}code @return {void}
|
|
|
function billsSelSub(code) {
|
|
function billsSelSub(code) {
|
|
|
- console.log(bills);
|
|
|
|
|
let sheet = curModule.workBook.getActiveSheet();
|
|
let sheet = curModule.workBook.getActiveSheet();
|
|
|
cleanData(sheet, curModule.headers, -1);
|
|
cleanData(sheet, curModule.headers, -1);
|
|
|
if (!code || code === '') {
|
|
if (!code || code === '') {
|
|
@@ -351,9 +459,9 @@ const BillsSub = (function() {
|
|
|
if (!bills.mapping[nineCode]) {
|
|
if (!bills.mapping[nineCode]) {
|
|
|
bills.mapping[nineCode] = {sub: {datas: [], tree: null, controller: null}};
|
|
bills.mapping[nineCode] = {sub: {datas: [], tree: null, controller: null}};
|
|
|
}
|
|
}
|
|
|
- let node = bills.mapping[nineCode];
|
|
|
|
|
- bills.selected = node;
|
|
|
|
|
- if(!node.sub.tree){
|
|
|
|
|
|
|
+ let container = bills.mapping[nineCode];
|
|
|
|
|
+ bills.selected = container;
|
|
|
|
|
+ if(!container.sub.tree){
|
|
|
let guidanceLibID;
|
|
let guidanceLibID;
|
|
|
if (projectObj.project.projectInfo.engineeringInfo && projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib) {
|
|
if (projectObj.project.projectInfo.engineeringInfo && projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib) {
|
|
|
guidanceLibID = projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib[0]
|
|
guidanceLibID = projectObj.project.projectInfo.engineeringInfo.billsGuidance_lib[0]
|
|
@@ -361,54 +469,14 @@ const BillsSub = (function() {
|
|
|
: null;
|
|
: null;
|
|
|
}
|
|
}
|
|
|
CommonAjax.post('/billsGuidance/api/getItemsByCode', {guidanceLibID: guidanceLibID, code: nineCode}, function (rstData) {
|
|
CommonAjax.post('/billsGuidance/api/getItemsByCode', {guidanceLibID: guidanceLibID, code: nineCode}, function (rstData) {
|
|
|
- //定额数据删除编号信息,(编码后+空格才会去除编码)
|
|
|
|
|
- for(let rData of rstData){
|
|
|
|
|
- if(rData.type === itemType.ration){
|
|
|
|
|
- let nameArr = rData.name.split(' ');
|
|
|
|
|
- if(nameArr.length > 1){
|
|
|
|
|
- nameArr.splice(0, 1);
|
|
|
|
|
- rData.name = nameArr.join(' ');
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- node.sub.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(sheet, function () {
|
|
|
|
|
- initTree(node.sub, sheet, elfItem.treeSetting, firstLevelDatas);
|
|
|
|
|
- //初始选择选项
|
|
|
|
|
- let initOptsOpr = [];
|
|
|
|
|
- for(let elfNode of node.sub.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, sheet, node.sub.tree.items, false);
|
|
|
|
|
- setOptionsCellType(node.sub.tree.items);
|
|
|
|
|
- //项目指引初始焦点
|
|
|
|
|
- elfItemInitSel(sheet.getActiveRowIndex() ? sheet.getActiveRowIndex() : 0);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ curModule === elfItem
|
|
|
|
|
+ ? initElf(sheet, container, rstData)
|
|
|
|
|
+ : initGuidance(sheet, container, rstData);
|
|
|
});
|
|
});
|
|
|
} else{
|
|
} else{
|
|
|
- renderSheetFunc(sheet, function () {
|
|
|
|
|
- node.sub.controller.showTreeData();
|
|
|
|
|
- setOptionsCellType(node.sub.tree.items);
|
|
|
|
|
- //项目指引初始焦点
|
|
|
|
|
- elfItemInitSel(sheet.getActiveRowIndex() ? sheet.getActiveRowIndex() : 0);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ curModule === elfItem
|
|
|
|
|
+ ? reshowElf(sheet, container)
|
|
|
|
|
+ : reshowGuidance(sheet, container);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//获取选项的深度
|
|
//获取选项的深度
|
|
@@ -694,29 +762,6 @@ const BillsSub = (function() {
|
|
|
this.isEscKey = e.keyCode === GC.Spread.Commands.Key.esc;
|
|
this.isEscKey = e.keyCode === GC.Spread.Commands.Key.esc;
|
|
|
return false;
|
|
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) {
|
|
OptionsCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
return {
|
|
return {
|
|
|
x: x,
|
|
x: x,
|
|
@@ -730,9 +775,47 @@ const BillsSub = (function() {
|
|
|
};
|
|
};
|
|
|
return new OptionsCellType();
|
|
return new OptionsCellType();
|
|
|
}
|
|
}
|
|
|
|
|
+ //原本清单存在此定额
|
|
|
|
|
+ function existTheRation(nodes, rationID) {
|
|
|
|
|
+ return nodes.find(node => node.data && node.data.stdID == rationID)
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取清单指生成的定额数据(不允许重复插入)
|
|
|
|
|
+ function getInsertGuidanceRationData() {
|
|
|
|
|
+ let rst = [];
|
|
|
|
|
+ if(!bills.selected || !bills.selected.sub){
|
|
|
|
|
+ return rst;
|
|
|
|
|
+ }
|
|
|
|
|
+ let tree = bills.selected.sub.tree;
|
|
|
|
|
+ if(!tree){
|
|
|
|
|
+ return rst;
|
|
|
|
|
+ }
|
|
|
|
|
+ let mainSelected = projectObj.project.mainTree.selected,
|
|
|
|
|
+ mainSelRationNodes = mainSelected.children.filter(node => node.data && node.data.type === rationType.ration);
|
|
|
|
|
+ // 从指引表从获取勾选的定额数据
|
|
|
|
|
+ let sheet = guideItem.workBook.getSheet(0),
|
|
|
|
|
+ rowCount = sheet.getRowCount();
|
|
|
|
|
+ for (let row = 0; row < rowCount; row++) {
|
|
|
|
|
+ let data = tree.items[row].data;
|
|
|
|
|
+ // 勾选的定额,且该定额在目标清单下不存在才插入
|
|
|
|
|
+ let isChecked = sheet.getValue(row, 1);
|
|
|
|
|
+ if (isChecked
|
|
|
|
|
+ && data.type === itemType.ration
|
|
|
|
|
+ && !existTheRation(mainSelRationNodes, data.rationID)) {
|
|
|
|
|
+ rst.push({
|
|
|
|
|
+ itemQuery: {
|
|
|
|
|
+ userID,
|
|
|
|
|
+ ID: data.rationID
|
|
|
|
|
+ },
|
|
|
|
|
+ rationType: rationType.ration
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return rst;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//获取清单精灵生成的定额数据(跳过重复,不允许重复插入)
|
|
//获取清单精灵生成的定额数据(跳过重复,不允许重复插入)
|
|
|
//@return {Array}
|
|
//@return {Array}
|
|
|
- function getInsertElfRationData(){
|
|
|
|
|
|
|
+ function getInsertElfRationData() {
|
|
|
let rst = [];
|
|
let rst = [];
|
|
|
if(!bills.selected || !bills.selected.sub){
|
|
if(!bills.selected || !bills.selected.sub){
|
|
|
return rst;
|
|
return rst;
|
|
@@ -741,29 +824,20 @@ const BillsSub = (function() {
|
|
|
if(!tree){
|
|
if(!tree){
|
|
|
return rst;
|
|
return rst;
|
|
|
}
|
|
}
|
|
|
- let mainSelected = projectObj.project.mainTree.selected;
|
|
|
|
|
- let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
|
|
|
|
|
- return c.data && c.data.type === rationType.ration;
|
|
|
|
|
- });
|
|
|
|
|
- //原本清单存在此定额
|
|
|
|
|
- function existTheRation(rationID) {
|
|
|
|
|
- let r = _.find(mainSelRationNodes, function (node) {
|
|
|
|
|
- return node.data && node.data.stdID && node.data.stdID == rationID;
|
|
|
|
|
- });
|
|
|
|
|
- return r;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let mainSelected = projectObj.project.mainTree.selected,
|
|
|
|
|
+ mainSelRationNodes = mainSelected.children.filter(node => node.data && node.data.type === rationType.ration);
|
|
|
//造价书当前选中清单下的定额
|
|
//造价书当前选中清单下的定额
|
|
|
for(let node of tree.items){
|
|
for(let node of tree.items){
|
|
|
for(let perChecked of node.data.optionChecked){
|
|
for(let perChecked of node.data.optionChecked){
|
|
|
//选项直接是定额
|
|
//选项直接是定额
|
|
|
- if(perChecked.type === itemType.ration && !existTheRation(perChecked.rationID)){
|
|
|
|
|
|
|
+ if(perChecked.type === itemType.ration && !existTheRation(mainSelRationNodes, perChecked.rationID)){
|
|
|
rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
|
|
rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
|
|
|
}
|
|
}
|
|
|
//选项下子选项是定额
|
|
//选项下子选项是定额
|
|
|
else {
|
|
else {
|
|
|
let rationOpts = getOptions(perChecked, bills.selected.sub.datas);
|
|
let rationOpts = getOptions(perChecked, bills.selected.sub.datas);
|
|
|
for(let ration of rationOpts){
|
|
for(let ration of rationOpts){
|
|
|
- if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
|
|
|
|
|
|
|
+ if(ration.type === itemType.ration && !existTheRation(mainSelRationNodes, ration.rationID)){
|
|
|
rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
|
|
rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -787,25 +861,16 @@ const BillsSub = (function() {
|
|
|
if (!elfSelected || !elfSelected.data.optionChecked || !elfSelected.data.optionChecked[0]) {
|
|
if (!elfSelected || !elfSelected.data.optionChecked || !elfSelected.data.optionChecked[0]) {
|
|
|
return rst;
|
|
return rst;
|
|
|
}
|
|
}
|
|
|
- let mainSelected = projectObj.project.mainTree.selected;
|
|
|
|
|
- let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
|
|
|
|
|
- return c.data && c.data.type === rationType.ration;
|
|
|
|
|
- });
|
|
|
|
|
- //原本清单存在此定额
|
|
|
|
|
- function existTheRation(rationID) {
|
|
|
|
|
- let r = _.find(mainSelRationNodes, function (node) {
|
|
|
|
|
- return node.data && node.data.stdID && node.data.stdID == rationID;
|
|
|
|
|
- });
|
|
|
|
|
- return r;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let mainSelected = projectObj.project.mainTree.selected,
|
|
|
|
|
+ mainSelRationNodes = mainSelected.children.filter(node => node.data && node.data.type === rationType.ration);
|
|
|
//选中的节点第一个选项时定额选项或第一个选项下的子选项时定额选项
|
|
//选中的节点第一个选项时定额选项或第一个选项下的子选项时定额选项
|
|
|
let firstOptionChecked = elfSelected.data.optionChecked[0];
|
|
let firstOptionChecked = elfSelected.data.optionChecked[0];
|
|
|
- if (firstOptionChecked.type === itemType.ration && !existTheRation(firstOptionChecked.rationID)) {
|
|
|
|
|
|
|
+ if (firstOptionChecked.type === itemType.ration && !existTheRation(mainSelRationNodes, firstOptionChecked.rationID)) {
|
|
|
rst.push({itemQuery: {userID: userID, ID: firstOptionChecked.rationID}, rationType: rationType.ration});
|
|
rst.push({itemQuery: {userID: userID, ID: firstOptionChecked.rationID}, rationType: rationType.ration});
|
|
|
} else {
|
|
} else {
|
|
|
let rationOpts = getOptions(firstOptionChecked, bills.selected.sub.datas);
|
|
let rationOpts = getOptions(firstOptionChecked, bills.selected.sub.datas);
|
|
|
for(let ration of rationOpts){
|
|
for(let ration of rationOpts){
|
|
|
- if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
|
|
|
|
|
|
|
+ if(ration.type === itemType.ration && !existTheRation(mainSelRationNodes, ration.rationID)){
|
|
|
rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
|
|
rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -822,24 +887,27 @@ const BillsSub = (function() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ function handleClick(getRationFunc) {
|
|
|
|
|
+ if (!projectObj.project.Ration.canAdd(projectObj.project.mainTree.selected)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ let addRationDatas = getRationFunc();
|
|
|
|
|
+ insertRations(addRationDatas);
|
|
|
|
|
+ }
|
|
|
//各监听事件
|
|
//各监听事件
|
|
|
//@return {void}
|
|
//@return {void}
|
|
|
function bindListener(){
|
|
function bindListener(){
|
|
|
- //插入定额
|
|
|
|
|
|
|
+ // 插入定额
|
|
|
|
|
+ $('#guidanceInsertRation').click(function () {
|
|
|
|
|
+ handleClick(getInsertGuidanceRationData);
|
|
|
|
|
+ });
|
|
|
|
|
+ // 应用选项
|
|
|
$('#elfInsertRation').click(function () {
|
|
$('#elfInsertRation').click(function () {
|
|
|
- if (!projectObj.project.Ration.canAdd(projectObj.project.mainTree.selected)) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- let addRationDatas = getInsertElfRationData();
|
|
|
|
|
- insertRations(addRationDatas);
|
|
|
|
|
|
|
+ handleClick(getInsertElfRationData);
|
|
|
});
|
|
});
|
|
|
- //插入单条
|
|
|
|
|
|
|
+ // 应用单条
|
|
|
$('#elfInsertSingle').click(function () {
|
|
$('#elfInsertSingle').click(function () {
|
|
|
- if (!projectObj.project.Ration.canAdd(projectObj.project.mainTree.selected)) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- let addRationDatas = getInsertElfSingleRation();
|
|
|
|
|
- insertRations(addRationDatas);
|
|
|
|
|
|
|
+ handleClick(getInsertElfSingleRation);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
@@ -847,11 +915,6 @@ const BillsSub = (function() {
|
|
|
buildSheet,
|
|
buildSheet,
|
|
|
refreshWorkBook,
|
|
refreshWorkBook,
|
|
|
billsSelSub,
|
|
billsSelSub,
|
|
|
- setColumnWidthByRate,
|
|
|
|
|
- bindListener
|
|
|
|
|
|
|
+ setColumnWidthByRate
|
|
|
};
|
|
};
|
|
|
-})();
|
|
|
|
|
-
|
|
|
|
|
-$(document).ready(function () {
|
|
|
|
|
- BillsSub.bindListener();
|
|
|
|
|
-});
|
|
|
|
|
|
|
+})();
|