shr.defineClass("shr.compensation.BatchSubmitShemeBillListEx", shr.compensation.BatchSubmitShemeBillList, {
	initalizeDOM: function () {
		shr.compensation.BatchSubmitShemeBillListEx.superClass.initalizeDOM.call(this);
		var _self = this;
		//
		$("#submitShemeTemplate").shrPromptBox("option", {
			//
			afterOnSelectRowHandler: function (event, data) {
				console.log(data.value.id);
				$.block.show({
					text: '正在生成套打附件，请稍候... <br/> Generating print attachment, please wait...'
				});
				_self.remoteCall({
					method: "customPrint",
					param: {
						submitShemeTemplateId: data.value.id,
						billIds: _self.getSelectedIds()
					},
					success: function (data) {
						window.open(data);
					},
					complete(data) {
						$.block.hide();
					},
				});
			}
		});
	},
	/**
	 * 模板打印
	 */
	customPrintAction: function () {
		var _self = this;
		//获取选中行id数组
		var idArray = _self.getSelectedFields("id");
		if (idArray.length == 0) {
			shr.showError({
				message: "请选择需要打印的单据！</br> You must select at least one record!",
			});
			return;
		}
		var submitSchemeId;
		var isError = false;
		var errorMsg = "";
		//遍历选中行
		idArray.forEach(function (rowid) {
			//提报方案id
			var submitSchemeIdNew = $("#grid").jqGrid("getCell", rowid, "submitScheme.id");
			if (!submitSchemeIdNew) {
				isError = true;
				errorMsg = "没有找到提报方案id,请检查！ </br> No submit scheme id found, please check!";
				return;
			}
			if (submitSchemeId == undefined) {
				submitSchemeId = submitSchemeIdNew;
			} else if (submitSchemeId != submitSchemeIdNew) {
				isError = true;
				errorMsg = "请选择相同提报方案的单据进行打印！ </br> Please select the records with the same submit scheme for printing!";
				return;
			}
		})
		if (isError) {
			shr.showError({
				message: "请选择相同提报方案的单据进行打印！ </br> Please select the records with the same submit scheme for printing!",
				hideAfter: 5
			});
			return;
		} else {
			//设置过滤条件
			$("#submitShemeTemplate").shrPromptBox("setFilter", "calSubmitScheme.id = '" + submitSchemeId + "' and state = '1'");
			//打开选择框
			$("#submitShemeTemplate").shrPromptBox("open");
		}
	},
});