1.dareway
function exportPdfFromView(filebase64, bzbh, wjmc){
var elemIF = document.createElement("iframe");
var url = new URL("gaSigFileUT.do?method=savePdfFromView");
url.addPara("filebase64", filebase64);
url.addPara("bzbh", bzbh);
var urlString = url.getURLString();
var result = AjaxUtil.ajaxRequest(urlString);
if (!AjaxUtil.checkException(result)) {
AjaxUtil.showException(result);
return;
}
var vdo = JSON.parse(result);
var bzbh = vdo.bzbh;
elemIF.src = "gaSigFileUT.do?method=exportPdfFromView&bzbh="+bzbh + "&__usersession_uuid=" + _GAUuuid + "&wjmc=" + wjmc;
elemIF.style.display = "none";
document.body.appendChild(elemIF);
}
public ModelAndView exportPdfFromView(HttpServletRequest request,
HttpServletResponse response, DataObject para) throws Exception {
String bzbh = para.getString("bzbh","");
String wjmc = para.getString("wjmc","");
byte[] blob = GABusUtil.getBillReport(bzbh);
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition","attachment; filename=" +URLEncoder.encode(wjmc, "UTF-8"));
OutputStream toClient=response.getOutputStream(); //得到向客户端输出二进制数据的对象
toClient.write(blob);
toClient.close();
return null;
}
2.
public static void downLoadFile(HttpServletResponse response, byte[] blob, String fileName) throws Exception{
try {
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
OutputStream toClient=response.getOutputStream(); //得到向客户端输出二进制数据的对象
toClient.write(blob);
toClient.close();
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="lib/layui/css/layui.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="lib/jquery-2.1.4.min.js"></script>
<link rel="stylesheet" href="lib/vue/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="lib/vue/vue.js"></script>
<script src="lib/vue/element.js"></script>
<script type="text/javascript" src="lib/config/basUrl.js"></script>
<script src="lib/layui/layui.js"></script>
<script type="text/javascript" src="lib/echarts.min.js"></script>
<style>
.table-wrapper {width: 80%;}
.table-wrapper table {
table-layout: fixed;width: 100%;text-align: left;font-size: 10px;border: 1px solid pink;
}
.table-wrapper table tbody{
display: inline-block;width: 100%;overflow: auto;max-height: 1000px;
}
.table-wrapper table tr{
display: inline-block;width: 100%;border-bottom: 1px solid #ddd;height: 40px;line-height: 40px;
}
.table-wrapper table td, .table-wrapper table th {
display: inline-block;width: 14.38%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.table-wrapper table td:nth-child(1), .table-wrapper table th:nth-child(1) {
width: 30px;
}
</style>
</head>
<body>
<div id="app" class="layui-tab-content">
<el-form ref="form" :model="form" label-width="140px">
<el-row :gutter="10">
<el-col :span="2">
<el-input placeholder="作者" v-model="author" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="2">
<el-input placeholder="邮件" v-model="email" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="sys_role">
<el-input placeholder="表名" v-model="tableName" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="sys_">
<el-input placeholder="表名前缀" v-model="tableNamePrefix" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="dev.bcl.ysl.module">
<el-input placeholder="基础包名" v-model="basePkg" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="system">
<el-input placeholder="模块名" v-model="moduleName" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="deleted">
<el-input placeholder="逻辑删除字段名" v-model="logicDelName" clearable></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="3">
<el-input placeholder="表名模糊筛选" v-model="tablenamelike" clearable></el-input>
</el-col>
<el-col :span="2">
<el-button type="primary" @click="chaxun">查数据库表</el-button>
</el-col>
<el-col :span="3">
<el-button type="primary" @click="create">生成代码</el-button>
</el-col>
</el-row>
</el-form>
<div class="table-wrapper">
<table class="layui-table" onclick="">
<thead>
<tr>
<th rowspan="2">序号</th>
<th rowspan="2">表名</th>
<th rowspan="2">前缀</th>
<th rowspan="2">数据条数</th>
<th rowspan="2">表注释</th>
<th rowspan="2">创建时间</th>
<th rowspan="2">更新时间</th>
</tr>
</thead>
<tbody>
<tr v-for="(ss,index) in form" @click="fillTableDate(ss)">
<td>{{index+1}}</td>
<td >{{ss.name }}</td>
<td >{{ss.tableNamePrefix }}</td>
<td>{{ss.rows }}</td>
<td>{{ss.comment }}</td>
<td>{{ss.createTime }}</td>
<td>{{ss.updateTime }}</td>
</tr>
</tbody>
</table>
<div style="text-align: center">
<el-pagination
@current-change="PageC"
:current-page="currentPage1"
:page-size="100"
layout="total, prev, pager, next,jumper"
:total="total1">
</el-pagination>
</div>
</div>
</div>
<script>
let app=new Vue({
el: '#app',
data:function() {
return {
author:'',
email:'',
tablenamelike:'',
tableName:'',
basePkg:'',
moduleName:'',
tableNamePrefix:'',
logicDelName:'',
form:{
},
// obtainTime:getMonth().year+'-'+getMonth().month,// 搜索时间 默认时间当前年月 //`${new Date().getFullYear()}-${new Date().getMonth() + 1}`
ss:{},
currentPage1:1,// 当前页码
total1:0,
date:[],
idsx:{},
}
},
mounted:function() {
let that=this;
that.chaxun()
},
methods: {
PageC:function(e){
this.currentPage1=e;
this.chaxun()
},
chaxun:function(){
let that=this;
$.ajax({
url: requestURL+'admin/generator/getTableList',
type: "get",
dataType: "json",
data:{
tableName:that.tablenamelike,
index:that.currentPage1,
size:100,
},
success: function (data) {
if(data.code==200){
if(data.data){
that.form=data.data;
that.total1=data.total;
} else {
that.form = []
that.total1 = ''
}
}else {
}
}
});
},
fillTableDate:function(e){
let that=this;
that.tableName=e.name;
that.tableNamePrefix=e.tableNamePrefix;
},
create:function(name, type){
let that=this;
let link = document.createElement("a");
link.style.display = "none";
link.href = requestURL+'admin/generator/createTolocal'+'?basePkg='+that.basePkg+'&moduleName='+that.moduleName+'&tableNamePrefix='+that.tableNamePrefix+'&tableName='+that.tableName+'&logicDelName='+that.logicDelName+'&author='+that.author+'&email='+that.email;
document.body.appendChild(link);
link.click();
},
}
})
function traffic(e){
layer.msg(e)
app.chaxun()
}
function eerr(e){
layer.msg(e)
}
</script>
<script>
layui.use(['element', 'layer', 'laydate', 'form', 'table'], function() {
var element = layui.element,
laydate = layui.laydate,
table = layui.table;
});
</script>
</body>
</html>