| var url = null; | 
| var dateTime; | 
| var warnList = null; | 
| var data = { | 
|     "interfaceId": "5801", | 
|     "tokenAuth": "", | 
|     "outId": "58011", | 
|     "reqDateTime": new Date(), | 
|     "data": { | 
|         "deptId": "", | 
|         "dataTime": "" | 
|     } | 
| }; | 
| var dataPop = { | 
|     "interfaceId": "5802", | 
|     "tokenAuth": "", | 
|     "outId": "58021", | 
|     "reqDateTime": new Date(), | 
|     "data": { | 
|         "id": "", | 
|         "status": "", | 
|         "remark": "" | 
|     } | 
| }; | 
|   | 
| function init() { | 
|   | 
|     console.log("init") | 
|     var user = JSON.parse(localStorage.getItem('user')); | 
|     var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId')); | 
|     data.tokenAuth = user.tokenAuth; | 
|     dataPop.tokenAuth = user.tokenAuth; | 
|     data.data.deptId = selectDeptId; | 
|     url = user.url + "/api-phone/v35/gateway"; | 
|   | 
|     dateTime = getDate(new Date()) | 
|     document.getElementById("date").value = dateTime | 
|   | 
|     //获取警告记录 | 
|     getWarnList(); | 
|   | 
| } | 
|   | 
|   | 
| //获取警告记录 | 
| function getWarnList() { | 
|     warnData = null; | 
|     //赋值参数的日期 | 
|     data.data.dateTime = dateTime; | 
|     //请求 | 
|     mui.ajax(url, { | 
|         type: "POST", | 
|         dataType: "json", | 
|         crossDomain: true, | 
|         contentType: "application/json;charset=utf-8", | 
|         data: JSON.stringify(data), | 
|         success: function(result) { | 
|             if (result.code == "0000") { | 
|                 warnList = result.data; | 
|                 console.log(warnList) | 
|                 renderWarn(); | 
|             } else { | 
|                 renderWarn(); | 
|                 mui.toast(result.msg); | 
|                 console.log(JSON.stringify(result)) | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") | 
|         } | 
|     }) | 
|     // warnList = [{ | 
|     //         "id": "88", | 
|     //         "name": "拉目些调", | 
|     //         "type": "nostrud", | 
|     //         "eventType": "cillumreprehenderitest", | 
|     //         "level": "1", | 
|     //         "status": "40", | 
|     //         "time": "2006-11-01 14:01:36", | 
|     //         "info": "dolor", | 
|     //         "depotId": "6", | 
|     //         "depotName": "", | 
|     //         "remark": "00000" | 
|     //     }, | 
|     //     { | 
|     //         "id": "56", | 
|     //         "name": "法都象叫与局", | 
|     //         "type": "cillumreprehenderitUt", | 
|     //         "eventType": "in", | 
|     //         "level": "2", | 
|     //         "status": "20", | 
|     //         "time": "1981-02-18 22:28:23", | 
|     //         "info": "deserunt Excepteur aliqua veniam commodo", | 
|     //         "depotId": "28", | 
|     //         "depotName": "龙用改素", | 
|     //         "remark": "1111" | 
|     //     }, { | 
|     //         "id": "72", | 
|     //         "name": "华林九别", | 
|     //         "type": "exdeseruntcillumeu", | 
|     //         "eventType": "aliqua sint dolor aute", | 
|     //         "level": "1", | 
|     //         "status": "10", | 
|     //         "time": "1978-07-23 12:17:27", | 
|     //         "info": "deserunt nostrud id tempor", | 
|     //         "depotId": "70", | 
|     //         "depotName": "县志选只", | 
|     //         "remark": "" | 
|     //     } | 
|     // ] | 
|   | 
| } | 
|   | 
|   | 
| //默认获取当天日期(yyyy-MM-dd) | 
| function getDate() { | 
|     var date = new Date(); | 
|     var year = date.getFullYear(); | 
|     var month, day; | 
|     month = date.getMonth() + 1; | 
|     if (month >= 1 && month <= 9) { | 
|         month = "0" + month; | 
|     } | 
|     day = date.getDate(); | 
|     if (day >= 1 && day <= 9) { | 
|         day = "0" + day; | 
|     } | 
|     return year + "-" + month + "-" + day | 
| } | 
| //默认获取当前日期(yyyy-MM-dd) | 
| function getDate(date) { | 
|     var year = date.getFullYear(); | 
|     var month, day; | 
|     month = date.getMonth() + 1; | 
|     if (month >= 1 && month <= 9) { | 
|         month = "0" + month; | 
|     } | 
|     day = date.getDate(); | 
|     if (day >= 1 && day <= 9) { | 
|         day = "0" + day; | 
|     } | 
|     return year + "-" + month + "-" + day; | 
| } | 
|   | 
| //加减天数 | 
| function addAndReduceMonth(tag) { | 
|     var date = new Date(dateTime); | 
|     date = date.setDate(date.getDate() + tag); | 
|     date = new Date(date); | 
|     dateTime = getDate(date); | 
|     document.getElementById("date").value = dateTime | 
|     //获取警告记录 | 
|     getWarnList(); | 
| } | 
|   | 
| function chooseDate() { | 
|     var dtpicker = new mui.DtPicker({ | 
|         type: "date", //设置日历初始视图模式  | 
|         // beginDate: new Date(2015, 04, 25), //设置开始日期  | 
|         // endDate: new Date(2016, 04, 25), //设置结束日期  | 
|         value: dateTime | 
|     }) | 
|     var time = dateTime | 
|     dtpicker.show(function(e) { | 
|         dateTime = e.value; | 
|         document.getElementById("date").value = e.value | 
|         if(time != dateTime){ | 
|             getWarnList(); | 
|         } | 
|     }) | 
| } | 
|   | 
| //渲染页面 | 
| function renderWarn() { | 
|     var html = ''; | 
|     if (warnList && warnList.length > 0) { | 
|         $.each(warnList, function(index, item) { | 
|             html += '<li><div class="con myfancy" id="'+item.id+'" remark="'+(item.remark == null ? "" : item.remark) +'" status="'+item.status+'" >'; | 
|             if (item.status == '10') { | 
|                 html += '<span class="type">未处理</span>'; | 
|             }else if (item.status == '20') { | 
|                 html += '<span class="type k">处理延迟</span>'; | 
|             }else if (item.status == '30') { | 
|                 html += '<span class="type k">已处理</span>'; | 
|             }else if (item.status == '40') { | 
|                 html += '<span class="type k">忽略</span>'; | 
|             } | 
|             html += '<div class="tit">警告名称: <span>' + item.name + '</span></div>'; | 
|             html += '<div class="txt">'; | 
|             html += '<div class="box"><div class="group c"><div class="desc">' + item.type + | 
|                 '</div><div class="ort">警告类型</div></div></div>'; | 
|             html += '<div class="box"><div class="group c1"><div class="desc">' + (item.depotName == null || | 
|                     item.depotName == "" ? "--" : item.depotName) + | 
|                 '</div><div class="ort">仓库名称</div></div></div>'; | 
|             if (item.level == '1') { | 
|                 html += | 
|                     '<div class="box"><div class="group level-2"><div class="desc">高级</div><div class="ort">警告级别</div></div></div></div>'; | 
|             } | 
|             if (item.level == '2') { | 
|                 html += | 
|                     '<div class="box"><div class="group level-1"><div class="desc">中级</div><div class="ort">警告级别</div></div></div></div>'; | 
|             } | 
|   | 
|             html += '<div class="tit coation">警告内容: <span>' + item.info + '</span></div>'; | 
|             html += '<div class="time">' + item.time + '</div></div></li>'; | 
|         }) | 
|     } else { | 
|         html += '<li><div class="con myfancy" id="0" remark="暂无警告信息" status="30">'; | 
|         html += '<span class="type k">已处理</span>'; | 
|         html += '<div class="tit">警告名称: <span>暂无警告信息</span></div>'; | 
|         html += '<div class="txt">'; | 
|         html += '<div class="box"><div class="group c"><div class="desc">--</div><div class="ort">警告类型</div></div></div>'; | 
|         html += '<div class="box"><div class="group c1"><div class="desc">--</div><div class="ort">仓库名称</div></div></div>'; | 
|         html += '<div class="box"><div class="group level-1"><div class="desc">无</div><div class="ort">警告级别</div></div></div></div>'; | 
|         html += '<div class="tit coation">警告内容: <span>无警告内容</span></div>'; | 
|         html += '<div class="time">'+dateTime+'</div></div></li>'; | 
|         // html += | 
|         //     '<li><div class="con myfancy" style="text-align: center;font-size: 20px;color:#dd524d">暂无警告信息</div></li>'; | 
|     } | 
|     $("#recordList").html(html); | 
| } | 
|   | 
|   | 
| //打开弹窗 | 
| mui(".mui-scroll-wrapper").on("tap", ".m-caution-mana ul li .myfancy", function() { | 
|     var warnId = this.getAttribute("id"); | 
|     var status = this.getAttribute("status"); | 
|     var remark = this.getAttribute("remark"); | 
|     dataPop.data.id = warnId; | 
|     var html = '' | 
|     if (status == '10') { | 
|         html += '<div type="button" class="mui-btn cancel"  onclick="handleWarn(\'' + 1 + '\')">忽略</div>' | 
|         html += '<div type="button" class="mui-btn confirm" onclick="handleWarn(\'' + 2 + '\')">处理</div>' | 
|     } | 
|     $("#handleWarn").html(html); | 
|     document.getElementById("textareaPop").value = remark; | 
|     $('#m-pop').css('display', 'flex'); | 
| }) | 
|   | 
| // //打开弹窗 | 
| // function openPop(warnId, remark, status) { | 
| //     dataPop.data.id = warnId; | 
| //     var html = '' | 
| //     if (status == '10') { | 
| //         html += '<div type="button" class="mui-btn cancel"  onclick="handleWarn(\'' + 1 + '\')">忽略</div>' | 
| //         html += '<div type="button" class="mui-btn confirm" onclick="handleWarn(\'' + 2 + '\')">处理</div>' | 
| //     } | 
| //     $("#handleWarn").html(html); | 
| //     document.getElementById("textareaPop").value = remark; | 
| //     $('#m-pop').css('display', 'flex'); | 
| // } | 
| //警告处理 | 
| function handleWarn(tag) { | 
|     if (tag == "1") { | 
|         dataPop.data.status = '40' | 
|         // mui.toast("忽略警告"); | 
|     } | 
|     if (tag == "2") { | 
|         dataPop.data.status = '30' | 
|         // mui.toast("警告处理"); | 
|     } | 
|     dataPop.data.remark = document.getElementById("textareaPop").value; | 
|     console.log(JSON.stringify(dataPop.data),"warn-list") | 
|     //请求 | 
|     mui.ajax(url, { | 
|         type: "POST", | 
|         dataType: "json", | 
|         crossDomain: true, | 
|         contentType: "application/json;charset=utf-8", | 
|         data: JSON.stringify(dataPop), | 
|         success: function(result) { | 
|             if (result.code == "0000") { | 
|                 mui.toast(result.msg); | 
|                 // console.log(JSON.stringify(result)) | 
|             } else { | 
|                 mui.toast(result.msg); | 
|                 // console.log(JSON.stringify(result)) | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") | 
|         } | 
|     }) | 
|     closePop(); | 
| } | 
| //关闭弹窗 | 
| function closePop() { | 
|     $("#m-pop").css('display', 'none'); | 
| } | 
| $('.pop-bg,.m-pop .close').click(function(e) { | 
|     e.stopPropagation(); | 
|     $('.m-pop').fadeOut(); | 
| }); | 
|   | 
|   | 
| //滑动 | 
| mui('.mui-scroll-wrapper').scroll({ | 
|     indicators: true, //是否显示滚动条 | 
|     deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 | 
|     bounce: false, //是否启用回弹 | 
|     deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 | 
| }); |