mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 14:10:27 +08:00
优化
This commit is contained in:
parent
561b6a670d
commit
0d144e3089
@ -31,11 +31,13 @@
|
||||
<el-tree
|
||||
class="tree"
|
||||
highlight-current
|
||||
auto-expand-parent
|
||||
:expand-on-click-node="false"
|
||||
:ref="setRefs('tree')"
|
||||
:lazy="tree.lazy"
|
||||
:data="list"
|
||||
:props="tree.props"
|
||||
:load="tree.onLoad"
|
||||
:default-expanded-keys="tree.defaultExpandedKeys"
|
||||
@node-click="select"
|
||||
>
|
||||
<template #default="{ data }">
|
||||
@ -148,7 +150,7 @@ import {
|
||||
Refresh as IconRefresh,
|
||||
Plus
|
||||
} from "@element-plus/icons-vue";
|
||||
import { useBrowser } from "/@/cool";
|
||||
import { useBrowser, useCool } from "/@/cool";
|
||||
import { ContextMenu, useForm, setFocus } from "@cool-vue/crud";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { ClViewGroup } from "./hook";
|
||||
@ -158,6 +160,7 @@ import { deepTree } from "/@/cool/utils";
|
||||
const { browser, onScreenChange } = useBrowser();
|
||||
const slots = useSlots();
|
||||
const Form = useForm();
|
||||
const { refs, setRefs } = useCool();
|
||||
|
||||
// 配置
|
||||
const config = reactive(
|
||||
@ -330,10 +333,12 @@ async function refresh(params?: any) {
|
||||
let req;
|
||||
|
||||
if (tree.visible) {
|
||||
// 树形数据
|
||||
req = config.service.list(data).then((res) => {
|
||||
list.value = deepTree(res);
|
||||
});
|
||||
} else {
|
||||
// 列表数据
|
||||
req = config.service.page(data).then((res) => {
|
||||
const arr = config.onData?.(res.list) || res.list;
|
||||
|
||||
@ -352,10 +357,13 @@ async function refresh(params?: any) {
|
||||
const item = selected.value || list.value[0];
|
||||
|
||||
if (item) {
|
||||
tree.defaultExpandedKeys = [item.id];
|
||||
}
|
||||
if (tree.visible) {
|
||||
const node = refs.tree.getNode(item);
|
||||
node.expand();
|
||||
}
|
||||
|
||||
select(item);
|
||||
select(item);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err.message);
|
||||
@ -509,8 +517,6 @@ defineExpose({
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,11 @@ import ClAvatar from "../components/avatar/index";
|
||||
export function useDeptViewGroup(options: DeepPartial<ClViewGroup.Options>) {
|
||||
const { ViewGroup } = useViewGroup({
|
||||
...options,
|
||||
label: "员工列表",
|
||||
service: service.base.sys.department,
|
||||
enableAdd: false,
|
||||
label: "员工列表",
|
||||
enableRefresh: false,
|
||||
enableContextMenu: false,
|
||||
tree: {
|
||||
lazy: true,
|
||||
onLoad(node: Node, resolve: (data: TreeData) => void) {
|
||||
@ -25,6 +27,7 @@ export function useDeptViewGroup(options: DeepPartial<ClViewGroup.Options>) {
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
res.unshift(...(node.data.children || []));
|
||||
|
||||
resolve(res);
|
||||
|
@ -33,11 +33,11 @@
|
||||
v-loading="loading"
|
||||
node-key="id"
|
||||
default-expand-all
|
||||
highlight-current
|
||||
:data="list"
|
||||
:props="{
|
||||
label: 'name'
|
||||
}"
|
||||
highlight-current
|
||||
:draggable="isDrag"
|
||||
:allow-drag="allowDrag"
|
||||
:allow-drop="allowDrop"
|
||||
@ -450,7 +450,6 @@ onMounted(function () {
|
||||
|
||||
&.is-active {
|
||||
color: var(--color-primary);
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user