Index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. 
  2. var selectedRow;
  3. var refreshGirdData;
  4. var typnum = 1;
  5. var bootstrap = function ($, learun) {
  6. "use strict";
  7. var page = {
  8. init: function () {
  9. page.initGird();
  10. page.bind();
  11. },
  12. bind: function () {
  13. // 查询
  14. $('#btn_Search').on('click', function () {
  15. var keyword = $('#txt_Keyword').val();
  16. page.search({ keyword: keyword });
  17. });
  18. // 刷新
  19. $('#lr_refresh').on('click', function () {
  20. location.reload();
  21. });
  22. $('#lr_import').on('click', function () {
  23. learun.layerForm({
  24. id: 'ImportForm',
  25. title: '导入Excel数据',
  26. url: top.$.rootUrl + '/Utility/ImportForm?ordertype=' + typnum,
  27. width: 600,
  28. height: 300,
  29. maxmin: true,
  30. btn: null
  31. });
  32. });
  33. $('#lr_exportnow').on('click', function () {
  34. learun.layerForm({
  35. id: "ExcelExportForm",
  36. title: '导出Excel数据',
  37. url: top.$.rootUrl + '/Utility/ExcelExportForm?gridId=' + $('#gridtable').attr('id') + '&filename=' + encodeURI(encodeURI("仓库列表")),
  38. width: 500,
  39. height: 380,
  40. callBack: function (id) {
  41. return top[id].acceptClick();
  42. },
  43. btn: ['导出Excel', '关闭']
  44. });
  45. });
  46. // 启用
  47. $('#lr_enable').on('click', function () {
  48. var keyValue = $('#gridtable').jfGridValue('F_no');
  49. //alert(keyValue);
  50. if (learun.checkrow(keyValue)) {
  51. learun.layerConfirm('是否确认启用该项!', function (res) {
  52. if (res) {
  53. learun.postForm(top.$.rootUrl + '/BaseManager/BaseItem/Enable', { no: keyValue }, function () {
  54. refreshGirdData();
  55. });
  56. }
  57. });
  58. }
  59. });
  60. // 禁用
  61. $('#lr_disable').on('click', function () {
  62. var keyValue = $('#gridtable').jfGridValue('F_no');
  63. if (learun.checkrow(keyValue)) {
  64. learun.layerConfirm('是否确认禁用该项!', function (res) {
  65. if (res) {
  66. learun.postForm(top.$.rootUrl + '/BaseManager/BaseItem/Disable', { no: keyValue }, function () {
  67. refreshGirdData();
  68. });
  69. }
  70. });
  71. }
  72. });
  73. },
  74. initGird: function () {
  75. $('#gridtable').jfGrid({
  76. url: top.$.rootUrl + '/BaseManager/BaseItem/GetPageList',
  77. headData: [
  78. { label: 'ID', name: 'F_no', width: 50, align: "left" },
  79. { label: '项目号', name: 'F_projectNo', width: 120, align: "left" },
  80. { label: '物料编码', name: 'F_matNo', width: 120, align: "left" },
  81. { label: '物料名称', name: 'F_matName', width: 120, align: "left" },
  82. { label: '物料名称1', name: 'F_matName1', width: 120, align: "left" },
  83. {
  84. label: '物料类型', name: 'F_matType', width: 100, align: "left"
  85. , formatterAsync: function (callback, value, row) {
  86. learun.clientdata.getAsync('dataItem', {
  87. Rowkey: value,
  88. GrpCode: 'EMatType',
  89. getType: 'Num',
  90. callback: function (item) {
  91. callback(item.F_NAME);
  92. }
  93. });
  94. }
  95. },
  96. { label: '飞旭物料类型1', name: 'F_partType', width: 120, align: "left" },
  97. {
  98. label: '状态', name: 'F_isStop', width: 120, align: "left",
  99. formatter: function (cellvalue) {
  100. if (cellvalue == 0) {
  101. return '<span class=\"label label-success\" style=\"cursor: pointer;\">启用</span>';
  102. } else {
  103. return '<span class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
  104. }
  105. }},
  106. { label: '单位', name: 'F_unit', width: 120, align: "left" },
  107. { label: '备注', name: 'F_demo', width: 120, align: "left" },
  108. { label: '创建用户', name: 'F_addUserNo', width: 120, align: "left" },
  109. { label: '创建时间', name: 'F_addTime', width: 120, align: "left" },
  110. ],
  111. mainId: 'F_no',
  112. sidx: 'F_no',
  113. isPage: true
  114. });
  115. page.search();
  116. },
  117. search: function (param) {
  118. param = param || {};
  119. $('#gridtable').jfGridSet('reload', param);
  120. }
  121. };
  122. refreshGirdData = function () {
  123. page.search();
  124. };
  125. page.init();
  126. }