var pers = [] var table,form,laydate layui.use(['form','layer','table','laydate'], function () { table = layui.table; form = layui.form; laydate = layui.laydate //初始化日期选择框 laydate.render({ elem: '#dataTime', type: 'month', }); // 触发submit提交 按钮点击或者表单被执行提交时触发 form.on('submit(query)', function (data) { console.log("搜索") // 对表格进行重载。id 即 table表格的id table.reload('table', { // //设定异步数据接口的额外参数 page:{curr : 1} ,where: data.field }) return false; // 阻止表单跳转。如果需要表单跳转,去掉这段即可。 }); $("#reset").click(function(){ console.log("重置") $('#search1').val(''); $('#search2').val(''); $('#search3').val(''); let obj = { search1:'', search2:'', search3:'' } // 对表格进行重载。id 即 table表格的id table.reload('table', { // //设定异步数据接口的额外参数 page:{curr : 1} ,where: obj }) }) table.on('tool(table)', function (obj) { switch (obj.event) { case 'details': console.log('详情',obj) detailsView(obj.id) break; case 'uploadResult': console.log('上传结果',obj) updateView() break; } }); init(); }); // 静态数据 var tableData = [ {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '1'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '1'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '1'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '2'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '2'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '2'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '3'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '3'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '3'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '4'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '4'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '4'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '4'}, {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', workPlan: '21', subPerson: '郭福林', subTime: '2024-02-28 18:10:10', status: '4'} ]; /** * 初始化数据 */ function init(){ // 渲染表格 table.render({ elem: '#table', // url: "/sys/achievement", page: true, skin: 'line', // 表格样式 cols: [[ { title: '序号', field: 'zizeng', align: 'center', type: 'numbers', width: '5%' }, {field:'comName', title: '分公司',align: 'center',width: '15%'}, {field:'sName', title: '运检站',align: 'center',width: '15%'}, {field:'month', title: '月份',align: 'center',width: '6%'}, {field:'workPlan', title: '工程计划数量',align: 'center',width: '7%'}, {field:'subPerson', title: '提交人',align: 'center',width: '7%'}, {field:'subTime', title: '提交时间',align: 'center',width: '15%'}, { field: '', title: '审核状态', align: 'center', width: '10%', templet: function(d){ var status = d.status; var text; var color; var html = ""; if(status == '1'){ text = '已审核'; color = '#19BE6B'; } if(status == '2'){ text = '待审核'; color = '#FF9900'; } if(status == '3'){ text = '未通过'; color = '#F56C6C'; } if(status == '4'){ text = '已撤销'; color = '#999999'; } html += "" html += `  ` html += `${text}` html += "" return html; }, }, { field: '', title: '操作', align: 'center', width: '20%', templet: function(d){ var id= d.id; var status = d.status; var text; var html = ""; if(status == '1'){ //已审核 html += `` html += `` } if(status == '2'){ //待审核 html += `` html += `` html += `` } if(status == '3'){ //未通过 html += `` html += `` html += `` html += `` } if(status == '4'){ //已撤销 html += `` html += `` html += `` html += `` } return html; }, } ]], data: tableData }); } //详情 function detailsView(id) { /* $.ajax({ type: 'post', contentType: "application/x-www-form-urlencoded", url: oiPlanUrl + '/monthlyPlanSubmission/getDataById', dataType: 'json', data: { id: id }, success: function (data) { var index = layer.open({ title: ['详情', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'], type: 2, content: './wagesReport/producePayrollDetails.html', area: [width, height], maxmin: false, success: function (layero, index) { console.log(data); var myIframe = window[layero.find('iframe')[0]['name']]; myIframe.hideSubmit(); // var fnc = myIframe.setData(data.data); //aaa()为子页面的方法 }, }); } }) */ //测试 let height = '98%'; let width = '99%'; var index = layer.open({ title: ['月计划详情', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'], type: 2, content: './monthPlanDetails.html', area: [width, height], maxmin: false, success: function (layero, index) { // var myIframe = window[layero.find('iframe')[0]['name']]; // myIframe.hideSubmit(); // var fnc = myIframe.setData(data.data); //aaa()为子页面的方法 }, }); } //撤销 function revokeView(id){ layer.confirm("确定撤销吗?", {icon: 0}, function () { }) } //删除 function delData(id){ layer.confirm("确定删除吗?", {icon: 0}, function () { }) } //修改 function updateView(id) { let height = '98%'; let width = '99%'; /* $.ajax({ type: 'post', contentType: "application/x-www-form-urlencoded", url: oiPlanUrl + '/monthlyPlanSubmission/getDataById', dataType: 'json', data: { id: id }, success: function (data) { var index = layer.open({ title: ['巡视结果上传', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'], type: 2, content: './wagesReport/producePayrollDetails.html', area: [width, height], maxmin: false, success: function (layero, index) { console.log(data); var myIframe = window[layero.find('iframe')[0]['name']]; myIframe.hideSubmit(); // var fnc = myIframe.setData(data.data); //aaa()为子页面的方法 }, }); } }) */ //测试 var index = layer.open({ title: ['月计划上报', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'], type: 2, content: './updateMonthPlan.html', area: [width, height], maxmin: false, success: function (layero, index) { // var myIframe = window[layero.find('iframe')[0]['name']]; // myIframe.hideSubmit(); // var fnc = myIframe.setData(data.data); //aaa()为子页面的方法 }, }); } //新增月计划addMonthPlan function addMonthPlan(id) { let height = '98%'; let width = '99%'; var index = layer.open({ title: ['月计划上报', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'], type: 2, content: './addMonthPlan.html', area: [width, height], maxmin: false, success: function (layero, index) { // var myIframe = window[layero.find('iframe')[0]['name']]; // myIframe.hideSubmit(); // var fnc = myIframe.setData(data.data); //aaa()为子页面的方法 }, }); } //导入计划 function importData(){ let height = '98%'; let width = '62%'; var index = layer.open({ title: ['月计划上报', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'], type: 2, content: './monthPlanImport.html', area: [width, height], maxmin: false, success: function (layero, index) { // var myIframe = window[layero.find('iframe')[0]['name']]; // myIframe.hideSubmit(); // var fnc = myIframe.setData(data.data); //aaa()为子页面的方法 }, }); } //导出 function exportData(){ // let search1 = $('#search1').val(); // let search2 = $('#search2').val(); window.location.href = oiPlanUrl + "/monthlyPlanSubmission/export?token=" + token; }