提交 ac8f8271 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 新增树表格

上级 8d911cd4
<template>
<div class="complex-table">
<div v-if="$slots.header || header" class="complex-table__header">
<slot name="header">{{ header }}</slot>
</div>
<div v-if="$slots.toolbar || searchConfig" class="complex-table__toolbar">
<slot name="toolbar">
<fu-search-bar v-bind="searchConfig" @exec="search">
<slot name="buttons" />
<fu-table-column-select :columns="columns" />
</fu-search-bar>
</slot>
</div>
<div class="complex-table__body">
<slot />
<!-- <fu-table ref="table" v-bind="$attrs" :columns="columns" :local-key="localKey" v-on="$listeners">
<slot />
</fu-table> -->
</div>
<div v-if="$slots.pagination || paginationConfig" class="complex-table__pagination">
<slot name="pagination">
<fu-table-pagination
:current-page.sync="paginationConfig.currentPage"
:page-size.sync="paginationConfig.pageSize"
v-bind="paginationConfig"
@change="search"
/>
</slot>
</div>
</div>
</template>
<script>
export default {
name: 'TreeTable',
props: {
columns: {
type: Array,
default: () => []
},
// eslint-disable-next-line vue/require-default-prop
localKey: String, // 如果需要记住选择的列,则这里添加一个唯一的Key
// eslint-disable-next-line vue/require-default-prop
header: String,
// eslint-disable-next-line vue/require-default-prop
searchConfig: Object,
// eslint-disable-next-line vue/require-default-prop
paginationConfig: Object
},
data() {
return {
condition: {}
}
},
methods: {
search(condition, e) {
if (condition) {
this.condition = condition
}
this.$emit('search', this.condition, e)
}
}
}
</script>
<style lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/variables.scss";
.complex-table {
.complex-table__header {
@include flex-row(flex-start, center);
height: 60px;
font-size: 20px;
}
.complex-table__toolbar {
@include flex-row(flex-end, center);
}
.complex-table__pagination {
margin-top: 20px;
@include flex-row(flex-end);
}
}
</style>
<template> <template>
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]"> <layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
<complex-table <!-- <complex-table
ref="table" ref="table"
:data="tableData" :data="tableData"
:lazy="isLazy" :lazy="isLazy"
...@@ -15,15 +15,31 @@ ...@@ -15,15 +15,31 @@
:default-expand-all="isTableExpand" :default-expand-all="isTableExpand"
row-key="deptId" row-key="deptId"
@search="search" @search="search"
> -->
<tree-table
:columns="columns"
:buttons="buttons"
:header="header"
:search-config="searchConfig"
@search="search"
> >
<template #buttons> <template #buttons>
<fu-table-button icon="el-icon-circle-plus-outline" :label="$t('organization.create')" @click="create" /> <fu-table-button icon="el-icon-circle-plus-outline" :label="$t('organization.create')" @click="create" />
</template> </template>
<el-table
<!-- <el-table-column type="selection" fix /> --> ref="table"
<el-table-column label="名称" prop="name" /> :data="tableData"
<el-table-column label="下属组织数" prop="subCount" /> lazy
<!-- <el-table-column label="状态" align="center" prop="enabled"> :load="loadExpandDatas"
style="width: 100%"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
row-key="deptId"
>
<!-- <el-table-column type="selection" fix /> -->
<el-table-column label="名称" prop="name" />
<el-table-column label="下属组织数" prop="subCount" />
<!-- <el-table-column label="状态" align="center" prop="enabled">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
v-model="scope.row.enabled" v-model="scope.row.enabled"
...@@ -34,14 +50,16 @@ ...@@ -34,14 +50,16 @@
/> />
</template> </template>
</el-table-column> --> </el-table-column> -->
<el-table-column prop="createTime" label="创建日期"> <el-table-column prop="createTime" label="创建日期">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span> <span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<fu-table-operations :buttons="buttons" label="操作" fix /> <fu-table-operations :buttons="buttons" label="操作" fix />
</complex-table> </el-table>
</tree-table>
<!-- </complex-table> -->
<!-- add organization form --> <!-- add organization form -->
<el-dialog <el-dialog
...@@ -106,7 +124,7 @@ ...@@ -106,7 +124,7 @@
<script> <script>
import LayoutContent from '@/components/business/LayoutContent' import LayoutContent from '@/components/business/LayoutContent'
import ComplexTable from '@/components/business/complex-table' import TreeTable from '@/components/business/tree-table'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import { formatCondition } from '@/utils/index' import { formatCondition } from '@/utils/index'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
...@@ -118,7 +136,7 @@ export default { ...@@ -118,7 +136,7 @@ export default {
name: 'MsOrganization', name: 'MsOrganization',
components: { components: {
LayoutContent, LayoutContent,
ComplexTable, TreeTable,
Treeselect Treeselect
}, },
data() { data() {
...@@ -168,11 +186,7 @@ export default { ...@@ -168,11 +186,7 @@ export default {
] ]
}, },
paginationConfig: {
currentPage: 1,
pageSize: 10,
total: 0
},
defaultCondition: { defaultCondition: {
field: 'pid', field: 'pid',
operator: 'eq', operator: 'eq',
...@@ -271,7 +285,7 @@ export default { ...@@ -271,7 +285,7 @@ export default {
}, },
// 加载表格数据 // 加载表格数据
search(condition) { search(condition) {
this.setTableAttr() // this.setTableAttr()
this.tableData = [] this.tableData = []
let param = {} let param = {}
if (condition && condition.quick) { if (condition && condition.quick) {
...@@ -293,7 +307,7 @@ export default { ...@@ -293,7 +307,7 @@ export default {
if (condition && condition.quick) { if (condition && condition.quick) {
data = this.buildTree(data) data = this.buildTree(data)
this.setTableAttr(true) // this.setTableAttr(true)
} }
this.tableData = data this.tableData = data
this.depts = null this.depts = null
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论