var that;
shr.defineClass("shr.dormitorysystem.WaterElectricityList",  shr.dormitorysystem.commonBatchListNew,{

    initalizeDOM: function () {
        shr.dormitorysystem.WaterElectricityList.superClass.initalizeDOM.call(this);
        that = this;
    },
    /**
     * 查看
     */
    viewAction: function (billId, rowid) {
        // 编辑界面禁用，则直接返回
        if (this.editViewDisable) {
            return;
        }
        var uipk = this.getEditUIPK();

        if("com.kingdee.eas.custom.dormitorysystem.waterelectricity.app.WaterElectricity.list"!=this.uipk){
            uipk=uipk.replace(".form",".edit.form");
        }
        this.reloadPage({
            uipk: uipk,
            billId: billId,
            method: 'view'
        });
    },
    /**
     * 锁定
     */
    lockAction: function () {
        //审核操作
        var fastFilterItems = this.getFastFilterItems();
        if (fastFilterItems) {
            fastFilterItems= JSON.stringifyOnce(fastFilterItems);
        }
        var ids=this.getSelectedIds();
        if(ids) {
            that.doRemoteWithBatchExtendAction({
                method: "lock",
                buttonName: 'lock',
                fastFilterItems: fastFilterItems,
                ids: ids,
            });
        }
    },
    /**
     * 解锁
     */
    unLockAction: function () {
        //审核操作
        var fastFilterItems = this.getFastFilterItems();
        if (fastFilterItems) {
            fastFilterItems= JSON.stringifyOnce(fastFilterItems);
        }
        var ids=this.getSelectedIds();
        if(ids){
            that.doRemoteWithBatchExtendAction({
                method: "unLock",
                buttonName: 'unLock',
                fastFilterItems:fastFilterItems,
                ids:ids,
            });
        }
    },
    /**
     * 计算
     */
    calculateAction: function () {
        this.createMonthAction();
    },
    /**
     * 审批操作
     */
    createMonthAction : function(){
        var _self = this;
       
            var day = new Date();
            var today = day.format("yyyy-MM");
            //添加选择月份弹框
            $("#periodDialog").remove();
            var $body = $(document.body);
            var dialog = _self.getPeriodDialog();
            var buttons = _self.getPeriodButtons();
            $body.append(dialog);
            showDialog("#periodDialog",
                "生成水电费数据",//'生成当月数据',
                dialog, buttons, 750, 300);
            var taxPeriodDate_json = {};
            taxPeriodDate_json.validate = "{required:true}";
            taxPeriodDate_json.id = "periodDate";
            taxPeriodDate_json.format = 'yyyy-mm';
            taxPeriodDate_json.maxDate = today;

            taxPeriodDate_json.isRemoveDay = true;
            taxPeriodDate_json.ctrlType = 'Date';
            $('#periodDate').shrDateTimePicker(taxPeriodDate_json);
            $('#periodDate').shrDateTimePicker("setValue",today);
        
    },
    getPeriodDialog: function() {
        var line = '选择月份'//'选择报送月份';
        var msg1 = '说明：';//'说明：';
        var msg2 = '1、	选择需要生成的月份；';//'1、	当月新增人员，或任职受雇从业信息有变更的人员需要进行人员报送；';
        var msg3 = '';//'2、	已报送成功的人员在发起下一次人员报送任务之前，始终有效，无需每月都报送。';
        var html = ['<div id="periodDialog" 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="periodDate" name="periodDate" 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;
    },
    getPeriodButtons: function() {
        var self = this;
        var buttons = [{
            text: '确定',//'确定',
            click: function() {
                var periodDate = $("#periodDate").shrDateTimePicker("getValue");
                if (periodDate == null) {
                    shr.showError({
                        message: "选择月份不能为空"//'选择报送月份不能为空'
                    });
                    return;
                }
                periodDate=periodDate.slice(0,periodDate.length-3);
                $("#periodDialog").dialog("close");
                shr.showInfo({
                    message: "生成中",
                    hideAfter : 100
                });
                self.doReport({periodDate:periodDate});
            }
        }];
        return buttons;
    },
    doReport: function(period){
        var _self = this;
        //调用后台人员申报接口
        that.doRemoteWithBatchExtendAction({
            method: "createMonth",
            buttonName: 'createMonth',
            periodDate: period.periodDate
        });
    },
    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;
	},
});