|
@@ -10,7 +10,7 @@ $("#fuzhu").click(function(){
|
|
|
$(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
|
|
|
});
|
|
|
|
|
|
-var rationOprObj = {
|
|
|
+let rationOprObj = {
|
|
|
workBook: null,
|
|
|
currentRations: {},
|
|
|
currentEditingRation: null,
|
|
@@ -21,7 +21,7 @@ var rationOprObj = {
|
|
|
header:[
|
|
|
{headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
|
|
|
{headerName:"名称",headerWidth:280,dataCode:"name", dataType: "String"},
|
|
|
- {headerName:"单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center"},
|
|
|
+ {headerName:"计量单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center"},
|
|
|
{headerName:"人工费",headerWidth:120,dataCode:"labourPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
|
|
|
{headerName:"材料费",headerWidth:120,dataCode:"materialPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
|
|
|
{headerName:"机械费",headerWidth:120,dataCode:"machinePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
|
|
@@ -43,7 +43,7 @@ var rationOprObj = {
|
|
|
},
|
|
|
buildSheet: function(container) {
|
|
|
let rationRepId = getQueryString("repository");
|
|
|
- var me = rationOprObj;
|
|
|
+ let me = rationOprObj;
|
|
|
let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
|
|
|
if(!gljLibID || typeof gljLibID === 'undefined' || gljLibID == -1){
|
|
|
alert("没有引用工料机库!");
|
|
@@ -57,12 +57,11 @@ var rationOprObj = {
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
|
|
|
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.RangeChanged, me.onRangeChanged);
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
|
|
|
},
|
|
|
|
|
|
onCellClick: function(sender, args) {
|
|
|
- var me = rationOprObj,
|
|
|
+ let me = rationOprObj,
|
|
|
sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
|
|
|
sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
|
|
|
sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting;
|
|
@@ -74,7 +73,7 @@ var rationOprObj = {
|
|
|
sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
|
|
|
sheetCommonObj.shieldAllCells(sheetAss);
|
|
|
if(!(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader || args.sheetArea === GC.Spread.Sheets.SheetArea.corner)){
|
|
|
- var cacheSection = me.getCache();
|
|
|
+ let cacheSection = me.getCache();
|
|
|
if (cacheSection && args.row < cacheSection.length) {
|
|
|
rationGLJOprObj.getGljItems(cacheSection[args.row], function () {
|
|
|
me.workBook.focus(true);
|
|
@@ -92,7 +91,7 @@ var rationOprObj = {
|
|
|
},
|
|
|
|
|
|
getCache: function() {
|
|
|
- var me = this, rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
+ let me = this, rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
if (!(rst)) {
|
|
|
me.currentRations["_SEC_ID_" + me.currentSectionId] = [];
|
|
|
rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
@@ -100,21 +99,21 @@ var rationOprObj = {
|
|
|
return rst;
|
|
|
},
|
|
|
updateCache: function(addArr, updateArr, removeIds, result) {
|
|
|
- var me = this, cacheSection = me.getCache();
|
|
|
+ let me = this, cacheSection = me.getCache();
|
|
|
if (addArr.length > 0) {
|
|
|
me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
|
|
|
cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
}
|
|
|
- for (var i = removeIds.length - 1; i >= 0; i--) {
|
|
|
- for (var j = cacheSection.length - 1; j >= 0 ; j--) {
|
|
|
+ for (let i = removeIds.length - 1; i >= 0; i--) {
|
|
|
+ for (let j = cacheSection.length - 1; j >= 0 ; j--) {
|
|
|
if (cacheSection[j]["ID"] == removeIds[i]) {
|
|
|
cacheSection.splice(j,1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (result && result.data.ops && result.data.ops.length > 0) {
|
|
|
- for (var i = 0; i < result.data.ops.length; i++) {
|
|
|
- for (var j = 0; j < cacheSection.length; j++) {
|
|
|
+ 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]) {
|
|
|
cacheSection[j]["ID"] = result.data.ops[i]["ID"];
|
|
|
cacheSection[j]["rationGljList"] = result.data.ops[i]["rationGljList"];
|
|
@@ -122,8 +121,8 @@ var rationOprObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- for (var i = 0; i < updateArr.length; i++) {
|
|
|
- for (var j = 0; j < cacheSection.length; j++) {
|
|
|
+ for (let i = 0; i < updateArr.length; i++) {
|
|
|
+ for (let j = 0; j < cacheSection.length; j++) {
|
|
|
if (updateArr[i]["ID"] && cacheSection[j]["ID"]) {
|
|
|
if (cacheSection[j]["ID"] == updateArr[i]["ID"]) {
|
|
|
cacheSection[j] = updateArr[i];
|
|
@@ -195,48 +194,6 @@ var rationOprObj = {
|
|
|
me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
me.workBook.commandManager().setShortcutKey('rationDelete', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
},
|
|
|
- onRangeChanged: function(sender, args) {
|
|
|
- if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
|
|
|
- var me = rationOprObj, updateArr = [], removeArr = [];
|
|
|
- var cacheSection = me.getCache();
|
|
|
- if (cacheSection) {
|
|
|
- for (var i = 0; i < args.rowCount; i++) {
|
|
|
- //var hasUpdate = false, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i),
|
|
|
- var hasUpdate = false, rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row + i),
|
|
|
- isEmpty = sheetCommonObj.chkIfEmpty(rObj, me.setting);
|
|
|
- for (var j = 0; j < cacheSection.length; j++) {
|
|
|
- if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
|
|
|
- rObj["ID"] = cacheSection[j]["ID"];
|
|
|
- hasUpdate = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if(isEmpty){
|
|
|
- if(args.row + i < cacheSection.length){
|
|
|
- rObj.ID = cacheSection[args.row + i].ID;
|
|
|
- removeArr.push(rObj.ID);
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (hasUpdate) {
|
|
|
- if (isEmpty) {
|
|
|
- removeArr.push(rObj);
|
|
|
- } else updateArr.push(rObj);
|
|
|
- } else if (isEmpty) {
|
|
|
- if (args.row + i < cacheSection.length) {
|
|
|
- rObj["ID"] = cacheSection[args.row + i]["ID"];
|
|
|
- removeArr.push(rObj["ID"]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
- //removeRationItems
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
onEnterCell: function (sender, args) {
|
|
|
let me = rationOprObj;
|
|
|
me.cellRowIdx = args.row;
|
|
@@ -252,17 +209,14 @@ var rationOprObj = {
|
|
|
if(isHasData){
|
|
|
if(me.editingRowIdx !== me.cellRowIdx) {
|
|
|
let focusToCol = !me.addRationItem.code ? 0 : -1;
|
|
|
- // else {
|
|
|
if(focusToCol !== -1){
|
|
|
$('#rationAlertBtn').click();
|
|
|
me.workBook.getSheet(0).options.isProtected = true;
|
|
|
$('#rationAlertCac').click(function () {
|
|
|
me.workBook.getSheet(0).options.isProtected = false;
|
|
|
- //me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
|
|
|
});
|
|
|
$('#rationAlertCls').click(function () {
|
|
|
me.workBook.getSheet(0).options.isProtected = false;
|
|
|
- // me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
|
|
|
});
|
|
|
$('#rationAlertCof').click(function () {
|
|
|
me.workBook.getSheet(0).options.isProtected = false;
|
|
@@ -270,21 +224,18 @@ var rationOprObj = {
|
|
|
for(let col=0; col<me.setting.header.length; col++){
|
|
|
me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingRation[me.setting.header[col].dataCode]);
|
|
|
}
|
|
|
- //me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
|
|
|
});
|
|
|
}
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
onCellEditStart: function(sender, args) {
|
|
|
- var me = rationOprObj;
|
|
|
- //var rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
|
|
|
- var rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row);
|
|
|
+ let me = rationOprObj;
|
|
|
+ let rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row);
|
|
|
me.currentEditingRation = rObj;
|
|
|
- var cacheSection = me.getCache();
|
|
|
+ let cacheSection = me.getCache();
|
|
|
if (cacheSection) {
|
|
|
- for (var j = 0; j < cacheSection.length; j++) {
|
|
|
+ for (let j = 0; j < cacheSection.length; j++) {
|
|
|
if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
|
|
|
rObj["ID"] = cacheSection[j]["ID"];
|
|
|
break;
|
|
@@ -293,8 +244,7 @@ var rationOprObj = {
|
|
|
}
|
|
|
},
|
|
|
onCellEditEnd: function(sender, args) {
|
|
|
- //var me = rationOprObj, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row),
|
|
|
- var me = rationOprObj, rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
|
|
|
+ let me = rationOprObj, rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
|
|
|
updateArr = [], addArr = [];
|
|
|
let dataCode = me.setting.header[args.col].dataCode;
|
|
|
me.editingRowIdx = args.row;
|
|
@@ -367,23 +317,19 @@ var rationOprObj = {
|
|
|
}
|
|
|
},
|
|
|
onClipboardPasting: function(sender, args) {
|
|
|
- var me = rationOprObj;
|
|
|
- /* if (args.cellRange.colCount != me.setting.header.length) {
|
|
|
- args.cancel = true;
|
|
|
- }*/
|
|
|
+ let me = rationOprObj;
|
|
|
},
|
|
|
onClipboardPasted: function(e, info) {
|
|
|
- var me = rationOprObj;
|
|
|
- var cacheSection = me.getCache();
|
|
|
- var updateArr = [], addArr = [];
|
|
|
- var items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
+ let me = rationOprObj;
|
|
|
+ let cacheSection = me.getCache();
|
|
|
+ let updateArr = [], addArr = [];
|
|
|
+ let items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
let failPasteArr = [];
|
|
|
- for (var i = 0, rowIdx =info.cellRange.row; i < items.length; i++, rowIdx++) {
|
|
|
+ for (let i = 0, rowIdx =info.cellRange.row; i < items.length; i++, rowIdx++) {
|
|
|
if (cacheSection) {
|
|
|
if(!me.isValidUnit(items[i], rationUnits)){//无效单位
|
|
|
items[i].unit = typeof cacheSection[rowIdx].unit !== 'undefined' && !cacheSection[rowIdx] ? cacheSection[rowIdx].unit : '';
|
|
|
}
|
|
|
- //var hasCacheItem = false;
|
|
|
if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
|
|
|
if(me.rationsCodes.indexOf(items[i].code) === -1){
|
|
|
//jobConten
|
|
@@ -477,7 +423,7 @@ var rationOprObj = {
|
|
|
})
|
|
|
},
|
|
|
mixUpdateRequest: function(updateArr, addArr, removeIds) {
|
|
|
- var me = rationOprObj;
|
|
|
+ let me = rationOprObj;
|
|
|
sheetCommonObj.setLockCol(me.workBook.getSheet(0), 0, true);
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
@@ -491,21 +437,27 @@ var rationOprObj = {
|
|
|
alert(`error`);
|
|
|
me.getRationItems(me.currentSectionId);
|
|
|
} else {
|
|
|
- var cacheSection = me.updateCache(addArr, updateArr, removeIds, result);
|
|
|
+ let cacheSection = me.updateCache(addArr, updateArr, removeIds, result);
|
|
|
cacheSection.sort(function(a, b){
|
|
|
- var rst = 0;
|
|
|
+ let rst = 0;
|
|
|
if (a.code > b.code) rst = 1
|
|
|
else if (a.code < b.code) rst = -1;
|
|
|
return rst;
|
|
|
});
|
|
|
//jobContent
|
|
|
- if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.PARTIAL){
|
|
|
+ if(jobContentOprObj ){
|
|
|
jobContentOprObj.currentRationItems = cacheSection;
|
|
|
- jobContentOprObj.buildTablePartial(jobContentOprObj.tablePartial, jobContentOprObj.getGroup(cacheSection));
|
|
|
+ jobContentOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, jobContentOprObj.radios);
|
|
|
+ if(cacheSection.length === 0){
|
|
|
+ jobContentOprObj.updateSituation(pageOprObj.rationLibId, me.currentSectionId, 'NONE');
|
|
|
+ }
|
|
|
+ jobContentOprObj.setRadiosChecked(jobContentOprObj.currentSituation, jobContentOprObj.radios);
|
|
|
+ if(jobContentOprObj.currentSituation === jobContentOprObj.situations.PARTIAL){
|
|
|
+ jobContentOprObj.buildTablePartial(jobContentOprObj.tablePartial, jobContentOprObj.getGroup(cacheSection));
|
|
|
+ }
|
|
|
}
|
|
|
me.showRationItems(me.currentSectionId);
|
|
|
me.mixUpdate = 0;
|
|
|
- // me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
|
|
|
}
|
|
|
sheetCommonObj.setLockCol(me.workBook.getSheet(0), 0, false);
|
|
|
},
|
|
@@ -515,7 +467,7 @@ var rationOprObj = {
|
|
|
},
|
|
|
getRationItems: function(sectionID){
|
|
|
if (sectionID != -1) {
|
|
|
- var me = rationOprObj;
|
|
|
+ let me = rationOprObj;
|
|
|
me.mixUpdate = 0;
|
|
|
me.currentSectionId = sectionID;
|
|
|
if (me.currentRations["_SEC_ID_" + sectionID]) {
|
|
@@ -576,13 +528,13 @@ var rationOprObj = {
|
|
|
sheet.resumePaint();
|
|
|
},
|
|
|
showRationItems: function(sectionID){
|
|
|
- var me = rationOprObj;
|
|
|
+ let me = rationOprObj;
|
|
|
if (me.workBook) {
|
|
|
if (me.currentRations && me.currentRations["_SEC_ID_" + sectionID] && me.currentRations["_SEC_ID_" + sectionID].length > 0) {
|
|
|
- var cacheSection = me.currentRations["_SEC_ID_" + sectionID];
|
|
|
+ let cacheSection = me.currentRations["_SEC_ID_" + sectionID];
|
|
|
//sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
|
|
|
- sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
|
|
|
+ sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
|
|
|
sheetCommonObj.setLockCol(me.workBook.getSheet(0), 4, true);
|
|
|
//combo
|
|
|
me.setCombo(me.workBook.getActiveSheet(), rationUnits);
|