Skip to content

Commit 467a85f

Browse files
xrr2016levy9527
authored andcommitted
feat(header): 完善标题栏配置
1 parent 794af75 commit 467a85f

File tree

4 files changed

+68
-13
lines changed

4 files changed

+68
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ allowDrop(dragNode, dropNode, dropType) {
542542
| customQuery | 外部的注入额外的查询参数, 键值对形式 | Object | - |
543543
| extraParams | 新增/修改提交时注入额外的参数 | Object | - |
544544
| hasOperation | 是否有操作列 | Boolean | true |
545-
| hasTitle | 是否有标题栏 | Boolean | false |
545+
| hasHeader | 是否有标题栏 | Boolean | false |
546546
| hasDelete | 是否有删除按钮 | Boolean | true |
547547
| hasNew | 是否有新增按钮 | Boolean | true |
548548
| hasEdit | 是否有编辑按钮 | Boolean | true |
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
```vue
44
<template>
5-
<el-data-tree v-bind="$data" :url="getUrl" :onNew="onNew" :onEdit="onEdit" :onDelete="onDelete" />
5+
<el-data-tree v-bind="$data" :url="getUrl" :onNew="onNew" :onEdit="onEdit" :onDelete="onDelete">
6+
<span slot="title">这是 slot 标题</span>
7+
<el-button type="primary" size="mini" slot="header-new-btn">添加组织</el-button>
8+
<el-button type="primary" size="mini" slot="header-extra-block">其他按钮</el-button>
9+
</el-data-tree>
610
</template>
711
812
<script>
913
export default {
1014
data() {
1115
return {
1216
dataPath: 'data.payload',
13-
hasTitle: true,
14-
title: "这是一个标题",
17+
hasHeader: true,
1518
form: [
1619
{
1720
$id: 'name',

src/el-data-tree.vue

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
<template>
22
<div class="el-data-tree" :class="{'has-border': hasBorder }">
3-
<slot name="title" v-if="hasTitle">
4-
<p class="data-tree-title">
5-
{{ title }}
6-
<i class="el-icon-plus" @click="onDefaultNew"></i>
7-
</p>
8-
</slot>
3+
<header class="header" v-if="hasTitle || hasHeader">
4+
<div class="header-left">
5+
<!--@slot 标题 -->
6+
<slot name="title">
7+
<p class="header-title">{{ title }}</p>
8+
</slot>
9+
</div>
10+
<div class="header-right">
11+
<span class="header-new-btn" @click="onDefaultNew">
12+
<!--@slot 头部新增按钮 -->
13+
<slot name="header-new-btn">
14+
<el-button type="text" size="mini">
15+
<i class="el-icon-plus"></i>
16+
</el-button>
17+
</slot>
18+
</span>
19+
<span class="header-extra-block">
20+
<!--@slot 标题栏右边的额外区域-->
21+
<slot name="header-extra-block"></slot>
22+
</span>
23+
</div>
24+
</header>
925

1026
<section class="body">
1127
<el-input
@@ -245,12 +261,20 @@ export default {
245261
default: true
246262
},
247263
/**
248-
* 是否有标题栏
264+
* @deprecated
265+
* 是否有标题栏,建议使用 hasHeader
249266
*/
250267
hasTitle: {
251268
type: Boolean,
252269
default: false
253270
},
271+
/**
272+
* 是否有标题栏
273+
*/
274+
hasHeader: {
275+
type: Boolean,
276+
default: false
277+
},
254278
/**
255279
* 是否有删除按钮
256280
*/
@@ -657,8 +681,36 @@ $delete-color = #E24156;
657681
}
658682
}
659683
684+
.header {
685+
display: flex;
686+
align-items: center;
687+
padding: 18px 20px;
688+
border-bottom: 1px solid #ebeef5;
689+
690+
.header-left, .header-right {
691+
flex: 1;
692+
display: flex;
693+
align-items: center;
694+
}
695+
696+
.header-right {
697+
justify-content: flex-end;
698+
}
699+
700+
.header-title {
701+
margin: 0;
702+
color: #303133;
703+
display: inline-block;
704+
padding-right: 10px;
705+
}
706+
707+
.header-new-btn, .header-extra-block {
708+
margin-left: 10px;
709+
}
710+
}
711+
660712
.body {
661-
padding: 1rem;
713+
padding: 20px;
662714
}
663715
664716
.data-tree-title {

styleguide.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path')
33

44
const docs = [
55
'basic',
6-
'has-title',
6+
'has-header',
77
'dynamic-url',
88
'filter-nodes',
99
'configure-el-tree',

0 commit comments

Comments
 (0)