block_lib.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. /**
  2. * 块模板库管理。
  3. * Created by CSL on 2018-09-19.
  4. */
  5. var blockLibObj = {
  6. mainSpread: null,
  7. mainSheet: null,
  8. mainTree: null,
  9. mainTreeController: null,
  10. mainSetting: {
  11. "emptyRowHeader": true,
  12. "rowHeaderWidth": 15,
  13. "emptyRows":0,
  14. "headRows":1,
  15. "headRowHeight":[30],
  16. "defaultRowHeight": 21,
  17. "treeCol": 9,
  18. "cols":[{
  19. "width":400,
  20. "readOnly": true,
  21. "head":{
  22. "titleNames":["名称"],
  23. "spanCols":[1],
  24. "spanRows":[1],
  25. "vAlign":[1],
  26. "hAlign":[1],
  27. "font":["Arial"]
  28. },
  29. "data":{
  30. "field":"name",
  31. "vAlign":1,
  32. "hAlign":0,
  33. "font":"Arial"
  34. }
  35. }]
  36. },
  37. mainDatas: [],
  38. billSpread: null,
  39. billSheet: null,
  40. billSetting: {
  41. header: [
  42. {headerName: "项目编码", headerWidth: 90, dataCode: "code", dataType: "String", hAlign: "center"},
  43. {headerName: "项目名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  44. {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center"},
  45. {headerName: "综合单价", headerWidth: 70, dataCode: "", dataType: "Number"},
  46. {headerName: "项目特征", headerWidth: 160, dataCode: "itemCharacterText", dataType: "String"}
  47. ],
  48. view: {
  49. lockColumns: [0, 1, 2, 3, 4]
  50. }
  51. },
  52. rationSpread: null,
  53. rationSheet: null,
  54. rationSetting: {
  55. header: [
  56. {headerName: "编码", headerWidth: 45, dataCode: "code", dataType: "String", hAlign: "center"},
  57. {headerName: "名称", headerWidth: 100, dataCode: "name", dataType: "String"},
  58. {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center"},
  59. {headerName: "含量", headerWidth: 40, dataCode: "contain", dataType: "Number"},
  60. {headerName: "取费专业", headerWidth: 70, dataCode: "", dataType: "String", hAlign: "center"},
  61. {headerName: "综合单价", headerWidth: 70, dataCode: "", dataType: "Number"},
  62. {headerName: "子目换算状态", headerWidth: 90, dataCode: "adjustState", dataType: "String"}
  63. ],
  64. view: {
  65. lockColumns: [0, 1, 2, 3, 4, 5, 6]
  66. }
  67. },
  68. buildSheet: function () {
  69. $.bootstrapLoading.start();
  70. let me = this;
  71. me.mainDatas = [
  72. {ID: 1, ParentID: -1, NextSiblingID: 2, name: '分类1', type: 1},
  73. {ID: 2, ParentID: -1, NextSiblingID: 3, name: '分类2', type: 1},
  74. {ID: 3, ParentID: -1, NextSiblingID: 4, name: '分类3', type: 1},
  75. // {ID: 105, ParentID: 1, NextSiblingID: 106, name: '块1', type: 2},
  76. // {ID: 106, ParentID: 1, NextSiblingID: 107, name: '块2', type: 2},
  77. {ID: 7, ParentID: -1, NextSiblingID: 8, name: '分类7', type: 1},
  78. {ID: 9, ParentID: -1, NextSiblingID: -1, name: '分类9', type: 1}//,
  79. // {ID: 201, ParentID: 52, NextSiblingID: -1, name: '块201', type: 2}
  80. ];
  81. if (me.mainSpread) {
  82. me.mainSpread.destroy();
  83. me.mainSpread = null;
  84. };
  85. if (me.billSpread) {
  86. me.billSpread.destroy();
  87. me.billSpread = null;
  88. };
  89. if (me.rationSpread) {
  90. me.rationSpread.destroy();
  91. me.rationSpread = null;
  92. };
  93. me.mainSpread = SheetDataHelper.createNewSpread($('#div_block_tree')[0]);
  94. // me.mainSpread = TREE_SHEET_HELPER.createNewSpread($('#div_block_tree')[0]);
  95. me.mainSheet = me.mainSpread.getSheet(0);
  96. me.mainSheet.name('blockLibSheet');
  97. sheetCommonObj.spreadDefaultStyle(me.mainSpread);
  98. function showBlockTree(datas) {
  99. me.mainTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
  100. me.mainTreeController = TREE_SHEET_CONTROLLER.createNew(me.mainTree, me.mainSheet, me.mainSetting);
  101. me.mainTree.loadDatas(datas);
  102. me.mainTreeController.showTreeData();
  103. me.mainSheet.getRange(-1, 0, -1, 1).cellType(me.getTreeCell(me.mainTree));
  104. me.mainTree.selected = me.mainTree.items[0];
  105. me.mainTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
  106. blockLibObj.loadDetailDatas(node);
  107. });
  108. };
  109. showBlockTree(me.mainDatas);
  110. me.billSpread = sheetCommonObj.buildSheet($('#div_block_bill')[0], me.billSetting, 1);
  111. me.billSheet = me.billSpread.getSheet(0);
  112. sheetCommonObj.spreadDefaultStyle(me.billSpread);
  113. me.billSheet.setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
  114. me.rationSpread = sheetCommonObj.buildSheet($('#div_block_ration')[0], me.rationSetting, 1);
  115. me.rationSheet = me.rationSpread.getSheet(0);
  116. sheetCommonObj.spreadDefaultStyle(me.rationSpread);
  117. me.rationSheet.setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
  118. me.loadTreeContextMenu();
  119. me.mainSpread.bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
  120. me.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onCellDoubleClick);
  121. $.bootstrapLoading.end();
  122. },
  123. loadDetailDatas: function (node){
  124. let me = this;
  125. if (node.data.type == 2){
  126. let sourceNode = node.data.sourceNode;
  127. let rations = sourceNode.children;
  128. let rationDatas = [];
  129. for (let r of rations){
  130. rationDatas.push(r.data);
  131. };
  132. sheetCommonObj.showData(me.billSheet, me.billSetting, [sourceNode.data]);
  133. me.changeBillText(sourceNode.data);
  134. let rCount = (rationDatas.length > 0) ? rationDatas.length : 1;
  135. me.rationSheet.setRowCount(rCount, GC.Spread.Sheets.SheetArea.viewport);
  136. sheetCommonObj.showData(me.rationSheet, me.rationSetting, rationDatas);
  137. me.changeRationText(rationDatas);
  138. }
  139. else{
  140. sheetCommonObj.cleanSheet(me.billSheet, me.billSetting, 1);
  141. sheetCommonObj.cleanSheet(me.rationSheet, me.rationSetting, 1);
  142. }
  143. },
  144. getTreeCell: function (tree) {
  145. let me = this;
  146. let indent = 20, levelIndent = -5, halfBoxLength = 5, halfExpandLength = 3, imgWidth = 14, imgHeight = 14;
  147. let TreeCell = function () {};
  148. TreeCell.prototype = new GC.Spread.Sheets.CellTypes.Text();
  149. TreeCell.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
  150. if (style.backColor) {
  151. ctx.save();
  152. ctx.fillStyle = style.backColor;
  153. ctx.fillRect(x, y, w, h);
  154. ctx.restore();
  155. } else {
  156. ctx.clearRect(x, y, w, h);
  157. };
  158. let drawLine = function (canvas, x1, y1, x2, y2, color) {
  159. ctx.save();
  160. ctx.translate(0.5, 0.5);
  161. ctx.beginPath();
  162. ctx.moveTo(x1, y1);
  163. ctx.lineTo(x2, y2);
  164. ctx.strokeStyle = color;
  165. ctx.stroke();
  166. ctx.restore();
  167. };
  168. let drawExpandBox = function (ctx, x, y, w, h, centerX, centerY, expanded) {
  169. let rect = {}, h1, h2, offset = 1;
  170. rect.top = centerY - halfBoxLength;
  171. rect.bottom = centerY + halfBoxLength;
  172. rect.left = centerX - halfBoxLength;
  173. rect.right = centerX + halfBoxLength;
  174. if (rect.left < x + w) {
  175. rect.right = Math.min(rect.right, x + w);
  176. ctx.save();
  177. ctx.translate(0.5, 0.5);
  178. ctx.strokeStyle = 'black';
  179. ctx.beginPath();
  180. ctx.moveTo(rect.left, rect.top);
  181. ctx.lineTo(rect.left, rect.bottom);
  182. ctx.lineTo(rect.right, rect.bottom);
  183. ctx.lineTo(rect.right, rect.top);
  184. ctx.lineTo(rect.left, rect.top);
  185. ctx.stroke();
  186. ctx.fillStyle = 'white';
  187. ctx.fill();
  188. ctx.restore();
  189. // Draw Horizontal Line
  190. h1 = centerX - halfExpandLength;
  191. h2 = Math.min(centerX + halfExpandLength, x + w);
  192. if (h2 > h1) {
  193. drawLine(ctx, h1, centerY, h2, centerY, 'black');
  194. }
  195. // Draw Vertical Line
  196. if (!expanded && (centerX < x + w)) {
  197. drawLine(ctx, centerX, centerY - halfExpandLength, centerX, centerY + halfExpandLength, 'black');
  198. }
  199. }
  200. };
  201. let node = tree.items[options.row];
  202. if (!node) return;
  203. let showTreeLine = true;
  204. let centerX = Math.floor(x) + node.depth() * indent + node.depth() * levelIndent + indent / 2;
  205. let x1 = centerX + indent / 2;
  206. let centerY = Math.floor((y + (y + h)) / 2);
  207. let y1;
  208. // Draw Horizontal Line、Image、sibling Vertical Line
  209. if (centerX < x + w) {
  210. // Draw Horizontal Line
  211. drawLine(ctx, centerX, centerY, Math.min(x1, x + w), centerY, 'gray');
  212. // Draw Image
  213. let imgId;
  214. if (node.data.type === 0) imgId = 'blockLib_pic'
  215. else if (node.data.type === 1) imgId = 'folder_pic'
  216. else if (node.data.type === 2) {
  217. imgId = 'block_pic';
  218. };
  219. let img = document.getElementById(imgId);
  220. ctx.drawImage(img, centerX+indent/2+3, centerY - 7, imgWidth, imgHeight);
  221. // Draw Vertical Line
  222. y1 = node.isLast() ? centerY : y + h;
  223. if (node.isFirst() && !node.parent/*.parent*/) {
  224. drawLine(ctx, centerX, centerY, centerX, y1, 'gray');
  225. } else {
  226. drawLine(ctx, centerX, y, centerX, y1, 'gray');
  227. }
  228. }
  229. // Draw Expand Box
  230. if (node.children.length > 0) {
  231. drawExpandBox(ctx, x, y, w, h, centerX, centerY, node.expanded);
  232. }
  233. // Draw Parent Line
  234. var curNode = node.parent, parentCenterX = centerX - indent - levelIndent;
  235. while (curNode) {
  236. if (!curNode.isLast()) {
  237. if (parentCenterX < x + w) {
  238. drawLine(ctx, parentCenterX, y, parentCenterX, y + h, 'gray');
  239. }
  240. }
  241. curNode = curNode.parent;
  242. parentCenterX -= (indent + levelIndent);
  243. }
  244. // Draw Text
  245. x = x + (node.depth() + 1) * indent + node.depth() * levelIndent + imgWidth + 3;
  246. w = w - (node.depth() + 1) * indent - node.depth() * levelIndent - imgWidth - 3;
  247. GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
  248. };
  249. TreeCell.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
  250. let info = {x: x, y: y, row: context.row, col: context.col, cellStyle: cellStyle, cellRect: cellRect, sheetArea: context.sheetArea};
  251. let node = tree.items[info.row];
  252. let offset = -1;
  253. let centerX = info.cellRect.x + offset + node.depth() * indent + node.depth() * levelIndent + indent / 2;
  254. let text = context.sheet.getText(info.row, info.col);
  255. let value = context.sheet.getValue(info.row, info.col);
  256. let acStyle = context.sheet.getActualStyle(info.row, info.col),
  257. zoom = context.sheet.zoom();
  258. let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, {sheet: context.sheet, row: info.row, col: info.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport});
  259. if(info.x > centerX + halfBoxLength && info.x < centerX + halfBoxLength + imgWidth + indent/2+3 + textLength){
  260. info.isReservedLocation = true;
  261. }
  262. return info;
  263. };
  264. TreeCell.prototype.processMouseDown = function (hitinfo) {
  265. let offset = -1;
  266. let node = tree.items[hitinfo.row];
  267. let centerX = hitinfo.cellRect.x + offset + node.depth() * indent + node.depth() * levelIndent + indent / 2;
  268. let centerY = (hitinfo.cellRect.y + offset + (hitinfo.cellRect.y + offset + hitinfo.cellRect.height)) / 2;
  269. let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
  270. let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
  271. let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
  272. zoom = hitinfo.sheet.zoom();
  273. let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, {sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport});
  274. //(图标+名字)区域
  275. function withingClickArea(){
  276. return hitinfo.x > centerX + halfBoxLength && hitinfo.x < centerX + halfBoxLength + imgWidth + indent/2+3 + textLength;
  277. }
  278. if (hitinfo.x > centerX - halfBoxLength && hitinfo.x < centerX + halfBoxLength && hitinfo.y > centerY - halfBoxLength && hitinfo.y < centerY + halfBoxLength) {
  279. node.setExpanded(!node.expanded);
  280. TREE_SHEET_HELPER.massOperationSheet(hitinfo.sheet, function () {
  281. let iCount = node.posterityCount(), i, child;
  282. for (i = 0; i < iCount; i++) {
  283. child = tree.items[hitinfo.row + i + 1];
  284. hitinfo.sheet.setRowVisible(hitinfo.row + i + 1, child.visible, hitinfo.sheetArea);
  285. }
  286. hitinfo.sheet.invalidateLayout();
  287. });
  288. hitinfo.sheet.repaint();
  289. }
  290. };
  291. TreeCell.prototype.processMouseMove = function (hitInfo) {
  292. let sheet = hitInfo.sheet;
  293. let div = sheet.getParent().getHost();
  294. let canvasId = div.id + "vp_vp";
  295. /* let canvas = $(`#${canvasId}`)[0];
  296. //改变鼠标图案
  297. if (sheet && hitInfo.isReservedLocation) {
  298. canvas.style.cursor='pointer';
  299. return true;
  300. }else{
  301. canvas.style.cursor='default';
  302. }*/
  303. return false;
  304. };
  305. TreeCell.prototype.processMouseEnter = function (hitinfo) {
  306. let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
  307. let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
  308. let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
  309. let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
  310. zoom = hitinfo.sheet.zoom();
  311. let node = me.mainTree.items[hitinfo.row];
  312. let nodeIndent = node ? (node.depth() + 1) * indent + node.depth() * levelIndent + imgWidth + 3 : 0;
  313. let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, {sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport});
  314. let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
  315. if(textLength > cellWidth - nodeIndent){
  316. TREE_SHEET_HELPER.showTipsDiv(text,{pos: {}},hitinfo);
  317. }
  318. };
  319. TreeCell.prototype.processMouseLeave = function (hitinfo) {
  320. let me = this;
  321. TREE_SHEET_HELPER.tipDiv = 'hide';
  322. if (TREE_SHEET_HELPER._toolTipElement) {
  323. $(TREE_SHEET_HELPER._toolTipElement).hide();
  324. TREE_SHEET_HELPER._toolTipElement = null;
  325. };
  326. TREE_SHEET_HELPER.tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
  327. };
  328. return new TreeCell();
  329. },
  330. newNode: function (nodeType, nodeName, categoryID, sourceNode){ // 1 分类(只用前两个参数) 2 块文件
  331. let tree = blockLibObj.mainTree;
  332. let pID = -1, nID = -1;
  333. let select = tree.selected;
  334. if (nodeType == 1){
  335. if (!select) {
  336. nID = -1;
  337. }
  338. else if (select.data.type == 1){
  339. nID = select.getNextSiblingID();
  340. }
  341. else if (select.data.type == 2){
  342. nID = select.parent.getNextSiblingID();
  343. };
  344. }
  345. else if (nodeType == 2) {
  346. pID = categoryID;
  347. nID = -1;
  348. }
  349. let newNode = tree.insert(pID, nID);
  350. newNode.data.type = nodeType;
  351. newNode.data.name = nodeName;
  352. if (nodeType == 2)
  353. newNode.data.sourceNode = sourceNode;
  354. tree.selected = newNode;
  355. let sheet = blockLibObj.mainSheet;
  356. sheet.suspendPaint();
  357. sheet.suspendEvent();
  358. let idx = tree.items.indexOf(newNode);
  359. sheet.addRows(idx, 1);
  360. sheet.getRange(idx, 0, 1, 1).locked(true);
  361. sheet.setValue(idx, 0, newNode.data.name);
  362. sheet.setSelection(idx, 0, 1, 1);
  363. sheet.resumeEvent();
  364. sheet.resumePaint();
  365. },
  366. reName: function (node, newName){
  367. node.data.name = newName;
  368. let idx = blockLibObj.mainTree.items.indexOf(node);
  369. blockLibObj.mainSheet.setValue(idx, 0, newName);
  370. },
  371. getCategories: function () {
  372. let nodes = [], node = blockLibObj.mainTree.items[0];
  373. nodes.push(node);
  374. while (node.nextSibling != null){
  375. node = node.nextSibling;
  376. nodes.push(node);
  377. };
  378. return nodes;
  379. },
  380. curIsBlock: function () {
  381. return this.mainTree.selected.data.type == 2;
  382. },
  383. curIsCategory: function () {
  384. return this.mainTree.selected.data.type == 1;
  385. },
  386. refreshSpread: function (){
  387. if (this.mainSpread)
  388. this.mainSpread.refresh();
  389. if (this.billSpread)
  390. this.billSpread.refresh();
  391. if (this.rationSpread)
  392. this.rationSpread.refresh();
  393. },
  394. changeRationText: function (rationDatas) {
  395. let sheet = this.rationSheet;
  396. sheet.suspendPaint();
  397. sheet.suspendEvent();
  398. for (let i = 0; i < rationDatas.length; i++) {
  399. let pID = rationDatas[i].programID;
  400. if (pID) sheet.setValue(i, 4, projectObj.project.calcProgram.compiledTemplateMaps[pID]);
  401. if (rationDatas[i].feesIndex && rationDatas[i].feesIndex.common)
  402. sheet.setValue(i, 5, rationDatas[i].feesIndex.common.unitFee);
  403. }
  404. sheet.resumeEvent();
  405. sheet.resumePaint();
  406. },
  407. changeBillText: function (billData){
  408. let sheet = this.billSheet;
  409. sheet.suspendPaint();
  410. sheet.suspendEvent();
  411. if (billData.feesIndex && billData.feesIndex.common)
  412. sheet.setValue(0, 3, billData.feesIndex.common.unitFee);
  413. sheet.resumeEvent();
  414. sheet.resumePaint();
  415. },
  416. loadTreeContextMenu: function (){
  417. let me = this;
  418. $.contextMenu({
  419. selector: '#div_block_tree',
  420. build: function ($trigger, e) {
  421. SheetDataHelper.safeRightClickSelection($trigger, e, me.mainSpread);
  422. me.onEnterCell();
  423. },
  424. items: {
  425. "oneToOneClone": {
  426. name: '一对一克隆',
  427. icon: "fa-battery-empty",
  428. disabled: function () {
  429. },
  430. visible: function(key, opt){
  431. return me.curIsBlock();
  432. },
  433. callback: function (key, opt) {
  434. }
  435. },
  436. "oneToMoreClone": {
  437. name: '一对多克隆',
  438. icon: "fa-battery-half",
  439. disabled: function () {
  440. },
  441. visible: function(key, opt){
  442. return me.curIsBlock();
  443. },
  444. callback: function (key, opt) {
  445. }
  446. },
  447. "moreToMoreClone": {
  448. name: '多对多克隆',
  449. icon: "fa-battery-full",
  450. disabled: function () {
  451. },
  452. visible: function(key, opt){
  453. return me.curIsCategory();
  454. },
  455. callback: function (key, opt) {
  456. }
  457. },
  458. "delete": {
  459. name: '删除',
  460. icon: "delete",
  461. disabled: function () {
  462. },
  463. visible: function(key, opt){
  464. return true;
  465. },
  466. callback: function (key, opt) {
  467. }
  468. },
  469. "moveBlock": {
  470. name: '移动模板',
  471. icon: "cut",
  472. disabled: function () {
  473. },
  474. visible: function(key, opt){
  475. return me.curIsBlock();
  476. },
  477. callback: function (key, opt) {
  478. }
  479. }
  480. }
  481. });
  482. },
  483. onEnterCell: function (sender, args) {
  484. let me = blockLibObj;
  485. me.mainTree.selected = me.mainTree.items[me.mainSheet.getActiveRowIndex()];
  486. },
  487. onCellDoubleClick: function (sender, args) {
  488. let me = blockLibObj;
  489. //
  490. }
  491. };
  492. $(document).ready(function(){
  493. $('#blockLibTab').on('click', function (){
  494. if ($("#kmbk").is(":visible")){
  495. if (!blockLibObj.mainSpread){
  496. blockLibObj.buildSheet();
  497. };
  498. }
  499. });
  500. $('#btn_block_newFolder').on('click', function (){
  501. $('#input_block_newFolder').val('');
  502. });
  503. $('#btn_block_newFolder_add').on('click', function (){
  504. let name = $('#input_block_newFolder').val();
  505. if (name != '') blockLibObj.newNode(1, name);
  506. });
  507. $('#btn_block_reName').on('click', function (){
  508. let select = blockLibObj.mainTree.selected;
  509. $('#input_block_reName').val(select.data.name);
  510. });
  511. $('#btn_block_reName_OK').on('click', function (){
  512. let select = blockLibObj.mainTree.selected;
  513. let oldName = select.data.name;
  514. let newName = $('#input_block_reName').val();
  515. if (oldName != newName) blockLibObj.reName(select, newName);
  516. });
  517. });