var yjId = $(window.parent.parent.document).find("input[id='taskSourceId']").attr("stationId"); 
var pers = []
var table,form,layer,laydate;
var times = getCurrentDateTimeArr();
layui.use(['form','layer','table', 'laydate'], function () {
    table = layui.table;
    form = layui.form;
	layer = layui.layer;
	laydate = layui.laydate;
	// 渲染时间选择器
	// laydate.render({
	//     elem: '#wagesMonth',
	//     type: 'month',
	//     format: 'yyyy-MM',
	//     fullPanel: true,
	// 	value: times[0] + "-" + times[1]
	// });

	//取消按钮点击
	$("#closeBt").click(() => {
		var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
		parent.layer.close(index); //再执行关闭
	})
	//保存按钮点击
	$("#submitBt").click(() => {
		save();
	})
	
    init();
});

//查询
function queryClick(){
	table.reload('layui_table', {
	    // //设定异步数据接口的额外参数
	    where: {
			'userName': $("#username").val(),
			'proName': $("#proName").val(),
			'yjId': yjId,
			'wagesMonth': $("#wagesMonth").val()
		}
	})
}
//重置
function resetClick(){
	$("#username").val('');
	$("#proName").val('');
	table.reload('layui_table', {
		where: {
			'userName': '',
			'proName': '',
			'yjId': yjId,
			'wagesMonth': times[0] + "-" + times[1]
		},
	})
}


//页面赋值
function setData(yjId,yjName,gsName,wagesMonth){
	$("#wagesMonth").val(wagesMonth);
	$.ajax({
	    type: 'POST',
	    url: PATH_URL + '/wages/getWagesNum',
	    contentType: "application/json; charset=utf-8",
	    data: JSON.stringify({"userName": '', "proName": '', "yjId": yjId, "wagesMonth": wagesMonth}),
	    success: function (data) {
			console.log('data:',data.data)
			if(data.code == '200'){
				$("#inspectionStation").text(yjName);
				$("#subComName").text(gsName);
				$("#proNum").text(data.data.proNum);
				$("#lineProtector").text(data.data.userNum);
				
				$("#allPriceNum").text(data.data.allPriceNum);
				$("#phonePriceNum").text(data.data.phonePriceNum);
				$("#rewardNum").text(data.data.rewardNum);
				$("#wagesNum").text(data.data.wagesNum);
			}
			
	    }
	})
	
}
    
/**
 * 初始化数据
 */
function init(){
      // 渲染表格
  table.render({
	id: 'layui_table',
    elem: '#table',
    url: PATH_URL + '/wages/getWagesById',
    where: {
		'yjId': yjId,
		'wagesMonth': $('#wagesMonth').val()
    },
    page: true, //开启分页
    method:'post',
    skin: 'line', // 表格样式
    cols: [[
        {
            title: '序号',
            field: 'zizeng',
            align: 'center',
            type: 'numbers'
        },
        {field:'userName', title: '姓 名',align: 'center',},
        {field:'idCard', title: '身份证号',align: 'center',},
        {field:'proName', title: '管辖线路名称',align: 'center',},
        {field:'phone', title: '手机号',align: 'center',},
        {field:'bank', title: '开户行',align: 'center',},
        {field:'bankCard', title: '银行卡号',align: 'center'},
        {field:'unionpayNum', title: '银联号',align: 'center'},
        {field:'xsNum', title: '巡视工作量（基*次）',align: 'center', },
        {field:'xsPrice', title: '约定巡视工价（元/(基*次)）',align: 'center', },
        {field:'txNum', title: '特巡工作量（人*天）',align: 'center', },
        {field:'txPrice', title: '约定特巡工价（元/(人*天)）',align: 'center', },
		{field:'allPrice', title: '合价（元）',align: 'center'},
		{field:'phonePrice', title: '通讯费',align: 'center'},
		{field:'reward', title: '奖惩',align: 'center'},
		{field:'remarks', title: '备注',align: 'center'},
		{field:'wages', title: '实发工资',align: 'center'},
    ]],
	done: function(res,curr,count){
		//checkPermission();
	}
  });
}

//判断是否为数字
function isNumber(variable){
	return !isNaN(Number(variable));
}

