modulelist.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. (function () {
  2. var page = {
  3. isScroll: true,
  4. init: function ($page) {
  5. var _html = '\
  6. <div class="searchBox">\
  7. <i class="iconfont icon-search"></i>\
  8. <div class="search" >搜索应用</div>\
  9. </div>';
  10. $page.parent().find('.f-page-header').addClass('lr-modulelist-header').append(_html).find('.f-page-title').remove();
  11. // 点击搜索框
  12. $page.parent().find('.searchBox').on('tap', function () {
  13. renlian.nav.go({ path: 'workspace/search', title: '', isBack: true, isHead: true });
  14. });
  15. renlian.clientdata.get('module', {
  16. callback: function (data) {
  17. var map = {};
  18. var TypeMap = {};
  19. $.each(data, function (_index, _item) {
  20. map[_item.F_Id] = _item;
  21. TypeMap[_item.F_Type] = TypeMap[_item.F_Type] || [];
  22. TypeMap[_item.F_Type].push(_item);
  23. });
  24. // 加载我的应用
  25. renlian.myModule.get(data, function (myModules) {
  26. var $appbox = $page.find('#lr_modulelist_mymodule');
  27. $.each(myModules, function (_index, _id) {
  28. var item = map[_id];
  29. if (item) {
  30. var _html = '\
  31. <div class="appitem" data-value="'+ item.F_Id + '">\
  32. <div><i class="'+ item.F_Icon + '"></i></div>\
  33. <span>'+ item.F_Name + '</span>\
  34. </div>';
  35. var _$html = $(_html);
  36. _$html[0].item = item;
  37. $appbox.append(_$html);
  38. }
  39. });
  40. });
  41. // 加载全部应用
  42. var $app = $page.find('.lr-modulelist-page');
  43. $.each(TypeMap, function (_type, _modules) {
  44. var _html = '\
  45. <div class="lr-app-panel" data-app="'+ _type + '">\
  46. <div class="title" ></div>\
  47. <div class="content"></div>\
  48. </div>';
  49. $app.append(_html);
  50. var $content = $app.find('[data-app="' + _type + '"] .content');
  51. renlian.clientdata.get('dataItem', {
  52. code: 'function',
  53. key: _type,
  54. callback: function (data, op) {
  55. $app.find('[data-app="' + op.key + '"] .title').text(data.text);
  56. }
  57. });
  58. $.each(_modules, function (_index, _item) {
  59. var __html = '\
  60. <div class="appitem" data-value="'+ _item.F_Id + '">\
  61. <div><i class="'+ _item.F_Icon + '"></i></div>\
  62. <span>'+ _item.F_Name + '</span>\
  63. </div>';
  64. var __$html = $(__html);
  65. __$html[0].item = _item;
  66. $content.append(__$html);
  67. });
  68. });
  69. }
  70. });
  71. // 注册编辑我的应用
  72. $page.find('#lr_edit_myapp').on('tap', function () {
  73. renlian.nav.go({ path: 'workspace/modulelist/edit', title: "我的应用编辑" });
  74. });
  75. // 点击功能按钮
  76. $page.delegate('.appitem', 'tap', function () {
  77. var $this = $(this);
  78. var item = $this[0].item;
  79. if (item.F_IsSystem === 1) {// 代码开发功能
  80. renlian.nav.go({ path: item.F_Url, title: item.F_Name, isBack: true, isHead: true, type: 'right' });
  81. }
  82. else {// 自定义表单开发功能
  83. renlian.nav.go({ path: 'custmerform', title: item.F_Name, param: { formSchemeId: item.F_FormId, girdScheme: item.F_Scheme }, isBack: true, isHead: true, type: 'right' });
  84. }
  85. return false;
  86. });
  87. },
  88. reload: function ($page, pageinfo) {
  89. renlian.clientdata.get('module', {
  90. callback: function (data) {
  91. var map = {};
  92. $.each(data, function (_index, _item) {
  93. map[_item.F_Id] = _item;
  94. });
  95. // 加载我的应用
  96. renlian.myModule.get(data, function (myModules) {
  97. var $appbox = $page.find('#lr_modulelist_mymodule');
  98. $appbox.html("");
  99. $.each(myModules, function (_index, _id) {
  100. var item = map[_id];
  101. if (item) {
  102. var _html = '\
  103. <div class="appitem" data-value="'+ item.F_Id + '">\
  104. <div><i class="'+ item.F_Icon + '"></i></div>\
  105. <span>'+ item.F_Name + '</span>\
  106. </div>';
  107. var _$html = $(_html);
  108. _$html[0].item = item;
  109. $appbox.append(_$html);
  110. }
  111. });
  112. });
  113. }
  114. });
  115. }
  116. };
  117. return page;
  118. })();