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.

491 lines
17 KiB

3 days ago
  1. <#import "../master.ftl" as master>
  2. <@master.layout>
  3. <style>
  4. /* 新增的样式 */
  5. #delivery_fm label {
  6. width: 135px;
  7. }
  8. /* 去下划线 */
  9. a.disabled-underscore{
  10. text-decoration: none;
  11. }
  12. .input-css{
  13. border: 1px solid;
  14. border-color: #95B8E7;
  15. border-radius: 5px;
  16. height: 25px;
  17. }
  18. .button-disabled {
  19. pointer-events: none; /* 禁止鼠标事件 */
  20. cursor: default; /* 更改鼠标指针为默认样式 */
  21. color: gray; /* 可选:改变颜色以指示链接被禁用 */
  22. text-decoration: none; /* 可选:移除下划线 */
  23. }
  24. </style>
  25. <div class="page-header">
  26. <h2>Counting List</h2>
  27. </div>
  28. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  29. data-options="pagination: true, pageSize:20, showFooter: true, singleSelect:true, fitColumns:true ,
  30. queryParams:{status: $('#search_status').val()},
  31. url:'/inventory/getAllInventoryTask', method:'POST', toolbar:'#tb'">
  32. <thead>
  33. <tr>
  34. <th data-options="field:'inventoryNo',width:60">Counting No</th>
  35. <th data-options="field:'status',width:60,formatter:formatStatusRemark" >Status</th>
  36. <th data-options="field:'createdBy',width:60">Created By</th>
  37. <th data-options="field:'createdDate',width:100, align: 'center',formatter:formatDateTime">Create Date</th>
  38. <th data-options="field:'updatedBy',width:60,align:'left'">Updated By</th>
  39. <th data-options="field:'updatedDate',width:100,align:'center',formatter:formatDateTime">Update Date</th>
  40. <th data-options="field:'locationNo',width:100,editor:'text'">Counted Locations</th>
  41. <th data-options="field:'partNo', width:60,editor:'text'">Counted Parts</th>
  42. <th data-options="field:'remark', width:60, editor:'textbox'">Remark</th>
  43. <th data-options="field:'id',width:200, formatter: formatDeliveryAction">Actions</th>
  44. </tr>
  45. </thead>
  46. </table>
  47. <div id="tb" style="padding:10px 5px;display: none;">
  48. <div>
  49. 盘点任务单号: <input class="easyui-textbox" id="search_inventory_no" name="inventoryNo" style="width:100px">
  50. 物料编码: <input class="easyui-textbox" id="search_part_no" name="partNo" style="width:100px">
  51. 库位: <input class="easyui-textbox" id="search_location_no" name="locationNo" style="width:100px">
  52. Status:
  53. <select class="easyui-combobox" name="status" id="search_status" style="width:90px;">
  54. <option value="ALL">ALL</option>
  55. <option value="N">In Propress</option>
  56. <option value="Y">Counted</option>
  57. <option value="C">Cancelled</option>
  58. </select>
  59. <#--创建日期: <input class="easyui-datebox" id="createdDateFrom" style="width:100px">
  60. 至: <input class="easyui-datebox" id="createdDateTo" style="width:100px">-->
  61. <a id="queryLink" onclick="searchData()" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  62. &nbsp;&nbsp;&nbsp;
  63. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="createInventoryTasks()">New Counting Report</a>
  64. </div>
  65. </div>
  66. <!-- 新增盘点单 -->
  67. <div id="sales_inventory_modal" class="easyui-dialog" style="width: 380px;display: none;"
  68. data-options="modal:true, onClose: function(){ $('#dg').datagrid('reload')}"
  69. closed="true" buttons="#sales-delivery-buttons">
  70. <form id="sales_inventory_fm" method="post" novalidate style="margin:0;padding:20px 20px">
  71. <div style="margin-bottom:10px; display: none;" >
  72. <input id="id" name="id" class="easyui-textbox " style="display: none;" value="0">
  73. </div>
  74. <div style="margin-bottom: 10px">
  75. <label>Counting No:</label>
  76. <input id="inventory_no" name="inventoryNo" class="input-css" style="width: 75%; margin-left: 10px;" readonly>
  77. </div>
  78. <div style="margin-bottom: 10px">
  79. <label>物料编码:</label>
  80. <input id="part_no" name="partNo" class="input-css" style="width: 75%; margin-left: 10px;" autocomplete="off">
  81. </div>
  82. <div style="margin-bottom: 10px">
  83. <label style="margin-left: 24px;">库位:</label>
  84. <input id="location_no" name="locationNo" class="input-css" style="width: 75%; margin-left: 10px;" autocomplete="off">
  85. </div>
  86. <div style="margin-bottom: 10px">
  87. <label style="margin-left: 24px;">Remark:</label>
  88. <input id="remark" name="remark" class="input-css" style="width: 75%; margin-left: 10px;" autocomplete="off">
  89. </div>
  90. </form>
  91. </div>
  92. <div id="sales-delivery-buttons" style="display: none; text-align: center;">
  93. <a href="javascript:void(0)" id="saveButton" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveinventoryTask()" style="width:90px">Save</a>
  94. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#sales_inventory_modal').dialog('close')" style="width:90px">Close</a>
  95. </div>
  96. <!-- 盘点明细 -->
  97. <div id="inventory_detail_modal" class="easyui-dialog" style="width: 730px;display: none;" closed="true" data-options="modal:true" >
  98. <table id="inventory_detail_table" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  99. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true ,
  100. method:'POST', pageSize:20,toolbar:'#inventory_detail_buttons'">
  101. <thead>
  102. <tr>
  103. <th data-options="field:'inventoryNo',width:150">Counting No</th>
  104. <th data-options="field:'labelNo',width:150">Box No</th>
  105. <th data-options="field:'labelQty',width:80,align:'right' " >Quantity</th>
  106. <th data-options="field:'partNo',width:120">Part No</th>
  107. <th data-options="field:'locationNo',width:100">Location No</th>
  108. <th data-options="field:'keyinFlag',width:120, formatter:formatDetailStatusRemark">Counted Flag</th>
  109. <th data-options="field:'keyinBy',width:120">Counted By</th>
  110. <th data-options="field:'keyinDate',width:180,align: 'center',formatter:formatDateTime">Counted Time</th>
  111. </tr>
  112. </thead>
  113. </table>
  114. </div>
  115. <div id="inventory_detail_buttons" style="padding:10px 5px;display: none;">
  116. <div>
  117. <a class="easyui-linkbutton" iconCls="icon-add" onclick="downInventoryDetailExcel()">Export to Excel</a>
  118. </div>
  119. </div>
  120. <!-- 盘点 -->
  121. <div id="performing_task_modal" class="easyui-dialog" style="width: 650px;display: none;" closed="true" data-options="modal:true" >
  122. <table id="performing_task_table" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  123. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true ,
  124. method:'POST', pageSize:20,toolbar:'#performing_task_buttons'">
  125. <thead>
  126. <tr>
  127. <th data-options="field:'labelNo',width:150">Box No</th>
  128. <th data-options="field:'labelQty',width:80,align:'right' " >Quantity</th>
  129. <th data-options="field:'partNo',width:120">Part No</th>
  130. <th data-options="field:'locationNo',width:100">Location No</th>
  131. <th data-options="field:'keyinFlag',width:120, formatter:formatDetailStatusRemark">Counted Flag</th>
  132. <th data-options="field:'keyinBy',width:120">Counted By</th>
  133. <th data-options="field:'keyinDate',width:180,align: 'center',formatter:formatDateTime">Counted Time</th>
  134. </tr>
  135. </thead>
  136. </table>
  137. </div>
  138. <div id="performing_task_buttons" style="padding:10px 5px;display: none;">
  139. <div>
  140. <div style="margin-bottom: 10px">
  141. <label>Counting No:</label>
  142. <input id="performing_inventory_no" name="inventoryNo" class="input-css" style="width: 30%; margin-left: 10px;" autocomplete="off" readonly>
  143. </div>
  144. <div style="margin-bottom: 10px">
  145. <label>Please scan Box No:</label>
  146. <input id="performing_label_no" name="labelNo" class="input-css" style="width: 30%; margin-left: 10px;" autocomplete="off">
  147. </div>
  148. </div>
  149. </div>
  150. <script>
  151. //公共参数
  152. var currentRow;//盘点单信息
  153. var addFlag = "Y";//盘点单信息
  154. let site = $('#current_site').val();
  155. $(window).resize(function () {
  156. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 30});
  157. });
  158. $(function () {
  159. $(window).resize();
  160. });
  161. //延时
  162. var delay = (function(){
  163. var timer = 0;
  164. return function(callback, ms){
  165. clearTimeout (timer);
  166. timer = setTimeout(callback, ms);
  167. };
  168. })();
  169. //格式化字符串时间
  170. function formatStringDateTime(value, row){
  171. if(null == value || '' == value){
  172. return '';
  173. }
  174. //处理位数不够的问题
  175. if(value.length < 19){
  176. value = value.substring(0, 10);
  177. }else{
  178. value = value.substring(0, 19);
  179. }
  180. value = value.replaceAll("T"," ");
  181. return value;
  182. }
  183. //状态中文翻译
  184. function formatStatusRemark(value, row){
  185. if('Y' == value){
  186. return 'Counted';
  187. }else if('N' == value){
  188. return 'In Propress';
  189. }else if('C' == value){
  190. return 'Cancelled';
  191. }
  192. }
  193. function formatDetailStatusRemark(value, row){
  194. if('Y' == value){
  195. return 'Counted';
  196. }else if('N' == value){
  197. return 'To be Counted';
  198. }
  199. }
  200. //查询主表的数据
  201. function searchData(){
  202. var dg = $('#dg').datagrid({
  203. queryParams: {
  204. inventoryNo: $('#search_inventory_no').val(),
  205. partNo: $('#search_part_no').val(),
  206. locationNo: $('#search_location_no').val(),
  207. status: $('#search_status').val(),
  208. /* startDate: $('#createdDateFrom').val(),
  209. endDate: $('#createdDateTo').val()*/
  210. }
  211. });
  212. }
  213. //主表功能
  214. function formatDeliveryAction(value, row){
  215. //根据状态区分不同的按钮
  216. let status = row.status;
  217. let tags = '';
  218. if('N' == status){
  219. tags += '<a onclick="performingTaskModal(\''+row.inventoryNo+'\')" class="disabled-underscore">Counting</a>&nbsp;|&nbsp;';
  220. }
  221. if('N' == status){
  222. tags += '<a onclick="closeInventoryTask(\''+row.inventoryNo+'\')" class="disabled-underscore">Complete Counting</a>&nbsp;|&nbsp;';
  223. tags += '<a onclick="deleteInventoryTask(\''+row.inventoryNo+'\')" class="disabled-underscore">Cancel Counting Report</a>&nbsp;|&nbsp;';
  224. }
  225. tags += '<a onclick="getAllInventoryTasksDetail(\''+row.inventoryNo+'\')" class="disabled-underscore">Detail</a>';
  226. return tags;
  227. }
  228. //绑定的enter事件
  229. $('#part_no').bind("keydown", function (e) {
  230. if (e.keyCode == 13) {
  231. let value = $.trim($(this).val());
  232. if(null != value && '' !== value && value.substring(value.length-1) !== ';'){
  233. $(this).val(value+";");
  234. //校验物料编码
  235. }
  236. }
  237. });
  238. $('#location_no').bind("keydown", function (e) {
  239. if (e.keyCode == 13) {
  240. let value = $.trim($(this).val());
  241. console.log(value);
  242. if(null != value && '' !== value && value.substring(value.length-1) !== ';'){
  243. $(this).val(value+";");
  244. //校验库位
  245. }
  246. }
  247. });
  248. $('#performing_label_no').bind("keydown", function (e) {
  249. if (e.keyCode == 13) {
  250. let value = $.trim($(this).val()); //扫描箱码
  251. console.log(value);
  252. if(null != value && '' !== value){
  253. //触发扫码盘点事件
  254. performingInventoryTask(value);
  255. }
  256. }
  257. });
  258. //提交网址
  259. let url = '';
  260. //新增出货单的modal
  261. function createInventoryTasks(){
  262. addFlag = "Y";
  263. $('#id').textbox("setValue", 0);
  264. $('#sales_inventory_modal').dialog('open').dialog('center').dialog('setTitle','New Counting Report');
  265. $('#sales_inventory_fm').form('clear');
  266. //生成盘点单号
  267. createInventoryNo();
  268. $('#part_no').focus();
  269. url = '/saveCountingHeader'; //新增方法
  270. }
  271. //获取盘点单号
  272. function createInventoryNo(){
  273. //获取盘点单号
  274. $.ajaxSetup({
  275. contentType: "application/x-www-form-urlencoded"});
  276. $.post('/getMaxCountingId', "", function(result){
  277. if (result.success){
  278. //放入单号标签中
  279. $('#inventory_no').val(result.reportId);
  280. } else {
  281. $.messager.alert('error',result.msg, 'error');
  282. }
  283. },'json');
  284. $.ajaxSetup({
  285. contentType: " application/x-www-form-urlencoded"});
  286. }
  287. //关闭盘点单
  288. function closeInventoryTask(inventoryNo){
  289. let postData = {'inventoryNo': inventoryNo};
  290. //保存或修改数据
  291. //序列化
  292. postData = JSON.stringify(postData);
  293. //post请求类型修改
  294. $.ajaxSetup({
  295. contentType: "application/json;charset=utf-8"});
  296. $.post("/checkTaskIfScanAll", postData, function(result){
  297. if (result.success){
  298. let comStr = 'There is lines have not be counted yet in this counting report ,are you sure to close the counting report(<b>'+inventoryNo+'</b>)?';
  299. if (result.checkFlag){
  300. comStr = 'There is lines have not be counted yet in this counting report ,are you sure to close the counting report(<b>'+inventoryNo+'</b>)?';
  301. }
  302. $.messager.confirm('Confirm',comStr, function(r){
  303. if (r){
  304. addFlag = 'N';
  305. //取到当前的行
  306. delay(function(){
  307. currentRow = $('#dg').datagrid('getSelected');
  308. url = '/closeCountingHeader';
  309. currentRow.updatedBy = username;
  310. //调用方法
  311. saveinventoryTask();
  312. }, 500);
  313. }
  314. });
  315. } else {
  316. $.messager.alert('error',result.msg, 'error');
  317. }
  318. },'json');
  319. $.ajaxSetup({
  320. contentType: " application/x-www-form-urlencoded"});
  321. }
  322. //删除确认
  323. function deleteInventoryTask(inventoryNo){
  324. $.messager.confirm('Confirm','Are you sure to cancel the counting report : <b>'+inventoryNo+'</b> ?', function(r){
  325. if (r){
  326. addFlag = 'D';
  327. //取到当前的行
  328. delay(function(){
  329. currentRow = $('#dg').datagrid('getSelected');
  330. currentRow.updatedBy = username;
  331. url = '/deleteCountingHeader';
  332. //调用删除方法
  333. saveinventoryTask();
  334. }, 500);
  335. }
  336. });
  337. }
  338. //保存盘点单信息
  339. function saveinventoryTask(){
  340. let postData;
  341. //判断是否新增
  342. if(addFlag == 'N'){//结束盘点任务
  343. postData = {'inventoryNo': currentRow.inventoryNo, 'updatedBy': username };
  344. }if(addFlag == 'Y'){//新增
  345. let inventoryNo = $.trim($("#inventory_no").val());
  346. let partNo = $.trim($("#part_no").val());
  347. let locationNo = $.trim($("#location_no").val());
  348. let remark = $.trim($("#remark").val());
  349. let id = $.trim($("#id").val());
  350. //空值判断
  351. if(null == inventoryNo || '' == inventoryNo){
  352. $.messager.alert('error','Exception error when generate counting no, please refresh and try again!', 'error');
  353. return false;
  354. }
  355. postData = {'inventoryNo': inventoryNo, 'partNo': partNo, 'locationNo': locationNo,
  356. 'remark': remark, 'createdBy': username};
  357. } else{ //删除盘点任务
  358. postData = {'inventoryNo': currentRow.inventoryNo, 'updatedBy': username};
  359. }
  360. //保存或修改数据
  361. //序列化
  362. postData = JSON.stringify(postData);
  363. //post请求类型修改
  364. $('#saveButton').addClass("button-disabled");
  365. $.ajaxSetup({
  366. contentType: "application/json;charset=utf-8"});
  367. $.post(url, postData, function(result){
  368. $('#saveButton').removeClass("button-disabled");
  369. if (result.success){
  370. //刷新主表数据
  371. $('#dg').datagrid('reload');
  372. //隐藏modal
  373. $('#sales_inventory_modal').dialog('close');
  374. } else {
  375. $.messager.alert('error',result.msg, 'error');
  376. }
  377. },'json');
  378. $.ajaxSetup({
  379. contentType: " application/x-www-form-urlencoded"});
  380. }
  381. //查询盘点详细信息
  382. function getAllInventoryTasksDetail(inventoryNo){
  383. delay(function(){
  384. currentRow = $('#dg').datagrid('getSelected');
  385. $('#inventory_detail_modal').dialog('open').dialog('center').dialog('setTitle', inventoryNo+'的盘点明细');
  386. //已经发货的不允许新增和重新导入
  387. let opts = $('#inventory_detail_table').datagrid('options');
  388. opts.queryParams = {'inventoryNo': inventoryNo};
  389. $("#inventory_detail_table").datagrid({url: "/getAllInventoryTaskDetail",
  390. onLoadSuccess: function(data) {
  391. }
  392. });
  393. }, 500);
  394. }
  395. //盘点Modal
  396. function performingTaskModal(inventoryNo){
  397. delay(function(){
  398. currentRow = $('#dg').datagrid('getSelected');
  399. $('#performing_task_modal').dialog('open').dialog('center').dialog('setTitle', inventoryNo+'的盘点任务');
  400. $('#performing_inventory_no').val(inventoryNo);
  401. let opts = $('#performing_task_table').datagrid('options');
  402. opts.queryParams = {'inventoryNo': inventoryNo};
  403. $("#performing_task_table").datagrid({url: "/getInventoryTaskDetailByScan",
  404. onLoadSuccess: function(data) {
  405. }
  406. });
  407. $('#performing_label_no').focus();
  408. }, 500);
  409. }
  410. //保存盘点单信息
  411. function performingInventoryTask(labelNo){
  412. let postData = {'inventoryNo': currentRow.inventoryNo, 'labelNo': labelNo, 'updatedBy': username };
  413. //保存或修改数据
  414. //序列化
  415. postData = JSON.stringify(postData);
  416. //post请求类型修改
  417. $.ajaxSetup({
  418. contentType: "application/json;charset=utf-8"});
  419. $.post('/performingInventoryTask', postData, function(result){
  420. if (result.success){
  421. //刷新表数据
  422. $('#performing_task_table').datagrid('reload');
  423. //清空获取焦点
  424. $('#performing_label_no').val('');
  425. $('#performing_label_no').focus();
  426. } else {
  427. //清空获取焦点
  428. $('#performing_label_no').val('');
  429. $('#performing_label_no').focus();
  430. $.messager.alert('error',result.msg, 'error');
  431. }
  432. },'json');
  433. $.ajaxSetup({
  434. contentType: " application/x-www-form-urlencoded"});
  435. }
  436. //下载Excel数据
  437. function downInventoryDetailExcel(){
  438. let inventoryNo = currentRow.inventoryNo;
  439. let print_url = '/export/downInventoryDetailExcel?inventoryNo='+inventoryNo;
  440. $("#ifmforprint").attr('src', print_url);
  441. }
  442. </script>
  443. </@master.layout>