tree宽度修改

This commit is contained in:
仲么了
2024-01-29 15:42:45 +08:00
parent 9351307908
commit cea1f4863f
4 changed files with 26 additions and 19 deletions

View File

@@ -1,12 +1,12 @@
<template> <template>
<div :style="{ width: menuCollapse ? '40px' : '280px' }" style="transition: all .3s; overflow: hidden;" > <div :style="{ width: menuCollapse ? '40px' : props.width }" style="transition: all 0.3s; overflow: hidden">
<Icon <Icon
v-show="menuCollapse" v-show="menuCollapse"
@click="onMenuCollapse" @click="onMenuCollapse"
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="menuCollapse ? 'unfold' : ''" :class="menuCollapse ? 'unfold' : ''"
size="18" size="18"
class="fold ml10 mt20 menu-collapse" class="fold ml10 mt20 menu-collapse"
style="cursor: pointer" style="cursor: pointer"
/> />
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }"> <div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
@@ -59,6 +59,13 @@ import { ref, watch } from 'vue'
defineOptions({ defineOptions({
name: 'govern/tree' name: 'govern/tree'
}) })
interface Props {
width?: string
}
const props = withDefaults(defineProps<Props>(), {
width: '280px'
})
const { proxy } = useCurrentInstance() const { proxy } = useCurrentInstance()
const menuCollapse = ref(false) const menuCollapse = ref(false)
const filterText = ref('') const filterText = ref('')
@@ -89,7 +96,7 @@ defineExpose({ treeRef })
box-sizing: border-box; box-sizing: border-box;
padding: 10px; padding: 10px;
height: 100%; height: 100%;
width: 280px; width: 100%;
:deep(.el-tree) { :deep(.el-tree) {
border: 1px solid var(--el-border-color); border: 1px solid var(--el-border-color);
} }

View File

@@ -74,7 +74,7 @@ export default class TableStore {
) )
).then((res: any) => { ).then((res: any) => {
this.table.data = res.data.records || res.data this.table.data = res.data.records || res.data
this.table.total = res.data.total || res.data.length||0 this.table.total = res.data.total || res.data.length || 0
if (this.isWebPaging) { if (this.isWebPaging) {
this.table.webPagingData = window.XEUtils.chunk(this.table.data, this.table.params.pageSize) this.table.webPagingData = window.XEUtils.chunk(this.table.data, this.table.params.pageSize)
this.table.data = this.table.webPagingData[this.table.params.pageNum - 1] this.table.data = this.table.webPagingData[this.table.params.pageNum - 1]

View File

@@ -1,23 +1,22 @@
<template> <template>
<div class="default-main" style="display: flex" :style="{ height: height }"> <div class="default-main" style="display: flex" :style="{ height: height }">
<div style="width: calc(100% - 280px)"> <div style="flex: 1; overflow: hidden">
<div class="custom-table-header"> <div class="custom-table-header">
<div style="flex: 1; font-weight: 700">角色列表</div> <div style="flex: 1; font-weight: 700">角色列表</div>
<el-button :icon="Plus" type="primary" @click="addRole" class="ml10">新增</el-button> <el-button :icon="Plus" type="primary" @click="addRole" class="ml10">新增</el-button>
</div> </div>
<Table ref="tableRef" @currentChange="currentChange" /> <Table ref="tableRef" @currentChange="currentChange" />
</div> </div>
<div style="height: 100%; flex: 1"> <Tree
<Tree v-if="menuListId"
v-if="menuListId" ref="treeRef"
ref="treeRef" show-checkbox
show-checkbox width="350px"
:data="menuTree" :data="menuTree"
:checkStrictly="checkStrictly" :checkStrictly="checkStrictly"
@check-change="checkChange" @check-change="checkChange"
></Tree> ></Tree>
<el-empty style="width: 100%; padding-top: 300px; box-sizing: border-box" description="请选择角色" v-else /> <el-empty style="width: 350px; padding-top: 300px; box-sizing: border-box" description="请选择角色" v-else />
</div>
<PopupForm ref="popupRef"></PopupForm> <PopupForm ref="popupRef"></PopupForm>
</div> </div>
</template> </template>
@@ -61,11 +60,11 @@ const tableStore = new TableStore({
render: 'tag', render: 'tag',
custom: { custom: {
0: 'danger', 0: 'danger',
1: 'success', 1: 'success'
}, },
replaceValue: { replaceValue: {
0: '注销', 0: '注销',
1: '正常', 1: '正常'
} }
}, },
{ {
@@ -150,7 +149,7 @@ const checkChange = (data: any) => {
timeout.value = setTimeout(() => { timeout.value = setTimeout(() => {
updateRoleMenu({ updateRoleMenu({
id: menuListId.value, id: menuListId.value,
idList: treeRef.value.treeRef.getCheckedNodes(false, true).map(node => node.id) idList: treeRef.value.treeRef.getCheckedNodes(false, true).map((node: any) => node.id)
}) })
}, 1000) }, 1000)
} }

View File

@@ -23,6 +23,7 @@ defineOptions({
const popupFormRef = ref() const popupFormRef = ref()
const tableStore = new TableStore({ const tableStore = new TableStore({
showPage:false,
url: '/system-boot/dic/dicTree', url: '/system-boot/dic/dicTree',
method: 'GET', method: 'GET',
column: [ column: [