✨ Introducing new features. closed #3045 【新特性】common-excel 模块

This commit is contained in:
wjie committed 2021-08-31 16:09:14 +08:00
1 parent 3ffb08968a
commit 109dc634e6
12 files changed
+81 -13

No files matched your search

@@ -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;