rpt_tpl_main.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. 'use strict'
  2. const
  3. IDMark_Switch = "_switch",
  4. IDMark_Icon = "_ico",
  5. IDMark_Span = "_span",
  6. IDMark_Input = "_input",
  7. IDMark_Check = "_check",
  8. IDMark_Edit = "_edit",
  9. IDMark_Remove = "_remove",
  10. IDMark_Ul = "_ul",
  11. IDMark_A = "_a",
  12. //以上的常量是在查找zTree默认生成的dom对象时用到(tID + 后缀)
  13. NODE_LEVEL_COMPILATION_NEW = 1,
  14. NODE_LEVEL_USER = 0;
  15. // 工程类型枚举值
  16. const valuationSelectorMap = {
  17. valuationSelector_NA: 'N/A',
  18. valuationSelector_suggestion: '建议估算',
  19. valuationSelector_feasibility: '可行性估算',
  20. valuationSelector_rough: '概算',
  21. valuationSelector_bill: '预算',
  22. valuationSelector_three_bill_budget: '三级清单预算',
  23. valuationSelector_ration: '清单预算',
  24. valuationSelector_changeBudget: '变更预算',
  25. valuationSelector_settlement: '结算'
  26. }
  27. let rptTplObj = {
  28. iniPage: function () {
  29. zTreeOprObj.getCompilationList();
  30. rpt_tpl_cfg_helper.getReportTplCfg();
  31. selectableFiledTreeOprObj.iniTree();
  32. preview_util.drawBorder($("#tplCanvas")[0]);
  33. calculationTreeOprObj.buildRunType();
  34. preHandleObj.buildTypeData();
  35. calculationTreeOprObj.iniExtCodeTpl();
  36. }
  37. };
  38. let zTreeOprObj = {
  39. treeObj: null,
  40. currentNode: null,
  41. moveSrcTopNode: null,
  42. dupTplIds: null,
  43. hasRefreshedDupRefIds: false,
  44. getCompilationList: function () {
  45. let me = zTreeOprObj, params = {};
  46. CommonAjax.postEx("report_tpl_api/getCompilationList", params, 20000, true, function (result) {
  47. //console.log(result);
  48. for (let item of result) {
  49. // if (item.is_release) {
  50. $("#compilations").append("<option value='" + item._id + "'>" + item.name + "</option>");
  51. // }
  52. }
  53. // me.getReportTemplateTree($("#compilations").get(0));
  54. me.getReportTemplateTreeEx($("#compilations").get(0));
  55. }, null, null
  56. );
  57. },
  58. refreshNodes: function () {
  59. let me = this;
  60. let private_setupIsParent = function (node) {
  61. // if (node.nodeType === RT.NodeType.NODE || node.level === 0) {
  62. if (node.nodeType === RT.NodeType.NODE || node.level <= NODE_LEVEL_COMPILATION_NEW) {
  63. node.isParent = true;
  64. } else {
  65. node.isParent = false;
  66. }
  67. if (node.items && node.items.length) {
  68. for (let i = 0; i < node.items.length; i++) {
  69. private_setupIsParent(node.items[i]);
  70. }
  71. }
  72. };
  73. let topNodes = me.treeObj.getNodes();
  74. for (let i = 0; i < topNodes.length; i++) {
  75. private_setupIsParent(topNodes[i]);
  76. }
  77. me.treeObj.refresh();
  78. },
  79. removeTreeRootNode: function (rawNode, isAsync, callback, failCallback) {
  80. let params = {};
  81. params.compilationId = rawNode.compilationId;
  82. params.engineerId = rawNode.engineerId;
  83. params.userId = rawNode.userId;
  84. params.isPhysically = true;
  85. CommonAjax.postEx("report_tpl_api/removeTreeRootNode", params, 5000, isAsync, callback, failCallback, null);
  86. },
  87. copyReportTemplate: function (orgID, newID, isAsync, callback, failCallback) {
  88. let params = {};
  89. params.orgRptTplId = orgID;
  90. params.newRptTplId = newID;
  91. CommonAjax.postEx("report_tpl_api/copyRptTpl", params, 5000, isAsync, callback, failCallback, null);
  92. },
  93. updateTreeRootNode: function (rawNode, isAsync, callback, failCallback) {
  94. let params = {};
  95. params.doc = rawNode;
  96. CommonAjax.postEx("report_tpl_api/updateTreeRootNode", params, 5000, isAsync, callback, failCallback, null);
  97. },
  98. updateTopNodeName: function (topNode, isAsync, callback, failCallback) {
  99. let params = {};
  100. params.compilationId = topNode.compilationId;
  101. params.engineerId = topNode.engineerId;
  102. params.userId = topNode.userId;
  103. params.nodeName = topNode.name;
  104. CommonAjax.postEx("report_tpl_api/updateTopNodeName", params, 5000, isAsync, callback, failCallback, null);
  105. },
  106. updateSubNode: function (topNode, subNode, isAsync, callback, failCallback) {
  107. let params = {};
  108. params.compilationId = topNode.compilationId;
  109. params.engineerId = topNode.engineerId;
  110. params.userId = topNode.userId;
  111. params.subNode = subNode;
  112. CommonAjax.postEx("report_tpl_api/updateSubLevelOneNode", params, 5000, isAsync, callback, failCallback, null);
  113. },
  114. createIniNode: function () {
  115. return {
  116. nodeType: RT.NodeType.TEMPLATE,
  117. refId: -1,
  118. name: "",
  119. ID: -1,
  120. items: null
  121. };
  122. },
  123. buildRootNodeDoc: function (topNode, excludeNode) {
  124. let me = this, rst = null;
  125. if (topNode) {
  126. rst = {
  127. compilationId: topNode.compilationId,
  128. engineerId: topNode.engineerId,
  129. userId: topNode.userId,
  130. properties: topNode.properties,
  131. released: true,
  132. isDeleted: topNode.isDeleted,
  133. items: me.private_build_items(topNode.items, excludeNode),
  134. name: topNode.name
  135. };
  136. }
  137. return rst;
  138. },
  139. buildSubRootNodeDoc: function (subNode) {
  140. let me = this, rst = null;
  141. if (subNode) {
  142. let isReleased = false;
  143. if (subNode.nodeType === RT.NodeType.TEMPLATE) {
  144. isReleased = subNode.checked;
  145. }
  146. rst = {
  147. nodeType: subNode.nodeType,
  148. refId: subNode.refId,
  149. ID: subNode.ID,
  150. released: isReleased,
  151. items: me.private_build_items(subNode.items, null),
  152. name: subNode.name
  153. };
  154. if (subNode.hasOwnProperty('flags')) {
  155. rst.flags = subNode.flags;
  156. }
  157. }
  158. return rst;
  159. },
  160. private_build_items: function (items, excludeNode) {
  161. let me = this, itemRst = null;
  162. if (items && items.length > 0) {
  163. itemRst = [];
  164. for (let item of items) {
  165. if (item !== excludeNode) {
  166. let isReleased = false;
  167. if (item.nodeType === RT.NodeType.TEMPLATE) {
  168. isReleased = item.checked;
  169. }
  170. let ir = {};
  171. ir.nodeType = item.nodeType;
  172. ir.refId = item.refId;
  173. ir.name = item.name;
  174. ir.ID = item.ID;
  175. ir.released = isReleased;
  176. if (item.hasOwnProperty('flags')) {
  177. ir.flags = item.flags;
  178. }
  179. ir.items = me.private_build_items(item.items);
  180. itemRst.push(ir);
  181. }
  182. }
  183. }
  184. return itemRst;
  185. },
  186. addHoverDom: function (treeId, treeNode) {
  187. let me = zTreeOprObj, sObj = $("#" + treeNode.tId + "_span");
  188. if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0 || treeNode.nodeType === RT.NodeType.TEMPLATE) return;
  189. if (treeNode.level === 0) {
  190. let addStr = "<span class='button star' id='addBtn_" + treeNode.tId + "' title='新增编办类型' onfocus='this.blur();'></span>";
  191. sObj.after(addStr);
  192. let btn = $("#addBtn_" + treeNode.tId);
  193. if (btn) btn.bind("click", function () {
  194. let rawNode = me.createIniComilationNode();
  195. if (!me.chkIfDupCompilationNode(rawNode, treeNode)) {
  196. rawNode.userId = treeNode.userId;
  197. me.addNewNodeEx(rawNode, function (rst) {
  198. if (rst) {
  199. let newNodes = [], isSilent = false;
  200. rawNode.isParent = true;
  201. newNodes.push(rawNode);
  202. if (treeNode.items && treeNode.items.length > 0) {
  203. let insertIdx = -1;
  204. for (let i = 0; i < treeNode.items.length; i++) {
  205. if (treeNode.items[i].compilationId === rawNode.compilationId) {
  206. if (treeNode.items[i].engineerId > rawNode.engineerId) {
  207. insertIdx = i;
  208. break;
  209. }
  210. }
  211. }
  212. me.treeObj.addNodes(treeNode, insertIdx, newNodes, isSilent);
  213. } else {
  214. me.treeObj.addNodes(treeNode, 0, newNodes, isSilent);
  215. }
  216. } else {
  217. alert("后台创建失败,请确认是否有重复类型跟节点!")
  218. }
  219. }, null);
  220. } else {
  221. alert("有重复编办!");
  222. }
  223. });
  224. } else {
  225. let addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='新增子目录' onfocus='this.blur();'></span>";
  226. sObj.after(addStr);
  227. let btn = $("#addBtn_" + treeNode.tId);
  228. if (btn) btn.bind("click", function () {
  229. me.getNewNodeID(1, function (newNodeID) {
  230. let rawNode = me.createIniNode();
  231. rawNode.nodeType = RT.NodeType.NODE;
  232. rawNode.name = "新增子节点";
  233. rawNode.ID = newNodeID;
  234. let newNodes = [], isSilent = false;
  235. newNodes.push(rawNode);
  236. if (me.treeObj) {
  237. let insertIdx = -1;
  238. if (treeNode.items && treeNode.items.length > 0) {
  239. for (let i = treeNode.items.length - 1; i >= 0; i--) {
  240. if (treeNode.items[i].nodeType === RT.NodeType.NODE) {
  241. insertIdx = i + 1;
  242. break;
  243. } else {
  244. insertIdx = i;
  245. }
  246. }
  247. }
  248. me.treeObj.addNodes(treeNode, insertIdx, newNodes, isSilent);
  249. let tn = me.getParentNodeByNodeLevel(treeNode, NODE_LEVEL_COMPILATION_NEW);
  250. let newTopNode = me.buildRootNodeDoc(tn);
  251. me.updateTreeRootNode(newTopNode, true, function (rst) {
  252. if (!(rst)) {
  253. alert("新增节点失败!");
  254. }
  255. me.refreshNodes();
  256. }, null);
  257. }
  258. });
  259. });
  260. addStr = "<span class='button blue_core' id='addBtn2_" + treeNode.tId + "' title='新增报表模板' onfocus='this.blur();'></span>";
  261. sObj.after(addStr);
  262. btn = $("#addBtn2_" + treeNode.tId + "");
  263. if (btn) btn.bind("click", function () {
  264. // let me = zTreeOprObj;
  265. if (treeNode.nodeType === RT.NodeType.NODE || treeNode.level === NODE_LEVEL_COMPILATION_NEW) {
  266. me.getNewNodeID(1, function (newNodeID) {
  267. let rawNode = me.createIniNode();
  268. rawNode.nodeType = RT.NodeType.TEMPLATE;
  269. rawNode.name = "新增报表模板";
  270. rawNode.ID = newNodeID;
  271. rawNode.released = false;
  272. let newNodes = [], isSilent = false;
  273. newNodes.push(rawNode);
  274. me.treeObj.addNodes(treeNode, -1, newNodes, isSilent);
  275. let tn = me.getParentNodeByNodeLevel(treeNode, NODE_LEVEL_COMPILATION_NEW);
  276. let topNode = me.buildRootNodeDoc(tn);
  277. me.updateTreeRootNode(topNode, true, function (rst) {
  278. if (!(rst)) {
  279. alert("新增空白模板失败!");
  280. }
  281. me.refreshNodes();
  282. }, null);
  283. });
  284. }
  285. });
  286. }
  287. },
  288. removeHoverDom: function (treeId, treeNode) {
  289. $("#addBtn_" + treeNode.tId).unbind().remove();
  290. $("#addBtn2_" + treeNode.tId).unbind().remove();
  291. },
  292. addNewNodeEx: function (rawNode, callback, failCallback) {
  293. let params = {};
  294. params.doc = rawNode;
  295. CommonAjax.postEx("report_tpl_api/createTreeRootNode", params, 5000, true, callback, failCallback, null);
  296. },
  297. onCheck: function (event, treeId, treeNode) {
  298. let me = zTreeOprObj;
  299. let topPNode = me.getParentNodeByNodeLevel(treeNode, NODE_LEVEL_COMPILATION_NEW);
  300. let newTopNode = me.buildRootNodeDoc(topPNode);
  301. me.updateTreeRootNode(newTopNode, true, function (rst) {
  302. if (!(rst)) {
  303. alert("修改发布状态失败!");
  304. }
  305. });
  306. },
  307. onBeforeDrag: function (treeId, treeNodes) {
  308. let rst = true;
  309. for (let node of treeNodes) {
  310. if (node.level === 0 || node.nodeType !== RT.NodeType.TEMPLATE) {
  311. rst = false;
  312. break;
  313. }
  314. }
  315. return rst;
  316. },
  317. onBeforeDrop: function (treeId, treeNodes, targetNode, moveType, isCopy) {
  318. let me = zTreeOprObj, rst = true;
  319. let srcNode = treeNodes[0];
  320. let sourceTopNode = me.getParentNodeByNodeLevel(srcNode, NODE_LEVEL_COMPILATION_NEW);
  321. let targetTopNode = me.getParentNodeByNodeLevel(targetNode, NODE_LEVEL_COMPILATION_NEW);
  322. me.moveSrcTopNode = null;
  323. if (moveType === 'inner') {
  324. if (targetNode.nodeType === RT.NodeType.TEMPLATE) {
  325. //模板节点不能成为另一个模板节点的子节点。不过zTree控件默认会处理,这里的代码应该走不到,放在这里以防万一
  326. rst = false;
  327. } else {
  328. if (sourceTopNode !== targetTopNode) {
  329. if (!isCopy) {
  330. if (!confirm("是否真的要把报表模板移动到另一个工程类型?")) {
  331. rst = false;
  332. }
  333. }
  334. } else {
  335. //同一根节点下,可以随便移动或copy
  336. }
  337. }
  338. } else {
  339. if (targetNode.level === 0 || targetNode.nodeType !== RT.NodeType.TEMPLATE) {
  340. //模板节点不能与类型节点或目录节点同级!
  341. rst = false;
  342. } else {
  343. if (sourceTopNode !== targetTopNode) {
  344. if (!isCopy) {
  345. if (!confirm("是否真的要把报表模板移动到另一个工程类型?")) {
  346. rst = false;
  347. }
  348. }
  349. } else {
  350. //同一根节点下,可以随便移动或copy
  351. }
  352. }
  353. }
  354. if (rst && !isCopy && sourceTopNode !== targetTopNode) {
  355. me.moveSrcTopNode = sourceTopNode;
  356. }
  357. return rst;
  358. },
  359. onDrop: function (event, treeId, treeNodes, targetNode, moveType, isCopy) {
  360. let me = zTreeOprObj;
  361. zTreeOprObj.treeObj.checkNode(treeNodes[0], false, false);
  362. treeNodes[0].released = false;
  363. let targetTopNode = me.getParentNodeByNodeLevel(targetNode, NODE_LEVEL_COMPILATION_NEW);
  364. let newTopNode = null;
  365. let canContinue = false;
  366. if (isCopy) {
  367. me.getNewNodeID(1, function (newNodeID) {
  368. let orgID = treeNodes[0].refId; //refId才是正确的模板ID(因可能copy一个有引用的节点),
  369. treeNodes[0].ID = newNodeID;
  370. if (confirm("是否引用相同的报表模板?")) {
  371. newTopNode = me.buildRootNodeDoc(targetTopNode);
  372. me.updateTreeRootNode(newTopNode, false, function (goodRst) {
  373. canContinue = true;
  374. if (treeNodes[0].rptTpl) {
  375. treeNodes[0].rptTpl.ID = newNodeID;
  376. }
  377. me.currentNode = treeNodes[0];
  378. me.chkAndSetDupRefTplIds(me.treeObj.getNodes(), null);
  379. me.treeObj.refresh();
  380. me.chkAndRreshRefTpl();
  381. }, function (badRst) {
  382. displayMessage("更新模板节点失败!", "red", 2000);
  383. // console.log(badRst.toString());
  384. console.log(badRst);
  385. });
  386. } else {
  387. treeNodes[0].refId = newNodeID;
  388. // targetNode.refId = newNodeID; //targetNode可以是父节点也可以是兄弟节点,没必要引用相同的tplID
  389. newTopNode = me.buildRootNodeDoc(targetTopNode);
  390. me.copyReportTemplate(orgID, newNodeID, true, function (goodResult) {
  391. me.updateTreeRootNode(newTopNode, true, function (goodRst) {
  392. canContinue = true;
  393. // treeObj.updateNode(nodes[0]);
  394. zTreeOprObj.treeObj.updateNode(treeNodes[0]);
  395. if (treeNodes[0].rptTpl) {
  396. treeNodes[0].rptTpl.ID = newNodeID;
  397. }
  398. me.currentNode = treeNodes[0];
  399. me.chkAndSetDupRefTplIds(me.treeObj.getNodes(), null);
  400. me.treeObj.refresh();
  401. me.chkAndRreshRefTpl();
  402. }, function (badRst) {
  403. displayMessage("更新模板节点失败!", "red", 2000);
  404. // console.log(badRst.toString());
  405. console.log(badRst);
  406. });
  407. }, function (badResult) {
  408. displayMessage("Copy请求失败!", "red", 2000);
  409. // console.log(badResult.toString());
  410. console.log(badResult);
  411. });
  412. }
  413. });
  414. // if (canContinue) {
  415. // me.chkAndRreshRefTpl();
  416. // }
  417. } else {
  418. newTopNode = me.buildRootNodeDoc(targetTopNode);
  419. me.updateTreeRootNode(newTopNode, false, function (rst) {
  420. canContinue = true;
  421. me.currentNode = treeNodes[0];
  422. }, function (badResult) {
  423. displayMessage("移动请求失败!", "red", 2000);
  424. console.log(badResult.toString());
  425. canContinue = false;
  426. });
  427. if (canContinue && !isCopy && me.moveSrcTopNode) {
  428. let newSrcTopNode = me.buildRootNodeDoc(me.moveSrcTopNode);
  429. me.updateTreeRootNode(newSrcTopNode, true, function (rst) {
  430. // canContinue = true;
  431. }, function (badResult) {
  432. displayMessage("移动请求失败!", "red", 2000);
  433. canContinue = true;
  434. });
  435. }
  436. me.moveSrcTopNode = null;
  437. }
  438. },
  439. addReportTemplate: function (newUsers) {
  440. let me = zTreeOprObj, params = {};
  441. params.compilationId = $("#compilations").get(0).value;
  442. params.userId = [];
  443. if (newUsers.length > 0) {
  444. for (let user of newUsers) {
  445. params.userId.push(user.userId);
  446. }
  447. }
  448. let allEngIds = [];
  449. for (let item of engineeringList) {
  450. allEngIds.push(item.value);
  451. }
  452. params.engineerId = allEngIds;
  453. CommonAjax.postEx("report_tpl_api/getRptTplTree", params, 20000, true, function (result) {
  454. result.sort(function (item1, item2) {
  455. let rst = 0;
  456. if (item1.userId === item2.userId) {
  457. rst = (item1.engineerId > item2.engineerId) ? 1 : ((item1.engineerId < item2.engineerId) ? -1 : 0);
  458. } else {
  459. if (item1.userId === "-100") {
  460. rst = 1
  461. } else if (item2.userId === "-100") {
  462. rst = -1
  463. } else {
  464. let idx1 = -1, idx2 = -1;
  465. for (let uidx = 0; uidx < newUsers.length; uidx++) {
  466. if (newUsers[uidx].userId === item1.userId) idx1 = uidx;
  467. if (newUsers[uidx].userId === item2.userId) idx2 = uidx;
  468. if (idx1 >= 0 && idx2 >= 0) {
  469. break;
  470. }
  471. rst = (idx1 > idx2) ? 1 : ((idx1 < idx2) ? -1 : 0);
  472. }
  473. }
  474. }
  475. return rst;
  476. });
  477. let allTopUserIdNodes = [];
  478. let allTopTplNodes = [];
  479. for (let user of newUsers) {
  480. allTopUserIdNodes.push(user.userId);
  481. allTopTplNodes.push({ userId: user.userId, name: user.real_name, items: [], isParent: true });
  482. }
  483. for (let item of result) {
  484. let uidx = allTopUserIdNodes.indexOf(item.userId);
  485. if (uidx >= 0) {
  486. item.isParent = true;
  487. allTopTplNodes[uidx].items.push(item);
  488. }
  489. }
  490. // zTreeHelper.createTreeDirectly(allTopTplNodes, setting, "rptTplTree", me);
  491. //add template nodes
  492. let isSilent = false;
  493. me.treeObj.addNodes(null, -1, allTopTplNodes, isSilent);
  494. me.refreshNodes();
  495. let private_setup_checked = function (itemNode) {
  496. if (itemNode.nodeType === RT.NodeType.NODE) {
  497. me.treeObj.setChkDisabled(itemNode, true);
  498. } else if (itemNode.nodeType === RT.NodeType.TEMPLATE) {
  499. me.treeObj.checkNode(itemNode, !!(itemNode.released));
  500. }
  501. if (itemNode.items && itemNode.items.length > 0) {
  502. for (let subItem of itemNode.items) {
  503. private_setup_checked(subItem);
  504. }
  505. }
  506. };
  507. let topNodes = me.treeObj.getNodes();
  508. // me.treeObj.expandAll(true);
  509. for (let node of topNodes) {
  510. me.treeObj.setChkDisabled(node, true);
  511. if (node.items && node.items.length > 0) {
  512. for (let item of node.items) {
  513. me.treeObj.setChkDisabled(item, true);
  514. private_setup_checked(item);
  515. }
  516. }
  517. }
  518. }, null, null);
  519. },
  520. chkAndSetDupRefTplIds: function (tplNodes, selectedRefId) {
  521. let me = zTreeOprObj, tmpRefIds = [];
  522. me.dupTplIds = [];
  523. let private_get_dup_ids = function (tplNode) {
  524. if (tplNode.refId && tplNode.refId !== -1) {
  525. let refId = tplNode.refId;
  526. if (tmpRefIds.indexOf(refId) < 0) {
  527. tmpRefIds.push(refId);
  528. } else {
  529. if (me.dupTplIds.indexOf(refId) < 0) {
  530. me.dupTplIds.push(refId);
  531. } else {
  532. //
  533. }
  534. }
  535. }
  536. if (tplNode.items && tplNode.items.length > 0) {
  537. for (let subTplNode of tplNode.items) {
  538. private_get_dup_ids(subTplNode);
  539. }
  540. }
  541. };
  542. let private_set_dup_icon = function (tplNode) {
  543. if (me.dupTplIds.indexOf(tplNode.refId) >= 0) {
  544. // tplNode.icon = "../../../../lib/ztree/css/img/diy/3.png"; //or below:
  545. if (selectedRefId && selectedRefId === tplNode.refId) {
  546. tplNode.icon = "/lib/ztree/css/img/diy/5.png";
  547. } else {
  548. tplNode.icon = "/lib/ztree/css/img/diy/3.png";
  549. }
  550. // tplNode.style = "background:url(/lib/ztree/css/img/diy/3.png) 0 0 no-repeat;"
  551. } else {
  552. //设置白板
  553. // if (!tplNode.isParent) tplNode.icon = "/lib/ztree/css/img/diy/10.png";
  554. if (!tplNode.isParent) tplNode.className = "button ico_docu";
  555. }
  556. if (tplNode.items && tplNode.items.length > 0) {
  557. for (let subTplNode of tplNode.items) {
  558. private_set_dup_icon(subTplNode);
  559. }
  560. }
  561. };
  562. for (let tplNodeItem of tplNodes) {
  563. private_get_dup_ids(tplNodeItem);
  564. }
  565. for (let tplNodeItem of tplNodes) {
  566. private_set_dup_icon(tplNodeItem);
  567. }
  568. if (selectedRefId) {
  569. me.hasRefreshedDupRefIds = true;
  570. } else {
  571. me.hasRefreshedDupRefIds = false;
  572. }
  573. },
  574. getReportTemplateTreeEx: function (compilationSelect) {
  575. let me = zTreeOprObj, params = {};
  576. params.compilationId = compilationSelect.value;
  577. CommonAjax.postEx("report_tpl_api/getTplTreeByCompilation", params, 20000, true, function (result) {
  578. result.sort(function (item1, item2) {
  579. let rst = 0;
  580. if (item1.userId === "-100") {
  581. rst = -1;
  582. } else if (item2.userId === "-100") {
  583. rst = 1;
  584. }
  585. return rst;
  586. });
  587. // me.chkAndSetDupRefTplIds(result);
  588. // console.log(dupRefIds);
  589. let allTopTplNodes = [{ userId: "-100", name: "公共模板", items: [], isParent: true, refId: "" }];
  590. if (result.length > 0) {
  591. if (!result[0].hasOwnProperty("refId")) {
  592. result[0].refId = "";
  593. }
  594. allTopTplNodes[0].items.push(result[0]);
  595. }
  596. let userIds = [];
  597. for (let idx = 1; idx < result.length; idx++) {
  598. let item = result[idx];
  599. if (!item.hasOwnProperty("refId")) {
  600. item.refId = "";
  601. }
  602. userIds.push(item.userId);
  603. }
  604. userListObj.findUsersByIds(userIds, function (userObjs) {
  605. for (let user of userObjs) {
  606. for (let itemIdx = 1; itemIdx < result.length; itemIdx++) {
  607. let item = result[itemIdx];
  608. if (item.userId === user._id) {
  609. allTopTplNodes.push({ userId: user.userId, name: user.real_name, items: [], isParent: true, refId: "" });
  610. allTopTplNodes[allTopTplNodes.length - 1].items.push(result[itemIdx]);
  611. break;
  612. }
  613. }
  614. }
  615. zTreeHelper.createTreeDirectly(allTopTplNodes, setting, "rptTplTree", me);
  616. let topNodes = me.treeObj.getNodes();
  617. me.chkAndSetDupRefTplIds(topNodes, null);
  618. me.refreshNodes();
  619. let private_setup_checked = function (itemNode) {
  620. if (itemNode.nodeType === RT.NodeType.NODE) {
  621. me.treeObj.setChkDisabled(itemNode, true);
  622. } else if (itemNode.nodeType === RT.NodeType.TEMPLATE) {
  623. me.treeObj.checkNode(itemNode, !!(itemNode.released));
  624. }
  625. if (itemNode.items && itemNode.items.length > 0) {
  626. for (let subItem of itemNode.items) {
  627. private_setup_checked(subItem);
  628. }
  629. }
  630. };
  631. me.treeObj.expandAll(true);
  632. for (let node of topNodes) {
  633. me.treeObj.setChkDisabled(node, true);
  634. if (node.items && node.items.length > 0) {
  635. for (let item of node.items) {
  636. me.treeObj.setChkDisabled(item, true);
  637. private_setup_checked(item);
  638. }
  639. }
  640. }
  641. });
  642. }, null, null);
  643. },
  644. getNewNodeID: function (scope, callback) {
  645. let params = {};
  646. params.scope = scope;
  647. CommonAjax.postEx("report_tpl_api/getNewNodeID", params, 5000, true, callback, null, null);
  648. },
  649. chkIfDupCompilationNode: function (rawNode, parentUserNode) {
  650. let rst = false;
  651. //在新的需求下,只需要检测编办与userId即可,无需工程id
  652. if (parentUserNode.items && parentUserNode.items.length > 0) {
  653. for (let node of parentUserNode.items) {
  654. if (node.compilationId === rawNode.compilationId && node.userId === rawNode.userId) {
  655. rst = true;
  656. break;
  657. }
  658. }
  659. }
  660. return rst;
  661. },
  662. createIniComilationNode: function () {
  663. //在新的需求下,无需工程id
  664. let rst = {
  665. compilationId: $("#compilations").get(0).selectedOptions[0].value,
  666. userId: (userAccount === 'admin') ? ("-100") : userID,
  667. properties: [],
  668. released: true,
  669. isDeleted: false,
  670. items: [],
  671. name: $("#compilations").get(0).selectedOptions[0].innerText
  672. };
  673. return rst;
  674. },
  675. onBeforeRemove: function (treeId, treeNode) {
  676. let canRemove = false;
  677. if (treeNode.level > NODE_LEVEL_USER) {
  678. if (!(treeNode.items) || treeNode.items.length < 1) {
  679. canRemove = confirm("请再确认您要删除!");
  680. } else {
  681. alert("含有子项,不能删除!");
  682. }
  683. } else {
  684. alert("不能删除用户级别模板!");
  685. }
  686. return canRemove;
  687. },
  688. onRemove: function (e, treeId, treeNode) {
  689. if (treeNode.level > NODE_LEVEL_USER) {
  690. let me = zTreeOprObj,
  691. topPNode = me.getParentNodeByNodeLevel(treeNode, NODE_LEVEL_COMPILATION_NEW);
  692. let rawNode = me.buildRootNodeDoc(topPNode, treeNode);
  693. if (treeNode.level === NODE_LEVEL_COMPILATION_NEW) {
  694. me.removeTreeRootNode(rawNode, true, function (rst) {
  695. if (!(rst)) {
  696. alert("删除请求失败!");
  697. }
  698. });
  699. } else {
  700. me.updateTreeRootNode(rawNode, true, function (rst) {
  701. if (!(rst)) {
  702. alert("删除请求失败!");
  703. }
  704. });
  705. }
  706. me.refreshNodes();
  707. }
  708. },
  709. beforeEditName: function (treeId, treeNode) {
  710. if (treeNode.level > NODE_LEVEL_COMPILATION_NEW) {
  711. setTimeout(function () {
  712. let ip = $("#" + treeNode.tId + IDMark_Input);
  713. if (ip.length > 0) {
  714. ip[0].className = "individualRename";
  715. } else {
  716. setTimeout(function () {
  717. let ip = $("#" + treeNode.tId + IDMark_Input);
  718. if (ip.length > 0) {
  719. ip[0].className = "individualRename";
  720. } else {
  721. console.log("sorry!");
  722. }
  723. }, 50);
  724. }
  725. }, 50);
  726. return true;
  727. } else {
  728. return false;
  729. }
  730. },
  731. beforeRename: function (treeId, treeNode, newName, isCancel) {
  732. if (newName.length === 0) {
  733. return false;
  734. }
  735. return true;
  736. },
  737. onRename: function (e, treeId, treeNode, isCancel) {
  738. if (!isCancel) {
  739. let me = zTreeOprObj;
  740. if (treeNode.level === 0) {
  741. //因结构变化,已经不允许更改顶节点名字
  742. } else {
  743. let subTopNode = me.getParentNodeByNodeLevel(treeNode, NODE_LEVEL_COMPILATION_NEW + 1);
  744. let topPNode = subTopNode.getParentNode();
  745. let rawNode = me.buildSubRootNodeDoc(subTopNode);
  746. me.updateSubNode(topPNode, rawNode, true, function (rst) {
  747. if (!(rst)) {
  748. alert('修改名称请求失败!');
  749. }
  750. });
  751. }
  752. }
  753. },
  754. onChangeFlag: function (flagProp, flagDom) {
  755. let me = zTreeOprObj;
  756. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE) {
  757. if (!me.currentNode.hasOwnProperty("flags")) {
  758. me.currentNode.flags = {};
  759. }
  760. me.currentNode.flags[flagProp] = (flagDom.selectedOptions[0].value === 'NA') ? null : flagDom.selectedOptions[0].value;
  761. let subTopNode = me.getParentNodeByNodeLevel(me.currentNode, NODE_LEVEL_COMPILATION_NEW + 1);
  762. let topPNode = subTopNode.getParentNode();
  763. let rawNode = me.buildSubRootNodeDoc(subTopNode);
  764. me.updateSubNode(topPNode, rawNode, true, function (rst) {
  765. if (!(rst)) {
  766. alert('修改标记:[' + flagProp + '] 失败!');
  767. }
  768. });
  769. }
  770. },
  771. onMutiChangeFlag: function (flagProp, flagDom) {
  772. let me = zTreeOprObj;
  773. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE) {
  774. if (!me.currentNode.hasOwnProperty("flags")) {
  775. me.currentNode.flags = {};
  776. }
  777. me.currentNode.flags[flagProp] = flagDom[0].value.split(',');
  778. let subTopNode = me.getParentNodeByNodeLevel(me.currentNode, NODE_LEVEL_COMPILATION_NEW + 1);
  779. let topPNode = subTopNode.getParentNode();
  780. let rawNode = me.buildSubRootNodeDoc(subTopNode);
  781. me.updateSubNode(topPNode, rawNode, true, function (rst) {
  782. if (!(rst)) {
  783. alert('修改标记:[' + flagProp + '] 失败!');
  784. }
  785. });
  786. }
  787. },
  788. createNewTpl: function () {
  789. let me = zTreeOprObj, params = {};
  790. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE) {
  791. params.treeNodeId = me.currentNode.ID;
  792. let rptTypeId = common_rpt_type_ids.flow;
  793. if ($("#crossTypeOpt")[0].checked) rptTypeId = common_rpt_type_ids.cross;
  794. if ($("#billTypeOpt")[0].checked) rptTypeId = common_rpt_type_ids.bill;
  795. params.rptDftTplId = rptTypeId;
  796. params.rptName = me.currentNode.name;
  797. params.grpKey = me.getFolderText(me.currentNode, "_");
  798. me.currentNode.refId = me.currentNode.ID;
  799. let subTopNode = me.getParentNodeByNodeLevel(me.currentNode, NODE_LEVEL_COMPILATION_NEW + 1);
  800. let topPNode = me.getParentNodeByNodeLevel(subTopNode, NODE_LEVEL_COMPILATION_NEW);
  801. let rawNode = me.buildSubRootNodeDoc(subTopNode);
  802. params.compilationId = topPNode.compilationId;
  803. params.engineerId = topPNode.engineerId;
  804. params.userId = topPNode.userId;
  805. params.subNode = rawNode;
  806. CommonAjax.postEx("report_tpl_api/createDftRptTpl", params, 10000, true, function (result) {
  807. if (result) {
  808. me.currentNode.rptTpl = result;
  809. me.chkAndRreshRefTpl();
  810. } else {
  811. alert('update error!');
  812. }
  813. }, null, null
  814. );
  815. }
  816. },
  817. beforeClick: function (treeId, treeNode, clickFlag) {
  818. let me = zTreeOprObj;
  819. if (me.dupTplIds && me.dupTplIds.indexOf(treeNode.refId) >= 0) {
  820. let topNodes = me.treeObj.getNodes();
  821. me.chkAndSetDupRefTplIds(topNodes, treeNode.refId);
  822. me.refreshNodes();
  823. } else if (me.hasRefreshedDupRefIds) {
  824. let topNodes = me.treeObj.getNodes();
  825. me.chkAndSetDupRefTplIds(topNodes, null);
  826. me.refreshNodes();
  827. }
  828. return true;
  829. },
  830. onClick: function (event, treeId, treeNode) {
  831. let me = zTreeOprObj;
  832. me.currentNode = treeNode;
  833. bandTreeOprObj.currentNode = null;
  834. if (treeNode.nodeType === RT.NodeType.NODE) {
  835. $("#rpt_tpl_display_label")[0].innerText = "...";
  836. } else if (treeNode.nodeType === RT.NodeType.TEMPLATE) {
  837. let showText = me.getFolderText(me.currentNode, " > ");
  838. $("#rpt_tpl_display_label")[0].innerText = showText;
  839. if (treeNode.refId < 0) {
  840. //创建新报表模板
  841. $('#rptTypeSelectionModal').modal('show');
  842. } else {
  843. //显示报表模板
  844. me.chkAndRreshRefTpl(true);
  845. }
  846. }
  847. },
  848. isFlowTpl: function () {
  849. let rst = false;
  850. let me = zTreeOprObj;
  851. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE) {
  852. rst = !!(me.currentNode.rptTpl[JV.NODE_FLOW_INFO]);
  853. }
  854. return rst;
  855. },
  856. isCrossTpl: function () {
  857. let rst = false;
  858. let me = zTreeOprObj;
  859. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE) {
  860. rst = !!(me.currentNode.rptTpl[JV.NODE_CROSS_INFO]);
  861. }
  862. return rst;
  863. },
  864. isBillTpl: function () {
  865. let rst = false;
  866. let me = zTreeOprObj;
  867. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE) {
  868. rst = !!(me.currentNode.rptTpl[JV.NODE_BILL_INFO]);
  869. }
  870. return rst;
  871. },
  872. getFolderText: function (treeNode, separator) {
  873. let rst = "";
  874. if (treeNode) {
  875. rst = treeNode.name;
  876. let parentNode = treeNode.getParentNode();
  877. while (parentNode !== null) {
  878. rst = parentNode.name + separator + rst;
  879. parentNode = parentNode.getParentNode();
  880. }
  881. }
  882. return rst;
  883. },
  884. chkAndRreshRefTpl: function (forceRefresh) {
  885. let me = zTreeOprObj, params = {};
  886. const valuationTypes = ['suggestion', 'feasibility', 'rough', 'bill', 'three_bill_budget', 'ration', 'changeBudget', 'settlement'];
  887. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE && me.currentNode.refId > 0) {
  888. if (forceRefresh || !(me.currentNode.rptTpl)) {
  889. params.rptTplId = me.currentNode.refId;
  890. CommonAjax.postEx("report_tpl_api/getRefRptTpl", params, 20000, true, function (result) {
  891. me.currentNode.rptTpl = result;
  892. me.currentNode.rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = me.currentNode.name;
  893. if (me.currentNode.rptTpl["GROUP_KEY"]) {
  894. let grp_keys = me.currentNode.rptTpl["GROUP_KEY"].split('_');
  895. if (grp_keys.length > 0) {
  896. grp_keys[1] = me.currentNode.name;
  897. }
  898. me.currentNode.rptTpl["GROUP_KEY"] = grp_keys.join("_");
  899. }
  900. tplHelper.refreshTplView(me.currentNode.rptTpl);
  901. if (me.currentNode.hasOwnProperty('flags')) {
  902. if (me.currentNode.flags.hasOwnProperty('taxType')) {
  903. let val = parseInt(me.currentNode.flags['taxType']);
  904. $("#element_flags_select")[0].selectedIndex = val;
  905. } else {
  906. $("#element_flags_select")[0].selectedIndex = 0;
  907. }
  908. $("#valuationSelector").hide();
  909. if (me.currentNode.flags.hasOwnProperty('valuationType')) {
  910. $(".mutiSelector").find('li').removeClass('checked');
  911. let valuationTypeStr = '';
  912. let valuationTypeStrList = [];
  913. let vType = me.currentNode.flags['valuationType'];
  914. // let vtIdx = valuationTypes.indexOf(vType);
  915. // $("#element_prjFlags_select")[0].selectedIndex = vtIdx + 1;
  916. if (vType instanceof Array) {
  917. for (let i = 0; i < vType.length; i++) {
  918. $("#valuationSelector_" + vType[i]).addClass('checked');
  919. valuationTypeStrList.push(valuationSelectorMap["valuationSelector_" + vType[i]]);
  920. }
  921. valuationTypeStr = valuationTypeStrList.join(',');
  922. } else if (vType) {
  923. $("#valuationSelector_" + vType).addClass('checked');
  924. valuationTypeStr = valuationSelectorMap["valuationSelector_" + vType];
  925. }
  926. $("#element_prjFlags_select")[0].value = vType;
  927. $("#element_prjFlags_selectStr")[0].value = valuationTypeStr;
  928. } else {
  929. $("#element_prjFlags_select")[0].value = '';
  930. $("#element_prjFlags_selectStr")[0].value = '';
  931. $('#valuationSelector .mutiSelector li').removeClass('checked');
  932. }
  933. if (me.currentNode.flags.hasOwnProperty('reportType')) {
  934. let rType = me.currentNode.flags['reportType'];
  935. if (rType === 'billSummary') $("#element_rptFlags_select")[0].selectedIndex = 1
  936. else if (rType === 'gljSummary') $("#element_rptFlags_select")[0].selectedIndex = 2
  937. else $("#element_rptFlags_select")[0].selectedIndex = 0;
  938. } else {
  939. $("#element_rptFlags_select")[0].selectedIndex = 0;
  940. }
  941. if (me.currentNode.flags.hasOwnProperty('sumLevelType')) {
  942. let sumLvType = me.currentNode.flags['sumLevelType'];
  943. if (sumLvType === 'construct') $("#element_sumLv_flags")[0].selectedIndex = 1
  944. else if (sumLvType === 'Single') $("#element_sumLv_flags")[0].selectedIndex = 2
  945. else if (sumLvType === 'custom') $("#element_sumLv_flags")[0].selectedIndex = 3
  946. else if (sumLvType === 'complexUnit') $("#element_sumLv_flags")[0].selectedIndex = 4
  947. else if (sumLvType === 'stageContrast') $("#element_sumLv_flags")[0].selectedIndex = 5
  948. else if (sumLvType === 'unitPriceContrast') $("#element_sumLv_flags")[0].selectedIndex = 6
  949. else $("#element_sumLv_flags")[0].selectedIndex = 0;
  950. } else {
  951. $("#element_sumLv_flags")[0].selectedIndex = 0;
  952. }
  953. if (me.currentNode.flags.hasOwnProperty('contrastType')) {
  954. let contrastType = me.currentNode.flags['contrastType'];
  955. if (contrastType === 'chapter') $("#element_contrastType_select")[0].selectedIndex = 1
  956. else if (contrastType === 'bill') $("#element_contrastType_select")[0].selectedIndex = 2
  957. else if (contrastType === 'quantities') $("#element_contrastType_select")[0].selectedIndex = 3
  958. else $("#element_contrastType_select")[0].selectedIndex = 0;
  959. }
  960. if (me.currentNode.flags.hasOwnProperty('existLevel')) {
  961. let existLevel = me.currentNode.flags['existLevel'];
  962. if (existLevel) $("#element_existLevel_select")[0].selectedIndex = 1
  963. else $("#element_existLevel_select")[0].selectedIndex = 0;
  964. } else {
  965. $("#element_existLevel_select")[0].selectedIndex = 0;
  966. }
  967. if (me.currentNode.flags.hasOwnProperty('constructSumType')) {
  968. let val = me.currentNode.flags['constructSumType'];
  969. if (val === 'constructSum') {
  970. $("#element_constructSumFlags_select")[0].selectedIndex = 1;
  971. } else {
  972. $("#element_constructSumFlags_select")[0].selectedIndex = 0;
  973. }
  974. } else {
  975. $("#element_constructSumFlags_select")[0].selectedIndex = 0;
  976. }
  977. } else {
  978. $("#element_flags_select")[0].selectedIndex = 0;
  979. $("#element_prjFlags_select")[0].selectedIndex = 0;
  980. $("#element_sumLv_flags")[0].selectedIndex = 0;
  981. $("#element_constructSumFlags_select")[0].selectedIndex = 0;
  982. // 清空工程类型
  983. $("#valuationSelector").hide();
  984. $("#element_prjFlags_select")[0].value = '';
  985. $("#element_prjFlags_selectStr")[0].value = '';
  986. $('#valuationSelector .mutiSelector li').removeClass('checked');
  987. $("#element_existLevel_select")[0].selectedIndex = 0;
  988. }
  989. if ($("#rpt_tpl_visual_tab")[0].className === "nav-link p-1 active") {
  990. setTimeout(function () { visualJumbo.iniSpreadJs(); visualJumbo.setupTpl() }, 50)
  991. }
  992. }, null, null
  993. );
  994. } else {
  995. me.currentNode.rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = me.currentNode.name;
  996. tplHelper.refreshTplView(me.currentNode.rptTpl);
  997. if ($("#rpt_tpl_visual_tab")[0].className === "nav-link p-1 active") {
  998. setTimeout(function () { visualJumbo.iniSpreadJs(); visualJumbo.setupTpl() }, 50)
  999. }
  1000. }
  1001. }
  1002. },
  1003. getRefTpl: function () {
  1004. let me = zTreeOprObj, rst = null;
  1005. if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE && me.currentNode.refId > 0) {
  1006. rst = me.currentNode.rptTpl
  1007. }
  1008. return rst;
  1009. },
  1010. changeProperty: function (propStr, dom) {
  1011. let me = zTreeOprObj;
  1012. if (me.currentNode && me.currentNode.rptTpl) {
  1013. let props = propStr.split('.');
  1014. let lastProp = me.currentNode.rptTpl;
  1015. for (let idx = 1; idx < props.length; idx++) {
  1016. lastProp = lastProp[props[idx - 1]];
  1017. }
  1018. lastProp[props[props.length - 1]] = dom.value;
  1019. }
  1020. },
  1021. extractMainInfo: function (rptTpl) {
  1022. //模板信息
  1023. rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = $("#rptTplName")[0].value;
  1024. rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = JV.PAGES_SIZE_STR[$("#rptTplPageSize")[0].selectedIndex];
  1025. if ($("#rptTplPageOrientation")[0].selectedIndex === 1) {
  1026. rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] = JV.ORIENTATION_PORTRAIT;
  1027. } else {
  1028. rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] = JV.ORIENTATION_LANDSCAPE;
  1029. }
  1030. if (rptTpl[JV.NODE_FLOW_INFO]) {
  1031. rptTpl[JV.NODE_FLOW_INFO][JV.PROP_MULTI_COLUMN] = parseInt($("#rptTplMultiCols")[0].value);
  1032. }
  1033. rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_CROSS_DISPLAY_ORDER] = $("#element_cross_display_seq")[0].selectedIndex;
  1034. //考虑到页边距必然跟用户设置走,所以这里没必要特意去设置了,全部下架
  1035. },
  1036. getParentNodeByNodeLevel: function (currentNode, level) {
  1037. let rst = currentNode;
  1038. while (rst !== null) {
  1039. if (rst.level <= level) {
  1040. break;
  1041. } else {
  1042. rst = rst.getParentNode();
  1043. }
  1044. }
  1045. return rst;
  1046. }
  1047. };
  1048. let userListObj = {
  1049. foundedUserList: [],
  1050. UserIdList: [],
  1051. pushUser: function (user, newUsers) {
  1052. let me = userListObj;
  1053. if (me.UserIdList.indexOf(user._id) < 0) {
  1054. me.UserIdList.push(user._id);
  1055. let newUser = { userId: user._id, real_name: user.real_name, username: user.username, mobile: user.mobile };
  1056. me.foundedUserList.push(newUser);
  1057. if (newUsers) {
  1058. newUsers.push(newUser);
  1059. }
  1060. }
  1061. },
  1062. findUser: function () {
  1063. let key = $("#rpt_user_input1").get(0).value;
  1064. let newUsers = [];
  1065. $.ajax({
  1066. type: "GET",
  1067. url: "user/search?keyword=" + key,
  1068. cache: false,
  1069. timeout: 5000,
  1070. success: function (result) {
  1071. if (result.data && result.data.length > 0) {
  1072. for (let user of result.data) {
  1073. userListObj.pushUser(user, newUsers);
  1074. }
  1075. if (newUsers.length > 0) {
  1076. zTreeOprObj.addReportTemplate(newUsers);
  1077. }
  1078. }
  1079. },
  1080. error: function (jqXHR, textStatus, errorThrown) {
  1081. }
  1082. });
  1083. },
  1084. findUsersByIds: function (userIds, cb) {
  1085. let params = {};
  1086. params.userIds = userIds;
  1087. CommonAjax.postEx("user/getUserList", params, 20000, true, function (result) {
  1088. for (let user of result) {
  1089. userListObj.pushUser(user, null);
  1090. }
  1091. if (cb) {
  1092. cb(result);
  1093. }
  1094. }, null, null
  1095. );
  1096. }
  1097. };
  1098. function displayMessage(message, color, disappearTime, id) {
  1099. let domId = id;
  1100. if (!domId) domId = "id_after_saved_lbl";
  1101. $("#" + domId)[0].style.color = color;
  1102. $("#" + domId)[0].innerHTML = message;
  1103. setTimeout(function () {
  1104. $("#" + domId)[0].innerHTML = "";
  1105. }, disappearTime);
  1106. }
  1107. $("#element_prjFlags_selectStr").on('click', function () {
  1108. if ($('#valuationSelector').visible) {
  1109. $('#valuationSelector').hide();
  1110. } else {
  1111. $('#valuationSelector').show();
  1112. }
  1113. return false;
  1114. })
  1115. $('#rpttplinfo').on('click', function () {
  1116. $('#valuationSelector').hide();
  1117. })
  1118. $('.mutiSelector').find('li').on('click', function (e) {
  1119. const hasChecked = $(this).hasClass('checked');
  1120. if (hasChecked) {
  1121. $(this).removeClass('checked');
  1122. } else {
  1123. $(this).addClass('checked');
  1124. }
  1125. const resultIDList = [];
  1126. const resultList = [];
  1127. $('.mutiSelector .checked').each(function (index, value) {
  1128. resultList.push(valuationSelectorMap[$(value).attr('id')]);
  1129. resultIDList.push($(value).attr('value'));
  1130. })
  1131. const result = resultList.join(',');
  1132. $('#element_prjFlags_selectStr').val(result);
  1133. $('#element_prjFlags_select').val(resultIDList);
  1134. zTreeOprObj.onMutiChangeFlag('valuationType', $('#element_prjFlags_select'));
  1135. return false;
  1136. })