ration_glj.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /**
  2. * Created by Tony on 2017/4/28.
  3. */
  4. var rationGLJOprObj = {
  5. sheet: null,
  6. currentRationItem: null,
  7. distTypeTree: null,
  8. activeCell: null,
  9. cache: {},
  10. setting: {
  11. header:[
  12. {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
  13. {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String"},
  14. {headerName:"规格",headerWidth:120,dataCode:"specs", dataType: "String"},
  15. {headerName:"单位",headerWidth:160,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
  16. {headerName:"基价单价",headerWidth:160, dataCode:"basePrice", dataType: "Number", formatter:"0.00", precision: 2},
  17. {headerName:"定额消耗",headerWidth:160, dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", precision: 3},
  18. {headerName:"类型",headerWidth:160,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"}
  19. ],
  20. view:{
  21. comboBox:[],
  22. lockColumns:[1,2,3,4,6]
  23. }
  24. },
  25. getDistTypeTree: function (gljDistType) {
  26. let me = this;
  27. let distType;
  28. let distTypeTree = {
  29. prefix : 'gljDistType',
  30. distTypes: {},
  31. comboDatas: [],
  32. distTypesArr: []
  33. };
  34. gljDistType.forEach(function (typeData) {
  35. let typeObj = {
  36. data: typeData,
  37. children: [],
  38. parent: null
  39. }
  40. distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
  41. distTypeTree.distTypesArr.push(typeObj);
  42. });
  43. gljDistType.forEach(function (typeData) {
  44. distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
  45. let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
  46. if(parent){
  47. distType.parent = parent;
  48. parent.children.push(distType);
  49. }
  50. });
  51. distTypeTree.distTypesArr.forEach(function (distTypeObj) {
  52. if(distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' &&distTypeObj.data.fullName !== '机械组成物'
  53. && distTypeObj.data.fullName !== '机上人工'){
  54. distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
  55. }
  56. if(distTypeObj.data.fullName === '机械'){
  57. distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
  58. }
  59. });
  60. return distTypeTree;
  61. },
  62. getGljDistType: function (callback) {
  63. let me = this;
  64. $.ajax({
  65. type: 'post',
  66. url: "api/getGljDistType",
  67. dataType: 'json',
  68. success: function (result) {
  69. if(!result.error && callback){
  70. me.distTypeTree = me.getDistTypeTree(result.data);
  71. callback();
  72. }
  73. }
  74. })
  75. },
  76. buildSheet: function(sheet) {
  77. var me = this;
  78. me.sheet = sheet;
  79. me.getGljDistType(function () {
  80. me.onContextmenuOpr();
  81. sheetCommonObj.initSheet(me.sheet, me.setting, 30);
  82. me.rationGljDelOpr();
  83. me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
  84. me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
  85. me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
  86. //me.sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
  87. });
  88. },
  89. rationGljDelOpr: function () {
  90. let me = rationGLJOprObj, spreadBook = me.sheet.getParent();
  91. spreadBook.commandManager().register('rationGljDelete', function () {
  92. let sels = me.sheet.getSelections(), updateArr = [], removeArr = [], lockCols = me.setting.view.lockColumns;
  93. let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID], isUpdate = false;
  94. if(sels.length > 0){
  95. for(let sel = 0; sel < sels.length; sel++){
  96. if(sels[sel].colCount === me.setting.header.length){
  97. if(cacheSection){
  98. for(let i = 0; i < sels[sel].rowCount; i++){
  99. if(sels[sel].row + i < cacheSection.length){
  100. isUpdate = true;
  101. cacheSection.splice(sels[sel].row + i, 1);
  102. }
  103. }
  104. }
  105. }
  106. else{
  107. if(sels[sel].col === 0){
  108. $('#alertText').text("编号不能为空,修改失败!");
  109. $('#alertModalBtn').click();
  110. me.sheet.options.isProtected = true;
  111. $('#alertModalCls').click(function () {
  112. me.sheet.options.isProtected = false;
  113. });
  114. $('#alertModalCof').click(function () {
  115. me.sheet.options.isProtected = false;
  116. });
  117. }
  118. else if(sels[sel].col !== 0 && sels[sel].col !== 5 && !(sels[sel].col === 1 && sels.col + sels[sel].colCount -1 === 3)){
  119. if(cacheSection){
  120. for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
  121. if(sels[sel].row + i < cacheSection.length){
  122. for(let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++){
  123. if(lockCols.indexOf(col) === -1){
  124. isUpdate = true;
  125. cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = 0;
  126. me.sheet.setValue(sels[sel].row + i, col, 0.00);
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }
  136. if(isUpdate){
  137. me.updateRationItem();
  138. sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
  139. me.showGljItems(me.currentRationItem.ID);
  140. }
  141. /* if(updateArr.length > 0 || removeArr.length > 0){
  142. me.mixUpdateRequest(updateArr, [], removeArr);
  143. }*/
  144. });
  145. spreadBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  146. spreadBook.commandManager().setShortcutKey('rationGljDelete', GC.Spread.Commands.Key.del, false, false, false, false);
  147. },
  148. onRangeChanged: function(sender, args) {
  149. if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
  150. var me = rationGLJOprObj, updateArr = [], removeArr = [];
  151. if (args.col == 0) {
  152. if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
  153. var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
  154. for (var i = args.rowCount - 1; i >= 0; i--) {
  155. if (args.row + i < cacheArr.length) {
  156. cacheArr.splice(args.row + i, 1);
  157. }
  158. }
  159. me.updateRationItem();
  160. sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
  161. me.showGljItems(me.currentRationItem.ID);
  162. }
  163. }
  164. }
  165. },
  166. onClipboardPasting: function(sender, args) {
  167. var me = rationGLJOprObj;
  168. /*if (args.cellRange.colCount != 1 || args.cellRange.col != 0 || !(me.currentRationItem)) {
  169. args.cancel = true;
  170. }*/
  171. },
  172. onClipboardPasted: function(e, info) {
  173. var me = rationGLJOprObj, repId = storageUtil.getSessionCache("RationGrp","repositoryID");
  174. if (repId) {
  175. let gljLibId = storageUtil.getSessionCache("gljLib", "repositoryID_" + repId);
  176. if(gljLibId){
  177. if (info.cellRange.col == 0) {
  178. let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
  179. var tmpCodes = sheetCommonObj.analyzePasteData({header:[{dataCode: "code"}] }, info);
  180. var codes = [];
  181. for (var i = 0; i < tmpCodes.length; i++) {
  182. let rowIdx = info.cellRange.row + i;
  183. if(rowIdx < cacheArr.length){//更新
  184. cacheArr.splice(rowIdx--, 1);
  185. }
  186. codes.push(tmpCodes[i].code);
  187. }
  188. me.addGljItems(codes, gljLibId, info.cellRange);
  189. } else {
  190. //修改用量
  191. if(me.cache["_GLJ_" + me.currentRationItem.ID] && info.cellRange.row < me.cache["_GLJ_" + me.currentRationItem.ID].length){
  192. let tempConsumes = sheetCommonObj.analyzePasteData(me.setting, info);
  193. let maxCount = info.cellRange.row + info.cellRange.rowCount -1 > me.cache["_GLJ_" + me.currentRationItem.ID].length -1 ?
  194. me.cache["_GLJ_" + me.currentRationItem.ID].length - info.cellRange.row : info.cellRange.rowCount;
  195. for(let i = 0; i < maxCount; i++){
  196. let roundCons = me.round(tempConsumes[i].consumeAmt, 3);
  197. me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = roundCons;
  198. }
  199. me.updateRationItem();
  200. if(info.cellRange.row + info.cellRange.rowCount -1 >= me.cache["_GLJ_" + me.currentRationItem.ID].length -1){
  201. me.sheet.suspendPaint();
  202. for(let rowIdx = me.cache["_GLJ_" + me.currentRationItem.ID].length; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx++){
  203. me.sheet.setValue(rowIdx, info.cellRange.col, '');
  204. }
  205. me.sheet.resumePaint();
  206. }
  207. }
  208. else if(info.cellRange.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
  209. me.sheet.suspendPaint();
  210. for(let rowIdx = info.cellRange.row; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx ++){
  211. me.sheet.setValue(rowIdx, info.cellRange.col, '');
  212. }
  213. me.sheet.resumePaint();
  214. }
  215. }
  216. }
  217. }
  218. },
  219. onCellEditEnd: function(sender, args){
  220. var me = rationGLJOprObj;
  221. var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
  222. if (args.col != 0) {
  223. if (args.row < cacheArr.length) {
  224. var editGlj = cacheArr[args.row];
  225. if (editGlj["consumeAmt"] != args.editingText) {
  226. let parseNum = parseFloat(args.editingText);
  227. if(isNaN(parseFloat(args.editingText))){
  228. $('#alertModalBtn').click();
  229. $('#alertText').text("定额消耗只能输入数值!");
  230. args.sheet.options.isProtected = true;
  231. $('#alertModalCls').click(function () {
  232. args.sheet.options.isProtected = false;
  233. args.sheet.setValue(args.row, args.col, editGlj['consumeAmt']);
  234. });
  235. $('#alertModalCof').click(function () {
  236. args.sheet.options.isProtected = false;
  237. args.sheet.setValue(args.row, args.col, editGlj['consumeAmt']);
  238. })
  239. }
  240. else{
  241. args.sheet.setValue(args.row, args.col, parseNum);
  242. let roundNum = me.round(parseNum, 3);
  243. editGlj["consumeAmt"] = roundNum;
  244. me.updateRationItem();
  245. }
  246. }
  247. }
  248. } else {
  249. if(args.editingText && args.editingText.toString().trim().length !== 0){
  250. let isExist = false;
  251. for(let i = 0, len = cacheArr.length; i < len; i++){
  252. if(cacheArr[i].code === args.editingText && i !== args.row){
  253. isExist = true;
  254. break;
  255. }
  256. }
  257. if(isExist){
  258. alert("该工料机已存在!");
  259. args.sheet.setValue(args.row, args.col, typeof cacheArr[args.row] !== 'undefined' ? cacheArr[args.row].code + '' : '');
  260. }
  261. else{
  262. if(args.row < cacheArr.length && args.editingText !== cacheArr[args.row].code){//更新
  263. cacheArr.splice(args.row, 1);
  264. let rationRepId = storageUtil.getSessionCache("RationGrp","repositoryID");
  265. let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
  266. let codes = [];
  267. codes.push(args.editingText.toString().trim());
  268. me.addGljItems(codes, gljLibID, args);
  269. }
  270. else if(args.row >= cacheArr.length){//新增
  271. let rationRepId = storageUtil.getSessionCache("RationGrp","repositoryID");
  272. let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
  273. if (gljLibID) {
  274. var codes = [];
  275. codes.push(args.editingText.toString().trim());
  276. me.addGljItems(codes, gljLibID, args);
  277. }
  278. }
  279. }
  280. }
  281. }
  282. },
  283. onContextmenuOpr: function () {
  284. let me = rationGLJOprObj;
  285. $.contextMenu({
  286. selector: '#rdSpread',
  287. build: function ($triggerElement, e) {
  288. //控制允许右键菜单在哪个位置出现
  289. let sheet = me.sheet;
  290. let offset = $triggerElement.offset(),
  291. x = e.pageX - offset.left,
  292. y = e.pageY - offset.top;
  293. let target = sheet.hitTest(x, y);
  294. if(sheet.parent.getActiveSheetIndex() === 0){
  295. let delDis = true;
  296. let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID];
  297. if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
  298. sheet.setActiveCell(target.row, target.col);
  299. if(target.row < cacheSection.length){
  300. delDis = false;
  301. }
  302. }
  303. return {
  304. callback: function(key, options) {
  305. },
  306. items: {
  307. /*"insert": {name: "插入", callback: function (key, opt) {
  308. }},*/
  309. "delete": {name: "删除", icon: 'fa-remove', disabled: delDis, callback: function (key, opt) {
  310. cacheSection.splice(target.row, 1);
  311. me.updateRationItem();
  312. sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
  313. me.showGljItems(me.currentRationItem.ID);
  314. }}
  315. }
  316. };
  317. }
  318. else{
  319. return false;
  320. }
  321. }
  322. });
  323. },
  324. addGljItems: function(codes, repId, args) {
  325. var me = this;
  326. $.ajax({
  327. type:"POST",
  328. url:"api/getGljItemsByCodes",
  329. data:{"gljCodes": JSON.stringify(codes), repId: repId},
  330. dataType:"json",
  331. cache:false,
  332. timeout:5000,
  333. success:function(result){
  334. //sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
  335. if (result) {
  336. if(result.data.length > 0){
  337. sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
  338. var rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
  339. for (var i = 0; i < result.data.length; i++) {
  340. dummyR.gljId = result.data[i].ID;
  341. rstArr.push(me.createRationGljDisplayItem(dummyR, result.data[i]));
  342. }
  343. if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
  344. var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
  345. for (var i = 0; i < rstArr.length; i++) {
  346. var hasDup = false;
  347. for (var j = 0; j < cacheArr.length; j++) {
  348. if (cacheArr[j].gljId == rstArr[i].gljId) {
  349. hasDup = true;
  350. break;
  351. }
  352. }
  353. if (!hasDup) {
  354. newAddArr.push(rstArr[i]);
  355. }
  356. }
  357. me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(newAddArr);
  358. me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
  359. var rst = 0;
  360. if (a.code > b.code) rst = 1
  361. else if (a.code < b.code) rst = -1;
  362. return rst;
  363. });
  364. }
  365. me.showGljItems(me.currentRationItem.ID);
  366. if (newAddArr.length > 0) {
  367. me.updateRationItem();
  368. }
  369. }
  370. else{
  371. $('#alertModalBtn').click();
  372. $('#alertText').text("工料机"+ codes + "不存在,请查找你所需要的工料机,或新增工料机");
  373. me.sheet.options.isProtected = true;
  374. $('#alertModalCls').click(function () {
  375. sheetCommonObj.lockCells(me.sheet, me.setting);
  376. me.showGljItems(me.currentRationItem.ID);
  377. me.sheet.setValue(args.row, args.col, '');
  378. });
  379. $('#alertModalCof').click(function () {
  380. sheetCommonObj.lockCells(me.sheet, me.setting);
  381. me.showGljItems(me.currentRationItem.ID);
  382. me.sheet.setValue(args.row, args.col, '');
  383. })
  384. }
  385. }
  386. sheetCommonObj.lockCells(me.sheet, me.setting);
  387. },
  388. error:function(err){
  389. alert(err);
  390. }
  391. })
  392. },
  393. round(v, e){
  394. var t=1;
  395. for(;e>0;t*=10,e--);
  396. for(;e<0;t/=10,e++);
  397. return Math.round(v*t)/t;
  398. },
  399. rationCal: function () {
  400. let me = rationGLJOprObj;
  401. let price = {gljType1: [], gljType2: [], gljType3: []}, rst = {labourPrice: 0, materialPrice: 0, machinePrice: 0}, rationBasePrc = 0;
  402. if(me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]){
  403. let cacheArr = me.cache['_GLJ_' + me.currentRationItem.ID];
  404. cacheArr.forEach(function (gljData) {
  405. if(gljData.gljType && gljData.basePrice && gljData.consumeAmt){
  406. let parent = me.distTypeTree.distTypes[me.distTypeTree.prefix + gljData.gljType].parent;
  407. if(parent && parent.data.ID <= 3){
  408. price['gljType' + parent.data.ID].push(me.round( gljData.basePrice * gljData.consumeAmt, 3));//取三位
  409. }
  410. if(!parent && gljData.gljType <= 3){
  411. price['gljType' + gljData.gljType].push(me.round( gljData.basePrice * gljData.consumeAmt, 3));//取三位
  412. }
  413. }
  414. });
  415. if(price.gljType1.length > 0){
  416. let labourPrice = 0;
  417. price.gljType1.forEach(function (singlePrc) {
  418. labourPrice += singlePrc;
  419. });
  420. let roundPrice = me.round(labourPrice, 2);
  421. rst.labourPrice = roundPrice;
  422. rationBasePrc += roundPrice;
  423. }
  424. if(price.gljType2.length > 0){
  425. let materialPrice = 0;
  426. price.gljType2.forEach(function (singlePrc) {
  427. materialPrice += singlePrc;
  428. });
  429. let roundPrice = me.round(materialPrice, 2);
  430. rst.materialPrice = roundPrice;
  431. rationBasePrc += roundPrice;
  432. }
  433. if(price.gljType3.length > 0){
  434. let machinePrice = 0;
  435. price.gljType3.forEach(function (singlePrc) {
  436. machinePrice += singlePrc;
  437. });
  438. let roundPrice = me.round(machinePrice, 2);
  439. rst.machinePrice = roundPrice;
  440. rationBasePrc += roundPrice;
  441. }
  442. rst.rationBasePrc = rationBasePrc;
  443. }
  444. return rst;
  445. },
  446. updateRationItem: function() {
  447. var me = this, updateArr = [];
  448. if (me.currentRationItem) {
  449. me.currentRationItem.rationGljList = me.buildRationItemGlj();
  450. //recalculate ration basePrice
  451. let price = me.rationCal();
  452. me.currentRationItem.labourPrice = price.labourPrice;
  453. me.currentRationItem.materialPrice = price.materialPrice;
  454. me.currentRationItem.machinePrice = price.machinePrice;
  455. me.currentRationItem.basePrice = price.rationBasePrc;
  456. updateArr.push(me.currentRationItem);
  457. rationOprObj.mixUpdateRequest(updateArr, [], []);
  458. }
  459. },
  460. buildRationItemGlj: function(){
  461. var me = this, rst = [];
  462. if (me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]) {
  463. var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
  464. for (var i = 0; i < cacheArr.length; i++) {
  465. rst.push({gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, proportion: 0});
  466. }
  467. }
  468. return rst;
  469. },
  470. createRationGljDisplayItem: function(rItem, repGlj) {
  471. var rst = {};
  472. rst.gljId = rItem.gljId;
  473. rst.consumeAmt = rItem.consumeAmt;
  474. rst.code = repGlj.code;
  475. rst.name = repGlj.name;
  476. rst.specs = repGlj.specs;
  477. rst.unit = repGlj.unit;
  478. rst.basePrice = repGlj.basePrice;
  479. rst.gljType = repGlj.gljType;
  480. return rst;
  481. },
  482. getGljItems: function(rationItem, callback) {
  483. var me = this, rationID = rationItem.ID, rationGljList = rationItem.rationGljList;
  484. me.currentRationItem = rationItem;
  485. if (me.cache["_GLJ_" + rationID]) {
  486. me.showGljItems(rationID);
  487. sheetCommonObj.lockCells(me.sheet, me.setting);
  488. } else {
  489. var gljIds = [];
  490. for (var i = 0; i < rationGljList.length; i++) {
  491. gljIds.push(rationGljList[i].gljId);
  492. }
  493. $.ajax({
  494. type:"POST",
  495. url:"api/getGljItemsByIds",
  496. data:{"gljIds": JSON.stringify(gljIds)},
  497. dataType:"json",
  498. cache:false,
  499. timeout:5000,
  500. success:function(result){
  501. sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
  502. if (result) {
  503. var cacheArr = [];
  504. for (var i = 0; i < result.data.length; i++) {
  505. for (var j = 0; j < rationGljList.length; j++) {
  506. if (rationGljList[j].gljId == result.data[i].ID) {
  507. cacheArr.push(me.createRationGljDisplayItem(rationGljList[j], result.data[i]));
  508. break;
  509. }
  510. }
  511. }
  512. function compare(){
  513. return function (a, b) {
  514. let rst = 0;
  515. if (a.code > b.code) {
  516. rst = 1;
  517. }
  518. else if (a.code < b.code) {
  519. rst = -1;
  520. }
  521. return rst;
  522. }
  523. }
  524. cacheArr.sort(compare());
  525. me.cache["_GLJ_" + rationID] = cacheArr;
  526. me.showGljItems(rationID);
  527. }
  528. sheetCommonObj.lockCells(me.sheet, me.setting);
  529. callback();
  530. },
  531. error:function(err){
  532. alert(err);
  533. }
  534. })
  535. }
  536. },
  537. showGljItems: function(rationID) {
  538. var me = this;
  539. if (me.cache["_GLJ_" + rationID]) {
  540. sheetCommonObj.showData(me.sheet, me.setting, me.cache["_GLJ_" + rationID], me.distTypeTree);
  541. //lock
  542. me.sheet.suspendPaint();
  543. me.sheet.suspendEvent();
  544. for(let i = 0, len = me.sheet.getRowCount(); i < len; i++){
  545. me.sheet.getCell(i, 4).locked(true);
  546. }
  547. me.sheet.resumePaint();
  548. me.sheet.resumeEvent();
  549. }
  550. }
  551. }