section_tree.js 26 KB

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