
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
		})
	})
   
    init();
});

  // 静态数据
  var tableData = [
    {id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'},
	{id: 1, comName: '运检一公司',sName: '昆明运检一站', month: '2024-03', personNum: '21', stationNum: '2,810', specialPatrolNum: '235', messageCost: '1', bonusPenalty: '0', actualRelease: '3,055'}
  ];

    
/**
 * 初始化数据
 */
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'},
        {field:'sName', title: '运检站',align: 'center'},
        {field:'month', title: '月份',align: 'center'},
        {field:'personNum', title: '人数',align: 'center'},
        {field:'stationNum', title: '巡视运检站（基*次）',align: 'center'},
        {field:'specialPatrolNum', title: '特巡天数（人*天）',align: 'center'},
		{field:'messageCost', title: '通讯费',align: 'center'},
		{field:'bonusPenalty', title: '奖惩',align: 'center'},
		{field:'actualRelease', title: '实发金额',align: 'center'},
        {
            field: '',
            title: '操作',
            align: 'center',
			width: '20%',
            templet: function(d){
				var id= d.id;
				var html = `<button class="layui-btn layui-btn-sm" onclick="detailsView('${id}')">详情</button>`
            	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: './wagesStatisticsDetails.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;
}