
shr.defineClass("shr.customer.gtiit.BatchSubmitShemeBillEx", shr.compensation.base.DefaultBatchSubmitShemeBill, {
	initalizeDOM: function() {
		var _self = this;
		shr.customer.gtiit.BatchSubmitShemeBillEx.superClass.initalizeDOM.call(_self);
		if(this.getOperateState() == 'ADDNEW' || this.getOperateState() == 'EDIT'){
			var datasource = _self.getFieldValue('datasource');
 			if (datasource == "") {
			    $("#datasource").shrSelect("setValue",2); 				
 			}
		} else {
			$("#availableBudget").hide();
		}
		// 字段授权
		_self.checkNoPermFields();
	},
	backToListAction: function(){
		document.location.href = shr.getContextPath() + "/dynamic.do?uipk=com.kingdee.shr.compensation.app.integrate.BatchSubmitShemeBill.whole.list&inFrame=true"
	},
	submitAction: function(event) {
		var _self = this;
		if (_self.validate() && _self.verify()) {

			var flag = _self.checkAmount();
			if(flag != null){
				shr.showWarning({message:"Line "+flag+": The submitted project must have a non empty one"});
				return false;
			}

			_self.preVerify(function(){			
				$.extend($.verifyRuleTool,_self.getVerifyOptions(submitNodeId))
				$.verifyRuleTool.afterVeriyCallBack =function(){
					shr.showConfirm($.shrI18n.common.tips.submitConfirm, function() {
						_self.doSubmit(event, 'submit');
					});
				};
				$.verifyRuleTool.verifyInto();
				$.verifyRuleTool.ip="submitShemeBill"
			},'submit')
		}
	},
	checkAmount:function(){
		var schemeItemField = "submitScheme";
		if(this.getOperateState() == 'EDIT' || this.getOperateState() == 'ADDNEW'){
			schemeItemField = schemeItemField+"_el";
		}
		var submitSchemeId = $("#"+schemeItemField).val();
		var flag = null;
		var schemeItemList = new Array();
		_self.remoteCall({
            type:"post",
            async: false,
            method:"getSchemeItemFilds",
            param:{calSchemeId:submitSchemeId},
            success:function(res){
                if(res.schemeItemList){
                     schemeItemList = res.schemeItemList;
                }
            }
        });
        if(!schemeItemList){
        	return flag;
        }
        var allRowData = $("#entry").jqGrid("getAllRowData");
        for(var i = 0; i < allRowData.length; i++){
        	var num = 0;
            for (const entryField of schemeItemList) {
			    var fieldValue = allRowData[i][entryField];
			    /*if(!fieldValue || fieldValue==0){
			    	num++;
			    }*/
				//20250326 改,数值可以为0; 但不能全空
			    if ( typeof fieldValue === 'number' && fieldValue === '' ){
					num++;	
				} else  if( (typeof fieldValue === 'string' && fieldValue == '' )||
						  (typeof fieldValue === 'object' && fieldValue == null && Object.keys(fieldValue).length == 0)) {
					num++;	
			    }


			}
			if(num == schemeItemList.length){
				flag = i+1;
				return flag;
			}
        }
        return flag;
	}
});