之前为了保留老习俗,虚拟M采用了和M调用一样的约定,这样的好处是习惯上保持一致,小伙伴提出现在是java了,还这样约定方法太啰嗦,确实是有点啰嗦,进行了改进。
改进为三个参数的,方法可以写在任何继承BaseHttpHandler和BaseHttpHandlerNoSession的ashx实现类里面,这样的好处是:1、方法什么补啰嗦了 2.在页面的ashx就可以实现了,避免专门为虚拟M再创建一个类,比如查询和导出一般要同时给页面使用和导出查询使用。
同页面ashx就可以直接调用,效率更高
导出指定的时候指定页面后台类即可,虚拟M可以防止任意的后台业务脚本里
示例页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>JRTPrintTemplateEle供拷贝代码使用</title>
<link rel="shortcut icon" href="../../resource/common/images/favicon.ico" />
<script src="../../resource/common/js/JRTBSBase.js" type="text/javascript"></script>
<script src="../../jrtprint/js/JRTPrint.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
SYSPageCommonInfo.Init();
var BasePath = '';
var ResourcePath = '';
var WebServicAddress = SYSPageCommonInfo.Data.WebServicAddress;
var UserDR = SYSPageCommonInfo.Data.Sesssion.UserDR;
var GroupID = SYSPageCommonInfo.Data.Sesssion.GroupID;
var SessionStr = SYSPageCommonInfo.Data.SessionStr;
</script>
<script type="text/javascript">
//全局变量
var me = {
actionUrl: '../ashx/ashJRTPrintTemplateEle.ashx'
};
//jquery入口
$(function () {
//导出Excel
$("#btnExport").click(function () {
var para = {};
var tempPath = DealExportExcelTMPName("打印元素.xls");
JRTBasePrint('Export@' + WebServicAddress + '@jrtdemo.ashx.ashJRTPrintTemplateEle@QryPrintEle@' + JSON.stringify(para) + '@' + SessionStr + '@' + tempPath + '@0');
});
//导出Excel多模板
$("#btnExport1").click(function () {
var para = {};
var tempPath = DealExportExcelTMPName("打印元素多模板");
JRTBasePrint('Export@' + WebServicAddress + '@jrtdemo.ashx.ashJRTPrintTemplateEle@QryPrintEle@' + JSON.stringify(para) + '@' + SessionStr + '@' + tempPath + '@0');
});
//导出Excel无模板
$("#btnExport0").click(function () {
var para = {};
var tempPath = "";
JRTBasePrint('Export@' + WebServicAddress + '@jrtdemo.ashx.ashJRTPrintTemplateEle@QryPrintEle@' + JSON.stringify(para) + '@' + SessionStr + '@' + tempPath + '@0');
});
//打印预览
$("#btnPrintPreview").click(function () {
//0:打印所有报告 1:循环打印每一份报告
var printFlag = "0";
var userCode = "";
//打印参数
var paramList = "";
//PrintOut:打印 PrintPreview打印预览
var printType = "PrintPreview";
var printPara = "1";
var Param = printFlag + "@" + WebServicAddress + "@" + printPara + "@" + userCode + "@" + printType + "@" + paramList + "@vm.test.PrintBarCodeTest@GetData";
JRTBasePrint(Param);
});
//打印表格
$("#btnPrintPreviewGrid").click(function () {
//0:打印所有报告 1:循环打印每一份报告
var printFlag = "0";
var userCode = "";
//打印参数
var paramList = "";
//PrintOut:打印 PrintPreview打印预览
var printType = "PrintOut";
var printPara = "1";
var Param = printFlag + "@" + WebServicAddress + "@" + printPara + "@" + userCode + "@" + printType + "@" + paramList + "@vm.test.DrawGrid@GetData";
JRTBasePrint(Param);
});
//打印报告
$("#btnPrintReport").click(function () {
//0:打印所有报告 1:循环打印每一份报告
var printFlag = "0";
var userCode = "";
//打印参数
var paramList = "";
//PrintOut:打印 PrintPreview打印预览
var printType = "PrintOut";
var printPara = "1";
var Param = printFlag + "@" + WebServicAddress + "@" + printPara + "@" + userCode + "@" + printType + "@" + paramList + "@vm.test.PrintTemplateTest@GetData";
JRTBasePrint(Param);
});
//集中打印
$("#btnCenterPrint").click(function () {
//0:打印所有报告 1:循环打印每一份报告
var printFlag = "0";
var userCode = "";
//打印参数
var paramList = "";
//PrintOut:打印 PrintPreview打印预览
var printType = "PrintOut";
var printPara = "1";
var Param = printFlag + "@" + WebServicAddress + "@" + printPara + "@" + userCode + "@" + printType + "@" + paramList + "@vm.test.CenterPrintTest@GetData";
JRTBasePrint(Param);
});
//在线预览
$("#btnPrintPreviewInline").click(function () {
showwin("#winPrintPreview", "在线打印预览", '../../facade/form/frmJRTPrintDrawView.aspx?PrintDR=' + 1 + '&PrintClassName=vm.test.PrintBarCodeTest', 950, $(window).height() - 20, true, "10px");
});
//打印
$("#btnPrint").click(function () {
//0:打印所有报告 1:循环打印每一份报告
var printFlag = "0";
var userCode = "";
//打印参数
var paramList = "";
//PrintOut:打印 PrintPreview打印预览
var printType = "PrintOut";
var printPara = "1";
var Param = printFlag + "@" + WebServicAddress + "@" + printPara + "@" + userCode + "@" + printType + "@" + paramList + "@vm.test.PrintBarCodeTest@GetData";
JRTBasePrint(Param);
});
//PDF
$("#btnPDF").click(function () {
//0:打印所有报告 1:循环打印每一份报告
var printFlag = "0";
var userCode = "";
//打印参数
var paramList = "";
//PrintOut:打印 PrintPreview打印预览
var printType = "PDF#-1";
var printPara = "1";
var Param = printFlag + "@" + WebServicAddress + "@" + printPara + "@" + userCode + "@" + printType + "@" + paramList + "@vm.test.PrintBarCodeTest@GetData";
JRTBasePrint(Param);
});
//PDF弹窗
$("#btnPDFSave").click(function () {
//0:打印所有报告 1:循环打印每一份报告
var printFlag = "0";
var userCode = "";
//打印参数
var paramList = "";
//PrintOut:打印 PrintPreview打印预览
var printType = "PDF#0";
var printPara = "1";
var Param = printFlag + "@" + WebServicAddress + "@" + printPara + "@" + userCode + "@" + printType + "@" + paramList + "@vm.test.PrintBarCodeTest@GetData";
JRTBasePrint(Param);
});
//上传文件到文件服务
$("#btnUpfile").click(function () {
$("#file_upload").click();
});
//改名文件
$("#btnRenamefile").click(function () {
//往后台提交数据
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=ReNameImageFile',
success: function (data, status) {
$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
alert("成功");
}
});
});
//删除文件
$("#btnDeletefile").click(function () {
//往后台提交数据
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=DeleteImageFile',
success: function (data, status) {
$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
alert("成功");
}
});
});
//Excel得到JSON
$("#btnExcelGetJson").click(function () {
JRTGetExcelFileJson(function (retJson) {
alert(JSON.stringify(retJson));
});
});
//新增数据点击
$("#btnAddJRTPrintTemplateEle").click(function () {
$("#txtJRTPrintTemplateEleRowID").val("");
$('#winEditJRTPrintTemplateEle').window({
title: TranslateDataMTHD('Add Data', '新增数据', ''),
modal: true
});
});
//修改数据点击
$("#btnUpdateJRTPrintTemplateEle").click(function () {
UpdateJRTPrintTemplateEle();
});
//修改数据
function UpdateJRTPrintTemplateEle(row)
{
var selectRow = $('#dgJRTPrintTemplateEle').datagrid("getSelected");
if(row!=null)
{
selectRow=row;
}
if (selectRow == null) {
$.messager.alert(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Please select the data to modify', '请选择要修改的数据!', ''), 'info');
return;
}
$("#formJRTPrintTemplateEle").form('load', selectRow);
$('#winEditJRTPrintTemplateEle').window({
title: TranslateDataMTHD('Update Data', '修改数据', ''),
modal: true
});
}
//删除数据点击
$("#btnDeleteJRTPrintTemplateEle").click(function () {
var checkRow = $('#dgJRTPrintTemplateEle').datagrid("getChecked");
var selectRow = $('#dgJRTPrintTemplateEle').datagrid("getSelected");
if ((checkRow == null || checkRow.length == 0)&&selectRow==null) {
$.messager.alert(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Please select the data to delete', '请勾选要删除的数据!', ''), 'info');
return;
}
if ((checkRow == null || checkRow.length == 0)) {
checkRow=[selectRow];
}
var RowIDS = "";
for (var i = 0; i < checkRow.length; i++) {
if (i == 0) {
RowIDS = checkRow[i].RowID;
}
else {
RowIDS += "^" + checkRow[i].RowID;
}
}
$.messager.confirm(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Do you want to delete the selected data', '是否要删除选择的数据?', '') , function (r) {
if (r) {
//开启等待
$.messager.progress({ text: TranslateDataMTHD("Deleting data","正在删除数据", ""), interval: 500 });
setTimeout(function () {
$.messager.progress('close');
}, 8000);
//往后台提交数据
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=DeleteJRTPrintTemplateEle',
data: { RowIDS: RowIDS },
success: function (data, status) {
$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
if (!data.IsOk) {
$.messager.alert(TranslateDataMTHD("Error message", "错误提示", ""), TranslateDataMTHD("failed to dalete data, error message:", "删除失败,错误信息:", "") + data.Message);
}
else {
QryJRTPrintTemplateEle();
$.messager.show({
title: TranslateDataMTHD("Info", "提示", ""),
msg: TranslateDataMTHD("Successfully deleted!", "删除成功!", ""),
timeout: 500,
showType: 'slide'
});
}
}
});
}
});
});
//保存数据
$("#btnSaveJRTPrintTemplateEle").click(function () {
var saveData = jQuery.parseJSON($("#formJRTPrintTemplateEle").serializeObject());
//开启等待
$.messager.progress({ text: TranslateDataMTHD("Saving data","正在保存数据", ""), interval: 500 });
setTimeout(function () {
$.messager.progress('close');
}, 8000);
//往后台提交数据
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=SaveJRTPrintTemplateEle',
data: saveData,
success: function (data, status) {
$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
if (!data.IsOk) {
$.messager.alert(TranslateDataMTHD("Error message", "错误提示", ""), TranslateDataMTHD("failed to dalete data, error message:", "删除失败,错误信息:", "") + data.Message);
}
else {
QryJRTPrintTemplateEle();
$.messager.show({
title: TranslateDataMTHD("Info", "提示", ""),
msg: TranslateDataMTHD("Successfully saveed!", "保存成功!", ""),
timeout: 500,
showType: 'slide'
});
$('#winEditJRTPrintTemplateEle').window("close");
}
}
});
});
//关闭窗口
$("#btnCloseJRTPrintTemplateEle").click(function () {
$('#winEditJRTPrintTemplateEle').window("close");
});
//构造查询事件
$("#txtFilterJRTPrintTemplateEle").searchbox({
searcher: function (value, name) {
QryJRTPrintTemplateEle();
},
prompt: TranslateDataMTHD('Enter query', '回车查询', '')
});
//模板下拉表格渲染
$('#txtJRTPrintTemplateElePrintTemplateDR').combogrid({
panelWidth: 350,
idField: 'RowID',
width: 205,
textField: 'CName',
url: me.actionUrl + '?Method=CommonQueryView&data='+JSON.stringify({ ModelName: "JRTPrintTemplate", Pram: [], IsDisplayCount: false, Joiner: [], Operators: [] }),
columns: [[
{ field: 'RowID', title: '主键', width: 60 },
{ field: 'CName', title: '名称', width: 260 }
]]
});
$('#txtJRTPrintTemplateElePrintTemplateDR').combogrid("showSelectWin");
//JRTPrintTemplateEle表格
$('#dgJRTPrintTemplateEle').datagrid({
remoteSort:false,
singleSelect: true,
toolbar: "#dgJRTPrintTemplateEleToolBar",
fit: true,
onSelect: function (index, row) {
//方便拷贝到子表查询用
var selectJRTPrintTemplateEle=$('#dgJRTPrintTemplateEle').datagrid("getSelected");
},
onDblClickRow: function (index, row) {
UpdateJRTPrintTemplateEle(row);
},
columns: [[
{ field: 'ChkFlag', title: TranslateDataMTHD('Check', '选择', ''), width: 20, sortable: true, align: 'center', checkbox: true },
{ field: 'RowID', title: TranslateDataMTHD('RowID', '主键', '') , width: 150, sortable: true },
{ field: 'PrintTemplateDRName', title: TranslateDataMTHD('PrintTemplateDRName', '模板', '') , width: 150, sortable: true },
{ field: 'PrintType', title: TranslateDataMTHD('PrintType', '元素类型', '') , width: 150, sortable: true },
{ field: 'PrintX', title: TranslateDataMTHD('PrintX', 'X坐标', '') , width: 150, sortable: true },
{ field: 'PrintY', title: TranslateDataMTHD('PrintY', 'Y坐标', '') , width: 150, sortable: true },
{ field: 'PrintFont', title: TranslateDataMTHD('PrintFont', '打印字体', '') , width: 150, sortable: true },
{ field: 'PrintFontSize', title: TranslateDataMTHD('PrintFontSize', '打印字体大小', '') , width: 150, sortable: true },
{ field: 'PrintFontStyle', title: TranslateDataMTHD('PrintFontStyle', '打印字体样式', '') , width: 150, sortable: true },
{ field: 'PrintLength', title: TranslateDataMTHD('PrintLength', '打印长度', '') , width: 150, sortable: true },
{ field: 'PrintWidth', title: TranslateDataMTHD('PrintWidth', '元素宽度', '') , width: 150, sortable: true },
{ field: 'PrintHeight', title: TranslateDataMTHD('PrintHeight', '元素高度', '') , width: 150, sortable: true },
{ field: 'PrintText', title: TranslateDataMTHD('PrintText', '元素文本', '') , width: 150, sortable: true },
{ field: 'DataField', title: TranslateDataMTHD('DataField', '绑定属性', '') , width: 150, sortable: true },
{ field: 'PrintFlag', title: TranslateDataMTHD('PrintFlag', '特殊标志', '') , width: 150, sortable: true },
{ field: 'PrintAlignment', title: TranslateDataMTHD('PrintAlignment', '停靠方向', '') , width: 150, sortable: true },
{ field: 'LayOut', title: TranslateDataMTHD('LayOut', '布局方式', '') , width: 150, sortable: true },
{ field: 'Angle', title: TranslateDataMTHD('Angle', '旋转角度', '') , width: 150, sortable: true },
{ field: 'IsVShow', title: TranslateDataMTHD('IsVShow', '是否垂直显示', '') , width: 150, sortable: true },
{ field: 'Color', title: TranslateDataMTHD('Color', '颜色', '') , width: 150, sortable: true },
{ field: 'FixedReport', title: TranslateDataMTHD('FixedReport', '固定元素', '') , width: 150, sortable: true }
]]
});
//查询JRTPrintTemplateEle
function QryJRTPrintTemplateEle() {
var Filter = $("#txtFilterJRTPrintTemplateEle").searchbox("getValue");
//开启等待,默认注释,在单击事件调用的逻辑启用等待会冲掉双击事件,按需要开启
//$.messager.progress({ text: TranslateDataMTHD("Querying data","正在查询数据", ""), interval: 500 });
//setTimeout(function () {
//$.messager.progress('close');
//}, 8000);
$.ajax({
type: "post",
dataType: "json",
cache: false, //
async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
url: me.actionUrl + '?Method=QryJRTPrintTemplateEle',
data: { Filter: Filter },
success: function (data, status) {
//结束等待
//$.messager.progress('close');
if (!FilterBackData(data)) {
return;
}
$('#dgJRTPrintTemplateEle').datagrid("loadData", data);
}
});
};
//执行查询数据
QryJRTPrintTemplateEle();
});
//上传文件
function UpFile(a) {
var selectFiles = document.getElementById('file_upload').files;
if (selectFiles != null && selectFiles.length > 0) {
for (var i = 0; i < selectFiles.length; i++) {
var data = new FormData();
var file = selectFiles[i];
data.append("file", file);
ajaxLoading();
setTimeout(function () {
ajaxLoadEnd();
}, 4000);
var url = me.actionUrl + "?Method=UpImageFile";
var callback = function (retData) {
retData = JSON.parse(retData);
if (retData.IsOk) {
showInfo("上传成功!");
}
else {
showError(retData["Message"]);
}
ajaxLoadEnd();
};
JRTHttpSys(data, url, callback);
}
$("#file_upload").val("");
}
}
</script>
</head>
<body>
<div class="easyui-layout" fit="true" style="border: none;">
<div data-options="region:'center',title:''" style="border: none;">
<div id="dgJRTPrintTemplateEleToolBar" style="padding: 3px 0px 3px 10px;">
<a id="btnAddJRTPrintTemplateEle" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" plain="true" listranslate="html~Add">新增</a>
<a id="btnUpdateJRTPrintTemplateEle" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-write-order'" plain="true" listranslate="html~Mod">修改</a>
<a id="btnDeleteJRTPrintTemplateEle" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" plain="true" listranslate="html~Del">删除</a>
<input id="txtFilterJRTPrintTemplateEle" style="margin-left: 14px; width: 240px;"></input>
<a id="btnExport" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" plain="true" listranslate="html~Export">导出</a>
<a id="btnExport1" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" plain="true" listranslate="html~Export">多模板</a>
<a id="btnExport0" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" plain="true" listranslate="html~Export">无模板</a>
<a id="btnPrintPreview" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~PrintPreview">打印预览</a>
<a id="btnPrintPreviewInline" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~PrintPreview">在线预览</a>
<a id="btnPrint" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~Print">打印</a>
<a id="btnPDF" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~PDF">PDF</a>
<a id="btnPDFSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~PDF">PDF弹</a>
<a id="btnPrintPreviewGrid" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~PrintGrid">打表格</a>
<a id="btnPrintReport" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~PrintReport">打报告</a>
<a id="btnCenterPrint" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" plain="true" listranslate="html~CenterPrint">集中打印</a>
<a id="btnUpfile" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-file'" plain="true" listranslate="html~File">上传文件</a>
<input type="file" id="file_upload" name="f" onchange="UpFile(this);" accept="image/png,image/gif,image/jp2,image/jpeg,image/bmp" style="display: none" multiple="multiple" />
<a id="btnExcelGetJson" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" plain="true" listranslate="html~ExcelJson">ExcelJson</a>
<a id="btnRenamefile" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-file'" plain="true" listranslate="html~File">改名</a>
<a id="btnDeletefile" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-file'" plain="true" listranslate="html~File">删除</a>
</div>
<table id="dgJRTPrintTemplateEle" title="" iconcls="icon-paper" listranslate="title~JRTPrintTemplateEle"></table>
</div>
<div id="winEditJRTPrintTemplateEle" style="padding: 10px 0px 0px 10px;width:1140px;height:366.6666666666666667px;display: none;">
<form id="formJRTPrintTemplateEle" name="edit_form" method="post">
<input type="hidden" id="txtJRTPrintTemplateEleRowID" name="RowID" value="0" />
<table>
<tr>
<td class="lisar" jrttranslate="html~PrintTemplateDR">模板</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintTemplateDR" type="text" name="PrintTemplateDR" style="width:200px;"/></td>
<td class="lisar" jrttranslate="html~PrintType">元素类型</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintType" type="text" name="PrintType" style="width:200px;" class="easyui-validatebox" maxlength="20"/></td>
<td class="lisar" jrttranslate="html~PrintX">X坐标</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintX" type="text" name="PrintX" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~PrintY">Y坐标</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintY" type="text" name="PrintY" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~PrintFont">打印字体</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintFont" type="text" name="PrintFont" style="width:200px;" class="easyui-validatebox" maxlength="20"/></td>
<td class="lisar" jrttranslate="html~PrintFontSize">打印字体大小</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintFontSize" type="text" name="PrintFontSize" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~PrintFontStyle">打印字体样式</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintFontStyle" type="text" name="PrintFontStyle" style="width:200px;" class="easyui-validatebox" maxlength="20"/></td>
<td class="lisar" jrttranslate="html~PrintLength">打印长度</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintLength" type="text" name="PrintLength" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~PrintWidth">元素宽度</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintWidth" type="text" name="PrintWidth" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~PrintHeight">元素高度</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintHeight" type="text" name="PrintHeight" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~PrintText">元素文本</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintText" type="text" name="PrintText" style="width:200px;" class="easyui-validatebox" maxlength="2000"/></td>
<td class="lisar" jrttranslate="html~DataField">绑定属性</td>
<td class="lisal"><input id="txtJRTPrintTemplateEleDataField" type="text" name="DataField" style="width:200px;" class="easyui-validatebox" maxlength="500"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~PrintFlag">特殊标志</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintFlag" type="text" name="PrintFlag" style="width:200px;" class="easyui-validatebox" maxlength="50"/></td>
<td class="lisar" jrttranslate="html~PrintAlignment">停靠方向</td>
<td class="lisal"><input id="txtJRTPrintTemplateElePrintAlignment" type="text" name="PrintAlignment" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~LayOut">布局方式</td>
<td class="lisal"><input id="txtJRTPrintTemplateEleLayOut" type="text" name="LayOut" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~Angle">旋转角度</td>
<td class="lisal"><input id="txtJRTPrintTemplateEleAngle" type="text" name="Angle" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~IsVShow">是否垂直显示</td>
<td class="lisal"><input id="txtJRTPrintTemplateEleIsVShow" type="text" name="IsVShow" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
<td class="lisar" jrttranslate="html~Color">颜色</td>
<td class="lisal"><input id="txtJRTPrintTemplateEleColor" type="text" name="Color" style="width:200px;" class="easyui-validatebox" maxlength="30"/></td>
</tr>
<tr>
<td class="lisar" jrttranslate="html~FixedReport">固定元素</td>
<td class="lisal"><input id="txtJRTPrintTemplateEleFixedReport" type="text" name="FixedReport" style="width:200px;" class="easyui-validatebox" maxlength="10"/></td>
</table>
<div region="south" border="fale" style="text-align: center; padding: 5px 0 0;">
<a id="btnSaveJRTPrintTemplateEle" href="#" class="easyui-linkbutton" plain="false" listranslate="html~Save">保存</a>
<span class="sp6"></span>
<a id="btnCloseJRTPrintTemplateEle" href="#" class="easyui-linkbutton" plain="false" listranslate="html~Cancel">取消</a>
</div>
</form>
</div>
<div id="winPrintPreview" style="padding: 10px 0px 0px 10px; width: 1140px; height: 786px; display: none;">
</div>
</div>
</body>
</html>
示例后台
import JRT.Core.Dto.OutValue;
import JRT.Core.MultiPlatform.FileCollection;
import JRT.Model.Bussiness.Parameters;
import JRTBLLBase.BaseHttpHandler;
import JRTBLLBase.Helper;
import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.ParamDto;
import JRT.Core.Dto.OutParam;
import JRT.Model.Entity.*;
import JRT.Core.Util.Convert;
import JRT.Core.MultiPlatform.JRTContext;
import java.util.ArrayList;
import java.util.List;
/**
*由代码生成器生成的后台代码
*/
public class ashJRTPrintTemplateEle extends BaseHttpHandler {
/**
* 保存数据,前台按表的属性名提交
* @return 字符串
*/
public String SaveJRTPrintTemplateEle() throws Exception
{
JRTPrintTemplateEle dto=new JRTPrintTemplateEle();
//主键
dto.RowID=Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), dto.RowID);
//模板
dto.PrintTemplateDR=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintTemplateDR"), dto.PrintTemplateDR);
//元素类型
dto.PrintType=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintType"), dto.PrintType);
//X坐标
dto.PrintX=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintX"), dto.PrintX);
//Y坐标
dto.PrintY=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintY"), dto.PrintY);
//打印字体
dto.PrintFont=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintFont"), dto.PrintFont);
//打印字体大小
dto.PrintFontSize=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintFontSize"), dto.PrintFontSize);
//打印字体样式
dto.PrintFontStyle=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintFontStyle"), dto.PrintFontStyle);
//打印长度
dto.PrintLength=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintLength"), dto.PrintLength);
//元素宽度
dto.PrintWidth=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintWidth"), dto.PrintWidth);
//元素高度
dto.PrintHeight=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintHeight"), dto.PrintHeight);
//元素文本
dto.PrintText=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintText"), dto.PrintText);
//绑定属性
dto.DataField=Helper.ValidParam(JRTContext.GetRequest(Request, "DataField"), dto.DataField);
//特殊标志
dto.PrintFlag=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintFlag"), dto.PrintFlag);
//停靠方向
dto.PrintAlignment=Helper.ValidParam(JRTContext.GetRequest(Request, "PrintAlignment"), dto.PrintAlignment);
//布局方式
dto.LayOut=Helper.ValidParam(JRTContext.GetRequest(Request, "LayOut"), dto.LayOut);
//旋转角度
dto.Angle=Helper.ValidParam(JRTContext.GetRequest(Request, "Angle"), dto.Angle);
//是否垂直显示
dto.IsVShow=Helper.ValidParam(JRTContext.GetRequest(Request, "IsVShow"), dto.IsVShow);
//颜色
dto.Color=Helper.ValidParam(JRTContext.GetRequest(Request, "Color"), dto.Color);
//固定元素
dto.FixedReport=Helper.ValidParam(JRTContext.GetRequest(Request, "FixedReport"), dto.FixedReport);
OutParam out=new OutParam();
int ret=0;
//更新
if(dto.RowID>0)
{
ret=EntityManager().Update(dto,null, out, null, null, null);
}
//插入数据
else
{
ret=EntityManager().Save(dto,out);
}
if(ret==1)
{
return Helper.Success();
}
else
{
return Helper.Error(out);
}
}
/**
* 删除数据,多个RowID以上尖号分割
* @return 字符串
*/
public String DeleteJRTPrintTemplateEle() throws Exception
{
String RowIDS=Helper.ValidParam(JRTContext.GetRequest(Request, "RowIDS"), "");
if(RowIDS.isEmpty())
{
return Helper.Error("请传入要删除数据的RowID,多个以^分割!");
}
//分割主键
String [] arr=RowIDS.split("^");
//out参数
OutParam out=new OutParam();
//循环删除数据
for(int i=0;i<arr.length;i++)
{
int ret=EntityManager().RemoveById(JRTPrintTemplateEle.class,Convert.ToInt32(arr[i]),out);
if(ret!=1)
{
return Helper.Error(out);
}
}
return Helper.Success();
}
/**
* 查询数据,前台按表的属性名提交
* @return 字符串
*/
public String QryJRTPrintTemplateEle() throws Exception
{
//模糊查询
String Filter=Helper.ValidParam(JRTContext.GetRequest(Request, "Filter"), "");
Parameters para=new Parameters();
para.P0=Filter;
para.P1="1";
//调虚拟M查询数据,和导出共用逻辑
return QryPrintEle(para,null,null);
}
/**
* 上传文件到文件服务
* @return
*/
public String UpImageFile() throws Exception
{
//得到文件
List<FileCollection> fileList=JRT.Core.MultiPlatform.JRTWebFile.GetFiles(Request);
if(fileList!=null&&fileList.size()>0)
{
JRT.Core.MultiPlatform.FileService fileService=new JRT.Core.MultiPlatform.FileService();
fileService.Upload("http://localhost:8080/JRTWeb/FileService/",fileList.get(0).GetInputStream(),fileList.get(0).GetFileName(),"/zlz");
}
return Helper.Success();
}
/**
* 改名文件
* @return
*/
public String ReNameImageFile() throws Exception
{
JRT.Core.MultiPlatform.FileService fileService=new JRT.Core.MultiPlatform.FileService();
fileService.ReName("http://localhost:8080/JRTWeb/FileService/","logo.png","logo1.png","zlz/");
return Helper.Success();
}
/**
* 删除文件
* @return
*/
public String DeleteImageFile() throws Exception
{
JRT.Core.MultiPlatform.FileService fileService=new JRT.Core.MultiPlatform.FileService();
fileService.Delete("http://localhost:8080/JRTWeb/FileService/zlz/logo.png");
fileService.Delete("http://localhost:8080/JRTWeb/FileService/zlz/logo1.png");
return Helper.Success();
}
/**
* 测试日期时间转JSON
* @return
* @throws Exception
*/
public String JsonTest() throws Exception
{
List<JRTPrintTemplate> list=EntityManager().FindAllSimple(JRTPrintTemplate.class,null);
return Helper.Object2Json(list);
}
/**
* 查询所有打印元素数据导出到Excel
*
* @param Param 参数
* @param Session
* @param Output
* @return
*/
public String QryPrintEle(Parameters Param, OutValue Session, OutValue Output) throws Exception {
if (Session != null) {
//返回的参数,供Excel模板使用
Session.Value = "元素数据导出^" + JRT.Core.Util.TimeParser.GetNowDate() + "^张联珠";
}
String Filter=Param.P0;
String DisplayCount=Param.P1;
//参数
List<ParamDto> para = new ArrayList<>();
//sql连接符号
List<String> joiner = new ArrayList<>();
//sql比较符号
List<String> operators = new ArrayList<>();
boolean displayCount = false;
if (DisplayCount.equals("1")) {
displayCount = true;
}
//模糊查询
if (!Filter.isEmpty()) {
ParamDto p = null;
//元素类型
p = new ParamDto();
p.Key = "PrintType";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//打印字体
p = new ParamDto();
p.Key = "PrintFont";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//打印字体大小
p = new ParamDto();
p.Key = "PrintFontSize";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//打印字体样式
p = new ParamDto();
p.Key = "PrintFontStyle";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//元素文本
p = new ParamDto();
p.Key = "PrintText";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//绑定属性
p = new ParamDto();
p.Key = "DataField";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//特殊标志
p = new ParamDto();
p.Key = "PrintFlag";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//停靠方向
p = new ParamDto();
p.Key = "PrintAlignment";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//布局方式
p = new ParamDto();
p.Key = "LayOut";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//旋转角度
p = new ParamDto();
p.Key = "Angle";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//是否垂直显示
p = new ParamDto();
p.Key = "IsVShow";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//颜色
p = new ParamDto();
p.Key = "Color";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
//固定元素
p = new ParamDto();
p.Key = "FixedReport";
p.Value = "%" + Filter + "%";
para.add(p);
joiner.add("or");
operators.add("like");
}
//调用查询
String json = EntityManager().QueryAllWithFK(JRTPrintTemplateEle.class, para, "", displayCount, -1, -1, "", joiner, operators);
return json;
}
}