Index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * 描 述:功能模块
  3. */
  4. var selectedRow;
  5. var refreshGirdData; // 更新数据
  6. var bootstrap = function ($, learun) {
  7. "use strict";
  8. var page = {
  9. init: function () {
  10. page.initGrid();
  11. page.bindEvent();
  12. },
  13. bindEvent: function () {
  14. // 查询
  15. $('#btn_Search').on('click', function () {
  16. var keyword = $('#txt_Keyword').val();
  17. page.search({ keyword: keyword });
  18. });
  19. // 刷新
  20. $('#lr_refresh').on('click', function () {
  21. location.reload();
  22. });
  23. // 新增
  24. $('#lr_add').on('click', function () {
  25. var keyValue = {};
  26. selectedRow = {};
  27. learun.layerForm({
  28. id: 'form',
  29. title: '添加功能',
  30. url: top.$.rootUrl + '/DevelopmentManager/Module/Form',
  31. height: 400,
  32. width: 800,
  33. callBack: function (id) {
  34. return top[id].acceptClick(refreshGirdData);
  35. }
  36. });
  37. });
  38. // 编辑
  39. $('#lr_edit').on('click', function () {
  40. var keyValue = $('#gridtable').jfGridValue('F_NO');
  41. selectedRow = $('#gridtable').jfGridGet('rowdata');
  42. if (learun.checkrow(keyValue)) {
  43. learun.layerForm({
  44. id: 'form',
  45. title: '编辑功能',
  46. url: top.$.rootUrl + '/DevelopmentManager/Module/Form?keyValue=' + keyValue,
  47. height: 400,
  48. width: 800,
  49. callBack: function (id) {
  50. return top[id].acceptClick(refreshGirdData);
  51. }
  52. });
  53. }
  54. });
  55. // 删除
  56. $('#lr_delete').on('click', function () {
  57. var keyValue = $('#gridtable').jfGridValue('F_NO');
  58. if (learun.checkrow(keyValue)) {
  59. learun.layerConfirm('是否确认删除该项!', function (res) {
  60. if (res) {
  61. learun.deleteForm(top.$.rootUrl + '/DevelopmentManager/Module/DeleteForm', { keyValue: keyValue }, function () {
  62. refreshGirdData();
  63. });
  64. }
  65. });
  66. }
  67. });
  68. },
  69. initGrid: function () {
  70. $('#gridtable').jfGrid({
  71. url: top.$.rootUrl + '/DevelopmentManager/Module/GetModuleList',
  72. headData: [
  73. { label: "名称", name: "F_NAME", width: 200, align: "left" },
  74. { label: "编号", name: "F_NO", width: 350, align: "left" },
  75. { label: "地址", name: "F_URLADDR", width: 350, align: "left" },
  76. {
  77. label: "目标", name: "F_TARGET", width: 60, align: "center",
  78. formatterAsync: function (callback, value, row) {
  79. learun.clientdata.getAsync('dataItem', {
  80. Rowkey: value,
  81. GrpCode: 'EModuleTarget',
  82. getType: 'Num',
  83. callback: function (_data) {
  84. callback(_data.F_NAME);
  85. }
  86. });
  87. }
  88. },
  89. {
  90. label: "菜单", name: "F_ISMENU", width: 50, align: "center",
  91. formatter: function (cellvalue, rowObject) {
  92. return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
  93. }
  94. },
  95. {
  96. label: "展开", name: "F_ALLOWEXPAND", width: 50, align: "center",
  97. formatter: function (cellvalue, rowObject) {
  98. return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
  99. }
  100. },
  101. {
  102. label: "有效", name: "F_ISSTOP", width: 50, align: "center",
  103. formatter: function (cellvalue, rowObject) {
  104. return cellvalue == 0 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
  105. }
  106. },
  107. {
  108. label: "排序号", name: "F_SORTNUM", width: 50, align: "center",
  109. },
  110. { label: "描述", name: "F_MEMO", width: 200, align: "left" }
  111. ],
  112. isTree: true,
  113. mainId: 'F_NO',
  114. parentId: 'F_PNO'
  115. });
  116. page.search();
  117. },
  118. search: function (param) {
  119. $('#gridtable').jfGridSet('reload', param);
  120. }
  121. };
  122. // 保存数据后回调刷新
  123. refreshGirdData = function () {
  124. var keyword = $('#txt_Keyword').val();
  125. page.search({ keyword: keyword });
  126. };
  127. page.init();
  128. }