parent
beb20c6497
commit
8fce04ae1b
@ -0,0 +1,23 @@ |
|||||||
|
<script type="text/jsx"> |
||||||
|
import Empty from '@/components/Empty' |
||||||
|
|
||||||
|
export default { |
||||||
|
name: "AbstractTable", |
||||||
|
functional: true, |
||||||
|
render(h, context) { |
||||||
|
const {data, children} = context |
||||||
|
return ( |
||||||
|
<el-table |
||||||
|
ref="table" |
||||||
|
current-row-key="id" |
||||||
|
row-key="id" |
||||||
|
highlight-current-row |
||||||
|
{...data} |
||||||
|
> |
||||||
|
{children} |
||||||
|
<Empty slot="empty"/> |
||||||
|
</el-table> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
@ -0,0 +1,69 @@ |
|||||||
|
<template> |
||||||
|
<div class="auto-hidden"> |
||||||
|
<div ref="content" v-html="html" class="auto-hidden__content" :style="contentStyle"/> |
||||||
|
<div v-if="showCollapse" class="auto-hidden__collapse"> |
||||||
|
<el-button |
||||||
|
type="text" |
||||||
|
size="mini" |
||||||
|
:icon="collapseIcon" |
||||||
|
@click="handleCollapse" |
||||||
|
> |
||||||
|
{{collapse ? '展开' : '收起'}} |
||||||
|
</el-button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import {getElementHeight} from "@/utils/browser" |
||||||
|
|
||||||
|
export default { |
||||||
|
name: "AutoHidden", |
||||||
|
props: { |
||||||
|
html: String, |
||||||
|
height: {type: String, default: '100px'} |
||||||
|
}, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
showCollapse: false, |
||||||
|
collapse: true |
||||||
|
} |
||||||
|
}, |
||||||
|
computed: { |
||||||
|
contentStyle() { |
||||||
|
if (!this.showCollapse || !this.collapse) return {} |
||||||
|
return {'max-height': this.height} |
||||||
|
}, |
||||||
|
collapseIcon() { |
||||||
|
return this.collapse ? 'el-icon-arrow-down' : 'el-icon-arrow-up' |
||||||
|
} |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
handleCollapse() { |
||||||
|
this.collapse = !this.collapse |
||||||
|
}, |
||||||
|
isOverHeight() { |
||||||
|
const height = getElementHeight(this.$refs['content']) |
||||||
|
return height > parseFloat(this.height) |
||||||
|
} |
||||||
|
}, |
||||||
|
mounted() { |
||||||
|
this.showCollapse = this.isOverHeight() |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<style lang="scss"> |
||||||
|
.auto-hidden { |
||||||
|
position: relative; |
||||||
|
|
||||||
|
&__content { |
||||||
|
overflow: hidden; |
||||||
|
} |
||||||
|
|
||||||
|
&__collapse { |
||||||
|
margin: 0 auto; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
} |
||||||
|
</style> |
||||||
Loading…
Reference in new issue