refactor: 规范系统页面类型命名
This commit is contained in:
@@ -231,6 +231,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useAppStore } from "@/stores/app";
|
import { useAppStore } from "@/stores/app";
|
||||||
import { DeviceEnum } from "@/enums/settings";
|
import { DeviceEnum } from "@/enums/settings";
|
||||||
|
import type { TreeNodeData } from "element-plus/es/components/tree";
|
||||||
|
|
||||||
import RoleAPI from "@/api/system/role";
|
import RoleAPI from "@/api/system/role";
|
||||||
import type { RoleItem, RoleForm } from "@/api/system/role";
|
import type { RoleItem, RoleForm } from "@/api/system/role";
|
||||||
@@ -249,7 +250,7 @@ const roleFormRef = ref();
|
|||||||
const permTreeRef = ref();
|
const permTreeRef = ref();
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const ids = ref<number[]>([]);
|
const ids = ref<string[]>([]);
|
||||||
|
|
||||||
const tableData = reactive<PageResult<RoleItem>>({
|
const tableData = reactive<PageResult<RoleItem>>({
|
||||||
list: [],
|
list: [],
|
||||||
@@ -301,6 +302,11 @@ const isExpanded = ref(true);
|
|||||||
|
|
||||||
const parentChildLinked = ref(true);
|
const parentChildLinked = ref(true);
|
||||||
|
|
||||||
|
interface ToggleableTreeNode {
|
||||||
|
expand: () => void;
|
||||||
|
collapse: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载角色列表数据
|
* 加载角色列表数据
|
||||||
*/
|
*/
|
||||||
@@ -337,8 +343,8 @@ function handleResetQuery(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 行复选框选中
|
// 行复选框选中
|
||||||
function handleSelectionChange(selection: any): void {
|
function handleSelectionChange(selection: RoleItem[]): void {
|
||||||
ids.value = selection.map((item: any) => item.id);
|
ids.value = selection.flatMap((item) => (item.id ? [item.id] : []));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -489,9 +495,10 @@ async function handleAssignPermClick(row: RoleItem): Promise<void> {
|
|||||||
function handleAssignPermSubmit() {
|
function handleAssignPermSubmit() {
|
||||||
const roleId = checkedRole.value.id;
|
const roleId = checkedRole.value.id;
|
||||||
if (roleId) {
|
if (roleId) {
|
||||||
const checkedMenuIds: number[] = permTreeRef
|
const checkedMenuIds = permTreeRef
|
||||||
.value!.getCheckedNodes(false, true)
|
.value!.getCheckedNodes(false, true)
|
||||||
.map((node: any) => node.value);
|
.map((node: TreeNodeData) => Number(node.value))
|
||||||
|
.filter((value: number) => !Number.isNaN(value));
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
RoleAPI.updateRoleMenus(roleId, checkedMenuIds)
|
RoleAPI.updateRoleMenus(roleId, checkedMenuIds)
|
||||||
@@ -510,11 +517,12 @@ function handleAssignPermSubmit() {
|
|||||||
function togglePermTree(): void {
|
function togglePermTree(): void {
|
||||||
isExpanded.value = !isExpanded.value;
|
isExpanded.value = !isExpanded.value;
|
||||||
if (permTreeRef.value) {
|
if (permTreeRef.value) {
|
||||||
Object.values(permTreeRef.value.store.nodesMap).forEach((node: any) => {
|
Object.values(permTreeRef.value.store.nodesMap).forEach((node) => {
|
||||||
|
const treeNode = node as ToggleableTreeNode;
|
||||||
if (isExpanded.value) {
|
if (isExpanded.value) {
|
||||||
node.expand();
|
treeNode.expand();
|
||||||
} else {
|
} else {
|
||||||
node.collapse();
|
treeNode.collapse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -525,19 +533,14 @@ watch(permKeywords, (val) => {
|
|||||||
permTreeRef.value!.filter(val);
|
permTreeRef.value!.filter(val);
|
||||||
});
|
});
|
||||||
|
|
||||||
function handlePermFilter(
|
function handlePermFilter(value: string, data: TreeNodeData) {
|
||||||
value: string,
|
|
||||||
data: {
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
if (!value) return true;
|
if (!value) return true;
|
||||||
return data.label.includes(value);
|
return String(data.label ?? "").includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 父子菜单节点是否联动
|
// 父子菜单节点是否联动
|
||||||
function handleParentChildLinkedChange(val: any): void {
|
function handleParentChildLinkedChange(val: string | number | boolean): void {
|
||||||
parentChildLinked.value = val;
|
parentChildLinked.value = Boolean(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import DeptAPI from "@/api/system/dept";
|
import DeptAPI from "@/api/system/dept";
|
||||||
|
import type { TreeNodeData } from "element-plus/es/components/tree";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@@ -32,7 +33,7 @@ const props = defineProps({
|
|||||||
// 部门树数据
|
// 部门树数据
|
||||||
const deptList = ref<OptionItem[]>();
|
const deptList = ref<OptionItem[]>();
|
||||||
const deptTreeRef = ref();
|
const deptTreeRef = ref();
|
||||||
const deptName = ref();
|
const deptName = ref("");
|
||||||
|
|
||||||
const emits = defineEmits(["node-click"]);
|
const emits = defineEmits(["node-click"]);
|
||||||
|
|
||||||
@@ -50,17 +51,17 @@ watchEffect(
|
|||||||
/**
|
/**
|
||||||
* 部门筛选
|
* 部门筛选
|
||||||
*/
|
*/
|
||||||
function handleFilter(value: string, data: any): boolean {
|
function handleFilter(value: string, data: TreeNodeData): boolean {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return data.label.indexOf(value) !== -1;
|
return String(data.label ?? "").includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门树节点点击事件
|
* 部门树节点点击事件
|
||||||
*/
|
*/
|
||||||
function handleNodeClick(data: { [key: string]: any }): void {
|
function handleNodeClick(data: OptionItem): void {
|
||||||
deptId.value = data.value;
|
deptId.value = data.value;
|
||||||
emits("node-click");
|
emits("node-click");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ function handleResetPassword(row: UserItem): void {
|
|||||||
inputPattern: /.{6,}/,
|
inputPattern: /.{6,}/,
|
||||||
inputErrorMessage: "密码至少需要6位字符",
|
inputErrorMessage: "密码至少需要6位字符",
|
||||||
}).then(
|
}).then(
|
||||||
(result: any) => resetPassword(row.id, result.value),
|
(result: { value: string }) => resetPassword(row.id, result.value),
|
||||||
() => {
|
() => {
|
||||||
/* 用户取消 */
|
/* 用户取消 */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user