You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
8.7 KiB

3 days ago
  1. <#import "../master.ftl" as master>
  2. <@master.layout>
  3. <style>
  4. #fm label {
  5. width: 150px;
  6. }
  7. </style>
  8. <div class="page-header">
  9. <h3>Query of Counting</h3>
  10. </div>
  11. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  12. data-options="pagination: true, showFooter: true, singleSelect:true, fitColumns:true , url:'/counting/all',method:'get',pageSize:20,toolbar:'#tb'">
  13. <thead>
  14. <tr>
  15. <th data-options="field:'countingNo',width:100,editor:'textbox'">Counting No</th>
  16. <th data-options="field:'remark',width:200,editor:'textbox'">Remark</th>
  17. <th data-options="field:'createdBy',width:80,align:'left'">Created By</th>
  18. <th data-options="field:'createdDate',width:150,align:'center',formatter:formatDateTime">Create Date</th>
  19. <th data-options="field:'status',width:100,editor:'textbox'">Status</th>
  20. <th data-options="field:'id',width:150,align:'center',formatter:formatAction">Actions</th>
  21. </tr>
  22. </thead>
  23. </table>
  24. <div id="tb" style="padding:10px 5px;display: none;">
  25. <div>
  26. 盘点号: <input class="easyui-textbox" id="countingNo" style="width:110px">
  27. Create Date: <input class="easyui-datetimebox" id="createdDateFrom" style="width:160px">
  28. 到: <input class="easyui-datetimebox" id="createdDateTo" style="width:160px">
  29. <a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  30. &nbsp;&nbsp;&nbsp;
  31. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="showCountingDialog()">New Counting Report</a>
  32. </div>
  33. </div>
  34. <form enctype="multipart/form-data" id="importForm" style="display:none;" method="post">
  35. <input type="file" name="importFile" id="importFile"/>
  36. </form>
  37. <div id="dlgDtls" class="easyui-dialog" style="width:1000px;display: none;"
  38. closed="true" data-options="modal:true">
  39. <table id="dgDtls" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  40. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:50">
  41. <thead>
  42. <tr>
  43. <th data-options="field:'partno',width:200">Part No</th>
  44. <th data-options="field:'partdescription',width:250">Part Description</th>
  45. <th data-options="field:'locationno',width:150">Location No</th>
  46. <th data-options="field:'lotbatchno',width:200">Lot/Batch No</th>
  47. <th data-options="field:'onhandqty',width:150">On Hand Qty</th>
  48. <th data-options="field:'availableqty',width:150">Available Qty</th>
  49. <th data-options="field:'countedqty',width:150">Counted Qty</th>
  50. <th data-options="field:'varianceqty',width:150">Variance Qty</th>
  51. <th data-options="field:'uom',width:100">UoM</th>
  52. <th data-options="field:'receiptdate',width:250">Receipt Date</th>
  53. </tr>
  54. </thead>
  55. </table>
  56. </div>
  57. <div id="dlg" class="easyui-dialog" style="width:500px;display: none;" closed="true" buttons="#dlg-buttons">
  58. <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
  59. <div style="margin-bottom:10px">
  60. <input name="countingRemark" id="countingRemark" class="easyui-textbox" required="true" label="Please input remark:" style="width:100%">
  61. </div>
  62. <div style="margin-bottom:10px;float:right;">
  63. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newCounting()">Ok</a>
  64. </div>
  65. </form>
  66. </div>
  67. <script>
  68. $(window).resize(function () {
  69. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  70. });
  71. $(function () {
  72. $(window).resize();
  73. });
  74. $.extend($.fn.validatebox.defaults.rules, {
  75. validDate: {
  76. validator: function (value) {
  77. var date = $.fn.datebox.defaults.parser(value);
  78. var s = $.fn.datebox.defaults.formatter(date);
  79. return s == value;
  80. },
  81. message: 'Please enter a valid date.'
  82. },
  83. valueRange: {
  84. validator: function (value, param) {
  85. return value >= param[0] && value <= param[1];
  86. },
  87. message: 'Field do not match.'
  88. }
  89. });
  90. $("#queryLink").click(function () {
  91. var dg = $('#dg').datagrid({
  92. queryParams: {
  93. countingNo: $("#countingNo").val(),
  94. createdDateFrom: $("#createdDateFrom").val(),
  95. createdDateTo: $("#createdDateTo").val()
  96. }
  97. });
  98. });
  99. function formatAction(value, row) {
  100. return "<a href='javascript:importCountingDtls(\"" + row.countingNo + "\")'>Import</a>&nbsp;&nbsp;&nbsp;<a href='javascript:viewCountingDetail(\"" + row.countingNo + "\")'>View</a>&nbsp;&nbsp;&nbsp;<a href='javascript:downloadCounting(\"" + row.countingNo + "\")'>Export</a>&nbsp;&nbsp;&nbsp;<a href='javascript:deleteCounting(\"" + row.countingNo + "\")'>Delete</a>";
  101. }
  102. function viewCountingDetail(countingNo) {
  103. $('#dlgDtls').dialog('open').dialog('center').dialog('setTitle', 'Detail of Counting');
  104. $("#dgDtls").datagrid({url: "/counting/detail/" + countingNo});
  105. }
  106. function downloadCounting(countingNo) {
  107. window.open("/counting/download/" + countingNo, '_blank');
  108. }
  109. function deleteCounting(countingNo) {
  110. if (confirm("Are you sure to delete the counting data?")) {
  111. $.post("/counting/delete/" + countingNo, {}, function (result) {
  112. if (result.errorMsg) {
  113. $.messager.alert('error', result.errorMsg, 'error');
  114. } else {
  115. $('#dg').datagrid('reload');
  116. }
  117. });
  118. }
  119. }
  120. function showCountingDialog() {
  121. $('#dlg').dialog('open').dialog('center').dialog('setTitle', 'New Counting Report');
  122. $('#fm').form('clear');
  123. }
  124. function newCounting() {
  125. var countingRemark = $("#countingRemark").val();
  126. if (countingRemark === "") {
  127. $.messager.alert('error', "Please input remark", 'error');
  128. return;
  129. }
  130. $.post("/counting/add", {
  131. "remark": countingRemark
  132. }, function (result) {
  133. if (result.errorMsg) {
  134. $.messager.alert('error', result.errorMsg, 'error');
  135. } else {
  136. $('#dlg').dialog('close');
  137. $('#dg').datagrid('reload');
  138. }
  139. });
  140. }
  141. function importCountingDtls(countNo) {
  142. $("#importFile").click();
  143. importCountingNo = countNo;
  144. }
  145. function saveReceive() {
  146. $('#fm').form('submit', {
  147. url: "/receive/add",
  148. onSubmit: function () {
  149. return $(this).form('validate');
  150. },
  151. success: function (result) {
  152. var result = eval("(" + result + ")");
  153. if (result.errorMsg) {
  154. $.messager.alert('error', result.errorMsg, 'error');
  155. } else {
  156. $('#dlg').dialog('close'); // close the dialog
  157. $('#dg').datagrid('reload'); // reload the user data
  158. }
  159. }
  160. });
  161. }
  162. var importCountingNo = null;
  163. $(function () {
  164. $('#importFile').change(function () {
  165. if (this.files.length > 0) {
  166. setTimeout(function () {
  167. //创建FormData对象,初始化为form表单中的数据。需要添加其他数据可使用formData.append("property", "value");
  168. var formData = new FormData($('#importForm')[0]);
  169. //ajax异步上传
  170. $.ajax({
  171. url: "/counting/import/" + importCountingNo,
  172. type: "POST",
  173. data: formData,
  174. cache: false,
  175. success: function (result) {
  176. $('#importFile').val("");
  177. if (result.errorMsg) {
  178. $.messager.alert('error', result.errorMsg, 'error');
  179. }
  180. else {
  181. $('#dlg').dialog('close'); // close the dialog
  182. $('#dg').datagrid('reload'); // reload the user data
  183. }
  184. },
  185. contentType: false, //必须false才会自动加上正确的Content-Type
  186. processData: false //必须false才会避开jQuery对 formdata 的默认处理
  187. });
  188. }, 100);
  189. }
  190. });
  191. });
  192. </script>
  193. </@master.layout>