From 98c684a1b0889e22cbafe55633a720ee7a5a8f79 Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 11 Jul 2024 17:34:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=96=E9=A1=B9=E7=AE=A1=E7=90=86=EF=BC=9A?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E4=BB=A5=E5=8F=8A=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AwardPersionController.java | 64 +++++++++++++++++++ .../awardpersion/entity/AwardPersion.java | 11 +++- .../src/hooks/system/useListPage.ts | 55 +++++++++++++++- .../src/hooks/system/useMethods.ts | 36 +++++++++++ .../views/awardpersion/AwardPersion.api.ts | 27 +++++++- .../views/awardpersion/AwardPersion.data.ts | 5 ++ .../views/awardpersion/AwardPersionList.vue | 40 +++++++++++- 7 files changed, 232 insertions(+), 6 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/controller/AwardPersionController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/controller/AwardPersionController.java index 638dcb14..9ddfbcf6 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/controller/AwardPersionController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/controller/AwardPersionController.java @@ -422,6 +422,38 @@ public class AwardPersionController extends JeecgController queryWrapper = QueryGenerator.initQueryWrapper(awardPersion, request.getParameterMap()); + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + // 过滤选中数据 + queryWrapper.eq("tj","1"); + // Step.2 获取导出数据 + List exportList = awardPersionService.list(queryWrapper); + + // Step.3 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + //此处设置的filename无效 ,前端会重更新设置一下 + mv.addObject(NormalExcelConstants.FILE_NAME, "获奖推荐"); + mv.addObject(NormalExcelConstants.CLASS, AwardPersion.class); + //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- + ExportParams exportParams=new ExportParams("获奖推荐" + "报表", "导出人:" + sysUser.getRealname(), "获奖推荐"); + exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload()); + //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- + mv.addObject(NormalExcelConstants.PARAMS,exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, exportList); + return mv; + } /** * 导出excel模板 * @@ -613,4 +645,36 @@ public class AwardPersionController extends JeecgController tj(@RequestParam(name="id",required=true) String id) { + AwardPersion awardPersion = awardPersionService.getById(id); + awardPersion.setTj("1"); + awardPersionService.updateById(awardPersion); + return Result.OK("成功!"); + } + + /** + * 撤销 + * + * @param + * @return + */ + @AutoLog(value = "撤销") + @ApiOperation(value="撤销", notes="撤销") + @GetMapping(value = "/cx") + public Result cx(@RequestParam(name="id",required=true) String id) { + AwardPersion awardPersion = awardPersionService.getById(id); + awardPersion.setTj("0"); + awardPersionService.updateById(awardPersion); + return Result.OK("成功!"); + } + } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java index ab248c03..6c9d1a4d 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/awardpersion/entity/AwardPersion.java @@ -77,16 +77,16 @@ public class AwardPersion implements Serializable { @ApiModelProperty(value = "奖项名称") private java.lang.String awardname; /**状态*/ - @Excel(name = "状态", width = 15, dicCode = "sh_status") + /*@Excel(name = "状态", width = 15, dicCode = "sh_status")*/ @Dict(dicCode = "sh_status") @ApiModelProperty(value = "状态") private java.lang.Integer status; /**奖项顺序*/ - @Excel(name = "奖项顺序", width = 15) + /*@Excel(name = "奖项顺序", width = 15)*/ @ApiModelProperty(value = "奖项顺序") private java.lang.Integer awardsort; /**奖项*/ - @Excel(name = "奖项", width = 15) + /*@Excel(name = "奖项", width = 15)*/ @ApiModelProperty(value = "奖项") private java.lang.String awardid; /**学生姓名*/ @@ -117,5 +117,10 @@ public class AwardPersion implements Serializable { @ApiModelProperty(value = "上传证书") private String sczs; + /**推荐*/ + @Excel(name = "是否推荐", width = 15, dicCode = "yn") + @Dict(dicCode = "yn") + @ApiModelProperty(value = "推荐") + private String tj; } diff --git a/jeecgboot-vue3-master/src/hooks/system/useListPage.ts b/jeecgboot-vue3-master/src/hooks/system/useListPage.ts index ed47739d..c175d58c 100644 --- a/jeecgboot-vue3-master/src/hooks/system/useListPage.ts +++ b/jeecgboot-vue3-master/src/hooks/system/useListPage.ts @@ -8,7 +8,7 @@ import { useMessage } from '/@/hooks/web/useMessage'; import { useMethods } from '/@/hooks/system/useMethods'; import { useDesign } from '/@/hooks/web/useDesign'; import { filterObj } from '/@/utils/common/compUtils'; -const { handleExportXls, handleImportXls,handleExportXlsMb } = useMethods(); +const { handleExportXls, handleImportXls,handleExportXlsMb,handleExportXlstj } = useMethods(); // 定义 useListPage 方法所需参数 interface ListPageOptions { @@ -33,6 +33,13 @@ interface ListPageOptions { //导出参数 params?: object; }; + exportConfigtj?: { + url: string | (() => string); + // 导出文件名 + name?: string | (() => string); + //导出参数 + params?: object; + }; // 导入配置 importConfig?: { //update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的 @@ -158,6 +165,51 @@ export function useListPage(options: ListPageOptions) { } } + // 导出奖项推荐数据 excel + async function onExportXlstj() { + //update-begin---author:wangshuai ---date:20220411 for:导出新增自定义参数------------ + let { url, name, params } = options?.exportConfigtj ?? {}; + let realUrl = typeof url === 'function' ? url() : url; + if (realUrl) { + let title = typeof name === 'function' ? name() : name; + //update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知- + let paramsForm:any = {}; + try { + paramsForm = await getForm().validate(); + } catch (e) { + console.error(e); + } + //update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知- + + //update-begin-author:liusq date:20230410 for:[/issues/409]导出功能没有按排序结果导出,设置导出默认排序,创建时间倒序 + if(!paramsForm?.column){ + Object.assign(paramsForm,{column:'createTime',order:'desc'}); + } + //update-begin-author:liusq date:20230410 for: [/issues/409]导出功能没有按排序结果导出,设置导出默认排序,创建时间倒序 + + //如果参数不为空,则整合到一起 + //update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId + if (params) { + Object.keys(params).map((k) => { + let temp = (params as object)[k]; + if (temp) { + paramsForm[k] = unref(temp); + } + }); + } + //update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId + if (selectedRowKeys.value && selectedRowKeys.value.length > 0) { + paramsForm['selections'] = selectedRowKeys.value.join(','); + } + console.log() + return handleExportXlstj(title as string, realUrl, filterObj(paramsForm)); + //update-end---author:wangshuai ---date:20220411 for:导出新增自定义参数-------------- + } else { + $message.createMessage.warn('没有传递 exportConfig.url 参数'); + return Promise.reject(); + } + } + // 导入 excel function onImportXls(file) { let { url, success } = options?.importConfig ?? {}; @@ -220,6 +272,7 @@ export function useListPage(options: ListPageOptions) { ...$message, onExportXls, onExportXlsMb, + onExportXlstj, onImportXls, doRequest, doDeleteRecord, diff --git a/jeecgboot-vue3-master/src/hooks/system/useMethods.ts b/jeecgboot-vue3-master/src/hooks/system/useMethods.ts index dfdd7dac..e4a8909a 100644 --- a/jeecgboot-vue3-master/src/hooks/system/useMethods.ts +++ b/jeecgboot-vue3-master/src/hooks/system/useMethods.ts @@ -49,6 +49,41 @@ export function useMethods() { window.URL.revokeObjectURL(url); //释放掉blob对象 } } + + /** + * 奖项推荐导出xls + * @param name + * @param url + */ + async function exportXlstj(name, url, params, isXlsx = false) { + const data = await defHttp.get({ url: url, params: params, responseType: 'blob' }, { isTransformResponse: false }); + if (!data) { + createMessage.warning('文件下载失败'); + return; + } + if (!name || typeof name != 'string') { + name = '导出文件'; + } + let blobOptions = { type: 'application/vnd.ms-excel' }; + let fileSuffix = '.xls'; + if (isXlsx === true) { + blobOptions['type'] = XLSX_MIME_TYPE; + fileSuffix = XLSX_FILE_SUFFIX; + } + if (typeof window.navigator.msSaveBlob !== 'undefined') { + window.navigator.msSaveBlob(new Blob([data], blobOptions), name + fileSuffix); + } else { + let url = window.URL.createObjectURL(new Blob([data], blobOptions)); + let link = document.createElement('a'); + link.style.display = 'none'; + link.href = url; + link.setAttribute('download', name + fileSuffix); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); //下载完成移除元素 + window.URL.revokeObjectURL(url); //释放掉blob对象 + } + } /** * 导出模板xls * @param name @@ -128,5 +163,6 @@ export function useMethods() { handleImportXls: (data, url, success) => importXls(data, url, success), handleExportXlsx: (name: string, url: string, params?: object) => exportXls(name, url, params, true), handleExportXlsMb: (name: string, url: string, params?: object) => exportXlsMb(name, url, params), + handleExportXlstj: (name: string, url: string, params?: object) => exportXlstj(name, url, params), }; } diff --git a/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.api.ts b/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.api.ts index 7cf35623..dbea3a36 100644 --- a/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.api.ts +++ b/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.api.ts @@ -17,7 +17,9 @@ enum Api { queryOptions = '/awardpersion/awardPersion/queryOptions', personalAbilityEvaluation = '/abilityEvaluation/personalAbilityEvaluation/personalAbilityEvaluation2', sczs='/awardpersion/awardPersion/sczs', - + exportXlstj = '/awardpersion/awardPersion/exportXlstj', + tj = '/awardpersion/awardPersion/tj', + qxtj = '/awardpersion/awardPersion/cx', } /** @@ -26,6 +28,7 @@ enum Api { */ export const getExportUrl = Api.exportXls; export const getExportUrlMb = Api.exportXlsMb; +export const getExportUrltj = Api.exportXlstj; /** * 导入api @@ -51,6 +54,28 @@ export const deleteOne = (params,handleSuccess) => { }); } +/** + * 推荐 + * @param params + * @param handleSuccess + */ +export const tj = (params,handleSuccess) => { + return defHttp.get({url: Api.tj, params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); +} + +/** + * 取消推荐 + * @param params + * @param handleSuccess + */ +export const qxtj = (params,handleSuccess) => { + return defHttp.get({url: Api.qxtj, params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); +} + /** * 批量删除 * @param params diff --git a/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.data.ts b/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.data.ts index 9e125b4f..5659744a 100644 --- a/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.data.ts +++ b/jeecgboot-vue3-master/src/views/awardpersion/AwardPersion.data.ts @@ -45,6 +45,11 @@ export const columns: BasicColumn[] = [ dataIndex: 'sczs', customRender: render.renderImagezs, }, + { + title: '是否推荐', + align: "center", + dataIndex: 'tj_dictText' + }, /* { title: '状态', align: "center", diff --git a/jeecgboot-vue3-master/src/views/awardpersion/AwardPersionList.vue b/jeecgboot-vue3-master/src/views/awardpersion/AwardPersionList.vue index e91b4f5a..93071035 100644 --- a/jeecgboot-vue3-master/src/views/awardpersion/AwardPersionList.vue +++ b/jeecgboot-vue3-master/src/views/awardpersion/AwardPersionList.vue @@ -40,6 +40,7 @@ 重新获取 导出 导出模板 + 导出推荐 导入