addPrint.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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: #008000;
  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: rgba(0, 153, 102, 1);
  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: #15ae68 !important;
  131. background-color: #15ae68 !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. </style>
  139. </head>
  140. <body>
  141. <h3 class="sale-title">上传打印量</h3>
  142. <input type="hidden" name="oldOrderId" id="oldOrderId" value="0">
  143. <div class="sale-table">
  144. <table width="100%">
  145. <tr>
  146. <th><em class="red">*</em>学校名称</th>
  147. <td colspan="3"> <?php echo $schoolName;?></td>
  148. </tr>
  149. <tr>
  150. <th><em class="red">*</em>申请人</th>
  151. <td>
  152. <?php echo $coachName;?>
  153. </td>
  154. <th><em class="red">*</em>上传时间</th>
  155. <td>
  156. <?php echo date('Y-m-d H:i:s');?>
  157. </td>
  158. </tr>
  159. <tr>
  160. <th><em class="red">*</em>上传图片</th>
  161. <td colspan="3">
  162. <label class="add-img">
  163. <span>+</span>
  164. <input type="file" id="uploadImg" accept="image/*" style="display: none;"/>
  165. </label>
  166. <span>上传图片</span>
  167. <div id="imgPreview"></div>
  168. </td>
  169. </tr>
  170. <tr>
  171. <th><em class="red">*</em>备注</th>
  172. <td colspan="3">
  173. <textarea style="width:100%;" id="remarks" name="remarks" rows="3"></textarea>
  174. </td>
  175. </tr>
  176. </table>
  177. </div>
  178. <div class="clearfix student-list">
  179. <div class="fl">选择打印机</div>
  180. </div>
  181. <div style="font-size:12px;max-height: 350px;overflow-y: scroll;margin-bottom: 25px;">
  182. <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" style="margin-bottom: 120px;">
  183. <thead>
  184. <tr>
  185. <th>品目编号</th>
  186. <th>品目名称</th>
  187. <th>规格</th>
  188. <th>最近更新量(页码</th>
  189. <th>本次更新打印量(页码)</th>
  190. </tr>
  191. </thead>
  192. <tbody id="active-submit-stu">
  193. <tr>
  194. <td>
  195. <div class="diy_select">
  196. <input type="hidden" id="itemId" name="itemId" class="diy_select_input" value="0">
  197. <div class="diy_select_txt pm_name_txt">请选择</div>
  198. <div class="diy_select_btn"></div>
  199. <ul id="itemList" class="diy_select_list pm_name" style="display: none;">
  200. <li val="0">请选择</li>
  201. <?php foreach ($printer as $item):?>
  202. <li val="<?php echo $item['fcId'];?>" fixedCode="<?php echo $item['fixedCode']?>" itemSpec="<?php echo $item['itemSpec']?>" print="<?php echo $item['print']?>"><?php echo $item['itemName'];?></li>
  203. <?php endforeach;?>
  204. </ul>
  205. </div>
  206. </td>
  207. <td id="fixedCode"></td>
  208. <td id="itemSpec"></td>
  209. <td id="print"></td>
  210. <td ><input type="text" name="addNumber" value="0"></td>
  211. </tr>
  212. </tbody>
  213. </table>
  214. </div>
  215. <div class="sale-submit">
  216. <button type="button" id="returnList" class="label-primary-s bth-s">取消</button>
  217. <button type="button" status="0" class="label-primary-s bth-s saveOrder">保存</button>
  218. <button type="button" status="1" class="label-primary-s bth-s saveOrder">保存并上传</button>
  219. </div>
  220. <script src="/js/productset/jquery.min.js"></script>
  221. <script src="/js/ims/jquery.datetimepicker.js"></script>
  222. <script src="/js/ims/layer/layer.js"></script>
  223. <script src="/js/ims/xsgl.js"></script>
  224. <script>
  225. $(document).ready(function () {
  226. var updatePrintNum=0; //最近更新打印量
  227. $('#outTimet').datetimepicker({
  228. format: "Y-m-d", //格式化日期
  229. timepicker: false //关闭时间选项
  230. });
  231. // 添加图片
  232. $("#uploadImg").on("change", function () {
  233. //限制图片数量
  234. var imgObj = $('#imgPreview img');
  235. if(imgObj.length>=3){
  236. layer.msg("最多可上传三张图片");
  237. return false;
  238. }
  239. var formData = new FormData();
  240. formData.append('uploadFile', document.getElementById('uploadImg').files[0]);
  241. var basic = "<?php echo $basic;?>";
  242. if(document.getElementById('uploadImg').files[0]==undefined){
  243. return false;
  244. }
  245. $.ajax({
  246. url: "<?php echo $uploadUrl;?>",
  247. type: "post",
  248. data: formData,
  249. processData: false,
  250. contentType: false,
  251. beforeSend: function (req) {
  252. req.setRequestHeader("Authorization", basic);
  253. },
  254. success: function (data) {
  255. console.log(data);
  256. if (data.errCode == '00') {
  257. var html = "<img src='" + data.data.url + "'>";
  258. $('#imgPreview').append(html);
  259. $('#uploadImg').val('');
  260. } else {
  261. layer.msg(data.errMsg);
  262. }
  263. }
  264. });
  265. });
  266. $("body").on("click", "#imgPreview img", function () {
  267. var obj = $(this);
  268. var imgUrl = $(this).attr('src');
  269. layer.confirm('您确定删除此图片吗?', {
  270. btn: ['确定', '取消'] //按钮
  271. }, function () {
  272. obj.remove();
  273. layer.closeAll();
  274. });
  275. });
  276. //品目 固定资产数据联动
  277. $('#itemList li').click(function () {
  278. var fixedCode = $(this).attr('fixedCode');
  279. var itemSpec = $(this).attr('itemSpec');
  280. var print = $(this).attr('print');
  281. updatePrintNum=parseInt($(this).attr('print'));
  282. $('#fixedCode').html(fixedCode);
  283. $('#itemSpec').html(itemSpec);
  284. $('#print').html(print);
  285. });
  286. function saveOrder(status){
  287. var remarks = $.trim($("#remarks").val());
  288. if(remarks.length === 0){
  289. layer.msg('备注不能为空');
  290. return false;
  291. }
  292. var itemId = $("input[name='itemId']").val();
  293. if(!itemId || itemId==0){
  294. layer.msg('请选择品目');
  295. return false;
  296. }
  297. var print=$('input[name=addNumber]').val();
  298. if(!print || print==0){
  299. layer.msg('打印量不能为空');
  300. return false;
  301. }
  302. if(updatePrintNum>print){
  303. layer.msg('本次更新打印量必须大于等于最近更新的印量');
  304. return false;
  305. }
  306. var imgArr = [];
  307. $('#imgPreview img').each(function () {
  308. imgArr.push($(this).attr('src'));
  309. });
  310. if (imgArr.length <= 0) {
  311. layer.msg('请上传图片!');
  312. return false;
  313. }
  314. var data = {
  315. print: print,
  316. remark: remarks,
  317. status: status,
  318. fcId: itemId,
  319. imgUrls: imgArr,
  320. };
  321. alertIndex=layer.msg('正在保存,请稍候',{time:0});
  322. $('.saveOrder').attr('disabled',true);
  323. $.ajax({
  324. url: "<?php echo $this->createUrl('imsDevice/savePrintNumber');?>",
  325. type: "post",
  326. data:data,
  327. dataType: "json",
  328. success: function (data) {
  329. layer.close(alertIndex);
  330. if (data.status === 1) {
  331. layer.alert("保存成功", {icon: 1,closeBtn:0}, function () {
  332. window.location.href = "<?php echo $this->createUrl('imsDevice/printUploadList');?>";
  333. })
  334. }else {
  335. $('.saveOrder').attr('disabled',false);
  336. layer.msg(data.msg);
  337. }
  338. }
  339. });
  340. }
  341. //保存
  342. $('.saveOrder').click(function () {
  343. var status=$(this).attr('status');
  344. saveOrder(status);
  345. });
  346. $('#returnList').click(function () {
  347. window.history.go(-1);
  348. });
  349. })
  350. </script>
  351. </body>
  352. </html>