outAdd.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>新增退库单</title>
  6. <link href="/css/base.css" rel="stylesheet">
  7. <link href="/css/ims/ims.css" rel="stylesheet">
  8. <link rel="stylesheet" type="text/css" href="/css/ims/bootstrap.min.css"/>
  9. <link rel="stylesheet" type="text/css" href="/css/ims/ace.min.css"/>
  10. <link rel="stylesheet" type="text/css" href="/css/ims/jquery.datetimepicker.css"/>
  11. <style>
  12. .ims-box {
  13. margin: 20px;
  14. }
  15. .screen {
  16. padding-left: 20px;
  17. height: 44px;
  18. line-height: 44px;
  19. background-color: #eff4fa;
  20. }
  21. .screen li {
  22. float: left;
  23. margin-right: 65px;
  24. }
  25. .bg-d9bf6e {
  26. margin-left: 5px;
  27. padding: 0 20px;
  28. color: #fff;
  29. background-color: #d9bf6e;
  30. }
  31. .list {
  32. padding: 0 40px;
  33. /*margin-top: 40px;*/
  34. overflow: hidden;
  35. }
  36. .list h2 {
  37. line-height: 30px;
  38. font-size: 14px;
  39. }
  40. .list .student-list_box {
  41. width: 300px;
  42. }
  43. .list .student-list_box > ul {
  44. height: 260px;
  45. overflow: auto;
  46. padding: 20px;
  47. background-color: #eef3ff;
  48. }
  49. .list .student-list_box li {
  50. line-height: 30px;
  51. cursor: pointer;
  52. }
  53. .list .student-selected_box {
  54. margin-left: 60px;
  55. }
  56. .list .student-list {
  57. display: none;
  58. margin-left: 20px;
  59. }
  60. .list .student-list li.active .btn-select_all {
  61. display: inline-block;
  62. }
  63. .list .student-list span {
  64. cursor: pointer;
  65. }
  66. .list .btn-select_all {
  67. margin-left: 84px;
  68. color: #2977ff;
  69. }
  70. .student-name_box li {
  71. position: relative;
  72. margin-left: 28px;
  73. line-height: 30px;
  74. }
  75. .student-name_box input {
  76. position: absolute;
  77. left: 155px;
  78. top: 8px;
  79. }
  80. .btn-select_all,
  81. .student-name_box {
  82. display: none;
  83. }
  84. .student-selected {
  85. width: 320px;
  86. height: 220px;
  87. overflow: auto;
  88. }
  89. .student-selected li {
  90. float: left;
  91. margin-right: 24px;
  92. margin-bottom: 12px;
  93. height: 26px;
  94. line-height: 26px;
  95. text-indent: 20px;
  96. background-color: #f2f2f2;
  97. }
  98. .student-selected .btn-delete {
  99. float: right;
  100. margin-right: 20px;
  101. color: red;
  102. cursor: pointer;
  103. }
  104. .btn-confirm_purchase {
  105. display: block;
  106. margin: 0 auto;
  107. margin-top: 100px;
  108. margin-bottom: 50px;
  109. width: 430px;
  110. line-height: 54px;
  111. color: #fff;
  112. font-family: PingFangSC-Regular, "PingFang SC";
  113. font-weight: 400;
  114. font-style: normal;
  115. font-size: 20px;
  116. text-align: center;
  117. background-color: #2977ff;
  118. cursor: pointer;
  119. }
  120. #imgPreview {
  121. display: inline-block;
  122. margin-top: 12px;
  123. }
  124. #imgPreview > img {
  125. max-width: 100px;
  126. max-height: 100px;
  127. margin-right: 5px;
  128. }
  129. .layui-layer-btn .layui-layer-btn0 {
  130. border-color: #2977ff !important;
  131. background-color: #2977ff !important;
  132. color: #fff;
  133. }
  134. .stop-layer-box, .resubmit-layer-box, .delete-layer-box {
  135. line-height: 140px;
  136. text-align: center;
  137. }
  138. .table-center th,.table-center td{text-align:center;}
  139. .table-center .diy_select{float:none;display:inline-block;}
  140. .out-count-div{display:inline-block;}
  141. .out-count-div a{display:inline-block;width:20px;height:20px;text-align:center;line-height:20px; background:#999;color:#fff;cursor:pointer}
  142. .out-count-div a:hover{background:#666;}
  143. .out-count-div span{margin-left:10px;}
  144. .hidden{display: none}
  145. .search-item{
  146. border-color: #2977ff !important;
  147. background-color: #2977ff !important;
  148. color: #fff;
  149. height: 28px;
  150. line-height: 28px;
  151. padding: 0 15px;
  152. background-color: #fff;
  153. border-radius: 2px;
  154. font-weight: 400;
  155. cursor: pointer;
  156. text-decoration: none;
  157. display: inline-block;
  158. }
  159. </style>
  160. </head>
  161. <body>
  162. <h3 class="sale-title">退库单</h3>
  163. <input type="hidden" name="oldOrderId" id="oldOrderId" value="0">
  164. <div class="sale-table">
  165. <table width="100%">
  166. <tr>
  167. <th><em class="red">*</em>出库单标题</th>
  168. <!-- <td colspan="3">-->
  169. <!-- <input type="text" style="width:100%;" placeholder="请输入标题" name="outTitle" value="--><?php //echo isset($pmData['inTitle'])?$pmData['inTitle']:'';?><!--">-->
  170. <!-- </td> -->
  171. <td colspan="3"><input type="text" readonly style="width:100%;" name="outTitle" value="<?php echo $schoolName.'-'.$coachName.'的退库单';?>"></td>
  172. </td>
  173. </tr>
  174. <tr>
  175. <th><em class="red">*</em>退库人</th>
  176. <td><?php echo $coachName;?></td>
  177. <td></td>
  178. <td></td>
  179. </tr>
  180. <tr>
  181. <th>退库所在仓库</th>
  182. <td><?php echo $schoolName;?></td>
  183. <th><em class="red">*</em>领用日期</th>
  184. <td>
  185. <input id="outTimet" readonly type="text" style="width:100%;" placeholder="请输入出库日期" name="out_date" value="<?php echo isset($pmData['inDate'])?date('Y-m-d',strtotime($pmData['inDate'])):'';?>">
  186. </td>
  187. </tr>
  188. <tr>
  189. <th><em class="red">*</em>退库品目类型</th>
  190. <td><input type="radio" name="itemType" value="2" <?php if($itemType == 2)echo "checked='checked'";?>>产成品<input type="radio" name="itemType" value="3" style="margin-left: 60px;" <?php if($itemType == 3)echo "checked='checked'";?>>低值易耗品</td>
  191. </tr>
  192. <tr>
  193. <th>退库说明</th>
  194. <td>
  195. <textarea rows="5" cols="50" class="use-explain" ><?php echo isset($pmData['remark'])?$pmData['remark']:'';?></textarea>
  196. </td>
  197. <td></td>
  198. <td></td>
  199. </tr>
  200. </table>
  201. <div>&nbsp;</div>
  202. <div style="margin-bottom:5px; font-size:18px;"><button type="button" class="select-item label-primary-s bth-s" style="margin-bottom: 5px">选择品目</button></div>
  203. <table width="100%" class="table-center">
  204. <tr class="item-out-list">
  205. <th>品目名称</th>
  206. <th>领用单号</th>
  207. <th>可退库数量</th>
  208. <th>退库数量</th>
  209. <th>操作</th>
  210. </tr>
  211. <?php if(isset($pmData['itemList']) && $pmData['itemList']):?>
  212. <?php foreach ($pmData['itemList'] as $v):?>
  213. <tr>
  214. <td>
  215. <?php echo $v['itemName'];?>
  216. <input type="hidden" name="select-itemId-outId" value="<?php echo $v['itemId'].'_'.$v['outId'];?>"/>
  217. </td>
  218. <td><?php echo $v['outCode'];?></td>
  219. <td class="item-num"><?php echo $v['validNum'];?></td>
  220. <td>
  221. <div class="out-count-div">
  222. <a class="reduce-out">-</a>
  223. <input type="text" name="out_stock_num" num="<?php echo $v['validNum'];?>" value="<?php echo isset($v['num']) ? $v['num'] : 1;?>" itmeName="<?php echo $v['itemName'];?>" id="<?php echo $v['itemId'].'_'.$v['outId'];?>"/>
  224. <a class="add-out">+</a>
  225. </div>
  226. </td>
  227. <td><a class="remove-list">移除</a></td>
  228. </tr>
  229. <?php endforeach;?>
  230. <?php endif;?>
  231. </table>
  232. <div style="margin:10px 0 20px;"></div>
  233. <div>&nbsp;</div>
  234. <!-- <div style="margin-bottom:5px; font-size:18px;">发放销售订单
  235. <span style="font-size: 12px;padding-left:20px;">指定领用的学生所在的销售订单,每次只能指定一个订单</span>
  236. </div>
  237. <table width="100%" class="table-center">
  238. <tr >
  239. <th>销售订单号</th>
  240. <th>商品</th>
  241. <th>商品配套数</th>
  242. <th>实际订购人数</th>
  243. <th>实际应发数</th>
  244. <th>待审核发放数</th>
  245. <th>已发放数</th>
  246. <th>本次发放数</th>
  247. </tr>
  248. <tbody class="item-order-out-list">
  249. </tbody>
  250. </table>
  251. -->
  252. <div class="sale-submit">
  253. <button type="button" class="label-primary-cancle">取消</button>
  254. <button type="button" class="label-primary-s submit-bth bth-s">提交</button>
  255. </div>
  256. <!-- 关联正式订单弹层 -->
  257. <div class="layer-relate rel-order-layer">
  258. <div class="layer-filter">
  259. <input type="text" name="outCode" placeholder="领用单编号" style="height:28px">
  260. <select name="itemId">
  261. <option value="0">品目名称</option>
  262. <?php if(isset($itemList) && $itemList):?>
  263. <?php foreach ($itemList as $key => $value): ?>
  264. <option value="<?php echo $value['itemId']; ?>"><?php echo $value['itemName']; ?></option>
  265. <?php endforeach; ?>
  266. <?php endif;?>
  267. </select>
  268. <a class="search-item">查询</a>
  269. </div>
  270. <table class="order-table table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
  271. style="font-size:12px">
  272. <thead>
  273. <tr>
  274. <th>选择</th>
  275. <th>领用单号</th>
  276. <th>品目名称</th>
  277. <th>可退库数量</th>
  278. </tr>
  279. </thead>
  280. <tbody>
  281. </tbody>
  282. </table>
  283. <div class="col-sm-12">
  284. <ul class="pagination">
  285. </ul>
  286. </div>
  287. </div>
  288. <script src="/js/productset/jquery.min.js"></script>
  289. <script src="/js/ims/jquery.datetimepicker.js"></script>
  290. <script src="/js/ims/layer/layer.js"></script>
  291. <script src="/js/ims/xsgl.js"></script>
  292. <!-- --><?php //include_once '_useDetail.php'?>
  293. <script>
  294. $(document).ready(function () {
  295. $('#outTimet').datetimepicker({
  296. format: "Y-m-d", //格式化日期
  297. timepicker: false //关闭时间选项
  298. });
  299. });
  300. <?php if (isset($pmData) && $pmData):?>
  301. //编辑页面数据初始化
  302. var D = "<?php echo date('Y-m-d', strtotime($pmData['inDate']));?>";
  303. $("#outTimet").val(D);
  304. <?php else:?>
  305. //新增页面数据初始化
  306. var date = new Date;
  307. var year = date.getFullYear();
  308. var month = date.getMonth() + 1;
  309. var day = date.getDate(); //获取当前日(1-31)
  310. month = month > 10 ? month : "0" + month;
  311. day = day > 10 ? day : "0" + day;
  312. var maxD = year + '-' + month + '-' + day;
  313. $("#outTimet").attr("value", maxD);
  314. <?php endif;?>
  315. $(function(){
  316. //选择品目
  317. $(".select-item").click(function () {
  318. var page = 1;
  319. selectItem(page,1);
  320. });
  321. function selectItem(page,open_type) {
  322. var itemOutIds = [];
  323. $(".select-itme-data").each(function () {
  324. itemOutIds.push($(this).attr('itemId')+'_'+$(this).attr('outId'));
  325. });
  326. var listData = [];
  327. var listOrderData = [];
  328. var itemType = $("input[name='itemType']:checked").val();
  329. var outCode = $("input[name='outCode']").val();
  330. var itemId = $("select[name='itemId']").val();
  331. // alert(itemId);return false;
  332. $.ajax({
  333. type: 'post',
  334. url: "<?php echo $this->createUrl('imsStore/stockChioceItme');?>",
  335. data: {page:page,itemOutIds:itemOutIds,itemType:itemType,outCode:outCode,itemId:itemId},
  336. dataType: 'json',
  337. success: function (res) {
  338. if (res.status) {
  339. //列表已存在的不显示
  340. var hasItemOut = [];
  341. $("input[name='select-itemId-outId']").each(function () {
  342. hasItemOut.push($(this).val());
  343. });
  344. var html = '';
  345. for (var i = 0; i < res.data.length; i++) {
  346. var item = res.data[i];
  347. if($.inArray(item['itemId']+'_'+item['outId'],hasItemOut) >= 0){
  348. continue;
  349. }
  350. var _btn = '<div class="out-count-div">\n' +
  351. ' <a class="reduce-out">-</a>\n' +
  352. ' <input type="text" name="out_stock_num" num="'+item['validNum']+'" value="<?php echo isset($stockNum) ? $stockNum : 1;?>" itmeName="'+item['itemName']+'" id="'+item['itemId']+'_'+item['outId']+'"/>\n' +
  353. ' <a class="add-out">+</a>\n' +
  354. ' </div>';
  355. listData[i] = '<tr><td>'+item['itemName']+'<input type="hidden" name="select-itemId-outId" value="'+item['itemId']+'_'+item['outId']+'"/></td><td>' + item['outCode'] + '</td><td class="valid-num" >'+item['validNum']+'</td><td>'+_btn+'</td><td><a class="remove-list">移除</a></td></tr>';
  356. temp='';
  357. temp+='<tr>';
  358. temp += '<td>' + item['orderId'] + '</td>';
  359. temp += '<td>' + item['goodsName'] + '</td>';
  360. temp += '<td>' + item['sendNo'] + '</td>';
  361. temp += '<td>' + item['quantity'] + '</td>';
  362. temp += '<td>' + item['sendNo']*item['quantity'] + '</td>';
  363. temp += '<td>' + item['waitCheckNo'] + '</td>';
  364. temp += '<td>' + item['saleNo'] + '</td>';
  365. temp += '<td></td>';
  366. temp+='</tr>';
  367. listOrderData[i] = temp;
  368. // listData = '';
  369. html += '<tr>';
  370. html += '<td><label class="checkbox-inline">';
  371. html += '<input type="checkbox" name="select-tr" value="'+i+'"/>';
  372. html += '</label></td>';
  373. html += '<td>' + item['outCode'] + '</td>';
  374. html += '<td>' + item['itemName'] + '</td>';
  375. html += '<td>' + item['validNum'] + '</td>';
  376. html += '</tr>';
  377. }
  378. // setPage(res.data);
  379. } else {
  380. layer.alert(res.msg, {icon: 7});
  381. return false;
  382. }
  383. $('.order-table tbody').html(html);
  384. },
  385. error: function () {
  386. layer.msg('品目列表获取失败!');
  387. return false;
  388. }
  389. })
  390. if(open_type == 1){
  391. layer.open({
  392. type: 1,
  393. title: '选择品目',
  394. btn: ['确定','取消'],
  395. area: ['810px', '420px'], //宽高
  396. btnAlign: 'c',
  397. content: $('.rel-order-layer'),
  398. yes: function (index, layero) {
  399. var listStr = '',listOrderStr='';
  400. // console.log($("input[name='select-tr']:checked"));
  401. $("input[name='select-tr']:checked").each(function () {
  402. var index = $(this).val();
  403. if(!(typeof(listData[index]) == 'undefined')){
  404. listStr += listData[index];
  405. }
  406. if(!(typeof(listOrderData[index]) == 'undefined')){
  407. listOrderStr += listOrderData[index];
  408. }
  409. });
  410. $(".item-out-list").after(listStr);
  411. $(".item-order-out-list").html(listOrderStr);
  412. layer.closeAll();
  413. }
  414. });
  415. }
  416. return false;
  417. }
  418. //提交数据
  419. $(".submit-bth").click(function () {
  420. var outId = "<?php echo isset($_GET['outId'])?$_GET['outId']:0;?>";
  421. var flag = true;
  422. if (flag){
  423. flag = false;
  424. //验证数据
  425. var outTitle = $.trim($("input[name='outTitle']").val());
  426. if (outTitle.length == 0) {
  427. showMsg('标题名称不能为空!');
  428. return false;
  429. } else if (outTitle.length > 49) {
  430. showMsg('标题名称不能超过50个字符!');
  431. return false;
  432. }
  433. var outDate = $.trim($("input[name='out_date']").val());
  434. if (!outDate) {
  435. showMsg('退库日期不正确!');
  436. return false;
  437. }
  438. if (!checkDate(outDate)) {
  439. showMsg('退库日期不正确!');
  440. return false;
  441. }
  442. //领用说明
  443. var useExplain = $(".use-explain").val();
  444. // var itemId = $("#itemId").val();
  445. //
  446. // if (itemId <= 0) {
  447. // showMsg('请选择品目名称!');
  448. // return false;
  449. // }
  450. //判断出库数量
  451. var itemNum = parseFloat($(".item-num").text());
  452. var varfiyMsg = '';
  453. // layer.msg('出库数量必须大于0!');return false;
  454. $("input[name='out_stock_num']").each(function () {
  455. if($(this).val() <= 0){
  456. varfiyMsg = '出库数量必须大于0!';
  457. return false;
  458. }
  459. // if($(this).val() > $(this).attr('num')){
  460. // varfiyMsg = $(this).attr('itmeName')+',退库数量不能大于可退库数量!';
  461. // return false;
  462. // }
  463. });
  464. if(varfiyMsg){
  465. layer.msg(varfiyMsg);
  466. return false;
  467. }
  468. var itemOutArr = [];
  469. $("input[name='select-itemId-outId']").each(function () {
  470. itemOutArr.push($(this).val()+'_'+$("#"+$(this).val()).val());
  471. });
  472. if(itemOutArr.length <= 0){
  473. showMsg('请选择品目!');
  474. return false;
  475. }
  476. var data = {
  477. itemOutArr: itemOutArr,
  478. useExplain: useExplain,
  479. outDate: outDate,
  480. outTitle: outTitle,
  481. outId:outId
  482. }
  483. //提交数据
  484. $.ajax({
  485. type: 'POST',
  486. url: "<?php echo $this->createUrl('imsStore/ajaxOutAdd');?>",
  487. data: data,
  488. async: false,
  489. dataType: 'json',
  490. success: function (result) {
  491. console.log(result);
  492. if (result.status == 1) {
  493. layer.alert("提交成功", {icon: 1,closeBtn:0}, function () {
  494. window.location.href = "<?php echo $this->createUrl('imsStore/useOut',array('useOutType'=>'out'));?>";
  495. })
  496. } else {
  497. flag = true;
  498. layer.msg(result.msg);
  499. }
  500. },
  501. error: function (jqXHR, textStatus, errorThrown) {
  502. /*错误信息处理*/
  503. flag = true;
  504. layer.msg('提交失败');
  505. }
  506. });
  507. }else{
  508. layer.msg("稍安勿躁,正在处理中...");
  509. }
  510. function showMsg(msg) {
  511. layer.msg(msg);
  512. }
  513. function checkDate(date) {
  514. return (new Date(date).getDate() == date.substring(date.length - 2));
  515. }
  516. });
  517. //移除列表
  518. $("body").delegate('.remove-list','click',function () {
  519. $(this).parents('tr').remove();
  520. });
  521. //加减库存
  522. $(".table-center").delegate('.reduce-out','click',function () {
  523. var ipt = $(this).siblings("input[name='out_stock_num']");
  524. var _num = parseInt(ipt.val());
  525. if(_num>1){
  526. ipt.val(_num - 1);
  527. }
  528. });
  529. $(".table-center").delegate('.add-out','click',function () {
  530. var ipt = $(this).siblings("input[name='out_stock_num']");
  531. var _num = parseInt(ipt.val());
  532. if(_num < ipt.attr('num')){
  533. ipt.val(_num + 1);
  534. }
  535. });
  536. $(".label-primary-cancle").click(function () {
  537. history.go(-1);
  538. });
  539. //查询
  540. $("body").delegate('.search-item','click',function () {
  541. selectItem(1,0);
  542. });
  543. //切换品目类型
  544. $("body").delegate('input[type=radio][name=itemType]','change',function(k,v) {
  545. $(".item-out-list").siblings("tr").remove();
  546. });
  547. })
  548. </script>
  549. </body>
  550. </html>