|
@@ -31,6 +31,7 @@ let repositoryGljObj = {
|
|
|
parentNodeIds: {},
|
|
|
gljList: [],
|
|
|
allowComponent: [202, 203, 204, 301],//可带组成物类型:混凝土、砂浆、配合比、机械台班
|
|
|
+ componentGljType: [201, 302, 303],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
|
|
|
distTypeTree: null,//add
|
|
|
setting: {
|
|
|
|
|
@@ -231,13 +232,51 @@ let repositoryGljObj = {
|
|
|
});
|
|
|
return rst;
|
|
|
},
|
|
|
+ //获得引用了组成物id为componentId的工料机,和重新变化组成物数组、重新计算单价
|
|
|
+ getUpdateGljs: function (rObj, isDelete) {
|
|
|
+ let me = repositoryGljObj, that = gljComponentOprObj,
|
|
|
+ rst = {updateArr: [], updateBasePrcArr: []};
|
|
|
+ //改变单价,以便reCalGljBasePrc方法可行
|
|
|
+ if(!isDelete){
|
|
|
+ for(let i = 0; i < me.gljList.length; i++){
|
|
|
+ if(me.gljList[i].ID === rObj.ID){
|
|
|
+ me.gljList[i].basePrice = rObj.basePrice;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(let i = 0; i < me.gljList.length; i++){
|
|
|
+ let thisComponent = me.gljList[i].component, isChange = false;
|
|
|
+ for(let j = 0; j < thisComponent.length; j++){
|
|
|
+ if(thisComponent[j].ID === rObj.ID){
|
|
|
+ //删除
|
|
|
+ isChange = true;
|
|
|
+ if(isDelete){
|
|
|
+ thisComponent.splice(j--, 1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isChange){//引用了此组成物
|
|
|
+ let gljBasePrc = that.reCalGljBasePrc(me.getCurrentComponent(thisComponent));
|
|
|
+ if(me.gljList[i].basePrice !== gljBasePrc){
|
|
|
+ me.gljList[i].basePrice = gljBasePrc;
|
|
|
+ rst.updateBasePrcArr.push({gljId: me.gljList[i].ID, gljType: me.gljList[i].gljType, basePrice: me.gljList[i].basePrice});
|
|
|
+ }
|
|
|
+ rst.updateArr.push(me.gljList[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
reshowGljBasePrc: function (glj) {
|
|
|
let me = repositoryGljObj;
|
|
|
-
|
|
|
- for(let i = 0; i < me.gljList.length; i++){
|
|
|
- if(glj.ID === me.gljList[i].ID){
|
|
|
- me.gljList[i].basePrice = glj.basePrice;
|
|
|
- me.workBook.getSheet(0).setValue(me.activeRow, 4, glj.basePrice);
|
|
|
+ let cacheSection = me.currentCache;
|
|
|
+ for(let i = 0; i < cacheSection.length; i++){
|
|
|
+ if(glj.ID === cacheSection[i].ID){
|
|
|
+ cacheSection[i].basePrice = glj.basePrice;
|
|
|
+ me.workBook.getSheet(0).setValue(i, 4, glj.basePrice);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -247,7 +286,6 @@ let repositoryGljObj = {
|
|
|
//混凝土202、砂浆203、配合比204、机械3
|
|
|
if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
|
|
|
let row = info.newSelections[0].row;
|
|
|
- me.activeRow = row;
|
|
|
sheetCommonObj.lockCells(that.workBook.getSheet(0), that.setting);
|
|
|
that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
@@ -339,9 +377,12 @@ let repositoryGljObj = {
|
|
|
let field = me.setting.header[col].dataCode;
|
|
|
if(field === 'gljType'){
|
|
|
me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(
|
|
|
- me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[field]].data.fullName);
|
|
|
+ typeof me.currentEditingGlj[field] !== 'undefined'?
|
|
|
+ me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[field]].data.fullName
|
|
|
+ : '');
|
|
|
}
|
|
|
else{
|
|
|
+ me.workBook.getSheet(0).getCell(me.editingRowIdx, 0).formatter("@");
|
|
|
me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingGlj[me.setting.header[col].dataCode]);
|
|
|
}
|
|
|
}
|
|
@@ -368,31 +409,65 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
},
|
|
|
onCellEditEnd: function(sender, args) {
|
|
|
- let me = repositoryGljObj, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
|
|
|
+ let me = repositoryGljObj, that = gljComponentOprObj,
|
|
|
+ rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
|
|
|
updateArr = [], addArr = [], updateBasePrcArr = [];
|
|
|
me.editingRowIdx = args.row;
|
|
|
rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
|
|
|
+ //更新
|
|
|
if (me.currentEditingGlj["ID"]) {
|
|
|
rObj["ID"] = me.currentEditingGlj["ID"];
|
|
|
rObj.gljClass = me.currentEditingGlj.gljClass;
|
|
|
- for(let col =0; col< me.setting.header.length; col++){
|
|
|
- if(me.currentEditingGlj[me.setting.header[col].dataCode] !== rObj[me.setting.header[col].dataCode]){
|
|
|
- me.addGljObj = rObj;
|
|
|
- if(rObj[me.setting.header[0].dataCode] && rObj[me.setting.header[1].dataCode] && rObj[me.setting.header[5].dataCode]){
|
|
|
- if(rObj.gljType !== me.currentEditingGlj.gljType){//修改了工料机类型,组成物清空
|
|
|
+ if(me.currentEditingGlj[me.setting.header[args.col].dataCode] !== rObj[me.setting.header[args.col].dataCode]){
|
|
|
+ if(rObj[me.setting.header[0].dataCode] && rObj[me.setting.header[1].dataCode] && rObj[me.setting.header[5].dataCode] &&
|
|
|
+ rObj[me.setting.header[0].dataCode].toString().trim().length !== 0 && rObj[me.setting.header[1].dataCode].toString().trim().length !== 0 && rObj[me.setting.header[5].dataCode].toString().trim().length !== 0){
|
|
|
+ if(rObj.gljType !== me.currentEditingGlj.gljType){//修改了工料机类型
|
|
|
if(me.currentGlj){
|
|
|
me.currentGlj.component = [];
|
|
|
}
|
|
|
if(me.allowComponent.indexOf(rObj.gljType) !== -1){
|
|
|
rObj.basePrice = 0;
|
|
|
}
|
|
|
+ if(me.componentGljType.indexOf(me.currentEditingGlj.gljType) !== -1 &&
|
|
|
+ !(me.currentEditingGlj.gljType === 302 && rObj.gljType === 303) && !(me.currentEditingGlj.gljType === 303 && rObj.gljType === 302)){//修改了原本是组成物的工料机
|
|
|
+ //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
|
|
|
+ let updateGljs = me.getUpdateGljs(rObj);
|
|
|
+ if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
+ updateArr.push(updateGljs.updateArr[i]);
|
|
|
+ }
|
|
|
+ for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
|
|
|
+ updateArr.push(updateGljs.updateBasePrcArr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(rObj.basePrice !== me.currentEditingGlj.basePrice){//修改了单价,可修改单价的必为可成为组成物的
|
|
|
+ //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
|
|
|
+ let updateGljs = me.getUpdateGljs(rObj);
|
|
|
+ if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
+ updateArr.push(updateGljs.updateArr[i]);
|
|
|
+ }
|
|
|
+ for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
|
|
|
+ updateArr.push(updateGljs.updateBasePrcArr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? that.round(parseFloat(rObj.basePrice), 2) : 0;
|
|
|
}
|
|
|
rObj.component = me.currentGlj.component;
|
|
|
updateArr.push(rObj);
|
|
|
- break;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if(me.setting.header[args.col].dataCode === 'gljType'){
|
|
|
+ let distTypeVal = me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[me.setting.header[args.col].dataCode]].data.fullName;
|
|
|
+ args.sheet.setValue(args.row, args.col, distTypeVal);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ args.sheet.setValue(args.row, args.col, me.currentEditingGlj[me.setting.header[args.col].dataCode]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
//--------------------------------------
|
|
|
if(me.currentEditingGlj.basePrice !== rObj.basePrice){
|
|
|
//update basePrice of ration when editting basePrice of glj
|
|
@@ -422,20 +497,25 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
//-----------------------------------------------------------
|
|
|
- } else {
|
|
|
- me.addGljObj = rObj;
|
|
|
- let isCanSav = true;
|
|
|
- if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[5].dataCode]){
|
|
|
- isCanSav = false;
|
|
|
- }
|
|
|
- if(isCanSav){
|
|
|
- me.addGljObj = null;
|
|
|
- rObj.component = [];
|
|
|
- //如果类型为混凝土、砂浆、配合比、机械台班时,添加时填写的单价清空
|
|
|
- if(me.allowComponent.indexOf(rObj.gljType) !== -1){
|
|
|
- rObj.basePrice = 0;
|
|
|
+ }
|
|
|
+ //新增
|
|
|
+ else {
|
|
|
+ if(typeof rObj.code !== 'undefined'){
|
|
|
+ me.addGljObj = rObj;
|
|
|
+ let isCanSav = true;
|
|
|
+ if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[5].dataCode]){
|
|
|
+ isCanSav = false;
|
|
|
+ }
|
|
|
+ if(isCanSav){
|
|
|
+ me.addGljObj = null;
|
|
|
+ rObj.component = [];
|
|
|
+ //如果类型为混凝土、砂浆、配合比、机械台班时,添加时填写的单价清空
|
|
|
+ if(me.allowComponent.indexOf(rObj.gljType) !== -1){
|
|
|
+ rObj.basePrice = 0;
|
|
|
+ }
|
|
|
+ rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? parseFloat(rObj.basePrice) : 0;
|
|
|
+ addArr.push(rObj);
|
|
|
}
|
|
|
- addArr.push(rObj);
|
|
|
}
|
|
|
}
|
|
|
if(me.gljCurTypeId !== 732){
|
|
@@ -463,6 +543,17 @@ let repositoryGljObj = {
|
|
|
if(sels[i].colCount === me.setting.header.length){
|
|
|
for(let j = 0; j < sels[i].rowCount; j++){
|
|
|
if(sels[i].row + j < cacheSection.length){
|
|
|
+ //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
|
|
|
+ let updateGljs = me.getUpdateGljs(cacheSection[sels[i].row + j], true);
|
|
|
+ if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
+ updateArr.push(updateGljs.updateArr[i]);
|
|
|
+ }
|
|
|
+ for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
|
|
|
+ updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(updateArr);
|
|
|
removeArr.push(cacheSection[sels[i].row + j].ID);
|
|
|
//tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
|
|
|
//删除后重新计算引用了此工料机的定额单价
|
|
@@ -518,45 +609,6 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //提取已被引用工料机
|
|
|
- /* if(tempRemoveArr.length > 0){
|
|
|
- for(let i = 0; i < tempRemoveArr.length; i++){
|
|
|
- if(me.rationGljIds.indexOf(tempRemoveArr[i].ID) !== -1){
|
|
|
- refGljCodes.push(tempRemoveArr[i].code);
|
|
|
- tempRemoveArr.splice(i--, 1);
|
|
|
- }
|
|
|
- else{
|
|
|
- removeArr.push(tempRemoveArr[i].ID);
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
- //提示
|
|
|
- /* if(refGljCodes.length > 0){
|
|
|
- let alertText;
|
|
|
- if(refGljCodes.length > 3){
|
|
|
- alertText = "编号: " + refGljCodes[0]+" 、" + refGljCodes[1] + " 、" + refGljCodes[2] + "...等工料机已有定额引用,删除失败!";
|
|
|
- }
|
|
|
- else {
|
|
|
- let alertCode = " ";
|
|
|
- for(let i=0; i< refGljCodes.length; i++){
|
|
|
- alertCode += refGljCodes[i] + " 、";
|
|
|
- }
|
|
|
- alertText = "编号:" + alertCode + "工料机已有定额引用,删除失败!"
|
|
|
- }
|
|
|
- $('#alertText').text(alertText);
|
|
|
- $('#codeAlertBtn').click();
|
|
|
- sheet.options.isProtected = true;
|
|
|
- $('#codAleConfBtn').click(function () {
|
|
|
- sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
|
|
|
- if(removeArr.length > 0){
|
|
|
- me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
- }
|
|
|
- });
|
|
|
- $('#codAleClose').click(function () {
|
|
|
- sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
|
|
|
- me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
- });
|
|
|
- }*/
|
|
|
if(removeArr.length > 0 || updateArr.length > 0){
|
|
|
//删除警告
|
|
|
$('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
|
|
@@ -577,8 +629,9 @@ let repositoryGljObj = {
|
|
|
me.workBook.commandManager().setShortcutKey('repositoryGljDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
},
|
|
|
validUpdateObj: function (pasteObj, rowIdx) {
|
|
|
- let rst = {}, backUpObj = {},
|
|
|
+ let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
|
|
|
me = repositoryGljObj,
|
|
|
+ that = gljComponentOprObj,
|
|
|
tempObj = me.currentCache[rowIdx],
|
|
|
reCalBasePrc = false,
|
|
|
isValid = true;
|
|
@@ -618,25 +671,53 @@ let repositoryGljObj = {
|
|
|
if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
|
|
|
isExsit = true;
|
|
|
reCalBasePrc = true;
|
|
|
+ //
|
|
|
+ if(me.componentGljType.indexOf(tempObj.gljType) !== -1 &&
|
|
|
+ !(tempObj.gljType === 302 && pasteObj.gljType === 303) && !(tempObj.gljType === 303 && pasteObj.gljType === 302)){//修改了原本是组成物的工料机
|
|
|
+ //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
|
|
|
+ let updateGljs = me.getUpdateGljs(tempObj, true);
|
|
|
+ if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
+ rst.updateGlj.push(updateGljs.updateArr[i]);
|
|
|
+ }
|
|
|
+ for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
|
|
|
+ rst.updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
tempObj.gljType = me.distTypeTree.comboDatas[i].value;
|
|
|
tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
|
|
|
-
|
|
|
+ if(me.allowComponent.indexOf(tempObj.gljType) !== -1){
|
|
|
+ tempObj.basePrice = 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
if(!isExsit) isValid = false;
|
|
|
}
|
|
|
//
|
|
|
- pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) :
|
|
|
+ pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? that.round(parseFloat(pasteObj.basePrice), 2) :
|
|
|
me.currentCache[rowIdx].basePrice;
|
|
|
if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
|
|
|
reCalBasePrc = true;
|
|
|
tempObj.basePrice = pasteObj.basePrice;
|
|
|
+ let updateGljs = me.getUpdateGljs(tempObj, false);
|
|
|
+ if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
+ rst.updateGlj.push(updateGljs.updateArr[i]);
|
|
|
+ }
|
|
|
+ for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
|
|
|
+ rst.updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if(isValid){
|
|
|
- rst.updateGlj = tempObj;
|
|
|
+ rst.updateGlj.push(tempObj);
|
|
|
if(reCalBasePrc){
|
|
|
//重新计算定额基价对象
|
|
|
- rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
|
|
|
+ //rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
|
|
|
+ let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
|
|
|
+ rst.updateBasePrcArr.push(newReObj);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -679,6 +760,7 @@ let repositoryGljObj = {
|
|
|
return true;
|
|
|
},
|
|
|
onClipboardPasting: function(sender, args) {
|
|
|
+ console.log(`oncp`);
|
|
|
let me = repositoryGljObj;
|
|
|
/*if (args.cellRange.colCount != me.setting.header.length || me.gljCurTypeId < 0 || me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
|
|
|
args.cancel = true;
|
|
@@ -705,9 +787,9 @@ let repositoryGljObj = {
|
|
|
for(let i = 0; i < items.length; i++){
|
|
|
let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
|
|
|
if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
|
|
|
- updateArr.push(updateObj.updateGlj);
|
|
|
+ updateArr = updateObj.updateGlj;
|
|
|
if(typeof updateObj.updateBasePrc !== 'undefined'){
|
|
|
- updateBasePrcArr.push(updateObj.updateBasePrc);
|
|
|
+ updateBasePrcArr = updateObj.updateBasePrc;
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
@@ -720,9 +802,9 @@ let repositoryGljObj = {
|
|
|
for(let i = 0; i < updateCount; i++){
|
|
|
let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
|
|
|
if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
|
|
|
- updateArr.push(updateObj.updateGlj);
|
|
|
+ updateArr = updateObj.updateGlj;
|
|
|
if(typeof updateObj.updateBasePrc !== 'undefined'){
|
|
|
- updateBasePrcArr.push(updateObj.updateBasePrc);
|
|
|
+ updateBasePrcArr = updateObj.updateBasePrc;
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
@@ -938,6 +1020,7 @@ let gljTypeTreeOprObj = {
|
|
|
that = gljComponentOprObj,
|
|
|
gljTypeId = treeNode.ID;
|
|
|
me.gljCurTypeId = treeNode.ID;
|
|
|
+ me.addGljObj = null;
|
|
|
//me.currentCache = me.getCache();
|
|
|
sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, 5);
|
|
|
that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|