editRepairOrder.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <?php
  2. $priority_arr = array(1=>'紧急维修',2=>'巡检');
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="UTF-8">
  8. <title>编辑维修工单</title>
  9. <link href="/css/base.css" rel="stylesheet">
  10. <link href="/css/ims/ims.css" rel="stylesheet">
  11. <link rel="stylesheet" type="text/css" href="/css/ims/bootstrap.min.css"/>
  12. <link rel="stylesheet" type="text/css" href="/css/ims/ace.min.css"/>
  13. <link rel="stylesheet" type="text/css" href="/css/ims/jquery.datetimepicker.css"/>
  14. <style>
  15. .ims-box {
  16. margin: 20px;
  17. }
  18. .screen {
  19. padding-left: 20px;
  20. height: 44px;
  21. line-height: 44px;
  22. background-color: #eff4fa;
  23. }
  24. .screen li {
  25. float: left;
  26. margin-right: 65px;
  27. }
  28. .bg-d9bf6e {
  29. margin-left: 5px;
  30. padding: 0 20px;
  31. color: #fff;
  32. background-color: #d9bf6e;
  33. }
  34. .list {
  35. padding: 0 40px;
  36. /*margin-top: 40px;*/
  37. overflow: hidden;
  38. }
  39. .list h2 {
  40. line-height: 30px;
  41. font-size: 14px;
  42. }
  43. .list .student-list_box {
  44. width: 300px;
  45. }
  46. .list .student-list_box > ul {
  47. height: 260px;
  48. overflow: auto;
  49. padding: 20px;
  50. background-color: #eef3ff;
  51. }
  52. .list .student-list_box li {
  53. line-height: 30px;
  54. cursor: pointer;
  55. }
  56. .list .student-selected_box {
  57. margin-left: 60px;
  58. }
  59. .list .student-list {
  60. display: none;
  61. margin-left: 20px;
  62. }
  63. .list .student-list li.active .btn-select_all {
  64. display: inline-block;
  65. }
  66. .list .student-list span {
  67. cursor: pointer;
  68. }
  69. .list .btn-select_all {
  70. margin-left: 84px;
  71. color: #008000;
  72. }
  73. .student-name_box li {
  74. position: relative;
  75. margin-left: 28px;
  76. line-height: 30px;
  77. }
  78. .student-name_box input {
  79. position: absolute;
  80. left: 155px;
  81. top: 8px;
  82. }
  83. .btn-select_all,
  84. .student-name_box {
  85. display: none;
  86. }
  87. .student-selected {
  88. width: 320px;
  89. height: 220px;
  90. overflow: auto;
  91. }
  92. .student-selected li {
  93. float: left;
  94. margin-right: 24px;
  95. margin-bottom: 12px;
  96. height: 26px;
  97. line-height: 26px;
  98. text-indent: 20px;
  99. background-color: #f2f2f2;
  100. }
  101. .student-selected .btn-delete {
  102. float: right;
  103. margin-right: 20px;
  104. color: red;
  105. cursor: pointer;
  106. }
  107. .btn-confirm_purchase {
  108. display: block;
  109. margin: 0 auto;
  110. margin-top: 100px;
  111. margin-bottom: 50px;
  112. width: 430px;
  113. line-height: 54px;
  114. color: #fff;
  115. font-family: PingFangSC-Regular, "PingFang SC";
  116. font-weight: 400;
  117. font-style: normal;
  118. font-size: 20px;
  119. text-align: center;
  120. background-color: rgba(0, 153, 102, 1);
  121. cursor: pointer;
  122. }
  123. #imgPreview {
  124. display: inline-block;
  125. margin-top: 12px;
  126. }
  127. #imgPreview > img {
  128. max-width: 100px;
  129. max-height: 100px;
  130. margin-right: 5px;
  131. }
  132. .layui-layer-btn .layui-layer-btn0 {
  133. border-color: #15ae68 !important;
  134. background-color: #15ae68 !important;
  135. color: #fff;
  136. }
  137. .stop-layer-box, .resubmit-layer-box, .delete-layer-box {
  138. line-height: 140px;
  139. text-align: center;
  140. }
  141. </style>
  142. </head>
  143. <body>
  144. <h3 class="sale-title">新增维修工单</h3>
  145. <input type="hidden" name="oldOrderId" id="oldOrderId" value="0">
  146. <div class="sale-table">
  147. <table width="100%">
  148. <tr>
  149. <th><em class="red">*</em>工单标题</th>
  150. <td colspan="3"><input type="text" style="width:100%;" placeholder="请输入标题" name="title" value="<?php echo $title;?>"></td>
  151. </tr>
  152. <tr>
  153. <th><em class="red">*</em>学校名称</th>
  154. <td>
  155. <?php echo $schoolName;?>
  156. </td>
  157. <th><em class="red">*</em>申请人</th>
  158. <td>
  159. <?php echo $coachName;?>
  160. </td>
  161. </tr>
  162. <tr>
  163. <th><em class="red">*</em>预约维修日期</th>
  164. <td>
  165. <input id="outTimet" readonly type="text" style="width:100%;" placeholder="请输入日期" name="reserveTime" value="<?php echo $reserveTime;?>">
  166. </td>
  167. <th>工单类型</th>
  168. <td>
  169. <div class="diy_select">
  170. <input type="hidden" id="priority" name="priority" class="diy_select_input" value="<?php echo $priority;?>">
  171. <div class="diy_select_txt pm_name_txt"><?php echo isset($priority_arr[$priority])?$priority_arr[$priority]:'';?></div>
  172. <div class="diy_select_btn"></div>
  173. <ul class="diy_select_list pm_name" style="display: none;">
  174. <li val="-1">请选择</li>
  175. <li val="1">紧急维修</li>
  176. <li val="2">巡检</li>
  177. </ul>
  178. </div>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td colspan="4" class="sale-num">&nbsp;</td>
  183. </tr>
  184. <tr>
  185. <th><em class="red">*</em>故障图片</th>
  186. <td colspan="3">
  187. <label class="add-img">
  188. <span>+</span>
  189. <input type="file" id="uploadImg" accept="image/*" style="display: none;"/>
  190. </label>
  191. <span>上传图片</span>
  192. <div id="imgPreview">
  193. <?php foreach ($imgUrls as $val):?>
  194. <img src="<?php echo $val;?>">
  195. <?php endforeach;?>
  196. </div>
  197. </td>
  198. </tr>
  199. <tr>
  200. <th><em class="red">*</em>故障描述</th>
  201. <td colspan="3">
  202. <input type="text" style="width:100%;" placeholder="输入故障描述" name="remarks" value="<?php echo $remarks;?>">
  203. </td>
  204. </tr>
  205. </table>
  206. </div>
  207. <div class="clearfix student-list">
  208. <div class="fl">维修品目</div>
  209. </div>
  210. <div style="font-size:12px;max-height: 350px;overflow-y: scroll;margin-bottom: 25px;">
  211. <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" style="margin-bottom: 120px;">
  212. <thead>
  213. <tr>
  214. <th>品目名称</th>
  215. <th>编号</th>
  216. <th>类型</th>
  217. <th>规格</th>
  218. </tr>
  219. </thead>
  220. <tbody id="active-submit-stu">
  221. <tr>
  222. <td>
  223. <div class="diy_select">
  224. <input type="hidden" id="itemId" name="itemId" class="diy_select_input" value="<?php echo isset($itemId)?$itemId:0;?>">
  225. <div class="diy_select_txt pm_name_txt"><?php echo $itemName;?></div>
  226. <div class="diy_select_btn"></div>
  227. <ul id="itemList" class="diy_select_list pm_name" style="display: none;">
  228. <li val="0">请选择</li>
  229. <?php foreach ($itemList as $item):?>
  230. <li val="<?php echo $item['itemId'];?>" type-name="<?php echo $item['typeName'];?>" item-desc="<?php echo $item['itemSpec'];?>"><?php echo $item['itemName'];?></li>
  231. <?php endforeach;?>
  232. </ul>
  233. </div>
  234. </td>
  235. <td>
  236. <div class="diy_select">
  237. <input type="hidden" id="fixedCode" name="fixedCode" class="diy_select_input" value="<?php echo isset($fixedCode)?$fixedCode:0;?>">
  238. <div class="diy_select_txt pm_name_txt"><?php echo $fixedCode;?></div>
  239. <div class="diy_select_btn"></div>
  240. <ul id="fixedList" class="diy_select_list pm_name" style="display: none;">
  241. <li val="0">请选择</li>
  242. </ul>
  243. </div>
  244. </td>
  245. <td>
  246. <?php echo isset($itemType)?$itemType:'';?>
  247. </td>
  248. <td>
  249. <?php echo isset($itemSpec)?$itemSpec:'';?>
  250. </td>
  251. </tr>
  252. </tbody>
  253. </table>
  254. </div>
  255. <div class="sale-submit">
  256. <button type="button" id="returnList" class="label-primary-s bth-s">取消</button>
  257. <button type="button" id="saveOrder" class="label-primary-s bth-s">保存</button>
  258. </div>
  259. <script src="/js/productset/jquery.min.js"></script>
  260. <script src="/js/ims/jquery.datetimepicker.js"></script>
  261. <script src="/js/ims/layer/layer.js"></script>
  262. <script src="/js/ims/xsgl.js"></script>
  263. <script>
  264. $(document).ready(function () {
  265. $('#outTimet').datetimepicker({
  266. format: "Y-m-d", //格式化日期
  267. timepicker: false //关闭时间选项
  268. });
  269. // 添加图片
  270. $("#uploadImg").on("change", function () {
  271. //限制图片数量
  272. var imgObj = $('#imgPreview img');
  273. if(imgObj.length>=3){
  274. layer.msg("最多可上传三张图片");
  275. return false;
  276. }
  277. var formData = new FormData();
  278. formData.append('uploadFile', document.getElementById('uploadImg').files[0]);
  279. if(document.getElementById('uploadImg').files[0]==undefined){
  280. return false;
  281. }
  282. var basic = "<?php echo $basic;?>";
  283. $.ajax({
  284. url: "<?php echo $uploadUrl;?>",
  285. type: "post",
  286. data: formData,
  287. processData: false,
  288. contentType: false,
  289. beforeSend: function (req) {
  290. req.setRequestHeader("Authorization", basic);
  291. },
  292. success: function (data) {
  293. console.log(data);
  294. if (data.errCode == '00') {
  295. var html = "<img src='" + data.data.url + "'>";
  296. $('#imgPreview').append(html);
  297. $('#uploadImg').val('');
  298. } else {
  299. layer.msg(data.errMsg);
  300. }
  301. }
  302. });
  303. });
  304. $("body").on("click", "#imgPreview img", function () {
  305. var obj = $(this);
  306. var imgUrl = $(this).attr('src');
  307. layer.confirm('您确定删除此图片吗?', {
  308. btn: ['确定', '取消'] //按钮
  309. }, function () {
  310. obj.remove();
  311. layer.closeAll();
  312. });
  313. });
  314. //品目 固定资产数据联动
  315. $('#itemList li').click(function () {
  316. var typeName = $(this).attr('type-name');
  317. var itemDesc = $(this).attr('item-desc');
  318. var url = "<?php echo $this->createUrl('imsDevice/getFixed');?>" + "?itemId=" + $(this).attr('val');
  319. $.ajax({
  320. url: url,
  321. type: "get",
  322. dataType: "json",
  323. success: function (data) {
  324. if (data.status === 1) {
  325. var con = '<li val="0">请选择</li>';
  326. $.each(data.data, function(index,item){
  327. con += '<li val="' + item + '">' + item + '</li>';
  328. });
  329. $('#fixedList').html(con);
  330. $('#typeName').html(typeName);
  331. $('#itemDesc').html(itemDesc);
  332. }else {
  333. layer.msg(data.message);
  334. }
  335. }
  336. });
  337. });
  338. function saveOrder(){
  339. var title = $.trim($("input[name='title']").val());
  340. if(title.length === 0){
  341. layer.msg('工单标题不能为空');
  342. return false;
  343. }
  344. var reserveTime = $.trim($("input[name='reserveTime']").val());
  345. if(!reserveTime){
  346. layer.msg('预约日期不正确');
  347. return false;
  348. }
  349. var remarks = $.trim($("input[name='remarks']").val());
  350. if(remarks.length === 0){
  351. layer.msg('故障描述不能为空');
  352. return false;
  353. }
  354. var priority = $("input[name='priority']").val();
  355. if(priority!=1 && priority!=2 && priority!=3 && priority!=4 && priority!=5){
  356. layer.msg('请选择工单类型');
  357. return false;
  358. }
  359. var itemId = $("input[name='itemId']").val();
  360. if(!itemId || itemId==0){
  361. layer.msg('请选择品目');
  362. return false;
  363. }
  364. var fixedCode = $("input[name='fixedCode']").val();
  365. if(!fixedCode || fixedCode==0){
  366. layer.msg('请选择固定资产');
  367. return false;
  368. }
  369. var imgArr = [];
  370. $('#imgPreview img').each(function () {
  371. imgArr.push($(this).attr('src'));
  372. });
  373. if (imgArr.length <= 0) {
  374. showMsg('请上传图片!');
  375. return false;
  376. }
  377. var data = {
  378. id : '<?php echo $id;?>',
  379. title: title,
  380. reserveTime: reserveTime,
  381. remarks: remarks,
  382. priority: priority,
  383. itemId: itemId,
  384. fixedCode: fixedCode,
  385. imgArr: imgArr,
  386. };
  387. $.ajax({
  388. url: "<?php echo $this->createUrl('imsDevice/ajaxSaveOrder');?>",
  389. type: "post",
  390. data:data,
  391. dataType: "json",
  392. success: function (data) {
  393. if (data.status === 1) {
  394. layer.alert("保存成功", {icon: 1,closeBtn:0}, function () {
  395. window.location.href = "<?php echo $this->createUrl('imsDevice/repairOrder');?>";
  396. })
  397. }else {
  398. layer.msg(data.msg);
  399. }
  400. }
  401. });
  402. }
  403. //保存
  404. $('#saveOrder').click(function () {
  405. saveOrder();
  406. });
  407. $('#returnList').click(function () {
  408. window.location.href = "<?php echo $this->createUrl('imsDevice/repairOrder');?>";
  409. });
  410. })
  411. </script>
  412. </body>
  413. </html>