section_tree.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /**
  2. * Created by Zhong on 2017/12/18.
  3. */
  4. let pageOprObj = {
  5. refreshAllBooks: function () {
  6. if (sectionTreeObj.workBook) {
  7. sectionTreeObj.workBook.refresh();
  8. }
  9. if (rationOprObj.workBook) {
  10. rationOprObj.workBook.refresh();
  11. }
  12. if (coeOprObj.workBook) {
  13. coeOprObj.workBook.refresh();
  14. } else {
  15. pageObj.initPage();
  16. }
  17. if (gljAdjOprObj.workBook) {
  18. gljAdjOprObj.workBook.refresh();
  19. }
  20. if (rationGLJOprObj.sheet.getParent()) {
  21. rationGLJOprObj.sheet.getParent().refresh();
  22. }
  23. },
  24. rationLibName : null,
  25. rationLibId : null,
  26. gljLibId: gljLibId,
  27. initPage : function() {
  28. let me = this;
  29. // me.getRationLibInfo(rationLibId, function (rstData) {
  30. //if(rstData.length > 0){
  31. //me.rationLibName = rstData[0].dispName;
  32. //let $rationName = $(`<div id='rationname' class='navbar-text'><a id='rationLibBtn' href='javascript:void(0);'>定额库</a><i class='fa fa-angle-right fa-fw'></i>${me.rationLibName}</div>`);
  33. //let $rationName = $(`<div id='rationname' class='navbar-text'>${me.rationLibName}</div>`);
  34. // $('.header-logo').after($rationName);
  35. // me.gljLibId = rstData[0].gljLib;
  36. sectionTreeObj.getSectionTree();
  37. //job
  38. jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
  39. $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
  40. $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
  41. jobContentOprObj.bindAllEvents($('#txtareaAll'));
  42. //fz
  43. annotationOprObj.radiosChange(annotationOprObj.radios, annotationOprObj.fzTableAll, annotationOprObj.fzTablePartial);
  44. $('#fzAddConBtn').click(annotationOprObj.bindAddConBtn());
  45. $('#fzUpdateConBtn').click(annotationOprObj.bindUpdateConBtn());
  46. annotationOprObj.bindAllEvents($('#fzTxtareaAll'));
  47. // }
  48. gljSelOprObj.getGljClassTree(gljLibId, function () {
  49. gljSelOprObj.getSelGljItems(gljLibId);
  50. });
  51. // });
  52. },
  53. getRationLibInfo: function (rationLibId, callback) {
  54. CommonAjax.post('api/getRationLib', {rationRepId: rationLibId}, callback);
  55. },
  56. //获取定额库列表
  57. /*getRationLibs: function () {
  58. let scFunc = function (rstData) {
  59. $("#comple_ration_table").empty();
  60. for(let i = 0; i < rstData.length; i++){
  61. storageUtil.setSessionCache("RationGrp","repositoryID_" + rstData[i].ID, rstData[i].dispName);
  62. if(rstData[i].gljLib !== undefined && rstData[i].gljLib && rstData[i].gljLib != -1){
  63. storageUtil.setSessionCache("gljLib","repositoryID_" + rstData[i].ID, rstData[i].gljLib);
  64. let id = rstData[i].ID;
  65. let libName = rstData[i].dispName;
  66. $("#comple_ration_table").append(
  67. "<tr id='tempId'>" +
  68. "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td></tr>"
  69. );
  70. var newHref = "/complementaryRation/ration?repository="+id;
  71. $("#tempId td:first a").attr("href", newHref);
  72. $("#tempId").attr("id", id);
  73. }
  74. }
  75. };
  76. let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
  77. let ids = [];
  78. for(lib of ration_lib){
  79. ids.push(parseInt(lib.id));
  80. }
  81. CommonAjax.post('/complementaryRation/api/getRationLibs', {user_id: userID, ids: ids}, scFunc);
  82. }*/
  83. };
  84. let sectionTreeObj = {
  85. cache: null,//ref to tree.items
  86. tree: null,
  87. controller: null,
  88. workBook: null,
  89. sheet: null,
  90. updateType: {new: 'new', update: 'update'},
  91. insertBtn: $('#tree_Insert'),
  92. removeBtn: $('#tree_remove'),
  93. upLevelBtn: $('#tree_upLevel'),
  94. downLevelBtn: $('#tree_downLevel'),
  95. downMoveBtn: $('#tree_downMove'),
  96. upMoveBtn: $('#tree_upMove'),
  97. type: {std: 'std', complementary: 'complementary'},
  98. setting: {
  99. sheet: {
  100. cols:[
  101. {
  102. head: {
  103. titleNames: ['名称'],
  104. spanCols: [1],
  105. spanRows: [2],
  106. vAlign: [1, 1],
  107. hAlign: [1, 1],
  108. font: 'Arial'
  109. },
  110. data: {
  111. field: 'name',
  112. vAlign: 1,
  113. hAlign: 0,
  114. font: 'Arial'
  115. },
  116. width: 400
  117. }
  118. ],
  119. headRows: 1,
  120. headRowHeight: [47],
  121. emptyRows: 0,
  122. treeCol: 0
  123. },
  124. tree: {
  125. id: 'ID',
  126. pid: 'ParentID',
  127. nid: 'NextSiblingID',
  128. rootId: -1
  129. },
  130. options: {
  131. allowContextMenu: false,
  132. tabStripVisible: false,
  133. allowCopyPasteExcelStyle : false,
  134. allowExtendPasteRange: false,
  135. allowUserDragDrop : false,
  136. allowUserDragFill: false,
  137. scrollbarMaxAlign : true
  138. }
  139. },
  140. isDef: function (v) {
  141. return v !== undefined && v !== null;
  142. },
  143. isFunc: function (v) {
  144. return this.isDef(v) && typeof v === 'function';
  145. },
  146. //sheet things
  147. setOptions: function (workbook, opts) {
  148. for(let opt in opts){
  149. workbook.options[opt] = opts[opt];
  150. }
  151. },
  152. renderFunc: function (sheet, func) {
  153. sheet.suspendPaint();
  154. sheet.suspendEvent();
  155. if(this.isFunc(func)){
  156. func();
  157. }
  158. sheet.resumePaint();
  159. sheet.resumeEvent();
  160. },
  161. buildSheet: function () {
  162. if(!this.isDef(this.workBook)){
  163. this.workBook = new GC.Spread.Sheets.Workbook($('#sectionSpread')[0], {sheetCount: 1});
  164. sheetCommonObj.spreadDefaultStyle(this.workBook);
  165. sheetCommonObj.bindEscKey(this.workBook, [{sheet: this.workBook.getSheet(0), editStarting: this.onEditStarting, editEnded: this.onEditEnded}]);
  166. this.sheet = this.workBook.getSheet(0);
  167. this.bindEvents(this.sheet);
  168. this.setOptions(this.workBook, this.setting.options);
  169. this.sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
  170. }
  171. },
  172. bindEvents: function (sheet) {
  173. let me = sectionTreeObj;
  174. const Events = GC.Spread.Sheets.Events;
  175. sheet.bind(Events.SelectionChanging, me.onSelectionChanging);
  176. sheet.bind(Events.EditEnded, me.onEditEnded);
  177. sheet.bind(Events.EditStarting, me.onEditStarting);
  178. sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
  179. sheet.bind(Events.ClipboardPasted, me.onClipboardPasted);
  180. },
  181. onSelectionChanging: function (sender, info) {
  182. let me = sectionTreeObj;
  183. if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
  184. let row = info.newSelections[0].row;
  185. let section = me.cache[row];
  186. me.initSelection(section);
  187. }
  188. else {
  189. me.refreshBtn(null);
  190. }
  191. },
  192. onEditStarting: function (sender, args) {
  193. },
  194. onEditEnded: function (sender, args) {
  195. let me = sectionTreeObj;
  196. let postData = [];
  197. let v = me.isDef(args.editingText) ? args.editingText.toString().trim() : '';
  198. let node = me.cache[args.row];
  199. if(me.isDef(node) && node.data.name !== v){
  200. let updateObj = me.getUpdateObj(me.updateType.update, {ID: node.getID(), name: v});
  201. postData.push(updateObj);
  202. //ajax
  203. //update
  204. me.sectionTreeAjax(postData, function (rstData) {
  205. node.data.name = v;
  206. }, function () {
  207. args.sheet.setValue(args.row, args.col, node.data.name ? node.data.name : '');
  208. });
  209. }
  210. },
  211. onClipboardPasting: function (sender, info) {
  212. },
  213. onClipboardPasted: function (sender, info) {
  214. let me = sectionTreeObj;
  215. let items = sheetCommonObj.analyzePasteData({header: [{dataCode: 'name'}]}, info);
  216. let postData = [];
  217. let frontData = [];
  218. for(let i = 0, len = items.length; i < len; i++){
  219. let row = info.cellRange.row + i;
  220. let node = me.cache[row];
  221. if(me.isDef(node) && me.isDef(items[i].name) && node.data.name !== items[i].name){
  222. let updateObj = me.getUpdateObj(me.updateType.update, {ID: node.getID(), name: items[i].name});
  223. postData.push(updateObj);
  224. frontData.push({row: row, name: items[i].name});
  225. node.data.name = items[i].name;
  226. }
  227. }
  228. if(postData.length > 0){
  229. //ajax
  230. me.sectionTreeAjax(postData, function (rstData) {
  231. for(let i = 0, len = frontData.length; i < len; i++){
  232. let node = me.cache[frontData[i]['row']];
  233. if(me.isDef(node)){
  234. node.data.name = frontData[i]['name'];
  235. }
  236. }
  237. }, function () {
  238. for(let i = 0, len = frontData.length; i < len; i++){
  239. let node = me.cache[frontData[i]['row']];
  240. me.sheet.setValue(frontData[i]['row'], 0, me.isDef(node) ? node.data.name : '');
  241. }
  242. });
  243. }
  244. },
  245. getSectionTree: function () {
  246. let me = sectionTreeObj;
  247. let url = 'api/getRationTree';
  248. //type: 0-补充库 1-标准库
  249. let postData = {type: 0};
  250. let sucFunc = function (rstData) {
  251. if(rstData.length > 0){
  252. storageUtil.setSessionCache("RationGrp","repositoryID",rstData[0].rationRepId);
  253. }
  254. //init
  255. me.buildSheet();
  256. me.initTree(rstData);
  257. me.cache = me.tree.items;
  258. me.bindBtn();
  259. me.initController(me.tree, me.sheet, me.setting.sheet);
  260. me.controller.showTreeData();
  261. me.setColor(me.cache);
  262. me.sheet.setFormatter(-1, 0, '@');
  263. me.initSelection(me.tree.selected);
  264. explanatoryOprObj.bindEvents($('#explanationShow'), $('#ruleTextShow'));
  265. };
  266. let errFunc = function () {
  267. };
  268. CommonAjax.post(url, postData, sucFunc, errFunc);
  269. },
  270. setColor: function (nodes) {
  271. let me = this;
  272. me.renderFunc(me.sheet, function () {
  273. for(let i = 0, len = nodes.length; i < len; i++){
  274. if(nodes[i].data.type === me.type.complementary){
  275. me.sheet.getCell(i, 0).foreColor('gray');
  276. }
  277. }
  278. });
  279. },
  280. initTree: function (datas) {
  281. this.tree = idTree.createNew(this.setting.tree);
  282. this.tree.loadDatas(datas);
  283. this.tree.selected = this.tree.items.length > 0 ? this.tree.items[0] : null;
  284. },
  285. initController: function (tree, sheet, setting) {
  286. this.controller = TREE_SHEET_CONTROLLER.createNew(tree, sheet, setting);
  287. },
  288. refreshBtn: function (selected) {
  289. let me = this;
  290. me.insertBtn.removeClass('disabled');
  291. me.removeBtn.removeClass('disabled');
  292. me.upLevelBtn.removeClass('disabled');
  293. me.downLevelBtn.removeClass('disabled');
  294. me.downMoveBtn.removeClass('disabled');
  295. me.upMoveBtn.removeClass('disabled');
  296. if(!me.isDef(selected)){
  297. me.removeBtn.addClass('disabled');
  298. me.upLevelBtn.addClass('disabled');
  299. me.downLevelBtn.addClass('disabled');
  300. me.downMoveBtn.addClass('disabled');
  301. me.upMoveBtn.addClass('disabled');
  302. }
  303. else {
  304. if(!me.isDef(selected.preSibling)){
  305. me.downLevelBtn.addClass('disabled');
  306. me.upMoveBtn.addClass('disabled');
  307. }
  308. if(!me.isDef(selected.nextSibling)){
  309. me.downMoveBtn.addClass('disabled');
  310. }
  311. if(!me.isDef(selected.parent)){
  312. me.upLevelBtn.addClass('disabled');
  313. }
  314. }
  315. },
  316. bindBtn: function () {
  317. let me = this;
  318. me.insertBtn.click(function () {
  319. me.insert();
  320. });
  321. $('#delConfirm').click(function () {
  322. if(me.canRemoveSection){
  323. me.remove(me.tree.selected);
  324. }
  325. else {
  326. $('#delAlert').modal('hide');
  327. }
  328. });
  329. me.removeBtn.click(function () {
  330. //不可删除有子节点或有定额数据的节点
  331. let section = me.cache[me.workBook.getActiveSheet().getActiveRowIndex()];
  332. if(!section){
  333. return;
  334. }
  335. let sectionName = me.isDef(section.data.name) ? section.data.name : '';
  336. let sectionRations = rationOprObj.currentRations[`_SEC_ID_${section.data.ID}`];
  337. if(section.children.length > 0 || (sectionRations && sectionRations.length > 0)){
  338. me.canRemoveSection = false;
  339. $('#delAlert').find('.modal-body h5').text('当前节点下有数据,不可删除。');
  340. }
  341. else {
  342. me.canRemoveSection = true;
  343. $('#delAlert').find('.modal-body h5').text(`确认要删除章节 “${sectionName}”吗?`);
  344. }
  345. $('#delAlert').modal('show');
  346. });
  347. me.upLevelBtn.click(function () {
  348. me.upLevel(me.tree.selected);
  349. });
  350. me.downLevelBtn.click(function () {
  351. me.downLevel(me.tree.selected);
  352. });
  353. me.downMoveBtn.click(function () {
  354. me.downMove(me.tree.selected);
  355. });
  356. me.upMoveBtn.click(function () {
  357. me.upMove(me.tree.selected);
  358. });
  359. },
  360. insert: function () {
  361. let me = sectionTreeObj;
  362. me.insertBtn.addClass('disabled');
  363. let postData = [],
  364. newID = uuid.v1();
  365. let selected = me.tree.selected;
  366. let insertObj = me.getUpdateObj(me.updateType.new, {ID: newID, NextSiblingID: -1, ParentID: -1, name: ''});
  367. if(me.isDef(selected)) {
  368. let updateObj = me.getUpdateObj(me.updateType.update, {ID: selected.getID(), NextSiblingID: newID});
  369. postData.push(updateObj);
  370. insertObj.updateData.ParentID = selected.getParentID();
  371. if(me.isDef(selected.nextSibling)){
  372. insertObj.updateData.NextSiblingID = selected.getNextSiblingID();
  373. }
  374. }
  375. postData.push(insertObj);
  376. if(postData.length > 0){
  377. //ajax
  378. me.sectionTreeAjax(postData, function (rstData) {
  379. me.controller.insertByID(newID);
  380. me.refreshBtn(me.tree.selected);
  381. //fresh tools
  382. me.initTools(me.tree.selected);
  383. me.workBook.focus();
  384. me.initSelection(me.tree.selected);
  385. });
  386. }
  387. },
  388. remove: function (selected) {
  389. let me = this;
  390. me.removeBtn.addClass('disabled');
  391. let postData = [],
  392. IDs = [],
  393. deleteObj = {
  394. deleted: true,
  395. deleteDateTime: new Date(),
  396. deleteBy: userID
  397. };
  398. if(!selected){
  399. return;
  400. }
  401. getDelIds(selected);
  402. function getDelIds(node){
  403. if(me.isDef(node)){
  404. IDs.push(node.getID());
  405. if(node.children.length > 0){
  406. for(let i = 0, len = node.children.length; i < len; i++){
  407. getDelIds(node.children[i]);
  408. }
  409. }
  410. }
  411. }
  412. if(me.isDef(selected.preSibling)){
  413. let updateObj = me.getUpdateObj(me.updateType.update, {ID: selected.preSibling.getID(), NextSiblingID: selected.getNextSiblingID()});
  414. postData.push(updateObj);
  415. }
  416. if(IDs.length > 0){
  417. for(let i = 0, len = IDs.length; i < len; i++){
  418. let delObj = me.getUpdateObj(me.updateType.update, {ID: IDs[i], deleteInfo: deleteObj});
  419. postData.push(delObj);
  420. }
  421. }
  422. if(postData.length > 0){
  423. //ajax
  424. me.sectionTreeAjax(postData, function (rstData) {
  425. $('#delAlert').modal('hide');
  426. me.removeRationsCodes(rationOprObj.currentRations["_SEC_ID_" + selected.data.ID]);
  427. me.controller.delete();
  428. me.refreshBtn(me.tree.selected);
  429. me.initTools(me.tree.selected);
  430. me.initSelection(me.tree.selected);
  431. me.workBook.focus();
  432. });
  433. }
  434. },
  435. removeRationsCodes: function (rations) {
  436. for(let ration of rations){
  437. rationOprObj.rationsCodes.splice(rationOprObj.rationsCodes.indexOf(ration.code), 1);
  438. }
  439. },
  440. upLevel: function (selected) {
  441. let me = this;
  442. me.upLevelBtn.addClass('disabled');
  443. let postData = [],
  444. parent = selected.parent;
  445. if(!me.isDef(parent)){
  446. return;
  447. }
  448. //更新父节点
  449. postData.push(me.getUpdateObj(me.updateType.update, {ID: parent.getID(), NextSiblingID: selected.getID()}));
  450. //更新前节点
  451. if(me.isDef(selected.preSibling)){
  452. postData.push(me.getUpdateObj(me.updateType.update, {ID: selected.preSibling.getID(), NextSiblingID: -1}));
  453. }
  454. //更新选中节点的后兄弟节点
  455. let nextIDs = [];
  456. getNext(selected);
  457. function getNext(node){
  458. if(me.isDef(node.nextSibling)){
  459. nextIDs.push(node.getNextSiblingID());
  460. getNext(node.nextSibling);
  461. }
  462. }
  463. for(let nextID of nextIDs){
  464. postData.push(me.getUpdateObj(me.updateType.update, {ID: nextID, ParentID: selected.getID()}));
  465. }
  466. //更新选中节点
  467. postData.push(me.getUpdateObj(me.updateType.update,
  468. {ID: selected.getID(), NextSiblingID: parent.getNextSiblingID(), ParentID: parent.getParentID()}));
  469. if(postData.length > 0){
  470. //ajax
  471. me.sectionTreeAjax(postData, function (rstData) {
  472. me.controller.upLevel();
  473. me.refreshBtn(me.tree.selected);
  474. me.workBook.focus();
  475. });
  476. }
  477. },
  478. downLevel: function (selected) {
  479. let me = this;
  480. me.downLevelBtn.addClass('disabled');
  481. let postData = [],
  482. preSibling = selected.preSibling;
  483. if(!me.isDef(preSibling)){
  484. return;
  485. }
  486. //更新前节点
  487. postData.push(me.getUpdateObj(me.updateType.update, {ID: preSibling.getID(), NextSiblingID: selected.getNextSiblingID()}));
  488. //更新前节点最末子节点
  489. if(preSibling.children.length > 0){
  490. postData.push(me.getUpdateObj(me.updateType.update,
  491. {ID: preSibling.children[preSibling.children.length - 1].getID(), NextSiblingID: selected.getID()}));
  492. }
  493. //更新选中节点
  494. postData.push(me.getUpdateObj(me.updateType.update, {ID: selected.getID(), NextSiblingID: -1, ParentID: preSibling.getID()}));
  495. if(postData.length > 0){
  496. //ajax
  497. me.sectionTreeAjax(postData, function (rstData) {
  498. me.controller.downLevel();
  499. me.refreshBtn(me.tree.selected);
  500. me.workBook.focus();
  501. });
  502. }
  503. },
  504. upMove: function (selected) {
  505. let me = this;
  506. me.upMoveBtn.addClass('disabled');
  507. let postData = [];
  508. if(!me.isDef(selected)){
  509. return;
  510. }
  511. if(!me.isDef(selected.preSibling)){
  512. return;
  513. }
  514. let updateObj = me.getUpdateObj(me.updateType.update, {ID: selected.getID(), NextSiblingID: selected.preSibling.getID()});
  515. postData.push(updateObj);
  516. let updatePre = me.getUpdateObj(me.updateType.update, {ID: selected.preSibling.getID(), NextSiblingID: selected.getNextSiblingID()});
  517. postData.push(updatePre);
  518. if(me.isDef(selected.preSibling.preSibling)){
  519. let updatePrepre = me.getUpdateObj(me.updateType.update, {ID: selected.preSibling.preSibling.getID(), NextSiblingID: selected.getID()});
  520. postData.push(updatePrepre);
  521. }
  522. if(postData.length > 0){
  523. //ajax
  524. me.sectionTreeAjax(postData, function (rstData) {
  525. me.controller.upMove();
  526. me.refreshBtn(me.tree.selected);
  527. me.workBook.focus();
  528. });
  529. }
  530. },
  531. downMove: function (selected) {
  532. let me = this;
  533. me.downMoveBtn.addClass('disabled');
  534. let postData = [];
  535. if(!me.isDef(selected)){
  536. return;
  537. }
  538. if(!me.isDef(selected.nextSibling)){
  539. return;
  540. }
  541. if(me.isDef(selected.preSibling)){
  542. let updatePre = me.getUpdateObj(me.updateType.update, {ID: selected.preSibling.getID(), NextSiblingID: selected.getNextSiblingID()});
  543. postData.push(updatePre);
  544. }
  545. let updateObj = me.getUpdateObj(me.updateType.update, {ID: selected.getID(), NextSiblingID: selected.nextSibling.getNextSiblingID()});
  546. postData.push(updateObj);
  547. let updateNext = me.getUpdateObj(me.updateType.update, {ID: selected.getNextSiblingID(), NextSiblingID: selected.getID()});
  548. postData.push(updateNext);
  549. if(postData.length > 0){
  550. //ajax
  551. me.sectionTreeAjax(postData, function (rstData) {
  552. me.controller.downMove();
  553. me.refreshBtn(me.tree.selected);
  554. me.workBook.focus();
  555. });
  556. }
  557. },
  558. getUpdateObj: function (updateType, updateData) {
  559. let updateObj = Object.create(null);
  560. updateObj.updateType = '';
  561. updateObj.updateData = Object.create(null);
  562. updateObj.updateData.rationRepId = pageOprObj.rationLibId;
  563. if(this.isDef(updateType)){
  564. updateObj.updateType = updateType;
  565. }
  566. if(this.isDef(updateData)){
  567. for(let attr in updateData){
  568. updateObj.updateData[attr] = updateData[attr];
  569. }
  570. }
  571. return updateObj;
  572. },
  573. sectionTreeAjax: function (postData, scFunc, errFunc) {
  574. CommonAjax.post('api/updateRationSection', {updateData: postData}, scFunc, errFunc);
  575. },
  576. initTools: function (node) {
  577. if(this.isDef(node)){
  578. explanatoryOprObj.setAttribute(explanatoryOprObj.currentTreeNode ? explanatoryOprObj.currentTreeNode : node, node, node.data.explanation, node.data.ruleText);
  579. explanatoryOprObj.clickUpdate($('#explanationShow'), $('#ruleTextShow'));
  580. explanatoryOprObj.showText($('#explanationShow'), $('#ruleTextShow'), node.data.explanation, node.data.ruleText);
  581. //job
  582. jobContentOprObj.currentSituation = typeof node.data.jobContentSituation !== 'undefined'? node.data.jobContentSituation : jobContentOprObj.situations.NONE;
  583. jobContentOprObj.setAttribute(jobContentOprObj.currentTreeNode ? jobContentOprObj.currentTreeNode : node, node);
  584. jobContentOprObj.clickUpdate($('#txtareaAll'));
  585. //fz
  586. annotationOprObj.currentSituation = typeof node.data.annotationSituation !== 'undefined'? node.data.annotationSituation : annotationOprObj.situations.NONE;
  587. annotationOprObj.clickUpdate($('#fzTxtareaAll'));
  588. }
  589. },
  590. //模仿默认点击
  591. initSelection: function (node) {
  592. node.tree.selected = node ? node : null;
  593. let me = this;
  594. if(!me.isDef(node)){
  595. sheetCommonObj.cleanSheet(rationOprObj.workBook.getActiveSheet(), rationOprObj.setting, -1);
  596. sheetCommonObj.cleanSheet(rationGLJOprObj.sheet, rationGLJOprObj.setting, -1);
  597. sheetCommonObj.cleanSheet(rationCoeOprObj.sheet, rationCoeOprObj.setting, -1);
  598. sheetCommonObj.cleanSheet(rationAssistOprObj.sheet, rationAssistOprObj.setting, -1);
  599. sheetCommonObj.cleanSheet(rationInstObj.sheet, rationInstObj.setting, -1);
  600. return;
  601. }
  602. me.workBook.getActiveSheet().setActiveCell(node.serialNo(), 0);
  603. me.initTools(node);
  604. me.refreshBtn(node);
  605. if(!me.isDef(node.children) || node.children.length === 0){
  606. rationOprObj.canRations = true;
  607. rationOprObj.workBook.getSheet(0).clearSelection();
  608. rationOprObj.getRationItems(node.data.ID, function () {
  609. rationOprObj.workBook.getActiveSheet().setActiveCell(0, 0);
  610. rationOprObj.rationSelInit(0, true);
  611. });
  612. rationOprObj.setCombo(rationOprObj.workBook.getSheet(0), 'dynamic');
  613. }
  614. else {
  615. rationOprObj.canRations = false;
  616. rationOprObj.currentSectionId = node.data.ID;
  617. rationOprObj.workBook.getSheet(0).setRowCount(30);
  618. rationOprObj.setCombo(rationOprObj.workBook.getSheet(0), null);
  619. // jobContentOprObj.setRadiosDisabled(true, jobContentOprObj.radios);
  620. jobContentOprObj.hideTable($('#tableAll'), $('#tablePartial'));
  621. // annotationOprObj.setRadiosDisabled(true, annotationOprObj.radios);
  622. annotationOprObj.hideTable($('#fzTableAll'), $('#fzTablePartial'));
  623. sheetCommonObj.cleanSheet(rationOprObj.workBook.getSheet(0), rationOprObj.setting, -1);
  624. sheetCommonObj.cleanSheet(rationGLJOprObj.sheet, rationGLJOprObj.setting, -1);
  625. sheetCommonObj.cleanSheet(rationCoeOprObj.sheet, rationCoeOprObj.setting, -1);
  626. sheetCommonObj.cleanSheet(rationAssistOprObj.sheet, rationAssistOprObj.setting, -1);
  627. sheetCommonObj.cleanSheet(rationInstObj.sheet, rationInstObj.setting, -1);
  628. }
  629. //rationGLJOprObj.sheet.getParent().focus(false);
  630. me.workBook.focus(true);
  631. }
  632. };