新增:新增公共查询枚举字典 API,优化前端获取枚举数据的方式
This commit is contained in:
parent
8200ea822f
commit
a79b3e0e96
@ -64,6 +64,11 @@ public class ContiNewAdminProperties {
|
|||||||
*/
|
*/
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基本包
|
||||||
|
*/
|
||||||
|
private String basePackage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作者信息
|
* 作者信息
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package top.charles7c.cnadmin.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import top.charles7c.cnadmin.common.base.BaseEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功/失败状态枚举
|
||||||
|
*
|
||||||
|
* @author Charles7c
|
||||||
|
* @since 2023/2/26 21:35
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum SuccessFailureStatusEnum implements BaseEnum<Integer, String> {
|
||||||
|
|
||||||
|
/** 成功 */
|
||||||
|
SUCCESS(1, "成功"),
|
||||||
|
|
||||||
|
/** 失败 */
|
||||||
|
FAILURE(2, "失败"),;
|
||||||
|
|
||||||
|
private final Integer value;
|
||||||
|
private final String description;
|
||||||
|
}
|
3
continew-admin-ui/components.d.ts
vendored
3
continew-admin-ui/components.d.ts
vendored
@ -10,7 +10,6 @@ declare module '@vue/runtime-core' {
|
|||||||
AAffix: typeof import('@arco-design/web-vue')['Affix']
|
AAffix: typeof import('@arco-design/web-vue')['Affix']
|
||||||
AAlert: typeof import('@arco-design/web-vue')['Alert']
|
AAlert: typeof import('@arco-design/web-vue')['Alert']
|
||||||
AAvatar: typeof import('@arco-design/web-vue')['Avatar']
|
AAvatar: typeof import('@arco-design/web-vue')['Avatar']
|
||||||
AAvatarGroup: typeof import('@arco-design/web-vue')['AvatarGroup']
|
|
||||||
ABadge: typeof import('@arco-design/web-vue')['Badge']
|
ABadge: typeof import('@arco-design/web-vue')['Badge']
|
||||||
ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb']
|
ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb']
|
||||||
ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem']
|
ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem']
|
||||||
@ -20,7 +19,6 @@ declare module '@vue/runtime-core' {
|
|||||||
ACardMeta: typeof import('@arco-design/web-vue')['CardMeta']
|
ACardMeta: typeof import('@arco-design/web-vue')['CardMeta']
|
||||||
ACarousel: typeof import('@arco-design/web-vue')['Carousel']
|
ACarousel: typeof import('@arco-design/web-vue')['Carousel']
|
||||||
ACarouselItem: typeof import('@arco-design/web-vue')['CarouselItem']
|
ACarouselItem: typeof import('@arco-design/web-vue')['CarouselItem']
|
||||||
ACascader: typeof import('@arco-design/web-vue')['Cascader']
|
|
||||||
ACheckbox: typeof import('@arco-design/web-vue')['Checkbox']
|
ACheckbox: typeof import('@arco-design/web-vue')['Checkbox']
|
||||||
ACol: typeof import('@arco-design/web-vue')['Col']
|
ACol: typeof import('@arco-design/web-vue')['Col']
|
||||||
AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider']
|
AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider']
|
||||||
@ -60,7 +58,6 @@ declare module '@vue/runtime-core' {
|
|||||||
ASelect: typeof import('@arco-design/web-vue')['Select']
|
ASelect: typeof import('@arco-design/web-vue')['Select']
|
||||||
ASkeleton: typeof import('@arco-design/web-vue')['Skeleton']
|
ASkeleton: typeof import('@arco-design/web-vue')['Skeleton']
|
||||||
ASkeletonLine: typeof import('@arco-design/web-vue')['SkeletonLine']
|
ASkeletonLine: typeof import('@arco-design/web-vue')['SkeletonLine']
|
||||||
ASkeletonShape: typeof import('@arco-design/web-vue')['SkeletonShape']
|
|
||||||
ASpace: typeof import('@arco-design/web-vue')['Space']
|
ASpace: typeof import('@arco-design/web-vue')['Space']
|
||||||
ASpin: typeof import('@arco-design/web-vue')['Spin']
|
ASpin: typeof import('@arco-design/web-vue')['Spin']
|
||||||
AStatistic: typeof import('@arco-design/web-vue')['Statistic']
|
AStatistic: typeof import('@arco-design/web-vue')['Statistic']
|
||||||
|
@ -5,11 +5,7 @@ import { MenuParam } from '@/api/system/menu';
|
|||||||
import { RoleParam } from '@/api/system/role';
|
import { RoleParam } from '@/api/system/role';
|
||||||
import { PostParam } from '@/api/system/post';
|
import { PostParam } from '@/api/system/post';
|
||||||
import { TreeNodeData } from '@arco-design/web-vue';
|
import { TreeNodeData } from '@arco-design/web-vue';
|
||||||
|
import { LabelValueState } from '@/store/modules/dict/types';
|
||||||
export interface LabelValueRecord {
|
|
||||||
label: string;
|
|
||||||
value: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function listDeptTree(params: DeptParam) {
|
export function listDeptTree(params: DeptParam) {
|
||||||
return axios.get<TreeNodeData[]>('/common/tree/dept', {
|
return axios.get<TreeNodeData[]>('/common/tree/dept', {
|
||||||
@ -30,7 +26,7 @@ export function listMenuTree(params: MenuParam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function listRoleDict(params: RoleParam) {
|
export function listRoleDict(params: RoleParam) {
|
||||||
return axios.get<LabelValueRecord[]>('/common/dict/role', {
|
return axios.get<LabelValueState[]>('/common/dict/role', {
|
||||||
params,
|
params,
|
||||||
paramsSerializer: (obj) => {
|
paramsSerializer: (obj) => {
|
||||||
return qs.stringify(obj);
|
return qs.stringify(obj);
|
||||||
@ -39,10 +35,14 @@ export function listRoleDict(params: RoleParam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function listPostDict(params: PostParam) {
|
export function listPostDict(params: PostParam) {
|
||||||
return axios.get<LabelValueRecord[]>('/common/dict/post', {
|
return axios.get<LabelValueState[]>('/common/dict/post', {
|
||||||
params,
|
params,
|
||||||
paramsSerializer: (obj) => {
|
paramsSerializer: (obj) => {
|
||||||
return qs.stringify(obj);
|
return qs.stringify(obj);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listEnumDict(enumTypeName: string) {
|
||||||
|
return axios.get<LabelValueState[]>(`/common/dict/enum/${enumTypeName}`);
|
||||||
|
}
|
||||||
|
@ -4,6 +4,7 @@ import ArcoVueIcon from '@arco-design/web-vue/es/icon';
|
|||||||
// eslint-disable-next-line import/no-unresolved
|
// eslint-disable-next-line import/no-unresolved
|
||||||
import 'virtual:svg-icons-register';
|
import 'virtual:svg-icons-register';
|
||||||
import globalComponents from '@/components';
|
import globalComponents from '@/components';
|
||||||
|
import useDict from '@/utils/dict';
|
||||||
import router from './router';
|
import router from './router';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
import i18n from './locale';
|
import i18n from './locale';
|
||||||
@ -16,6 +17,9 @@ import '@/utils/request';
|
|||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
|
// 全局方法挂载
|
||||||
|
app.config.globalProperties.useDict = useDict;
|
||||||
|
|
||||||
app.use(ArcoVue, {});
|
app.use(ArcoVue, {});
|
||||||
app.use(ArcoVueIcon);
|
app.use(ArcoVueIcon);
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { createPinia } from 'pinia';
|
import { createPinia } from 'pinia';
|
||||||
import useAppStore from './modules/app';
|
import useAppStore from './modules/app';
|
||||||
import useLoginStore from './modules/login';
|
import useLoginStore from './modules/login';
|
||||||
|
import useDictStore from './modules/dict';
|
||||||
import useTabBarStore from './modules/tab-bar';
|
import useTabBarStore from './modules/tab-bar';
|
||||||
|
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
|
|
||||||
export { useAppStore, useLoginStore, useTabBarStore };
|
export { useAppStore, useLoginStore, useDictStore, useTabBarStore };
|
||||||
export default pinia;
|
export default pinia;
|
||||||
|
54
continew-admin-ui/src/store/modules/dict/index.ts
Normal file
54
continew-admin-ui/src/store/modules/dict/index.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { DictState, LabelValueState } from '@/store/modules/dict/types';
|
||||||
|
|
||||||
|
const useDictStore = defineStore('dict', {
|
||||||
|
state: () => ({ dict: [] as Array<DictState> }),
|
||||||
|
actions: {
|
||||||
|
// 获取字典
|
||||||
|
getDict(_name: string) {
|
||||||
|
if (_name === null && _name === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < this.dict.length; i += 1) {
|
||||||
|
if (this.dict[i].name === _name) {
|
||||||
|
return this.dict[i].detail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
// 设置字典
|
||||||
|
setDict(_name: string, detail: Array<LabelValueState>) {
|
||||||
|
if (_name !== null && _name !== '') {
|
||||||
|
this.dict.push({
|
||||||
|
name: _name,
|
||||||
|
detail,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 删除字典
|
||||||
|
deleteDict(_name: string) {
|
||||||
|
let bln = false;
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < this.dict.length; i += 1) {
|
||||||
|
if (this.dict[i].name === _name) {
|
||||||
|
this.dict.splice(i, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
bln = false;
|
||||||
|
}
|
||||||
|
return bln;
|
||||||
|
},
|
||||||
|
// 清空字典
|
||||||
|
cleanDict() {
|
||||||
|
this.dict = [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default useDictStore;
|
9
continew-admin-ui/src/store/modules/dict/types.ts
Normal file
9
continew-admin-ui/src/store/modules/dict/types.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export interface LabelValueState {
|
||||||
|
label: string;
|
||||||
|
value: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DictState {
|
||||||
|
name: string;
|
||||||
|
detail: Array<LabelValueState>;
|
||||||
|
}
|
27
continew-admin-ui/src/utils/dict.ts
Normal file
27
continew-admin-ui/src/utils/dict.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { ref, toRefs } from 'vue';
|
||||||
|
import { listEnumDict } from '@/api/common';
|
||||||
|
import { useDictStore } from '@/store';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典数据
|
||||||
|
*
|
||||||
|
* @param names 字典名列表
|
||||||
|
*/
|
||||||
|
export default function useDict(...names: Array<string>) {
|
||||||
|
const res = ref<any>({});
|
||||||
|
return (() => {
|
||||||
|
names.forEach((name: string) => {
|
||||||
|
res.value[name] = [];
|
||||||
|
const dict = useDictStore().getDict(name);
|
||||||
|
if (dict) {
|
||||||
|
res.value[name] = dict;
|
||||||
|
} else {
|
||||||
|
listEnumDict(name).then((resp) => {
|
||||||
|
res.value[name] = resp.data;
|
||||||
|
useDictStore().setDict(name, res.value[name]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return toRefs(res.value);
|
||||||
|
})();
|
||||||
|
}
|
@ -10,10 +10,10 @@
|
|||||||
<a-form-item field="status" hide-label>
|
<a-form-item field="status" hide-label>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
:options="statusOptions"
|
:options="SuccessFailureStatusEnum"
|
||||||
placeholder="登录状态搜索"
|
placeholder="登录状态搜索"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 150px;"
|
style="width: 150px"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item field="createTime" hide-label>
|
<a-form-item field="createTime" hide-label>
|
||||||
@ -81,7 +81,6 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
||||||
import { SelectOptionData } from '@arco-design/web-vue';
|
|
||||||
import {
|
import {
|
||||||
LoginLogParam,
|
LoginLogParam,
|
||||||
LoginLogRecord,
|
LoginLogRecord,
|
||||||
@ -89,14 +88,11 @@
|
|||||||
} from '@/api/monitor/log';
|
} from '@/api/monitor/log';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const { SuccessFailureStatusEnum } = proxy.useDict('SuccessFailureStatusEnum');
|
||||||
|
|
||||||
const loginLogList = ref<LoginLogRecord[]>([]);
|
const loginLogList = ref<LoginLogRecord[]>([]);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const statusOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '成功', value: 1 },
|
|
||||||
{ label: '失败', value: 2 },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
// 查询参数
|
// 查询参数
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<a-form-item field="status" hide-label>
|
<a-form-item field="status" hide-label>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
:options="statusOptions"
|
:options="SuccessFailureStatusEnum"
|
||||||
placeholder="操作状态搜索"
|
placeholder="操作状态搜索"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 150px"
|
style="width: 150px"
|
||||||
@ -91,7 +91,6 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
||||||
import { SelectOptionData } from '@arco-design/web-vue';
|
|
||||||
import {
|
import {
|
||||||
OperationLogParam,
|
OperationLogParam,
|
||||||
OperationLogRecord,
|
OperationLogRecord,
|
||||||
@ -99,14 +98,11 @@
|
|||||||
} from '@/api/monitor/log';
|
} from '@/api/monitor/log';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const { SuccessFailureStatusEnum } = proxy.useDict('SuccessFailureStatusEnum');
|
||||||
|
|
||||||
const operationLogList = ref<OperationLogRecord[]>([]);
|
const operationLogList = ref<OperationLogRecord[]>([]);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const statusOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '成功', value: 1 },
|
|
||||||
{ label: '失败', value: 2 },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
// 查询参数
|
// 查询参数
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<a-form-item field="status" hide-label>
|
<a-form-item field="status" hide-label>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
:options="statusOptions"
|
:options="DisEnableStatusEnum"
|
||||||
placeholder="状态搜索"
|
placeholder="状态搜索"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 150px"
|
style="width: 150px"
|
||||||
@ -282,11 +282,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
||||||
import {
|
import { TreeNodeData, TableData } from '@arco-design/web-vue';
|
||||||
SelectOptionData,
|
|
||||||
TreeNodeData,
|
|
||||||
TableData,
|
|
||||||
} from '@arco-design/web-vue';
|
|
||||||
import {
|
import {
|
||||||
DeptRecord,
|
DeptRecord,
|
||||||
DeptParam,
|
DeptParam,
|
||||||
@ -299,6 +295,7 @@
|
|||||||
import { listDeptTree } from '@/api/common';
|
import { listDeptTree } from '@/api/common';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const { DisEnableStatusEnum } = proxy.useDict('DisEnableStatusEnum');
|
||||||
|
|
||||||
const deptList = ref<DeptRecord[]>([]);
|
const deptList = ref<DeptRecord[]>([]);
|
||||||
const dept = ref<DeptRecord>({
|
const dept = ref<DeptRecord>({
|
||||||
@ -322,10 +319,6 @@
|
|||||||
const exportLoading = ref(false);
|
const exportLoading = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const detailVisible = ref(false);
|
const detailVisible = ref(false);
|
||||||
const statusOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '禁用', value: 2 },
|
|
||||||
]);
|
|
||||||
const treeData = ref<TreeNodeData[]>();
|
const treeData = ref<TreeNodeData[]>();
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<a-form-item field="status" hide-label>
|
<a-form-item field="status" hide-label>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
:options="statusOptions"
|
:options="DisEnableStatusEnum"
|
||||||
placeholder="状态搜索"
|
placeholder="状态搜索"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 150px"
|
style="width: 150px"
|
||||||
@ -335,11 +335,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
||||||
import {
|
import { TreeNodeData, TableData } from '@arco-design/web-vue';
|
||||||
SelectOptionData,
|
|
||||||
TreeNodeData,
|
|
||||||
TableData,
|
|
||||||
} from '@arco-design/web-vue';
|
|
||||||
import {
|
import {
|
||||||
MenuRecord,
|
MenuRecord,
|
||||||
MenuParam,
|
MenuParam,
|
||||||
@ -352,6 +348,7 @@
|
|||||||
import { listMenuTree } from '@/api/common';
|
import { listMenuTree } from '@/api/common';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const { DisEnableStatusEnum } = proxy.useDict('DisEnableStatusEnum');
|
||||||
|
|
||||||
const menuList = ref<MenuRecord[]>([]);
|
const menuList = ref<MenuRecord[]>([]);
|
||||||
const ids = ref<Array<number>>([]);
|
const ids = ref<Array<number>>([]);
|
||||||
@ -364,10 +361,6 @@
|
|||||||
const expandAll = ref(false);
|
const expandAll = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const showChooseIcon = ref(false);
|
const showChooseIcon = ref(false);
|
||||||
const statusOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '禁用', value: 2 },
|
|
||||||
]);
|
|
||||||
const treeData = ref<TreeNodeData[]>();
|
const treeData = ref<TreeNodeData[]>();
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<a-form-item field="status" hide-label>
|
<a-form-item field="status" hide-label>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
:options="statusOptions"
|
:options="DisEnableStatusEnum"
|
||||||
placeholder="状态搜索"
|
placeholder="状态搜索"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 150px"
|
style="width: 150px"
|
||||||
@ -267,7 +267,6 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
||||||
import { SelectOptionData } from '@arco-design/web-vue';
|
|
||||||
import {
|
import {
|
||||||
PostRecord,
|
PostRecord,
|
||||||
PostParam,
|
PostParam,
|
||||||
@ -279,6 +278,7 @@
|
|||||||
} from '@/api/system/post';
|
} from '@/api/system/post';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const { DisEnableStatusEnum } = proxy.useDict('DisEnableStatusEnum');
|
||||||
|
|
||||||
const postList = ref<PostRecord[]>([]);
|
const postList = ref<PostRecord[]>([]);
|
||||||
const post = ref<PostRecord>({
|
const post = ref<PostRecord>({
|
||||||
@ -301,10 +301,6 @@
|
|||||||
const exportLoading = ref(false);
|
const exportLoading = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const detailVisible = ref(false);
|
const detailVisible = ref(false);
|
||||||
const statusOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '禁用', value: 2 },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
// 查询参数
|
// 查询参数
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<a-form-item field="status" hide-label>
|
<a-form-item field="status" hide-label>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
:options="statusOptions"
|
:options="DisEnableStatusEnum"
|
||||||
placeholder="状态搜索"
|
placeholder="状态搜索"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 150px"
|
style="width: 150px"
|
||||||
@ -244,7 +244,7 @@
|
|||||||
<a-form-item label="数据权限" field="dataScope">
|
<a-form-item label="数据权限" field="dataScope">
|
||||||
<a-select
|
<a-select
|
||||||
v-model="form.dataScope"
|
v-model="form.dataScope"
|
||||||
:options="dataScopeOptions"
|
:options="DataScopeEnum"
|
||||||
placeholder="请选择数据权限"
|
placeholder="请选择数据权限"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -378,7 +378,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
|
||||||
import { SelectOptionData, TreeNodeData } from '@arco-design/web-vue';
|
import { TreeNodeData } from '@arco-design/web-vue';
|
||||||
import {
|
import {
|
||||||
RoleRecord,
|
RoleRecord,
|
||||||
RoleParam,
|
RoleParam,
|
||||||
@ -391,6 +391,7 @@
|
|||||||
import { listMenuTree, listDeptTree } from '@/api/common';
|
import { listMenuTree, listDeptTree } from '@/api/common';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const { DataScopeEnum, DisEnableStatusEnum } = proxy.useDict('DataScopeEnum', 'DisEnableStatusEnum');
|
||||||
|
|
||||||
const roleList = ref<RoleRecord[]>([]);
|
const roleList = ref<RoleRecord[]>([]);
|
||||||
const role = ref<RoleRecord>({
|
const role = ref<RoleRecord>({
|
||||||
@ -417,17 +418,6 @@
|
|||||||
const exportLoading = ref(false);
|
const exportLoading = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const detailVisible = ref(false);
|
const detailVisible = ref(false);
|
||||||
const statusOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '禁用', value: 2 },
|
|
||||||
]);
|
|
||||||
const dataScopeOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '全部数据权限', value: 1 },
|
|
||||||
{ label: '本部门及以下数据权限', value: 2 },
|
|
||||||
{ label: '本部门数据权限', value: 3 },
|
|
||||||
{ label: '仅本人数据权限', value: 4 },
|
|
||||||
{ label: '自定义数据权限', value: 5 },
|
|
||||||
]);
|
|
||||||
const menuLoading = ref(false);
|
const menuLoading = ref(false);
|
||||||
const deptLoading = ref(false);
|
const deptLoading = ref(false);
|
||||||
const menuOptions = ref<TreeNodeData[]>([]);
|
const menuOptions = ref<TreeNodeData[]>([]);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<a-form-item field="status" hide-label>
|
<a-form-item field="status" hide-label>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
:options="statusOptions"
|
:options="DisEnableStatusEnum"
|
||||||
placeholder="状态搜索"
|
placeholder="状态搜索"
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 150px"
|
style="width: 150px"
|
||||||
@ -484,7 +484,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getCurrentInstance, ref, toRefs, reactive, watch } from 'vue';
|
import { getCurrentInstance, ref, toRefs, reactive, watch } from 'vue';
|
||||||
import { SelectOptionData, TreeNodeData } from '@arco-design/web-vue';
|
import { TreeNodeData } from '@arco-design/web-vue';
|
||||||
import {
|
import {
|
||||||
UserRecord,
|
UserRecord,
|
||||||
UserParam,
|
UserParam,
|
||||||
@ -496,15 +496,12 @@
|
|||||||
resetPassword,
|
resetPassword,
|
||||||
updateUserRole,
|
updateUserRole,
|
||||||
} from '@/api/system/user';
|
} from '@/api/system/user';
|
||||||
import {
|
import { listDeptTree, listPostDict, listRoleDict } from '@/api/common';
|
||||||
LabelValueRecord,
|
import { LabelValueState } from '@/store/modules/dict/types';
|
||||||
listDeptTree,
|
|
||||||
listPostDict,
|
|
||||||
listRoleDict,
|
|
||||||
} from '@/api/common';
|
|
||||||
import getAvatar from '@/utils/avatar';
|
import getAvatar from '@/utils/avatar';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const { DisEnableStatusEnum } = proxy.useDict('DisEnableStatusEnum');
|
||||||
|
|
||||||
const userList = ref<UserRecord[]>([]);
|
const userList = ref<UserRecord[]>([]);
|
||||||
const user = ref<UserRecord>({
|
const user = ref<UserRecord>({
|
||||||
@ -535,16 +532,12 @@
|
|||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const userRoleVisible = ref(false);
|
const userRoleVisible = ref(false);
|
||||||
const detailVisible = ref(false);
|
const detailVisible = ref(false);
|
||||||
const statusOptions = ref<SelectOptionData[]>([
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '禁用', value: 2 },
|
|
||||||
]);
|
|
||||||
const deptLoading = ref(false);
|
const deptLoading = ref(false);
|
||||||
const postLoading = ref(false);
|
const postLoading = ref(false);
|
||||||
const roleLoading = ref(false);
|
const roleLoading = ref(false);
|
||||||
const deptOptions = ref<TreeNodeData[]>([]);
|
const deptOptions = ref<TreeNodeData[]>([]);
|
||||||
const postOptions = ref<LabelValueRecord[]>([]);
|
const postOptions = ref<LabelValueState[]>([]);
|
||||||
const roleOptions = ref<LabelValueRecord[]>([]);
|
const roleOptions = ref<LabelValueState[]>([]);
|
||||||
const deptTree = ref<TreeNodeData[]>([]);
|
const deptTree = ref<TreeNodeData[]>([]);
|
||||||
const deptName = ref('');
|
const deptName = ref('');
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
package top.charles7c.cnadmin.webapi.controller.common;
|
package top.charles7c.cnadmin.webapi.controller.common;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@ -24,12 +25,13 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
|
import cn.hutool.core.util.ClassUtil;
|
||||||
|
|
||||||
|
import top.charles7c.cnadmin.common.base.BaseEnum;
|
||||||
|
import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
||||||
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
||||||
import top.charles7c.cnadmin.common.model.vo.LabelValueVO;
|
import top.charles7c.cnadmin.common.model.vo.LabelValueVO;
|
||||||
import top.charles7c.cnadmin.common.model.vo.R;
|
import top.charles7c.cnadmin.common.model.vo.R;
|
||||||
@ -55,6 +57,7 @@ import top.charles7c.cnadmin.system.service.RoleService;
|
|||||||
*/
|
*/
|
||||||
@Tag(name = "公共 API")
|
@Tag(name = "公共 API")
|
||||||
@Log(ignore = true)
|
@Log(ignore = true)
|
||||||
|
@Validated
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/common")
|
@RequestMapping("/common")
|
||||||
@ -64,6 +67,7 @@ public class CommonController {
|
|||||||
private final MenuService menuService;
|
private final MenuService menuService;
|
||||||
private final RoleService roleService;
|
private final RoleService roleService;
|
||||||
private final PostService postService;
|
private final PostService postService;
|
||||||
|
private final ContiNewAdminProperties properties;
|
||||||
|
|
||||||
@Operation(summary = "查询部门树", description = "查询树结构的部门列表")
|
@Operation(summary = "查询部门树", description = "查询树结构的部门列表")
|
||||||
@GetMapping("/tree/dept")
|
@GetMapping("/tree/dept")
|
||||||
@ -96,4 +100,24 @@ public class CommonController {
|
|||||||
List<LabelValueVO<Long>> dictList = postService.buildDict(list);
|
List<LabelValueVO<Long>> dictList = postService.buildDict(list);
|
||||||
return R.ok(dictList);
|
return R.ok(dictList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询枚举字典", description = "查询枚举字典列表")
|
||||||
|
@GetMapping("/dict/enum/{enumTypeName}")
|
||||||
|
public R<List<LabelValueVO>> listEnumDict(@PathVariable String enumTypeName) {
|
||||||
|
// 扫描所有 BaseEnum 枚举基类的子类
|
||||||
|
Set<Class<?>> classSet = ClassUtil.scanPackageBySuper(properties.getBasePackage(), BaseEnum.class);
|
||||||
|
Optional<Class<?>> first =
|
||||||
|
classSet.stream().filter(c -> c.getSimpleName().equalsIgnoreCase(enumTypeName)).findFirst();
|
||||||
|
if (!first.isPresent()) {
|
||||||
|
return R.fail("枚举字典不存在");
|
||||||
|
}
|
||||||
|
// 转换枚举为字典列表
|
||||||
|
Class<?> enumClass = first.get();
|
||||||
|
Object[] enumConstants = enumClass.getEnumConstants();
|
||||||
|
List<LabelValueVO> dictList = Arrays.stream(enumConstants).map(e -> {
|
||||||
|
BaseEnum<Integer, String> baseEnum = (BaseEnum<Integer, String>)e;
|
||||||
|
return new LabelValueVO(baseEnum.getDescription(), baseEnum.getValue());
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return R.ok(dictList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ continew-admin:
|
|||||||
description: ContiNew Admin 中后台管理框架(孵化中),Continue New Admin,持续以最新流行技术栈构建。
|
description: ContiNew Admin 中后台管理框架(孵化中),Continue New Admin,持续以最新流行技术栈构建。
|
||||||
# URL
|
# URL
|
||||||
url: https://github.com/Charles7c/continew-admin
|
url: https://github.com/Charles7c/continew-admin
|
||||||
|
# 基本包
|
||||||
|
basePackage: top.charles7c.cnadmin
|
||||||
## 作者信息配置
|
## 作者信息配置
|
||||||
author:
|
author:
|
||||||
name: Charles7c
|
name: Charles7c
|
||||||
|
Loading…
Reference in New Issue
Block a user