section_tree.js 26 KB

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