|
@@ -7,9 +7,10 @@ var pageOprObj = {
|
|
|
initPage : function(container, containerComponent) {
|
|
|
var me = this, gljLibId = getQueryString("gljLibId");//获取定额库参数
|
|
|
me.gljLibId = gljLibId;
|
|
|
- repositoryGljObj.getGljLib(gljLibId);
|
|
|
+ repositoryGljObj.getGljLib(gljLibId, function () {
|
|
|
repositoryGljObj.buildSheet(container);
|
|
|
gljComponentOprObj.buildSheet(containerComponent);
|
|
|
+ //获得定额库中引用此工料机库中的,所有被定额所套的工料机的ID
|
|
|
//repositoryGljObj.getRationGljIds(gljLibId);
|
|
|
repositoryGljObj.getGljDistType(function () {
|
|
|
repositoryGljObj.currentRepositoryId = parseInt(gljLibId);
|
|
@@ -18,7 +19,7 @@ var pageOprObj = {
|
|
|
});
|
|
|
sheetCommonObj.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
|
|
|
});
|
|
|
- // }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
repositoryGljObj = {
|
|
@@ -29,7 +30,7 @@ repositoryGljObj = {
|
|
|
currentCache: null,
|
|
|
parentNodeIds: {},
|
|
|
gljList: [],
|
|
|
- allowComponent: [202, 203, 204, 3],
|
|
|
+ allowComponent: [202, 203, 204, 3],//可带组成物类型:混凝土、砂浆、配合比、机械
|
|
|
distTypeTree: null,//add
|
|
|
setting: {
|
|
|
|
|
@@ -104,8 +105,8 @@ repositoryGljObj = {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- getGljLib: function (libId) {
|
|
|
- let me = this;
|
|
|
+ getGljLib: function (libId, callback) {
|
|
|
+ let me = repositoryGljObj;
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: 'api/getGljLib',
|
|
@@ -113,10 +114,14 @@ repositoryGljObj = {
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
if(!result.error){
|
|
|
- $(".navbar-text").append(
|
|
|
- "<a href='/stdGljRepository/main'>工料机库</a><i class='fa fa-angle-right fa-fw'></i>"+result.data[0].dispName
|
|
|
- );
|
|
|
- pageOprObj.gljLibName = result.data[0].dispName;
|
|
|
+ if(result.data.length > 0){
|
|
|
+ me.rationLibs = result.data[0].rationLibs;
|
|
|
+ $(".navbar-text").append(
|
|
|
+ "<a href='/stdGljRepository/main'>工料机库</a><i class='fa fa-angle-right fa-fw'></i>"+result.data[0].dispName
|
|
|
+ );
|
|
|
+ pageOprObj.gljLibName = result.data[0].dispName;
|
|
|
+ }
|
|
|
+ callback();
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -231,7 +236,8 @@ 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(i - 1, 4, glj.basePrice);
|
|
|
+ me.workBook.getSheet(0).setValue(i, 4, glj.basePrice);
|
|
|
+ console.log(i);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -247,12 +253,13 @@ repositoryGljObj = {
|
|
|
//that.workBook.getSheet(0).options.isProtected = true;
|
|
|
sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
|
|
|
me.workBook.focus(true);
|
|
|
- me.currentGlj = null;
|
|
|
me.currentComponent = [];
|
|
|
if(row < me.currentCache.length){
|
|
|
+ //标记当前工料机
|
|
|
+ me.currentGlj = me.currentCache[row];
|
|
|
+ console.log(`me.currentCache`);
|
|
|
+ console.log(me.currentCache);
|
|
|
if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
|
|
|
- //标记当前工料机
|
|
|
- me.currentGlj = me.currentCache[row];
|
|
|
that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
//that.workBook.getSheet(0).options.isProtected = false;
|
|
@@ -266,6 +273,9 @@ repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else{
|
|
|
+ me.currentGlj = null;
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
onEnterCell: function (sender, args) {
|
|
@@ -363,6 +373,8 @@ repositoryGljObj = {
|
|
|
updateArr = [], addArr = [], updateBasePrcArr = [];
|
|
|
me.editingRowIdx = args.row;
|
|
|
rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
|
|
|
+ console.log(`me.currentGlj`);
|
|
|
+ console.log(me.currentGlj);
|
|
|
if (me.currentEditingGlj["ID"]) {
|
|
|
rObj["ID"] = me.currentEditingGlj["ID"];
|
|
|
rObj.gljClass = me.currentEditingGlj.gljClass;
|
|
@@ -378,7 +390,8 @@ repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /* if(me.currentEditingGlj.basePrice !== rObj.basePrice){
|
|
|
+ //--------------------------------------
|
|
|
+ if(me.currentEditingGlj.basePrice !== rObj.basePrice){
|
|
|
//update basePrice of ration when editting basePrice of glj
|
|
|
let gljType = -1;
|
|
|
let gljTypeParent = me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj.gljType].parent;
|
|
@@ -391,15 +404,20 @@ repositoryGljObj = {
|
|
|
let gljBasePrcObj = {gljId: me.currentEditingGlj.ID, gljType: gljType, basePrice: rObj.basePrice};
|
|
|
if(gljBasePrcObj.gljType !== -1){
|
|
|
updateBasePrcArr.push(gljBasePrcObj);
|
|
|
- me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
+ if(me.rationLibs.length > 0){//重算定额单价
|
|
|
+ me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
+ }
|
|
|
}
|
|
|
- }*/
|
|
|
+ }
|
|
|
//update basePrice of ration when editting gljType of glj
|
|
|
- /* if(me.currentEditingGlj.gljType !== rObj.gljType){
|
|
|
+ if(me.currentEditingGlj.gljType !== rObj.gljType){
|
|
|
let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
|
|
|
updateBasePrcArr.push(gljTypeObj);
|
|
|
- me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
- }*/
|
|
|
+ if(me.rationLibs.length > 0){
|
|
|
+ me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //-----------------------------------------------------------
|
|
|
} else {
|
|
|
me.addGljObj = rObj;
|
|
|
let isCanSav = true;
|
|
@@ -409,16 +427,21 @@ repositoryGljObj = {
|
|
|
if(isCanSav){
|
|
|
me.addGljObj = null;
|
|
|
rObj.component = [];
|
|
|
+ //如果类型为混凝土、砂浆、配合比、机械时,添加时填写的单价清空
|
|
|
+ if(me.allowComponent.indexOf(rObj.gljType) !== -1){
|
|
|
+ rObj.basePrice = 0;
|
|
|
+ }
|
|
|
addArr.push(rObj);
|
|
|
}
|
|
|
}
|
|
|
- if(me.gljCurTypeId !== 1){
|
|
|
+ if(me.gljCurTypeId !== 732){
|
|
|
rObj.gljClass = me.gljCurTypeId;
|
|
|
}
|
|
|
if(updateArr.length >0 || addArr.length >0){
|
|
|
me.currentEditingGlj = null;
|
|
|
//me.workBook.getSheet(0).setValue(11, 5, "人工");
|
|
|
me.mixUpdateRequest(updateArr, addArr, []);
|
|
|
+ console.log(updateArr);
|
|
|
}
|
|
|
},
|
|
|
repositoryGljDelOpr: function () {
|
|
@@ -430,14 +453,17 @@ repositoryGljObj = {
|
|
|
refGljCodes = [], //已被引用的工料机
|
|
|
updateBasePrcArr = [],//删除基价单位后重新计算
|
|
|
sels = sheet.getSelections(),
|
|
|
+ canUpdate = false,
|
|
|
cacheSection = me.currentCache;
|
|
|
if(sels.length > 0 && cacheSection.length > 0){
|
|
|
for(let i = 0; i < sels.length; i++){
|
|
|
if(sels[i].colCount === me.setting.header.length){
|
|
|
for(let j = 0; j < sels[i].rowCount; j++){
|
|
|
if(sels[i].row + j < cacheSection.length){
|
|
|
- //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
|
|
|
removeArr.push(cacheSection[sels[i].row + j].ID);
|
|
|
+ //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
|
|
|
+ //删除后重新计算引用了此工料机的定额单价
|
|
|
+ updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -449,14 +475,21 @@ repositoryGljObj = {
|
|
|
let updateObj = cacheSection[sels[i].row + j];
|
|
|
for(let col = sels[i].col; col <= maxCol; col++){
|
|
|
if(me.setting.header[col].dataCode === 'basePrice'){
|
|
|
- updateObj[me.setting.header[col].dataCode] = 0;
|
|
|
- // updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
|
|
|
+ //如果类型不为混凝土、砂浆、配合比、机械,才可删除单价 basePrice = 0
|
|
|
+ if(me.allowComponent.indexOf(updateObj.gljType) === -1){
|
|
|
+ canUpdate = true;
|
|
|
+ updateObj[me.setting.header[col].dataCode] = 0;
|
|
|
+ updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
|
|
|
+ }
|
|
|
}
|
|
|
else{
|
|
|
+ canUpdate = true;
|
|
|
updateObj[me.setting.header[col].dataCode] = '';
|
|
|
}
|
|
|
}
|
|
|
- updateArr.push(updateObj);
|
|
|
+ if(canUpdate){
|
|
|
+ updateArr.push(updateObj);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -522,10 +555,16 @@ repositoryGljObj = {
|
|
|
});
|
|
|
}*/
|
|
|
if(removeArr.length > 0 || updateArr.length > 0){
|
|
|
- me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
- /* if(updateBasePrcArr.length > 0){
|
|
|
- me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
- }*/
|
|
|
+ //删除警告
|
|
|
+ $('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
|
|
|
+ $('#gljAlertBtn').click();
|
|
|
+ //确认
|
|
|
+ $('#aleConfBtn').click(function () {
|
|
|
+ me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
+ if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
+ me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -538,7 +577,7 @@ repositoryGljObj = {
|
|
|
let rst = {}, backUpObj = {},
|
|
|
me = repositoryGljObj,
|
|
|
tempObj = me.currentCache[rowIdx],
|
|
|
- //reCalBasePrc = false,
|
|
|
+ reCalBasePrc = false,
|
|
|
isValid = true;
|
|
|
//备份原始数据
|
|
|
for(let atr in tempObj){
|
|
@@ -575,7 +614,7 @@ repositoryGljObj = {
|
|
|
for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
|
|
|
if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
|
|
|
isExsit = true;
|
|
|
- // reCalBasePrc = true;
|
|
|
+ reCalBasePrc = true;
|
|
|
tempObj.gljType = me.distTypeTree.comboDatas[i].value;
|
|
|
tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
|
|
|
|
|
@@ -587,15 +626,15 @@ repositoryGljObj = {
|
|
|
pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) :
|
|
|
me.currentCache[rowIdx].basePrice;
|
|
|
if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
|
|
|
- // reCalBasePrc = true;
|
|
|
+ reCalBasePrc = true;
|
|
|
tempObj.basePrice = pasteObj.basePrice;
|
|
|
}
|
|
|
if(isValid){
|
|
|
rst.updateGlj = tempObj;
|
|
|
- /*if(reCalBasePrc){
|
|
|
+ if(reCalBasePrc){
|
|
|
//重新计算定额基价对象
|
|
|
rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
for(let attr in backUpObj){
|
|
@@ -650,7 +689,7 @@ repositoryGljObj = {
|
|
|
var updateArr = [], addArr = [];
|
|
|
var items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,
|
|
|
- maxRow = me.currentCache.length - 1, updateItems = [], addItems = [],
|
|
|
+ maxRow = me.currentCache.length - 1,
|
|
|
updateBasePrcArr = [] ,
|
|
|
updateCount, resumeArr = [];
|
|
|
if(endRow <= maxRow){
|
|
@@ -659,9 +698,9 @@ repositoryGljObj = {
|
|
|
let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
|
|
|
if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
|
|
|
updateArr.push(updateObj.updateGlj);
|
|
|
- /* if(typeof updateObj.updateBasePrc !== 'undefined'){
|
|
|
+ if(typeof updateObj.updateBasePrc !== 'undefined'){
|
|
|
updateBasePrcArr.push(updateObj.updateBasePrc);
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
else{
|
|
|
resumeArr.push(info.cellRange.row + i);
|
|
@@ -674,9 +713,9 @@ repositoryGljObj = {
|
|
|
let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
|
|
|
if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
|
|
|
updateArr.push(updateObj.updateGlj);
|
|
|
- /* if(typeof updateObj.updateBasePrc !== 'undefined'){
|
|
|
+ if(typeof updateObj.updateBasePrc !== 'undefined'){
|
|
|
updateBasePrcArr.push(updateObj.updateBasePrc);
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
else{
|
|
|
resumeArr.push(info.cellRange.row + i);
|
|
@@ -685,7 +724,11 @@ repositoryGljObj = {
|
|
|
if(info.cellRange.colCount === me.setting.header.length){
|
|
|
for(let i = updateCount ; i < items.length; i++){
|
|
|
if(me.isValidObj(items[i])){
|
|
|
- addItems.push(items[i]);
|
|
|
+ items[i].component = [];
|
|
|
+ //类型为混凝土、砂浆、配合比、机械时,基价只能组成物计算
|
|
|
+ if(me.allowComponent.indexOf(items[i].gljType) !== -1){
|
|
|
+ items[i].basePrice = 0;
|
|
|
+ }
|
|
|
addArr.push(items[i]);
|
|
|
}
|
|
|
else{
|
|
@@ -703,6 +746,10 @@ repositoryGljObj = {
|
|
|
if(info.cellRange.colCount === me.setting.header.length){
|
|
|
for(let i = 0; i < items.length; i++){
|
|
|
if(me.isValidObj(items[i])){
|
|
|
+ items[i].component = [];
|
|
|
+ if(me.allowComponent.indexOf(items[i].gljType) !== -1){
|
|
|
+ items[i].basePrice = 0;
|
|
|
+ }
|
|
|
addArr.push(items[i]);
|
|
|
}
|
|
|
else{
|
|
@@ -742,15 +789,15 @@ repositoryGljObj = {
|
|
|
if (updateArr.length > 0 || addArr.length > 0) {
|
|
|
me.mixUpdateRequest(updateArr, addArr, []);
|
|
|
}
|
|
|
- /* if(updateBasePrcArr.length > 0){
|
|
|
+ if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
- }*/
|
|
|
+ }
|
|
|
},
|
|
|
- /* updateRationBasePrcRq: function (basePrcArr) {
|
|
|
+ updateRationBasePrcRq: function (basePrcArr) {
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: 'api/updateRationBasePrc',
|
|
|
- data:{data: JSON.stringify({repId: pageOprObj.rationLibId, lastOpr: userAccount, basePrcArr: basePrcArr})},
|
|
|
+ data:{basePrcArr: JSON.stringify(basePrcArr)},
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
if(result.error){
|
|
@@ -758,7 +805,7 @@ repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- },*/
|
|
|
+ },
|
|
|
/* getRationGljIds: function (repId) {
|
|
|
let me = repositoryGljObj;
|
|
|
$.ajax({
|
|
@@ -843,7 +890,7 @@ repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (result && result.data.ops && result.data.ops.length > 0) {
|
|
|
+ if (result && result.data && result.data.ops && result.data.ops.length > 0) {
|
|
|
for (var i = 0; i < result.data.ops.length; i++) {
|
|
|
for (var j = 0; j < cacheSection.length; j++) {
|
|
|
if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
|