Skip to content

Commit 45dd3c6

Browse files
committed
fix: table :rowSelection, Tree.jsx
1 parent 192fe98 commit 45dd3c6

File tree

8 files changed

+419
-406
lines changed

8 files changed

+419
-406
lines changed

src/components/CountDown/CountDown.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
},
2424
onEnd: {
2525
type: Function,
26-
default: () => {
27-
}
26+
default: () => ({})
2827
}
2928
},
3029
data() {

src/components/Tree/Tree.jsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ export default {
1010
type: Array,
1111
required: true
1212
},
13+
openKeys: {
14+
type: Array,
15+
default: () => []
16+
},
1317
search: {
1418
type: Boolean,
1519
default: false
1620
}
1721
},
22+
created () {
23+
this.localOpenKeys = this.openKeys.slice(0)
24+
},
1825
data () {
1926
return {
20-
openKeys: []
27+
localOpenKeys: []
2128
}
2229
},
2330
methods: {
@@ -99,15 +106,16 @@ export default {
99106
},
100107
render () {
101108
const { dataSource, search } = this.$props
102-
109+
110+
// this.localOpenKeys = openKeys.slice(0)
103111
const list = dataSource.map(item => {
104112
return this.renderItem(item)
105113
})
106114

107115
return (
108116
<div class="tree-wrapper">
109117
{ search ? this.renderSearch() : null }
110-
<Menu mode="inline" class="custom-tree" {...{ on: { click: item => this.$emit('click', item) } }}>
118+
<Menu mode="inline" class="custom-tree" {...{ on: { click: item => this.$emit('click', item), 'update:openKeys': val => { this.localOpenKeys = val } }}} openKeys={this.localOpenKeys}>
111119
{ list }
112120
</Menu>
113121
</div>

src/components/page/PageLayout.vue

+123-123
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,124 @@
1-
<template>
2-
<div :style="!$route.meta.pageHeader ? 'margin: -24px -24px 0px;' : null">
3-
<!-- pageHeader , route meta hideHeader:true on hide -->
4-
<page-header v-if="!$route.meta.pageHeader" :title="title" :logo="logo" :avatar="avatar">
5-
<slot slot="action" name="action"></slot>
6-
<slot slot="content" name="headerContent"></slot>
7-
<div slot="content" v-if="!this.$slots.headerContent && desc">
8-
<p style="font-size: 14px;color: rgba(0,0,0,.65)">{{ desc }}</p>
9-
<div class="link">
10-
<template v-for="(link, index) in linkList">
11-
<a :key="index" :href="link.href">
12-
<a-icon :type="link.icon"/>
13-
<span>{{ link.title }}</span>
14-
</a>
15-
</template>
16-
</div>
17-
</div>
18-
<slot slot="extra" name="extra"></slot>
19-
<div slot="pageMenu">
20-
<div class="page-menu-search" v-if="search">
21-
<a-input-search style="width: 80%; max-width: 522px;" placeholder="请输入..." size="large" enterButton="搜索" />
22-
</div>
23-
<div class="page-menu-tabs" v-if="tabs && tabs.items">
24-
<!-- @change="callback" :activeKey="activeKey" -->
25-
<a-tabs :tabBarStyle="{margin: 0}" @change="tabs.callback" :activeKey="tabs.active()">
26-
<a-tab-pane v-for="item in tabs.items" :tab="item.title" :key="item.key"></a-tab-pane>
27-
</a-tabs>
28-
</div>
29-
</div>
30-
</page-header>
31-
<div class="content">
32-
<div :class="['page-header-index-wide']">
33-
<slot></slot>
34-
</div>
35-
</div>
36-
</div>
37-
</template>
38-
39-
<script>
40-
import PageHeader from './PageHeader'
41-
42-
export default {
43-
name: 'LayoutContent',
44-
components: {
45-
PageHeader
46-
},
47-
// ['desc', 'logo', 'title', 'avatar', 'linkList', 'extraImage']
48-
props: {
49-
desc: {
50-
type: String,
51-
default: null
52-
},
53-
logo: {
54-
type: String,
55-
default: null
56-
},
57-
title: {
58-
type: String,
59-
default: null
60-
},
61-
avatar: {
62-
type: String,
63-
default: null
64-
},
65-
linkList: {
66-
type: Array,
67-
default: null
68-
},
69-
extraImage: {
70-
type: String,
71-
default: null
72-
},
73-
search: {
74-
type: Boolean,
75-
default: false
76-
},
77-
tabs: {
78-
type: Object,
79-
default: () => {}
80-
}
81-
},
82-
methods: {
83-
}
84-
}
85-
</script>
86-
87-
<style lang="less" scoped>
88-
.content {
89-
margin: 24px 24px 0;
90-
91-
.link {
92-
margin-top: 16px;
93-
94-
&:not(:empty) {
95-
margin-bottom: 16px;
96-
}
97-
a {
98-
margin-right: 32px;
99-
height: 24px;
100-
line-height: 24px;
101-
display: inline-block;
102-
103-
i {
104-
font-size: 24px;
105-
margin-right: 8px;
106-
vertical-align: middle;
107-
}
108-
span {
109-
height: 24px;
110-
line-height: 24px;
111-
display: inline-block;
112-
vertical-align: middle;
113-
}
114-
}
115-
}
116-
}
117-
.page-menu-search {
118-
text-align: center;
119-
margin-bottom: 16px;
120-
}
121-
.page-menu-tabs {
122-
margin-top: 48px;
123-
}
1+
<template>
2+
<div :style="!$route.meta.pageHeader ? 'margin: -24px -24px 0px;' : null">
3+
<!-- pageHeader , route meta hideHeader:true on hide -->
4+
<page-header v-if="!$route.meta.pageHeader" :title="title" :logo="logo" :avatar="avatar">
5+
<slot slot="action" name="action"></slot>
6+
<slot slot="content" name="headerContent"></slot>
7+
<div slot="content" v-if="!this.$slots.headerContent && desc">
8+
<p style="font-size: 14px;color: rgba(0,0,0,.65)">{{ desc }}</p>
9+
<div class="link">
10+
<template v-for="(link, index) in linkList">
11+
<a :key="index" :href="link.href">
12+
<a-icon :type="link.icon"/>
13+
<span>{{ link.title }}</span>
14+
</a>
15+
</template>
16+
</div>
17+
</div>
18+
<slot slot="extra" name="extra"></slot>
19+
<div slot="pageMenu">
20+
<div class="page-menu-search" v-if="search">
21+
<a-input-search style="width: 80%; max-width: 522px;" placeholder="请输入..." size="large" enterButton="搜索" />
22+
</div>
23+
<div class="page-menu-tabs" v-if="tabs && tabs.items">
24+
<!-- @change="callback" :activeKey="activeKey" -->
25+
<a-tabs :tabBarStyle="{margin: 0}" @change="tabs.callback" :activeKey="tabs.active()">
26+
<a-tab-pane v-for="item in tabs.items" :tab="item.title" :key="item.key"></a-tab-pane>
27+
</a-tabs>
28+
</div>
29+
</div>
30+
</page-header>
31+
<div class="content">
32+
<div :class="['page-header-index-wide']">
33+
<slot></slot>
34+
</div>
35+
</div>
36+
</div>
37+
</template>
38+
39+
<script>
40+
import PageHeader from './PageHeader'
41+
42+
export default {
43+
name: 'LayoutContent',
44+
components: {
45+
PageHeader
46+
},
47+
// ['desc', 'logo', 'title', 'avatar', 'linkList', 'extraImage']
48+
props: {
49+
desc: {
50+
type: String,
51+
default: null
52+
},
53+
logo: {
54+
type: String,
55+
default: null
56+
},
57+
title: {
58+
type: String,
59+
default: null
60+
},
61+
avatar: {
62+
type: String,
63+
default: null
64+
},
65+
linkList: {
66+
type: Array,
67+
default: null
68+
},
69+
extraImage: {
70+
type: String,
71+
default: null
72+
},
73+
search: {
74+
type: Boolean,
75+
default: false
76+
},
77+
tabs: {
78+
type: Object,
79+
default: () => ({})
80+
}
81+
},
82+
methods: {
83+
}
84+
}
85+
</script>
86+
87+
<style lang="less" scoped>
88+
.content {
89+
margin: 24px 24px 0;
90+
91+
.link {
92+
margin-top: 16px;
93+
94+
&:not(:empty) {
95+
margin-bottom: 16px;
96+
}
97+
a {
98+
margin-right: 32px;
99+
height: 24px;
100+
line-height: 24px;
101+
display: inline-block;
102+
103+
i {
104+
font-size: 24px;
105+
margin-right: 8px;
106+
vertical-align: middle;
107+
}
108+
span {
109+
height: 24px;
110+
line-height: 24px;
111+
display: inline-block;
112+
vertical-align: middle;
113+
}
114+
}
115+
}
116+
}
117+
.page-menu-search {
118+
text-align: center;
119+
margin-bottom: 16px;
120+
}
121+
.page-menu-tabs {
122+
margin-top: 48px;
123+
}
124124
</style>

src/components/table/index.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export default {
4949
type: [Object, Boolean],
5050
default: null
5151
},
52+
rowSelection: {
53+
type: Object,
54+
default: () => ({})
55+
},
5256
/** @Deprecated */
5357
showAlertInfo: {
5458
type: Boolean,
@@ -97,7 +101,7 @@ export default {
97101
/**
98102
* 表格重新加载方法
99103
* 如果参数为 true, 则强制刷新到第一页
100-
* @param Boolean bool
104+
* @param Boolean bool
101105
*/
102106
refresh(bool = false) {
103107
this.loadData(bool ? { current: 1 }: {})
@@ -172,12 +176,13 @@ export default {
172176
*/
173177
updateSelect (selectedRowKeys, selectedRows) {
174178
this.selectedRows = selectedRows
179+
this.selectedRowKeys = selectedRowKeys
175180
const list = this.needTotalList
176181
this.needTotalList = list.map(item => {
177182
return {
178183
...item,
179184
total: selectedRows.reduce((sum, val) => {
180-
const total = sum + get(val, item.dataIndex)
185+
const total = sum + parseInt(get(val, item.dataIndex))
181186
return isNaN(total) ? 0 : total
182187
}, 0)
183188
}
@@ -198,6 +203,7 @@ export default {
198203
* @returns {*}
199204
*/
200205
renderClear (callback) {
206+
if (this.selectedRowKeys.length <= 0) return null
201207
return (
202208
<a style="margin-left: 24px" onClick={() => {
203209
callback()
@@ -236,7 +242,7 @@ export default {
236242
render () {
237243
const props = {}
238244
const localKeys = Object.keys(this.$data)
239-
const showAlert = (typeof this.alert === 'object' && this.alert !== null && this.alert.show) || this.alert
245+
const showAlert = (typeof this.alert === 'object' && this.alert !== null && this.alert.show) && typeof this.rowSelection.selectedRowKeys !== 'undefined' || this.alert
240246

241247
Object.keys(T.props).forEach(k => {
242248
const localKey = `local${k.substring(0, 1).toUpperCase()}${k.substring(1)}`
@@ -246,10 +252,11 @@ export default {
246252
if (showAlert && k === 'rowSelection') {
247253
// 重新绑定 rowSelection 事件
248254
return props[k] = {
249-
selectedRowKeys: this[k].selectedRowKeys,
255+
selectedRows: this.selectedRows,
256+
selectedRowKeys: this.selectedRowKeys,
250257
onChange: (selectedRowKeys, selectedRows) => {
251258
this.updateSelect(selectedRowKeys, selectedRows)
252-
this[k].onChange(selectedRowKeys, selectedRows)
259+
typeof this[k].onChange !== 'undefined' && this[k].onChange(selectedRowKeys, selectedRows)
253260
}
254261
}
255262
}

src/utils/filter.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Vue from 'vue'
22
import moment from 'moment'
3+
import 'moment/locale/zh-cn'
4+
moment.locale('zh-cn')
35

46
Vue.filter('NumberFormat', function (value) {
57
if (!value) {

0 commit comments

Comments
 (0)