|
@@ -17,36 +17,18 @@ var rationCoeOprObj = {
|
|
|
lockColumns:[1,2]
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
buildSheet: function(sheet) {
|
|
|
var me = this;
|
|
|
me.sheet = sheet;
|
|
|
me.libID = storageUtil.getSessionCache("RationGrp","repositoryID"); // 不可靠,有时取不到
|
|
|
if (me.libID == undefined){me.libID = getQueryString('repository')};
|
|
|
- //alert('0000 初始化libID: ' + JSON.stringify(me.libID));
|
|
|
sheetCommonObj.initSheet(me.sheet, me.setting, 30);
|
|
|
me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
|
|
|
me.sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
|
|
|
},
|
|
|
- onRangeChanged: function(sender, args) {
|
|
|
- if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
|
|
|
- var me = rationCoeOprObj, updateArr = [], removeArr = [];
|
|
|
- if (args.col == 0) {
|
|
|
- var curCache = me.cache["_Coe_" + me.curRation.ID];
|
|
|
- if (curCache) {
|
|
|
- for (var i = args.rowCount - 1; i >= 0; i--) {
|
|
|
- if (args.row + i < curCache.length) {
|
|
|
- curCache.splice(args.row + i, 1);
|
|
|
- };
|
|
|
- };
|
|
|
- me.updateCurRation();
|
|
|
- sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
|
|
|
- me.showCoeItems(me.curRation.ID);
|
|
|
- };
|
|
|
- };
|
|
|
- };
|
|
|
- },
|
|
|
|
|
|
onClipboardPasting: function(sender, args) {
|
|
|
var me = rationCoeOprObj;
|
|
@@ -65,13 +47,13 @@ var rationCoeOprObj = {
|
|
|
for (let obj of temp) {
|
|
|
coeIDs.push(obj.ID);
|
|
|
};
|
|
|
- //alert('0009 ' + JSON.stringify(IDs));
|
|
|
me.addCoeItems(coeIDs);
|
|
|
} else {
|
|
|
- //修改用量
|
|
|
+ //修改其它列。
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
onCellEditEnd: function(sender, args){
|
|
|
var me = rationCoeOprObj;
|
|
|
if (args.col == 0) { // 编号列
|
|
@@ -97,37 +79,68 @@ var rationCoeOprObj = {
|
|
|
};
|
|
|
},
|
|
|
|
|
|
+ onRangeChanged: function(sender, args) {
|
|
|
+ if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
|
|
|
+ var me = rationCoeOprObj, updateArr = [], removeArr = [];
|
|
|
+ if (args.col == 0) {
|
|
|
+ var curCache = me.cache["_Coe_" + me.curRation.ID];
|
|
|
+ if (curCache) {
|
|
|
+ for (var i = args.rowCount - 1; i >= 0; i--) {
|
|
|
+ if (args.row + i < curCache.length) {
|
|
|
+ curCache.splice(args.row + i, 1);
|
|
|
+ };
|
|
|
+ };
|
|
|
+ me.updateCurRation();
|
|
|
+ sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
|
|
|
+ me.showCoeItems(me.curRation.ID);
|
|
|
+ };
|
|
|
+ };
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
addCoeItems: function(coeIDs) {
|
|
|
var me = this;
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"api/getCoeItemsByIDs",
|
|
|
- data: {"data": JSON.stringify({"libID": me.libID, "coeIDs": coeIDs})},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:5000,
|
|
|
- success:function(result){
|
|
|
- sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
|
|
|
- if (result) {
|
|
|
- var rstArr = [], newAddArr = [];
|
|
|
- for (let obj of result.data){rstArr.push(obj)};
|
|
|
-
|
|
|
- var curCache = me.cache["_Coe_" + me.curRation.ID];
|
|
|
- if (curCache) {
|
|
|
- for (var i = 0; i < rstArr.length; i++) {
|
|
|
- var hasDup = false;
|
|
|
- for (let obj of curCache) {
|
|
|
- if (obj.ID == rstArr[i].ID) {
|
|
|
- hasDup = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- };
|
|
|
- if (!hasDup) {
|
|
|
- newAddArr.push(rstArr[i]);
|
|
|
- };
|
|
|
- };
|
|
|
+ sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
|
|
|
|
|
|
- curCache = curCache.concat(newAddArr);
|
|
|
+ var curCache = me.cache["_Coe_" + me.curRation.ID];
|
|
|
+ var temp = [];
|
|
|
+ if (curCache) {
|
|
|
+ for (var i = 0; i < coeIDs.length; i++) {
|
|
|
+ var isExist = false;
|
|
|
+ for (let obj of curCache) {
|
|
|
+ if (obj.ID == coeIDs[i]) {
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ };
|
|
|
+ };
|
|
|
+ if (!isExist) {
|
|
|
+ temp.push(coeIDs[i]);
|
|
|
+ };
|
|
|
+ };
|
|
|
+ }else{
|
|
|
+ for (let obj of coeIDs){temp.push(obj)};
|
|
|
+ };
|
|
|
+
|
|
|
+ if(temp.length == 0){
|
|
|
+ me.showCoeItems(me.curRation.ID);
|
|
|
+ sheetCommonObj.lockCells(me.sheet, me.setting);
|
|
|
+ }else{
|
|
|
+ $.ajax({
|
|
|
+ type:"POST",
|
|
|
+ url:"api/getCoeItemsByIDs",
|
|
|
+ data: {"data": JSON.stringify({"libID": me.libID, "coeIDs": temp})},
|
|
|
+ dataType:"json",
|
|
|
+ cache:false,
|
|
|
+ timeout:5000,
|
|
|
+ success:function(result){
|
|
|
+ if (result) {
|
|
|
+ var rstArr = [];
|
|
|
+ for (let obj of result.data){rstArr.push(obj)};
|
|
|
+ if (curCache) {
|
|
|
+ curCache = curCache.concat(rstArr);
|
|
|
+ }else{
|
|
|
+ curCache = rstArr;
|
|
|
+ }
|
|
|
|
|
|
curCache.sort(function(a, b) {
|
|
|
var rst = 0;
|
|
@@ -137,43 +150,15 @@ var rationCoeOprObj = {
|
|
|
});
|
|
|
|
|
|
me.cache["_Coe_" + me.curRation.ID] = curCache;
|
|
|
- if (newAddArr.length > 0) {
|
|
|
- me.updateCurRation();
|
|
|
- };
|
|
|
- }else{
|
|
|
- rstArr.sort(function(a, b) {
|
|
|
- var rst = 0;
|
|
|
- if (a.ID > b.ID) rst = 1
|
|
|
- else if (a.ID < b.ID) rst = -1;
|
|
|
- return rst;
|
|
|
- });
|
|
|
-
|
|
|
- me.cache["_Coe_" + me.curRation.ID] = rstArr;
|
|
|
me.updateCurRation();
|
|
|
+ me.showCoeItems(me.curRation.ID);
|
|
|
};
|
|
|
- me.showCoeItems(me.curRation.ID);
|
|
|
- };
|
|
|
- sheetCommonObj.lockCells(me.sheet, me.setting);
|
|
|
- },
|
|
|
- error:function(err){
|
|
|
- alert(err);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- updateCurRation: function() {
|
|
|
- var me = this, updateArr = [];
|
|
|
- if (me.curRation) {
|
|
|
- var rst = [];
|
|
|
- var curCache = me.cache["_Coe_" + me.curRation.ID];
|
|
|
- if (curCache) {
|
|
|
- for (let obj of curCache) {
|
|
|
- rst.push(obj.ID);
|
|
|
- };
|
|
|
- me.curRation.rationCoeList = rst;
|
|
|
- updateArr.push(me.curRation);
|
|
|
- rationOprObj.mixUpdateRequest(updateArr, [], []);
|
|
|
- };
|
|
|
+ sheetCommonObj.lockCells(me.sheet, me.setting);
|
|
|
+ },
|
|
|
+ error:function(err){
|
|
|
+ alert(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -187,13 +172,11 @@ var rationCoeOprObj = {
|
|
|
var coeList = ration.rationCoeList;
|
|
|
var curCache = me.cache["_Coe_" + ration.ID];
|
|
|
|
|
|
- //alert('0001 缓存:' + JSON.stringify(curCache));
|
|
|
if (curCache && curCache.length > 0) {
|
|
|
me.showCoeItems(ration.ID);
|
|
|
sheetCommonObj.lockCells(me.sheet, me.setting);
|
|
|
} else {
|
|
|
var data = {"libID": me.libID, "coeIDs": coeList};
|
|
|
- //alert('0002 进入后台:' + JSON.stringify(data));
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url:"api/getCoeItemsByIDs",
|
|
@@ -203,7 +186,6 @@ var rationCoeOprObj = {
|
|
|
timeout:5000,
|
|
|
success:function(result){
|
|
|
sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
|
|
|
- //alert('0003 后台结果:' + JSON.stringify(result.data));
|
|
|
if (result.data) {
|
|
|
var tempResult = [];
|
|
|
for (let obj of result.data) {
|
|
@@ -229,6 +211,21 @@ var rationCoeOprObj = {
|
|
|
if (curCache) {
|
|
|
sheetCommonObj.showData(me.sheet, me.setting, curCache);
|
|
|
}
|
|
|
- rationOprObj.workBook.focus(true);
|
|
|
+ },
|
|
|
+
|
|
|
+ updateCurRation: function() {
|
|
|
+ var me = this, updateArr = [];
|
|
|
+ if (me.curRation) {
|
|
|
+ var rst = [];
|
|
|
+ var curCache = me.cache["_Coe_" + me.curRation.ID];
|
|
|
+ if (curCache) {
|
|
|
+ for (let obj of curCache) {
|
|
|
+ rst.push(obj.ID);
|
|
|
+ };
|
|
|
+ me.curRation.rationCoeList = rst;
|
|
|
+ updateArr.push(me.curRation);
|
|
|
+ rationOprObj.mixUpdateRequest(updateArr, [], []);
|
|
|
+ };
|
|
|
+ };
|
|
|
}
|
|
|
}
|