createPlanList.php 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>新增库存盘点</title>
  6. <link href="/css/ims/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: 300px;
  87. overflow: auto;
  88. }
  89. .student-selected li {
  90. float: left;
  91. margin-right: 24px;
  92. margin-bottom: 12px;
  93. width: 280px;
  94. height: 26px;
  95. line-height: 26px;
  96. text-indent: 20px;
  97. background-color: #f2f2f2;
  98. }
  99. .student-selected .btn-delete {
  100. float: right;
  101. margin-right: 20px;
  102. color: red;
  103. cursor: pointer;
  104. }
  105. .btn-confirm_purchase {
  106. display: block;
  107. margin: 0 auto;
  108. margin-top: 100px;
  109. margin-bottom: 50px;
  110. width: 430px;
  111. line-height: 54px;
  112. color: #fff;
  113. font-family: PingFangSC-Regular, "PingFang SC";
  114. font-weight: 400;
  115. font-style: normal;
  116. font-size: 20px;
  117. text-align: center;
  118. background-color: #2977ff;
  119. cursor: pointer;
  120. }
  121. .sale-table input {
  122. border: 1px solid #ccc;
  123. border-radius: 4px;
  124. }
  125. #imgPreview {
  126. display: inline-block;
  127. margin-top: 12px;
  128. }
  129. #imgPreview > img {
  130. max-width: 100px;
  131. max-height: 100px;
  132. margin-right: 5px;
  133. }
  134. .layui-layer-btn .layui-layer-btn0 {
  135. border-color: #2977ff !important;
  136. background-color: #2977ff !important;
  137. color: #fff;
  138. }
  139. .stop-layer-box, .resubmit-layer-box, .delete-layer-box {
  140. line-height: 140px;
  141. text-align: center;
  142. }
  143. .blue{
  144. color:blue;
  145. cursor: pointer;
  146. }
  147. .bg-green{
  148. background-color: #2977ff;
  149. }
  150. .bg-red{
  151. background-color: red;
  152. }
  153. .bg-yellow{
  154. background-color: #DAA520;
  155. }
  156. .title{
  157. padding: 0 10px;
  158. font-size: 16px;
  159. font-weight: 600;
  160. line-height: 28px;
  161. }
  162. .product{
  163. padding: 0 10px;
  164. margin-top: 10px;
  165. }
  166. .table-product{
  167. width: 100%;
  168. text-align: center;
  169. line-height: 30px;
  170. }
  171. .table-product tr:nth-child(odd) {
  172. background-color: #fafafa;
  173. }
  174. .product .table-product th,.product .table-product td{
  175. width: 15%;
  176. }
  177. .product .table-product th{
  178. text-align: center;
  179. }
  180. .product .plan-count-wrap-po{
  181. display: inline-block;
  182. height: 24px;
  183. font-size: 0;
  184. }
  185. .product .reduce-count,.product .add-count{
  186. display: inline-block;
  187. width: 24px;
  188. line-height: 24px;
  189. height: 24px;
  190. font-size: 14px;
  191. text-align: center;
  192. color: #fff;
  193. background-color: #666;
  194. cursor: pointer;
  195. }
  196. .product .product-contrast{
  197. text-align: left;
  198. padding-left: 6%;
  199. }
  200. .product .plan-count{
  201. width: 80px;
  202. height: 24px;
  203. line-height: 24px;
  204. font-size: 14px;
  205. text-align: center;
  206. box-sizing: border-box;
  207. }
  208. .tag-table-product{
  209. display: inline-block;
  210. margin-right: 10px;
  211. width: 24px;
  212. height: 24px;
  213. line-height: 24px;
  214. color: #fff;
  215. text-align: center;
  216. }
  217. .assets{
  218. width: 100%;
  219. margin-top: 10px;
  220. padding: 0 10px;
  221. }
  222. .assets .table-assets{
  223. width: 100%;
  224. text-align: center;
  225. line-height: 30px;
  226. }
  227. .table-assets tr:nth-child(odd) {
  228. background-color: #fafafa;
  229. }
  230. .assets .table-assets th{
  231. text-align: center;
  232. }
  233. .show-layer-assets-number{
  234. color: #169BD5;
  235. cursor: pointer;
  236. }
  237. /*弹窗开始*/
  238. .dialog-layer-assets-number{
  239. display: none;
  240. width: 360px;
  241. padding: 10px 20px;
  242. color: #666;
  243. }
  244. .dialog-layer-assets-number .pan-title{
  245. line-height: 32px;
  246. color: #333;
  247. font-weight: 600;
  248. }
  249. .assets-number-list{
  250. height: 60px;
  251. overflow: auto;
  252. }
  253. .assets-number-list label{
  254. display: inline-block;
  255. width: 150px;
  256. line-height: 30px;
  257. font-size: 13px;
  258. }
  259. .dialog-layer-assets-number .new-assets-number-box{
  260. line-height: 30px;
  261. }
  262. .dialog-layer-assets-number .input-new-assets-number{
  263. width: 120px;
  264. line-height: 24px;
  265. box-sizing: border-box;
  266. }
  267. .dialog-layer-assets-number .new-add-plan{
  268. line-height: 24px;
  269. margin-left: 14px;
  270. border-radius: 3px;
  271. padding: 0 4px;
  272. font-size: 12px;
  273. color: #fff;
  274. background-color: #2977ff;
  275. cursor: pointer;
  276. border: none;
  277. outline: none;
  278. }
  279. body .input-layer-new-assets-number{
  280. width: 137px;
  281. border: none;
  282. outline: none;
  283. background: #fff !important;
  284. }
  285. .dialog-btn-box{
  286. margin-top: 20px;
  287. text-align: center;
  288. }
  289. .dialog-btn-box button{
  290. width: 60px;
  291. height: 24px;
  292. line-height: 24px;
  293. text-align: center;
  294. cursor: pointer;
  295. border: none;
  296. outline: none;
  297. }
  298. .dialog-btn-box .btn-dialog-colse{
  299. color: #2977ff;
  300. background-color: #fff;
  301. border: 1px solid #2977ff;
  302. box-sizing: border-box;
  303. }
  304. .dialog-btn-box .btn-dialog-save{
  305. margin-left: 20px;
  306. color: #fff;
  307. background-color: #2977ff;
  308. }
  309. .now-hidden{display: none}
  310. /*在谷歌下移除input[number]的上下箭头*/
  311. .new-assets-number-box input[type='number']::-webkit-outer-spin-button,
  312. .new-assets-number-box input[type='number']::-webkit-inner-spin-button{
  313. -webkit-appearance: none !important;
  314. margin: 0;
  315. }
  316. /*在firefox下移除input[number]的上下箭头*/
  317. .new-assets-number-box input[type="number"]{-moz-appearance:textfield;}
  318. .btn-go-img{
  319. position: relative;
  320. top: 40px;
  321. color:#478fca!important;
  322. cursor:pointer;
  323. }
  324. //示例图片样式
  325. .top-bar{
  326. overflow: hidden;
  327. }
  328. .top-bar .msg{
  329. color: red;
  330. font-size: 14px;
  331. line-height: 29px;
  332. }
  333. .top-bar button{
  334. float: right;
  335. padding: 4px 8px;
  336. font-size: 14px;
  337. color: #2977ff;
  338. border: 1px solid #2977ff;
  339. border-radius: 5px;
  340. background-color: #fff;
  341. cursor: pointer;
  342. outline: none;
  343. }
  344. .img-example{
  345. border: 1px solid #333;
  346. margin-top: 20px;
  347. margin-bottom: 20px;
  348. padding: 0 20px 20px 20px;
  349. }
  350. .img-example h2{
  351. font-size: 18px;
  352. line-height: 1.5em;
  353. }
  354. .table-img-example {
  355. width: 100%;
  356. border-left: 1px solid #ccc;
  357. border-top: 1px solid #ccc;
  358. box-sizing: border-box;
  359. border-collapse: collapse;
  360. }
  361. .table-img-example td {
  362. width: 25%;
  363. padding: 4px;
  364. border-right: 1px solid #ccc;
  365. border-bottom: 1px solid #ccc;
  366. box-sizing: border-box;
  367. }
  368. .table-img-example .img-box{
  369. text-align: center;
  370. /*width: 24%;*/
  371. }
  372. .table-img-example .img-box img{
  373. max-width: 100%;
  374. }
  375. .table-img-example .text-box{
  376. text-indent:2em!important;
  377. text-align: left;
  378. }
  379. .dialog-img-big{
  380. display: none;
  381. padding: 20px;
  382. }
  383. .dialog-img-big img{
  384. width: 100%;
  385. }
  386. .show-tr{
  387. color:#2977ff;
  388. cursor: pointer;
  389. }
  390. </style>
  391. </head>
  392. <body>
  393. <div class="body-sale">
  394. <h3 class="sale-title">库存盘点单</h3>
  395. <input type="hidden" name="itemName">
  396. <input type="hidden" name="itemSpec">
  397. <input type="hidden" name="itemCode">
  398. <input type="hidden" name="unitId">
  399. <div class="sale-table">
  400. <table width="100%">
  401. <tr>
  402. <th><em class="red">*</em>标题</th>
  403. <td colspan="3">
  404. <input type="text" style="width:50%;" name="stockTitle" value="<?php echo $title;?>" readonly="readonly">
  405. </td>
  406. </tr>
  407. <tr>
  408. <th><em class="red">*</em>盘点日期</th>
  409. <td colspan="3">
  410. <input id="stocktakingDate" type="text" name="stocktakingDate" style="width:50%;" readonly>
  411. </td>
  412. </tr>
  413. <tr>
  414. <th><em class="red">*</em>盘点凭证</th>
  415. <td colspan="3">
  416. <label class="add-img">
  417. <span>+</span>
  418. <input type="file" id="fileImg" accept="image/*" style="display: none;" />
  419. </label>
  420. <span> 请上传货品盘点的照片</span>
  421. <div id="imgPreview"></div>
  422. <!--<span class="fr btn-go-img" onclick="window.location.href='<?php // echo Yii::app()->createUrl('imsStore/planExamples')."?planId=".$planId; ?>'">查看示例图片</span>-->
  423. <span class="fr btn-go-img">查看示例图片</span>
  424. </td>
  425. </tr>
  426. <tr>
  427. <!-- more less same-->
  428. <td colspan="4" class="sale-num get-status">
  429. </td>
  430. </tr>
  431. <tr>
  432. <th>盘点说明</th>
  433. <td colspan="3">
  434. <textarea name="remark" id="remark" rows="6" cols="60"></textarea>
  435. </td>
  436. </tr>
  437. </table>
  438. </div>
  439. <?php if(isset($list) && $list):?>
  440. <?php foreach($list as $k=>$v):?>
  441. <?php if($k == 'finishList'):?>
  442. <?php if($v):?>
  443. <?php $tr_show = "";?>
  444. <?php $tr_hide = "";?>
  445. <h4 class="title">产成品</h4>
  446. <div class="product">
  447. <table class="table-product" border="1px">
  448. <tr>
  449. <th>品目名称</th>
  450. <th class="now-hidden">理论数量</th>
  451. <th>总库存盘点</th>
  452. <th>不合格品盘点</th>
  453. <th>单位</th>
  454. <th>总库存盘点情况</th>
  455. <th>不合格品盘点情况</th>
  456. </tr>
  457. <?php foreach($v as $kk=>$vv):?>
  458. <?php
  459. if($vv['invNo'] == 0){
  460. $profit = '<span class="tag-table-product bg-yellow">平</span>';
  461. }elseif($vv['invNo'] > 0){
  462. $profit = '<span class="tag-table-product bg-red">亏</span>-'.$vv['invNo'];
  463. }elseif($vv['invNo'] < 0){
  464. $profit = '<span class="tag-table-product bg-green">盈</span>+'.$vv['invNo'];
  465. }
  466. ?>
  467. <?php
  468. if($vv['scrapOld'] == 0){
  469. $scrapOld = '<span class="tag-table-product bg-yellow">平</span>';
  470. }elseif($vv['scrapOld'] > 0){
  471. $scrapOld = '<span class="tag-table-product bg-red">亏</span>-'.$vv['scrapOld'];
  472. }elseif($vv['scrapOld'] < 0){
  473. $scrapOld = '<span class="tag-table-product bg-green">盈</span>+'.$vv['scrapOld'];
  474. }
  475. ?>
  476. <?php
  477. if($vv['invNo'] > 0){
  478. $tr_show .= '<tr class="no-fixed" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td class="now-hidden">'.$vv['scrapOld'].'</td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td>'.$vv['unitName'].'</td><td class="product-contrast">'.$profit.'</td><td class="product-contrast">'.$scrapOld.'</td></tr>';
  479. }else{
  480. $tr_hide .= '<tr class="no-fixed hide need-hide" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td class="now-hidden">'.$vv['scrapOld'].'</td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td>'.$vv['unitName'].'</td><td class="product-contrast">'.$profit.'</td><td class="product-contrast">'.$scrapOld.'</td></tr>';
  481. }
  482. ?>
  483. <!--<tr class="no-fixed" itemId="<?php echo $vv['itemId']?>"><td><?php echo $vv['itemName'];?></td><td class="now-hidden"><?php echo $vv['invNo'];?></td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,'')"><span class="add-count">+</span></span></td><td class="now-hidden"><?php echo $vv['scrapOld'];?></td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,'')"><span class="add-count">+</span></span></td><td><?php echo $vv['unitName'];?></td><td class="product-contrast"><?php echo $profit;?></td><td class="product-contrast"><?php echo $scrapOld;?></td></tr>-->
  484. <?php endforeach;?>
  485. <?php echo $tr_show;?>
  486. <?php if($tr_hide):?>
  487. <?php echo $tr_hide;?>
  488. <?php endif;?>
  489. </table>
  490. <?php if($tr_hide):?>
  491. <div class="show-tr fr">展示更多</div>
  492. <?php endif;?>
  493. </div>
  494. <?php endif;?>
  495. <?php elseif($k == 'fixedList'):?>
  496. <?php if($v):?>
  497. <?php $tr_show = "";?>
  498. <?php $tr_hide = "";?>
  499. <h4 class="title">固定资产</h4>
  500. <div class="assets">
  501. <table class="table-assets" border="1">
  502. <tr>
  503. <th>品目名称</th>
  504. <th class="now-hidden">理论数量</th>
  505. <th>总库存盘点</th>
  506. <th>单位</th>
  507. <th>盘点情况</th>
  508. </tr>
  509. <?php foreach($v as $kk=>$vv):?>
  510. <?php
  511. if($vv['invNo'] == 0){
  512. $profit = '<span class="tag-table-product bg-yellow">平</span>';
  513. }elseif($vv['invNo'] > 0){
  514. $profit = '<span class="tag-table-product bg-red">亏</span>-'.$vv['invNo'];
  515. }elseif($vv['invNo'] < 0){
  516. $profit = '<span class="tag-table-product bg-green">盈</span>+'.$vv['invNo'];
  517. }
  518. ?>
  519. <?php
  520. if($vv['invNo'] > 0){
  521. $tr_show .= '<tr class="fixed" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td class="blue choose-pro" planId="'.$vv['itemId'].'" selectIds="" originIds="'.$vv['originIds'].'">0</td><td>'.$vv['unitName'].'</td><td class="product-contrast"><?php echo $profit;?></td></tr>';
  522. }else{
  523. $tr_hide .= '<tr class="fixed hide need-hide" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td class="blue choose-pro" planId="'.$vv['itemId'].'" selectIds="" originIds="'.$vv['originIds'].'">0</td><td>'.$vv['unitName'].'</td><td class="product-contrast"><?php echo $profit;?></td></tr>';
  524. }
  525. ?>
  526. <!--<tr class="fixed" itemId="<?php echo $vv['itemId']?>"><td><?php echo $vv['itemName'];?></td><td class="now-hidden"><?php echo $vv['invNo'];?></td><td class="blue choose-pro" planId="<?php echo $vv['itemId'];?>" selectIds="" originIds="<?php echo $vv['originIds'];?>">0</td><td><?php echo $vv['unitName'];?></td><td class="product-contrast"><?php echo $profit;?></td></tr>-->
  527. <?php endforeach;?>
  528. <?php echo $tr_show;?>
  529. <?php if($tr_hide):?>
  530. <?php echo $tr_hide;?>
  531. <?php endif;?>
  532. </table>
  533. <?php if($tr_hide):?>
  534. <div class="show-tr fr">展示更多</div>
  535. <?php endif;?>
  536. </div>
  537. <?php endif;?>
  538. <?php elseif($k == 'lowList'):?>
  539. <?php if($v):?>
  540. <?php $tr_show = "";?>
  541. <?php $tr_hide = "";?>
  542. <h4 class="title">低值易耗品</h4>
  543. <div class="product">
  544. <table class="table-product" border="1px">
  545. <tr>
  546. <th>品目名称</th>
  547. <th class="now-hidden">理论数量</th>
  548. <th>总库存盘点</th>
  549. <th>不合格品盘点</th>
  550. <th>单位</th>
  551. <th>总库存盘点情况</th>
  552. <th>不合格品盘点情况</th>
  553. </tr>
  554. <?php foreach($v as $kk=>$vv):?>
  555. <?php
  556. if($vv['invNo'] == 0){
  557. $profit = '<span class="tag-table-product bg-yellow">平</span>';
  558. }elseif($vv['invNo'] > 0){
  559. $profit = '<span class="tag-table-product bg-red">亏</span>-'.$vv['invNo'];
  560. }elseif($vv['invNo'] < 0){
  561. $profit = '<span class="tag-table-product bg-green">盈</span>+'.$vv['invNo'];
  562. }
  563. ?>
  564. <?php
  565. if($vv['scrapOld'] == 0){
  566. $scrapOld = '<span class="tag-table-product bg-yellow">平</span>';
  567. }elseif($vv['scrapOld'] > 0){
  568. $scrapOld = '<span class="tag-table-product bg-red">亏</span>-'.$vv['scrapOld'];
  569. }elseif($vv['scrapOld'] < 0){
  570. $scrapOld = '<span class="tag-table-product bg-green">盈</span>+'.$vv['scrapOld'];
  571. }
  572. ?>
  573. <?php
  574. if($vv['invNo'] > 0){
  575. $tr_show .= '<tr class="no-fixed" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td class="now-hidden">'.$vv['scrapOld'].'</td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td>'.$vv['unitName'].'</td><td class="product-contrast">'.$profit.'</td><td class="product-contrast">'.$scrapOld.'</td></tr>';
  576. }else{
  577. $tr_hide .= '<tr class="no-fixed hide need-hide" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td class="now-hidden">'.$vv['scrapOld'].'</td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td>'.$vv['unitName'].'</td><td class="product-contrast">'.$profit.'</td><td class="product-contrast">'.$scrapOld.'</td></tr>';
  578. }
  579. ?>
  580. <!--<tr class="no-fixed" itemId="<?php echo $vv['itemId']?>"><td><?php echo $vv['itemName'];?></td><td class="now-hidden"><?php echo $vv['invNo'];?></td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,'')"><span class="add-count">+</span></span></td><td class="now-hidden"><?php echo $vv['scrapOld'];?></td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,'')"><span class="add-count">+</span></span></td><td><?php echo $vv['unitName'];?></td><td class="product-contrast"><?php echo $profit;?></td><td class="product-contrast"><?php echo $scrapOld;?></td></tr>-->
  581. <?php endforeach;?>
  582. <?php echo $tr_show;?>
  583. <?php if($tr_hide):?>
  584. <?php echo $tr_hide;?>
  585. <?php endif;?>
  586. </table>
  587. <?php if($tr_hide):?>
  588. <div class="show-tr fr">展示更多</div>
  589. <?php endif;?>
  590. </div>
  591. <?php endif;?>
  592. <?php elseif($k == 'rawList'):?>
  593. <?php if($v):?>
  594. <?php $tr_show = "";?>
  595. <?php $tr_hide = "";?>
  596. <h4 class="title">原材料</h4>
  597. <div class="product">
  598. <table class="table-product" border="1px">
  599. <tr>
  600. <th>品目名称</th>
  601. <th class="now-hidden">理论数量</th>
  602. <th>总库存盘点</th>
  603. <th>不合格品盘点</th>
  604. <th>单位</th>
  605. <th>总库存盘点情况</th>
  606. <th>不合格品盘点情况</th>
  607. </tr>
  608. <?php foreach($v as $kk=>$vv):?>
  609. <?php
  610. if($vv['invNo'] == 0){
  611. $profit = '<span class="tag-table-product bg-yellow">平</span>';
  612. }elseif($vv['invNo'] > 0){
  613. $profit = '<span class="tag-table-product bg-red">亏</span>-'.$vv['invNo'];
  614. }elseif($vv['invNo'] < 0){
  615. $profit = '<span class="tag-table-product bg-green">盈</span>+'.$vv['invNo'];
  616. }
  617. ?>
  618. <?php
  619. if($vv['scrapOld'] == 0){
  620. $scrapOld = '<span class="tag-table-product bg-yellow">平</span>';
  621. }elseif($vv['scrapOld'] > 0){
  622. $scrapOld = '<span class="tag-table-product bg-red">亏</span>-'.$vv['scrapOld'];
  623. }elseif($vv['scrapOld'] < 0){
  624. $scrapOld = '<span class="tag-table-product bg-green">盈</span>+'.$vv['scrapOld'];
  625. }
  626. ?>
  627. <?php
  628. if($vv['invNo'] > 0){
  629. $tr_show .= '<tr class="no-fixed" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td class="now-hidden">'.$vv['scrapOld'].'</td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td>'.$vv['unitName'].'</td><td class="product-contrast">'.$profit.'</td><td class="product-contrast">'.$scrapOld.'</td></tr>';
  630. }else{
  631. $tr_hide .= '<tr class="no-fixed hide need-hide" itemId="'.$vv['itemId'].'"><td>'.$vv['itemName'].'</td><td class="now-hidden">'.$vv['invNo'].'</td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td class="now-hidden">'.$vv['scrapOld'].'</td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,\'\')"><span class="add-count">+</span></span></td><td>'.$vv['unitName'].'</td><td class="product-contrast">'.$profit.'</td><td class="product-contrast">'.$scrapOld.'</td></tr>';
  632. }
  633. ?>
  634. <!--<tr class="no-fixed" itemId="<?php echo $vv['itemId']?>"><td><?php echo $vv['itemName'];?></td><td class="now-hidden"><?php echo $vv['invNo'];?></td><td><span class="plan-count-wrap-po inv-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,'')"><span class="add-count">+</span></span></td><td class="now-hidden"><?php echo $vv['scrapOld'];?></td><td><span class="plan-count-wrap-po scrap-count"><span class="reduce-count">-</span><input type="text" value="0" name="plan-count" class="plan-count" oninput="value=value.replace(/[^\d]/g,'')"><span class="add-count">+</span></span></td><td><?php echo $vv['unitName'];?></td><td class="product-contrast"><?php echo $profit;?></td><td class="product-contrast"><?php echo $scrapOld;?></td></tr>-->
  635. <?php endforeach;?>
  636. <?php echo $tr_show;?>
  637. <?php if($tr_hide):?>
  638. <?php echo $tr_hide;?>
  639. <?php endif;?>
  640. </table>
  641. <?php if($tr_hide):?>
  642. <div class="show-tr fr">展示更多</div>
  643. <?php endif;?>
  644. </div>
  645. <?php endif;?>
  646. <?php endif;?>
  647. <?php endforeach;?>
  648. <?php endif;?>
  649. <div class="sale-submit" style="margin-top: 25px;">
  650. <button type="button" class="" onclick="javascript:history.back(-1);">返回</button>
  651. <button type="button" class=" label-primary-s bth-s" id="savebutton">提交</button>
  652. </div>
  653. <div class="dialog-layer-assets-number">
  654. <div class='pan-title'>盘点数量(<span class='pan-count'>0</span>)</div>
  655. <div class='assets-number-list-parent'></div>
  656. <div class='new-assets-number-box'>
  657. <input type='checkbox' name='need-plan' value=''><input type='text' value='' name='need-plan-name' class='input-new-assets-number' placeholder='输入新编号'>
  658. <button type='button' class='new-add-plan'>新盘点编号</button>
  659. </div>
  660. <div class='dialog-btn-box'>
  661. <button type="button" class="back-plan btn-dialog-colse">返回</button>
  662. <button type="button" class="btn-dialog-save" id="add-plan-identifier">提交</button>
  663. </div>
  664. </div>
  665. </div>
  666. <div class="pic-sale" style="display:none">
  667. <div class="top-bar">
  668. <span class="msg">上传的图片,用于新建盘点单时作图片参考</span>
  669. <!--<button type="button" onclick="window.location.href='<?php // echo Yii::app()->createUrl('imsStore/createPlanList')."?planId=".$planId; ?>'">返回</button>-->
  670. <button type="button">返回</button>
  671. </div>
  672. <?php if(isset($result) && $result):?>
  673. <div class="img-example">
  674. <h2>固定资产</h2>
  675. <?php if(isset($result['fixedList']) && $result['fixedList']):?>
  676. <table class="table-img-example">
  677. <?php foreach($result['fixedList'] as $k=>$v):?>
  678. <?php if($k%2 == 0):?>
  679. <tr>
  680. <td class="img-box">
  681. <img src="<?php echo isset($v["imgUrl"])?$v["imgUrl"]:"";?>" alt="">
  682. </td>
  683. <td class="text-box">
  684. <?php echo isset($v["description"])?$v["description"]:"";?>
  685. </td>
  686. <?php if(!isset($result['fixedList'][$k+1])):?>
  687. <td class="img-box"></td>
  688. <td class="text-box"></td>
  689. </tr>
  690. <?php endif;?>
  691. <?php else:?>
  692. <td class="img-box">
  693. <img src="<?php echo isset($v["imgUrl"])?$v["imgUrl"]:"";?>" alt="">
  694. </td>
  695. <td class="text-box">
  696. <?php echo isset($v["description"])?$v["description"]:"";?>
  697. </td>
  698. </tr>
  699. <?php endif;?>
  700. <?php endforeach;?>
  701. </table>
  702. <?php endif;?>
  703. </div>
  704. <div class="img-example">
  705. <h2>产成品</h2>
  706. <?php if(isset($result['finishList']) && $result['finishList']):?>
  707. <table class="table-img-example">
  708. <?php foreach($result['finishList'] as $k=>$v):?>
  709. <?php if($k%2 == 0):?>
  710. <tr>
  711. <td class="img-box">
  712. <img src="<?php echo isset($v["imgUrl"])?$v["imgUrl"]:"";?>" alt="">
  713. </td>
  714. <td class="text-box">
  715. <?php echo isset($v["description"])?$v["description"]:"";?>
  716. </td>
  717. <?php if(!isset($result['finishList'][$k+1])):?>
  718. <td class="img-box"></td>
  719. <td class="text-box"></td>
  720. </tr>
  721. <?php endif;?>
  722. <?php else:?>
  723. <td class="img-box">
  724. <img src="<?php echo isset($v["imgUrl"])?$v["imgUrl"]:"";?>" alt="">
  725. </td>
  726. <td class="text-box">
  727. <?php echo isset($v["description"])?$v["description"]:"";?>
  728. </td>
  729. </tr>
  730. <?php endif;?>
  731. <?php endforeach;?>
  732. </table>
  733. <?php endif;?>
  734. </div>
  735. <div class="img-example">
  736. <h2>低值易耗品</h2>
  737. <?php if(isset($result['lowList']) && $result['lowList']):?>
  738. <table class="table-img-example">
  739. <?php foreach($result['lowList'] as $k=>$v):?>
  740. <?php if($k%2 == 0):?>
  741. <tr>
  742. <td class="img-box">
  743. <img src="<?php echo isset($v["imgUrl"])?$v["imgUrl"]:"";?>" alt="">
  744. </td>
  745. <td class="text-box">
  746. <?php echo isset($v["description"])?$v["description"]:"";?>
  747. </td>
  748. <?php if(!isset($result['lowList'][$k+1])):?>
  749. <td class="img-box"></td>
  750. <td class="text-box"></td>
  751. </tr>
  752. <?php endif;?>
  753. <?php else:?>
  754. <td class="img-box">
  755. <img src="<?php echo isset($v["imgUrl"])?$v["imgUrl"]:"";?>" alt="">
  756. </td>
  757. <td class="text-box">
  758. <?php echo isset($v["description"])?$v["description"]:"";?>
  759. </td>
  760. </tr>
  761. <?php endif;?>
  762. <?php endforeach;?>
  763. </table>
  764. <?php endif;?>
  765. <!-- 图片放大弹窗 -->
  766. <div class="dialog-img-big">
  767. <img src="" alt="" id="imgBig">
  768. </div>
  769. </div>
  770. <?php endif;?>
  771. </div>
  772. <script src="/js/jquery-2.2.2.min.js" ></script>
  773. <script src="/js/jquery.datetimepicker.js"></script>
  774. <script src="/js/layer/layer.js"></script>
  775. <script src="/js/xsgl.js"></script>
  776. <?php // include_once '_stock.php'?>
  777. <script>
  778. $('body').delegate('.choose-pro','click', function(){
  779. var planId = $(this).attr("planId");
  780. var originIds = $(this).attr("originIds");
  781. var selectIds = $(this).attr("selectIds");
  782. if(selectIds){
  783. var selectIdsArr = selectIds.split(",");
  784. }else{
  785. var selectIdsArr = [];
  786. }
  787. // if(planId){
  788. // $.ajax({
  789. // url: "<?php // echo Yii::app()->createUrl('imsStore/ajaxGetIdentifier')?>",
  790. // type: "post",
  791. // data: {'planId':planId},
  792. // dataType: 'json',
  793. // success: function (res) {
  794. // console.log(res);
  795. var html = "";
  796. // html += "<div class='pan-title'>盘点数量(<span class='pan-count'>0</span>)</div>";
  797. if(originIds){
  798. originIdsArr = originIds.split(",");
  799. html += "<div class='assets-number-list'>";
  800. for(var a = 0;a<originIdsArr.length;a++){
  801. if($.inArray(originIdsArr[a],selectIdsArr) > -1){
  802. html += "<label><input type='checkbox' name='need-plan' value='' checked='checked'><input type='text' value='"+originIdsArr[a]+"' name='need-plan-name' class='input-layer-new-assets-number' readonly='readonly'></label>";
  803. }else{
  804. html += "<label><input type='checkbox' name='need-plan' value=''><input type='text' value='"+originIdsArr[a]+"' name='need-plan-name' class='input-layer-new-assets-number' readonly='readonly'></label>";
  805. }
  806. }
  807. html += "</div>";
  808. }
  809. // html += "<div class='new-assets-number-box'>";
  810. // html += " <input type='checkbox' name='need-plan' value=''><input type='text' value='' name='need-plan-name' class='input-new-assets-number' placeholder='输入新编号'>";
  811. // html += " <button type='button' class='new-add-plan'>新盘点编号</button>";
  812. // html += "</div>";
  813. // html += "<div class='dialog-btn-box'>";
  814. // html += ' <button type="button" class="back-plan btn-dialog-colse">返回</button>';
  815. // html +=' <button type="button" class="btn-dialog-save" id="add-plan-identifier" planId='+planId+'>提交</button>';
  816. // html += "</div>";
  817. $('.assets-number-list-parent').html(html);
  818. $('#add-plan-identifier').attr("planId",planId);
  819. var length = $('.dialog-layer-assets-number input:checked').length;
  820. $('.pan-count').html(length);
  821. layer.open({
  822. title: false,
  823. closeBtn: 0,
  824. type: 1,
  825. area: ['360px', '200px'],
  826. content: $(".dialog-layer-assets-number")
  827. });
  828. // }
  829. // })
  830. // }
  831. });
  832. $('body').delegate('.dialog-layer-assets-number input[type="checkbox"]','click', function(){
  833. var length = $('.dialog-layer-assets-number input:checked').length;
  834. $('.pan-count').html(length);
  835. });
  836. $('body').delegate('.btn-dialog-colse','click', function(){
  837. layer.close(layer.index);
  838. });
  839. $('body').delegate('.new-add-plan','click', function(){
  840. var html = "<div class='new-assets-number-box'><input type='checkbox' name='need-plan' value=''><input type='text' value='' name='need-plan-name' class='input-new-assets-number' placeholder='输入新编号'></div>";
  841. $(this).parent().after(html);
  842. });
  843. $('body').delegate('#add-plan-identifier','click', function(){
  844. var selectIdentifierIds = [];
  845. var originIdentifierIds = [];
  846. var planId = $(this).attr("planId");
  847. $('input[name="need-plan"]:checked').each(function(){
  848. if($(this).next().val()){
  849. selectIdentifierIds.push($(this).next().val());
  850. }
  851. });
  852. $('.assets-number-list input[name="need-plan-name"]').each(function(){
  853. originIdentifierIds.push($(this).val());
  854. })
  855. // if(selectIdentifierIds.length>0){
  856. $('.choose-pro[planId='+planId+']').html(selectIdentifierIds.length);
  857. // }
  858. $('.choose-pro[planId='+planId+']').attr("selectIds",selectIdentifierIds.join(","));
  859. $('.choose-pro[planId='+planId+']').attr("originIds",originIdentifierIds.join(","));
  860. layer.close(layer.index);
  861. console.log(selectIdentifierIds);
  862. })
  863. $('body').delegate('.add-count','click', function(){
  864. var count = parseInt($(this).prev().val());
  865. count += 1;
  866. $(this).prev().val(count);
  867. if($(this).parent().hasClass("inv-count")){
  868. var type = 6;
  869. }else{
  870. var type = 7;
  871. }
  872. var oldCount = parseInt($(this).parent().parent().prev().text());
  873. if(oldCount == count){
  874. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-yellow">平</span>');
  875. }else if(oldCount > count){
  876. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-red">亏</span>-'+(oldCount-count));
  877. }else if(oldCount < count){
  878. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-green">盈</span>+'+(count-oldCount));
  879. }
  880. });
  881. $('body').delegate('.reduce-count','click', function(){
  882. var count = parseInt($(this).next().val());
  883. if($(this).parent().hasClass("inv-count")){
  884. var type = 6;
  885. }else{
  886. var type = 7;
  887. }
  888. if(count >= 1){
  889. count -= 1;
  890. $(this).next().val(count);
  891. var oldCount = parseInt($(this).parent().parent().prev().text());
  892. if(oldCount == count){
  893. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-yellow">平</span>');
  894. }else if(oldCount > count){
  895. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-red">亏</span>-'+(oldCount-count));
  896. }else if(oldCount < count){
  897. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-green">盈</span>+'+(count-oldCount));
  898. }
  899. }
  900. });
  901. $('.plan-count').on('input propertychange', function() {
  902. var count = parseInt($(this).val());
  903. var oldCount = parseInt($(this).parent().parent().prev().text());
  904. if($(this).parent().hasClass("inv-count")){
  905. var type = 6;
  906. }else{
  907. var type = 7;
  908. }
  909. if(oldCount == count){
  910. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-yellow">平</span>');
  911. }else if(oldCount > count){
  912. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-red">亏</span>-'+(oldCount-count));
  913. }else if(oldCount < count){
  914. $(this).parent().parent().parent().find("td:eq("+type+")").html('<span class="tag-table-product bg-green">盈</span>+'+(count-oldCount));
  915. }
  916. });
  917. $('#stocktakingDate').datetimepicker({
  918. format: "Y-m-d", //格式化日期
  919. timepicker: false //关闭时间选项
  920. });
  921. //添加图片
  922. $("#fileImg").on("change", function () {
  923. //限制图片数量
  924. var imgObj = $('#imgPreview img');
  925. if(imgObj.length>=10){
  926. layer.msg("最多可上传10张图片");
  927. return false;
  928. }
  929. var formData = new FormData();
  930. formData.append('uploadFile', document.getElementById('fileImg').files[0]);
  931. if(document.getElementById('fileImg').files[0]==undefined){
  932. return false;
  933. }
  934. var basic = "<?php echo $basic;?>";
  935. $.ajax({
  936. url: "<?php echo $uploadUrl;?>",
  937. type: "post",
  938. data: formData,
  939. processData: false,
  940. contentType: false,
  941. beforeSend: function (req) {
  942. req.setRequestHeader("Authorization", basic);
  943. },
  944. success: function (data) {
  945. console.log(data);
  946. if (data.errCode == '00') {
  947. var html = "<img src='" + data.data.url + "'>";
  948. $('#imgPreview').append(html);
  949. $('#uploadImg').val('');
  950. } else {
  951. layer.msg(data.errMsg);
  952. }
  953. },
  954. error:function(data){
  955. console.log(data);
  956. }
  957. });
  958. });
  959. $("body").on("click", "#imgPreview img", function () {
  960. var obj = $(this);
  961. var imgUrl = $(this).attr('src');
  962. layer.confirm('您确定删除此图片吗?', {
  963. btn: ['确定', '取消'] //按钮
  964. }, function () {
  965. obj.remove();
  966. layer.closeAll();
  967. });
  968. });
  969. var flag = true;
  970. //提交
  971. $("#savebutton").click(function () {
  972. if (flag){
  973. flag = false;
  974. var stockTitle = $.trim($("input[name='stockTitle']").val());
  975. var stocktakingDate = $("input[name='stocktakingDate']").val();
  976. var remark = $('#remark').val();
  977. var details = [];
  978. var isZero = 0;
  979. var no = 0;
  980. if (stockTitle == '') {
  981. layer.msg('标题名称不能为空!');
  982. flag = true;
  983. return false;
  984. } else if (stockTitle.length > 49) {
  985. showMsg('标题名称不能超过50个字符!');
  986. flag = true;
  987. return false;
  988. }
  989. if (!stocktakingDate) {
  990. layer.msg('时间不能为空!');
  991. flag = true;
  992. return false;
  993. }
  994. var imgArr = [];
  995. $('#imgPreview img').each(function () {
  996. imgArr.push($(this).attr('src'));
  997. });
  998. if (imgArr.length < 1) {
  999. layer.msg('请上传图片!');
  1000. flag = true;
  1001. return false;
  1002. }
  1003. //其他
  1004. $('.no-fixed').each(function(){
  1005. var temp={};
  1006. //details[no] = {};
  1007. temp.fixedCodes = [];
  1008. temp.invFixedCodes = [];
  1009. temp.itemId = $(this).attr("itemId");
  1010. temp.stockNo = parseFloat($(this).find("td:eq(2)").find("input").val());
  1011. temp.theoreticalNo = parseFloat($(this).find("td:eq(1)").text());
  1012. temp.lossNo = accSub(parseFloat($(this).find("td:eq(2)").find("input").val()),parseFloat($(this).find("td:eq(1)").text()));
  1013. temp.scrapOld = parseFloat($(this).find("td:eq(3)").text());
  1014. temp.scrapNo = parseFloat($(this).find("td:eq(4)").find("input").val());
  1015. temp.scrapLoss = accSub(parseFloat($(this).find("td:eq(4)").find("input").val()),parseFloat($(this).find("td:eq(3)").text()));
  1016. if(temp.lossNo == 0){
  1017. temp.lossType = 2;
  1018. }else if(temp.lossNo > 0){
  1019. temp.lossType = 1;
  1020. }else if(temp.lossNo < 0){
  1021. temp.lossType = 0;
  1022. }
  1023. if(temp.stockNo!=0 || temp.theoreticalNo!=0 || temp.scrapOld!=0 || temp.scrapNo!=0){
  1024. details[no]=temp;
  1025. if(details[no].stockNo == 0){
  1026. isZero = 1;
  1027. }
  1028. no++;
  1029. }
  1030. });
  1031. $('.fixed').each(function(){
  1032. var temp={};
  1033. // details[no] = {};
  1034. if($(this).find("td:eq(2)").attr("selectIds")){
  1035. temp.fixedCodes = $(this).find("td:eq(2)").attr("selectIds").split(",");
  1036. }else{
  1037. temp.fixedCodes = [];
  1038. }
  1039. if($(this).find("td:eq(2)").attr("originIds")){
  1040. temp.invFixedCodes = $(this).find("td:eq(2)").attr("originIds").split(",");
  1041. }else{
  1042. temp.invFixedCodes = [];
  1043. }
  1044. temp.itemId = $(this).attr("itemId");
  1045. temp.stockNo = parseFloat($(this).find("td:eq(2)").text());
  1046. temp.theoreticalNo = $(this).find("td:eq(1)").text();
  1047. temp.lossNo = parseFloat(($(this).find("td:eq(2)").text()),$(this).find("td:eq(1)").text());
  1048. if(temp.lossNo == 0){
  1049. temp.lossType = 2;
  1050. }else if(temp.lossNo > 0){
  1051. temp.lossType = 1;
  1052. }else if(temp.lossNo < 0){
  1053. temp.lossType = 0;
  1054. }
  1055. if(temp.stockNo!=0 || temp.theoreticalNo!=0 ){
  1056. details[no]=temp;
  1057. if(details[no].stockNo == 0){
  1058. isZero = 1;
  1059. }
  1060. no++;
  1061. }
  1062. });
  1063. //固定资产
  1064. // var fixedCodesArr = [];
  1065. // var inFixedCodesArr = [];
  1066. // if (itemType.val()==0){
  1067. // var fixedObj = $('input[name="fixedCodes"]:checked');
  1068. // fixedObj.each(function () {
  1069. // fixedCodesArr.push($(this).val());
  1070. // });
  1071. // var infixedObj = $('input[name="fixedCodes"]');
  1072. // infixedObj.each(function () {
  1073. // inFixedCodesArr.push($(this).val());
  1074. // });
  1075. // }
  1076. if(details.length==0){
  1077. layer.msg('盘点品目不能为空!');
  1078. flag = true;
  1079. return false;
  1080. }
  1081. var data = {
  1082. stockTitle: stockTitle,
  1083. stocktakingDate: stocktakingDate,
  1084. imgArr: imgArr,
  1085. remark:remark,
  1086. details:details,
  1087. pId:'<?php echo $_GET['planId']?>'
  1088. };
  1089. console.log(data);
  1090. if(isZero == 1){
  1091. layer.confirm('盘点数量有0值项,确定提交吗?', {
  1092. btn: ['提交', '返回'] //按钮
  1093. }, function () {
  1094. alertIndex=layer.msg('正在提交,请稍候。。。。。。');
  1095. $.ajax({
  1096. type: 'POST',
  1097. url: "<?php echo $this->createUrl('imsStore/ajaxNewStockAdd');?>",
  1098. data: data,
  1099. async: false,
  1100. dataType: 'json',
  1101. success: function (result) {
  1102. layer.close(alertIndex);
  1103. if (result.status == 1) {
  1104. layer.alert(result.msg, {icon: 1,closeBtn:0}, function () {
  1105. window.location.href = "<?php echo $this->createUrl('imsStore/newStock');?>";
  1106. })
  1107. } else {
  1108. flag = true;
  1109. layer.alert(result.msg,{icon:2});
  1110. }
  1111. },
  1112. error: function (jqXHR, textStatus, errorThrown) {
  1113. /*错误信息处理*/
  1114. flag = true;
  1115. layer.msg('提交失败');
  1116. }
  1117. });
  1118. },function(){
  1119. layer.closeAll();
  1120. });
  1121. }else{
  1122. layer.confirm('确认提交盘点单吗?', {
  1123. btn: ['提交', '返回'] //按钮
  1124. }, function () {
  1125. alertIndex=layer.msg('正在提交,请稍候。。。。。。');
  1126. $.ajax({
  1127. type: 'POST',
  1128. url: "<?php echo $this->createUrl('imsStore/ajaxNewStockAdd');?>",
  1129. data: data,
  1130. async: false,
  1131. dataType: 'json',
  1132. success: function (result) {
  1133. layer.close(alertIndex);
  1134. if (result.status == 1) {
  1135. layer.alert(result.msg, {icon: 1,closeBtn:0}, function () {
  1136. window.location.href = "<?php echo $this->createUrl('imsStore/newStock');?>";
  1137. })
  1138. } else {
  1139. flag = true;
  1140. layer.alert(result.msg,{icon:2});
  1141. }
  1142. },
  1143. error: function (jqXHR, textStatus, errorThrown) {
  1144. /*错误信息处理*/
  1145. flag = true;
  1146. layer.msg('提交失败');
  1147. }
  1148. });
  1149. },function(){
  1150. layer.closeAll();
  1151. });
  1152. }
  1153. } else {
  1154. layer.msg("稍安勿躁,正在处理中...");
  1155. }
  1156. });
  1157. //查看示例图片
  1158. $('body').delegate('.btn-go-img','click', function(){
  1159. $(".pic-sale").show();
  1160. $(".body-sale").hide();
  1161. });
  1162. //查看示例图片返回
  1163. $('body').delegate('.top-bar button','click', function(){
  1164. $(".pic-sale").hide();
  1165. $(".body-sale").show();
  1166. });
  1167. //放大图片
  1168. $(".img-example").on("click",".img-box img", function(){
  1169. var imgUrl = $(this).attr('src');
  1170. $('#imgBig').attr('src',imgUrl);
  1171. layer.open({
  1172. title: false,
  1173. closeBtn: 1,
  1174. type: 1,
  1175. area: ['800px', '600px'],
  1176. offset: '100px',
  1177. content: $(".dialog-img-big")
  1178. });
  1179. });
  1180. //展示更多或收起
  1181. $("body").on("click",".show-tr", function(){
  1182. if($(this).hasClass("hide-tr")){
  1183. $(this).prev().find("tr.need-hide").addClass("hide");
  1184. $(this).html("展开更多");
  1185. $(this).removeClass("hide-tr");
  1186. }else{
  1187. $(this).html("收起");
  1188. $(this).addClass("hide-tr");
  1189. $(this).prev().find("tr.need-hide").removeClass("hide");
  1190. }
  1191. });
  1192. var accSub = function(num1, num2) {
  1193. num1 = Number(num1);
  1194. num2 = Number(num2);
  1195. var dec1, dec2, times;
  1196. try { dec1 = countDecimals(num1)+1; } catch (e) { dec1 = 0; }
  1197. try { dec2 = countDecimals(num2)+1; } catch (e) { dec2 = 0; }
  1198. times = Math.pow(10, Math.max(dec1, dec2));
  1199. // var result = Number(((num1 * times - num2 * times) / times);
  1200. var result = Number((accMul(num1, times) - accMul(num2, times)) / times);
  1201. return getCorrectResult("sub", num1, num2, result);
  1202. // return result;
  1203. };
  1204. function accMul(arg1,arg2)
  1205. {
  1206. var m=0,s1=arg1.toString(),s2=arg2.toString();
  1207. try{m+=s1.split(".")[1].length}catch(e){}
  1208. try{m+=s2.split(".")[1].length}catch(e){}
  1209. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
  1210. }
  1211. var countDecimals = function(num) {
  1212. var len = 0;
  1213. try {
  1214. num = Number(num);
  1215. var str = num.toString().toUpperCase();
  1216. if (str.split('E').length === 2) { // scientific notation
  1217. var isDecimal = false;
  1218. if (str.split('.').length === 2) {
  1219. str = str.split('.')[1];
  1220. if (parseInt(str.split('E')[0]) !== 0) {
  1221. isDecimal = true;
  1222. }
  1223. }
  1224. let x = str.split('E');
  1225. if (isDecimal) {
  1226. len = x[0].length;
  1227. }
  1228. len -= parseInt(x[1]);
  1229. } else if (str.split('.').length === 2) { // decimal
  1230. if (parseInt(str.split('.')[1]) !== 0) {
  1231. len = str.split('.')[1].length;
  1232. }
  1233. }
  1234. } catch(e) {
  1235. throw e;
  1236. } finally {
  1237. if (isNaN(len) || len < 0) {
  1238. len = 0;
  1239. }
  1240. return len;
  1241. }
  1242. };
  1243. var convertToInt = function(num) {
  1244. num = Number(num);
  1245. var newNum = num;
  1246. var times = countDecimals(num);
  1247. var temp_num = num.toString().toUpperCase();
  1248. if (temp_num.split('E').length === 2) {
  1249. newNum = Math.round(num * Math.pow(10, times));
  1250. } else {
  1251. newNum = Number(temp_num.replace(".", ""));
  1252. }
  1253. return newNum;
  1254. };
  1255. var getCorrectResult = function(type, num1, num2, result) {
  1256. var temp_result = 0;
  1257. switch (type) {
  1258. case "add":
  1259. temp_result = num1 + num2;
  1260. break;
  1261. case "sub":
  1262. temp_result = num1 - num2;
  1263. break;
  1264. case "div":
  1265. temp_result = num1 / num2;
  1266. break;
  1267. case "mul":
  1268. temp_result = num1 * num2;
  1269. break;
  1270. }
  1271. if (Math.abs(result - temp_result) > 1) {
  1272. return temp_result;
  1273. }
  1274. return result;
  1275. };
  1276. </script>
  1277. </body>
  1278. </html>