|
@@ -39,12 +39,12 @@ let repositoryGljObj = {
|
|
|
currentCache: null,
|
|
|
parentNodeIds: {},
|
|
|
gljList: [],
|
|
|
- allowComponent: [202, 203, 204, 301, 4],//可带组成物类型:混凝土、砂浆、配合比、机械台班
|
|
|
- componentGljType: [201, 302, 303, 4],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
|
|
|
//materialType: ['钢材', '木材', '水泥', '钢筋', '标准砖'],//三材类型:钢材1、钢筋101、木材2、水泥3、标准砖4
|
|
|
materialType: {textArr: ['钢材', '钢筋', '木材', '水泥', '标准砖'], comboItems: [{text: '钢材', value: 1}, {text: '钢筋', value: 2},{text: '木材', value: 3},//三材类型:钢材1、钢筋101、木材2、水泥3、标准砖4
|
|
|
{text: '水泥', value: 4}, {text: '标准砖', value: 5}]},
|
|
|
materialTypeIdx: {'1': '钢材', '2': '钢筋', '3': '木材', '4': '水泥', '5': '标准砖'},
|
|
|
+ machineModel: {textArr: ['特', '大', '中', '小'], comboItems: [{text: '特', value: 1}, {text: '大', value: 2},{text: '中', value: 3}, {text: '小', value: 4}]},
|
|
|
+ machineModelIdx: {'1': '特', '2': '大', '3': '中', '4': '小'},
|
|
|
distTypeTree: null,//add
|
|
|
setting: {
|
|
|
owner: "glj",
|
|
@@ -58,6 +58,7 @@ let repositoryGljObj = {
|
|
|
{headerName:"调整系数",headerWidth:60,dataCode:"adjCoe", dataType: "Number", hAlign: "center", vAlign: "center"},
|
|
|
{headerName:"三材类别",headerWidth:90,dataCode:"materialType", dataType: "String", hAlign: "center", vAlign: "center"},
|
|
|
{headerName:"三材系数",headerWidth:60,dataCode:"materialCoe", dataType: "Number", hAlign: "center", vAlign: "center"},
|
|
|
+ {headerName:"机型",headerWidth:60,dataCode:"model", dataType: "Number", hAlign: "center", vAlign: "center"},
|
|
|
],
|
|
|
view:{
|
|
|
comboBox:[
|
|
@@ -67,6 +68,14 @@ let repositoryGljObj = {
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
+ existsGljType: function (gljType, v) {
|
|
|
+ for(let attr in gljType){
|
|
|
+ if(gljType[attr] == v){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
setUnitCombo: function (sheet, headers) {
|
|
|
let me = this;
|
|
|
sheet.suspendPaint();
|
|
@@ -97,15 +106,19 @@ let repositoryGljObj = {
|
|
|
children: [],
|
|
|
parent: null
|
|
|
}
|
|
|
- distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
|
|
|
- distTypeTree.distTypesArr.push(typeObj);
|
|
|
+ if(allowGljType.includes(typeData.ID)){
|
|
|
+ distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
|
|
|
+ distTypeTree.distTypesArr.push(typeObj);
|
|
|
+ }
|
|
|
});
|
|
|
gljDistType.forEach(function (typeData) {
|
|
|
- distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
|
|
|
- let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
|
|
|
- if(parent){
|
|
|
- distType.parent = parent;
|
|
|
- parent.children.push(distType);
|
|
|
+ if(allowGljType.includes(typeData.ID)){
|
|
|
+ distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
|
|
|
+ let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
|
|
|
+ if(parent){
|
|
|
+ distType.parent = parent;
|
|
|
+ parent.children.push(distType);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
distTypeTree.distTypesArr.forEach(function (distTypeObj) {
|
|
@@ -208,11 +221,13 @@ let repositoryGljObj = {
|
|
|
if (me.workBook) {
|
|
|
let cacheSection = data;
|
|
|
sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
|
|
|
- sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection, me.distTypeTree, me.materialTypeIdx);
|
|
|
- sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 5, me.workBook.getActiveSheet().getRowCount(), me.distTypeTree.comboDatas, false, 'text');
|
|
|
+ sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection, me.distTypeTree, me.materialTypeIdx, me.machineModelIdx);
|
|
|
+ sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 5, me.workBook.getActiveSheet().getRowCount(), me.distTypeTree.comboDatas, 10, 'text');
|
|
|
sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 7, me.workBook.getActiveSheet().getRowCount(), me.materialType.comboItems, false, 'text');
|
|
|
+ sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 9, me.workBook.getActiveSheet().getRowCount(), me.machineModel.comboItems, false, 'text');
|
|
|
cacheSection = null;
|
|
|
- me.initSel(0);
|
|
|
+ let selRow = me.workBook.getActiveSheet().getSelections()[0].row;
|
|
|
+ me.initSel(selRow);
|
|
|
}
|
|
|
},
|
|
|
bindEnterKey: function () {
|
|
@@ -286,10 +301,11 @@ let repositoryGljObj = {
|
|
|
for(let i = 0; i < gljComponent.length; i++){
|
|
|
let obj = {};
|
|
|
for(let j = 0; j < me.gljList.length; j++){
|
|
|
+ let specs = me.gljList[j].specs ? ' ' + me.gljList[j].specs : '';
|
|
|
if(gljComponent[i].ID == me.gljList[j].ID){
|
|
|
obj.ID = me.gljList[j].ID;
|
|
|
obj.code = me.gljList[j].code;
|
|
|
- obj.name = me.gljList[j].name;
|
|
|
+ obj.name = me.gljList[j].name + specs
|
|
|
obj.unit = me.gljList[j].unit;
|
|
|
obj.basePrice = me.gljList[j].basePrice;
|
|
|
obj.consumeAmt = gljComponent[i].consumeAmt;
|
|
@@ -354,6 +370,23 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ reSetGljBasePrc: function (gljs) {
|
|
|
+ let me = repositoryGljObj;
|
|
|
+ let cacheSection = me.currentCache;
|
|
|
+ let sheet = me.workBook.getSheet(0);
|
|
|
+ sheet.suspendPaint();
|
|
|
+ sheet.suspendEvent();
|
|
|
+ for(let i = 0; i < cacheSection.length; i++){
|
|
|
+ for(let glj of gljs){
|
|
|
+ if(glj.ID === cacheSection[i].ID){
|
|
|
+ sheet.setValue(i, 4, glj.basePrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sheet.resumePaint();
|
|
|
+ sheet.resumeEvent();
|
|
|
+
|
|
|
+ },
|
|
|
initSel: function (row) {
|
|
|
let me = repositoryGljObj, that = gljComponentOprObj;
|
|
|
sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
|
|
@@ -363,7 +396,7 @@ let repositoryGljObj = {
|
|
|
if(row < me.currentCache.length){
|
|
|
//标记当前工料机
|
|
|
me.currentGlj = me.currentCache[row];
|
|
|
- if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
|
|
|
+ if(allowComponent.includes(me.currentCache[row].gljType)){
|
|
|
//展示数据
|
|
|
if(me.currentGlj.component.length > 0){
|
|
|
me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
|
|
@@ -394,7 +427,7 @@ let repositoryGljObj = {
|
|
|
let thisDataCode = me.setting.header[args.col].dataCode,
|
|
|
lastDataCode = me.setting.header[me.lastCell.col].dataCode;
|
|
|
if(thisDataCode === 'unit'|| lastDataCode === 'unit' || thisDataCode === 'gljType' || lastDataCode === 'gljType'
|
|
|
- || thisDataCode === 'materialType' || lastDataCode === 'materialType'){
|
|
|
+ || thisDataCode === 'materialType' || lastDataCode === 'materialType' || thisDataCode === 'model' || lastDataCode === 'model'){
|
|
|
let rects = [];
|
|
|
rects.push(args.sheet.getCellRect(args.row, args.col));
|
|
|
if(me.lastCell){
|
|
@@ -417,7 +450,6 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
if(isHasData){
|
|
|
if(me.editingRowIdx !== me.cellRowIdx) {
|
|
|
- let isComple = true;
|
|
|
let focusToCol;
|
|
|
function getFocusToCol (me){
|
|
|
if(!me.addGljObj[me.setting.header[0].dataCode]){
|
|
@@ -474,10 +506,11 @@ let repositoryGljObj = {
|
|
|
if(args.row < me.currentCache.length){
|
|
|
let dataCode = me.setting.header[args.col].dataCode;
|
|
|
me.currentGlj = me.currentCache[args.row];
|
|
|
- if(dataCode === 'code' || (dataCode === 'basePrice' && me.allowComponent.indexOf(me.currentGlj.gljType) !== -1
|
|
|
+ if(dataCode === 'code' || (dataCode === 'basePrice' && allowComponent.includes(me.currentGlj.gljType)
|
|
|
&& me.currentGlj.component.length > 0)
|
|
|
|| (dataCode === 'adjCoe' && me.currentGlj.gljType !== 1 && me.currentGlj.gljType !== 303)
|
|
|
- || (dataCode === 'materialCoe' && !me.currentGlj.materialType)){
|
|
|
+ || (dataCode === 'materialCoe' && !me.currentGlj.materialType)
|
|
|
+ || (dataCode === 'model' && me.currentGlj.gljType !== 301)){
|
|
|
args.cancel = true;
|
|
|
}
|
|
|
else {
|
|
@@ -513,8 +546,13 @@ let repositoryGljObj = {
|
|
|
if((me.currentEditingGlj.gljType === 1 || me.currentEditingGlj.gljType === 303) && !(rObj.gljType === 1 || rObj.gljType === 303)){
|
|
|
rObj.adjCoe = null;
|
|
|
}
|
|
|
- if(me.componentGljType.indexOf(me.currentEditingGlj.gljType) !== -1 &&
|
|
|
- !(me.currentEditingGlj.gljType === 302 && rObj.gljType === 303) && !(me.currentEditingGlj.gljType === 303 && rObj.gljType === 302)){//修改了原本是组成物的工料机
|
|
|
+ //工料机类型不为机械台班时,清空机型
|
|
|
+ if(me.currentEditingGlj.gljType === 301 && rObj.gljType !== 301 && me.currentEditingGlj.model){
|
|
|
+ rObj.model = null;
|
|
|
+ }
|
|
|
+ if(componentType.includes(me.currentEditingGlj.gljType)&&
|
|
|
+ !(machineComponent.includes(me.currentEditingGlj.gljType) && machineComponent.includes(rObj.gljType)) &&
|
|
|
+ !(materialComponent.includes(me.currentEditingGlj.gljType) && materialComponent.includes(rObj.gljType))){//修改了原本是组成物的工料机
|
|
|
//寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
|
|
|
let updateGljs = me.getUpdateGljs(rObj, true);
|
|
|
if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
@@ -680,8 +718,8 @@ let repositoryGljObj = {
|
|
|
else {
|
|
|
if(dataCode === 'basePrice'){
|
|
|
//如果类型不为混凝土、砂浆、配合比、机械、主材且无组成物,才可删除单价 basePrice = 0
|
|
|
- if(me.allowComponent.indexOf(updateObj.gljType) === -1 ||
|
|
|
- (me.allowComponent.indexOf(updateObj.gljType) !== -1 && updateObj.component.length === 0)){
|
|
|
+ if(!allowComponent.includes(updateObj.gljType) ||
|
|
|
+ (allowComponent.includes(updateObj.gljType) && updateObj.component.length === 0)){
|
|
|
canUpdate = true;
|
|
|
updateObj[dataCode] = 0;
|
|
|
updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
|
|
@@ -775,8 +813,13 @@ let repositoryGljObj = {
|
|
|
else if((pasteObj.gljType === 1 || pasteObj.gljType === 303) && typeof pasteObj.adjCoe !== 'undefined' && !isNaN(pasteObj.adjCoe) && pasteObj.adjCoe % 1 === 0) {
|
|
|
tempObj.adjCoe = pasteObj.adjCoe;
|
|
|
}
|
|
|
- if(me.componentGljType.indexOf(tempObj.gljType) !== -1 &&
|
|
|
- !(tempObj.gljType === 302 && pasteObj.gljType === 303) && !(tempObj.gljType === 303 && pasteObj.gljType === 302)){//修改了原本是组成物的工料机
|
|
|
+ if(pasteObj.gljType !== 301 && tempObj.gljType === 301){
|
|
|
+ tempObj.model = null;
|
|
|
+ }
|
|
|
+ if(componentType.includes(tempObj.gljType) &&
|
|
|
+ //!(tempObj.gljType === 302 && pasteObj.gljType === 303) && !(tempObj.gljType === 303 && pasteObj.gljType === 302)){//修改了原本是组成物的工料机
|
|
|
+ !(machineComponent.includes(tempObj.gljType) && machineComponent.includes(pasteObj.gljType)) &&
|
|
|
+ !(materialComponent.includes(tempObj.gljType) && materialComponent.includes(pasteObj.gljType))){//修改了原本是组成物的工料机
|
|
|
//寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
|
|
|
let updateGljs = me.getUpdateGljs(tempObj, true);
|
|
|
if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
@@ -850,6 +893,29 @@ let repositoryGljObj = {
|
|
|
tempObj.materialCoe = pasteObj.materialCoe !== '' ? scMathUtil.roundTo(parseFloat(pasteObj.materialCoe), -5) : null;
|
|
|
}
|
|
|
}
|
|
|
+ if(typeof pasteObj.model !== 'undefined'){
|
|
|
+ if(!me.machineModel.textArr.includes(pasteObj.model)){
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ let existsModel = false;
|
|
|
+ if((typeof pasteObj.gljType !== 'undefined' && pasteObj.gljType === 301) ||
|
|
|
+ (tempObj.gljType && tempObj.gljType === 301)){
|
|
|
+ me.machineModel.comboItems.forEach(function (item) {
|
|
|
+ if(item.text === pasteObj.model){
|
|
|
+ tempObj.model = item.value;
|
|
|
+ existsModel = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(!existsModel){
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if(isValid){
|
|
|
rst.updateGlj.push(tempObj);
|
|
|
if(reCalBasePrc){
|
|
@@ -916,6 +982,16 @@ let repositoryGljObj = {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+ if(typeof pasteObj.model !== 'undefined' && pasteObj.model){
|
|
|
+ if(!me.machineModel.textArr.includes(pasteObj.model) || pasteObj.gljType !== 301){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ me.machineModel.comboItems.forEach(function (item) {
|
|
|
+ if(item.text === pasteObj.model){
|
|
|
+ pasteObj.model = item.value;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
|
|
|
if(!me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]){
|
|
|
pasteObj.gljClass = me.gljCurTypeId;
|
|
@@ -939,7 +1015,7 @@ let repositoryGljObj = {
|
|
|
for(let i = 0, len = info.cellRange.rowCount; i < len; i++){
|
|
|
let row = i + info.cellRange.row;
|
|
|
if(row < me.currentCache.length){
|
|
|
- if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1 && me.currentCache[row].component.length > 0){
|
|
|
+ if(allowComponent.includes(me.currentCache[row].gljType) && me.currentCache[row].component.length > 0){
|
|
|
rst = false;
|
|
|
}
|
|
|
}
|
|
@@ -996,7 +1072,7 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
//if(info.cellRange.colCount === me.setting.header.length){
|
|
|
- if(info.cellRange.colCount >= me.setting.header.length - 3 && info.cellRange.colCount <= me.setting.header.length){
|
|
|
+ if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length){
|
|
|
for(let i = updateCount ; i < items.length; i++){
|
|
|
if(me.isValidObj(items[i])){
|
|
|
items[i].component = [];
|
|
@@ -1011,7 +1087,7 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
else{
|
|
|
//if(info.cellRange.colCount === me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
|
|
|
- if(info.cellRange.colCount >= me.setting.header.length - 3 && info.cellRange.colCount <= me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
|
|
|
+ if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
|
|
|
for(let i = 0; i < items.length; i++){
|
|
|
if(me.isValidObj(items[i])){
|
|
|
items[i].component = [];
|
|
@@ -1040,6 +1116,9 @@ let repositoryGljObj = {
|
|
|
else if(dCode === 'materialType'){
|
|
|
info.sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][dCode] ? me.materialTypeIdx[me.currentCache[resumeArr[i]][dCode]]: '');
|
|
|
}
|
|
|
+ else if(dCode === 'model'){
|
|
|
+ info.sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][dCode] ? me.machineModelIdx[me.currentCache[resumeArr[i]][dCode]]: '');
|
|
|
+ }
|
|
|
else{
|
|
|
info.sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][dCode]);
|
|
|
}
|
|
@@ -1060,10 +1139,9 @@ let repositoryGljObj = {
|
|
|
me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
}
|
|
|
},
|
|
|
- updateRationBasePrcRq: function (basePrcArr) {
|
|
|
+ updateRationBasePrcRq: function (basePrcArr, workBook, callback) {
|
|
|
let me = this;
|
|
|
me.prevent = true;
|
|
|
- me.workBook.focus(false);
|
|
|
$.bootstrapLoading.start();
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
@@ -1074,8 +1152,16 @@ let repositoryGljObj = {
|
|
|
if(result.error){
|
|
|
alert("计算定额基价失败");
|
|
|
}
|
|
|
- me.workBook.focus(true);
|
|
|
+ if(workBook){
|
|
|
+ workBook.focus(true);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ me.workBook.focus(true);
|
|
|
+ }
|
|
|
me.prevent = false;
|
|
|
+ if(callback){
|
|
|
+ callback();
|
|
|
+ }
|
|
|
$.bootstrapLoading.end();
|
|
|
}
|
|
|
});
|