From c63ad90821270d93b821faf57a0bf8839c63972c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Mon, 6 Mar 2023 11:26:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AD=97=E5=85=B8=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E2=9C=A8=20=E5=AD=97=E5=85=B8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完成字典管理的对接 --- backend/dvadmin/system/views/dictionary.py | 12 ++++-------- web/src/views/system/dictionary/crud.tsx | 12 +++++++----- web/src/views/system/dictionary/index.vue | 6 +----- web/src/views/system/dictionary/subDict/crud.tsx | 2 +- web/src/views/system/dictionary/subDict/index.vue | 7 ++++--- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/backend/dvadmin/system/views/dictionary.py b/backend/dvadmin/system/views/dictionary.py index d28ef06..0dcc47c 100644 --- a/backend/dvadmin/system/views/dictionary.py +++ b/backend/dvadmin/system/views/dictionary.py @@ -54,21 +54,17 @@ class DictionaryViewSet(CustomModelViewSet): extra_filter_class = [] search_fields = ['label'] - def list(self,request): - """懒加载""" - params = request.query_params + def get_queryset(self): + params = self.request.query_params parent = params.get('parent', None) if params: if parent: queryset = self.queryset.filter(status=1, parent=parent) else: - queryset = self.queryset.filter(status=1) + queryset = self.queryset.filter(status=1, parent__isnull=True) else: queryset = self.queryset.filter(status=1, parent__isnull=True) - queryset = self.filter_queryset(queryset) - serializer = DictionarySerializer(queryset, many=True, request=request) - data = serializer.data - return SuccessResponse(data=data) + return queryset class InitDictionaryViewSet(APIView): diff --git a/web/src/views/system/dictionary/crud.tsx b/web/src/views/system/dictionary/crud.tsx index 2d09912..e994f06 100644 --- a/web/src/views/system/dictionary/crud.tsx +++ b/web/src/views/system/dictionary/crud.tsx @@ -1,13 +1,13 @@ import * as api from './api'; import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud'; import { dictionary } from '/@/utils/dictionary'; -import {ref} from 'vue'; +import {nextTick, ref} from 'vue'; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } -export const createCrudOptions = function ({ crudExpose, subDictRef,showSub }: { crudExpose: CrudExpose; subDictRef: any,showSub:any }): CreateCrudOptionsTypes { +export const createCrudOptions = function ({ crudExpose, subDictRef }: { crudExpose: CrudExpose; subDictRef: any }): CreateCrudOptionsTypes { const pageRequest = async (query: PageQuery) => { return await api.GetList(query); }; @@ -42,10 +42,12 @@ export const createCrudOptions = function ({ crudExpose, subDictRef,showSub }: { //@ts-ignore click: (context: any) => { const {row} = context - console.log(subDictRef.value.crudBinding) - // showSub.value = true - subDictRef.value.currentRow = row subDictRef.value.drawer = true; + nextTick(()=>{ + subDictRef.value.setSearchFormData({ form: { parent: row.id } }); + subDictRef.value.doRefresh(); + }) + }, }, diff --git a/web/src/views/system/dictionary/index.vue b/web/src/views/system/dictionary/index.vue index dd0af7a..715bf35 100644 --- a/web/src/views/system/dictionary/index.vue +++ b/web/src/views/system/dictionary/index.vue @@ -1,7 +1,7 @@ @@ -14,10 +14,6 @@ import subDict from './subDict/index.vue'; //字典配置ref const subDictRef = ref(); - -const rowId: Ref = ref(0); - -defineExpose({ subDictRef, rowId }); // crud组件的ref const crudRef = ref(); // crud 配置的ref diff --git a/web/src/views/system/dictionary/subDict/crud.tsx b/web/src/views/system/dictionary/subDict/crud.tsx index 1364a23..27828ab 100644 --- a/web/src/views/system/dictionary/subDict/crud.tsx +++ b/web/src/views/system/dictionary/subDict/crud.tsx @@ -7,7 +7,7 @@ interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } -export const createCrudOptions = function ({ crudExpose,currentRow }: { crudExpose: CrudExpose,currentRow:any }): CreateCrudOptionsTypes { +export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExpose }): CreateCrudOptionsTypes { const pageRequest = async (query: PageQuery) => { return await api.GetList(query); }; diff --git a/web/src/views/system/dictionary/subDict/index.vue b/web/src/views/system/dictionary/subDict/index.vue index 343af27..94bbeab 100644 --- a/web/src/views/system/dictionary/subDict/index.vue +++ b/web/src/views/system/dictionary/subDict/index.vue @@ -7,7 +7,7 @@