dhtmlxCombo(select非数据库取值),导出excel功能,利用form表单传值getActualValue()到后台根据条件判断
前台jsp代码(引入文件和不相关文件略):
<div class="exm_1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="34"><img src="img/tp1.jpg" /></td>
<td style="background:url(img/tp2.jpg) repeat-x 0px 4px;"><span class="span01">查询条件</span></td>
<td width="4"><img src="img/tp3.jpg" /></td>
</tr>
</table>
<div class="exm_l3" style="margin-top:-5px">
<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center" class="table01">
<tr>
<td height="30" width="65">查询时间:</td>
<td height="30" width="220">
<input type="text" name="datestr" id="startdate" style="width:90px"/> ~<input type="text" name="datestr" id="enddate" style="width:90px"/>
</td>
<td height="30" width="75" align="center">
查询类别:
</td>
<td id="statustd" width="70">
<select id="status">
<option value="0">全部</option>
<option value="1">门诊</option>
<option value="2">住院</option>
</select>
<td height="30" width="65" align="center">
统筹区:
</td>
<td id="tcqdm" width="90">
<select id="tcq">
<option value="000000">全部</option>
<option value="330803">衢江医保</option>
<option value="330824">开化医保</option>
<option value="330822">常山医保</option>
<option value="330825">龙游医保</option>
<option value="330881">江山医保</option>
<option value="330801">衢州医保</option>
<option value="330802">柯城医保</option>
</select>
<td height="30" width="80">交易流水号:</td>
<td height="30" width="80"><input id="jylsh" style="width:90px"></input></td>
<td width="10"></td>
<td>
<div id="hos_combo"></div>
</td>
<td width="60" align="right">
<input id="searchButton" class="btn01" type="button" value="查 询" οnclick="lookUp()"/>
<input id="exportButton" class="btn01" type="button" value="导 出" οnclick="exportExcel()"/>
</td>
</tr>
</table>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4" valign="top"><img src="img/bt1.jpg" /></td>
<td class="bgr"></td>
<td width="4" valign="top"><img src="img/bt3.jpg" /></td>
</tr>
</table>
</div>
<div class="exm_1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="34"><img src="img/tp1.jpg" /></td>
<td style="background:url(img/tp2.jpg) repeat-x 0px 4px;"><span class="span01">查询结果<span id="bxxx"></span></span></td>
<td width="4"><img src="img/tp3.jpg" /></td>
</tr>
</table>
<div id="mainDiv" class="exm_l3" style="margin-top:-5px;height:375px;padding:5px 10px 0px 10px">
<div id="gridbox" style="width:98.8%;height:340px;"></div>
<div id="pageDiv" style="float:right;height:26px;margin-top:6px;"></div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4" valign="top"><img src="img/bt1.jpg" /></td>
<td class="bgr"></td>
<td width="4" valign="top"><img src="img/bt3.jpg" /></td>
</tr>
</table>
</div>
<form id="dataForm" action="nus/Export.htm" method="post" style="display:none"> <span style="font-family: Arial, Helvetica, sans-serif;"><!--提交表单链接--></span>
<input type="hidden" name="startdate" id="stdate_"/>
<input type="hidden" name="enddate" id="enddate_"/>
<input type="hidden" name="jylsh" id="jylsh_"/><!--交易流水号-->
<input type="hidden" name="tcq" id="tcq_"/><!--统筹区-->
<input type="hidden" name="flag" id="flag_" /><!--查询类型-->
<input type="hidden" name="nodecode" id="nodecode_"/><!--医院-->
<input id="hosnum" type="hidden" value="${hosnum}"/>
<input id="hosname" type="hidden" value="${hosname}"/>
<input id="nodecode" type="hidden" value="${nodecode }"/>
</form>
var mygrid;//grid数据
var status_combo;//combo选项
var tcq_combo;//统筹区选项
var startdate="";//查询的日期,点击搜索以后赋值
var enddate="";
var falg="";//查询的类型
var pageSize=15;//每页显示条数
var jylsh="";
var hos_combo;
var tcq="";
$(function(){
status_combo = new dhtmlXCombo("status","status",70); //初始化combo
status_combo.readonly(true,false);
status_combo.setOptionHeight(70);
tcq_combo= new dhtmlXCombo("tcq","tcq",90);
tcq_combo.readonly(true,false);
tcq_combo.setOptionHeight(90);
});
$(document).ready(function(){
//初始化高度
$("#mainDiv").css("height",window.parent.document.documentElement.clientHeight-212);
$("#gridbox").css("height",window.parent.document.documentElement.clientHeight-247);
pageSize = (window.parent.document.documentElement.clientHeight-247)/27
pageSize = parseInt(pageSize);
myCalendar = new dhtmlXCalendarObject(["startdate","enddate"]);
myCalendar.setDateFormat("%Y-%m-%d");
myCalendar.loadUserLanguage("cn");
dhtmlXCalendarObject.prototype.langData["cn"] = {
monthesFNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
monthesSNames: ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
daysFNames: ["星期天","星期一","星期二","星期三","星期四","星期五","星期六"],
daysSNames: ["日","一","二","三","四","五","六"],
weekstart: 0
}
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("imgs/");
mygrid.setHeader("序号,来源,姓名,结算流水号,报销类型,状态,总费用,报销总金额,结算时间,统筹区");
mygrid.setInitWidths("40,60,100,100,*,80,120,80,180,80");
mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro");
mygrid.setColAlign("center,center,center,center,center,center,right,right,center,center");
mygrid.setSkin("dhx_custom");
mygrid.init();
hos_combo = new dhtmlXCombo("hos_combo", "alfa3", 150);
hos_combo.readonly(true);
hos_combo.setOptionHeight(200);
loadhospitals();
$("#next").attr("disabled",true);
});
function lookUp(){
//判断时间
startdate=$("#startdate").val();
enddate=$("#enddate").val();
if(startdate==''||enddate==''){
alert("请选择日期后查询");
return;
}
if(startdate>enddate){
alert("开始时间不能大于结束时间");
return;
}
$("#stdate_").val($("#startdate").val());
$("#enddate_").val($("#enddate").val());
$("#tcq_").val(tcq_combo.getSelectedValue());
$("#flag_").val(status_combo.getSelectedValue());//门诊OR住院
$("#nodecode_").val(hos_combo.getActualValue());
$("#jylsh_").val($("#jylsh").val());
jylsh=$("#jylsh").val();
falg=status_combo.getSelectedValue();
tcq=tcq_combo.getSelectedValue();
mygrid.clearAll();
loadDate();//加载数据
}
//发送请求获取数据总数
function loadDate(){
$.ajax({
url:"nus/lookuppaydetailscount.htm",
type:"post",
data:"flag="+falg+"&startdate="+startdate+"&enddate="+enddate+"&jylsh="+jylsh+"&nodecode="+hos_combo.getActualValue()+"&tcq="+tcq,
error:function(){
alert("获取数据失败");
},
success:function(reply){
if(reply==("fail")){
alert("服务器内部错误");
}else{
var js=eval(""+reply+"");
$("#pageDiv").pagination(parseInt(js[0].count), {
callback: lookupdate,
items_per_page:pageSize, //显示条数
prev_text: '上一页', //上一页按钮里text
next_text: '下一页', //下一页按钮里text
num_display_entries:8, //连续分页主体部分分页条目数
num_edge_entries: 2 //两侧首尾分页条目数
});
$("#bxxx").text(" 报销人数:"+parseInt(js[0].count)+" 总费用:"+js[0].fyze+" 报销金额:"+js[0].hjbxje+" 自付金额:"+js[0].hjxjzf +" 个帐支付:"+js[0].gzzf+" 统筹支付:"+js[0].tczf);
}
}
});
}
function lookupdate(index,jq){
$.ajax({
url:"nus/lookuppaydetails.htm",
type:"post",
data:"curPage="+index+"&pageSize="+pageSize+"&startdate="+startdate+"&enddate="+enddate+"&flag="+falg+"&time="+(new Date()).valueOf()+"&jylsh="+jylsh+"&nodecode="+hos_combo.getActualValue()+"&tcq="+tcq,
error:function() {
alert("获取数据失败");
},
success:function(reply) {
if(reply=="fail") {
alert("获取数据失败");
}else{
var js=eval(""+reply+"")
mygrid.clearAll();
var length=js.length;
for(var i=0;i<length;i++){
var tchy="柯城医保";
if("330803"==js[i].tcqbh){
tchy="衢江医保";
}else if("330824"==js[i].tcqbh){
tchy="开化医保";
}else if("330822"==js[i].tcqbh){
tchy="常山医保";
}else if("330825"==js[i].tcqbh){
tchy="龙游医保";
}else if("330881"==js[i].tcqbh){
tchy="江山医保";
}else if("330801"==js[i].tcqbh){
tchy="衢州医保";
}
mygrid.addRow(js[i].jslsh,[index*pageSize+i+1,js[i].lybz,js[i].name,js[i].jslsh,js[i].bxlx,updateZT(js[i].zdbz),js[i].zfy,js[i].bxzje,js[i].jssj,tchy]);
}
}
}
});
return false;
}
Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)){
format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(format)){
format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
}
}
return format;
}
function updateZT(zt){
if(zt=="Y"){
return "已成功";
}else if(zt=="N"){
return "未成功";
}else if(zt=="T"){
return "已退费";
}
}
function findSome(number){
if(number==null||number==""||number=='undefine' || isNaN(number)){
return "";
}else {
number=parseFloat(number);
return number.toFixed(2);
}
}
function loadhospitals(){
var nodecode=$("#nodecode").val();
var hosnum=$("#hosnum").val();
if(nodecode!=hosnum){
var hosname = $("#hosname").val();
hos_combo.addOption(nodecode,hosname);
}else{
$.ajax({
url:"farmDuizhang/loadHospitals.htm?nodecode="+nodecode,
async:false,
cache:false,
error:function(){
alert( "获取对账数据失败");
return false;
},
success: function(reply){
var jsons = eval("("+reply+")");
hos_combo.addOption("all","全部");
for(var i=0;i<jsons.length;i++){
hos_combo.addOption(jsons[i].nodecode,jsons[i].hosname);
}
}
});
}
hos_combo.setComboValue(nodecode);
}
function exportExcel(){
if($("#startdate").val()==''||$("#enddate").val()==''){
alert("请选择日期后导出");
return;
}
$("#dataForm")[0].submit(); //提交表单数据
}
@SuppressWarnings({ "unchecked", "unchecked" })
@RequestMapping(value = "/Export", method = RequestMethod.POST)
public void ExportChgDetail(HttpServletRequest request, HttpServletResponse response)throws Exception{
request.setCharacterEncoding("utf-8");
// response.setCharacterEncoding("utf-8");
Bas_hospitals bh = (Bas_hospitals) request.getSession().getAttribute("login_hospital");
String flag=request.getParameter("flag");//0:全部 1:门诊 2:住院
String startdate=request.getParameter("startdate");//日期
String enddate=request.getParameter("enddate");//日期
String jylsh = request.getParameter("jylsh");
String tcq=request.getParameter("tcq");//统筹区编码
// PrintWriter pw = response.getWriter(); //不注释报错,getwrite have already
DBOperator db=new DBOperator();
String nodecode = request.getParameter("nodecode");
List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
try{
if(flag!=null&&!flag.equals("")){
String selectsql="";
if(flag.equals("1")){ //根据前台combo传来的getActualValue()
selectsql=" and r.lybz='门诊' ";
}else if(flag.equals("2")){
selectsql=" and r.lybz='住院'";
}
if(jylsh!=null&&!jylsh.equals("")){
selectsql=" and r.jslsh='"+jylsh+"'";
}
if("all".equals(nodecode)){
selectsql=selectsql+" and r.hosnum='"+bh.getHosnum()+"'";
}else{
selectsql=selectsql+" and r.nodecode='"+nodecode+"'";
}
String tcqsql="";
if(tcq!=null && !"".equals(tcq) && !"000000".equals(tcq)){
tcqsql=" and r.tcqbh='"+tcq+"'";
}
String sql="select rownum,a.* from (select r.lybz,p.patname as name,r.jslsh,p.instype as bxlx,decode(r.zdbz,'Y','已成功','N','未成功','T','已退费') as zdbz,r.fyze as zfy,r.hjbxje as bxzje,to_char(r.jssj,'yyyy-MM-dd hh24:mi:ss') as jssj,decode(r.tcqbh,'330803','衢江医保','330824','开化医保','330822','常山医保','330825','龙游医保','330881','江山医保','330801','衢州医保','柯城医保') from his_yb_recon r left join bas_patient_ids i on r.cardno=i.idno and i.idtype='医保卡' left join bas_patients p on i.patientid=p.patientid where r.zdbz='Y' and to_char(r.jssj,'yyyy-mm-dd')>=? and to_char(r.jssj,'yyyy-mm-dd')<=? "+selectsql+tcqsql+") a ";
//decode(r.zdbz,'Y','已成功','N','未成功','T','已退费')表示,zdbz为y时,值为"已成功",为n时,值为"未成功",为t时,值为"已退费"
list=db.find(sql,new Object[]{startdate,enddate});
// list=db.find(sql);
response.setContentType("application/x-msdownload;charset=gbk");
String title="医保交易明细("+startdate+"~"+enddate+")";
String fileName = title+".xls";
String fileNameTemp = URLEncoder.encode(fileName, "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=" + new String(fileNameTemp.getBytes("utf-8"), "gbk"));
OutputStream os = response.getOutputStream();
ExcelUtils eu = new ExcelUtils();
eu.export(os, title, new String[]{"序号","来源","姓名","结算流水号","报销类型","状态","总费用","报销总金额","结算时间","统筹区"},
new int[]{10,14,25,25,25,25,20,20,30,18}, DbUtils.ListMapToListObject(list));
os.flush();
os.close();
}
} catch (Exception e) {
e.printStackTrace();
db.rollback();
}finally{
db.freeCon();
}
}