教学大纲,导出选中数据,有勾选导出勾选条目,无勾选导出所有

This commit is contained in:
2026-09-21 17:48:38 +08:00
parent 450d664c33
commit 12eddac276
4 changed files with 30 additions and 14 deletions
@@ -119,7 +119,8 @@ public class ZYJXJHBController {
public void exportData(
HttpServletResponse response,
@RequestParam(required = false) String zydh,
@RequestParam(required = false) Integer ty) throws Exception {
zyjxjhbService.exportZYJXJHBExcel(response, zydh, ty);
@RequestParam(required = false) Integer ty,
@RequestParam(required = false) List<String> bhList) throws Exception {
zyjxjhbService.exportZYJXJHBExcel(response, zydh, ty, bhList);
}
}
@@ -82,5 +82,6 @@ public interface ZYJXJHBService {
* @param zydh 专业代号(可选)
* @param ty 停用标识(可选,0-正常,1-停用)
*/
void exportZYJXJHBExcel(jakarta.servlet.http.HttpServletResponse response, String zydh, Integer ty) throws Exception;
void exportZYJXJHBExcel(jakarta.servlet.http.HttpServletResponse response, String zydh, Integer ty,
java.util.List<String> bhList) throws Exception;
}
@@ -307,16 +307,25 @@ public class ZYJXJHBServiceImpl implements ZYJXJHBService {
}
@Override
public void exportZYJXJHBExcel(jakarta.servlet.http.HttpServletResponse response, String zydh, Integer ty) throws Exception {
LambdaQueryWrapper<ZYJXJHB> wrapper = new LambdaQueryWrapper<>();
if (zydh != null && !zydh.isEmpty()) {
wrapper.eq(ZYJXJHB::getZydh, zydh);
public void exportZYJXJHBExcel(jakarta.servlet.http.HttpServletResponse response, String zydh, Integer ty,
java.util.List<String> bhList) throws Exception {
List<ZYJXJHB> list;
if (bhList != null && !bhList.isEmpty()) {
// 勾选导出:按编号集合取数,忽略筛选条件
list = zyjxjhbMapper.selectBatchIds(bhList);
list.sort(java.util.Comparator.comparing(ZYJXJHB::getZydh,
java.util.Comparator.nullsLast(String::compareTo)));
} else {
LambdaQueryWrapper<ZYJXJHB> wrapper = new LambdaQueryWrapper<>();
if (zydh != null && !zydh.isEmpty()) {
wrapper.eq(ZYJXJHB::getZydh, zydh);
}
if (ty != null) {
wrapper.eq(ZYJXJHB::getTy, ty);
}
wrapper.orderByAsc(ZYJXJHB::getZydh);
list = zyjxjhbMapper.selectList(wrapper);
}
if (ty != null) {
wrapper.eq(ZYJXJHB::getTy, ty);
}
wrapper.orderByAsc(ZYJXJHB::getZydh);
List<ZYJXJHB> list = zyjxjhbMapper.selectList(wrapper);
String[] headers = {"专业代号", "课编号", "学期第次", "课类型", "学时", "学分", "周课时",
"课程定位", "模块", "成绩分制", "理论学时", "实践学时", "考试课时", "教研室代号", "简称"};
byte[] bytes = com.roomroot.jwgl.utils.ExcelExportUtil.export("专业教学计划", headers, list,
@@ -574,8 +574,13 @@ export default {
/* ---------- 下载 ---------- */
handleDownload() {
const query = {}
if (this.searchForm.zydh) query.zydh = this.searchForm.zydh
if (this.searchForm.ty === 0 || this.searchForm.ty === 1) query.ty = this.searchForm.ty
// 勾选行优先:有勾选则只导出所选,否则按筛选条件导出
if (this.selection.length) {
query.bhList = this.selection.map(row => row.bh).join(',')
} else {
if (this.searchForm.zydh) query.zydh = this.searchForm.zydh
if (this.searchForm.ty === 0 || this.searchForm.ty === 1) query.ty = this.searchForm.ty
}
exportSyllabus(query).then(blob => {
saveAs(blob, '教学大纲.xlsx')
this.$message.success('导出成功')