Merge branch 'warm-flw-future' of https://gitee.com/JavaLionLi/plus-ui into warm-flw-future

This commit is contained in:
gssong 2024-12-15 01:38:47 +08:00
commit 54f1d2588d
9 changed files with 77 additions and 23 deletions

View File

@ -28,6 +28,18 @@ export interface DeptVO extends BaseEntity {
menuId: string | number; menuId: string | number;
} }
/**
*
*/
export interface DeptTreeVO extends BaseEntity {
id: number | string;
label: string;
parentId: number | string;
weight: number;
children: DeptTreeVO[];
disabled: boolean;
}
/** /**
* *
*/ */

View File

@ -1,4 +1,4 @@
import { DeptVO } from './../dept/types'; import {DeptTreeVO, DeptVO} from './../dept/types';
import { RoleVO } from '@/api/system/role/types'; import { RoleVO } from '@/api/system/role/types';
import request from '@/utils/request'; import request from '@/utils/request';
import { AxiosPromise } from 'axios'; import { AxiosPromise } from 'axios';
@ -202,7 +202,7 @@ export const listUserByDeptId = (deptId: string | number): AxiosPromise<UserVO[]
/** /**
* *
*/ */
export const deptTreeSelect = (): AxiosPromise<DeptVO[]> => { export const deptTreeSelect = (): AxiosPromise<DeptTreeVO[]> => {
return request({ return request({
url: '/system/user/deptTree', url: '/system/user/deptTree',
method: 'get' method: 'get'

View File

@ -20,6 +20,7 @@ import useTagsViewStore from '@/store/modules/tagsView';
import IframeToggle from './IframeToggle/index.vue'; import IframeToggle from './IframeToggle/index.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const route = useRoute();
const tagsViewStore = useTagsViewStore(); const tagsViewStore = useTagsViewStore();
// //
@ -37,6 +38,20 @@ watch(
}, },
{ immediate: true } { immediate: true }
); );
onMounted(() => {
addIframe()
})
watchEffect((route) => {
addIframe()
})
function addIframe() {
if (route.meta.link) {
useTagsViewStore().addIframeView(route)
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -135,11 +135,7 @@ const addTags = () => {
} }
if (name) { if (name) {
useTagsViewStore().addView(route as any); useTagsViewStore().addView(route as any);
if (route.meta.link) {
useTagsViewStore().addIframeView(route as any);
}
} }
return false;
}; };
const moveToCurrentTag = () => { const moveToCurrentTag = () => {
nextTick(() => { nextTick(() => {

View File

@ -3,14 +3,18 @@ import router from './router';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import 'nprogress/nprogress.css'; import 'nprogress/nprogress.css';
import { getToken } from '@/utils/auth'; import { getToken } from '@/utils/auth';
import { isHttp } from '@/utils/validate'; import { isHttp, isPathMatch } from '@/utils/validate';
import { isRelogin } from '@/utils/request'; import { isRelogin } from '@/utils/request';
import useUserStore from '@/store/modules/user'; import useUserStore from '@/store/modules/user';
import useSettingsStore from '@/store/modules/settings'; import useSettingsStore from '@/store/modules/settings';
import usePermissionStore from '@/store/modules/permission'; import usePermissionStore from '@/store/modules/permission';
NProgress.configure({ showSpinner: false }); NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/register', '/social-callback']; const whiteList = ['/login', '/register', '/social-callback', '/register*', '/register/*'];
const isWhiteList = (path: string) => {
return whiteList.some(pattern => isPathMatch(pattern, path))
}
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
NProgress.start(); NProgress.start();
@ -20,7 +24,7 @@ router.beforeEach(async (to, from, next) => {
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }); next({ path: '/' });
NProgress.done(); NProgress.done();
} else if (whiteList.indexOf(to.path as string) !== -1) { } else if (isWhiteList(to.path)) {
next(); next();
} else { } else {
if (useUserStore().roles.length === 0) { if (useUserStore().roles.length === 0) {
@ -49,7 +53,7 @@ router.beforeEach(async (to, from, next) => {
} }
} else { } else {
// 没有token // 没有token
if (whiteList.indexOf(to.path as string) !== -1) { if (isWhiteList(to.path)) {
// 在免登录白名单,直接进入 // 在免登录白名单,直接进入
next(); next();
} else { } else {

View File

@ -1,3 +1,15 @@
/**
*
* @param {string} pattern
* @param {string} path
* @returns {Boolean}
*/
export function isPathMatch(pattern: string, path: string) {
const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*\*/g, '.*').replace(/\*/g, '[^\\/]*')
const regex = new RegExp(`^${regexPattern}$`)
return regex.test(path)
}
/** /**
* url是否是http或https * url是否是http或https
* @returns {Boolean} * @returns {Boolean}

View File

@ -159,8 +159,8 @@ const dialog = reactive<DialogOption>({
// //
const columns = ref<FieldOption[]>([ const columns = ref<FieldOption[]>([
{ key: 0, label: `主建`, visible: true }, { key: 0, label: `主建`, visible: false },
{ key: 1, label: `配置key`, visible: false }, { key: 1, label: `配置key`, visible: true },
{ key: 2, label: `访问站点`, visible: true }, { key: 2, label: `访问站点`, visible: true },
{ key: 3, label: `自定义域名`, visible: true }, { key: 3, label: `自定义域名`, visible: true },
{ key: 4, label: `桶名称`, visible: true }, { key: 4, label: `桶名称`, visible: true },

View File

@ -154,7 +154,7 @@
<el-form-item label="归属部门" prop="deptId"> <el-form-item label="归属部门" prop="deptId">
<el-tree-select <el-tree-select
v-model="form.deptId" v-model="form.deptId"
:data="deptOptions" :data="enabledDeptOptions"
:props="{ value: 'id', label: 'label', children: 'children' }" :props="{ value: 'id', label: 'label', children: 'children' }"
value-key="id" value-key="id"
placeholder="请选择归属部门" placeholder="请选择归属部门"
@ -287,7 +287,7 @@
<script setup name="User" lang="ts"> <script setup name="User" lang="ts">
import api from '@/api/system/user'; import api from '@/api/system/user';
import { UserForm, UserQuery, UserVO } from '@/api/system/user/types'; import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
import { DeptVO } from '@/api/system/dept/types'; import {DeptTreeVO, DeptVO} from '@/api/system/dept/types';
import { RoleVO } from '@/api/system/role/types'; import { RoleVO } from '@/api/system/role/types';
import { PostQuery, PostVO } from '@/api/system/post/types'; import { PostQuery, PostVO } from '@/api/system/post/types';
import { treeselect } from '@/api/system/dept'; import { treeselect } from '@/api/system/dept';
@ -307,7 +307,8 @@ const multiple = ref(true);
const total = ref(0); const total = ref(0);
const dateRange = ref<[DateModelType, DateModelType]>(['', '']); const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const deptName = ref(''); const deptName = ref('');
const deptOptions = ref<DeptVO[]>([]); const deptOptions = ref<DeptTreeVO[]>([]);
const enabledDeptOptions = ref<DeptTreeVO[]>([]);
const initPassword = ref<string>(''); const initPassword = ref<string>('');
const postOptions = ref<PostVO[]>([]); const postOptions = ref<PostVO[]>([]);
const roleOptions = ref<RoleVO[]>([]); const roleOptions = ref<RoleVO[]>([]);
@ -431,12 +432,6 @@ watchEffect(
} }
); );
/** 查询部门下拉树结构 */
const getTreeSelect = async () => {
const res = await api.deptTreeSelect();
deptOptions.value = res.data;
};
/** 查询用户列表 */ /** 查询用户列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
@ -446,6 +441,26 @@ const getList = async () => {
total.value = res.total; total.value = res.total;
}; };
/** 查询部门下拉树结构 */
const getDeptTree = async () => {
const res = await api.deptTreeSelect();
deptOptions.value = res.data;
enabledDeptOptions.value = filterDisabledDept(res.data);
};
/** 过滤禁用的部门 */
const filterDisabledDept = (deptList: DeptTreeVO[]) => {
return deptList.filter(dept => {
if (dept.disabled) {
return false;
}
if (dept.children && dept.children.length) {
dept.children = filterDisabledDept(dept.children);
}
return true;
});
};
/** 节点单击事件 */ /** 节点单击事件 */
const handleNodeClick = (data: DeptVO) => { const handleNodeClick = (data: DeptVO) => {
queryParams.value.deptId = data.id; queryParams.value.deptId = data.id;
@ -643,7 +658,7 @@ const resetForm = () => {
form.value.status = '1'; form.value.status = '1';
}; };
onMounted(() => { onMounted(() => {
getTreeSelect(); // getDeptTree(); //
getList(); // getList(); //
proxy?.getConfigKey('sys.user.initPassword').then((response) => { proxy?.getConfigKey('sys.user.initPassword').then((response) => {
initPassword.value = response.data; initPassword.value = response.data;

View File

@ -243,8 +243,8 @@ onMounted(() => {
queryParams.value.pageNum = Number(route.query.pageNum); queryParams.value.pageNum = Number(route.query.pageNum);
dateRange.value = ['', '']; dateRange.value = ['', ''];
queryFormRef.value?.resetFields(); queryFormRef.value?.resetFields();
getList();
} }
getList();
getDataNameList(); getDataNameList();
}); });
</script> </script>