var url = null; var dateTime; //日期:yyyy-MM-dd var outRecordData = null; var data = { "interfaceId": "5204", "sign": "10204", "outId": "10204", "reqDateTime": new Date(), "tokenAuth": "", "data": { "deptId": "", "dateTime": '' } }; //初始化数据 function init() { var user = JSON.parse(localStorage.getItem('user')); var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId')); url = user.url + "/api-phone/v35/gateway"; data.tokenAuth = user.tokenAuth; data.data.deptId = selectDeptId; //获取当前天时间 dateTime = getDate(new Date()); $("#dateTime").val(dateTime); //获取出库记录 getOutRecordList(); } //查询出库记录 function getOutRecordList() { outRecordData = null; //赋值参数的日期 data.data.dateTime = dateTime; console.log(JSON.stringify(data.data), "inout-out-record") //请求 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") { console.log(JSON.stringify(result)) outRecordData = result.data; renderData(); } else { mui.toast(result.mag); renderData(); } }, error: function() { mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") } }) outRecordData = { "sum": "55", "listInout": [{ "id": "98", "plateNum": "39", "depotId": "83", "depotName": "能始际法高等", "foodVariety": "quis Ut", "foodVarietyName": "被龙济来", "recordWeight": "25", "completeTime": "1971-10-20 14:45:38" }, { "id": "37", "plateNum": "50", "depotId": "16", "depotName": "准民青共工", "foodVariety": "aliquip eiusmod laborum nulla", "foodVarietyName": "号走根形", "recordWeight": "30", "completeTime": "1971-04-09 06:42:06" } ], } } //渲染页面 function renderData() { var html = ''; var sumHtml = '0'; if(outRecordData){ sumHtml = outRecordData.sum; console.log() var outRecordList = outRecordData.listInout; if (outRecordList && outRecordList.length > 0) { $.each(outRecordList, function(index, item) { html += '
'; html += '
单据号: ' + item.id + '
'; html += '
完成时间:' + getStrDate(item.completeTime) + '
'; }) } else { html += '
所选日期暂无出库记录信息
'; } }else{ html += '
所选日期暂无出库记录信息
'; } $("#sum").html(sumHtml); $("#recordList").html(html); } //加减天 function addAndReduceMonth(tag) { var date = new Date(dateTime); date = date.setDate(date.getDate() + tag); date = new Date(date); dateTime = getDate(date); $("#dateTime").val(dateTime); getOutRecordList(); } //选择日期 function chooseDate() { var dtpicker = new mui.DtPicker({ type: "date" ,//设置日历初始视图模式 value: dateTime }) dtpicker.show(function(e) { dateTime = e.value; $("#dateTime").val(dateTime); }) getOutRecordList(); } //默认获取当前日期(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; } //获取日期格式(yyyy-MM-dd HH:mm) function getStrDate(tag) { var date = new Date(tag); var year = date.getFullYear(); var month, day, hour, min; month = date.getMonth() + 1; if (month >= 1 && month <= 9) { month = "0" + month; } day = date.getDate(); if (day >= 1 && day <= 9) { day = "0" + day; } hour = date.getHours(); if (hour >= 1 && hour <= 9) { hour = "0" + hour; } min = date.getMinutes(); if (min >= 1 && min <= 9) { min = "0" + min; } return year + "-" + month + "-" + day + " " + hour + ":" + min; } //滑动 mui('.mui-scroll-wrapper').scroll({ indicators: false, //是否显示滚动条 deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 bounce: false, //是否启用回弹 deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 });