|
@@ -42,19 +42,20 @@ var rationOprObj = {
|
|
|
buildSheet: function(container) {
|
|
|
var me = rationOprObj;
|
|
|
me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
|
|
|
+ me.rationDelOpr();
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
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.RangeChanged, me.onRangeChanged);
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
|
|
|
},
|
|
|
+
|
|
|
onCellClick: function(sender, args) {
|
|
|
var me = rationOprObj,
|
|
|
sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
|
|
|
sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
|
|
|
sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting;
|
|
|
-
|
|
|
sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
|
|
|
sheetCommonObj.shieldAllCells(sheetGLJ);
|
|
|
sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
|
|
@@ -119,10 +120,77 @@ var rationOprObj = {
|
|
|
}
|
|
|
return cacheSection;
|
|
|
},
|
|
|
+ rationDelOpr: function () {
|
|
|
+ let me = rationOprObj;
|
|
|
+ me.workBook.commandManager().register('rationDelete', function () {
|
|
|
+ let rationSheet = me.workBook.getActiveSheet();
|
|
|
+ let sels = rationSheet.getSelections(), updateArr = [], removeArr = [], lockCols = me.setting.view.lockColumns;
|
|
|
+ let cacheSection = me.getCache();
|
|
|
+ console.log(`sels`);
|
|
|
+ console.log(sels);
|
|
|
+ console.log(`cache`);
|
|
|
+ console.log(cacheSection);
|
|
|
+ if(sels.length > 0){
|
|
|
+ for(let sel = 0; sel < sels.length; sel++){
|
|
|
+ if(sels[sel].colCount === me.setting.header.length){
|
|
|
+ if(cacheSection){
|
|
|
+ for(let i = 0; i < sels[sel].rowCount; i++){
|
|
|
+ if(sels[sel].row + i < cacheSection.length){
|
|
|
+ removeArr.push(cacheSection[sels[sel].row + i].ID);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if(sels[sel].col === 0){
|
|
|
+ $('#alertText').text("编号不能为空,修改失败!");
|
|
|
+ $('#alertModalBtn').click();
|
|
|
+ rationSheet.options.isProtected = true;
|
|
|
+ $('#alertModalCls').click(function () {
|
|
|
+ rationSheet.options.isProtected = false;
|
|
|
+ });
|
|
|
+ $('#alertModalCof').click(function () {
|
|
|
+ rationSheet.options.isProtected = false;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else if(sels[sel].col !== 0 && !(sels[sel].col === 3 && sels.col + sels[sel].colCount -1 === 6)){
|
|
|
+ if(cacheSection){
|
|
|
+ for(let i =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){
|
|
|
+ cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateArr.push(cacheSection[sels[sel].row + i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(`updateArr`);
|
|
|
+ console.log(updateArr);
|
|
|
+ console.log(`removeArr`);
|
|
|
+ console.log(removeArr);
|
|
|
+ if(updateArr.length > 0 || removeArr.length > 0){
|
|
|
+ //me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ 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) {
|
|
|
+ console.log(`sdad`);
|
|
|
if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
|
|
|
var me = rationOprObj, updateArr = [], removeArr = [];
|
|
|
var cacheSection = me.getCache();
|
|
|
+ console.log(`cacheSection`);
|
|
|
+ console.log(cacheSection);
|
|
|
+ console.log(`args`);
|
|
|
+ console.log(args);
|
|
|
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),
|
|
@@ -135,6 +203,16 @@ var rationOprObj = {
|
|
|
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);
|
|
@@ -146,7 +224,7 @@ var rationOprObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
+ // me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
//removeRationItems
|
|
|
}
|
|
|
}
|
|
@@ -172,12 +250,11 @@ var rationOprObj = {
|
|
|
//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),
|
|
|
updateArr = [], addArr = [];
|
|
|
- console.log(`editEnd`);
|
|
|
- console.log(rObj);
|
|
|
- if (me.currentEditingRation["ID"]) {
|
|
|
+ let dataCode = me.setting.header[args.col].dataCode;
|
|
|
+ if (me.currentEditingRation["ID"] && me.currentEditingRation[dataCode] !== args.editingText) {
|
|
|
rObj["ID"] = me.currentEditingRation["ID"];
|
|
|
updateArr.push(rObj);
|
|
|
- } else {
|
|
|
+ } else if(!me.currentEditingRation["ID"]) {
|
|
|
if (!sheetCommonObj.chkIfEmpty(rObj, me.setting)) {
|
|
|
addArr.push(rObj);
|
|
|
}
|
|
@@ -200,6 +277,8 @@ var rationOprObj = {
|
|
|
console.log(info);
|
|
|
var me = rationOprObj;
|
|
|
var cacheSection = me.getCache();
|
|
|
+ console.log(`cache`);
|
|
|
+ console.log(cacheSection);
|
|
|
var updateArr = [], addArr = [];
|
|
|
var items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
console.log(`items`);
|
|
@@ -214,15 +293,21 @@ var rationOprObj = {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (!hasCacheItem) {
|
|
|
+ if (!hasCacheItem && info.cellRange.col === 0) {
|
|
|
addArr.push(items[i]);
|
|
|
- } else {
|
|
|
+ } else if(hasCacheItem){
|
|
|
updateArr.push(items[i]);
|
|
|
}
|
|
|
} else {
|
|
|
- addArr.push(items[i])
|
|
|
+ //add
|
|
|
+ if(info.cellRange.col === 0){
|
|
|
+ addArr.push(items[i])
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
+ console.log(`updateArr`);
|
|
|
+ console.log(updateArr);
|
|
|
+ console.log(addArr);
|
|
|
if (updateArr.length > 0 || addArr.length > 0) {
|
|
|
//me.mixUpdateRequest(updateArr, addArr, []);
|
|
|
}
|
|
@@ -260,8 +345,6 @@ var rationOprObj = {
|
|
|
var me = rationOprObj;
|
|
|
me.currentSectionId = sectionID;
|
|
|
if (me.currentRations["_SEC_ID_" + sectionID]) {
|
|
|
- console.log(`currentRations`);
|
|
|
- console.log(me.currentRations);
|
|
|
me.showRationItems(sectionID);
|
|
|
///sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
|
|
|
sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
|
|
@@ -279,6 +362,7 @@ var rationOprObj = {
|
|
|
success:function(result){
|
|
|
if (result) {
|
|
|
me.currentRations["_SEC_ID_" + sectionID] = result.data;
|
|
|
+ me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
|
|
|
me.showRationItems(sectionID);
|
|
|
//sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
|
|
|
sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
|
|
@@ -315,9 +399,14 @@ var rationOprObj = {
|
|
|
sortByCode: function(arr){
|
|
|
function compare(){
|
|
|
return function (a, b) {
|
|
|
- let valA = a.code,
|
|
|
- valB = b.code;
|
|
|
- return valA - valB;
|
|
|
+ let rst = 0;
|
|
|
+ if (a.code > b.code) {
|
|
|
+ rst = 1;
|
|
|
+ }
|
|
|
+ else if (a.code < b.code) {
|
|
|
+ rst = -1;
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
}
|
|
|
}
|
|
|
arr.sort(compare());
|