fix(字典管理): 🐛 字典管理
字典管理
This commit is contained in:
@@ -54,6 +54,22 @@ class DictionaryViewSet(CustomModelViewSet):
|
||||
extra_filter_class = []
|
||||
search_fields = ['label']
|
||||
|
||||
def list(self,request):
|
||||
"""懒加载"""
|
||||
params = 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)
|
||||
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)
|
||||
|
||||
|
||||
class InitDictionaryViewSet(APIView):
|
||||
"""
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { request } from '/@/utils/service';
|
||||
import { PageQuery, AddReq, DelReq, EditReq, InfoReq } from '@fast-crud/fast-crud';
|
||||
import XEUtils from 'xe-utils';
|
||||
|
||||
export const apiPrefix = '/api/system/dictionary/';
|
||||
export function GetList(query: PageQuery) {
|
||||
return request({
|
||||
url: apiPrefix,
|
||||
method: 'get',
|
||||
data: query,
|
||||
});
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
export function GetObj(id: InfoReq) {
|
||||
return request({
|
||||
|
||||
@@ -1,12 +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';
|
||||
|
||||
interface CreateCrudOptionsTypes {
|
||||
crudOptions: CrudOptions;
|
||||
}
|
||||
|
||||
export const createCrudOptions = function ({ crudExpose, subDictRef }: { crudExpose: CrudExpose; subDictRef: any }): CreateCrudOptionsTypes {
|
||||
export const createCrudOptions = function ({ crudExpose, subDictRef,showSub }: { crudExpose: CrudExpose; subDictRef: any,showSub:any }): CreateCrudOptionsTypes {
|
||||
const pageRequest = async (query: PageQuery) => {
|
||||
return await api.GetList(query);
|
||||
};
|
||||
@@ -39,8 +40,13 @@ export const createCrudOptions = function ({ crudExpose, subDictRef }: { crudExp
|
||||
content: '字典配置',
|
||||
},
|
||||
//@ts-ignore
|
||||
click: (opts: any) => {
|
||||
click: (context: any) => {
|
||||
const {row} = context
|
||||
console.log(subDictRef.value.crudBinding)
|
||||
// showSub.value = true
|
||||
subDictRef.value.currentRow = row
|
||||
subDictRef.value.drawer = true;
|
||||
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -58,6 +64,7 @@ export const createCrudOptions = function ({ crudExpose, subDictRef }: { crudExp
|
||||
//计算序号,你可以自定义计算规则,此处为翻页累加
|
||||
let index = context.index ?? 1;
|
||||
let pagination = crudExpose.crudBinding.value.pagination;
|
||||
// @ts-ignore
|
||||
return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ export function GetList(query: PageQuery) {
|
||||
return request({
|
||||
url: apiPrefix,
|
||||
method: 'get',
|
||||
data: query,
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
export function GetObj(id: InfoReq) {
|
||||
|
||||
@@ -2,11 +2,12 @@ import * as api from './api';
|
||||
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud';
|
||||
import { request } from '/@/utils/service';
|
||||
import { dictionary } from '/@/utils/dictionary';
|
||||
import {watch} from "vue";
|
||||
interface CreateCrudOptionsTypes {
|
||||
crudOptions: CrudOptions;
|
||||
}
|
||||
|
||||
export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExpose }): CreateCrudOptionsTypes {
|
||||
export const createCrudOptions = function ({ crudExpose,currentRow }: { crudExpose: CrudExpose,currentRow:any }): CreateCrudOptionsTypes {
|
||||
const pageRequest = async (query: PageQuery) => {
|
||||
return await api.GetList(query);
|
||||
};
|
||||
@@ -20,6 +21,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
|
||||
const addRequest = async ({ form }: AddReq) => {
|
||||
return await api.AddObj(form);
|
||||
};
|
||||
|
||||
return {
|
||||
crudOptions: {
|
||||
request: {
|
||||
@@ -41,6 +43,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
|
||||
//计算序号,你可以自定义计算规则,此处为翻页累加
|
||||
let index = context.index ?? 1;
|
||||
let pagination = crudExpose.crudBinding.value.pagination;
|
||||
// @ts-ignore
|
||||
return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -24,8 +24,10 @@ const { resetCrudOptions } = useCrud({ crudExpose, crudOptions });
|
||||
|
||||
//抽屉是否显示
|
||||
const drawer = ref(false);
|
||||
|
||||
//抽屉关闭确认
|
||||
const handleClose = (done: () => void) => {
|
||||
|
||||
ElMessageBox.confirm('您确定要关闭?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
|
||||
@@ -33,7 +33,6 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos
|
||||
delRequest
|
||||
},
|
||||
columns: {
|
||||
|
||||
id: {
|
||||
title: 'id',
|
||||
form: {
|
||||
|
||||
@@ -41,6 +41,7 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp
|
||||
},
|
||||
click: (context:any):void => {
|
||||
const {row} = context
|
||||
// eslint-disable-next-line no-mixed-spaces-and-tabs
|
||||
rolePermission.value.drawer=true
|
||||
rolePermission.value.editedRoleInfo = row
|
||||
rolePermission.value.initGet()
|
||||
@@ -69,6 +70,7 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp
|
||||
//计算序号,你可以自定义计算规则,此处为翻页累加
|
||||
let index = context.index ?? 1;
|
||||
let pagination = crudExpose.crudBinding.value.pagination;
|
||||
// @ts-ignore
|
||||
return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -306,7 +306,7 @@ const onSaveButtonForm = async () => {
|
||||
//选中的部门
|
||||
const checkedList = deptTree.value.getCheckedKeys()
|
||||
form.dept = checkedList
|
||||
if (!buttonFormRef) return
|
||||
if (!buttonFormRef.value) return
|
||||
await buttonFormRef.value.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
api.CreatePermission(form).then((res:any)=>{
|
||||
|
||||
Reference in New Issue
Block a user