update 适配 ruoyi 关于优化导出数据操作
This commit is contained in:
parent
64add90edd
commit
2781655b0a
@ -43,7 +43,7 @@ public class SysLogininforController extends BaseController {
|
||||
@ApiOperation("导出系统访问记录列表")
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysLogininfor logininfor, HttpServletResponse response) {
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);
|
||||
|
@ -43,7 +43,7 @@ public class SysOperlogController extends BaseController {
|
||||
@ApiOperation("导出操作日志记录列表")
|
||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysOperLog operLog, HttpServletResponse response) {
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);
|
||||
|
@ -47,7 +47,7 @@ public class SysConfigController extends BaseController {
|
||||
@ApiOperation("导出参数配置列表")
|
||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysConfig config, HttpServletResponse response) {
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
ExcelUtil.exportExcel(list, "参数数据", SysConfig.class, response);
|
||||
|
@ -47,7 +47,7 @@ public class SysDictDataController extends BaseController {
|
||||
@ApiOperation("导出字典数据列表")
|
||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysDictData dictData, HttpServletResponse response) {
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil.exportExcel(list, "字典数据", SysDictData.class, response);
|
||||
|
@ -44,7 +44,7 @@ public class SysDictTypeController extends BaseController {
|
||||
@ApiOperation("导出字典类型列表")
|
||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysDictType dictType, HttpServletResponse response) {
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil.exportExcel(list, "字典类型", SysDictType.class, response);
|
||||
|
@ -47,7 +47,7 @@ public class SysPostController extends BaseController {
|
||||
@ApiOperation("导出岗位列表")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysPost post, HttpServletResponse response) {
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil.exportExcel(list, "岗位数据", SysPost.class, response);
|
||||
|
@ -54,7 +54,7 @@ public class SysRoleController extends BaseController {
|
||||
@ApiOperation("导出角色信息列表")
|
||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysRole role, HttpServletResponse response) {
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil.exportExcel(list, "角色数据", SysRole.class, response);
|
||||
|
@ -67,7 +67,7 @@ public class SysUserController extends BaseController {
|
||||
@ApiOperation("导出用户列表")
|
||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysUser user, HttpServletResponse response) {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
|
||||
@ -98,7 +98,7 @@ public class SysUserController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("下载导入模板")
|
||||
@GetMapping("/importTemplate")
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class TestDemoController extends BaseController {
|
||||
@ApiOperation("导出测试单表列表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:demo:export')")
|
||||
@Log(title = "测试单表", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
public void export(@Validated TestDemoBo bo, HttpServletResponse response) {
|
||||
List<TestDemoVo> list = iTestDemoService.queryList(bo);
|
||||
// 测试雪花id导出
|
||||
|
@ -7,46 +7,6 @@ import { blobValidate } from "@/utils/ruoyi";
|
||||
const baseURL = process.env.VUE_APP_BASE_API
|
||||
|
||||
export default {
|
||||
excel(url, params) {
|
||||
// get请求映射params参数
|
||||
if (params) {
|
||||
let urlparams = url + '?';
|
||||
for (const propName of Object.keys(params)) {
|
||||
const value = params[propName];
|
||||
var part = encodeURIComponent(propName) + "=";
|
||||
if (value !== null && typeof(value) !== "undefined") {
|
||||
if (typeof value === 'object') {
|
||||
for (const key of Object.keys(value)) {
|
||||
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
|
||||
let params = propName + '[' + key + ']';
|
||||
let subPart = encodeURIComponent(params) + '=';
|
||||
urlparams += subPart + encodeURIComponent(value[key]) + '&';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
urlparams += part + encodeURIComponent(value) + "&";
|
||||
}
|
||||
}
|
||||
}
|
||||
urlparams = urlparams.slice(0, -1);
|
||||
url = urlparams;
|
||||
}
|
||||
url = baseURL + url
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
responseType: 'blob',
|
||||
headers: { 'Authorization': 'Bearer ' + getToken() }
|
||||
}).then(async (res) => {
|
||||
const isLogin = await this.blobValidate(res.data);
|
||||
if (isLogin) {
|
||||
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
|
||||
this.saveAs(blob, decodeURI(res.headers['download-filename']))
|
||||
} else {
|
||||
Message.error('无效的会话,或者会话已过期,请重新登录。');
|
||||
}
|
||||
})
|
||||
},
|
||||
oss(ossId) {
|
||||
var url = baseURL + '/system/oss/download/' + ossId
|
||||
axios({
|
||||
@ -55,7 +15,7 @@ export default {
|
||||
responseType: 'blob',
|
||||
headers: { 'Authorization': 'Bearer ' + getToken() }
|
||||
}).then(async (res) => {
|
||||
const isLogin = await this.blobValidate(res.data);
|
||||
const isLogin = await blobValidate(res.data);
|
||||
if (isLogin) {
|
||||
const blob = new Blob([res.data], { type: 'application/octet-stream' })
|
||||
this.saveAs(blob, decodeURI(res.headers['download-filename']))
|
||||
|
@ -138,19 +138,6 @@ export const constantRoutes = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/monitor/job-log',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
component: (resolve) => require(['@/views/monitor/job/log'], resolve),
|
||||
name: 'JobLog',
|
||||
meta: { title: '调度日志', activeMenu: '/monitor/job'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/tool/gen-edit',
|
||||
component: Layout,
|
||||
|
@ -77,7 +77,6 @@
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
:loading="exportLoading"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['demo:demo:export']"
|
||||
>导出</el-button>
|
||||
@ -181,8 +180,6 @@ export default {
|
||||
buttonLoading: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 导出遮罩层
|
||||
exportLoading: false,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
@ -358,7 +355,9 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.$download.excel('/demo/demo/export', this.queryParams);
|
||||
this.download('demo/demo/export', {
|
||||
...this.queryParams
|
||||
}, `demo_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user