ration.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /**
  2. * Created by Tony on 2017/4/28.
  3. */
  4. $("#gongliao").click(function(){
  5. $(this).attr('href', "/rationRepository/lmm" + "?repository=" + getQueryString("repository"))
  6. });
  7. $("#fuzhu").click(function(){
  8. $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
  9. });
  10. var rationOprObj = {
  11. workBook: null,
  12. currentRations: {},
  13. currentEditingRation: null,
  14. currentSectionId: -1,
  15. activeCell: null,
  16. rationsCodes: [],
  17. setting: {
  18. header:[
  19. {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
  20. {headerName:"名称",headerWidth:300,dataCode:"name", dataType: "String"},
  21. {headerName:"单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center"},
  22. {headerName:"人工费",headerWidth:120,dataCode:"labourPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
  23. {headerName:"材料费",headerWidth:120,dataCode:"materialPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
  24. {headerName:"机械费",headerWidth:120,dataCode:"machinePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
  25. {headerName:"基价",headerWidth:120,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
  26. {headerName:"显示名称(以%s表示参数)",headerWidth:350,dataCode:"caption", dataType: "String"},
  27. {headerName:"取费专业",headerWidth:120,dataCode:"feeType", dataType: "Number", hAlign: "center"}
  28. ],
  29. view:{
  30. comboBox:[
  31. {row:-1,col:2,rowCount:-1,colCount:1}
  32. ],
  33. lockedCells:[
  34. {row:-1,col:3,rowCount:-1, colCount:1}
  35. ],
  36. lockColumns: [
  37. 3, 4, 5, 6
  38. ]
  39. }
  40. },
  41. buildSheet: function(container) {
  42. let rationRepId = getQueryString("repository");
  43. var me = rationOprObj;
  44. me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
  45. me.workBook.options.showHorizontalScrollbar = true;
  46. me.getRationsCodes(rationRepId);
  47. me.rationDelOpr();
  48. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
  49. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
  50. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
  51. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
  52. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
  53. //me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
  54. me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
  55. },
  56. onCellClick: function(sender, args) {
  57. var me = rationOprObj,
  58. sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
  59. sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
  60. sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting;
  61. me.activeCell = {row: args.row, col: args.col};
  62. sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
  63. sheetCommonObj.shieldAllCells(sheetGLJ);
  64. sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
  65. sheetCommonObj.shieldAllCells(sheetCoe);
  66. sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
  67. sheetCommonObj.shieldAllCells(sheetAss);
  68. if(!(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader || args.sheetArea === GC.Spread.Sheets.SheetArea.corner)){
  69. var cacheSection = me.getCache();
  70. if (cacheSection && args.row < cacheSection.length) {
  71. rationGLJOprObj.getGljItems(cacheSection[args.row]);
  72. rationCoeOprObj.getCoeItems(cacheSection[args.row]);
  73. rationAssistOprObj.getAssItems(cacheSection[args.row]);
  74. }
  75. };
  76. me.workBook.focus(true);
  77. },
  78. getCache: function() {
  79. var me = this, rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
  80. if (!(rst)) {
  81. me.currentRations["_SEC_ID_" + me.currentSectionId] = [];
  82. rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
  83. }
  84. return rst;
  85. },
  86. updateCache: function(addArr, updateArr, removeIds, result) {
  87. var me = this, cacheSection = me.getCache();
  88. if (addArr.length > 0) {
  89. me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
  90. cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
  91. }
  92. for (var i = removeIds.length - 1; i >= 0; i--) {
  93. for (var j = cacheSection.length - 1; j >= 0 ; j--) {
  94. if (cacheSection[j]["ID"] == removeIds[i]) {
  95. cacheSection.splice(j,1);
  96. }
  97. }
  98. }
  99. if (result && result.data.ops && result.data.ops.length > 0) {
  100. for (var i = 0; i < result.data.ops.length; i++) {
  101. for (var j = 0; j < cacheSection.length; j++) {
  102. if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
  103. cacheSection[j]["ID"] = result.data.ops[i]["ID"];
  104. cacheSection[j]["rationGljList"] = result.data.ops[i]["rationGljList"];
  105. }
  106. }
  107. }
  108. }
  109. for (var i = 0; i < updateArr.length; i++) {
  110. for (var j = 0; j < cacheSection.length; j++) {
  111. if (updateArr[i]["ID"] && cacheSection[j]["ID"]) {
  112. if (cacheSection[j]["ID"] == updateArr[i]["ID"]) {
  113. cacheSection[j] = updateArr[i];
  114. }
  115. } else {
  116. if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
  117. cacheSection[j] = updateArr[i];
  118. }
  119. }
  120. }
  121. }
  122. return cacheSection;
  123. },
  124. rationDelOpr: function () {
  125. let me = rationOprObj;
  126. me.workBook.commandManager().register('rationDelete', function () {
  127. let rationSheet = me.workBook.getActiveSheet();
  128. let sels = rationSheet.getSelections(), updateArr = [], removeArr = [], lockCols = me.setting.view.lockColumns;
  129. let cacheSection = me.getCache();
  130. if(sels.length > 0){
  131. for(let sel = 0; sel < sels.length; sel++){
  132. if(sels[sel].colCount === me.setting.header.length){
  133. if(cacheSection){
  134. for(let i = 0; i < sels[sel].rowCount; i++){
  135. if(sels[sel].row + i < cacheSection.length){
  136. removeArr.push(cacheSection[sels[sel].row + i].ID);
  137. me.rationsCodes.splice(me.rationsCodes.indexOf(cacheSection[sels[sel].row + i].code), 1);
  138. }
  139. }
  140. }
  141. }
  142. else{
  143. if(sels[sel].col === 0){
  144. $('#alertText').text("编号不能为空,修改失败!");
  145. $('#alertModalBtn').click();
  146. rationSheet.options.isProtected = true;
  147. $('#alertModalCls').click(function () {
  148. rationSheet.options.isProtected = false;
  149. });
  150. $('#alertModalCof').click(function () {
  151. rationSheet.options.isProtected = false;
  152. })
  153. }
  154. else if(sels[sel].col !== 0 && !(sels[sel].col === 3 && sels.col + sels[sel].colCount -1 === 6)){
  155. if(cacheSection){
  156. for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
  157. if(sels[sel].row + i < cacheSection.length){
  158. for(let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++){
  159. if(lockCols.indexOf(col) === -1){
  160. cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = '';
  161. }
  162. }
  163. }
  164. if(cacheSection[sels[sel].row + i] && typeof cacheSection[sels[sel].row + i] !== 'undefined'){
  165. updateArr.push(cacheSection[sels[sel].row + i]);
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. if(updateArr.length > 0 || removeArr.length > 0){
  174. me.mixUpdateRequest(updateArr, [], removeArr);
  175. }
  176. });
  177. me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
  178. me.workBook.commandManager().setShortcutKey('rationDelete', GC.Spread.Commands.Key.del, false, false, false, false);
  179. },
  180. onRangeChanged: function(sender, args) {
  181. if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
  182. var me = rationOprObj, updateArr = [], removeArr = [];
  183. var cacheSection = me.getCache();
  184. if (cacheSection) {
  185. for (var i = 0; i < args.rowCount; i++) {
  186. //var hasUpdate = false, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i),
  187. var hasUpdate = false, rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row + i),
  188. isEmpty = sheetCommonObj.chkIfEmpty(rObj, me.setting);
  189. for (var j = 0; j < cacheSection.length; j++) {
  190. if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
  191. rObj["ID"] = cacheSection[j]["ID"];
  192. hasUpdate = true;
  193. break;
  194. }
  195. }
  196. if(isEmpty){
  197. if(args.row + i < cacheSection.length){
  198. rObj.ID = cacheSection[args.row + i].ID;
  199. removeArr.push(rObj.ID);
  200. }
  201. }
  202. else{
  203. }
  204. if (hasUpdate) {
  205. if (isEmpty) {
  206. removeArr.push(rObj);
  207. } else updateArr.push(rObj);
  208. } else if (isEmpty) {
  209. if (args.row + i < cacheSection.length) {
  210. rObj["ID"] = cacheSection[args.row + i]["ID"];
  211. removeArr.push(rObj["ID"]);
  212. }
  213. }
  214. }
  215. // me.mixUpdateRequest(updateArr, [], removeArr);
  216. //removeRationItems
  217. }
  218. }
  219. },
  220. onEnterCell: function (sender, args) {
  221. let me = rationOprObj;
  222. me.cellRowIdx = args.row;
  223. let isHasData = false;
  224. if(me.addRationItem){
  225. for(let i=0; i<me.setting.header.length; i++){
  226. if(me.addRationItem[me.setting.header[i].dataCode]){
  227. isHasData = true;
  228. break;
  229. }
  230. }
  231. }
  232. if(isHasData){
  233. if(me.editingRowIdx !== me.cellRowIdx) {
  234. let focusToCol = !me.addRationItem.code ? 0 : -1;
  235. // else {
  236. if(focusToCol !== -1){
  237. $('#rationAlertBtn').click();
  238. me.workBook.getSheet(0).options.isProtected = true;
  239. $('#rationAlertCac').click(function () {
  240. me.workBook.getSheet(0).options.isProtected = false;
  241. me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
  242. });
  243. $('#rationAlertCls').click(function () {
  244. me.workBook.getSheet(0).options.isProtected = false;
  245. me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
  246. });
  247. $('#rationAlertCof').click(function () {
  248. me.workBook.getSheet(0).options.isProtected = false;
  249. me.addRationItem = null;
  250. for(let col=0; col<me.setting.header.length; col++){
  251. me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingRation[me.setting.header[col].dataCode]);
  252. }
  253. me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
  254. });
  255. }
  256. // }
  257. }
  258. }
  259. },
  260. onCellEditStart: function(sender, args) {
  261. var me = rationOprObj;
  262. //var rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
  263. var rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row);
  264. me.currentEditingRation = rObj;
  265. var cacheSection = me.getCache();
  266. if (cacheSection) {
  267. for (var j = 0; j < cacheSection.length; j++) {
  268. if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
  269. rObj["ID"] = cacheSection[j]["ID"];
  270. break;
  271. }
  272. }
  273. }
  274. },
  275. onCellEditEnd: function(sender, args) {
  276. //var me = rationOprObj, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row),
  277. var me = rationOprObj, rObj = sheetCommonObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
  278. updateArr = [], addArr = [];
  279. let dataCode = me.setting.header[args.col].dataCode;
  280. me.editingRowIdx = args.row;
  281. if (me.currentEditingRation["ID"]) {
  282. rObj["ID"] = me.currentEditingRation["ID"];
  283. //updateArr.push(rObj);
  284. for(let col =0; col< me.setting.header.length; col++){
  285. if(me.currentEditingRation[me.setting.header[col].dataCode] !== rObj[me.setting.header[col].dataCode]){
  286. me.addRationItem = rObj;
  287. if(rObj[me.setting.header[0].dataCode]){
  288. updateArr.push(rObj);
  289. break;
  290. }
  291. }
  292. }
  293. } else if(!me.currentEditingRation["ID"]) {
  294. if (!sheetCommonObj.chkIfEmpty(rObj, me.setting)) {
  295. //addArr.push(rObj);
  296. me.addRationItem = rObj;
  297. if(rObj.code && rObj.code.trim().length > 0){
  298. if(me.rationsCodes.indexOf(rObj.code) === -1){
  299. addArr.push(rObj);
  300. me.rationsCodes.push(rObj.code);
  301. me.addRationItem = null;
  302. }
  303. else if(!rObj.code && rObj.code === ''){
  304. $('#alertModalBtn').click();
  305. me.workBook.getSheet(0).options.isProtected = true;
  306. $('#alertModalCls').click(function () {
  307. me.workBook.getSheet(0).options.isProtected = false;
  308. me.addRationItem.code = '';
  309. me.workBook.getSheet(0).setValue(args.row, args.col, '');
  310. me.workBook.getSheet(0).setActiveCell(args.row, args.col);
  311. });
  312. $('#alertModalCof').click(function () {
  313. me.workBook.getSheet(0).options.isProtected = false;
  314. me.addRationItem.code = '';
  315. me.workBook.getSheet(0).setValue(args.row, args.col, '');
  316. me.workBook.getSheet(0).setActiveCell(args.row, args.col);
  317. });
  318. }
  319. }
  320. else if(rObj.code && rObj.code.trim().length === 0){
  321. me.workBook.getSheet(0).setValue(args.row, args.col, '');
  322. }
  323. }
  324. }
  325. if (updateArr.length > 0 || addArr.length > 0) {
  326. me.currentEditingRation = null;
  327. me.mixUpdateRequest(updateArr, addArr, []);
  328. }
  329. },
  330. onClipboardPasting: function(sender, args) {
  331. var me = rationOprObj;
  332. /* if (args.cellRange.colCount != me.setting.header.length) {
  333. args.cancel = true;
  334. }*/
  335. },
  336. onClipboardPasted: function(e, info) {
  337. var me = rationOprObj;
  338. var cacheSection = me.getCache();
  339. var updateArr = [], addArr = [];
  340. var items = sheetCommonObj.analyzePasteData(me.setting, info);
  341. let failPasteArr = [];
  342. for (var i = 0, rowIdx =info.cellRange.row; i < items.length; i++, rowIdx++) {
  343. if (cacheSection) {
  344. //var hasCacheItem = false;
  345. if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
  346. if(me.rationsCodes.indexOf(items[i].code) === -1){
  347. addArr.push(items[i]);
  348. me.rationsCodes.push(items[i].code);
  349. }
  350. else{
  351. failPasteArr.push(items[i].code);
  352. me.workBook.getSheet(0).setValue(rowIdx, 0, '');
  353. }
  354. }
  355. else if(cacheSection[rowIdx]){
  356. for(let col = 0; col < me.setting.header.length; col++){
  357. if(!items[i][me.setting.header[col].dataCode] && typeof cacheSection[rowIdx][me.setting.header[col].dataCode] !== 'undefined'){
  358. items[i][me.setting.header[col].dataCode] = cacheSection[rowIdx][me.setting.header[col].dataCode];
  359. }
  360. }
  361. if(info.cellRange.col === 0){
  362. if(me.rationsCodes.indexOf(items[i].code) === -1){
  363. items[i].ID = cacheSection[rowIdx].ID;
  364. updateArr.push(items[i]);
  365. }
  366. else{
  367. me.workBook.getSheet(0).setValue(rowIdx, 0, cacheSection[rowIdx].code);
  368. }
  369. }
  370. else{
  371. items[i].ID = cacheSection[rowIdx].ID;
  372. updateArr.push(items[i]);
  373. }
  374. }
  375. } else {
  376. //add
  377. if(info.cellRange.col === 0){
  378. //是否含有已存在的编号
  379. if(me.rationsCodes.indexOf(items[i].code) === -1){
  380. addArr.push(items[i]);
  381. }
  382. else{
  383. failPasteArr.push(items[i]);
  384. }
  385. }
  386. }
  387. };
  388. /* if(failPasteArr.length > 0 && !(updateArr.length > 0 || addArr.length > 0)){
  389. me.showRationItems(me.currentSectionId);
  390. }*/
  391. if (updateArr.length > 0 || addArr.length > 0) {
  392. me.mixUpdateRequest(updateArr, addArr, []);
  393. }
  394. },
  395. getRationsCodes: function (repId) {
  396. let me = rationOprObj;
  397. $.ajax({
  398. type: 'post',
  399. url: 'api/getRationsCodes',
  400. data: {data: JSON.stringify({repId: repId})},
  401. dataType: 'json',
  402. success: function (result) {
  403. if(!result.error){
  404. me.rationsCodes = result.data;
  405. }
  406. }
  407. })
  408. },
  409. mixUpdateRequest: function(updateArr, addArr, removeIds) {
  410. var me = rationOprObj;
  411. $.ajax({
  412. type:"POST",
  413. url:"api/mixUpdateRationItems",
  414. data:{"rationLibId": getQueryString("repository"), "lastOpr": userAccount, "sectionID": me.currentSectionId, "updateItems": JSON.stringify(updateArr), "addItems": JSON.stringify(addArr), "removeIds": JSON.stringify(removeIds)},
  415. dataType:"json",
  416. cache:false,
  417. timeout:5000,
  418. success:function(result){
  419. if (result.error) {
  420. alert(`error`);
  421. me.getRationItems(me.currentSectionId);
  422. } else {
  423. var cacheSection = me.updateCache(addArr, updateArr, removeIds, result);
  424. cacheSection.sort(function(a, b){
  425. var rst = 0;
  426. if (a.code > b.code) rst = 1
  427. else if (a.code < b.code) rst = -1;
  428. return rst;
  429. });
  430. me.showRationItems(me.currentSectionId);
  431. /* me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
  432. let spreadBook = new GC.Spread.Sheets.Workbook(rationOprObj.sheet, { sheetCount: 1 });
  433. spreadBook.focus(true);*/
  434. }
  435. },
  436. error:function(){
  437. }
  438. });
  439. },
  440. getRationItems: function(sectionID){
  441. if (sectionID != -1) {
  442. var me = rationOprObj;
  443. me.currentSectionId = sectionID;
  444. if (me.currentRations["_SEC_ID_" + sectionID]) {
  445. me.showRationItems(sectionID);
  446. ///sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
  447. sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
  448. sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
  449. sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
  450. sheetCommonObj.unShieldAllCells(rationAssistOprObj.sheet);
  451. } else {
  452. $.ajax({
  453. type:"POST",
  454. url:"api/getRationItems",
  455. data:{"sectionID": sectionID},
  456. dataType:"json",
  457. cache:false,
  458. timeout:1000,
  459. success:function(result){
  460. if (result) {
  461. me.currentRations["_SEC_ID_" + sectionID] = result.data;
  462. me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
  463. me.showRationItems(sectionID);
  464. //sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
  465. sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
  466. sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
  467. sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
  468. sheetCommonObj.unShieldAllCells(rationAssistOprObj.sheet);
  469. } else {
  470. sheetCommonObj.shieldAllCells(me.workBook.getSheet(0));
  471. sheetCommonObj.shieldAllCells(rationGLJOprObj.sheet);
  472. sheetCommonObj.shieldAllCells(rationCoeOprObj.sheet);
  473. sheetCommonObj.shieldAllCells(rationAssistOprObj.sheet);
  474. }
  475. },
  476. error:function(err){
  477. alert(err);
  478. }
  479. })
  480. }
  481. }
  482. },
  483. showRationItems: function(sectionID){
  484. var me = rationOprObj;
  485. if (me.workBook) {
  486. if (me.currentRations && me.currentRations["_SEC_ID_" + sectionID] && me.currentRations["_SEC_ID_" + sectionID].length > 0) {
  487. var cacheSection = me.currentRations["_SEC_ID_" + sectionID];
  488. sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
  489. sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
  490. } else {
  491. //清除ration数据及工料机数据
  492. sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
  493. }
  494. }
  495. },
  496. sortByCode: function(arr){
  497. function compare(){
  498. return function (a, b) {
  499. let rst = 0;
  500. if (a.code > b.code) {
  501. rst = 1;
  502. }
  503. else if (a.code < b.code) {
  504. rst = -1;
  505. }
  506. return rst;
  507. }
  508. }
  509. arr.sort(compare());
  510. }
  511. }