|
@@ -8,24 +8,29 @@ let gljComponentOprObj = {
|
|
|
owner: "gljComponent",
|
|
|
header:[
|
|
|
{headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
|
|
|
- {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
|
|
|
+ {headerName:"名称",headerWidth:110,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
|
|
|
{headerName:"计量单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
|
|
|
{headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
|
|
|
{headerName:"消耗量",headerWidth:80,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"}
|
|
|
],
|
|
|
view: {
|
|
|
- lockedCells:[1, 2, 3]
|
|
|
+ lockedCells:[0, 1, 2, 3]
|
|
|
}
|
|
|
},
|
|
|
buildSheet: function(container) {
|
|
|
let me = gljComponentOprObj;
|
|
|
- me.workBook = sheetOpr.buildSheet(container, me.setting, 30, me);
|
|
|
+ me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
|
|
|
me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
|
|
|
me.workBook.getSheet(0).options.isProtected = true;
|
|
|
sheetOpr.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
|
|
|
- me.onContextmenuOpr();
|
|
|
+ me.onContextmenuOpr();//右键菜单
|
|
|
+ me.gljComponentDelOpr();
|
|
|
+ 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.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
+ me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
/*me.gljComponentDelOpr();
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
@@ -89,7 +94,28 @@ let gljComponentOprObj = {
|
|
|
//弹出窗口
|
|
|
$('#componentBtn').click();
|
|
|
}},
|
|
|
- "delete": {name: "删除", disabled: delDis}
|
|
|
+ "delete": {name: "删除", disabled: delDis, callback: function (key, opt) {
|
|
|
+ //删除
|
|
|
+ let deleteObj = that.currentComponent[target.row];
|
|
|
+ let gljComponent = that.currentGlj.component;
|
|
|
+ let updateArr = [];
|
|
|
+ //更新当前工料机的组成物列表
|
|
|
+ for(let i = 0, len = gljComponent.length; i < len; i++){
|
|
|
+ if(gljComponent[i].ID === deleteObj.ID){
|
|
|
+ gljComponent.splice(i, 1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //重新计算工料机
|
|
|
+ let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(gljComponent));
|
|
|
+ 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);
|
|
|
+ me.updateComponent(updateArr);
|
|
|
+ }}
|
|
|
}
|
|
|
};
|
|
|
}
|
|
@@ -178,7 +204,7 @@ let gljComponentOprObj = {
|
|
|
}
|
|
|
});
|
|
|
me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
- me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
+ //me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
},
|
|
|
onCellEditStart: function(sender, args) {
|
|
|
let me = gljComponentOprObj, that = repositoryGljObj;
|
|
@@ -188,127 +214,127 @@ 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 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;
|
|
|
+ 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 = 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});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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] : '');
|
|
|
+ //不存在
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ 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, me.currentEditingComponent.consumeAmt);
|
|
|
+ }
|
|
|
if(updateArr.length > 0){
|
|
|
me.updateComponent(updateArr);
|
|
|
- if(updateBasePrc.length > 0){
|
|
|
+ /*if(updateBasePrc.length > 0){
|
|
|
that.updateRationBasePrcRq(updateBasePrc)
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
},
|
|
|
onClipboardPasting: function (sender, info) {
|
|
@@ -324,7 +350,8 @@ let gljComponentOprObj = {
|
|
|
component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false, updateBasePrc = [];
|
|
|
let items = sheetOpr.analyzePasteData(me.setting, info);
|
|
|
let gljCache = that.gljList;
|
|
|
- if(info.cellRange.col === 0){
|
|
|
+ //编码
|
|
|
+ /* if(info.cellRange.col === 0){
|
|
|
for(let i = 0; i < items.length; i++){
|
|
|
for(let j = 0; j < gljCache.length; j++){
|
|
|
if(items[i].code === gljCache[j].code){
|
|
@@ -387,8 +414,9 @@ let gljComponentOprObj = {
|
|
|
}
|
|
|
updateArr.push(that.currentGlj);
|
|
|
}
|
|
|
- }
|
|
|
- else if(info.cellRange.col === 4){
|
|
|
+ }*/
|
|
|
+ //消耗量
|
|
|
+ if(info.cellRange.col === 4){
|
|
|
let items = sheetOpr.analyzePasteData(me.setting, info);
|
|
|
let row = info.cellRange.row;
|
|
|
for(let i = 0; i < items.length; i++){
|
|
@@ -419,33 +447,35 @@ let gljComponentOprObj = {
|
|
|
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});
|
|
|
+ //updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
|
|
|
}
|
|
|
updateArr.push(that.currentGlj);
|
|
|
}
|
|
|
}
|
|
|
if(updateArr.length > 0){
|
|
|
me.updateComponent(updateArr);
|
|
|
- if(updateBasePrc.length > 0){
|
|
|
+ /* if(updateBasePrc.length > 0){
|
|
|
that.updateRationBasePrcRq(updateBasePrc);
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
},
|
|
|
updateComponent: function (updateArr) {
|
|
|
let me = gljComponentOprObj, that = repositoryGljObj;
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
- url: 'api/updateComponent',
|
|
|
- data: {libId: pageOprObj.gljLibId, updateArr: updateArr, oprtor: userAccount},
|
|
|
+ url: 'complementartGlj/api/updateComponent',
|
|
|
+ data: {"userId": pageOprObj.userId, "updateArr": JSON.stringify(updateArr)},
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
- if(result.data.length > 0){
|
|
|
- if(result.data[0]){
|
|
|
+ if(!result.error){
|
|
|
that.currentComponent = that.getCurrentComponent(result.data[0].component);
|
|
|
sheetOpr.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
sheetOpr.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
|
|
|
- }
|
|
|
}
|
|
|
+ else{
|
|
|
+ sheetOpr.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
+ }
|
|
|
+ $('#componentsCacnel').click();
|
|
|
}
|
|
|
})
|
|
|
},
|