Index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * 描 述:单位管理
  3. */
  4. var selectedRow;
  5. var refreshGirdData;
  6. var typnum = 1;
  7. var unitGrpId = '';
  8. var bootstrap = function ($, learun) {
  9. "use strict";
  10. var page = {
  11. init: function () {
  12. page.inittree();
  13. page.initGird();
  14. page.bind();
  15. },
  16. bind: function () {
  17. // 查询
  18. $('#btn_Search').on('click', function () {
  19. var keyword = $('#txt_Keyword').val();
  20. page.search({ keyword: keyword });
  21. });
  22. // 刷新
  23. $('#lr_refresh').on('click', function () {
  24. location.reload();
  25. });
  26. // 新增
  27. $('#lr_add').on('click', function () {
  28. selectedRow = null;
  29. learun.layerForm({
  30. id: 'form',
  31. title: '单位新增',
  32. url: top.$.rootUrl + '/BaseManager/BaseUnitItem/Form?unitGrpId=' + unitGrpId,
  33. width: 700,
  34. height: 400,
  35. callBack: function (id) {
  36. return top[id].acceptClick(refreshGirdData);
  37. }
  38. });
  39. });
  40. // 编辑
  41. $('#lr_edit').on('click', function () {
  42. var keyValue = $('#gridtable').jfGridValue('F_NO');
  43. selectedRow = $('#gridtable').jfGridGet('rowdata');
  44. if (learun.checkrow(keyValue)) {
  45. learun.layerForm({
  46. id: 'form',
  47. title: '单位编辑',
  48. url: top.$.rootUrl + '/BaseManager/BaseUnitItem/Form?keyValue=' + keyValue,
  49. width: 700,
  50. height: 400,
  51. callBack: function (id) {
  52. return top[id].acceptClick(refreshGirdData);
  53. }
  54. });
  55. }
  56. });
  57. // 删除
  58. $('#lr_delete').on('click', function () {
  59. var keyValue = $('#gridtable').jfGridValue('F_NO');
  60. if (learun.checkrow(keyValue)) {
  61. learun.layerConfirm('是否确认删除该项!', function (res) {
  62. if (res) {
  63. learun.deleteForm(top.$.rootUrl + '/BaseManager/BaseUnitItem/DeleteForm', { keyValue: keyValue }, function () {
  64. refreshGirdData();
  65. });
  66. }
  67. });
  68. }
  69. });
  70. $('#lr_import').on('click', function () {
  71. learun.layerForm({
  72. id: 'ImportForm',
  73. title: '导入Excel数据',
  74. url: top.$.rootUrl + '/Utility/ImportForm?ordertype=' + typnum,
  75. width: 600,
  76. height: 400,
  77. maxmin: true,
  78. btn: null
  79. });
  80. });
  81. $('#lr_exportnow').on('click', function () {
  82. learun.layerForm({
  83. id: "ExcelExportForm",
  84. title: '导出Excel数据',
  85. url: top.$.rootUrl + '/Utility/ExcelExportForm?gridId=' + $('#gridtable').attr('id') + '&filename=' + encodeURI(encodeURI("单位列表")),
  86. width: 500,
  87. height: 380,
  88. callBack: function (id) {
  89. return top[id].acceptClick();
  90. },
  91. btn: ['导出Excel', '关闭']
  92. });
  93. });
  94. },
  95. inittree: function () {
  96. $('#UnitGrpTree').lrtree({
  97. url: top.$.rootUrl + '/BaseManager/BaseUnitItem/GetTree',
  98. param: { parentId: '0' },
  99. nodeClick: page.treeNodeClick
  100. });
  101. $('#UnitGrpTree').lrtreeSet('setValue', '53298b7a-404c-4337-aa7f-80b2a4ca6681');
  102. },
  103. treeNodeClick: function (item) {
  104. if (item.parentId == 0) {
  105. unitGrpId = "";
  106. } else {
  107. unitGrpId = item.id;
  108. }
  109. $('#titleinfo').text(item.text);
  110. page.search();
  111. },
  112. initGird: function () {
  113. $('#gridtable').jfGrid({
  114. url: top.$.rootUrl + '/BaseManager/BaseUnitItem/GetPageList',
  115. headData: [
  116. learun.jfFormatter.col_F_NO("单位编码"),
  117. learun.jfFormatter.col_F_NAME("单位名称"),
  118. { label: "转换率", name: 'F_RATE', width: 120, align: "left" },
  119. {
  120. label: '单位组', name: 'F_UNITGRPNO', width: 150, align: "left"
  121. , formatterAsync: function (callback, value, row) {
  122. learun.clientdata.getAsync('unitgrp', {
  123. key: value,
  124. callback: function (item) {
  125. callback(item.F_NAME);
  126. }
  127. });
  128. }
  129. },
  130. learun.jfFormatter.col_F_ISSTOP(),
  131. learun.jfFormatter.col_F_ADDUSERNO(),
  132. learun.jfFormatter.col_F_ADDTIME(),
  133. learun.jfFormatter.col_F_EDITUSERNO(),
  134. learun.jfFormatter.col_F_EDITTIME(),
  135. learun.jfFormatter.col_F_MEMO()
  136. ],
  137. mainId: 'F_NO',
  138. sidx: 'F_NO',
  139. reloadSelected: true,
  140. isPage: true
  141. });
  142. page.search();
  143. },
  144. search: function (param) {
  145. param = param || {};
  146. param.unitGrpId = unitGrpId;
  147. $('#gridtable').jfGridSet('reload', param);
  148. }
  149. };
  150. refreshGirdData = function () {
  151. page.search();
  152. };
  153. page.init();
  154. }