apiready = function(){ ctrl = { prId: null, //配电室id keyword: '', // 关键字 init: {}, bind: {}, getList: {}, // 获取列表 renderList: {} // 渲染列表 } /** * 弹出提示框 */ ctrl.toast = function(msg) { api.toast({ msg: msg, duration: 3000, locaiton: 'top' }); } ctrl.init = function() { this.prId = api.pageParam.id; // 获取客户id this.bind(); this.getList(); } ctrl.bind = function() { // 搜索回路 $('#searchBox').on('input', function() { ctrl.keyword = $(this).val(); ctrl.getList(); }) // 下拉刷新 api.setRefreshHeaderInfo({ bgColor: "#CCCCCC", textColor: "#FFFFFF" }, function (ret, err) { ctrl.keyword = ''; $('#searchBox').val('') ctrl.getList(); }) var time = api.pageParam.time; // 当前报表的时间 // 点击每个回路 $('#list').on('touchend', '.item', function() { var id = $(this).data('prid'); var ddNum = $(this).data('ddh'); var location = $(this).data('location'); api.openWin({ name: 'reportData', url: './reportData.html', pageParam: { prid: id, time: time, ddNum: ddNum, location:location } }); }) } ctrl.getList = function() { var args = { prId: ctrl.prId, roleId: $api.getStorage('cusRoleType'), keyword: ctrl.keyword } var url = '/ems/rest/report/Ddn'; $api.get(url, args, function(data,err) { api.refreshHeaderLoadDone(); if(err) { toast('网络请求失败'); }else { if(data.code === 200) { $("#list").empty(); if(!data.body || !data.body.length) { $('#empty-tips').css('display', 'block'); return; } $('#empty-tips').css('display', 'none'); ctrl.renderList(data.body); } } }) } ctrl.renderList = function(list) { var tpl = ''; tpl += '