|
@@ -10,24 +10,24 @@ var rationGLJOprObj = {
|
|
|
tempCacheArr: [],//被更新的工料机,若更新的工料机不存在,则恢复
|
|
|
cache: {},
|
|
|
setting: {
|
|
|
- header:[
|
|
|
- {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
|
|
|
- {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String"},
|
|
|
- {headerName:"规格型号",headerWidth:120,dataCode:"specs", dataType: "String"},
|
|
|
- {headerName:"单位",headerWidth:160,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
|
|
|
- {headerName:"定额价",headerWidth:160, dataCode:"basePrice", dataType: "Number", formatter:"0.00", precision: 2},
|
|
|
- {headerName:"定额消耗",headerWidth:160, dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", precision: 3},
|
|
|
- {headerName:"类型",headerWidth:160,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"}
|
|
|
+ header: [
|
|
|
+ { headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String", formatter: "@" },
|
|
|
+ { headerName: "名称", headerWidth: 400, dataCode: "name", dataType: "String" },
|
|
|
+ { headerName: "规格型号", headerWidth: 120, dataCode: "specs", dataType: "String" },
|
|
|
+ { headerName: "单位", headerWidth: 160, dataCode: "unit", dataType: "String", hAlign: "center", vAlign: "center" },
|
|
|
+ { headerName: "定额价", headerWidth: 160, dataCode: "basePrice", dataType: "Number", formatter: "0.00", precision: 2 },
|
|
|
+ { headerName: "定额消耗", headerWidth: 160, dataCode: "consumeAmt", dataType: "Number", formatter: "0.000", precision: 3 },
|
|
|
+ { headerName: "类型", headerWidth: 160, dataCode: "gljType", dataType: "String", hAlign: "center", vAlign: "center" }
|
|
|
],
|
|
|
- view:{
|
|
|
- comboBox:[],
|
|
|
- lockColumns:[1,2,3,4,6]
|
|
|
+ view: {
|
|
|
+ comboBox: [],
|
|
|
+ lockColumns: [1, 2, 3, 4, 6]
|
|
|
}
|
|
|
},
|
|
|
getDistTypeTree: function (gljDistType) {
|
|
|
let distType;
|
|
|
let distTypeTree = {
|
|
|
- prefix : 'gljDistType',
|
|
|
+ prefix: 'gljDistType',
|
|
|
distTypes: {},
|
|
|
comboDatas: [],
|
|
|
distTypesArr: []
|
|
@@ -44,18 +44,18 @@ var rationGLJOprObj = {
|
|
|
gljDistType.forEach(function (typeData) {
|
|
|
distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
|
|
|
let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
|
|
|
- if(parent){
|
|
|
+ if (parent) {
|
|
|
distType.parent = parent;
|
|
|
parent.children.push(distType);
|
|
|
}
|
|
|
});
|
|
|
distTypeTree.distTypesArr.forEach(function (distTypeObj) {
|
|
|
- if(distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' &&distTypeObj.data.fullName !== '机械组成物'
|
|
|
- && distTypeObj.data.fullName !== '机上人工'){
|
|
|
- distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
|
|
|
+ if (distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' && distTypeObj.data.fullName !== '机械组成物'
|
|
|
+ && distTypeObj.data.fullName !== '机上人工') {
|
|
|
+ distTypeTree.comboDatas.push({ text: distTypeObj.data.fullName, value: distTypeObj.data.ID });
|
|
|
}
|
|
|
- if(distTypeObj.data.fullName === '机械'){
|
|
|
- distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
|
|
|
+ if (distTypeObj.data.fullName === '机械') {
|
|
|
+ distTypeTree.comboDatas.push({ text: distTypeObj.data.fullName, value: distTypeObj.data.ID });
|
|
|
}
|
|
|
});
|
|
|
return distTypeTree;
|
|
@@ -67,14 +67,14 @@ var rationGLJOprObj = {
|
|
|
url: "api/getGljDistType",
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
- if(!result.error && callback){
|
|
|
+ if (!result.error && callback) {
|
|
|
me.distTypeTree = me.getDistTypeTree(result.data);
|
|
|
callback();
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- buildSheet: function(sheet) {
|
|
|
+ buildSheet: function (sheet) {
|
|
|
this.sheet = sheet;
|
|
|
this.distTypeTree = this.getDistTypeTree(this.distTypeTree);
|
|
|
sheetCommonObj.initSheet(this.sheet, this.setting, 30);
|
|
@@ -90,117 +90,127 @@ var rationGLJOprObj = {
|
|
|
let raCoe = rationCoeOprObj;
|
|
|
$.contextMenu({
|
|
|
selector: '#rdSpread',
|
|
|
- build: function($triggerElement, e){
|
|
|
+ build: function ($triggerElement, e) {
|
|
|
//控制允许右键菜单在哪个位置出现
|
|
|
let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.sheet.getParent());
|
|
|
let sheet = me.sheet;
|
|
|
let addDis = false, delDis = false;
|
|
|
let rationGlj = [];
|
|
|
- if(me.sheet.getParent().getActiveSheetIndex() === 0 && target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
|
|
|
+ if (me.sheet.getParent().getActiveSheetIndex() === 0 && target.hitTestType === 3) {//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
|
|
|
//rationGlj表
|
|
|
- if(typeof target.row !== 'undefined'){
|
|
|
+ if (typeof target.row !== 'undefined') {
|
|
|
//控制按钮是否可用
|
|
|
sheet.setActiveCell(target.row, target.col);
|
|
|
console.log(me.currentRationItem);
|
|
|
- if(me.currentRationItem){
|
|
|
- rationGlj = me.cache['_GLJ_' + me.currentRationItem.ID];
|
|
|
- if(!rationGlj ||target.row >= rationGlj.length){//右键定位在有数据的行,删除键才显示可用
|
|
|
+ if (me.currentRationItem) {
|
|
|
+ rationGlj = me.cache['_GLJ_' + me.currentRationItem.ID];
|
|
|
+ if (!rationGlj || target.row >= rationGlj.length) {//右键定位在有数据的行,删除键才显示可用
|
|
|
delDis = true;
|
|
|
}
|
|
|
- else{//有数据
|
|
|
- if(typeof target.col === 'undefined'){//定位不在表格内
|
|
|
+ else {//有数据
|
|
|
+ if (typeof target.col === 'undefined') {//定位不在表格内
|
|
|
delDis = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else{
|
|
|
+ else {
|
|
|
addDis = true;
|
|
|
delDis = true;
|
|
|
}
|
|
|
}
|
|
|
- else{
|
|
|
+ else {
|
|
|
addDis = true;
|
|
|
delDis = true;
|
|
|
}
|
|
|
return {
|
|
|
- callback: function(){},
|
|
|
+ callback: function () { },
|
|
|
items: {
|
|
|
- "add": {name: "添加人材机", disabled: addDis, icon: "fa-plus", callback: function (key, opt) {
|
|
|
- //默认radio所有工料机
|
|
|
- gljSelOprObj.initRadio();
|
|
|
- gljSelOprObj.gljCurTypeId = null;
|
|
|
- gljSelOprObj.initClassTree('std', gljSelOprObj.treeData.std);
|
|
|
- //弹出窗口
|
|
|
- $('#selGlj').modal('show');
|
|
|
- }},
|
|
|
- "delete": {name: "删除人材机", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
|
|
|
- rationGlj.splice(target.row, 1);
|
|
|
- me.updateRationItem(function(){
|
|
|
- me.sheet.getParent().focus();
|
|
|
- });
|
|
|
- sheetCommonObj.cleanData(me.sheet, me.setting, -1);
|
|
|
- me.showGljItems(me.currentRationItem.ID);
|
|
|
- }},
|
|
|
+ "add": {
|
|
|
+ name: "添加人材机", disabled: addDis, icon: "fa-plus", callback: function (key, opt) {
|
|
|
+ //默认radio所有工料机
|
|
|
+ gljSelOprObj.initRadio();
|
|
|
+ gljSelOprObj.gljCurTypeId = null;
|
|
|
+ gljSelOprObj.initClassTree('std', gljSelOprObj.treeData.std);
|
|
|
+ //弹出窗口
|
|
|
+ $('#selGlj').modal('show');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "delete": {
|
|
|
+ name: "删除人材机", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
|
|
|
+ rationGlj.splice(target.row, 1);
|
|
|
+ me.updateRationItem(function () {
|
|
|
+ me.sheet.getParent().focus();
|
|
|
+ });
|
|
|
+ sheetCommonObj.cleanData(me.sheet, me.setting, -1);
|
|
|
+ me.showGljItems(me.currentRationItem.ID);
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
//rationCoe表
|
|
|
- else if(me.sheet.getParent().getActiveSheetIndex() === 2 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){
|
|
|
- let currentCache = raCoe.curRation && raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID]) ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
|
|
|
+ else if (me.sheet.getParent().getActiveSheetIndex() === 2 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined') {
|
|
|
+ let currentCache = raCoe.curRation && raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID]) ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
|
|
|
sheet.setActiveCell(target.row, target.col);
|
|
|
//控制按钮是否可用
|
|
|
let upDis = false,
|
|
|
downDis = false,
|
|
|
refDis = false;
|
|
|
- if(target.row >= currentCache.length){
|
|
|
+ if (target.row >= currentCache.length) {
|
|
|
upDis = true;
|
|
|
downDis = true;
|
|
|
refDis = true;
|
|
|
}
|
|
|
else {
|
|
|
- if(!raCoe.isDef(currentCache[target.row - 1])){
|
|
|
+ if (!raCoe.isDef(currentCache[target.row - 1])) {
|
|
|
upDis = true;
|
|
|
}
|
|
|
- if(!raCoe.isDef(currentCache[target.row + 1])){
|
|
|
+ if (!raCoe.isDef(currentCache[target.row + 1])) {
|
|
|
downDis = true;
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
- callback: function(){},
|
|
|
+ callback: function () { },
|
|
|
items: {
|
|
|
- "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
|
|
|
- raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
|
|
|
- }},
|
|
|
- "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
|
|
|
- raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
|
|
|
- }},
|
|
|
- "ref": {name: "添加到本节其他定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
|
|
|
- raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
|
|
|
- for(let i = 0, len = updateArr.length; i < len; i++){
|
|
|
- let ration = updateArr[i];
|
|
|
- let rationCoeList = updateArr[i].rationCoeList;
|
|
|
- let newNo = 1;
|
|
|
- for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
|
|
|
- if(rationCoeList[j].no >= newNo){
|
|
|
- newNo = rationCoeList[j].no + 1;
|
|
|
+ "upMove": {
|
|
|
+ name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
|
|
|
+ raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], { row: target.row - 1, col: target.col });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "downMove": {
|
|
|
+ name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
|
|
|
+ raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], { row: target.row + 1, col: target.col });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "ref": {
|
|
|
+ name: "添加到本节其他定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
|
|
|
+ raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
|
|
|
+ for (let i = 0, len = updateArr.length; i < len; i++) {
|
|
|
+ let ration = updateArr[i];
|
|
|
+ let rationCoeList = updateArr[i].rationCoeList;
|
|
|
+ let newNo = 1;
|
|
|
+ for (let j = 0, jLen = rationCoeList.length; j < jLen; j++) {
|
|
|
+ if (rationCoeList[j].no >= newNo) {
|
|
|
+ newNo = rationCoeList[j].no + 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- let theCache = raCoe.cache["_Coe_" + ration.ID];
|
|
|
- if(theCache !== undefined && theCache !== null){
|
|
|
- let newCoe = {};
|
|
|
- for(let attr in currentCache[target.row]){
|
|
|
- newCoe[attr] = currentCache[target.row][attr];
|
|
|
+ let theCache = raCoe.cache["_Coe_" + ration.ID];
|
|
|
+ if (theCache !== undefined && theCache !== null) {
|
|
|
+ let newCoe = {};
|
|
|
+ for (let attr in currentCache[target.row]) {
|
|
|
+ newCoe[attr] = currentCache[target.row][attr];
|
|
|
+ }
|
|
|
+ newCoe.no = newNo;
|
|
|
+ theCache.push(newCoe);
|
|
|
}
|
|
|
- newCoe.no = newNo;
|
|
|
- theCache.push(newCoe);
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- }}
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
- else{
|
|
|
+ else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -209,26 +219,26 @@ var rationGLJOprObj = {
|
|
|
bindRationGljDelOpr: function () {
|
|
|
let me = rationGLJOprObj, spreadBook = me.sheet.getParent();
|
|
|
spreadBook.commandManager().register('rationGljDelete', function () {
|
|
|
- if(!me.currentRationItem){
|
|
|
+ if (!me.currentRationItem) {
|
|
|
return;
|
|
|
}
|
|
|
let sels = me.sheet.getSelections(), lockCols = me.setting.view.lockColumns;
|
|
|
let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID], isUpdate = false;
|
|
|
- if(sels.length > 0){
|
|
|
- for(let sel = 0; sel < sels.length; sel++){
|
|
|
- if(sels[sel].colCount === me.setting.header.length){
|
|
|
- if(cacheSection && sels[sel].row < cacheSection.length){
|
|
|
+ if (sels.length > 0) {
|
|
|
+ for (let sel = 0; sel < sels.length; sel++) {
|
|
|
+ if (sels[sel].colCount === me.setting.header.length) {
|
|
|
+ if (cacheSection && sels[sel].row < cacheSection.length) {
|
|
|
isUpdate = true;
|
|
|
cacheSection.splice(sels[sel].row, sels[sel].rowCount);
|
|
|
}
|
|
|
}
|
|
|
- else{
|
|
|
- if(sels[sel].col !== 0 && sels[sel].col !== 5 && !(sels[sel].col === 1 && sels.col + sels[sel].colCount -1 === 3)){
|
|
|
- if(cacheSection){
|
|
|
- for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
|
|
|
- if(sels[sel].row + i < cacheSection.length){
|
|
|
- for(let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++){
|
|
|
- if(lockCols.indexOf(col) === -1){
|
|
|
+ else {
|
|
|
+ if (sels[sel].col !== 0 && sels[sel].col !== 5 && !(sels[sel].col === 1 && sels.col + sels[sel].colCount - 1 === 3)) {
|
|
|
+ if (cacheSection) {
|
|
|
+ for (let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++) {
|
|
|
+ if (sels[sel].row + i < cacheSection.length) {
|
|
|
+ for (let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++) {
|
|
|
+ if (lockCols.indexOf(col) === -1) {
|
|
|
isUpdate = true;
|
|
|
cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = 0;
|
|
|
me.sheet.setValue(sels[sel].row + i, col, 0.00);
|
|
@@ -241,7 +251,7 @@ var rationGLJOprObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(isUpdate){
|
|
|
+ if (isUpdate) {
|
|
|
me.updateRationItem(function () {
|
|
|
me.sheet.getParent().focus(true);
|
|
|
});
|
|
@@ -252,67 +262,65 @@ var rationGLJOprObj = {
|
|
|
spreadBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
spreadBook.commandManager().setShortcutKey('rationGljDelete', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
},
|
|
|
- onClipboardPasting: function(sender, args) {
|
|
|
+ onClipboardPasting: function (sender, args) {
|
|
|
var me = rationGLJOprObj;
|
|
|
let rationSection = rationOprObj.getCache();
|
|
|
let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
|
|
|
me.currentRationItem = rationRow < rationSection.length ? rationSection[rationRow] : null;
|
|
|
- if(me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined'){
|
|
|
+ if (me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined') {
|
|
|
me.cache["_GLJ_" + me.currentRationItem.ID] = [];
|
|
|
}
|
|
|
if (!(args.cellRange.col === 0 || args.cellRange.col === 5) || !(me.currentRationItem)) {
|
|
|
args.cancel = true;
|
|
|
}
|
|
|
},
|
|
|
- onClipboardPasted: function(e, info) {
|
|
|
+ onClipboardPasted: function (e, info) {
|
|
|
var me = rationGLJOprObj, repId = pageOprObj.rationLibId;
|
|
|
me.tempCacheArr = [];
|
|
|
- if (repId) {
|
|
|
- let gljLibId = pageOprObj.gljLibId;
|
|
|
- console.log(gljLibId);
|
|
|
- if(gljLibId){
|
|
|
- if (info.cellRange.col == 0) {
|
|
|
- let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
|
|
|
- var tmpCodes = sheetCommonObj.analyzePasteData({header:[{dataCode: "code"}] }, info);
|
|
|
- var codes = [];
|
|
|
- for (var i = 0; i < tmpCodes.length; i++) {
|
|
|
- let rowIdx = info.cellRange.row + i;
|
|
|
- if(rowIdx < cacheArr.length){//更新
|
|
|
- me.tempCacheArr.push({org: cacheArr[rowIdx], newCode: tmpCodes[i].code});
|
|
|
- cacheArr.splice(rowIdx--, 1);
|
|
|
- }
|
|
|
- codes.push(tmpCodes[i].code);
|
|
|
+ let gljLibId = pageOprObj.gljLibId;
|
|
|
+ console.log(gljLibId);
|
|
|
+ if (gljLibId) {
|
|
|
+ if (info.cellRange.col == 0) {
|
|
|
+ let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
|
|
|
+ var tmpCodes = sheetCommonObj.analyzePasteData({ header: [{ dataCode: "code" }] }, info);
|
|
|
+ var codes = [];
|
|
|
+ for (var i = 0; i < tmpCodes.length; i++) {
|
|
|
+ let rowIdx = info.cellRange.row + i;
|
|
|
+ if (rowIdx < cacheArr.length) {//更新
|
|
|
+ me.tempCacheArr.push({ org: cacheArr[rowIdx], newCode: tmpCodes[i].code });
|
|
|
+ cacheArr.splice(rowIdx--, 1);
|
|
|
}
|
|
|
- me.addGljItems(codes, gljLibId, info.cellRange);
|
|
|
- } else {
|
|
|
- //修改用量
|
|
|
- if(me.cache["_GLJ_" + me.currentRationItem.ID] && info.cellRange.row < me.cache["_GLJ_" + me.currentRationItem.ID].length){
|
|
|
- let tempConsumes = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
- let maxCount = info.cellRange.row + info.cellRange.rowCount -1 > me.cache["_GLJ_" + me.currentRationItem.ID].length -1 ?
|
|
|
+ codes.push(tmpCodes[i].code);
|
|
|
+ }
|
|
|
+ me.addGljItems(codes, gljLibId, info.cellRange);
|
|
|
+ } else {
|
|
|
+ //修改用量
|
|
|
+ if (me.cache["_GLJ_" + me.currentRationItem.ID] && info.cellRange.row < me.cache["_GLJ_" + me.currentRationItem.ID].length) {
|
|
|
+ let tempConsumes = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
+ let maxCount = info.cellRange.row + info.cellRange.rowCount - 1 > me.cache["_GLJ_" + me.currentRationItem.ID].length - 1 ?
|
|
|
me.cache["_GLJ_" + me.currentRationItem.ID].length - info.cellRange.row : info.cellRange.rowCount;
|
|
|
- for(let i = 0; i < maxCount; i++){
|
|
|
- let roundCons = scMathUtil.roundTo(tempConsumes[i].consumeAmt, -3);
|
|
|
- me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = roundCons;
|
|
|
- }
|
|
|
- me.updateRationItem(function () {
|
|
|
- me.sheet.getParent().focus(true);
|
|
|
- });
|
|
|
- if(info.cellRange.row + info.cellRange.rowCount -1 >= me.cache["_GLJ_" + me.currentRationItem.ID].length -1){
|
|
|
- me.sheet.suspendPaint();
|
|
|
- for(let rowIdx = me.cache["_GLJ_" + me.currentRationItem.ID].length; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx++){
|
|
|
- me.sheet.setValue(rowIdx, info.cellRange.col, '');
|
|
|
- }
|
|
|
- me.sheet.resumePaint();
|
|
|
- }
|
|
|
+ for (let i = 0; i < maxCount; i++) {
|
|
|
+ let roundCons = scMathUtil.roundTo(tempConsumes[i].consumeAmt, -3);
|
|
|
+ me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = roundCons;
|
|
|
}
|
|
|
- else if(info.cellRange.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
|
|
|
+ me.updateRationItem(function () {
|
|
|
+ me.sheet.getParent().focus(true);
|
|
|
+ });
|
|
|
+ if (info.cellRange.row + info.cellRange.rowCount - 1 >= me.cache["_GLJ_" + me.currentRationItem.ID].length - 1) {
|
|
|
me.sheet.suspendPaint();
|
|
|
- for(let rowIdx = info.cellRange.row; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx ++){
|
|
|
+ for (let rowIdx = me.cache["_GLJ_" + me.currentRationItem.ID].length; rowIdx <= info.cellRange.row + info.cellRange.rowCount - 1; rowIdx++) {
|
|
|
me.sheet.setValue(rowIdx, info.cellRange.col, '');
|
|
|
}
|
|
|
me.sheet.resumePaint();
|
|
|
}
|
|
|
}
|
|
|
+ else if (info.cellRange.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length) {
|
|
|
+ me.sheet.suspendPaint();
|
|
|
+ for (let rowIdx = info.cellRange.row; rowIdx <= info.cellRange.row + info.cellRange.rowCount - 1; rowIdx++) {
|
|
|
+ me.sheet.setValue(rowIdx, info.cellRange.col, '');
|
|
|
+ }
|
|
|
+ me.sheet.resumePaint();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -321,21 +329,21 @@ var rationGLJOprObj = {
|
|
|
let rationSection = rationOprObj.getCache();
|
|
|
let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
|
|
|
me.currentRationItem = rationRow < rationSection.length ? rationSection[rationRow] : null;
|
|
|
- if(me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined'){
|
|
|
+ if (me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined') {
|
|
|
me.cache["_GLJ_" + me.currentRationItem.ID] = [];
|
|
|
}
|
|
|
- if(!me.currentRationItem){
|
|
|
+ if (!me.currentRationItem) {
|
|
|
args.cancel = true;
|
|
|
}
|
|
|
else {
|
|
|
- if(args.col !== 0 && args.col !== 5 || args.col === 5 && args.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
|
|
|
+ if (args.col !== 0 && args.col !== 5 || args.col === 5 && args.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length) {
|
|
|
args.cancel = true;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- onCellEditEnd: function(sender, args){
|
|
|
+ onCellEditEnd: function (sender, args) {
|
|
|
var me = rationGLJOprObj;
|
|
|
- if(me.currentRationItem) {
|
|
|
+ if (me.currentRationItem) {
|
|
|
var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
|
|
|
me.tempCacheArr = [];
|
|
|
if (args.col != 0) {
|
|
@@ -378,7 +386,7 @@ var rationGLJOprObj = {
|
|
|
}
|
|
|
else {
|
|
|
if (args.row < cacheArr.length && args.editingText !== cacheArr[args.row].code) {//更新
|
|
|
- me.tempCacheArr.push({org: cacheArr[args.row], newCode: args.editingText.toString().trim()});
|
|
|
+ me.tempCacheArr.push({ org: cacheArr[args.row], newCode: args.editingText.toString().trim() });
|
|
|
cacheArr.splice(args.row, 1);
|
|
|
let gljLibID = pageOprObj.gljLibId;
|
|
|
let codes = [];
|
|
@@ -406,32 +414,32 @@ var rationGLJOprObj = {
|
|
|
},
|
|
|
getRecoveryArr: function (tempDelArr, newArr) {//获得更新的code不存在,恢复删除的被更新数据
|
|
|
let rst = [];
|
|
|
- for(let i = 0, len = tempDelArr.length; i < len; i++){
|
|
|
+ for (let i = 0, len = tempDelArr.length; i < len; i++) {
|
|
|
let isExist = false;
|
|
|
- for(let j = 0, jLen = newArr.length; j < jLen; j++){
|
|
|
- if(tempDelArr[i].newCode == newArr[j].code){
|
|
|
+ for (let j = 0, jLen = newArr.length; j < jLen; j++) {
|
|
|
+ if (tempDelArr[i].newCode == newArr[j].code) {
|
|
|
isExist = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(!isExist){
|
|
|
+ if (!isExist) {
|
|
|
rst.push(tempDelArr[i].org);
|
|
|
}
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
- addGljItems: function(codes, repId, args) {
|
|
|
+ addGljItems: function (codes, repId, args) {
|
|
|
let me = this;
|
|
|
- CommonAjax.post('api/getGljItemsByCodes', {gljCodes: codes, rationRepId: repId}, function (rstData) {
|
|
|
- if(rstData.length > 0){
|
|
|
- if(priceProperties && priceProperties.length > 0){
|
|
|
+ CommonAjax.post('api/getGljItemsByCodes', { gljCodes: codes, rationRepId: repId }, function (rstData) {
|
|
|
+ if (rstData.length > 0) {
|
|
|
+ if (priceProperties && priceProperties.length > 0) {
|
|
|
let priceField = priceProperties[0].price.dataCode;
|
|
|
- for(let glj of rstData){
|
|
|
+ for (let glj of rstData) {
|
|
|
glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
|
|
|
}
|
|
|
}
|
|
|
sheetCommonObj.cleanData(me.sheet, me.setting, -1);
|
|
|
- let rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
|
|
|
+ let rstArr = [], dummyR = { gljId: 0, consumeAmt: 0 }, newAddArr = [];
|
|
|
for (let i = 0; i < rstData.length; i++) {
|
|
|
dummyR.gljId = rstData[i].ID;
|
|
|
dummyR.type = rstData[i].type;
|
|
@@ -453,10 +461,10 @@ var rationGLJOprObj = {
|
|
|
}
|
|
|
me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(newAddArr);
|
|
|
let recoveryArr = me.getRecoveryArr(me.tempCacheArr, rstData);
|
|
|
- if(recoveryArr.length > 0){
|
|
|
+ if (recoveryArr.length > 0) {
|
|
|
me.cache["_GLJ_" + me.currentRationItem.ID] = me.cache["_GLJ_" + me.currentRationItem.ID].concat(recoveryArr);
|
|
|
}
|
|
|
- me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
|
|
|
+ me.cache["_GLJ_" + me.currentRationItem.ID].sort(function (a, b) {
|
|
|
let aV = a.gljType + a.code,
|
|
|
bV = b.gljType + b.code;
|
|
|
if (aV > bV) {
|
|
@@ -474,14 +482,14 @@ var rationGLJOprObj = {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- else{
|
|
|
- let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID]? me.cache["_GLJ_" + me.currentRationItem.ID] : [];
|
|
|
+ else {
|
|
|
+ let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID] ? me.cache["_GLJ_" + me.currentRationItem.ID] : [];
|
|
|
let recoveryArr = me.getRecoveryArr(me.tempCacheArr, []);
|
|
|
- if(recoveryArr.length > 0){
|
|
|
+ if (recoveryArr.length > 0) {
|
|
|
me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(recoveryArr);
|
|
|
}
|
|
|
//更新的工料机不存在
|
|
|
- me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
|
|
|
+ me.cache["_GLJ_" + me.currentRationItem.ID].sort(function (a, b) {
|
|
|
let aV = a.gljType + a.code,
|
|
|
bV = b.gljType + b.code;
|
|
|
if (aV > bV) {
|
|
@@ -492,7 +500,7 @@ var rationGLJOprObj = {
|
|
|
return 0;
|
|
|
});
|
|
|
$('#alertModalBtn').click();
|
|
|
- $('#alertText').text("人材机"+ codes + "不存在,请查找你所需要的人材机,或新增人材机");
|
|
|
+ $('#alertText').text("人材机" + codes + "不存在,请查找你所需要的人材机,或新增人材机");
|
|
|
$('#alertModalCls').click(function () {
|
|
|
me.showGljItems(me.currentRationItem.ID);
|
|
|
});
|
|
@@ -502,29 +510,29 @@ var rationGLJOprObj = {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- round(v, e){
|
|
|
- var t=1;
|
|
|
- for(;e>0;t*=10,e--);
|
|
|
- for(;e<0;t/=10,e++);
|
|
|
- return Math.round(v*t)/t;
|
|
|
+ round(v, e) {
|
|
|
+ var t = 1;
|
|
|
+ for (; e > 0; t *= 10, e--);
|
|
|
+ for (; e < 0; t /= 10, e++);
|
|
|
+ return Math.round(v * t) / t;
|
|
|
},
|
|
|
rationCal: function () {
|
|
|
let me = rationGLJOprObj;
|
|
|
- let price = {gljType1: [], gljType2: [], gljType3: []}, rst = {labourPrice: 0, materialPrice: 0, machinePrice: 0}, rationBasePrc = 0;
|
|
|
- if(me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]){
|
|
|
+ let price = { gljType1: [], gljType2: [], gljType3: [] }, rst = { labourPrice: 0, materialPrice: 0, machinePrice: 0 }, rationBasePrc = 0;
|
|
|
+ if (me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]) {
|
|
|
let cacheArr = me.cache['_GLJ_' + me.currentRationItem.ID];
|
|
|
cacheArr.forEach(function (gljData) {
|
|
|
- if(gljData.gljType && gljData.basePrice && gljData.consumeAmt){
|
|
|
+ if (gljData.gljType && gljData.basePrice && gljData.consumeAmt) {
|
|
|
let parent = me.distTypeTree.distTypes[me.distTypeTree.prefix + gljData.gljType].parent;
|
|
|
- if(parent && parent.data.ID <= 3){
|
|
|
- price['gljType' + parent.data.ID].push(scMathUtil.roundTo( gljData.basePrice * gljData.consumeAmt, -3));//取三位
|
|
|
+ if (parent && parent.data.ID <= 3) {
|
|
|
+ price['gljType' + parent.data.ID].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3));//取三位
|
|
|
}
|
|
|
- if(!parent && gljData.gljType <= 3){
|
|
|
- price['gljType' + gljData.gljType].push(scMathUtil.roundTo( gljData.basePrice * gljData.consumeAmt, -3));//取三位
|
|
|
+ if (!parent && gljData.gljType <= 3) {
|
|
|
+ price['gljType' + gljData.gljType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3));//取三位
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- if(price.gljType1.length > 0){
|
|
|
+ if (price.gljType1.length > 0) {
|
|
|
let labourPrice = 0;
|
|
|
price.gljType1.forEach(function (singlePrc) {
|
|
|
labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, me.processDecimal);
|
|
@@ -533,7 +541,7 @@ var rationGLJOprObj = {
|
|
|
rst.labourPrice = roundPrice;
|
|
|
rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
|
|
|
}
|
|
|
- if(price.gljType2.length > 0){
|
|
|
+ if (price.gljType2.length > 0) {
|
|
|
let materialPrice = 0;
|
|
|
price.gljType2.forEach(function (singlePrc) {
|
|
|
materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, me.processDecimal);
|
|
@@ -542,7 +550,7 @@ var rationGLJOprObj = {
|
|
|
rst.materialPrice = roundPrice;
|
|
|
rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
|
|
|
}
|
|
|
- if(price.gljType3.length > 0){
|
|
|
+ if (price.gljType3.length > 0) {
|
|
|
let machinePrice = 0;
|
|
|
price.gljType3.forEach(function (singlePrc) {
|
|
|
machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, me.processDecimal);
|
|
@@ -555,7 +563,7 @@ var rationGLJOprObj = {
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
- updateRationItem: function(callback) {
|
|
|
+ updateRationItem: function (callback) {
|
|
|
var me = this, updateArr = [];
|
|
|
if (me.currentRationItem) {
|
|
|
me.currentRationItem.rationGljList = me.buildRationItemGlj();
|
|
@@ -567,23 +575,23 @@ var rationGLJOprObj = {
|
|
|
me.currentRationItem.basePrice = price.rationBasePrc;
|
|
|
updateArr.push(me.currentRationItem);
|
|
|
rationOprObj.mixUpdateRequest(updateArr, [], [], function () {
|
|
|
- if(callback) callback();
|
|
|
+ if (callback) callback();
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- buildRationItemGlj: function(){
|
|
|
+ buildRationItemGlj: function () {
|
|
|
var me = this, rst = [];
|
|
|
if (me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]) {
|
|
|
var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
|
|
|
for (var i = 0; i < cacheArr.length; i++) {
|
|
|
- rst.push({gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, type: cacheArr[i].type});
|
|
|
+ rst.push({ gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, type: cacheArr[i].type });
|
|
|
}
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
|
|
|
- createRationGljDisplayItem: function(rItem, repGlj) {
|
|
|
+ createRationGljDisplayItem: function (rItem, repGlj) {
|
|
|
var rst = {};
|
|
|
rst.gljId = rItem.gljId;
|
|
|
rst.type = rItem.type;
|
|
@@ -596,7 +604,7 @@ var rationGLJOprObj = {
|
|
|
rst.gljType = repGlj.gljType;
|
|
|
return rst;
|
|
|
},
|
|
|
- getGljItems: function(rationItem, callback) {
|
|
|
+ getGljItems: function (rationItem, callback) {
|
|
|
let me = this, rationID = rationItem.ID, rationGljList = rationItem.rationGljList ? rationItem.rationGljList : [], rationType = rationItem.type;
|
|
|
me.currentRationItem = rationItem;
|
|
|
if (me.cache["_GLJ_" + rationID]) {
|
|
@@ -609,11 +617,11 @@ var rationGLJOprObj = {
|
|
|
idObj.id = rationGljList[i].gljId;
|
|
|
gljIds.push(idObj);
|
|
|
}
|
|
|
- CommonAjax.post('api/getGljItemsByIds', {ids: gljIds}, function (rstData) {
|
|
|
+ CommonAjax.post('api/getGljItemsByIds', { ids: gljIds }, function (rstData) {
|
|
|
sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
|
|
|
- if(priceProperties && priceProperties.length > 0){
|
|
|
+ if (priceProperties && priceProperties.length > 0) {
|
|
|
let priceField = priceProperties[0].price.dataCode;
|
|
|
- for(let glj of rstData){
|
|
|
+ for (let glj of rstData) {
|
|
|
glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
|
|
|
}
|
|
|
}
|
|
@@ -626,7 +634,7 @@ var rationGLJOprObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- function compare(){
|
|
|
+ function compare() {
|
|
|
return function (a, b) {
|
|
|
let aV = a.gljType + a.code,
|
|
|
bV = b.gljType + b.code;
|
|
@@ -641,11 +649,11 @@ var rationGLJOprObj = {
|
|
|
cacheArr.sort(compare());
|
|
|
me.cache["_GLJ_" + rationID] = cacheArr;
|
|
|
me.showGljItems(rationID);
|
|
|
- if(callback) callback();
|
|
|
+ if (callback) callback();
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- showGljItems: function(rationID) {
|
|
|
+ showGljItems: function (rationID) {
|
|
|
var me = this;
|
|
|
if (me.cache["_GLJ_" + rationID]) {
|
|
|
sheetCommonObj.cleanData(me.sheet, me.setting, -1);
|