Index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. var refreshGirdData;
  2. var OneInTimebegin = '';
  3. var OneInTimeend = '';
  4. var ProductTimebegin = '';
  5. var ProductTimeend = '';
  6. var logbegin = '';
  7. var logend = '';
  8. var selectedRow;
  9. var refreshGirdData; // 更新数据
  10. var bootstrap = function ($, learun) {
  11. "use strict";
  12. var page = {
  13. init: function () {
  14. page.initGird();
  15. page.bind();
  16. },
  17. bind: function () {
  18. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  19. // 调用后台查询
  20. // queryJson 查询条件
  21. var oneintime = $('#lr_search_date_OneInTime').html();
  22. if (oneintime == '') {
  23. OneInTimebegin = '';
  24. OneInTimeend = '';
  25. }
  26. var producttime = $('#lr_search_date_ProductTime').html();
  27. if (producttime == '') {
  28. ProductTimebegin = '';
  29. ProductTimeend = '';
  30. }
  31. console.log(queryJson);
  32. queryJson["Code"] = $("#Code").val();
  33. queryJson["Name"] = $("#Name").val();
  34. queryJson["ShortDesc"] = $("#ShortDesc").val();
  35. queryJson["SpoolType"] = $("#SpoolType").val();
  36. page.search({ queryJson: JSON.stringify(queryJson) });
  37. }, 250);
  38. // 查询
  39. $('#btn_Search').on('click', function () {
  40. var keyword = $('#txt_Keyword').val();
  41. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  42. });
  43. // 刷新
  44. $('#lr_refresh').on('click', function () {
  45. location.reload();
  46. });
  47. //$('#ContGrpType').lrselect({
  48. // url: top.$.rootUrl + '/PTManager/Enums/GetContGrpTypeList',
  49. // maxHeight: 180,
  50. // allowSearch: false
  51. //});
  52. $('#InvStateCode').lrselect({
  53. url: top.$.rootUrl + '/PTManager/Enums/GetInvStateList',
  54. maxHeight: 180,
  55. allowSearch: false
  56. });
  57. // 新增
  58. $('#lr_add').on('click', function () {
  59. var keyValue = {};
  60. selectedRow = {};
  61. learun.layerForm({
  62. id: 'form',
  63. title: '添加物料',
  64. url: top.$.rootUrl + '/PTManager/BaseMatinfo/Form',
  65. height: 400,
  66. width: 800,
  67. callBack: function (id) {
  68. return top[id].acceptClick(refreshGirdData);
  69. }
  70. });
  71. });
  72. // 编辑
  73. $('#lr_edit').on('click', function () {
  74. var keyValue = $('#gridtable').jfGridValue('Code');
  75. selectedRow = $('#gridtable').jfGridGet('rowdata');
  76. if (learun.checkrow(keyValue)) {
  77. learun.layerForm({
  78. id: 'form',
  79. title: '编辑物料信息',
  80. url: top.$.rootUrl + '/PTManager/BaseMatinfo/Form?keyValue=' + keyValue,
  81. height: 400,
  82. width: 800,
  83. callBack: function (id) {
  84. return top[id].acceptClick(refreshGirdData);
  85. }
  86. });
  87. }
  88. });
  89. // 删除
  90. $('#lr_delete').on('click', function () {
  91. var keyValue = $('#gridtable').jfGridValue('Code');
  92. if (learun.checkrow(keyValue)) {
  93. learun.layerConfirm('是否确认删除该项!', function (res) {
  94. if (res) {
  95. learun.deleteForm(top.$.rootUrl + '/PTManager/BaseMatinfo/Delete', { keyValue: keyValue }, function () {
  96. refreshGirdData();
  97. });
  98. }
  99. });
  100. }
  101. });
  102. },
  103. // 初始化列表
  104. initGird: function () {
  105. $('#gridtable').jfGrid({
  106. url: top.$.rootUrl + '/PTManager/BaseMatinfo/GetPageList',
  107. headData: [
  108. { label: "物料编码", name: "Code", width: 110, align: "left" },
  109. { label: "物料名称", name: "Name", width: 80, align: "left" },
  110. { label: "物料描述", name: "ShortDesc", width: 80, align: "left" },
  111. { label: "镀层", name: "Plating", width: 80, align: "left" },
  112. { label: "镀层克重", name: "PlatingWeight", width: 80, align: "left" },
  113. { label: "强度", name: "Strength", width: 80, align: "left" },
  114. { label: "工字轮类型", name: "SpoolType", width: 80, align: "left" },
  115. { label: "线密度", name: "Linear", width: 80, align: "left" },
  116. {
  117. label: "是否启用时长", name: "IsHold", width: 80, align: "left", formatter: function (cellvalue) {
  118. if (cellvalue == true) {
  119. return '<span class=\"label label-success\" >是</span>';
  120. } else {
  121. return '<span class=\"label label-default\" >否</span>';
  122. }
  123. }
  124. },
  125. { label: "启用时长", name: "HoldDuration", width: 80, align: "left" },
  126. { label: "创建时间", name: "AddTime", width: 130, align: "left" },
  127. { label: "修改时间", name: "EditTime", width: 130, align: "left" },
  128. ],
  129. mainId: 'Id',
  130. isPage: true,
  131. reloadSelected: true,
  132. autowWidth: true,
  133. sidx: 'AddTime',
  134. sord: 'DESC',
  135. });
  136. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  137. },
  138. search: function (param) {
  139. $('#gridtable').jfGridSet('reload', param);
  140. }
  141. };
  142. refreshGirdData = function () {
  143. $('#gridtable').jfGridSet('reload');
  144. };
  145. page.init();
  146. }