shr.defineClass("shr.compensation.ERPManualLogList", shr.framework.List, {

    initalizeDOM: function () {
        shr.compensation.ERPManualLogList.superClass.initalizeDOM.call(this);
        var that = this;
    },
    /**
     * 审批操作
     */
    dataToERPAction : function(){
        var _self = this;
       
            var day = new Date();
            var today = day.format("yyyy-MM");
            //添加选择月份弹框
            $("#taxPeriodDialog").remove();
            var $body = $(document.body);
            var dialog = _self.getTaxPeriodDialog();
            var buttons = _self.getTaxPeriodButtons();
            $body.append(dialog);
            showDialog("#taxPeriodDialog",
                "薪酬数据同步",//'薪酬数据同步',
                dialog, buttons, 750, 300);
            var taxPeriodDate_json = {};
            taxPeriodDate_json.validate = "{required:true}";
            taxPeriodDate_json.id = "taxPeriodDate";
            taxPeriodDate_json.format = 'yyyy-mm';
            taxPeriodDate_json.maxDate = today;

            taxPeriodDate_json.isRemoveDay = true;
            taxPeriodDate_json.ctrlType = 'Date';
            $('#taxPeriodDate').shrDateTimePicker(taxPeriodDate_json);
            $('#taxPeriodDate').shrDateTimePicker("setValue",today);
        
    },
    getTaxPeriodDialog: function() {
        var line = '选择报送月份'//'选择报送月份';
        var msg1 = '说明：';//'说明：';
        var msg2 = '1、	选择需要触发薪酬数据同步的月份；';//'1、	当月新增人员，或任职受雇从业信息有变更的人员需要进行人员报送；';
        var msg3 = '';//'2、	已报送成功的人员在发起下一次人员报送任务之前，始终有效，无需每月都报送。';
        var html = ['<div id="taxPeriodDialog" style="padding:5px;">',
            '<div class="photoState" style="margin-left:0px;">',
            '<table width="100%">',
            '<tr>',
            '<td width="20%"><h6>' + line + '</h6></td>' ,
            '<td width="40%">',
            '<input type="text" id="taxPeriodDate" name="taxPeriodDate" class="input-height" style=""/>',
            '</td>',
            '<td width="40%"></td>',
            '</tr>',
            '</table>',
            '<div style="color:#428bca;width:auto;height:auto;">' +
            '<p>'+msg1+'</p>' +
            '<p>'+msg2+'</p>' +
            '<p>'+msg3+'</p>',
            '</div>',
            '</div>',
            '</div>'].join('');
        return html;
    },
    getTaxPeriodButtons: function() {
        var self = this;
        var buttons = [{
            text: '确定',//'确定',
            click: function() {
                var taxPeriodDate = $("#taxPeriodDate").shrDateTimePicker("getValue");
                if (taxPeriodDate == null) {
                    shr.showError({
                        message: "选择报送月份不能为空"//'选择报送月份不能为空'
                    });
                    return;
                }
                taxPeriodDate=taxPeriodDate.slice(0,taxPeriodDate.length-3);
                $("#taxPeriodDialog").dialog("close");
                self.doReport({taxPeriodDate:taxPeriodDate});
            }
        }];
        return buttons;
    },
    doReport: function(taxPeriodDate){
        var _self = this;
//		var serviceId =_self.getFieldValue("serviceID");
        var selectedRowsData = $('#grid').jqGrid('getSelectedRowsData');
        var temp = [];
        for(i=0; i<selectedRowsData.length; i++){

            var selectedData=selectedRowsData[i];
            temp.push(selectedData.id);
        }
        var selectedIds =temp.join(",");

        var param = _self.assembleFullQueryParam();
        param.selectedIds = selectedIds;
        param.taxPeriodDate=taxPeriodDate.taxPeriodDate;
        //调用后台人员申报接口
        _self.remoteCall({
            method : "dataToERP",
            param :param,
            success : function(response) {

                shr.showInfo({
//					message : "已提交系统进行人员报送，需要等待几分钟，可在执行任务监控中查看运行进度；报送完成后将会推送消息告知",
                    message : "已提交系统进行报送，需要等待几分钟，可在执行任务监控中查看运行进度；",
                    hideAfter : 10
                });
                return;
            }
        });
    },
    assembleFullQueryParam : function(){
		var _self = this;
		var postData=$('#grid').jqGrid("getGridParam","postData");
		$('#grid')._pingPostData(postData);		
		totalRecords = $('#grid').jqGrid('getGridParam', 'records');		
		var param = $.extend({}, postData);	
		var selectedIdsP = _self.getSelectedFields().toString();
		param.totalRecords =totalRecords;
		param.selectedData = selectedIdsP;
		param.page = 1;
		param.isAll = true;
		param.columnModel = "id";
		return param;
	},
});