From 3b2a140cae0e2e92a0eb0358e578fb8d2aa2e191 Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 3 Jul 2024 23:50:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(bugs):=20=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=B7=B2=E7=9F=A5=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/ToolBar.vue | 15 ++++++++------- component/toolbar/Export.vue | 7 ++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/component/ToolBar.vue b/component/ToolBar.vue index 28cab76..284f119 100644 --- a/component/ToolBar.vue +++ b/component/ToolBar.vue @@ -113,6 +113,7 @@ clearable @clear="onSearch" @keydown.enter="onSearch" + @blur="onSearch()" /> @@ -276,7 +277,7 @@ const props = defineProps({ */ exportAsync: { type: Boolean, - default: false, + default: true, }, /** @@ -469,21 +470,21 @@ const keyword = ref('') * 查询事件 */ function onSearch() { - const request = new AirRequest(props.entity) + request.value = new AirRequestPage(props.entity) const keys = Object.keys(data.value) keys.forEach((key) => { if (data.value[key] === '') { data.value[key] = undefined } }) - request.filter = AirClassTransformer.newInstance(props.entity) + request.value.filter = AirClassTransformer.newInstance(props.entity) .recoverBy(data.value) - if ((request as AirRequestPage).page) { - (request as AirRequestPage).page.pageNum = 1 + if (request.value.page) { + request.value.page.pageNum = 1 } - request.keyword = keyword.value.trimEnd() + request.value.keyword = keyword.value.trimEnd() .trimStart() - emits('onSearch', request) + emits('onSearch', request.value) } /** diff --git a/component/toolbar/Export.vue b/component/toolbar/Export.vue index 3b94413..94dec7d 100644 --- a/component/toolbar/Export.vue +++ b/component/toolbar/Export.vue @@ -46,6 +46,7 @@ import { AirFile } from '../../helper/AirFile' import { AirHttp } from '../../helper/AirHttp' import { airPropsParam } from '../../config/AirProps' import { AirI18n } from '../../helper/AirI18n' +import { IJson } from '../../interface/IJson' const props = defineProps(airPropsParam(new AirExportModel())) @@ -81,7 +82,7 @@ async function startLoop(fileCode: string) { try { const exportModel = new AirExportModel() exportModel.fileCode = fileCode - const downloadPath = await AirHttp.create('file/download').callbackError() + const downloadPath = await AirHttp.create('user/queryExport').callbackError() .post(exportModel) as unknown as string isLoading.value = false exportFilePath.value = AirFile.getStaticFileUrl(downloadPath) @@ -108,8 +109,8 @@ async function createExportTask() { isLoading.value = true try { // 将请求的param参数发送到url对应的API上 开始创建一个任务 - const json = props.param.param.toJson() - json.page = undefined + const json = props.param.param; + (json as IJson).page = undefined const fileCode: string = await AirHttp.create(props.param.url).post(json) as unknown as string // 轮询任务结果 startLoop(fileCode) -- Gitee From ba26f8fae740fa92bd29198a10d8ba9b6ca6fadd Mon Sep 17 00:00:00 2001 From: Hamm Date: Thu, 4 Jul 2024 01:31:25 +0800 Subject: [PATCH 2/3] refactor(toolbar): rename variable for clarity in export feature Renamed `json` to `exportRequest` in `Export.vue` to improve code readability and explicitly indicate the purpose of the variable within the export functionality. --- component/toolbar/Export.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/component/toolbar/Export.vue b/component/toolbar/Export.vue index 94dec7d..e49e1c3 100644 --- a/component/toolbar/Export.vue +++ b/component/toolbar/Export.vue @@ -109,9 +109,11 @@ async function createExportTask() { isLoading.value = true try { // 将请求的param参数发送到url对应的API上 开始创建一个任务 - const json = props.param.param; - (json as IJson).page = undefined - const fileCode: string = await AirHttp.create(props.param.url).post(json) as unknown as string + const exportRequest = props.param.param; + + // 导出数据无需分页 + (exportRequest as IJson).page = undefined + const fileCode: string = await AirHttp.create(props.param.url).post(exportRequest) as unknown as string // 轮询任务结果 startLoop(fileCode) } catch (e) { -- Gitee From 7395a7257a041f27e0b55a85fc691c72dcb6e725 Mon Sep 17 00:00:00 2001 From: Hamm Date: Thu, 4 Jul 2024 02:04:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?release(v2.1.1):=20=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E4=BA=86`v2.1.1`=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 +++++++- component/ToolBar.vue | 44 +++++++++--------------------------- component/toolbar/Export.vue | 4 ++-- config/AirConfig.ts | 24 +------------------- helper/AirDialog.ts | 9 +++----- model/AirExportModel.ts | 24 ++++++-------------- 6 files changed, 32 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad4105..53cf76a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ # AirPower4T 版本发布日志 -## v2.1.0 +## v2.1.1 ### 🎉 Features: +- feat(Export): 内置了默认异步导出的相关方法 +- feat(Search): 支持了输入框失去焦点触发搜索 + +## v2.1.0 + +### 🐞 Bug fixes: + - fix(Permission): 优化了权限验证逻辑 > 后端需同步升级到 `v2.1.0` diff --git a/component/ToolBar.vue b/component/ToolBar.vue index 284f119..3a5e86e 100644 --- a/component/ToolBar.vue +++ b/component/ToolBar.vue @@ -155,6 +155,7 @@ import { IJson } from '../interface/IJson' import { AirAbstractEntityService } from '../base/AirAbstractEntityService' import { getDictionary } from '../decorator/Custom' import { AirI18n } from '../helper/AirI18n' +import { AirExportModel } from '../model/AirExportModel' const emits = defineEmits(['onSearch', 'onAdd', 'onReset']) @@ -243,15 +244,6 @@ const props = defineProps({ default: undefined, }, - /** - * # 导出接口地址 如传入则优先使用 - * 默认按传入的service自动生成 - */ - exportUrl: { - type: String, - default: undefined, - }, - /** * # 导出的请求参数 */ @@ -263,23 +255,13 @@ const props = defineProps({ /** * # 是否显示导出按钮 * --- - * 💡 如传入 则需要再传入 ```:service``` 或 ```:export-url``` + * 💡 如传入 则需要再传入 ```:service``` */ showExport: { type: Boolean, default: false, }, - /** - * # 异步导出 - * --- - * 💡 建议数据量大的导出功能都使用这个方法 - */ - exportAsync: { - type: Boolean, - default: true, - }, - /** * # 导入接口地址 * --- @@ -410,21 +392,17 @@ function getUrlWithAccessToken(url: string) { * 导出方法 */ function onExport() { - let url = props.exportUrl - if (!url) { - // 没有自定义传入 则自动生成 - if (!props.service) { - AirNotification.error('请为ToolBar传入service或者exportUrl', '导出失败') - return - } - const service = AirClassTransformer.newInstance(props.service) - url = `${service.baseUrl}/${props.exportAsync ? AirConfig.exportUrl : AirConfig.exportSyncUrl}` - } - if (props.exportAsync) { - AirDialog.createExportTask(url, request.value) + if (!props.service) { + AirNotification.error('请为ToolBar传入service', '导出失败') return } - window.open(AirConfig.apiUrl + getUrlWithAccessToken(url)) + + const service = AirClassTransformer.newInstance(props.service) + const exportModel = new AirExportModel() + exportModel.param = request.value + exportModel.createExportTaskUrl = `${service.baseUrl}/export` + exportModel.queryExportUrl = `${service.baseUrl}/queryExport` + AirDialog.createExportTask(exportModel) } /** diff --git a/component/toolbar/Export.vue b/component/toolbar/Export.vue index e49e1c3..19f2202 100644 --- a/component/toolbar/Export.vue +++ b/component/toolbar/Export.vue @@ -82,7 +82,7 @@ async function startLoop(fileCode: string) { try { const exportModel = new AirExportModel() exportModel.fileCode = fileCode - const downloadPath = await AirHttp.create('user/queryExport').callbackError() + const downloadPath = await AirHttp.create(props.param.queryExportUrl).callbackError() .post(exportModel) as unknown as string isLoading.value = false exportFilePath.value = AirFile.getStaticFileUrl(downloadPath) @@ -113,7 +113,7 @@ async function createExportTask() { // 导出数据无需分页 (exportRequest as IJson).page = undefined - const fileCode: string = await AirHttp.create(props.param.url).post(exportRequest) as unknown as string + const fileCode: string = await AirHttp.create(props.param.createExportTaskUrl).post(exportRequest) as unknown as string // 轮询任务结果 startLoop(fileCode) } catch (e) { diff --git a/config/AirConfig.ts b/config/AirConfig.ts index 81f4bd4..6eb4626 100644 --- a/config/AirConfig.ts +++ b/config/AirConfig.ts @@ -23,7 +23,7 @@ export class AirConfig { /** * # AirPower版本号 */ - static readonly version = 'v2.0.2' + static readonly version = 'v2.1.1' /** * # AppKey @@ -447,26 +447,4 @@ export class AirConfig { * 将自动拼接 ```apiUrl``` + ```baseUrl``` + ```importTemplateUrl``` */ static importTemplateUrl = 'importTemplate' - - /** - * # 默认同步导出URL - * - * --- - * 😈 请注意 请勿包含 ```baseUrl``` 和 ```apiUrl``` - * - * --- - * 将自动拼接 ```apiUrl``` + ```baseUrl``` + ```exportSyncUrl``` - */ - static exportSyncUrl = 'exportSync' - - /** - * # 默认异步导出URL - * - * --- - * 😈 请注意 请勿包含 ```baseUrl``` 和 ```apiUrl``` - * - * --- - * 将自动拼接 ```apiUrl``` + ```baseUrl``` + ```exportUrl``` - */ - static exportUrl = 'export' } diff --git a/helper/AirDialog.ts b/helper/AirDialog.ts index 7d24965..3377e87 100644 --- a/helper/AirDialog.ts +++ b/helper/AirDialog.ts @@ -8,7 +8,6 @@ import { AUpload } from '../component' import ExportView from '../component/toolbar/Export.vue' import { IUploadConfig } from '../interface/IUploadConfig' import { IFile } from '../interface/IFile' -import { AirRequest } from '../model/AirRequest' import { AirEntity } from '../base/AirEntity' import { IJson } from '../interface/IJson' import { AirStore } from '../store/AirStore' @@ -131,12 +130,10 @@ export class AirDialog { /** * # 创建一个导出任务 - * @param url 接口地址 - * @param exportParam (可选)导出request参数对象 + * @param exportParam (可选)导出参数对象 */ - static async createExportTask(url: string, exportParam?: R): Promise { - const param = new AirExportModel(url, exportParam) - return this.show(ExportView, param) + static async createExportTask(exportModel: AirExportModel): Promise { + return this.show(ExportView, exportModel) } /** diff --git a/model/AirExportModel.ts b/model/AirExportModel.ts index 412c1d2..c494ccc 100644 --- a/model/AirExportModel.ts +++ b/model/AirExportModel.ts @@ -8,9 +8,14 @@ import { AirRequest } from './AirRequest' */ export class AirExportModel extends AirModel { /** - * # 导出请求的API地址 + * # 创建导出任务的API地址 */ - @Type(String) url!: string + @Type(String) createExportTaskUrl!: string + + /** + * # 查询导出结果的API地址 + */ + @Type(String) queryExportUrl!: string /** * # 请求的参数 @@ -22,19 +27,4 @@ export class AirExportModel extends AirModel * ! 传参用 */ @Type(String) fileCode!: string - - /** - * # 实例化一个导出模型 - * @param url (可选) 导出URL地址 - * @param param (可选) 导出的查询参数 - */ - constructor(url?: string, param?: R) { - super() - if (url) { - this.url = url - } - if (param) { - this.param = param - } - } } -- Gitee