createRepairOrder.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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"><input type="text" style="width:100%;" placeholder="请输入标题" name="title" value=""></td>
  148. </tr>
  149. <tr>
  150. <th><em class="red">*</em>学校名称</th>
  151. <td>
  152. <?php echo $schoolName;?>
  153. </td>
  154. <th><em class="red">*</em>申请人</th>
  155. <td>
  156. <?php echo $coachName;?>
  157. </td>
  158. </tr>
  159. <tr>
  160. <th><em class="red">*</em>预约维修日期</th>
  161. <td>
  162. <input id="outTimet" readonly type="text" style="width:100%;" placeholder="请输入日期" name="reserveTime" value="">
  163. </td>
  164. <th>工单类型</th>
  165. <td>
  166. <div class="diy_select">
  167. <input type="hidden" id="priority" name="priority" class="diy_select_input" value="-1">
  168. <div class="diy_select_txt pm_name_txt">请选择</div>
  169. <div class="diy_select_btn"></div>
  170. <ul class="diy_select_list pm_name" style="display: none;">
  171. <li val="-1">请选择</li>
  172. <li val="1">紧急维修</li>
  173. <li val="2">巡检</li>
  174. </ul>
  175. </div>
  176. </td>
  177. </tr>
  178. <tr>
  179. <td colspan="4" class="sale-num">&nbsp;</td>
  180. </tr>
  181. <tr>
  182. <th><em class="red">*</em>故障图片</th>
  183. <td colspan="3">
  184. <label class="add-img">
  185. <span>+</span>
  186. <input type="file" id="uploadImg" accept="image/*" style="display: none;"/>
  187. </label>
  188. <span>上传图片</span>
  189. <div id="imgPreview"></div>
  190. </td>
  191. </tr>
  192. <tr>
  193. <th><em class="red">*</em>故障描述</th>
  194. <td colspan="3">
  195. <input type="text" style="width:100%;" placeholder="输入故障描述" name="remarks" value="">
  196. </td>
  197. </tr>
  198. </table>
  199. </div>
  200. <div class="clearfix student-list">
  201. <div class="fl">维修品目</div>
  202. </div>
  203. <div style="font-size:12px;max-height: 350px;overflow-y: scroll;margin-bottom: 25px;">
  204. <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" style="margin-bottom: 120px;">
  205. <thead>
  206. <tr>
  207. <th>品目名称</th>
  208. <th>编号</th>
  209. <th>类型</th>
  210. <th>规格</th>
  211. </tr>
  212. </thead>
  213. <tbody id="active-submit-stu">
  214. <tr>
  215. <td>
  216. <div class="diy_select">
  217. <input type="hidden" id="itemId" name="itemId" class="diy_select_input" value="0">
  218. <div class="diy_select_txt pm_name_txt">请选择</div>
  219. <div class="diy_select_btn"></div>
  220. <ul id="itemList" class="diy_select_list pm_name" style="display: none;">
  221. <li val="0">请选择</li>
  222. <?php foreach ($itemList as $item):?>
  223. <li val="<?php echo $item['itemId'];?>" type-name="<?php echo $item['typeName'];?>" item-desc="<?php echo $item['itemSpec'];?>"><?php echo $item['itemName'];?></li>
  224. <?php endforeach;?>
  225. </ul>
  226. </div>
  227. </td>
  228. <td>
  229. <div class="diy_select">
  230. <input type="hidden" id="fixedCode" name="fixedCode" class="diy_select_input" value="0">
  231. <div class="diy_select_txt pm_name_txt">请选择</div>
  232. <div class="diy_select_btn"></div>
  233. <ul id="fixedList" class="diy_select_list pm_name" style="display: none;">
  234. <li val="0">请选择</li>
  235. </ul>
  236. </div>
  237. </td>
  238. <td id="typeName"></td>
  239. <td id="itemDesc"></td>
  240. </tr>
  241. </tbody>
  242. </table>
  243. </div>
  244. <div class="sale-submit">
  245. <button type="button" id="returnList" class="label-primary-s bth-s">取消</button>
  246. <button type="button" id="saveOrder" class="label-primary-s bth-s">保存</button>
  247. </div>
  248. <script src="/js/productset/jquery.min.js"></script>
  249. <script src="/js/ims/jquery.datetimepicker.js"></script>
  250. <script src="/js/ims/layer/layer.js"></script>
  251. <script src="/js/ims/xsgl.js"></script>
  252. <script>
  253. $(document).ready(function () {
  254. $('#outTimet').datetimepicker({
  255. format: "Y-m-d", //格式化日期
  256. timepicker: false //关闭时间选项
  257. });
  258. // 添加图片
  259. $("#uploadImg").on("change", function () {
  260. //限制图片数量
  261. var imgObj = $('#imgPreview img');
  262. if(imgObj.length>=3){
  263. layer.msg("最多可上传三张图片");
  264. return false;
  265. }
  266. var formData = new FormData();
  267. formData.append('uploadFile', document.getElementById('uploadImg').files[0]);
  268. if(document.getElementById('uploadImg').files[0]==undefined){
  269. return false;
  270. }
  271. var basic = "<?php echo $basic;?>";
  272. $.ajax({
  273. url: "<?php echo $uploadUrl;?>",
  274. type: "post",
  275. data: formData,
  276. processData: false,
  277. contentType: false,
  278. beforeSend: function (req) {
  279. req.setRequestHeader("Authorization", basic);
  280. },
  281. success: function (data) {
  282. console.log(data);
  283. if (data.errCode == '00') {
  284. var html = "<img src='" + data.data.url + "'>";
  285. $('#imgPreview').append(html);
  286. $('#uploadImg').val('');
  287. } else {
  288. layer.msg(data.errMsg);
  289. }
  290. }
  291. });
  292. });
  293. $("body").on("click", "#imgPreview img", function () {
  294. var obj = $(this);
  295. var imgUrl = $(this).attr('src');
  296. layer.confirm('您确定删除此图片吗?', {
  297. btn: ['确定', '取消'] //按钮
  298. }, function () {
  299. obj.remove();
  300. layer.closeAll();
  301. });
  302. });
  303. //品目 固定资产数据联动
  304. $('#itemList li').click(function () {
  305. var typeName = $(this).attr('type-name');
  306. var itemDesc = $(this).attr('item-desc');
  307. var url = "<?php echo $this->createUrl('imsDevice/getFixed');?>" + "?itemId=" + $(this).attr('val');
  308. $.ajax({
  309. url: url,
  310. type: "get",
  311. dataType: "json",
  312. success: function (data) {
  313. if (data.status === 1) {
  314. var con = '<li val="0">请选择</li>';
  315. $.each(data.data, function(index,item){
  316. con += '<li val="' + item + '">' + item + '</li>';
  317. });
  318. $('#fixedList').html(con);
  319. $('#typeName').html(typeName);
  320. $('#itemDesc').html(itemDesc);
  321. }else {
  322. layer.msg(data.message);
  323. }
  324. }
  325. });
  326. });
  327. function saveOrder(){
  328. var title = $.trim($("input[name='title']").val());
  329. if(title.length === 0){
  330. layer.msg('工单标题不能为空');
  331. return false;
  332. }
  333. var reserveTime = $.trim($("input[name='reserveTime']").val());
  334. if(!reserveTime){
  335. layer.msg('预约日期不正确');
  336. return false;
  337. }
  338. var remarks = $.trim($("input[name='remarks']").val());
  339. if(remarks.length === 0){
  340. layer.msg('故障描述不能为空');
  341. return false;
  342. }
  343. var priority = $("input[name='priority']").val();
  344. if(priority!=1 && priority!=2 && priority!=3 && priority!=4 && priority!=5){
  345. layer.msg('请选择工单类型');
  346. return false;
  347. }
  348. var itemId = $("input[name='itemId']").val();
  349. if(!itemId || itemId==0){
  350. layer.msg('请选择品目');
  351. return false;
  352. }
  353. var fixedCode = $("input[name='fixedCode']").val();
  354. if(!fixedCode || fixedCode==0){
  355. layer.msg('请选择固定资产');
  356. return false;
  357. }
  358. var imgArr = [];
  359. $('#imgPreview img').each(function () {
  360. imgArr.push($(this).attr('src'));
  361. });
  362. if (imgArr.length <= 0) {
  363. showMsg('请上传图片!');
  364. return false;
  365. }
  366. var data = {
  367. title: title,
  368. reserveTime: reserveTime,
  369. remarks: remarks,
  370. priority: priority,
  371. itemId: itemId,
  372. fixedCode: fixedCode,
  373. imgArr: imgArr,
  374. };
  375. $.ajax({
  376. url: "<?php echo $this->createUrl('imsDevice/ajaxSaveOrder');?>",
  377. type: "post",
  378. data:data,
  379. dataType: "json",
  380. success: function (data) {
  381. if (data.status === 1) {
  382. layer.alert("保存成功", {icon: 1,closeBtn:0}, function () {
  383. window.location.href = "<?php echo $this->createUrl('imsDevice/repairOrder');?>";
  384. })
  385. }else {
  386. layer.msg(data.msg);
  387. }
  388. }
  389. });
  390. }
  391. //保存
  392. $('#saveOrder').click(function () {
  393. saveOrder();
  394. });
  395. $('#returnList').click(function () {
  396. window.history.go(-1);
  397. });
  398. })
  399. </script>
  400. </body>
  401. </html>