|
@@ -143,121 +143,121 @@ let gljComponentOprObj = {
|
|
|
onCellEditEnd: function (sender, args) {
|
|
|
let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
|
|
|
let gljList = that.gljList, updateArr = [], materialComponent = [202, 203, 204], machineComponent = [302, 303];
|
|
|
- if(args.editingText !== me.currentEditingComponent.code){
|
|
|
- if(args.col === 0 && args.editingText && args.editingText.trim().length > 0){
|
|
|
- let component = that.currentGlj.component, hasCode = false;
|
|
|
- for(let i = 0; i < gljList.length; i++){
|
|
|
- if(gljList[i].code === args.editingText){//有效的组成物
|
|
|
- hasCode = true;
|
|
|
- if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
|
|
|
- || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
|
|
|
- //是否与原有组成物不同
|
|
|
- let isExist = false;
|
|
|
- for(let j = 0; j < component.length; j++){
|
|
|
- if(component[j].ID === gljList[i].ID){
|
|
|
- isExist = true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ //if(args.editingText !== me.currentEditingComponent.code){
|
|
|
+ if(args.col === 0 && args.editingText && args.editingText.trim().length > 0 && args.editingText !== me.currentEditingComponent.code){
|
|
|
+ let component = that.currentGlj.component, hasCode = false;
|
|
|
+ for(let i = 0; i < gljList.length; i++){
|
|
|
+ if(gljList[i].code === args.editingText){//有效的组成物
|
|
|
+ hasCode = true;
|
|
|
+ if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
|
|
|
+ || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
|
|
|
+ //是否与原有组成物不同
|
|
|
+ let isExist = false;
|
|
|
+ for(let j = 0; j < component.length; j++){
|
|
|
+ if(component[j].ID === gljList[i].ID){
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
}
|
|
|
- if(!isExist){
|
|
|
- let rObj = {};
|
|
|
- rObj.ID = gljList[i].ID;
|
|
|
- //rObj.basePrice = gljList[i].basePrice;
|
|
|
- if(typeof that.currentComponent[args.row] !== 'undefined'){
|
|
|
- rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
|
|
|
- let index;
|
|
|
- for(let j = 0; j < component.length; j++){
|
|
|
- if(component[j].ID === that.currentComponent[args.row].ID){
|
|
|
- index = j;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- component.splice(index, 1);
|
|
|
- component.splice(index, 0, rObj);
|
|
|
- //计算工料机单价
|
|
|
- let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
|
|
|
- if(gljBasePrc !== that.currentGlj.basePrice){
|
|
|
- that.currentGlj.basePrice = gljBasePrc;
|
|
|
- that.reshowGljBasePrc(that.currentGlj);
|
|
|
- //工料机单价改变,重算引用了该工料机的定额单价
|
|
|
- updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
|
|
|
+ }
|
|
|
+ if(!isExist){
|
|
|
+ let rObj = {};
|
|
|
+ rObj.ID = gljList[i].ID;
|
|
|
+ //rObj.basePrice = gljList[i].basePrice;
|
|
|
+ if(typeof that.currentComponent[args.row] !== 'undefined'){
|
|
|
+ rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
|
|
|
+ let index;
|
|
|
+ for(let j = 0; j < component.length; j++){
|
|
|
+ if(component[j].ID === that.currentComponent[args.row].ID){
|
|
|
+ index = j;
|
|
|
+ break;
|
|
|
}
|
|
|
- updateArr.push(that.currentGlj);
|
|
|
}
|
|
|
- else{
|
|
|
- rObj.consumeAmt = 0;
|
|
|
- component.push(rObj);
|
|
|
- //计算工料机单价
|
|
|
- let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
|
|
|
- if(gljBasePrc !== that.currentGlj.basePrice){
|
|
|
- that.currentGlj.basePrice = gljBasePrc;
|
|
|
- that.reshowGljBasePrc(that.currentGlj);
|
|
|
- //工料机单价改变,重算引用了该工料机的定额单价
|
|
|
- updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
|
|
|
- }
|
|
|
- updateArr.push(that.currentGlj);
|
|
|
+ component.splice(index, 1);
|
|
|
+ component.splice(index, 0, rObj);
|
|
|
+ //计算工料机单价
|
|
|
+ let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
|
|
|
+ if(gljBasePrc !== that.currentGlj.basePrice){
|
|
|
+ that.currentGlj.basePrice = gljBasePrc;
|
|
|
+ that.reshowGljBasePrc(that.currentGlj);
|
|
|
+ //工料机单价改变,重算引用了该工料机的定额单价
|
|
|
+ updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
|
|
|
}
|
|
|
- break;
|
|
|
+ updateArr.push(that.currentGlj);
|
|
|
}
|
|
|
else{
|
|
|
- //已存在
|
|
|
- alert("已存在!");
|
|
|
- args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
|
|
|
- me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
|
|
|
+ rObj.consumeAmt = 0;
|
|
|
+ component.push(rObj);
|
|
|
+ //计算工料机单价
|
|
|
+ let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
|
|
|
+ if(gljBasePrc !== that.currentGlj.basePrice){
|
|
|
+ that.currentGlj.basePrice = gljBasePrc;
|
|
|
+ that.reshowGljBasePrc(that.currentGlj);
|
|
|
+ //工料机单价改变,重算引用了该工料机的定额单价
|
|
|
+ updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
|
|
|
+ }
|
|
|
+ updateArr.push(that.currentGlj);
|
|
|
}
|
|
|
-
|
|
|
+ break;
|
|
|
}
|
|
|
else{
|
|
|
- if(materialComponent.indexOf(that.currentGlj.gljType) === 1){
|
|
|
- alert("该组成物只能是普通材料!");
|
|
|
- }
|
|
|
- else if(that.currentGlj.gljType === 301){
|
|
|
- alert("该组成物只能是机械组成物或机上人工!")
|
|
|
- }
|
|
|
+ //已存在
|
|
|
+ alert("已存在!");
|
|
|
args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
|
|
|
me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
|
|
|
- //无效
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
- if(!hasCode){
|
|
|
- alert("不存在此工料机,请先添加!");
|
|
|
- args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
|
|
|
- me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
|
|
|
- //不存在
|
|
|
- }
|
|
|
- }
|
|
|
- else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
|
|
|
- let consumeAmt = parseFloat(args.editingText);
|
|
|
- if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
|
|
|
- let component = that.currentGlj.component;
|
|
|
- for(let i = 0; i < component.length; i++){
|
|
|
- if(component[i].ID === that.currentComponent[args.row].ID){
|
|
|
- component[i].consumeAmt = consumeAmt
|
|
|
+ else{
|
|
|
+ if(materialComponent.indexOf(that.currentGlj.gljType) === 1){
|
|
|
+ alert("该组成物只能是普通材料!");
|
|
|
+ }
|
|
|
+ else if(that.currentGlj.gljType === 301){
|
|
|
+ alert("该组成物只能是机械组成物或机上人工!")
|
|
|
}
|
|
|
+ args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
|
|
|
+ me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
|
|
|
+ //无效
|
|
|
}
|
|
|
- that.currentComponent[args.row].consumeAmt = consumeAmt;
|
|
|
- //计算工料机单价
|
|
|
- let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
|
|
|
- if(gljBasePrc !== that.currentGlj.basePrice){
|
|
|
- that.currentGlj.basePrice = gljBasePrc;
|
|
|
- that.reshowGljBasePrc(that.currentGlj);
|
|
|
- //工料机单价改变,重算引用了该工料机的定额单价
|
|
|
- updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!hasCode){
|
|
|
+ alert("不存在此工料机,请先添加!");
|
|
|
+ args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
|
|
|
+ me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
|
|
|
+ //不存在
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
|
|
|
+ let consumeAmt = parseFloat(args.editingText);
|
|
|
+ if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
|
|
|
+ let roundCons = me.round(consumeAmt, 3);
|
|
|
+ let component = that.currentGlj.component;
|
|
|
+ for(let i = 0; i < component.length; i++){
|
|
|
+ if(component[i].ID === that.currentComponent[args.row].ID){
|
|
|
+ component[i].consumeAmt = roundCons;
|
|
|
}
|
|
|
- updateArr.push(that.currentGlj);
|
|
|
}
|
|
|
- else{
|
|
|
- //只能输入数值
|
|
|
- args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
|
|
|
- me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
|
|
|
-
|
|
|
+ that.currentComponent[args.row].consumeAmt = roundCons;
|
|
|
+ //计算工料机单价
|
|
|
+ let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
|
|
|
+ if(gljBasePrc !== that.currentGlj.basePrice){
|
|
|
+ that.currentGlj.basePrice = gljBasePrc;
|
|
|
+ that.reshowGljBasePrc(that.currentGlj);
|
|
|
+ //工料机单价改变,重算引用了该工料机的定额单价
|
|
|
+ updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
|
|
|
}
|
|
|
+ updateArr.push(that.currentGlj);
|
|
|
}
|
|
|
else{
|
|
|
- args.sheet.setValue(args.row, args.col, '');
|
|
|
+ //只能输入数值
|
|
|
+ args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
|
|
|
+ me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
+ else{
|
|
|
+ args.sheet.setValue(args.row, args.col, '');
|
|
|
+ }
|
|
|
if(updateArr.length > 0){
|
|
|
me.updateComponent(updateArr);
|
|
|
if(updateBasePrc.length > 0){
|
|
@@ -349,8 +349,9 @@ let gljComponentOprObj = {
|
|
|
if(row + i < that.currentComponent.length){
|
|
|
let currentObj = that.currentComponent[row + i];
|
|
|
if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
|
|
|
+ let roundCons = me.round(items[i].consumeAmt, 3);
|
|
|
isChange = true;
|
|
|
- currentObj.consumeAmt = items[i].consumeAmt;
|
|
|
+ currentObj.consumeAmt = roundCons;
|
|
|
for(let j = 0; j < component.length; j++){
|
|
|
if(component[j].ID === currentObj.ID){
|
|
|
component[j].consumeAmt = currentObj.consumeAmt;
|