task.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="format-detection" content="telephone=no" />
  6. <meta name="format-detection" content="email=no" />
  7. <title>mes</title>
  8. <link rel="stylesheet" href="../css/reset.css">
  9. <link rel="stylesheet" href="../css/style.css">
  10. <script src="../script/flexible.js"></script>
  11. <style>
  12. html,body{
  13. height:100%;
  14. }
  15. .task_con {
  16. overflow: auto;
  17. padding-top: 0.23rem;
  18. }
  19. .task_con ul{
  20. display: none;
  21. }
  22. .task_con li {
  23. height: 2.83rem;
  24. margin-bottom: .2rem;
  25. background-color: #fff;
  26. position: relative;
  27. overflow: hidden;
  28. }
  29. .task_con li>div {
  30. display: inline-block;
  31. }
  32. .task_status {
  33. width: .6rem;
  34. height: 100%;
  35. font-size: .34rem;
  36. text-align: center;
  37. white-space: pre-wrap;
  38. color: #fff;
  39. position: relative;
  40. }
  41. .task_status_1{
  42. background-color: #ff6e6e;
  43. }
  44. .task_status_2{
  45. background-color: #22ac38;
  46. }
  47. .task_status_3{
  48. background-color: #a0a0a0;
  49. }
  50. .task_status_4{
  51. background-color: #f39700;
  52. }
  53. .task_status span {
  54. display: inline-block;
  55. width: .36rem;
  56. position: absolute;
  57. top: 50%;
  58. left: calc(50% - .18rem);
  59. -webkit-transform: translateY(-50%);
  60. transform: translateY(-50%);
  61. }
  62. .task_taskCon {
  63. max-width: calc(100% - 1.1rem);
  64. padding: .2rem 0 0 .2rem ;
  65. }
  66. .task_taskCon p {
  67. margin-bottom: .1rem;
  68. height: .5rem;
  69. color: #3d3d3d;
  70. font-size: .38rem;
  71. white-space: nowrap;
  72. }
  73. .task_name{
  74. display: inline-block;
  75. max-width: 6.1rem;
  76. font-size: .48rem;
  77. overflow: hidden;
  78. text-overflow: ellipsis;
  79. white-space: nowrap;
  80. vertical-align: middle;
  81. }
  82. .task_taskCon p:first-of-type{
  83. height: .6rem;
  84. position: relative;
  85. }
  86. .task_taskCon p:nth-of-type(n+2){
  87. width: 8rem;
  88. color: #898989;
  89. overflow-x: hidden;
  90. text-overflow: ellipsis;
  91. white-space: nowrap;
  92. }
  93. .icon_1{
  94. width: .3rem;
  95. height: .3rem;
  96. background: url("../image/task_icon_1.png") no-repeat 100% 110%/100%;
  97. margin-right: .1rem;
  98. }
  99. .icon_2{
  100. width: .3rem;
  101. height: .3rem;
  102. background: url("../image/task_icon_2.png") no-repeat 50% 140%/80%;
  103. margin-right: .1rem;
  104. }
  105. .task_taskCon p:last-of-type{
  106. width: 100%;
  107. overflow: visible;
  108. }
  109. .task_taskCon p:nth-of-type(3) {
  110. margin-bottom: .11rem;
  111. }
  112. .task_dbqk {
  113. display: inline-block;
  114. font-size: .3rem;
  115. padding: 0 .1rem;
  116. border-radius: .03rem;
  117. color: #fff;
  118. margin-left: .26rem;
  119. white-space: nowrap;
  120. }
  121. .task_dbqk1{
  122. background-color: #f39700;
  123. }
  124. .task_dbqk2{
  125. background-color: #ff0000;
  126. }
  127. .task_dbqk3{
  128. background-color: #bbbc5f;
  129. }
  130. .task_dbqk4{
  131. background-color: #e60012;
  132. }
  133. .task_dbqk5{
  134. background-color: #cacbbb;
  135. }
  136. .task_pssj,
  137. .task_wcsj {
  138. display: inline-block;
  139. height: .4rem;
  140. line-height: .4rem;
  141. font-size: .3rem;
  142. padding: 0 .18rem;
  143. border-radius: .03rem;
  144. }
  145. .task_pssj {
  146. border: 1px solid #3aca74;
  147. color: #3aca74;
  148. margin-right: .2rem;
  149. }
  150. .task_wcsj {
  151. border: 1px solid #fd9b53;
  152. color: #fd9b53;
  153. }
  154. .task_jt {
  155. position: absolute;
  156. top:0;
  157. right: 0;
  158. height: 100%;
  159. line-height: 2.6rem;
  160. font-size: .5rem;
  161. color: #b5b5b5;
  162. padding: 0 .18rem;
  163. }
  164. .nomore_tit{
  165. width: 60%;
  166. border-top: 1px solid #e0e0e0;
  167. margin: .2rem auto;
  168. }
  169. .nomore_txt{
  170. font-size: .4rem;
  171. color: #b0b0b0;
  172. text-align: center;
  173. padding: 0 .1rem;
  174. }
  175. .hid{
  176. display: none;
  177. }
  178. </style>
  179. </head>
  180. <body>
  181. <div class="flex-con task_con">
  182. <ul>
  183. <li class="flex-wrap" data-taskid="{{taskID}}" data-lon="{{lon}}" data-lat="{{lat}}">
  184. <div class="task_status {{taskstatus}}" data-taskstatus="0"><span>{{status}}</span></div>
  185. <div class="task_taskCon flex-con">
  186. <p><span class="task_name">{{name}}</span><span class="task_dbqk {{statusclass}}">{{type}}</span></p>
  187. <p><i class="icon_1"></i>检修内容:<span class="task_duty">{{duty}}</span></p>
  188. <p><i class="icon_2"></i>地址:<span class="task_dw">{{enterprise}}</span></p>
  189. <p><span class="task_pssj">申请日期:{{pssj}}</span><span class="task_wcsj">计划开始:{{jhks}}</span></p>
  190. </div>
  191. <div class="task_jt">〉</div>
  192. </li>
  193. </ul>
  194. </div>
  195. <div class="nomore hid">
  196. <fieldset class="nomore_tit">
  197. <legend align="center" class="nomore_txt">已经没有更多了</legend>
  198. </fieldset>
  199. </div>
  200. <script src="../script/publicData.js"></script>
  201. <script src="../script/jqueryMin.js"></script>
  202. <script type="text/javascript" src="../script/api.js"></script>
  203. <script>
  204. apiready = function() {
  205. if(api.systemType=="ios"){
  206. $(".task_taskCon p").css("margin-bottom",".1rem")
  207. }
  208. if(!$api.getStorage("task_frame1Data")){
  209. api.showProgress({
  210. title: '努力加载中...',
  211. text: '请稍等...',
  212. modal: false
  213. });
  214. }
  215. var duty,page=1;
  216. var ulModel=$(".task_con ul").html();
  217. var isreload=false;
  218. getData();
  219. api.addEventListener({
  220. name:'scrolltobottom',
  221. extra:{
  222. threshold:0 //设置距离底部多少距离时触发,默认值为0,数字类型
  223. }
  224. }, function(ret, err){
  225. if(!$(".nomore").hasClass("hid")||isreload){
  226. return;
  227. }else {
  228. if($api.getStorage("taskpage")<=1) return;
  229. api.toast({
  230. msg: '正在加载更多',
  231. duration: 2000,
  232. location: 'bottom'
  233. });
  234. }
  235. var postData={
  236. user_id:$api.getStorage("user").id,
  237. page:page,
  238. status:0
  239. };
  240. isreload=true;
  241. api.ajax({
  242. url: pageUrl+"/index/task/index",
  243. method: 'get',
  244. timeout: 30,
  245. dataType: 'text',
  246. returnAll: false,
  247. data: {
  248. values: {user_id:$api.getStorage("user").id, page:page, status:0,type:2}
  249. }
  250. }, function (data, err) {
  251. data=JSON.parse(data)
  252. // alert(JSON.stringify(data))
  253. var data=data.data,str="";
  254. var dataNames1=[];
  255. if(!data.length){
  256. str="<p style='padding-top: 5.3rem;font-size: .5rem;text-align: center;color: #818181'>暂无任务</p>"
  257. }else {
  258. for(var i in data){
  259. str+=ulModel.replace("{{taskID}}",data[i]['id']).replace("{{name}}",data[i]['title']).replace("{{duty}}",data[i]['remark']).replace("{{enterprise}}",data[i]['address']).replace("{{type}}",data[i]['task_type']==1?"紧急":"常规").replace("{{statusclass}}",data[i]['task_type']==0?"task_dbqk1":"task_dbqk2")
  260. .replace("{{pssj}}",data[i]['start_time']?data[i]['start_time'].slice(0,16):"").replace("{{jhks}}",data[i]['created_at']?data[i]['created_at'].slice(0,16):"未设定").replace("{{lon}}",data[i]['lon']).replace("{{lat}}",data[i]['lat'])
  261. switch (data[i]['status']+""){
  262. case "0":str=str.replace("{{status}}","未开始").replace("{{taskstatus}}","task_status_1");break;
  263. case "1":str=str.replace("{{status}}","进行中").replace("{{taskstatus}}","task_status_2");break;
  264. case "2":str=str.replace("{{status}}","暂停中").replace("{{taskstatus}}","task_status_4");break;
  265. case "3":str=str.replace("{{status}}","已完成").replace("{{taskstatus}}","task_status_3");break;
  266. }
  267. dataNames1.push(data[i]['title'])
  268. }
  269. }
  270. api.refreshHeaderLoadDone();
  271. if(page>=$api.getStorage("taskpage")&&$api.getStorage("taskpage")!=0){
  272. $(".nomore").removeClass("hid")
  273. }else {
  274. page++;
  275. }
  276. $(".task_con ul")[0].insertAdjacentHTML("beforeend",str);
  277. searchFn1(dataNames1)
  278. isreload=false;
  279. api.execScript({
  280. name: 'root',
  281. script: 'totalTime(0);'
  282. });
  283. });
  284. });
  285. api.addEventListener({
  286. name: 'refresh'
  287. }, function (ret, err) {
  288. var type=ret.value.task_type;
  289. var index=$api.getStorage("selectli");
  290. switch (type){
  291. case 0:$(".task_con li:eq("+index+")").find(".task_status")[0].className="task_status task_status_1";$(".task_con li:eq("+index+") .task_status span").text("未开始");break;
  292. case 1:$(".task_con li:eq("+index+")").find(".task_status")[0].className="task_status task_status_2";$(".task_con li:eq("+index+") .task_status span").text("进行中");break;
  293. case 2:$(".task_con li:eq("+index+")").find(".task_status")[0].className="task_status task_status_4";$(".task_con li:eq("+index+") .task_status span").text("暂停中");break;
  294. case 3:$(".task_con li:eq("+index+")").remove();break;
  295. }
  296. });
  297. function getData() {
  298. var postData={
  299. user_id:$api.getStorage("user").id,
  300. page:1,
  301. status:0
  302. };
  303. api.ajax({
  304. url: pageUrl+"/index/task/index",
  305. method: 'get',
  306. timeout: 30,
  307. dataType: 'text',
  308. returnAll: false,
  309. data: {
  310. values: {user_id:$api.getStorage("user").id, page:1, status:0,type:2}
  311. }
  312. }, function (data, err) {
  313. data=JSON.parse(data)
  314. // alert(JSON.stringify(data))
  315. $api.setStorage("taskpage",data["last_page"]);
  316. var data=data.data,str="";
  317. var dataNames1=[];
  318. if(!data.length){
  319. str="<p style='padding-top: 5.3rem;font-size: .5rem;text-align: center;color: #818181'>暂无任务</p>"
  320. }else {
  321. for(var i in data){
  322. str+=ulModel.replace("{{taskID}}",data[i]['id']).replace("{{name}}",data[i]['title']).replace("{{duty}}",data[i]['remark']).replace("{{enterprise}}",data[i]['address']).replace("{{type}}",data[i]['task_type']==1?"紧急":"常规").replace("{{statusclass}}",data[i]['task_type']==0?"task_dbqk1":"task_dbqk2")
  323. .replace("{{pssj}}",data[i]['start_time']?data[i]['start_time'].slice(0,16):"").replace("{{jhks}}",data[i]['created_at']?data[i]['created_at'].slice(0,16):"未设定").replace("{{lon}}",data[i]['lon']).replace("{{lat}}",data[i]['lat'])
  324. switch (data[i]['status']+""){
  325. case "0":str=str.replace("{{status}}","未开始").replace("{{taskstatus}}","task_status_1");break;
  326. case "1":str=str.replace("{{status}}","进行中").replace("{{taskstatus}}","task_status_2");break;
  327. case "2":str=str.replace("{{status}}","暂停中").replace("{{taskstatus}}","task_status_4");break;
  328. case "3":str=str.replace("{{status}}","已完成").replace("{{taskstatus}}","task_status_3");break;
  329. }
  330. dataNames1.push(data[i]['title'])
  331. }
  332. }
  333. api.refreshHeaderLoadDone();
  334. api.hideProgress();
  335. if(page>=$api.getStorage("taskpage")&&$api.getStorage("taskpage")!=0){
  336. $(".nomore").removeClass("hid")
  337. }else {
  338. page++;
  339. }
  340. $(".task_con ul").html(str).css("display","block");
  341. searchFn1(dataNames1)
  342. api.execScript({
  343. name: 'root',
  344. script: 'totalTime(0);'
  345. });
  346. });
  347. }
  348. function getTime(time) {
  349. var time=new Date(time*1000),str="";
  350. var year=time.getFullYear();
  351. var month=time.getMonth()+1;
  352. var day=time.getDate();
  353. var hours=time.getHours();
  354. var minutes=time.getMinutes();
  355. var str=year+"-"+checkTime(month)+"-"+checkTime(day)+" "+checkTime(hours)+":"+checkTime(minutes);
  356. return str;
  357. }
  358. function checkTime(val) {
  359. var val=val;
  360. if((val+"").length==1){
  361. val="0"+val;
  362. }
  363. return val
  364. }
  365. $(".task_con ul").on('click','li',function () {
  366. //在名为winName的window中执行jsfun脚本
  367. var jsfun1 = 'toFrame(6);',that=$(this).index();
  368. $api.setStorage("taskXQ",{taskID:this.dataset.taskid,lon:this.dataset.lon,lat:this.dataset.lat,tohome:false,taskType:"service"});
  369. api.execScript({
  370. script: jsfun1
  371. });
  372. })
  373. function searchFn1(dataNames) {
  374. api.addEventListener({name:"searchVal"},function (ret) {
  375. var re=new RegExp("("+ret.value.val+")"),liArr=[];
  376. for(var i=0;i<dataNames.length;i++){
  377. if(re.test(dataNames[i])){
  378. liArr.push($(".task_con ul li").get(i));
  379. }
  380. }
  381. if(!liArr.length){
  382. api.toast({
  383. msg: '没有搜索到该任务',
  384. duration: 2000,
  385. location: 'bottom'
  386. });
  387. }else {
  388. $(".task_con ul").html(" ");
  389. for(var j=0;j<liArr.length;j++){
  390. $(".task_con ul").append(liArr[j]);
  391. }
  392. }
  393. })
  394. }
  395. $("body").click(function () {
  396. api.sendEvent({
  397. name: 'clInput'
  398. });
  399. })
  400. api.addEventListener({
  401. name: 'refeshCheck'
  402. }, function (ret, err) {
  403. $(".nomore").addClass("hid");
  404. page=1;
  405. getData();
  406. });
  407. api.setRefreshHeaderInfo({
  408. loadingImg: 'widget://image/refresh.png',
  409. bgColor: '#fff',
  410. textColor: '#818181',
  411. textDown: '下拉刷新...',
  412. textUp: '松开刷新...'
  413. }, function(ret, err) {
  414. //在这里从服务器加载数据,加载完成后调用api.refreshHeaderLoadDone()方法恢复组件到默认状态
  415. $(".nomore").addClass("hid");
  416. page=1;
  417. getData();
  418. });
  419. api.addEventListener({
  420. name: 'reloadPage'
  421. }, function (ret, err) {
  422. api.closeFrame({
  423. name: 'task'
  424. });
  425. });
  426. }
  427. </script>
  428. </body>
  429. </html>