let form, table; let tableIns; let pageNum = 1; // 定义分页 layui.use(["form", "table"], function () { form = layui.form; table = layui.table; initTable(); getStatistics(); }); // 数据概览 function getStatistics() { let encryptedData = {}; let url = dataUrl + 'backstage/supApply/getStatistics?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData)); ajaxRequest(url, "GET", null, true, function () { }, function (result) { if (result.code === 200) { setNum(result.data); } }, function (xhr, status, error) { errorFn(xhr, status, error) }, null); // 数据概览赋值 function setNum(obj) { $('#num').html(parseInt(obj.proNum)); $('#num2').html(obj.needNum); $('#num3').html(parseInt(obj.supNum)); $('#num4').html('¥ ' + parseInt(obj.money)); $('#num5').html('¥ ' +parseInt(obj.yfkMoney)); $('#num6').html('¥ ' +parseInt(obj.dfkMoney)); } } // 查询/重置 function queryTable(type) { if (type === 1) { let supName = $('#supName').val(); let flag = checkValue(supName); if (flag) { $('#supName').val(''); return layer.msg('供应商查询包含特殊字符,请重新输入', { icon: 2 }); } let planCode = $('#planCode').val(); let flag2 = checkValue(planCode); if (flag2) { $('#planCode').val(''); return layer.msg('需求计划编号查询包含特殊字符,请重新输入', { icon: 2 }); } let proName = $('#proName').val(); let flag3 = checkValue(proName); if (flag3) { $('#proName').val(''); return layer.msg('工程查询查询包含特殊字符,请重新输入', { icon: 2 }); } reloadTable(1); } else if (type === 2) { $('#supName').val(''); $('#planCode').val(''); $('#proName').val(''); $('#isPay').val(''); layui.form.render(); reloadTable(1); } } // 刷新页面数据 function reloadData() { reloadTable(1); } // 重载表格 function reloadTable(pageNum) { table.reload("currentTableId", { page: { curr: pageNum ? pageNum : 1, }, where: { encryptedData: JSON.stringify({ 'supName': $('#supName').val(), 'planCode': $('#planCode').val(), 'proName': $('#proName').val(), 'isPay': $('#isPay').val() }), }, }, ); } // 初始化表格 function initTable() { tableIns = table.render({ elem: "#currentTableId", id: 'currentTableId', headers: { authorization: sessionStorage.getItem("gz-token"), }, height: "full-350", url: dataUrl + "backstage/supApply/getSupApplyStatistics", where: { encryptedData: JSON.stringify({ 'supName': $('#supName').val(), 'planCode': $('#planCode').val(), 'proName': $('#proName').val(), 'isPay': $('#isPay').val() }), }, request: { pageName: 'pageNum', limitName: 'pageSize' }, parseData: function (res) { // res 即为原始返回的数据 if (res.code === 401) { closeWindowOpen(); } return { "code": 0, // 解析接口状态 "msg": '获取成功', // 解析提示文本 "count": res.total, // 解析数据长度 "data": res.list // 解析数据列表 }; }, cols: [ [ { width: '5.9%', title: "序号", align: "center", templet: function (d) { return d.LAY_NUM; }, }, { field: "proName", width: '10%', title: "工程名称", unresize: true, align: "center", sort:true, }, { field: "planCode", width: '10%', title: "需求计划编号", unresize: true, align: "center", sort:true, templet: function (d) { let html = ""; html += "" + d.planCode + ""; return html; }, }, { field: "supName", width: '10%', title: "供应商名称", unresize: true, align: "center", sort:true, }, { field: "cgNum", title: "采购数量", width: '8%', unresize: true, align: "center", sort:true, }, { field: "money", width: '12%', title: "金额", unresize: true, align: "center", sort:true, templet: function (d) { return ' ¥ ' + (d.money ? d.money : 0); }, }, { field: "manager", width: '8%', title: "经办人", unresize: true, align: "center", sort:true, }, { field: "outTime", width: '10%', title: "经办时间", unresize: true, align: "center", sort:true, }, { field: "isPay", width: '8%', title: "是否已付款", unresize: true, sort:true, align: "center", templet: function (d) { if (d.isPay === '1') { return "已付"; } else if (d.isPay === '0') { return "待付"; } }, }, { field: "fkTime", width: '10%', title: "付款时间", unresize: true, align: "center", sort:true, }, { title: "操作", width: '8%', align: "center", unresize: true, templet: function (d) { let html = ""; html += "详情"; return html; }, }, ], ], limits: [10, 15, 20, 25, 50, 100], limit: 10, page: true, done: function (res, curr, count) { pageNum = tableIns.config.page.curr; table.resize("currentTableId"); }, }); } // 需求计划详情 function openPlanDetail(obj) { obj.id = obj.planId; obj.code = obj.planCode; openIframeByParamObj("planDetail", "安全工器具需求计划", "../aq_demand_plan/child/apply_plan_detail.html", "92%", "95%", obj); } // 详情 function settlementDetail(obj) { openIframeByParamObj("settlementDetail", "详情", "./child/settlement_detail.html", "92%", "95%", obj); } // 导出 function exportExcel() { let params = { 'supName': $('#supName').val(), 'planCode': $('#planCode').val(), 'proName': $('#proName').val(), 'isPay': $('#isPay').val() } let url = dataUrl + "backstage/supApply/export3"; exportExcelUtil(url, '供应商结算统计', JSON.stringify(params)); }