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.

493 lines
17 KiB

1 week 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>盘点清单</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:50">Created By</th>
  37. <th data-options="field:'createdDate',width:100, align: 'center',formatter:formatStringDateTime">Created Time</th>
  38. <th data-options="field:'updatedBy',width:50,align:'left'">Updated By</th>
  39. <th data-options="field:'updatedDate',width:100,align:'center',formatter:formatStringDateTime">Updated Time</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:240, formatter: formatDeliveryAction">Actions</th>
  44. </tr>
  45. </thead>
  46. </table>
  47. <div id="tb" style="padding:10px 5px;display: none;">
  48. <div>
  49. Counting No: <input class="easyui-textbox" id="search_inventory_no" name="inventoryNo" style="width:100px">
  50. Part No: <input class="easyui-textbox" id="search_part_no" name="partNo" style="width:100px">
  51. Location No: <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: 100%; margin-left: 0px;" readonly>
  77. </div>
  78. <div style="margin-bottom: 10px">
  79. <label>Part No:</label>
  80. <input id="part_no" name="partNo" class="input-css" style="width: 100%; margin-left: 0px;" autocomplete="off">
  81. </div>
  82. <div style="margin-bottom: 10px">
  83. <label style="margin-left: 0px;">Location No:</label>
  84. <input id="location_no" name="locationNo" class="input-css" style="width: 100%; margin-left: 0px;" autocomplete="off">
  85. </div>
  86. <div style="margin-bottom: 10px">
  87. <label style="margin-left: 0px;">Remark:</label>
  88. <input id="remark" name="remark" class="input-css" style="width: 100%; margin-left: 0px;" 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: 850px;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:false ,
  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' " >Qty</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:formatStringDateTime">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' " >Qty</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:formatStringDateTime">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. let username = $('#current_username').val();
  156. $(window).resize(function () {
  157. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 30});
  158. });
  159. $(function () {
  160. $(window).resize();
  161. });
  162. //延时
  163. var delay = (function(){
  164. var timer = 0;
  165. return function(callback, ms){
  166. clearTimeout (timer);
  167. timer = setTimeout(callback, ms);
  168. };
  169. })();
  170. //格式化字符串时间
  171. function formatStringDateTime(value, row){
  172. if(null == value || '' == value){
  173. return '';
  174. }
  175. //处理位数不够的问题
  176. if(value.length < 19){
  177. value = value.substring(0, 10);
  178. }else{
  179. value = value.substring(0, 19);
  180. }
  181. value = value.replaceAll("T"," ");
  182. return value;
  183. }
  184. //状态中文翻译
  185. function formatStatusRemark(value, row){
  186. if('Y' == value){
  187. return 'Counted';
  188. }else if('N' == value){
  189. return 'In Propress';
  190. }else if('C' == value){
  191. return 'Cancelled';
  192. }
  193. }
  194. function formatDetailStatusRemark(value, row){
  195. if('Y' == value){
  196. return 'Counted';
  197. }else if('N' == value){
  198. return 'To be Counted';
  199. }
  200. }
  201. //查询主表的数据
  202. function searchData(){
  203. var dg = $('#dg').datagrid({
  204. queryParams: {
  205. inventoryNo: $('#search_inventory_no').val(),
  206. partNo: $('#search_part_no').val(),
  207. locationNo: $('#search_location_no').val(),
  208. status: $('#search_status').val(),
  209. /* startDate: $('#createdDateFrom').val(),
  210. endDate: $('#createdDateTo').val()*/
  211. }
  212. });
  213. }
  214. //主表功能
  215. function formatDeliveryAction(value, row){
  216. //根据状态区分不同的按钮
  217. let status = row.status;
  218. let tags = '';
  219. if('N' == status){
  220. tags += '<a onclick="performingTaskModal(\''+row.inventoryNo+'\')" class="disabled-underscore">Counting</a>&nbsp;|&nbsp;';
  221. }
  222. if('N' == status){
  223. tags += '<a onclick="closeInventoryTask(\''+row.inventoryNo+'\')" class="disabled-underscore">Complete Counting</a>&nbsp;|&nbsp;';
  224. tags += '<a onclick="deleteInventoryTask(\''+row.inventoryNo+'\')" class="disabled-underscore">Cancel Counting Report</a>&nbsp;|&nbsp;';
  225. }
  226. tags += '<a onclick="getAllInventoryTasksDetail(\''+row.inventoryNo+'\')" class="disabled-underscore">Detail</a>';
  227. return tags;
  228. }
  229. //绑定的enter事件
  230. $('#part_no').bind("keydown", function (e) {
  231. if (e.keyCode == 13) {
  232. let value = $.trim($(this).val());
  233. if(null != value && '' !== value && value.substring(value.length-1) !== ';'){
  234. $(this).val(value+";");
  235. //校验物料编码
  236. }
  237. }
  238. });
  239. $('#location_no').bind("keydown", function (e) {
  240. if (e.keyCode == 13) {
  241. let value = $.trim($(this).val());
  242. console.log(value);
  243. if(null != value && '' !== value && value.substring(value.length-1) !== ';'){
  244. $(this).val(value+";");
  245. //校验库位
  246. }
  247. }
  248. });
  249. $('#performing_label_no').bind("keydown", function (e) {
  250. if (e.keyCode == 13) {
  251. let value = $.trim($(this).val()); //扫描箱码
  252. console.log(value);
  253. if(null != value && '' !== value){
  254. //触发扫码盘点事件
  255. performingInventoryTask(value);
  256. }
  257. }
  258. });
  259. //提交网址
  260. let url = '';
  261. //新增出货单的modal
  262. function createInventoryTasks(){
  263. addFlag = "Y";
  264. $('#id').textbox("setValue", 0);
  265. $('#sales_inventory_modal').dialog('open').dialog('center').dialog('setTitle','New Counting Report');
  266. $('#sales_inventory_fm').form('clear');
  267. //生成盘点单号
  268. createInventoryNo();
  269. $('#part_no').focus();
  270. url = '/inventory/saveCountingHeader'; //新增方法
  271. }
  272. //获取盘点单号
  273. function createInventoryNo(){
  274. //获取盘点单号
  275. $.ajaxSetup({
  276. contentType: "application/x-www-form-urlencoded"});
  277. $.post('/inventory/getMaxCountingId', "", function(result){
  278. if (result.success){
  279. //放入单号标签中
  280. $('#inventory_no').val(result.reportId);
  281. } else {
  282. $.messager.alert('error',result.msg, 'error');
  283. }
  284. },'json');
  285. $.ajaxSetup({
  286. contentType: " application/x-www-form-urlencoded"});
  287. }
  288. //关闭盘点单
  289. function closeInventoryTask(inventoryNo){
  290. let postData = {'inventoryNo': inventoryNo};
  291. //保存或修改数据
  292. //序列化
  293. postData = JSON.stringify(postData);
  294. //post请求类型修改
  295. $.ajaxSetup({
  296. contentType: "application/json;charset=utf-8"});
  297. $.post("/inventory/checkTaskIfScanAll", postData, function(result){
  298. if (result.success){
  299. let comStr = 'Are you sure to close the counting report(<b>'+inventoryNo+'</b>)?';
  300. if (result.checkFlag){
  301. comStr = 'There is lines have not be counted yet in this counting report ,are you sure to close the counting report (<b>'+inventoryNo+'</b>)?';
  302. }
  303. $.messager.confirm('Confirm',comStr, function(r){
  304. if (r){
  305. addFlag = 'N';
  306. //取到当前的行
  307. delay(function(){
  308. currentRow = $('#dg').datagrid('getSelected');
  309. url = '/inventory/closeCountingHeader';
  310. currentRow.updatedBy = username;
  311. //调用方法
  312. saveinventoryTask();
  313. }, 500);
  314. }
  315. });
  316. } else {
  317. $.messager.alert('error',result.msg, 'error');
  318. }
  319. },'json');
  320. $.ajaxSetup({
  321. contentType: " application/x-www-form-urlencoded"});
  322. }
  323. //删除确认
  324. function deleteInventoryTask(inventoryNo){
  325. $.messager.confirm('Confirm','Cancel Counting Report: <b>'+inventoryNo+'</b> ?', function(r){
  326. if (r){
  327. addFlag = 'D';
  328. //取到当前的行
  329. delay(function(){
  330. currentRow = $('#dg').datagrid('getSelected');
  331. currentRow.updatedBy = username;
  332. url = '/inventory/deleteCountingHeader';
  333. //调用删除方法
  334. saveinventoryTask();
  335. }, 500);
  336. }
  337. });
  338. }
  339. //保存盘点单信息
  340. function saveinventoryTask(){
  341. let postData;
  342. //判断是否新增
  343. if(addFlag == 'N'){//结束盘点任务
  344. postData = {'inventoryNo': currentRow.inventoryNo, 'updatedBy': username };
  345. }if(addFlag == 'Y'){//新增
  346. let inventoryNo = $.trim($("#inventory_no").val());
  347. let partNo = $.trim($("#part_no").val());
  348. let locationNo = $.trim($("#location_no").val());
  349. let remark = $.trim($("#remark").val());
  350. let id = $.trim($("#id").val());
  351. //空值判断
  352. if(null == inventoryNo || '' == inventoryNo){
  353. $.messager.alert('error','Exception error when generate counting no, please refresh and try again\n!', 'error');
  354. return false;
  355. }
  356. postData = {'inventoryNo': inventoryNo, 'partNo': partNo, 'locationNo': locationNo,
  357. 'remark': remark, 'createdBy': username};
  358. } else{ //删除盘点任务
  359. postData = {'inventoryNo': currentRow.inventoryNo, 'updatedBy': username};
  360. }
  361. //保存或修改数据
  362. //序列化
  363. postData = JSON.stringify(postData);
  364. //post请求类型修改
  365. $('#saveButton').addClass("button-disabled");
  366. $.ajaxSetup({
  367. contentType: "application/json;charset=utf-8"});
  368. $.post(url, postData, function(result){
  369. $('#saveButton').removeClass("button-disabled");
  370. if (result.success){
  371. //刷新主表数据
  372. $('#dg').datagrid('reload');
  373. //隐藏modal
  374. $('#sales_inventory_modal').dialog('close');
  375. } else {
  376. $.messager.alert('error',result.msg, 'error');
  377. }
  378. },'json');
  379. $.ajaxSetup({
  380. contentType: " application/x-www-form-urlencoded"});
  381. }
  382. //查询盘点详细信息
  383. function getAllInventoryTasksDetail(inventoryNo){
  384. delay(function(){
  385. currentRow = $('#dg').datagrid('getSelected');
  386. $('#inventory_detail_modal').dialog('open').dialog('center').dialog('setTitle', inventoryNo+' Counting Lines ');
  387. //已经发货的不允许新增和重新导入
  388. let opts = $('#inventory_detail_table').datagrid('options');
  389. opts.queryParams = {'inventoryNo': inventoryNo};
  390. $("#inventory_detail_table").datagrid({url: "/inventory/getAllInventoryTaskDetail",
  391. onLoadSuccess: function(data) {
  392. }
  393. });
  394. }, 500);
  395. }
  396. //盘点Modal
  397. function performingTaskModal(inventoryNo){
  398. delay(function(){
  399. currentRow = $('#dg').datagrid('getSelected');
  400. $('#performing_task_modal').dialog('open').dialog('center').dialog('setTitle', inventoryNo+' Counting Lines ');
  401. $('#performing_inventory_no').val(inventoryNo);
  402. let opts = $('#performing_task_table').datagrid('options');
  403. opts.queryParams = {'inventoryNo': inventoryNo};
  404. $("#performing_task_table").datagrid({url: "/inventory/getInventoryTaskDetailByScan",
  405. onLoadSuccess: function(data) {
  406. }
  407. });
  408. $('#performing_label_no').focus();
  409. }, 500);
  410. }
  411. //保存盘点单信息
  412. function performingInventoryTask(labelNo){
  413. let postData = {'inventoryNo': currentRow.inventoryNo, 'labelNo': labelNo, 'updatedBy': username };
  414. //保存或修改数据
  415. //序列化
  416. postData = JSON.stringify(postData);
  417. //post请求类型修改
  418. $.ajaxSetup({
  419. contentType: "application/json;charset=utf-8"});
  420. $.post('/inventory/performingInventoryTask', postData, function(result){
  421. if (result.success){
  422. //刷新表数据
  423. $('#performing_task_table').datagrid('reload');
  424. //清空获取焦点
  425. $('#performing_label_no').val('');
  426. $('#performing_label_no').focus();
  427. } else {
  428. //清空获取焦点
  429. $('#performing_label_no').val('');
  430. $('#performing_label_no').focus();
  431. $.messager.alert('error',result.msg, 'error');
  432. }
  433. },'json');
  434. $.ajaxSetup({
  435. contentType: " application/x-www-form-urlencoded"});
  436. }
  437. //下载Excel数据
  438. function downInventoryDetailExcel(){
  439. let inventoryNo = currentRow.inventoryNo;
  440. let print_url = '/export/inventory/downInventoryDetailExcel?inventoryNo='+inventoryNo;
  441. $("#ifmforprint").attr('src', print_url);
  442. }
  443. </script>
  444. </@master.layout>