Index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. var refreshGirdData;
  2. var bootstrap = function ($, learun) {
  3. "use strict";
  4. var page = {
  5. init: function () {
  6. page.initGird();
  7. page.bind();
  8. },
  9. bind: function () {
  10. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  11. // 调用后台查询
  12. // queryJson 查询条件
  13. console.log(queryJson);
  14. page.search({ queryJson: JSON.stringify(queryJson) });
  15. }, 250);
  16. // 查询
  17. $('#btn_Search').on('click', function () {
  18. var keyword = $('#txt_Keyword').val();
  19. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  20. });
  21. // 加载
  22. $('#DBCode').lrselect({
  23. url: top.$.rootUrl + "/WCSManager/WcsDatablock/GetSelectDBNameList",
  24. allowSearch: true
  25. });
  26. // 刷新
  27. $('#lr_refresh').on('click', function () {
  28. location.reload();
  29. });
  30. $('#lr_generate').on('click', function () {
  31. learun.layerForm({
  32. id: 'form',
  33. title: '新增',
  34. url: top.$.rootUrl + '/WCSManager/WcsDeviceInfo/GenerateDeviceForm',
  35. width: 700,
  36. height: 400,
  37. callBack: function (id) {
  38. return top[id].acceptClick(refreshGirdData);
  39. }
  40. });
  41. });
  42. // 新增
  43. $('#lr_add').on('click', function () {
  44. learun.layerForm({
  45. id: 'form',
  46. title: '新增',
  47. url: top.$.rootUrl + '/WCSManager/WcsDeviceInfo/Form',
  48. width:700,
  49. height: 630,
  50. callBack: function (id) {
  51. return top[id].acceptClick(refreshGirdData);
  52. }
  53. });
  54. });
  55. // 编辑
  56. $('#lr_edit').on('click', function () {
  57. var keyValue = $('#gridtable').jfGridValue('CODE');
  58. if (learun.checkrow(keyValue)) {
  59. learun.layerForm({
  60. id: 'form',
  61. title: '编辑',
  62. url: top.$.rootUrl + '/WCSManager/WcsDeviceInfo/Form?keyValue=' + keyValue,
  63. width: 700,
  64. height: 630,
  65. callBack: function (id) {
  66. return top[id].acceptClick(refreshGirdData);
  67. }
  68. });
  69. }
  70. });
  71. // 删除
  72. $('#lr_delete').on('click', function () {
  73. var keyValue = $('#gridtable').jfGridValue('CODE');
  74. if (learun.checkrow(keyValue)) {
  75. learun.layerConfirm('是否确认删除该项!', function (res) {
  76. if (res) {
  77. learun.deleteForm(top.$.rootUrl + '/WCSManager/WcsDeviceInfo/DeleteForm', { keyValue: keyValue }, function () {
  78. refreshGirdData();
  79. });
  80. }
  81. });
  82. }
  83. });
  84. // 打印
  85. $('#lr_print').on('click', function () {
  86. $('#gridtable').jqprintTable();
  87. });
  88. },
  89. // 初始化列表
  90. initGird: function () {
  91. $('#gridtable').jfGrid({
  92. url: top.$.rootUrl + '/WCSManager/WcsDeviceInfo/GetPageList',
  93. headData: [
  94. { label: "设备编号", name: "CODE", width: 200, align: "left" },
  95. { label: "设备名称", name: "NAME", width: 300, align: "left" },
  96. { label: "PLCDB", name: "DBCODE", width: 300, align: "left" },
  97. { label: "起始位置", name: "POSITION", width: 200, align: "left" },
  98. { label: "是否可用", name: "Enabled", align: "left" },
  99. ],
  100. mainId: 'CODE',
  101. isPage: true,
  102. reloadSelected: true,
  103. sidx: 'CODE',
  104. });
  105. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  106. },
  107. search: function (param) {
  108. $('#gridtable').jfGridSet('reload', param);
  109. }
  110. };
  111. refreshGirdData = function () {
  112. $('#gridtable').jfGridSet('reload');
  113. };
  114. page.init();
  115. }