lotmst.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. var layer, eTbl;
  2. layui.use(['table', 'layer', 'laydate'], function () {
  3. var table = layui.table;
  4. var orderId = QueryString('orderId');
  5. if (orderId != null && orderId != '' && orderId != undefined) {
  6. where = {
  7. poCode: orderId
  8. }
  9. }
  10. layer = layui.layer;
  11. var laydate = layui.laydate;
  12. laydate.render({
  13. elem: '#starttime'
  14. });
  15. laydate.render({
  16. elem: '#endtime'
  17. });
  18. var where;
  19. //第一个实例
  20. eTbl = table.render({
  21. elem: '#tbl',
  22. url: '/mes/api/lotmst/get', //数据接口
  23. page: true, //开启分页
  24. toolbar: '#toolbar',
  25. where: where,
  26. cols: [[ //表头
  27. { checkbox: true },
  28. { field: 'lotNo', title: 'LOTNo', width: 160, sort: true },
  29. { field: 'poCode', title: '生产订单编号', width: 120, sort: true },
  30. {
  31. field: 'fCount', title: '数量', width: 160, sort: true, templet: function (d) {
  32. var count = d.fCount;
  33. var formatCount = '';
  34. while (count >= 1000) {
  35. formatCount = ',' + count.toString().substr(count.toString().length - 3, 3) + formatCount;
  36. count = parseInt(count.toString().substr(0, count.toString().length - 3));
  37. }
  38. formatCount = count + formatCount;
  39. return formatCount;
  40. }
  41. },
  42. { field: 'fStatus', title: '状态', width: 160, sort: true },
  43. { field: 'enterName', title: '录入人', width: 160 },
  44. {
  45. field: 'rectime', title: '录入日期', width: 240, sort: true, templet: function (d) {
  46. return (d.rectime == null || d.rectime == undefined) ? '' : timeFormat(d.rectime);
  47. }
  48. },
  49. { field: 'remark', title: '备注', width: 380 }
  50. ]],
  51. done: function () {
  52. $('[name=pocode]').val(orderId);
  53. $.ajaxSettings.async = false;
  54. }
  55. });
  56. table.on('toolbar(macmodel)', function (obj) {
  57. if (obj.event == 'search') {
  58. showToast();
  59. var startTime, endTime, poCode, lotNo;
  60. poCode = $('[name=pocode]').val();
  61. lotNo = $('[name=lotno]').val();
  62. var withtime = $('#withTime').prop('checked');
  63. var s = $('#starttime').val();
  64. var e = $('#endtime').val();
  65. if (withtime) {
  66. startTime = s;
  67. endTime = e;
  68. }
  69. where = {
  70. poCode: poCode,
  71. lotNo: lotNo,
  72. startTime: startTime,
  73. endTime: endTime
  74. };
  75. eTbl.reload({
  76. where: where,
  77. page: {
  78. curr: 1
  79. },
  80. done: function () {
  81. $('[name=pocode]').val(poCode);
  82. $('[name=lotno]').val(lotNo);
  83. laydate.render({
  84. elem: '#starttime',
  85. value: s
  86. });
  87. laydate.render({
  88. elem: '#endtime',
  89. value: e
  90. });
  91. if (withtime) {
  92. $('#withTime').attr('checked', withtime);
  93. $('#withTime').next().addClass('layui-form-checked');
  94. }
  95. layer.closeAll('loading');
  96. }
  97. });
  98. } else if (obj.event == 'all') {
  99. showToast();
  100. $('[name=pocode]').val('');
  101. $('[name=lotno]').val('');
  102. eTbl.reload({
  103. where: {
  104. poCode: '',
  105. lotNo: '',
  106. startTime: '',
  107. endTime: ''
  108. },
  109. page: {
  110. curr: 1
  111. },
  112. done: function () {
  113. laydate.render({
  114. elem: '#starttime'
  115. });
  116. laydate.render({
  117. elem: '#endtime'
  118. });
  119. $('#withTime').attr('checked', false);
  120. $('#withTime').next().removeClass('layui-form-checked');
  121. layer.closeAll('loading');
  122. }
  123. });
  124. }
  125. });
  126. //table.on('toolbar(macmodel)', function (obj) {
  127. // if (obj.event == 'add') {
  128. // layer.open({
  129. // type: 2,
  130. // title: '新增机器型号',
  131. // content: 'macmodelAdd.html',
  132. // area: ['800px', '400px']
  133. // });
  134. // } else if (obj.event == 'delete') {
  135. // var checkStatus = table.checkStatus('tbl');
  136. // console.log(checkStatus);
  137. // if (checkStatus.data.length === 0) {
  138. // layer.msg('请先选中需要操作的型号!', {
  139. // icon: 2,
  140. // anim: 6
  141. // });
  142. // return;
  143. // }
  144. // var ids = '';
  145. // for (var i = 0; i < checkStatus.data.length; i++) {
  146. // ids += checkStatus.data[i].id + ',';
  147. // }
  148. // ids = ids.substr(0, ids.length - 1);
  149. // $.ajax({
  150. // url: '/mes/api/macmodel/delete',
  151. // type: 'post',
  152. // contentType: 'application/json',
  153. // dataType: 'text',
  154. // data: JSON.stringify(ids),
  155. // success: function (res) {
  156. // if (res) {
  157. // layer.msg('操作成功', {
  158. // icon: 1,
  159. // anim: 0
  160. // });
  161. // eTbl.reload(true);
  162. // } else {
  163. // layer.msg('操作失败', {
  164. // icon: 2,
  165. // anim: 6
  166. // });
  167. // }
  168. // }
  169. // });
  170. // }
  171. //});
  172. //table.on('rowDouble(macmodel)', function (obj) {
  173. // console.log(obj);
  174. // layer.open({
  175. // type: 2,
  176. // content: 'macmodelAdd.html?id=' + obj.data.id,
  177. // area: ['800px', '400px']
  178. // });
  179. //});
  180. table.on('sort(macmodel)', function (obj) {
  181. where['sort'] = obj.field;
  182. where['order'] = obj.type;
  183. eTbl.reload({
  184. initSort: obj,
  185. where: where
  186. })
  187. });
  188. });
  189. function reloadTable() {
  190. eTbl.reload();
  191. }