✨ Introducing new features. closed #3045 【新特性】common-excel 模块
This commit is contained in:
1 parent
3ffb08968a
commit
109dc634e6
12 files changed
+81
-13
No files matched your search
@@ -120,6 +120,11 @@
|
||||
<artifactId>pigx-common-xss</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-excel</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-upms-api</artifactId>
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"groups": [
|
||||
{
|
||||
"name": "excel",
|
||||
"type": "com.pig4cloud.pigx.common.excel.config.ExcelConfigProperties",
|
||||
"sourceType": "com.pig4cloud.pigx.common.excel.config.ExcelConfigProperties"
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "excel.template-path",
|
||||
"type": "java.lang.String",
|
||||
"description": "模板路径",
|
||||
"defaultValue": "excel",
|
||||
"sourceType": "com.pig4cloud.pigx.common.excel.config.ExcelConfigProperties"
|
||||
}
|
||||
],
|
||||
"hints": []
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.pig4cloud.pigx.common.excel.ResponseExcelAutoConfiguration
|
||||
@@ -37,6 +37,7 @@
|
||||
<module>pigx-common-core</module>
|
||||
<module>pigx-common-data</module>
|
||||
<module>pigx-common-datasource</module>
|
||||
<module>pigx-common-excel</module>
|
||||
<module>pigx-common-feign</module>
|
||||
<module>pigx-common-gateway</module>
|
||||
<module>pigx-common-gray</module>
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
</dependency>
|
||||
<!-- excel 导入导出 -->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud.excel</groupId>
|
||||
<artifactId>excel-spring-boot-starter</artifactId>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-excel</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+1
-1
@@ -27,7 +27,7 @@ import com.pig4cloud.pigx.admin.api.vo.PreLogVO;
|
||||
import com.pig4cloud.pigx.admin.service.SysLogService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
+2
-6
@@ -27,12 +27,11 @@ import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.vo.UserExcelVO;
|
||||
import com.pig4cloud.pigx.admin.service.SysUserService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.RequestExcel;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
|
||||
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -197,9 +196,6 @@ public class SysUserController {
|
||||
@PostMapping("/import")
|
||||
@PreAuthorize("@pms.hasPermission('sys_log_export')")
|
||||
public R importUser(@RequestExcel List<UserExcelVO> excelVOList, BindingResult bindingResult) {
|
||||
// 通用校验获取失败的数据
|
||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||
|
||||
return userService.importUser(excelVOList, bindingResult);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.data.datascope.DataScope;
|
||||
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
|
||||
import com.pig4cloud.pigx.common.excel.vo.ErrorMessage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
@@ -24,11 +24,13 @@ import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
@@ -109,4 +111,16 @@ public class ${className}Controller {
|
||||
return R.ok(${classname}Service.removeById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param ${classname} 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_export')" )
|
||||
public List<${className}> export(${className} ${classname}) {
|
||||
return ${classname}Service.list(Wrappers.query(${classname}));
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,18 @@
|
||||
@current-change="currentChange"
|
||||
@row-update="handleUpdate"
|
||||
@row-save="handleSave"
|
||||
@row-del="rowDel">
|
||||
@row-del="handleDel">
|
||||
<template slot="menuLeft">
|
||||
<el-button
|
||||
v-if="permissions.${moduleName}_${pathName}_export"
|
||||
class="filter-item"
|
||||
plain
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="el-icon-download"
|
||||
@click="exportExcel">导出
|
||||
</el-button>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</basic-container>
|
||||
</div>
|
||||
@@ -67,6 +78,7 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 列表查询
|
||||
getList(page, params) {
|
||||
this.tableLoading = true
|
||||
fetchList(Object.assign({
|
||||
@@ -80,7 +92,8 @@
|
||||
this.tableLoading=false
|
||||
})
|
||||
},
|
||||
rowDel: function (row, index) {
|
||||
// 删除
|
||||
handleDel: function (row, index) {
|
||||
this.$confirm('是否确认删除ID为' + row.$pk.lowerAttrName, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
@@ -92,6 +105,7 @@
|
||||
this.getList(this.page)
|
||||
})
|
||||
},
|
||||
// 更新
|
||||
handleUpdate: function (row, index, done,loading) {
|
||||
putObj(row).then(data => {
|
||||
this.$message.success('修改成功')
|
||||
@@ -101,6 +115,7 @@
|
||||
loading();
|
||||
});
|
||||
},
|
||||
// 保存
|
||||
handleSave: function (row, done,loading) {
|
||||
addObj(row).then(data => {
|
||||
this.$message.success('添加成功')
|
||||
@@ -110,21 +125,29 @@
|
||||
loading();
|
||||
});
|
||||
},
|
||||
// 每页条数改变事件
|
||||
sizeChange(pageSize){
|
||||
this.page.pageSize = pageSize
|
||||
},
|
||||
// 当前页发生改变事件
|
||||
currentChange(current){
|
||||
this.page.currentPage = current
|
||||
},
|
||||
// 查询事件
|
||||
searchChange(form, done) {
|
||||
this.searchForm = form
|
||||
this.page.currentPage = 1
|
||||
this.getList(this.page, form)
|
||||
done()
|
||||
},
|
||||
// 刷新事件
|
||||
refreshChange() {
|
||||
this.getList(this.page)
|
||||
},
|
||||
// 导出excel
|
||||
exportExcel() {
|
||||
this.downBlobFile('/${moduleName}/${pathName}/export',this.searchForm, '${pathName}.xlsx')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
@@ -4,6 +4,7 @@
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_add" icon="el-icon-plus" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_export" icon="el-icon-download" type="primary" plain @click="exportExcel()">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -60,6 +61,7 @@
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
searchForm: {},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
@@ -120,6 +122,10 @@
|
||||
this.$message.success('删除成功')
|
||||
this.getDataList()
|
||||
})
|
||||
},
|
||||
// 导出excel
|
||||
exportExcel() {
|
||||
this.downFile('/${moduleName}/${pathName}/export', this.searchForm,'${pathName}.xlsx')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,3 +16,5 @@ insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `de
|
||||
SELECT @parentId, '${moduleName}_${pathName}_edit', '1', null, '1', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}修改', 1;
|
||||
insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`, `tenant_id`)
|
||||
SELECT @parentId, '${moduleName}_${pathName}_del', '1', null, '1', '0', '2018-05-15 21:35:18', '3', '2018-07-29 13:38:59', '${comments}删除', 1;
|
||||
insert into `sys_menu` ( `parent_id`, `permission`, `type`, `path`, `icon`, `del_flag`, `create_time`, `sort`, `update_time`, `name`, `tenant_id`)
|
||||
SELECT @parentId, '${moduleName}_${pathName}_export', '1', null, '1', '0', '2018-05-15 21:35:18', '3', '2018-07-29 13:38:59', '导入导出', 1;
|
||||
Reference in new issue
Block a user