feat(字典管理): ✨ 字典管理
完成字典管理的对接
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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();
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<fs-page>
|
||||
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
|
||||
<subDict ref="subDictRef" :row-id="rowId"></subDict>
|
||||
<subDict ref="subDictRef"></subDict>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
@@ -14,10 +14,6 @@ import subDict from './subDict/index.vue';
|
||||
|
||||
//字典配置ref
|
||||
const subDictRef = ref();
|
||||
|
||||
const rowId: Ref<number> = ref(0);
|
||||
|
||||
defineExpose({ subDictRef, rowId });
|
||||
// crud组件的ref
|
||||
const crudRef = ref();
|
||||
// crud 配置的ref
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted, defineProps, computed } from 'vue';
|
||||
import {ref, onMounted, defineProps, computed, watch} from 'vue';
|
||||
import { useExpose, useCrud } from '@fast-crud/fast-crud';
|
||||
import { createCrudOptions } from './crud';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
@@ -40,10 +40,11 @@ const handleClose = (done: () => void) => {
|
||||
// catch error
|
||||
});
|
||||
};
|
||||
|
||||
defineExpose({ drawer });
|
||||
const {setSearchFormData,doRefresh} = crudExpose
|
||||
defineExpose({ drawer,setSearchFormData,doRefresh });
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
// console.log(48,currentRow)
|
||||
crudExpose.doRefresh();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user