|
@@ -13,6 +13,12 @@ let pageOprObj = {
|
|
|
initPage : function(container, containerComponent, containerC) {
|
|
|
let me = this, gljLibId = getQueryString("gljLibId");//获取定额库参数
|
|
|
me.gljLibId = gljLibId;
|
|
|
+ //生成人材机表格列头
|
|
|
+ repositoryGljObj.setting.header = repositoryGljObj.initHeaders(priceProperties);
|
|
|
+ //生成列映射
|
|
|
+ sheetCommonObj.initColMapping(repositoryGljObj, repositoryGljObj.setting.header);
|
|
|
+ //生成单价列下标数组
|
|
|
+ repositoryGljObj.initPriceCols(priceProperties, repositoryGljObj.colMapping);
|
|
|
repositoryGljObj.getGljLib(gljLibId, function () {
|
|
|
repositoryGljObj.buildSheet(container);
|
|
|
gljComponentOprObj.buildSheet(containerComponent);
|
|
@@ -32,6 +38,7 @@ let pageOprObj = {
|
|
|
}
|
|
|
};
|
|
|
let repositoryGljObj = {
|
|
|
+ colMapping: null,
|
|
|
treeObj : null,
|
|
|
workBook: null,
|
|
|
gljCurTypeId: -1,
|
|
@@ -68,25 +75,159 @@ let repositoryGljObj = {
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
- existsGljType: function (gljType, v) {
|
|
|
- for(let attr in gljType){
|
|
|
- if(gljType[attr] == v){
|
|
|
+ //根据费用定额的单价属性获取人材机的单价属性
|
|
|
+ getPriceProperty: function (priceProperties) {
|
|
|
+ let priceProperty = {};
|
|
|
+ for(let priceProp of priceProperties){
|
|
|
+ priceProperty[priceProp.price.dataCode] = 0;
|
|
|
+ }
|
|
|
+ return priceProperty;
|
|
|
+ },
|
|
|
+ //根据单价字段获取消耗量字段
|
|
|
+ getConsumeAmtField: function (consumeAmtProperties, priceField) {
|
|
|
+ if(!consumeAmtProperties || consumeAmtProperties.length === 0){
|
|
|
+ return 'consumeAmt';
|
|
|
+ }
|
|
|
+ for(let consumeAmtProp of consumeAmtProperties){
|
|
|
+ if(consumeAmtProp.consumeAmt.refPrice === priceField){
|
|
|
+ return consumeAmtProp.consumeAmt.dataCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 'consumeAmt';
|
|
|
+ },
|
|
|
+ //初始单价相关的列(单价列、单价属性列)
|
|
|
+ initPriceCols: function (priceProperties, colMapping) {
|
|
|
+ let priceCols = [],
|
|
|
+ pricePropertyCols = [];
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ priceCols.push(colMapping.fieldToCol['basePrice']);
|
|
|
+ }
|
|
|
+ for(let priceProp of priceProperties){
|
|
|
+ pricePropertyCols.push(colMapping.fieldToCol[priceProp.price.dataCode]);
|
|
|
+ priceCols.push(colMapping.fieldToCol[priceProp.price.dataCode]);
|
|
|
+ }
|
|
|
+ this.priceCols = priceCols;
|
|
|
+ this.pricePropertyCols = pricePropertyCols;
|
|
|
+ },
|
|
|
+ getPriceFields: function () {
|
|
|
+ let rst = [];
|
|
|
+ for(let priceCol of this.priceCols){
|
|
|
+ rst.push(this.colMapping.colToField[priceCol]);
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ //获取更新定额价的人材机价格(人材机只有一个单价取basePrice, 人材机有多个单价,取第一个单价)
|
|
|
+ getRationGljPrice: function (glj) {
|
|
|
+ if(glj.priceProperty){
|
|
|
+ let keys = Object.keys(glj.priceProperty);
|
|
|
+ if(keys.length > 0){
|
|
|
+ return glj.priceProperty[keys[0]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return glj.basePrice;
|
|
|
+ },
|
|
|
+ //生成列头(多单价)
|
|
|
+ initHeaders: function (priceProperties) {
|
|
|
+ let headers = [
|
|
|
+ {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
|
|
|
+ {headerName:"名称",headerWidth:160,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
|
|
|
+ {headerName:"规格型号",headerWidth:120,dataCode:"specs", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
|
|
|
+ {headerName:"单位",headerWidth:60,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
|
|
|
+ {headerName:"类型",headerWidth:90,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},
|
|
|
+ ];
|
|
|
+ //生成单价列
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ headers.push({headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"});
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ for(let priceProp of priceProperties){
|
|
|
+ let colData = {
|
|
|
+ headerName: priceProp.price.dataName,
|
|
|
+ headerWidth: 100,
|
|
|
+ dataCode: priceProp.price.dataCode,
|
|
|
+ dataType: 'Number',
|
|
|
+ formatter: '0.00',
|
|
|
+ hAlign: 'right',
|
|
|
+ vAlign: 'center'
|
|
|
+ };
|
|
|
+ headers.push(colData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let tailHeaders = [
|
|
|
+ {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"}
|
|
|
+ ];
|
|
|
+ headers = headers.concat(tailHeaders);
|
|
|
+ return headers;
|
|
|
+ },
|
|
|
+ //工料机单价赋初始值(没有单价属性,则单价字段为basePrice,否则单价字段为单价属性对象中的属性)
|
|
|
+ initPrice: function (glj) {
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ glj.basePrice = glj.basePrice && !isNaN(parseFloat(glj.basePrice)) ? scMathUtil.roundTo(parseFloat(glj.basePrice), -2) : 0;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if(!glj.priceProperty){
|
|
|
+ glj.priceProperty = {};
|
|
|
+ }
|
|
|
+ for(let priceProp of priceProperties){
|
|
|
+ let gljPrice = glj['priceProperty'][priceProp.price.dataCode];
|
|
|
+ gljPrice = gljPrice && !isNaN(parseFloat(gljPrice)) ? scMathUtil.roundTo(parseFloat(gljPrice), -2) : 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //人材机单价是否变化
|
|
|
+ isGljPriceChange: function (glj, newPrice) {
|
|
|
+ //多单价,与人材机单价属性比较
|
|
|
+ if(typeof newPrice === 'object'){
|
|
|
+ return !_.isEqual(glj.priceProperty, newPrice);
|
|
|
+ }
|
|
|
+ return !_.isEqual(glj.basePrice, newPrice);
|
|
|
+ },
|
|
|
+ //粘贴数据含有单价
|
|
|
+ pasteIncludesPrice: function (pasteObj) {
|
|
|
+ let me = repositoryGljObj;
|
|
|
+ for(let priceCol of me.priceCols){
|
|
|
+ let priceField = me.colMapping.colToField[priceCol];
|
|
|
+ if(typeof pasteObj[priceField] !== 'undefined'){
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
+ //获取人材机价格
|
|
|
+ getPrice: function (glj, col) {
|
|
|
+ let me = repositoryGljObj;
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ return glj.basePrice;
|
|
|
+ }
|
|
|
+ return glj.priceProperty[me.colMapping.colToField[col]];
|
|
|
+ },
|
|
|
+ //工料机价格是否相同
|
|
|
+ priceIsEqual: function (gljA, gljB) {
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ return gljA.basePrice === gljB.basePrice;
|
|
|
+ }
|
|
|
+ return _.isEqual(gljA.priceProperty, gljB.priceProperty);
|
|
|
+ },
|
|
|
+ setGljPrice: function (glj, newPrice, col) {
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ glj.basePrice = newPrice;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ glj.priceProperty[this.colMapping.colToField[col]] = newPrice;
|
|
|
+ }
|
|
|
+ },
|
|
|
setUnitCombo: function (sheet, headers) {
|
|
|
let me = this;
|
|
|
sheet.suspendPaint();
|
|
|
sheet.suspendEvent();
|
|
|
let combo = sheetCommonObj.getDynamicCombo();
|
|
|
combo.items(rationAndGljUnits).itemHeight(10).editable(true);
|
|
|
- for(let i = 0; i < headers.length; i++){
|
|
|
- if(headers[i].dataCode === 'unit'){
|
|
|
- sheet.getRange(-1, i, -1, 1).cellType(combo);
|
|
|
- break;
|
|
|
- }
|
|
|
+ let unitCol = me.colMapping.fieldToCol['unit'];
|
|
|
+ if(unitCol){
|
|
|
+ sheet.getRange(-1, unitCol, -1, 1).cellType(combo);
|
|
|
}
|
|
|
sheet.resumePaint();
|
|
|
sheet.resumeEvent();
|
|
@@ -105,25 +246,23 @@ let repositoryGljObj = {
|
|
|
data: typeData,
|
|
|
children: [],
|
|
|
parent: null
|
|
|
- }
|
|
|
- if(allowGljType.includes(typeData.ID)){
|
|
|
+ };
|
|
|
distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
|
|
|
distTypeTree.distTypesArr.push(typeObj);
|
|
|
- }
|
|
|
});
|
|
|
gljDistType.forEach(function (typeData) {
|
|
|
- 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) {
|
|
|
- if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
|
|
|
+ if(allowGljType.includes(distTypeObj.data.ID)){
|
|
|
+ //if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
|
|
|
distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
|
|
|
+ // }
|
|
|
}
|
|
|
});
|
|
|
return distTypeTree;
|
|
@@ -221,10 +360,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, 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');
|
|
|
+ sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, cacheSection, me.distTypeTree, me.materialTypeIdx, me.machineModelIdx);
|
|
|
+ let gljTypeCol = me.colMapping.fieldToCol['gljType'],
|
|
|
+ materialTypeCol = me.colMapping.fieldToCol['materialType'],
|
|
|
+ modelCol = me.colMapping.fieldToCol['model'];
|
|
|
+ sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, gljTypeCol, me.workBook.getActiveSheet().getRowCount(), me.distTypeTree.comboDatas, 10, 'text');
|
|
|
+ sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, materialTypeCol, me.workBook.getActiveSheet().getRowCount(), me.materialType.comboItems, false, 'text');
|
|
|
+ sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, modelCol, me.workBook.getActiveSheet().getRowCount(), me.machineModel.comboItems, false, 'text');
|
|
|
cacheSection = null;
|
|
|
let selRow = me.workBook.getActiveSheet().getSelections()[0].row;
|
|
|
me.initSel(selRow);
|
|
@@ -239,7 +381,8 @@ let repositoryGljObj = {
|
|
|
if(sheet.isEditing()){
|
|
|
sheet.endEdit();
|
|
|
}
|
|
|
- let code = sheet.getValue(orgRow, 0);
|
|
|
+ let codeCol = me.colMapping.fieldToCol['code'];
|
|
|
+ let code = sheet.getValue(orgRow, codeCol);
|
|
|
let newRow, newCol;
|
|
|
if(!me.currentCache[orgRow] && code !== undefined && code !== null && orgCol !== me.setting.header.length - 1){
|
|
|
newRow = orgRow;
|
|
@@ -270,6 +413,9 @@ let repositoryGljObj = {
|
|
|
me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
+ if(priceProperties && priceProperties.length > 0){
|
|
|
+ me.workBook.getSheet(0).frozenColumnCount(5);
|
|
|
+ }
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
|
|
@@ -305,10 +451,12 @@ let repositoryGljObj = {
|
|
|
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 + specs
|
|
|
+ obj.name = me.gljList[j].name + specs;
|
|
|
obj.unit = me.gljList[j].unit;
|
|
|
obj.basePrice = me.gljList[j].basePrice;
|
|
|
+ obj.priceProperty = me.gljList[j].priceProperty ? me.gljList[j].priceProperty : {};
|
|
|
obj.consumeAmt = gljComponent[i].consumeAmt;
|
|
|
+ obj.consumeAmtProperty = gljComponent[i].consumeAmtProperty ? gljComponent[i].consumeAmtProperty : {};
|
|
|
rst.push(obj);
|
|
|
}
|
|
|
}
|
|
@@ -330,6 +478,7 @@ let repositoryGljObj = {
|
|
|
for(let i = 0; i < me.gljList.length; i++){
|
|
|
if(me.gljList[i].ID === rObj.ID){
|
|
|
me.gljList[i].basePrice = rObj.basePrice;
|
|
|
+ me.gljList[i].priceProperty = rObj.priceProperty ? rObj.priceProperty : {};
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -349,11 +498,17 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
if(isChange){//引用了此组成物
|
|
|
- let gljBasePrc = that.reCalGljBasePrc(me.getCurrentComponent(thisComponent));
|
|
|
+ /* 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]);*/
|
|
|
+ /* let gljBasePrc = that.reCalGljBasePrc(me.getCurrentComponent(thisComponent));
|
|
|
+ if(me.isGljPriceChange(me.gljList[i], gljBasePrc)){
|
|
|
+ me.setGljPrice(me.gljList[i], gljBasePrc);
|
|
|
+ rst.updateBasePrcArr.push({gljId: me.gljList[i].ID, gljType: me.gljList[i].gljType, basePrice: me.getRationGljPrice(me.gljList[i])});
|
|
|
+ }*/
|
|
|
rst.updateArr.push(me.gljList[i]);
|
|
|
}
|
|
|
}
|
|
@@ -362,24 +517,49 @@ let repositoryGljObj = {
|
|
|
reshowGljBasePrc: function (glj) {
|
|
|
let me = repositoryGljObj;
|
|
|
let cacheSection = me.currentCache;
|
|
|
+ let sheet = me.workBook.getActiveSheet();
|
|
|
+ let row = _.findIndex(cacheSection, {ID: glj.ID});
|
|
|
+ sheet.suspendEvent();
|
|
|
+ sheet.suspendPaint();
|
|
|
+ for(let priceCol of me.priceCols){
|
|
|
+ sheet.setValue(row, priceCol, glj[me.colMapping.colToField[priceCol]]);
|
|
|
+ }
|
|
|
+ sheet.resumeEvent();
|
|
|
+ sheet.resumePaint();
|
|
|
+ },
|
|
|
+/* reshowGljBasePrc: function (glj) {
|
|
|
+ let me = repositoryGljObj;
|
|
|
+ let cacheSection = me.currentCache;
|
|
|
+ let basePriceCol = me.colMapping.fieldToCol['basePrice'];
|
|
|
+ let sheet = me.workBook.getActiveSheet();
|
|
|
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);
|
|
|
+ sheet.suspendEvent();
|
|
|
+ sheet.suspendPaint();
|
|
|
+ for(let priceCol of me.priceCols){
|
|
|
+ sheet.setValue(i, priceCol, glj.basePrice);
|
|
|
+ }
|
|
|
+ sheet.resumeEvent();
|
|
|
+ sheet.resumePaint();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
+ },*/
|
|
|
reSetGljBasePrc: function (gljs) {
|
|
|
let me = repositoryGljObj;
|
|
|
let cacheSection = me.currentCache;
|
|
|
let sheet = me.workBook.getSheet(0);
|
|
|
+ let basePriceCol = me.colMapping.fieldToCol['basePrice'];
|
|
|
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);
|
|
|
+ for(let priceCol of me.priceCols){
|
|
|
+ sheet.setValue(i, priceCol, glj[me.colMapping.colToField[priceCol]]);
|
|
|
+ }
|
|
|
+ //sheet.setValue(i, basePriceCol, glj.basePrice);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -401,7 +581,8 @@ let repositoryGljObj = {
|
|
|
if(me.currentGlj.component.length > 0){
|
|
|
me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
|
|
|
if(me.currentComponent.length > 0){
|
|
|
- sheetsOprObj.showData(that.workBook.getSheet(0), that.setting, me.currentComponent);
|
|
|
+ console.log(me.currentComponent);
|
|
|
+ sheetsOprObj.showData(that, that.workBook.getSheet(0), that.setting, me.currentComponent);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -452,17 +633,17 @@ let repositoryGljObj = {
|
|
|
if(me.editingRowIdx !== me.cellRowIdx) {
|
|
|
let focusToCol;
|
|
|
function getFocusToCol (me){
|
|
|
- if(!me.addGljObj[me.setting.header[0].dataCode]){
|
|
|
+ if(!me.addGljObj.code){
|
|
|
$('#alertGljTxt').text('编号不能为空,继续增加人材机?');
|
|
|
- return 0;
|
|
|
+ return me.colMapping.fieldToCol['code'];
|
|
|
}
|
|
|
- else if(!me.addGljObj[me.setting.header[1].dataCode]){
|
|
|
+ else if(!me.addGljObj.name){
|
|
|
$('#alertGljTxt').text('名称不能为空,继续增加人材机?');
|
|
|
- return 1;
|
|
|
+ return me.colMapping.fieldToCol['name'];
|
|
|
}
|
|
|
- else if(!me.addGljObj[me.setting.header[5].dataCode]){
|
|
|
+ else if(!me.addGljObj.gljType){
|
|
|
$('#alertGljTxt').text('类型不能为空,继续增加人材机?');
|
|
|
- return 5;
|
|
|
+ return me.colMapping.fieldToCol['gljType'];
|
|
|
}
|
|
|
else {
|
|
|
return -1;
|
|
@@ -482,6 +663,8 @@ let repositoryGljObj = {
|
|
|
});
|
|
|
$('#aleCanceBtn').click(function () {
|
|
|
me.addGljObj = null;
|
|
|
+ args.sheet.suspendEvent();
|
|
|
+ args.sheet.suspendPaint();
|
|
|
for(let col=0; col<me.setting.header.length; col++){
|
|
|
if(col === 0){
|
|
|
me.workBook.getSheet(0).getCell(me.editingRowIdx, 0).formatter("@");
|
|
@@ -490,6 +673,8 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
|
|
|
me.workBook.focus(true);
|
|
|
+ args.sheet.resumeEvent();
|
|
|
+ args.sheet.resumePaint();
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -497,18 +682,17 @@ let repositoryGljObj = {
|
|
|
},
|
|
|
onCellEditStart: function(sender, args) {
|
|
|
let me = repositoryGljObj;
|
|
|
- let rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
|
|
|
+ me.orgCode = me.workBook.getSheet(0).getValue(args.row, me.colMapping.fieldToCol['code']);
|
|
|
+ let rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me);
|
|
|
if(me.prevent){
|
|
|
args.cancel = true;
|
|
|
return;
|
|
|
}
|
|
|
me.currentEditingGlj = rObj;
|
|
|
- me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
|
|
|
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' && allowComponent.includes(me.currentGlj.gljType)
|
|
|
- && me.currentGlj.component.length > 0)
|
|
|
+ if(dataCode === 'code'
|
|
|
|| (dataCode === 'adjCoe' && me.currentGlj.gljType !== 1 && me.currentGlj.gljType !== 303)
|
|
|
|| (dataCode === 'materialCoe' && !me.currentGlj.materialType)
|
|
|
|| (dataCode === 'model' && me.currentGlj.gljType !== 301)){
|
|
@@ -517,27 +701,38 @@ let repositoryGljObj = {
|
|
|
else {
|
|
|
rObj.ID = me.currentGlj.ID;
|
|
|
rObj.gljClass = me.currentGlj.gljClass;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
me.currentGlj = null;
|
|
|
}
|
|
|
},
|
|
|
+ dataChanged: function (objA, objB, col) {
|
|
|
+ let me = repositoryGljObj;
|
|
|
+ if(me.priceCols.includes(col)){
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ return objA.basePrice !== objB.basePrice;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return objA.priceProperty[me.colMapping.colToField[col]] !== objB.priceProperty[me.colMapping.colToField[col]]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return objA[me.colMapping.colToField[col]] !== objB[[me.colMapping.colToField[col]]];
|
|
|
+ },
|
|
|
onCellEditEnd: function(sender, args) {
|
|
|
- console.log(args);
|
|
|
let me = repositoryGljObj, that = gljComponentOprObj,
|
|
|
rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
|
|
|
updateArr = [], addArr = [], updateBasePrcArr = [];
|
|
|
me.editingRowIdx = args.row;
|
|
|
- rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
|
|
|
+ //rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
|
|
|
+ me.initPrice(rObj);
|
|
|
//更新
|
|
|
if (me.currentEditingGlj["ID"] && me.currentGlj) {
|
|
|
rObj["ID"] = me.currentEditingGlj["ID"];
|
|
|
rObj.gljClass = me.currentEditingGlj.gljClass;
|
|
|
- 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(me.dataChanged(me.currentEditingGlj, rObj, args.col)){
|
|
|
+ if(rObj.code && rObj.name && rObj.gljType &&
|
|
|
+ rObj.code.toString().trim().length !== 0 && rObj.name.toString().trim().length !== 0 && rObj.gljType.toString().trim().length !== 0){
|
|
|
/* if(rObj.gljType !== me.currentEditingGlj.gljType){//修改了工料机类型
|
|
|
if(me.currentGlj){
|
|
|
me.currentGlj.component = [];
|
|
@@ -608,11 +803,12 @@ let repositoryGljObj = {
|
|
|
rObj.component = me.currentGlj.component;
|
|
|
updateArr.push(rObj);
|
|
|
me.mixUpdateRequest(updateArr, [], []);
|
|
|
- let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
|
|
|
+ //let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
|
|
|
+ /* let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: me.getRationGljPrice(rObj)};
|
|
|
updateBasePrcArr.push(gljTypeObj);
|
|
|
if(me.rationLibs.length > 0){
|
|
|
me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
- }
|
|
|
+ }*/
|
|
|
});
|
|
|
$('.typeClose').unbind('click');
|
|
|
$('.typeClose').bind('click', function () {
|
|
@@ -636,7 +832,7 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
rObj.materialCoe = scMathUtil.roundTo(parseFloat(rObj.materialCoe), -5);
|
|
|
}
|
|
|
- else if(rObj.basePrice !== me.currentEditingGlj.basePrice){//修改了单价,可修改单价的必为可成为组成物的
|
|
|
+ /*else if(rObj.basePrice !== me.currentEditingGlj.basePrice){//修改了单价,可修改单价的必为可成为组成物的
|
|
|
//寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
|
|
|
if(isNaN(parseFloat(rObj.basePrice))){
|
|
|
alert('单价只能输入数值!');
|
|
@@ -653,6 +849,26 @@ let repositoryGljObj = {
|
|
|
updateArr.push(updateGljs.updateBasePrcArr[i]);
|
|
|
}
|
|
|
}
|
|
|
+ }*/
|
|
|
+ else if(!me.priceIsEqual(rObj, me.currentEditingGlj)){//修改了单价,可修改单价的必为可成为组成物的
|
|
|
+ let rObjPrice = me.getPrice(rObj, args.col),
|
|
|
+ editingGljPrice = me.getPrice(me.currentEditingGlj, args.col);
|
|
|
+ //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
|
|
|
+ if(isNaN(parseFloat(rObjPrice))){
|
|
|
+ alert('单价只能输入数值!');
|
|
|
+ args.sheet.setValue(args.row, args.col, editingGljPrice ? editingGljPrice : 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ me.setGljPrice(rObj, scMathUtil.roundTo(parseFloat(rObjPrice), -2), args.col);
|
|
|
+ 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.component = me.currentGlj.component;
|
|
|
updateArr.push(rObj);
|
|
@@ -667,7 +883,7 @@ let 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;
|
|
@@ -684,6 +900,25 @@ let repositoryGljObj = {
|
|
|
me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
}
|
|
|
}
|
|
|
+ }*/
|
|
|
+ if(!me.priceIsEqual(rObj, me.currentEditingGlj)){
|
|
|
+ console.log('df');
|
|
|
+ //update basePrice of ration when editting basePrice of glj
|
|
|
+ let gljType = -1;
|
|
|
+ let gljTypeParent = me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj.gljType].parent;
|
|
|
+ if(gljTypeParent && gljTypeParent.data.ID <=3){
|
|
|
+ gljType = gljTypeParent.data.ID;
|
|
|
+ }
|
|
|
+ if(!gljTypeParent && me.currentEditingGlj.gljType <= 3){
|
|
|
+ gljType = me.currentEditingGlj.gljType;
|
|
|
+ }
|
|
|
+ let gljBasePrcObj = {gljId: me.currentEditingGlj.ID, gljType: gljType, basePrice: me.getRationGljPrice(rObj)};
|
|
|
+ if(gljBasePrcObj.gljType !== -1){
|
|
|
+ updateBasePrcArr.push(gljBasePrcObj);
|
|
|
+ if(me.rationLibs.length > 0){//重算定额单价
|
|
|
+ me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//update basePrice of ration when editting gljType of glj
|
|
|
/* if(me.currentEditingGlj.gljType !== rObj.gljType){
|
|
@@ -700,17 +935,14 @@ let repositoryGljObj = {
|
|
|
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]){
|
|
|
+ if(!rObj.code || !rObj.name || !rObj.gljType){
|
|
|
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') ? scMathUtil.roundTo(parseFloat(rObj.basePrice), -2) : 0;
|
|
|
+ //rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? scMathUtil.roundTo(parseFloat(rObj.basePrice), -2) : 0;
|
|
|
+ me.initPrice(rObj);
|
|
|
addArr.push(rObj);
|
|
|
}
|
|
|
}
|
|
@@ -729,29 +961,21 @@ let repositoryGljObj = {
|
|
|
me.workBook.commandManager().register('repositoryGljDel', function () {
|
|
|
let sheet = me.workBook.getSheet(0),
|
|
|
updateArr = [], removeArr = [],
|
|
|
+ removeIDs = [],
|
|
|
removeNames = [],
|
|
|
updateBasePrcArr = [],//删除基价单位后重新计算
|
|
|
sels = sheet.getSelections(),
|
|
|
canUpdate = false,
|
|
|
- cacheSection = me.currentCache;
|
|
|
+ cacheSection = me.currentCache,
|
|
|
+ updateBackups = [];
|
|
|
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){
|
|
|
- //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
|
|
|
- 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]);
|
|
|
- }
|
|
|
- }
|
|
|
- removeArr.push(cacheSection[sels[i].row + j].ID);
|
|
|
+ removeArr.push(cacheSection[sels[i].row + j]);
|
|
|
+ removeIDs.push(cacheSection[sels[i].row + j].ID);
|
|
|
removeNames.push(cacheSection[sels[i].row + j].name);
|
|
|
- //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});
|
|
|
}
|
|
@@ -771,62 +995,58 @@ let repositoryGljObj = {
|
|
|
return false;
|
|
|
}
|
|
|
else {
|
|
|
- if(dataCode === 'basePrice'){
|
|
|
- //如果类型不为混凝土、砂浆、配合比、机械、主材且无组成物,才可删除单价 basePrice = 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});
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- if(dataCode === 'materialType'){
|
|
|
- updateObj['materialCoe'] = null;
|
|
|
- }
|
|
|
- canUpdate = true;
|
|
|
- updateObj[dataCode] = '';
|
|
|
- }
|
|
|
+ canUpdate = true;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
- if(canUpdate){
|
|
|
- updateArr.push(updateObj);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /* if(removeArr.length > 0 || updateArr.length > 0){
|
|
|
- //删除警告
|
|
|
- let upAlertText = removeArr.length > 0 ? '可能已有定额引用了当前人材机,导致定额查找不到此人材机。确定要删除吗?' : '确认删除选中字段?';
|
|
|
- $('#alertGljTxt').text(upAlertText);
|
|
|
- $('#gljAlert').modal('show');
|
|
|
- //确认
|
|
|
- $('#aleConfBtn').bind('click', function () {
|
|
|
- me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
- if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
- me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
- }
|
|
|
- $('#aleConfBtn').unbind('click');
|
|
|
- });
|
|
|
- }*/
|
|
|
- if(updateArr.length > 0){
|
|
|
+ if(canUpdate){
|
|
|
//删除警告
|
|
|
let upAlertText = '确认删除选中字段?';
|
|
|
$('#alertGljTxt').text(upAlertText);
|
|
|
$('#gljAlert').modal('show');
|
|
|
+ $('#aleConfBtn').unbind('click');
|
|
|
//确认
|
|
|
$('#aleConfBtn').bind('click', function () {
|
|
|
+ for(let i = 0; i < sels.length; i++) {
|
|
|
+ let maxCol = sels[i].col + sels[i].colCount - 1;
|
|
|
+ for (let j = 0; j < sels[i].rowCount; j++) {
|
|
|
+ if (sels[i].row + j < cacheSection.length) {
|
|
|
+ let updateObj = cacheSection[sels[i].row + j];
|
|
|
+ for (let col = sels[i].col; col <= maxCol; col++) {
|
|
|
+ let dataCode = me.setting.header[col].dataCode;
|
|
|
+ if (me.priceCols.includes(col)) {
|
|
|
+ me.setGljPrice(updateObj, 0, col);
|
|
|
+ updateBasePrcArr.push({
|
|
|
+ gljId: updateObj.ID,
|
|
|
+ gljType: updateObj.gljType,
|
|
|
+ basePrice: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (dataCode === 'materialType') {
|
|
|
+ updateObj['materialCoe'] = null;
|
|
|
+ }
|
|
|
+ updateObj[dataCode] = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateArr.push(updateObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
me.mixUpdateRequest(updateArr, [], []);
|
|
|
if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
}
|
|
|
- $('#aleConfBtn').unbind('click');
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
if(removeArr.length > 0){
|
|
|
$.bootstrapLoading.start();
|
|
|
- CommonAjax.post('/stdGljRepository/api/isUsed', {gljIds: removeArr}, function (rstData) {
|
|
|
+ CommonAjax.post('/stdGljRepository/api/isUsed', {gljIds: removeIDs}, function (rstData) {
|
|
|
$.bootstrapLoading.end();
|
|
|
//存在被引用的人材机(标准/补充定额库)
|
|
|
if(rstData.isUsed){
|
|
@@ -840,11 +1060,21 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
else {
|
|
|
$('#gljAlert').find('.modal-body h5').text(`确定要删除人材机 “${removeNames.join(',')}” 吗? `);
|
|
|
- $('#gljAlert').modal('show');
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#gljAlert').modal('show');
|
|
|
+ }, 200);
|
|
|
//确认
|
|
|
$('#aleConfBtn').unbind('click');
|
|
|
$('#aleConfBtn').bind('click', function () {
|
|
|
- me.mixUpdateRequest([], [], removeArr);
|
|
|
+ for(let removeD of removeArr){
|
|
|
+ let updateGljs = me.getUpdateGljs(removeD, true);
|
|
|
+ if(updateGljs.updateArr.length > 0){
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
+ updateArr.push(updateGljs.updateArr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.mixUpdateRequest(updateArr, [], removeIDs);
|
|
|
if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
me.workBook.focus(true);
|
|
@@ -912,7 +1142,6 @@ let repositoryGljObj = {
|
|
|
if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
|
|
|
pasteObj.gljType = me.distTypeTree.comboDatas[i].value;
|
|
|
isExsit = true;
|
|
|
- reCalBasePrc = true;
|
|
|
//调整系数
|
|
|
if(pasteObj.gljType !== 1 && pasteObj.gljType !== 303){
|
|
|
tempObj.adjCoe = null;
|
|
@@ -959,7 +1188,44 @@ let repositoryGljObj = {
|
|
|
isValid = false;
|
|
|
}
|
|
|
}
|
|
|
- if(typeof pasteObj.basePrice !== 'undefined'){
|
|
|
+ //单价相关
|
|
|
+ if(me.pasteIncludesPrice(pasteObj)){
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ pasteObj.basePrice = pasteObj.basePrice && !isNaN(parseFloat(pasteObj.basePrice)) ?
|
|
|
+ scMathUtil.roundTo(parseFloat(pasteObj.basePrice), -2) : me.currentCache[rowIdx].basePrice;
|
|
|
+ if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
|
|
|
+ reCalBasePrc = true;
|
|
|
+ tempObj.basePrice = pasteObj.basePrice;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //多单价粘贴
|
|
|
+ let pastePriceProperty = {};
|
|
|
+ let priceFields = me.getPriceFields();
|
|
|
+ for(let priceField of priceFields){
|
|
|
+ if(typeof pasteObj[priceField] !== 'undefined' && pasteObj[priceField] && !isNaN(parseFloat(pasteObj[priceField]))){
|
|
|
+ pastePriceProperty[priceField] = scMathUtil.roundTo(parseFloat(pasteObj[priceField]), -2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!me.priceIsEqual(tempObj, pasteObj)){
|
|
|
+ reCalBasePrc = true;
|
|
|
+ //更新人材机单价
|
|
|
+ for(let priceField in pastePriceProperty){
|
|
|
+ tempObj.priceProperty[priceField] = pastePriceProperty[priceField];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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(typeof pasteObj.basePrice !== 'undefined'){
|
|
|
pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? scMathUtil.roundTo(parseFloat(pasteObj.basePrice), -2) :
|
|
|
me.currentCache[rowIdx].basePrice;
|
|
|
if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
|
|
@@ -975,7 +1241,7 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
if(typeof pasteObj.materialType !== 'undefined'){
|
|
|
if(!me.materialType.textArr.includes(pasteObj.materialType)){
|
|
|
isValid = false;
|
|
@@ -1027,8 +1293,8 @@ let repositoryGljObj = {
|
|
|
rst.updateGlj.push(tempObj);
|
|
|
if(reCalBasePrc){
|
|
|
//重新计算定额基价对象
|
|
|
- //rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
|
|
|
- let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
|
|
|
+ //let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
|
|
|
+ let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: me.getRationGljPrice(tempObj)};
|
|
|
rst.updateBasePrcArr.push(newReObj);
|
|
|
}
|
|
|
}
|
|
@@ -1099,7 +1365,24 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
|
|
|
+ if(!priceProperties || priceProperties.length === 0){
|
|
|
+ pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ let pastePriceProperty = {};
|
|
|
+ let priceFields = me.getPriceFields();
|
|
|
+ for(let priceField of priceFields){
|
|
|
+ if(typeof pasteObj[priceField] !== 'undefined' && pasteObj[priceField] && !isNaN(parseFloat(pasteObj[priceField]))){
|
|
|
+ pastePriceProperty[priceField] = scMathUtil.roundTo(parseFloat(pasteObj[priceField]), -2);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ pastePriceProperty[priceField] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pasteObj.priceProperty = pastePriceProperty;
|
|
|
+ }
|
|
|
+ //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;
|
|
|
}
|
|
@@ -1111,6 +1394,7 @@ let repositoryGljObj = {
|
|
|
if(me.gljCurTypeId < 0){
|
|
|
return false;
|
|
|
}
|
|
|
+ //粘贴的最大列下标不超过总列数
|
|
|
if(info.cellRange.col + info.cellRange.colCount - 1 > me.setting.header.length - 1){
|
|
|
return false;
|
|
|
}
|
|
@@ -1118,19 +1402,6 @@ let repositoryGljObj = {
|
|
|
if(info.cellRange.col === 0){
|
|
|
return false;
|
|
|
}
|
|
|
- else if(info.cellRange.col <= 4 && info.cellRange.col + info.cellRange.colCount - 1 >= 4){
|
|
|
- for(let i = 0, len = info.cellRange.rowCount; i < len; i++){
|
|
|
- let row = i + info.cellRange.row;
|
|
|
- if(row < me.currentCache.length){
|
|
|
- if(allowComponent.includes(me.currentCache[row].gljType) && me.currentCache[row].component.length > 0){
|
|
|
- rst = false;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
@@ -1151,7 +1422,7 @@ let repositoryGljObj = {
|
|
|
let items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,
|
|
|
maxRow = me.currentCache.length - 1,
|
|
|
- updateBasePrcArr = [] ,
|
|
|
+ updateBasePrcArr = [],
|
|
|
updateCount, resumeArr = [];
|
|
|
if(endRow <= maxRow){
|
|
|
//updateItems = items;
|
|
@@ -1178,8 +1449,9 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //if(info.cellRange.colCount === me.setting.header.length){
|
|
|
- if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length){
|
|
|
+ //if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length){
|
|
|
+ //[code, ..., gljType]
|
|
|
+ if(info.cellRange.colCount >= 5 && info.cellRange.colCount <= me.setting.header.length){
|
|
|
for(let i = updateCount ; i < items.length; i++){
|
|
|
if(me.isValidObj(items[i])){
|
|
|
items[i].component = [];
|
|
@@ -1193,8 +1465,9 @@ 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 - 4 && 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){
|
|
|
+ //粘贴的的最大列至少要等于工料机类型列,因为工料机类型必须有效才可新增
|
|
|
+ if(info.cellRange.colCount >= 5 && info.cellRange.colCount <= me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= me.colMapping.fieldToCol['gljType']){
|
|
|
for(let i = 0; i < items.length; i++){
|
|
|
if(me.isValidObj(items[i])){
|
|
|
items[i].component = [];
|
|
@@ -1216,7 +1489,11 @@ let repositoryGljObj = {
|
|
|
if(resumeArr[i] < me.currentCache.length){
|
|
|
for(let col = 0; col < me.setting.header.length; col++){
|
|
|
let dCode = me.setting.header[col].dataCode;
|
|
|
- if(dCode === 'gljType'){
|
|
|
+ if(me.priceCols.includes(col)){
|
|
|
+ let price = me.getPrice(me.currentCache[resumeArr[i]], col);
|
|
|
+ info.sheet.setValue(resumeArr[i], col, price ? price : 0);
|
|
|
+ }
|
|
|
+ else if(dCode === 'gljType'){
|
|
|
let gljType = me.currentCache[resumeArr[i]][dCode];
|
|
|
info.sheet.setValue(resumeArr[i], col, me.distTypeTree.distTypes["gljType" + gljType].data.fullName);
|
|
|
}
|
|
@@ -1321,7 +1598,7 @@ let repositoryGljObj = {
|
|
|
me.currentGlj = row < me.currentCache.length ? me.currentCache[row] : null;
|
|
|
me.currentComponent = me.currentGlj ? me.getCurrentComponent(me.currentGlj.component) : [];
|
|
|
sheetCommonObj.cleanData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, -1);
|
|
|
- sheetsOprObj.showData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, me.currentComponent);
|
|
|
+ sheetsOprObj.showData(gljComponentOprObj, gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, me.currentComponent);
|
|
|
}
|
|
|
},
|
|
|
error:function(err){
|
|
@@ -1389,7 +1666,7 @@ let repositoryGljObj = {
|
|
|
if (result && result.data && result.data.ops && result.data.ops.length > 0) {
|
|
|
for (let i = 0; i < result.data.ops.length; i++) {
|
|
|
for (let j = 0; j < cacheSection.length; j++) {
|
|
|
- if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
|
|
|
+ if (cacheSection[j]['code'] == result.data.ops[i]['code']) {
|
|
|
cacheSection[j]["ID"] = result.data.ops[i]["ID"];
|
|
|
}
|
|
|
}
|
|
@@ -1402,7 +1679,7 @@ let repositoryGljObj = {
|
|
|
cacheSection[j] = updateArr[i];
|
|
|
}
|
|
|
} else {
|
|
|
- if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
|
|
|
+ if (cacheSection[j]['code'] == updateArr[i]['code']) {
|
|
|
cacheSection[j] = updateArr[i];
|
|
|
}
|
|
|
}
|