diff --git a/packages/toolkits/pro/template/server/nestJs/src/i18/i18.controller.ts b/packages/toolkits/pro/template/server/nestJs/src/i18/i18.controller.ts index f23c79a0..1d603262 100644 --- a/packages/toolkits/pro/template/server/nestJs/src/i18/i18.controller.ts +++ b/packages/toolkits/pro/template/server/nestJs/src/i18/i18.controller.ts @@ -9,21 +9,17 @@ import { Query, ParseIntPipe, DefaultValuePipe, - ParseBoolPipe, + ParseArrayPipe, } from '@nestjs/common'; import { I18Service } from './i18.service'; import { CreateI18Dto } from './dto/create-i18.dto'; import { UpdateI18Dto } from './dto/update-i18.dto'; -import { CreateLang } from './dto/create-lang.dto'; import { I18LangService } from './lang.service'; import { Permission } from '../public/permission.decorator'; @Controller('i18') export class I18Controller { - constructor( - private readonly i18Service: I18Service, - private readonly langService: I18LangService - ) {} + constructor(private readonly i18Service: I18Service) {} @Permission('i18n::add') @Post() @@ -41,9 +37,19 @@ export class I18Controller { findAll( @Query('page', new DefaultValuePipe(1), ParseIntPipe) page?: number, @Query('limit', new DefaultValuePipe(0), ParseIntPipe) limit?: number, - @Query('all', ParseIntPipe) all?: number + @Query('all', ParseIntPipe) all?: number, + @Query('lang', new DefaultValuePipe([]), ParseArrayPipe) lang?: number[], + @Query('key') key?: string, + @Query('content') content?: string ) { - return this.i18Service.findAll(page, limit, Boolean(all)); + return this.i18Service.findAll( + page, + limit, + Boolean(all), + lang, + content, + key + ); } @Permission('i18n::query') diff --git a/packages/toolkits/pro/template/server/nestJs/src/i18/i18.service.ts b/packages/toolkits/pro/template/server/nestJs/src/i18/i18.service.ts index 12e34dd9..620df359 100644 --- a/packages/toolkits/pro/template/server/nestJs/src/i18/i18.service.ts +++ b/packages/toolkits/pro/template/server/nestJs/src/i18/i18.service.ts @@ -3,7 +3,7 @@ import { CreateI18Dto } from './dto/create-i18.dto'; import { UpdateI18Dto } from './dto/update-i18.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { I18, Lang } from '@app/models'; -import { Repository } from 'typeorm'; +import { In, Like, Repository } from 'typeorm'; import { paginate } from 'nestjs-typeorm-paginate'; import { I18nTranslations } from '../.generate/i18n.generated'; import { I18nContext, I18nService } from 'nestjs-i18n'; @@ -84,11 +84,23 @@ export class I18Service { }, }); } - async findAll(page?: number, limit?: number, all?: boolean) { + async findAll( + page?: number, + limit?: number, + all?: boolean, + lang?: number[], + content?: string, + key?: string + ) { let count = 0; if (all) { count = await this.i18.count(); } + const where = { + lang: lang && lang.length ? { id: In(lang) } : undefined, + content: content ? Like(content) : undefined, + key: key ? Like(key) : undefined, + }; if (page && limit) { return paginate( this.i18, @@ -99,6 +111,7 @@ export class I18Service { { relations: ['lang'], loadEagerRelations: true, + where, } ); } else { @@ -111,6 +124,7 @@ export class I18Service { { relations: ['lang'], loadEagerRelations: true, + where, } ); } diff --git a/packages/toolkits/pro/template/tinyvue/src/api/local.ts b/packages/toolkits/pro/template/tinyvue/src/api/local.ts index ab90f4c6..4d0c4373 100644 --- a/packages/toolkits/pro/template/tinyvue/src/api/local.ts +++ b/packages/toolkits/pro/template/tinyvue/src/api/local.ts @@ -45,8 +45,13 @@ export const getAllLocalItems = ( page?: number, limit?: number, all?: number, + filters?: { + [x: string]: number[] | string; + }, ) => { - return axios.get('/api/i18', { params: { page, limit, all } }); + return axios.get('/api/i18', { + params: { page, limit, all, ...filters }, + }); }; export const createLocalItem = (data: CreateLocal) => { diff --git a/packages/toolkits/pro/template/tinyvue/src/views/locale/components/locale-table.vue b/packages/toolkits/pro/template/tinyvue/src/views/locale/components/locale-table.vue index 07adbb57..7539839a 100644 --- a/packages/toolkits/pro/template/tinyvue/src/views/locale/components/locale-table.vue +++ b/packages/toolkits/pro/template/tinyvue/src/views/locale/components/locale-table.vue @@ -5,6 +5,7 @@ :fetch-data="fetchData" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" :loading="loading" + remote-filter @edit-closed="onEditClosed" > @@ -12,16 +13,19 @@ field="key" title="key" :editor="{ component: 'input', autoselect: true }" + :filter="keyFilter" >