|
@@ -92,75 +92,46 @@ let repositoryGljObj = {
|
|
|
},
|
|
|
getGljDistType: function (callback) {
|
|
|
let me = this;
|
|
|
- $.ajax({
|
|
|
- type: 'post',
|
|
|
- url: "complementartGlj/api/getGljDistType",
|
|
|
- dataType: 'json',
|
|
|
- success: function (result) {
|
|
|
- if(!result.error && callback){
|
|
|
- me.distTypeTree = me.getComboData(result.data);
|
|
|
- console.log(me.distTypeTree);
|
|
|
- callback();
|
|
|
- }
|
|
|
+ CommonAjax.post('complementartGlj/api/getGljDistType', {}, function (rstData) {
|
|
|
+ if(callback){
|
|
|
+ me.distTypeTree = me.getComboData(rstData);
|
|
|
+ console.log(me.distTypeTree);
|
|
|
+ callback();
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
getGljTree: function(gljLibId, callback) {
|
|
|
let me = this;
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"complementartGlj/api/getGljTree",
|
|
|
- data:{"gljLibId": gljLibId},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:20000,
|
|
|
- success:function(result,textStatus,status){
|
|
|
- if(status.status == 200) {
|
|
|
- zTreeHelper.createTree(result.data, gljSetting, "repositoryTree", me);
|
|
|
- zTreeHelper.createTree(result.data, componentSetting, "componentTree", componentOprObj);
|
|
|
- if (result.data && result.data.length > 0) {
|
|
|
- me.gljCurTypeId = result.data[0].ID;
|
|
|
- } else {
|
|
|
- //重新创建库?
|
|
|
- gljTypeTreeOprObj.addRootNode();
|
|
|
- }
|
|
|
- callback();
|
|
|
- }
|
|
|
- },
|
|
|
- error:function(err){
|
|
|
- alert(err.responseJSON.error);
|
|
|
+ CommonAjax.post('complementartGlj/api/getGljTree', {gljLibId: gljLibId}, function (rstData) {
|
|
|
+ zTreeHelper.createTree(rstData, gljSetting, "repositoryTree", me);
|
|
|
+ zTreeHelper.createTree(rstData, componentSetting, "componentTree", componentOprObj);
|
|
|
+ if (rstData && rstData.length > 0) {
|
|
|
+ me.gljCurTypeId = rstData[0].ID;
|
|
|
+ } else {
|
|
|
+ //重新创建库?
|
|
|
+ // gljTypeTreeOprObj.addRootNode();
|
|
|
+ }
|
|
|
+ if(callback){
|
|
|
+ callback();
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
getGljItems: function(stdGljLibId, userId, compilationId) {
|
|
|
let me = this;
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"complementartGlj/api/getGljItems",
|
|
|
- data:{stdGljLibId: stdGljLibId, userId: userId, compilationId: compilationId},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:5000,
|
|
|
- success:function(result){
|
|
|
- if(!result.error) {
|
|
|
- me.stdGljList = result.data.stdGljs;
|
|
|
- me.complementaryGljList = result.data.complementaryGljs;
|
|
|
- me.workBook.getSheet(0).setRowCount(me.stdGljList.length);
|
|
|
- me.sortGlj(me.stdGljList);
|
|
|
- me.setProp('isStd', true, me.stdGljList);
|
|
|
- me.sortGlj(me.complementaryGljList);
|
|
|
- let rootNode = me.treeObj.getNodes()[0];
|
|
|
- if(rootNode && rootNode.isParent && rootNode.isFirstNode){
|
|
|
- componentOprObj.rootNode = rootNode;
|
|
|
- me.treeObj.selectNode(rootNode);
|
|
|
- gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- error:function(err){
|
|
|
- alert(err.responseJSON.error);
|
|
|
+ CommonAjax.post('complementartGlj/api/getGljItems', {stdGljLibId: stdGljLibId, userId: userId, compilationId: compilationId}, function (rstData) {
|
|
|
+ me.stdGljList = rstData.stdGljs;
|
|
|
+ me.complementaryGljList = rstData.complementaryGljs;
|
|
|
+ me.workBook.getSheet(0).setRowCount(me.stdGljList.length);
|
|
|
+ me.sortGlj(me.stdGljList);
|
|
|
+ me.setProp('isStd', true, me.stdGljList);
|
|
|
+ me.sortGlj(me.complementaryGljList);
|
|
|
+ let rootNode = me.treeObj.getNodes()[0];
|
|
|
+ if(rootNode && rootNode.isParent && rootNode.isFirstNode){
|
|
|
+ componentOprObj.rootNode = rootNode;
|
|
|
+ me.treeObj.selectNode(rootNode);
|
|
|
+ gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
showGljItems: function(data, type) {
|
|
|
let me = repositoryGljObj;
|
|
@@ -963,39 +934,29 @@ let repositoryGljObj = {
|
|
|
if(addArr.length > 0){
|
|
|
me.saveInString(addArr);
|
|
|
}
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"complementartGlj/api/mixUpdateGljItems",
|
|
|
- data:{userId: pageOprObj.userId, compilationId: pageOprObj.compilationId, updateItems: JSON.stringify(updateArr), addItems: JSON.stringify(addArr), removeIds: JSON.stringify(removeIds)},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:5000,
|
|
|
- success:function(result){
|
|
|
- if (result.error) {
|
|
|
- alert(result.message);
|
|
|
- me.getRationItems(me.currentRepositoryId);
|
|
|
- } else {
|
|
|
- me.updateCache(addArr, updateArr, removeIds, result);
|
|
|
- me.sortGlj(me.complementaryGljList);
|
|
|
- if(me.currentOprParent === 1){
|
|
|
- me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]);
|
|
|
- }
|
|
|
- else{
|
|
|
- me.currentCache = me.getCache();
|
|
|
- }
|
|
|
- me.showGljItems(me.complementaryGljList, me.gljCurTypeId);
|
|
|
- //getCurrentGlj
|
|
|
- let row = me.workBook.getSheet(0).getSelections()[0].row;
|
|
|
- me.currentGlj = row < me.currentCache.length ? me.currentCache[row] : null;
|
|
|
- me.currentComponent = me.currentGlj ? me.getCurrentComponent(me.currentGlj.component) : [];
|
|
|
- sheetOpr.cleanData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, -1);
|
|
|
- sheetOpr.showData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, me.currentComponent);
|
|
|
- }
|
|
|
- },
|
|
|
- error:function(err){
|
|
|
- alert("保存失败");
|
|
|
+ let url = 'complementartGlj/api/mixUpdateGljItems';
|
|
|
+ let post = {updateItems: updateArr, addItems: addArr, removeIds: removeIds};
|
|
|
+ let scCaller = function (rstData) {
|
|
|
+ me.updateCache(addArr, updateArr, removeIds, rstData);
|
|
|
+ me.sortGlj(me.complementaryGljList);
|
|
|
+ if(me.currentOprParent === 1){
|
|
|
+ me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ me.currentCache = me.getCache();
|
|
|
}
|
|
|
- })
|
|
|
+ me.showGljItems(me.complementaryGljList, me.gljCurTypeId);
|
|
|
+ //getCurrentGlj
|
|
|
+ let row = me.workBook.getSheet(0).getSelections()[0].row;
|
|
|
+ me.currentGlj = row < me.currentCache.length ? me.currentCache[row] : null;
|
|
|
+ me.currentComponent = me.currentGlj ? me.getCurrentComponent(me.currentGlj.component) : [];
|
|
|
+ sheetOpr.cleanData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, -1);
|
|
|
+ sheetOpr.showData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, me.currentComponent);
|
|
|
+ }
|
|
|
+ let errCaller = function (err) {
|
|
|
+ alert('保存失败');
|
|
|
+ };
|
|
|
+ CommonAjax.post(url, post, scCaller, errCaller);
|
|
|
},
|
|
|
saveInString: function (datas) {
|
|
|
for(let i = 0, len = datas.length; i < len; i++){
|
|
@@ -1040,7 +1001,7 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
- updateCache: function(addArr, updateArr, removeIds, result) {
|
|
|
+ updateCache: function(addArr, updateArr, removeIds, rstData) {
|
|
|
let me = this, cacheSection = me.complementaryGljList;
|
|
|
if (addArr.length > 0) {
|
|
|
me.complementaryGljList = me.complementaryGljList.concat(addArr);
|
|
@@ -1053,11 +1014,11 @@ let repositoryGljObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (result && result.data && result.data.ops && result.data.ops.length > 0) {
|
|
|
- for (let i = 0; i < result.data.ops.length; i++) {
|
|
|
+ if (rstData && rstData.ops && rstData.ops.length > 0) {
|
|
|
+ for (let i = 0; i < rstData.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"];
|
|
|
+ if (cacheSection[j][me.setting.header[0].dataCode] == rstData.ops[i][me.setting.header[0].dataCode]) {
|
|
|
+ cacheSection[j]["ID"] = rstData.ops[i]["ID"];
|
|
|
}
|
|
|
}
|
|
|
}
|