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.

1236 lines
44 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. </style>
  13. <div class="page-header">
  14. <h2>Customer Order Shipment</h2>
  15. </div>
  16. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  17. data-options="pagination: true, pageSize:20, showFooter: true, singleSelect:true, fitColumns:true ,
  18. queryParams:{status: $('#search_delivery_status').val()},
  19. url:'/sales/delivery/getSalesDeliverysByCon', method:'POST', toolbar:'#tb'">
  20. <thead>
  21. <tr>
  22. <th data-options="field:'deliveryNo',width:90">Delivery No</th>
  23. <th data-options="field:'ifsDeliveryNo',width:10">IFS Shipment ID</th>
  24. <th data-options="field:'customerNo',width:110">Customer Part No</th>
  25. <th data-options="field:'customerName',width:150">Customer Part Desc.</th>
  26. <th data-options="field:'trackingNo',width:110, align: 'center'">Express Bill No</th>
  27. <th data-options="field:'createdBy',width:80,align:'left'">Created By</th>
  28. <th data-options="field:'createdDate',width:100,align:'center',formatter:formatStringTime">Created Time</th>
  29. <#-- <th data-options="field:'ifsDeliveryNo',width:100,editor:'text'">IFS 单号</th>-->
  30. <th data-options="field:'status', width:70,editor:'text', formatter: formatStatusRemark">Status</th>
  31. <th data-options="field:'remark', width:70, editor:'textbox'">Remark</th>
  32. <th data-options="field:'id',width:200, formatter: formatDeliveryAction">Actions</th>
  33. </tr>
  34. </thead>
  35. </table>
  36. <div id="tb" style="padding:10px 5px;display: none;">
  37. <div>
  38. Delivery No: <input class="easyui-textbox" id="search_delivery_no" name="deliveryNo" style="width:100px">
  39. IFS Shipment No: <input class="easyui-textbox" id="search_ifs_delivery_no" name="ifsDeliveryNo" style="width:100px">
  40. Status: <select class="easyui-combobox" panelHeight="auto" name="status" id="search_delivery_status" style="width:100px">
  41. <option value="ALL">ALL</option>
  42. <option value="Created">Created</option>
  43. <option value="Boxing">Packing</option>
  44. <option value="Boxed">Packed</option>
  45. <option value="Shipped">Shipped</option>
  46. </select>
  47. <a id="queryLink" onclick="searchData()" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  48. &nbsp;&nbsp;&nbsp;
  49. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newSalesDeliveryModal()">New Shipment</a>
  50. </div>
  51. </div>
  52. <!-- 新增出库单 -->
  53. <div id="sales_delivery_modal" class="easyui-dialog" style="width: 380px;display: none;"
  54. data-options="modal:true, onClose: function(){ $('#dg').datagrid('reload')}"
  55. closed="true" buttons="#sales-delivery-buttons">
  56. <form id="sales_delivery_fm" method="post" novalidate style="margin:0;padding:20px 20px">
  57. <div style="margin-bottom:10px; display: none;" >
  58. <input id="id" name="id" class="easyui-textbox" style="display: none;" value="0">
  59. <input id="created_by" name="createdBy" class="easyui-textbox" style="display: none;" value="">
  60. <input id="updated_by" name="updatedBy" class="easyui-textbox" style="display: none;" value="">
  61. </div>
  62. <div style="margin-bottom:10px">
  63. <input id="ifs_delivery_no" name="ifsDeliveryNo" class="easyui-textbox" required="true" label="IFS Shipment No:" data-options="buttonText: 'IFS',onClickButton:getIfsDeliveryOrder" style="width: 100%;">
  64. </div>
  65. <div style="margin-bottom:10px">
  66. <input id="customer_no" name="customerNo" class="easyui-textbox" required="true" label="Customer No:" style="width:100%">
  67. </div>
  68. <div style="margin-bottom:10px">
  69. <input id="customer_name" name="customerName" class="easyui-textbox" required="true" label="Customer Name:" style="width:100%">
  70. </div>
  71. <div style="margin-bottom:10px">
  72. <input id="tracking_no" name="trackingNo" class="easyui-textbox" label="Express Bill No:" style="width:100%">
  73. </div>
  74. <div style="margin-bottom:10px">
  75. <input id="delivery_remark" name="remark" class="easyui-textbox" label="Remak:" style="width:100%">
  76. </div>
  77. </form>
  78. </div>
  79. <div id="sales-delivery-buttons" style="display: none; text-align: center;">
  80. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveSalesDelivery()" style="width:90px">Save</a>
  81. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#sales_delivery_modal').dialog('close')" style="width:90px">Close</a>
  82. </div>
  83. <!-- 发货计划 -->
  84. <div id="sales_delivery_plan" class="easyui-dialog" style="width:600px;display: none;" closed="true" data-options="modal:true" >
  85. <table id="sales_delivery_plan_table" class="easyui-datagrid" style="height:300px; display: none;"
  86. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'POST',
  87. pageSize:50, toolbar:'#sales_delivery_table_buttons'">
  88. <thead>
  89. <tr>
  90. <th data-options="field:'partNo', width:60">Part No</th>
  91. <th data-options="field:'shipQty', width:60">Planned Qty</th>
  92. <th data-options="field:'shippedQty', width:60">Actual Qty</th>
  93. <th data-options="field:'id', width:100, formatter: shipmentPlanAction">Actions</th>
  94. </tr>
  95. </thead>
  96. </table>
  97. </div>
  98. <div id="sales_delivery_table_buttons" style="padding:10px 5px;display: none;">
  99. <div>
  100. <!-- <a id="new_delivery" class="easyui-linkbutton" iconCls="icon-add" onclick="newSalesDeliveryPlanModal()">新增发货计划</a> -->
  101. <a class="easyui-linkbutton" iconCls="icon-add" onclick="importSalesDeliveryPlan()">Import Shipment Plan</a>
  102. <a id="boxed_plan" class="easyui-linkbutton" onclick="preFinishBoxing()">
  103. <span class="glyphicon glyphicon-folder-close"></span>Complete Packing
  104. </a>
  105. </div>
  106. </div>
  107. <div id="operate_sales_delivery_plan" class="easyui-dialog" style="width:500px;display: none;"
  108. closed="true" buttons="#plan-buttons" data-options="modal:true">
  109. <div style="margin-bottom:10px;padding:20px 20px">
  110. <input id="plan_part_no" class="easyui-textbox" required="true" label="Part No:" style="width:100%">
  111. <br/><br>
  112. <input id="plan_ship_qty" class="easyui-numberbox" required="true" label="Qty:" style="width:100%">
  113. </div>
  114. </div>
  115. <div id="plan-buttons" style="display: none; text-align: center;">
  116. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveSalesDeliveryPlan()" style="width:90px">Save</a>
  117. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#operate_sales_delivery_plan').dialog('close')" style="width:90px">Close</a>
  118. </div>
  119. <!-- 库存箱 -->
  120. <div id="stock_box_modal" class="easyui-dialog" style="width: 580px;display: none;" closed="true" data-options="modal:true" >
  121. <table id="stock_box_table" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  122. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true ,
  123. method:'POST', pageSize:20,toolbar:'#stock_box_buttons'">
  124. <thead>
  125. <tr>
  126. <th data-options="field:'boxNo',width:130">Box No</th>
  127. <th data-options="field:'partNo',width:100">Part No</th>
  128. <th data-options="field:'boxQty',width:100">Qty</th>
  129. <th data-options="field:'locationNo',width:80">Location No</th>
  130. <th data-options="field:'labelDate',width:100">Production Date</th>
  131. </tr>
  132. </thead>
  133. </table>
  134. </div>
  135. <div id="stock_box_buttons" style="padding:10px 5px;display: none;">
  136. <div>
  137. <a class="easyui-linkbutton" iconCls="icon-add" onclick="downStockBoxExcel()">Export to Excel</a>
  138. </div>
  139. </div>
  140. <!-- 发货箱 -->
  141. <div id="sales_delivery_box" class="easyui-dialog" style="width:800px;display: none;" closed="true" data-options="modal:true" >
  142. <table id="sales_delivery_box_table" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  143. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true ,
  144. method:'POST', pageSize:20,toolbar:'#sales_delivery_box_buttons'">
  145. <thead>
  146. <tr>
  147. <th data-options="field:'boxNo',width:130">Box No</th>
  148. <th data-options="field:'partNo',width:100">Part No</th>
  149. <th data-options="field:'boxQty',width:100">Qty</th>
  150. <th data-options="field:'status',width:100">Status</th>
  151. <th data-options="field:'id',width:300,formatter: formatBoxAction">Actions</th>
  152. </tr>
  153. </thead>
  154. </table>
  155. </div>
  156. <div id="sales_delivery_box_buttons" style="padding:10px 5px;display: none;">
  157. <div>
  158. <a id="add_box" class="easyui-linkbutton" iconCls="icon-add" onclick="newSalesDeliveryBox()">New Box</a>
  159. <a id="add_box_not_unpack" class="easyui-linkbutton" iconCls="icon-add" onclick="scanStockBoxModal()">Scanning Box</a>
  160. </div>
  161. </div>
  162. <!-- 扫描箱modal -->
  163. <div id="scan_box_modal" class="easyui-dialog" style="width: 600px; display: none;" closed="true" data-options="modal: true, onClose: function(){
  164. $('#sales_delivery_box_table').datagrid('reload')}">
  165. <form id="scan_box_fm" method="post" novalidate style="margin:0; padding: 20px 20px">
  166. <div style="margin-bottom:10px">
  167. <label>Box No:</label>
  168. <input id="scan_box_no" name="boxNo" style="width: 75%; margin-left: 10px;">
  169. </div>
  170. </form>
  171. <table id="scan_box_no_table" class="easyui-datagrid" style="width:100%;height: 200px;">
  172. <thead>
  173. <tr>
  174. <th data-options="field:'sortNo',width: 60, formatter: formatBoxSort">Item No</th>
  175. <th data-options="field:'boxNo',width: 180,editor:'textbox'">Box No</th>
  176. <th data-options="field:'boxQty',width: 100,editor:'textbox'">Qty</th>
  177. <th data-options="field:'id',width: 200, formatter: formatBoxFunction">Actions</th>
  178. </tr>
  179. </thead>
  180. </table>
  181. <!-- 发货计划 -->
  182. <table id="cache_sales_delivery_plan_table" class="easyui-datagrid" style="margin-top: 5px; width:100%;height:200px;display: none;"
  183. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'POST',
  184. pageSize:50,">
  185. <thead>
  186. <tr>
  187. <th data-options="field:'partNo',width:60">Part No</th>
  188. <th data-options="field:'shipQty',width:60">Planned Qty</th>
  189. <th data-options="field:'shippedQty',width:60">Actual Qty</th>
  190. </tr>
  191. </thead>
  192. </table>
  193. </div>
  194. <!-- 扫描卷modal -->
  195. <div id="sales_delivery_roll" class="easyui-dialog" style="width: 600px; display: none;" closed="true" data-options="modal:true">
  196. <form id="sales_delivery_roll_fm" method="post" novalidate style="margin:0; padding: 20px 20px">
  197. <div style="margin-bottom: 0px">
  198. <label>Roll No:</label>
  199. <input id="scan_roll_no" name="rollNo" style="width: 75%; margin-left: 10px;">
  200. </div>
  201. </form>
  202. <table id="scan_roll_table" class="easyui-datagrid" style="width:100%;height: 300px;">
  203. <thead>
  204. <tr>
  205. <th data-options="field:'sortNo',width:60, formatter: formatRollSort">Item No</th>
  206. <th data-options="field:'rollNo',width:180,editor:'textbox'">Roll No</th>
  207. <th data-options="field:'rollQty',width:60,editor:'textbox'">Qty</th>
  208. <th data-options="field:'id',width:200, formatter:formatRollFunction">Actions</th>
  209. </tr>
  210. </thead>
  211. </table>
  212. </div>
  213. <!-- 发运modal -->
  214. <div id="shipment_sales" class="easyui-dialog" style="width: 320px; display: none;" closed="true" data-options="modal:true"
  215. buttons="#shipment-sale-buttons">
  216. <form id="shipment_sales_fm" method="post" novalidate style="margin:0; padding: 20px 20px">
  217. <div style="margin-bottom: 10px">
  218. <label>Express Bill No:</label>
  219. <input id="shipment_no" name="trackingNo" style="margin-left: 10px;">
  220. </div>
  221. </form>
  222. </div>
  223. <div id="shipment-sale-buttons" style="display: none; text-align: center;">
  224. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveShipmentNo()" style="width:90px">Save</a>
  225. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#shipment_sales').dialog('close')" style="width:90px">Close</a>
  226. </div>
  227. <script src='http://127.0.0.1:8000/CLodopfuncs.js'></script>
  228. <!-- <script language="javascript" src="LodopFuncs.js"></script> -->
  229. <script type="text/javascript" src="/js/print/print_label.js"></script>
  230. <script>
  231. //公共参数
  232. var currentRow;//销售出库单
  233. let currentPrinter = ${currentPrinter};
  234. let currentPlanRow;//发运计划
  235. let currentBoxRow;//发运箱row
  236. let currentRollRow;//发运卷
  237. let currentCheckOrderRow;//检验单行
  238. let addSaleFlag;//新增销售发货单标记
  239. let addPlanFlag;//新增发运计划
  240. let scanBoxNoList;
  241. let site = $('#current_site').val();
  242. let username = $('#current_username').val();
  243. $(window).resize(function () {
  244. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 30});
  245. });
  246. $(function () {
  247. $(window).resize();
  248. });
  249. //延时
  250. var delay = (function(){
  251. var timer = 0;
  252. return function(callback, ms){
  253. clearTimeout (timer);
  254. timer = setTimeout(callback, ms);
  255. };
  256. })();
  257. //状态中文翻译
  258. function formatStatusRemark(value, row){
  259. if('Created' == value){
  260. return 'Created';
  261. }else if('Boxing' == value){
  262. return 'Packing';
  263. }else if('Boxed' == value){
  264. return 'Packed';
  265. }else if('Shipped' == value){
  266. return 'Shipped';
  267. }
  268. }
  269. // 销售交货单功能
  270. function formatDeliveryAction(value, row){
  271. //根据状态区分不同的按钮
  272. let status = row.status;
  273. let tags = '';
  274. tags += '<a onclick="stockBoxModal(\''+row.deliveryNo+'\')" class="disabled-underscore">Stock List</a>&nbsp;|&nbsp;';
  275. if('Created' == status){
  276. tags += '<a onclick="editSaleDeliveryModal()" class="disabled-underscore">Edit</a>&nbsp;|&nbsp;';
  277. tags += '<a onclick="preDeleteSalesDelivery(\''+row.deliveryNo+'\')" class="disabled-underscore">Delete</a>&nbsp;|&nbsp;';
  278. }else if('Boxed' == status){
  279. tags += '<a onclick="shipmentModal(\''+row.deliveryNo+'\')" class="disabled-underscore">Final Ship</a>&nbsp;|&nbsp;';
  280. }
  281. tags += '<a onclick="salesDeliveryBoxModal(\''+row.deliveryNo+'\')" class="disabled-underscore">List of Shipped</a>&nbsp;|&nbsp;';
  282. tags += '<a onclick="salesDeliveryPlanModal(\''+row.deliveryNo+'\')" class="disabled-underscore">Shipment Plan</a>&nbsp;|&nbsp;';
  283. return tags;
  284. }
  285. //查询主表的数据
  286. function searchData(){
  287. var dg = $('#dg').datagrid({
  288. queryParams: {
  289. deliveryNo: $('#search_delivery_no').val(),
  290. ifsDeliveryNo: $('#search_ifs_delivery_no').val(),
  291. status: $('#search_delivery_status').val()
  292. }
  293. });
  294. }
  295. //销售交货的网址
  296. let url = '';
  297. //新增出货单的modal
  298. function newSalesDeliveryModal(){
  299. addSalesFlag = 'Y';
  300. $('#id').textbox("setValue", 0);
  301. $('#sales_delivery_modal').dialog('open').dialog('center').dialog('setTitle','New Shipment');
  302. $('#sales_delivery_fm').form('clear');
  303. $('#ifs_delivery_no').textbox('textbox').removeAttr('disabled');
  304. $('#customer_no').textbox('textbox').removeAttr('disabled');
  305. $('#customer_name').textbox('textbox').removeAttr('disabled');
  306. url = '/sales/delivery/addSalesDelivery';
  307. $("#delivery_remark").textbox("setValue", '');
  308. }
  309. //修改销售出库单的数据
  310. function editSaleDeliveryModal(){
  311. addSalesFlag = 'N';
  312. //取到当前的行
  313. delay(function(){
  314. currentRow = $('#dg').datagrid('getSelected');
  315. $('#sales_delivery_modal').dialog('open').dialog('center').dialog('setTitle','New Shipment');
  316. $('#sales_delivery_fm').form('clear');
  317. //加载当前的行数据
  318. $('#sales_delivery_fm').form('load', currentRow);
  319. //禁用一些字段的输入
  320. $('#ifs_delivery_no').textbox('textbox').attr('disabled', 'disabled');
  321. $('#customer_no').textbox('textbox').attr('disabled', 'disabled');
  322. $('#customer_name').textbox('textbox').attr('disabled', 'disabled');
  323. url = '/sales/delivery/editSalesDelivery';
  324. //设置参数
  325. $("#ifs_delivery_no").textbox("setValue", currentRow.ifsDeliveryNo);
  326. $("#delivery_remark").textbox("setValue", currentRow.remark);
  327. }, 500);
  328. }
  329. //保存销售交货的主表信息
  330. function saveSalesDelivery(){
  331. let trackingNo = $.trim($("#tracking_no").val());
  332. let customerNo = $.trim($("#customer_no").val());
  333. let customerName = $.trim($("#customer_name").val());
  334. let ifsDeliveryNo = $.trim($("#ifs_delivery_no").val());
  335. let remark = $.trim($("#delivery_remark").val());
  336. //空值判断
  337. if(null == customerNo || '' == customerNo){
  338. $.messager.alert('error','The customer no should have value!', 'error');
  339. return false;
  340. }
  341. if(null == customerName || '' == customerName){
  342. $.messager.alert('error','The customer name should have value!', 'error');
  343. return false;
  344. }
  345. if(null == ifsDeliveryNo || '' == ifsDeliveryNo){
  346. $.messager.alert('error','The IFS SO No should have value!', 'error');
  347. return false;
  348. }
  349. let postData;
  350. //判断是否新增
  351. if(addSalesFlag == 'N'){
  352. postData = {'deliveryNo': currentRow.deliveryNo, 'ifsDeliveryNo': ifsDeliveryNo, 'customerNo': customerNo,
  353. 'customerName': customerName, 'trackingNo': trackingNo,'remark': remark, 'updatedBy': username};
  354. }else{
  355. postData = {'ifsDeliveryNo': ifsDeliveryNo, 'customerNo': customerNo, 'customerName': customerName,
  356. 'trackingNo': trackingNo, 'remark': remark, 'createdBy': username};
  357. }
  358. //保存或修改数据
  359. //序列化
  360. postData = JSON.stringify(postData);
  361. //post请求类型修改
  362. $.ajaxSetup({
  363. contentType: "application/json;charset=utf-8"});
  364. $.post(url, postData, function(result){
  365. if (result.success){
  366. //刷新主表数据
  367. $('#dg').datagrid('reload');
  368. //隐藏modal
  369. $('#sales_delivery_modal').dialog('close');
  370. } else {
  371. $.messager.alert('error',result.msg, 'error');
  372. }
  373. },'json');
  374. $.ajaxSetup({
  375. contentType: " application/x-www-form-urlencoded"});
  376. }
  377. //删除确认
  378. function preDeleteSalesDelivery(deliveryNo){
  379. $.messager.confirm('Confirm','Are you sure to delete the delivery order: <b>'+deliveryNo+'</b> ?', function(r){
  380. if (r){
  381. deleteSalesDelivery(deliveryNo);
  382. }
  383. });
  384. }
  385. //删除销售交货单
  386. function deleteSalesDelivery(deliveryNo){
  387. let postData = {'deliveryNo': deliveryNo, 'updatedBy': username, 'status': 'Deleted', 'statusCode': -1};
  388. //保存或修改数据
  389. //序列化
  390. postData = JSON.stringify(postData);
  391. //post请求类型修改
  392. $.ajaxSetup({
  393. contentType: "application/json;charset=utf-8"});
  394. $.post('/sales/delivery/deleteSalesDelivery', postData, function(result){
  395. if (result.success){
  396. //刷新主表数据
  397. $('#dg').datagrid('reload');
  398. } else {
  399. $.messager.alert('error',result.msg, 'error');
  400. }
  401. },'json');
  402. $.ajaxSetup({
  403. contentType: " application/x-www-form-urlencoded"});
  404. }
  405. //发运计划
  406. function salesDeliveryPlanModal(deliveryNo){
  407. delay(function(){
  408. currentRow = $('#dg').datagrid('getSelected');
  409. $('#sales_delivery_plan').dialog('open').dialog('center').dialog('setTitle', deliveryNo+'Shipment Plan');
  410. //已经发货的不允许新增和重新导入
  411. let saleStatus = currentRow.status;
  412. if('Created' == saleStatus || 'Boxing' == saleStatus){
  413. $("#new_delivery").linkbutton({"disabled": false});
  414. $("#boxed_plan").linkbutton({"disabled": false});
  415. }else{
  416. $("#new_delivery").linkbutton({"disabled": true});
  417. $("#boxed_plan").linkbutton({"disabled": true});
  418. }
  419. let opts = $('#sales_delivery_plan_table').datagrid('options');
  420. opts.queryParams = {'deliveryNo': deliveryNo};
  421. $("#sales_delivery_plan_table").datagrid({url: "/sales/delivery/getSalesDeliveryPlans",
  422. onLoadSuccess: function(data) {
  423. },
  424. rowStyler: function(index, row){
  425. if (Number(row.shipQty)!=Number(row.shippedQty)){
  426. return 'background-color:#ff534d;font-weight:bold;';
  427. }
  428. }
  429. });
  430. }, 500);
  431. }
  432. let planUrl = '';
  433. //新增发运计划
  434. function newSalesDeliveryPlanModal(){
  435. //设置modal
  436. $('#operate_sales_delivery_plan').dialog('open').dialog('center').dialog('setTitle', 'New Shipment Plan');
  437. //清空数据
  438. $("#plan_part_no").textbox("setValue", '');
  439. $("#plan_ship_qty").textbox("setValue", '');
  440. $("#plan_part_no").textbox({"disabled" : false});
  441. planUrl = '/sales/delivery/newSalesDeliveryPlan';
  442. addPlanFlag = 'Y';
  443. }
  444. //修改发运计划
  445. function editPlanModal(){
  446. delay(function(){
  447. currentPlanRow = $('#sales_delivery_plan_table').datagrid('getSelected');
  448. //设置modal
  449. $('#operate_sales_delivery_plan').dialog('open').dialog('center').dialog('setTitle', 'Edit Shipment Plan');
  450. //清空数据
  451. $("#plan_part_no").textbox("setValue", currentPlanRow.partNo);
  452. $("#plan_ship_qty").textbox("setValue", currentPlanRow.shipQty);
  453. //不允许修改物料编码
  454. $("#plan_part_no").textbox({"disabled" : true});
  455. planUrl = '/sales/delivery/editSalesDeliveryPlan';
  456. addPlanFlag = 'N';
  457. }, 500);
  458. }
  459. //保存发运计划
  460. function saveSalesDeliveryPlan(){
  461. //获取当前的行
  462. currentPlanRow = $('#sales_delivery_plan_table').datagrid('getSelected');
  463. let partNo = $.trim($('#plan_part_no').val());
  464. let shipQty = $.trim($('#plan_ship_qty').val());
  465. let postData;
  466. //区分新增还是修改
  467. if('N' == addPlanFlag){
  468. postData = {'deliveryNo': currentPlanRow.deliveryNo, 'partNo': currentPlanRow.partNo, 'shipQty': shipQty, 'updatedBy': username};
  469. }else{
  470. postData = {'deliveryNo': currentRow.deliveryNo, 'ifsDeliveryNo': currentRow.ifsDeliveryNo, 'partNo': partNo,
  471. 'shipQty': shipQty, 'shippedQty': 0, 'status': 'Created', 'statusCode': 1, 'createdBy': username};
  472. }
  473. //保存或修改数据
  474. //序列化
  475. postData = JSON.stringify(postData);
  476. //post请求类型修改
  477. $.ajaxSetup({
  478. contentType: "application/json;charset=utf-8"});
  479. $.post(planUrl, postData, function(result){
  480. if (result.success){
  481. //关闭模态框
  482. $('#operate_sales_delivery_plan').dialog('close');
  483. //刷新发货计划的数据
  484. $('#sales_delivery_plan_table').datagrid('reload');
  485. } else {
  486. $.messager.alert('error',result.msg, 'error');
  487. }
  488. },'json');
  489. $.ajaxSetup({
  490. contentType: " application/x-www-form-urlencoded"});
  491. }
  492. //发运计划的操作
  493. function shipmentPlanAction(value, row){
  494. //currentRow = $('#dg').datagrid('getSelected');
  495. let status = currentRow.status;
  496. let tags = '';
  497. if('Created' == status || 'Boxing' == status){
  498. tags += '<a onclick="preDeletePlan()" class="disabled-underscore">Delete</a>&nbsp;|&nbsp;';
  499. tags += '<a onclick="editPlanModal()" class="disabled-underscore">Update</a>';
  500. }
  501. return tags;
  502. }
  503. //页面打开关闭选中的箱
  504. $("#sales_delivery_plan").dialog({
  505. onClose: function () {
  506. //清空当前的入库箱数据
  507. currentBoxRow = null;
  508. //刷新订单的列表
  509. $('#dg').datagrid('reload');
  510. }
  511. });
  512. //提示是否删除
  513. function preDeletePlan(){
  514. delay(function(){
  515. $.messager.confirm('Confirm','Are you sure to delete the shipment plan?', function(r){
  516. if (r){
  517. deleteSalesDeliveryPlan();
  518. }
  519. });
  520. }, 500);
  521. }
  522. //删除发运计划
  523. function deleteSalesDeliveryPlan(){
  524. //获取当前的行
  525. currentPlanRow = $('#sales_delivery_plan_table').datagrid('getSelected');
  526. let postData = {'deliveryNo': currentPlanRow.deliveryNo, 'partNo': currentPlanRow.partNo, 'updatedBy': username, 'status': 'Deleted', 'statusCode': -1};
  527. //保存或修改数据
  528. //序列化
  529. postData = JSON.stringify(postData);
  530. //post请求类型修改
  531. $.ajaxSetup({
  532. contentType: "application/json;charset=utf-8"});
  533. $.post('/sales/delivery/deleteSalesDeliveryPlan', postData, function(result){
  534. if (result.success){
  535. //刷新主表数据
  536. $('#sales_delivery_plan_table').datagrid('reload');
  537. } else {
  538. $.messager.alert('error',result.msg, 'error');
  539. }
  540. },'json');
  541. $.ajaxSetup({
  542. contentType: " application/x-www-form-urlencoded"});
  543. }
  544. //查询库存箱的modal
  545. function stockBoxModal(deliveryNo){
  546. delay(function(){
  547. currentRow = $('#dg').datagrid('getSelected');
  548. $('#stock_box_modal').dialog('open').dialog('center').dialog('setTitle', deliveryNo+'List of Stock');
  549. //已经发货的不允许新增和重新导入
  550. let opts = $('#stock_box_table').datagrid('options');
  551. opts.queryParams = {'deliveryNo': deliveryNo};
  552. $("#stock_box_table").datagrid({url: "/sales/delivery/getStockBoxsWithFirstInAndFirstOut",
  553. onLoadSuccess: function(data) {
  554. }
  555. });
  556. }, 500);
  557. }
  558. //下载Excel数据
  559. function downStockBoxExcel(){
  560. let deliveryNo = currentRow.deliveryNo;
  561. let print_url = '/export/sales/downStockBoxExcel?deliveryNo='+deliveryNo;
  562. $("#ifmforprint").attr('src', print_url);
  563. }
  564. //打开发货箱的modal
  565. function salesDeliveryBoxModal(){
  566. delay(function(){
  567. currentRow = $('#dg').datagrid('getSelected');
  568. let deliveryNo = currentRow.deliveryNo;
  569. let opts = $('#sales_delivery_box_table').datagrid('options');
  570. //根据状态判断是否新增箱子
  571. let saleStatus = currentRow.status;
  572. if('Created' == saleStatus || 'Boxing' == saleStatus){
  573. $("#add_box").linkbutton({"disabled": false});
  574. $("#add_box_not_unpack").linkbutton({"disabled": false});
  575. }else if('Boxed' == saleStatus || 'Shipped' == saleStatus){
  576. $("#add_box").linkbutton({"disabled": true});
  577. $("#add_box_not_unpack").linkbutton({"disabled": true});
  578. }
  579. opts.queryParams = {'deliveryNo': deliveryNo};
  580. //设置modal
  581. $('#sales_delivery_box').dialog('open').dialog('center').dialog('setTitle', currentRow.deliveryNo+'List of Boxes!');
  582. $("#sales_delivery_box_table").datagrid({url: "/sales/delivery/getSalesDeliveryBoxs",
  583. onLoadSuccess: function(data) {
  584. }
  585. });
  586. }, 500);
  587. }
  588. //箱的操作放大
  589. function formatBoxAction(value, row){
  590. var tags = "";
  591. if(row.status == 'Created'){
  592. tags += '<a onclick="boxRollModal()" class="disabled-underscore">Scanning Rolls</a>&nbsp;|&nbsp;';
  593. tags += '<a onclick="preDeleteBox(\''+row.boxNo+'\')" class="disabled-underscore">Delete</a>';
  594. }else if(row.status == 'Boxing'){
  595. tags += '<a onclick="boxRollModal()" class="disabled-underscore">Scanning Rolls</a>&nbsp;|&nbsp;';
  596. tags += '<a onclick="preSealingBox(\''+row.boxNo+'\')" class="disabled-underscore">Packed</a>';
  597. }else if(row.status == 'Boxed'){
  598. tags += '<a onclick="boxRollModal(\''+row.boxNo+'\')" class="disabled-underscore">List of Rolls</a>&nbsp;|&nbsp;';
  599. tags += '<a onclick="preDeleteBoxed(\''+row.boxNo+'\',' +'\'table'+'\')" class="disabled-underscore">Delete</a>&nbsp;|&nbsp;';
  600. tags += '<a onclick="printBoxLabel(\''+row.boxNo+'\')" class="disabled-underscore">Print Box Label</a>';
  601. }
  602. return tags;
  603. }
  604. //扫描外箱
  605. function scanStockBoxModal(){
  606. //打开扫描卷的modal
  607. $('#scan_box_modal').dialog('open').dialog('center').dialog('setTitle', 'Scanning Box');
  608. $("#scan_box_no").val("");
  609. //获取焦点
  610. $('#scan_box_no').focus();
  611. //刷新当前箱号表的table
  612. //空集合数据
  613. let cacheData = {
  614. total: 0,
  615. rows:[]
  616. };
  617. $('#scan_box_no_table').datagrid('loadData', cacheData);
  618. //加载发货计划的数据
  619. let opts = $('#cache_sales_delivery_plan_table').datagrid('options');
  620. opts.queryParams = {'deliveryNo': currentRow.deliveryNo};
  621. $("#cache_sales_delivery_plan_table").datagrid({url: "/sales/delivery/getSalesDeliveryPlans",
  622. onLoadSuccess: function(data) {
  623. },
  624. rowStyler: function(index, row){
  625. if (Number(row.shipQty)!=Number(row.shippedQty)){
  626. return 'background-color:#ff534d;font-weight:bold;';
  627. }
  628. }
  629. });
  630. }
  631. /* 格式化箱号序号 */
  632. function formatBoxSort(value, row, index){
  633. let rows = $("#scan_box_no_table").datagrid("getData").rows;
  634. let total = rows.length;
  635. return total - index;
  636. }
  637. /* 添加方法 */
  638. function formatBoxFunction(value, row){
  639. let tags = '';
  640. tags += '<a style="text-decoration:none;" onclick="preDeleteBoxed(\''+row.boxNo+'\',' +'\'cache'+'\')" class="disabled-underscore">Delete</a>';
  641. return tags;
  642. }
  643. //绑定的enter事件
  644. $('#scan_box_modal').bind("keydown", function (e) {
  645. if (e.keyCode == 13) {
  646. let boxNo = $.trim($("#scan_box_no").val());
  647. if(null == boxNo || '' == boxNo){
  648. $.messager.alert('error', 'Please scan box no!', 'error', function(){
  649. $("#scan_box_no").val('');
  650. $("#scan_box_no").focus();
  651. });
  652. return false;
  653. }else{
  654. //处理卷号
  655. // if(!boxNo.includes(';')){
  656. // $.messager.alert('error', '箱码不符合规则!', 'error', function(){
  657. // $("#scan_box_no").val('');
  658. // $("#scan_box_no").focus();
  659. // });
  660. // return false;
  661. // }
  662. //boxNo = processBoxNoData(boxNo);
  663. scanSalesDeliveryBox(boxNo);
  664. return false;
  665. }
  666. }
  667. });
  668. //处理外箱号的方法
  669. function processBoxNoData(boxNo){
  670. let strArray = boxNo.split(';');
  671. return strArray[3];
  672. }
  673. //扫描外箱号
  674. function scanSalesDeliveryBox(boxNo){
  675. delay(function(){
  676. let postData = {'boxNo': boxNo, 'deliveryNo': currentRow.deliveryNo, 'ifsDeliveryNo': currentRow.ifsDeliveryNo,
  677. 'boxQty': 0, 'status': 'Created', 'statusCode': 1, 'createdBy': username};
  678. //保存或修改数据
  679. //序列化
  680. postData = JSON.stringify(postData);
  681. //post请求类型修改
  682. $.ajaxSetup({
  683. contentType: "application/json;charset=utf-8"});
  684. $.post('/sales/delivery/scanSalesDeliveryBox', postData, function(result){
  685. if (result.success){
  686. printBoxLabel(boxNo);
  687. //刷新发货箱的数据
  688. $('#sales_delivery_box_table').datagrid('reload');
  689. let rows = $('#scan_box_no_table').datagrid('getRows');
  690. //从第一行开始加
  691. rows.unshift({"deliveryNo": currentRow.deliveryNo, "boxNo": boxNo, "boxQty": result.boxQty});
  692. $('#scan_box_no_table').datagrid('loadData', rows);
  693. //重新加载表格数据
  694. $("#cache_sales_delivery_plan_table").datagrid('reload');
  695. $("#scan_box_no").val("");
  696. $("#scan_box_no").focus();
  697. // $('#scan_box_modal').dialog('close');
  698. } else {
  699. $.messager.alert('error',result.msg, 'error', function(){
  700. $("#scan_box_no").val("");
  701. $("#scan_box_no").focus();
  702. });
  703. }
  704. },'json');
  705. $.ajaxSetup({
  706. contentType: " application/x-www-form-urlencoded"});
  707. }, 500);
  708. }
  709. //确认删除封箱的出货箱的操作
  710. function preDeleteBoxed(boxNo, sourceMethod){
  711. delay(function(){
  712. //重置缓存箱行
  713. //区分删除的是扫描装箱还是创建装箱
  714. if(sourceMethod == 'cache'){
  715. currentBoxRow = $('#scan_box_no_table').datagrid('getSelected');
  716. }else{
  717. currentBoxRow = $('#sales_delivery_box_table').datagrid('getSelected');
  718. }
  719. $.messager.confirm('Confirm','Are sure to delete the box?', function(r){
  720. if (r){
  721. cancelScanSalesDeliveryBox(sourceMethod);
  722. }
  723. });
  724. }, 500);
  725. }
  726. //删除已经封箱的发货箱
  727. function cancelScanSalesDeliveryBox(sourceMethod){
  728. let postData = {'site': site, 'deliveryNo': currentBoxRow.deliveryNo, 'boxNo': currentBoxRow.boxNo,
  729. 'partNo': currentBoxRow.partNo, 'updatedBy': username, 'status': 'Deleted', 'statusCode': -1};
  730. //转json字符串
  731. postData = JSON.stringify(postData);
  732. //设置请求的类型
  733. $.ajaxSetup({
  734. contentType: "application/json;charset=utf-8"});
  735. $.post('/sales/delivery/cancelScanSalesDeliveryBox', postData,
  736. function(result){
  737. if (result.success){
  738. //区分删除的是扫描装箱还是创建装箱
  739. if(sourceMethod == 'cache'){
  740. let rows = $('#scan_box_no_table').datagrid('getRows');
  741. //删除当前选中的行数据
  742. deleteBoxCacheData(rows, currentBoxRow.boxNo);
  743. //刷新发货箱的数据
  744. $('#scan_box_no_table').datagrid('loadData', rows);
  745. //重新加载表格数据
  746. $("#cache_sales_delivery_plan_table").datagrid('reload');
  747. //获取焦点继续扫描
  748. $('#scan_box_no').focus();
  749. }else{
  750. //刷新发货箱的数据
  751. $('#sales_delivery_box_table').datagrid('reload');
  752. }
  753. } else {
  754. $.messager.alert('error',result.msg, 'error');
  755. }
  756. },'json');
  757. //设置请求的类型
  758. $.ajaxSetup({
  759. contentType: " application/x-www-form-urlencoded"});
  760. }
  761. //新建箱子的方法
  762. function newSalesDeliveryBox(){
  763. delay(function(){
  764. let postData = {'deliveryNo': currentRow.deliveryNo, 'ifsDeliveryNo': currentRow.ifsDeliveryNo, 'partNo': '',
  765. 'boxQty': 0, 'status': 'Created', 'statusCode': 1, 'createdBy': username};
  766. //保存或修改数据
  767. //序列化
  768. postData = JSON.stringify(postData);
  769. //post请求类型修改
  770. $.ajaxSetup({
  771. contentType: "application/json;charset=utf-8"});
  772. $.post('/sales/delivery/newSalesDeliveryBox', postData, function(result){
  773. if (result.success){
  774. //刷新发货箱的数据
  775. $('#sales_delivery_box_table').datagrid('reload');
  776. } else {
  777. $.messager.alert('error',result.msg, 'error');
  778. }
  779. },'json');
  780. $.ajaxSetup({
  781. contentType: " application/x-www-form-urlencoded"});
  782. }, 500);
  783. }
  784. //确认删除箱的操作
  785. function preDeleteBox(boxNo, sourceMethod){
  786. delay(function(){
  787. //重置缓存箱行
  788. currentBoxRow = $('#sales_delivery_box_table').datagrid('getSelected');
  789. $.messager.confirm('Confirm','Are sure to delete the box?', function(r){
  790. if (r){
  791. deleteSalesDeliveryBox();
  792. }
  793. });
  794. }, 500);
  795. }
  796. //删除发货箱
  797. function deleteSalesDeliveryBox(sourceMethod){
  798. let postData = {'site': site, 'deliveryNo': currentBoxRow.deliveryNo, 'boxNo': currentBoxRow.boxNo,
  799. 'updatedBy': username, 'status': 'Deleted', 'statusCode': -1};
  800. //转json字符串
  801. postData = JSON.stringify(postData);
  802. //设置请求的类型
  803. $.ajaxSetup({
  804. contentType: "application/json;charset=utf-8"});
  805. $.post('/sales/delivery/deleteSalesDeliveryBox', postData,
  806. function(result){
  807. if (result.success){
  808. //刷新发货箱的数据
  809. $('#sales_delivery_box_table').datagrid('reload');
  810. } else {
  811. $.messager.alert('error',result.msg, 'error');
  812. }
  813. },'json');
  814. //设置请求的类型
  815. $.ajaxSetup({
  816. contentType: " application/x-www-form-urlencoded"});
  817. }
  818. //删除当前箱的数据
  819. function deleteBoxCacheData(boxRows, boxNo){
  820. //循环删除缓存中的数据
  821. for(let i = 0; i < boxRows.length; i++){
  822. let temBoxNo = boxRows[i].boxNo;
  823. //如果箱号相同删掉数据
  824. if(temBoxNo == boxNo){
  825. boxRows.splice(i, 1);
  826. }
  827. }
  828. }
  829. //扫码装箱页面
  830. function boxRollModal(){
  831. delay(function(){
  832. currentBoxRow = $('#sales_delivery_box_table').datagrid('getSelected');
  833. let boxNo = currentBoxRow.boxNo;
  834. let opts = $('#scan_roll_table').datagrid('options');
  835. opts.queryParams = {'deliveryNo': currentBoxRow.deliveryNo, 'boxNo': boxNo};
  836. //根据箱子的状态判断是否封箱
  837. let boxStatus = currentBoxRow.status;
  838. if('Boxed' == boxStatus){
  839. //封箱去掉
  840. $("#close_box").linkbutton({"disabled": true});
  841. //隐藏扫描卷的功能
  842. $('#sales_delivery_roll_fm').hide();
  843. }else{
  844. $("#close_box").linkbutton({"disabled": false});
  845. //隐藏扫描卷的功能
  846. $('#sales_delivery_roll_fm').show();
  847. }
  848. //设置modal
  849. $('#sales_delivery_roll').dialog('open').dialog('center').dialog('setTitle', boxNo+'List of Boxes!');
  850. //获取焦点
  851. $('#scan_roll_no').focus();
  852. $("#scan_roll_table").datagrid({url: "/sales/delivery/getSalesDeliveryRolls",
  853. onLoadSuccess: function(data) {
  854. }
  855. });
  856. }, 500);
  857. }
  858. //表格序号
  859. function formatRollSort(value, row, index){
  860. let rows = $("#scan_roll_table").datagrid("getData").rows;
  861. let total = rows.length;
  862. return total - index;
  863. }
  864. //pack列表的功能
  865. function formatRollFunction(value, row){
  866. let boxStatus = currentBoxRow.status;
  867. let tags = '';
  868. //没有封包的时候才可以删除
  869. if('Boxed' != boxStatus){
  870. tags += '<a style="text-decoration:none;" onclick="preCancelScanRollNo(\''+row.rollNo+'\')">Delete</a>';
  871. }
  872. return tags;
  873. }
  874. //页面打开关闭选中的箱
  875. $("#sales_delivery_roll").dialog({
  876. onClose: function () {
  877. //清空当前的入库箱数据
  878. currentBoxRow = null;
  879. //刷新订单的列表
  880. $('#sales_delivery_box_table').datagrid('reload');
  881. },
  882. onOpen: function () {
  883. $('#scan_roll_no').val('');
  884. $('#scan_roll_no').focus();
  885. }
  886. });
  887. //绑定的enter事件
  888. $('#sales_delivery_roll').bind("keydown", function (e) {
  889. if (e.keyCode == 13) {
  890. let rollNo = $.trim($("#scan_roll_no").val());
  891. if(null == rollNo || '' == rollNo){
  892. $.messager.alert('error', 'Please scan roll no!', 'error');
  893. $("#scan_roll_no").focus();
  894. return false;
  895. }else{
  896. //rollNo = processRollNoData(rollNo);
  897. scanRollNo(rollNo);
  898. return false;
  899. }
  900. }
  901. });
  902. //处理卷号的方法
  903. function processRollNoData(rollNo){
  904. let strArray = rollNo.split(';');
  905. return strArray[3];
  906. }
  907. //扫描卷
  908. function scanRollNo(rollNo){
  909. let postData = {'deliveryNo': currentRow.deliveryNo, 'ifsDeliveryNo': currentRow.ifsDeliveryNo,
  910. 'boxNo': currentBoxRow.boxNo, 'rollNo': rollNo, "createdBy": username};
  911. //转json字符串
  912. postData = JSON.stringify(postData);
  913. //设置请求的类型
  914. $.ajaxSetup({
  915. contentType: "application/json;charset=utf-8"});
  916. $.post('/sales/delivery/scanStockRoll', postData,
  917. function(result){
  918. if (result.success){
  919. //获取当前的行数
  920. //判断是否触发封箱
  921. if(result.sealFlag){
  922. sealingSalesDeliveryBox(currentBoxRow.boxNo);
  923. }
  924. $('#scan_roll_table').datagrid('reload');
  925. $('#scan_roll_no').val('');
  926. $("#scan_roll_no").focus();
  927. } else {
  928. $.messager.alert('error',result.msg, 'error', function(){
  929. //自动获取焦点
  930. $('#scan_roll_no').val('');
  931. $("#scan_roll_no").focus();
  932. });
  933. }
  934. },'json');
  935. //设置请求的类型
  936. $.ajaxSetup({
  937. contentType: " application/x-www-form-urlencoded"});
  938. }
  939. //准备取消扫描卷
  940. function preCancelScanRollNo(rollNo){
  941. delay(function(){
  942. //重置缓存箱行
  943. currentRollRow = $('#scan_roll_table').datagrid('getSelected');
  944. $.messager.confirm('Confirm','Are you sure to delete the roll '+rollNo+'?', function(r){
  945. if (r){
  946. cancelScanRollNo(rollNo);
  947. }
  948. });
  949. }, 500);
  950. }
  951. //取消扫描卷
  952. function cancelScanRollNo(rollNo){
  953. let postData = {'deliveryNo': currentRollRow.deliveryNo, 'boxNo': currentRollRow.boxNo, 'rollNo': rollNo,
  954. 'updatedBy': username, 'status': 'Deleted', 'statusCode': -1};
  955. //转json字符串
  956. postData = JSON.stringify(postData);
  957. //设置请求的类型
  958. $.ajaxSetup({
  959. contentType: "application/json;charset=utf-8"});
  960. $.post('/sales/delivery/cancelScanStockRoll', postData,
  961. function(result){
  962. if (result.success){
  963. //获取当前的行数
  964. $('#scan_roll_table').datagrid('reload');
  965. $('#scan_roll_no').val('');
  966. $("#scan_roll_no").focus();
  967. } else {
  968. $.messager.alert('error',result.msg, 'error', function(){
  969. //自动获取焦点
  970. $('#scan_roll_no').val('');
  971. $("#scan_roll_no").focus();
  972. });
  973. }
  974. },'json');
  975. //设置请求的类型
  976. $.ajaxSetup({
  977. contentType: " application/x-www-form-urlencoded"});
  978. }
  979. //确认封箱的操作
  980. function preSealingBox(boxNo){
  981. delay(function(){
  982. //重置缓存箱行
  983. currentBoxRow = $('#sales_delivery_box_table').datagrid('getSelected');
  984. $.messager.confirm('Confirm','Are you sure to complete packing?', function(r){
  985. if (r){
  986. sealingSalesDeliveryBox(boxNo);
  987. }
  988. });
  989. }, 500);
  990. }
  991. //封箱操作
  992. function sealingSalesDeliveryBox(boxNo){
  993. //重置缓存箱行
  994. currentBoxRow = $('#sales_delivery_box_table').datagrid('getSelected');
  995. let postData = {'deliveryNo': currentBoxRow.deliveryNo, 'boxNo': boxNo, 'updatedBy': username, 'status': 'Boxed', 'statusCode': 3};
  996. //转json字符串
  997. postData = JSON.stringify(postData);
  998. //设置请求的类型
  999. $.ajaxSetup({
  1000. contentType: "application/json;charset=utf-8"});
  1001. $.post('/sales/delivery/sealingSalesDeliveryBox', postData,
  1002. function(result){
  1003. if (result.success){
  1004. //先打印标签
  1005. printBoxLabel(boxNo);
  1006. //刷新发货箱的数据
  1007. $('#sales_delivery_box_table').datagrid('reload');
  1008. //隐藏modal
  1009. $('#sales_delivery_roll').dialog('close');
  1010. } else {
  1011. $.messager.alert('error',result.msg, 'error');
  1012. }
  1013. },'json');
  1014. //设置请求的类型
  1015. $.ajaxSetup({
  1016. contentType: " application/x-www-form-urlencoded"});
  1017. }
  1018. //打印外箱标签
  1019. function printBoxLabel(boxNo){
  1020. delay(function(){
  1021. // if('cache' == cacheFlag){
  1022. // //重置缓存箱行
  1023. // currentBoxRow = $('#sales_delivery_box_table').datagrid('getSelected');
  1024. // }
  1025. // let postData = {'deliveryNo': currentBoxRow.deliveryNo, 'boxNo': currentBoxRow.boxNo};
  1026. // console.log(postData)
  1027. /* 缓存打印信息 */
  1028. // $.get('/print/box/'+postData.boxNo,
  1029. // function(result){
  1030. // if (result.success){
  1031. // $('#pack_dlg_table').datagrid('reload');
  1032. // //调用打印的方法打印标签
  1033. // printOutBoxLabel(JSON.parse(result.printData), currentPrinter);
  1034. // } else {
  1035. // $.messager.alert('error',result.msg, 'error');
  1036. // }
  1037. // });//临时调用的
  1038. $("#ifmforprint").attr('src', "/aoi/box/" + boxNo );
  1039. }, 500);
  1040. }
  1041. //准备完成装箱
  1042. function preFinishBoxing(){
  1043. delay(function(){
  1044. //重置缓存行
  1045. currentRow = $('#dg').datagrid('getSelected');
  1046. $.messager.confirm('Confirm','Are you sure to complete packing'+currentRow.deliveryNo+'?', function(r){
  1047. if (r){
  1048. finishBoxing();
  1049. }
  1050. });
  1051. }, 500);
  1052. }
  1053. //完成装箱
  1054. function finishBoxing(){
  1055. currentRow = $('#dg').datagrid('getSelected');
  1056. let postData = {'deliveryNo': currentRow.deliveryNo, 'updatedBy': username, 'status': 'Boxed', 'status_code': 3};
  1057. //转json字符串
  1058. postData = JSON.stringify(postData);
  1059. //设置请求的类型
  1060. $.ajaxSetup({
  1061. contentType: "application/json;charset=utf-8"});
  1062. $.post('/sales/delivery/finishBoxing', postData,
  1063. function(result){
  1064. if (result.success){
  1065. //关闭modal
  1066. $('#sales_delivery_plan').dialog('close');
  1067. //刷新table
  1068. $('#sales_delivery_plan_table').datagrid('reload');
  1069. } else {
  1070. $.messager.alert('error',result.msg, 'error');
  1071. }
  1072. },'json');
  1073. //设置请求的类型
  1074. $.ajaxSetup({
  1075. contentType: " application/x-www-form-urlencoded"});
  1076. }
  1077. //发货信息
  1078. function shipmentModal(deliveryNo){
  1079. //重置缓存行
  1080. currentRow = $('#dg').datagrid('getSelected');
  1081. $('#shipment_sales').dialog('open').dialog('center').dialog('setTitle', deliveryNo+' Inspection Info!');
  1082. }
  1083. //保存快递单号行
  1084. function saveShipmentNo(){
  1085. currentRow = $('#dg').datagrid('getSelected');
  1086. let trackingNo = $('#shipment_no').val();
  1087. let postData = {'deliveryNo': currentRow.deliveryNo, 'trackingNo': trackingNo, 'remark': 'Shipped',
  1088. 'updatedBy': username, 'status': 'Shipped', 'statusCode': 5};
  1089. //保存或修改数据
  1090. //序列化
  1091. postData = JSON.stringify(postData);
  1092. //post请求类型修改
  1093. $.ajaxSetup({
  1094. contentType: "application/json;charset=utf-8"});
  1095. $.post('/sales/delivery/saveTrackingNo', postData, function(result){
  1096. if (result.success){
  1097. //刷新主表数据
  1098. $('#dg').datagrid('reload');
  1099. //隐藏modal
  1100. $('#shipment_sales').dialog('close');
  1101. } else {
  1102. $.messager.alert('error',result.msg, 'error');
  1103. }
  1104. },'json');
  1105. $.ajaxSetup({
  1106. contentType: " application/x-www-form-urlencoded"});
  1107. }
  1108. //下载Excel数据
  1109. function downSalesDeliveryExcel(deliveryNo){
  1110. let print_url = '/export/sales/downSalesDeliveryExcel?deliveryNo='+deliveryNo;
  1111. $("#ifmforprint").attr('src', print_url);
  1112. }
  1113. //获取ifs出货单得信息
  1114. function getIfsDeliveryOrder(){
  1115. var ifsDeliveryNo = $("#ifs_delivery_no").val();
  1116. if (ifsDeliveryNo != ""){
  1117. $.post("/sales/delivery/getIfsDeliveryOrder", {ifsDeliveryNo: ifsDeliveryNo}, function (data) {
  1118. if(data.success){
  1119. $('#customer_no').textbox("setValue", data.customerNo);
  1120. $('#customer_name').textbox("setValue", data.customerName);
  1121. }else{
  1122. $.messager.alert('Warning', data.msg, 'warning');
  1123. }
  1124. })
  1125. }
  1126. }
  1127. //导入发货计划
  1128. function importSalesDeliveryPlan(){
  1129. delay(function(){
  1130. currentRow = $('#dg').datagrid('getSelected');
  1131. let requestParam = {'ifsDeliveryNo': currentRow.ifsDeliveryNo, 'deliveryNo': currentRow.deliveryNo};
  1132. $.post("/sales/delivery/importSalesDeliveryPlan", requestParam, function (data) {
  1133. if(data.success){
  1134. //重新加载表格数据
  1135. $.messager.alert('Warning', data.msg, 'warning');
  1136. $("sales_delivery_plan_table").datagrid('reload');
  1137. }else{
  1138. $.messager.alert('Warning', data.msg, 'warning');
  1139. }
  1140. })
  1141. }, 500);
  1142. }
  1143. </script>
  1144. </@master.layout>