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