let table, form, layer, laydate, rate, util; let pageNum = 1, limitSize = 10; $(function () { layui.use(['rate', 'layer', 'laydate', 'form', 'table', 'util'], function () { layer = layui.layer; rate = layui.rate; form = layui.form; laydate = layui.laydate; table = layui.table; util = layui.util; form.render(); pages(1, 10, 1); }); }); function pages(pageNum, pageSize, typeNum) { $.ajax({ headers: { "encrypt": sm3(JSON.stringify({})) }, url: dataUrl + "proteam/pot/uav/getUavBandProList" + '?token=' + token, type: 'POST', async: false, success: function (result) { if (result.code === 200) { if (result.rows) { initTable(result.rows, limitSize, pageNum) laypages(result.total, pageNum, limitSize) } } else if (result.code === 500) { layer.alert(result.msg, {icon: 2}) } else if (result.code === 401) { logout(1); } }, error: function () { } }); } function laypages(total, page, limit) { layui.use(['laypage'], function () { let laypage = layui.laypage; laypage.render({ elem: 'voi-page', count: total, curr: page, limit: limit, limits: [10,20,50,100,200,500], layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'], groups: 5, jump: function (obj, first) { if (!first) { pageNum = obj.curr, limitSize = obj.limit; pages(obj.curr, obj.limit, null); } } }); }) } function initTable(dataList, limit, page) { table.render({ elem: "#table", id: "table", height: "full-85", data: dataList, limit: limit, cols: [ [//表头 { field: "number", type: "numbers", title: "序号", minWidth: 100, unresize: true, align: "center", }, { field: "deviceName", title: "无人机名称", unresize: true, minWidth: 200, align: "center", }, { field: 'proName', title: "工程名称", unresize: true, minWidth: 200, align: "center", }, { title: "操作", unresize: true, minWidth: 200, align: "center", templet: function (d) { let cent = ''; if (isEmpty(d.proName)) { cent += '绑定'; } else { cent += '修改绑定'; } return cent; }, } ], ], done: function (res, curr, count) { for (let i = 0; i < res.data.length; i++) { rate.render({ elem: '#test' + i , value: res.data[i].zhpj / 2 , readonly: true , half: true, theme: '#2F82FB' }); table.render() } }, parseData: function (res) { console.log(res); return { "code": res.code === 200 ? 0 : res.code, "msg": res.msg, "count": res.total, "data": res.rows }; } }); } function band(type, deviceName, macId, proId) { let title = ''; if (type === 1) { title = '绑定'; } else { title = '修改绑定' } let height = '80%'; let width = '90%'; layer.open({ id: "band", title: title, type: 2, shade: 0.1, shadeClose: true, maxmin: true, content: 'band.html', area: [width, height], success: function (layero, index) { let body = layer.getChildFrame('body', index); let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法: iframeWin.setForm(macId, deviceName, proId);//调用子页面的方法,页面锁定 }, end: function () { pages(1, limitSize); } }); } // 关闭页面 function closePage() { let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 parent.layer.close(index); //再执行关闭 }