rpt_tpl_field_map.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict'
  2. let fieldMapTreeOprObj = {
  3. treeObj : null,
  4. iniTree: function(rptTpl) {
  5. var me = this;
  6. let fieldMapList = me.buildTreeData(rptTpl);
  7. me.treeObj = $.fn.zTree.init($("#field_map_tree_reversed"), fieldMapSetting, fieldMapList);
  8. me.treeObj.expandAll(true);
  9. },
  10. buildTreeData: function (rptTpl) {
  11. let rst = [];
  12. let private_setSubFields = function (parent, fieldList) {
  13. for (let field of fieldList) {
  14. parent.items.push(field);
  15. }
  16. }
  17. if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DISCRETE_FIELDS]) {
  18. rst.push({Name: JV.NODE_DISCRETE_FIELDS, items: [], isParent: true});
  19. private_setSubFields(rst[rst.length - 1], rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DISCRETE_FIELDS])
  20. }
  21. if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS]) {
  22. rst.push({Name: JV.NODE_MASTER_FIELDS, items: [], isParent: true});
  23. private_setSubFields(rst[rst.length - 1], rptTpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS])
  24. }
  25. if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS]) {
  26. rst.push({Name: JV.NODE_DETAIL_FIELDS, items: [], isParent: true});
  27. private_setSubFields(rst[rst.length - 1], rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS])
  28. }
  29. return rst;
  30. },
  31. onClick: function () {
  32. //
  33. },
  34. onBeforeRemove: function(treeId, treeNode){
  35. if (treeNode.level === 0) {
  36. return false;
  37. }
  38. return true;
  39. },
  40. beforeRename: function(treeId, treeNode, newName, isCancel) {
  41. if (isCancel) {
  42. return true;
  43. }
  44. if (treeNode.level === 0) {
  45. return false;
  46. }
  47. return true;
  48. },
  49. onRemove: function () {
  50. //
  51. },
  52. onRename: function () {
  53. //
  54. },
  55. extractFieldMaps: function (rptTpl) {
  56. //
  57. }
  58. };