style
This commit is contained in:
91
src/components/Sticky/index.vue
Normal file
91
src/components/Sticky/index.vue
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<template>
|
||||||
|
<div :style="{height:height+'px',zIndex:zIndex}">
|
||||||
|
<div
|
||||||
|
:class="className"
|
||||||
|
:style="{top:(isSticky ? stickyTop +'px' : ''),zIndex:zIndex,position:position,width:width,height:height+'px'}"
|
||||||
|
>
|
||||||
|
<slot>
|
||||||
|
<div>sticky</div>
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'Sticky',
|
||||||
|
props: {
|
||||||
|
stickyTop: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
zIndex: {
|
||||||
|
type: Number,
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
className: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
active: false,
|
||||||
|
position: '',
|
||||||
|
width: undefined,
|
||||||
|
height: undefined,
|
||||||
|
isSticky: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.height = this.$el.getBoundingClientRect().height
|
||||||
|
window.addEventListener('scroll', this.handleScroll)
|
||||||
|
window.addEventListener('resize', this.handleReize)
|
||||||
|
},
|
||||||
|
activated() {
|
||||||
|
this.handleScroll()
|
||||||
|
},
|
||||||
|
destroyed() {
|
||||||
|
window.removeEventListener('scroll', this.handleScroll)
|
||||||
|
window.removeEventListener('resize', this.handleReize)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
sticky() {
|
||||||
|
if (this.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.position = 'fixed'
|
||||||
|
this.active = true
|
||||||
|
this.width = this.width + 'px'
|
||||||
|
this.isSticky = true
|
||||||
|
},
|
||||||
|
handleReset() {
|
||||||
|
if (!this.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.reset()
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
this.position = ''
|
||||||
|
this.width = 'auto'
|
||||||
|
this.active = false
|
||||||
|
this.isSticky = false
|
||||||
|
},
|
||||||
|
handleScroll() {
|
||||||
|
const width = this.$el.getBoundingClientRect().width
|
||||||
|
this.width = width || 'auto'
|
||||||
|
const offsetTop = this.$el.getBoundingClientRect().top
|
||||||
|
if (offsetTop < this.stickyTop) {
|
||||||
|
this.sticky()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.handleReset()
|
||||||
|
},
|
||||||
|
handleReize() {
|
||||||
|
if (this.isSticky) {
|
||||||
|
this.width = this.$el.getBoundingClientRect().width + 'px'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -115,7 +115,9 @@
|
|||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card>
|
<el-card>
|
||||||
<h1 class="word">设计</h1>
|
<sticky :z-index="10">
|
||||||
|
<h1 class="word">设计</h1>
|
||||||
|
</sticky>
|
||||||
<el-table v-loading="loading1" :data="tableData1" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
<el-table v-loading="loading1" :data="tableData1" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
||||||
<el-table-column label="组号" align="center" min-width="100px">
|
<el-table-column label="组号" align="center" min-width="100px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -153,9 +155,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-card>
|
<sticky :z-index="11">
|
||||||
<el-card>
|
<h1 class="word">采购</h1>
|
||||||
<h1 class="word">采购</h1>
|
</sticky>
|
||||||
<el-table v-loading="loading1" :data="tableData2" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
<el-table v-loading="loading1" :data="tableData2" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
||||||
<el-table-column label="组号" align="center" min-width="100px">
|
<el-table-column label="组号" align="center" min-width="100px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -195,7 +197,9 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card>
|
<el-card>
|
||||||
<h1 class="word">备料</h1>
|
<sticky :z-index="12">
|
||||||
|
<h1 class="word">备料</h1>
|
||||||
|
</sticky>
|
||||||
<el-table v-loading="loading1" :data="tableData3" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
<el-table v-loading="loading1" :data="tableData3" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
||||||
<el-table-column label="组号" align="center" min-width="100px">
|
<el-table-column label="组号" align="center" min-width="100px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -235,7 +239,9 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card>
|
<el-card>
|
||||||
<h1 class="word">制造</h1>
|
<sticky :z-index="13">
|
||||||
|
<h1 class="word">制造</h1>
|
||||||
|
</sticky>
|
||||||
<el-table v-loading="loading1" :data="tableData4" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
<el-table v-loading="loading1" :data="tableData4" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
||||||
<el-table-column label="组号" align="center" min-width="100px">
|
<el-table-column label="组号" align="center" min-width="100px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -275,7 +281,9 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card>
|
<el-card>
|
||||||
<h1 class="word">装配调试</h1>
|
<sticky :z-index="14">
|
||||||
|
<h1 class="word">装配调试</h1>
|
||||||
|
</sticky>
|
||||||
<el-table v-loading="loading1" :data="tableData5" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
<el-table v-loading="loading1" :data="tableData5" highlight-current-row style="width: 100%;" stripe border element-loading-text="拼命加载中">
|
||||||
<el-table-column label="组号" align="center" min-width="100px">
|
<el-table-column label="组号" align="center" min-width="100px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -317,9 +325,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>import { initProject, initMachine, searchtable, searchtable2 } from '@/api/ManufacturingCenter/ProjectPlanningQuery'
|
<script>
|
||||||
|
import { initProject, initMachine, searchtable, searchtable2 } from '@/api/ManufacturingCenter/ProjectPlanningQuery'
|
||||||
|
import Sticky from '@/components/Sticky'
|
||||||
export default {
|
export default {
|
||||||
|
components: { Sticky },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
projectValue: '',
|
projectValue: '',
|
||||||
@@ -539,9 +549,12 @@ export default {
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.word{
|
.word{
|
||||||
/*font-size: 20px;*/
|
border: 1px solid #ebeef5;
|
||||||
/*margin-bottom: 20px;*/
|
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
line-height: 60px;
|
||||||
|
/*height: 50px;*/
|
||||||
|
background-color: white;
|
||||||
}
|
}
|
||||||
span{
|
span{
|
||||||
margin: 10px 0 10px 10px;
|
margin: 10px 0 10px 10px;
|
||||||
@@ -559,5 +572,6 @@ export default {
|
|||||||
<style>
|
<style>
|
||||||
.bold-font .el-table{
|
.bold-font .el-table{
|
||||||
font: bold 18px arial!important;
|
font: bold 18px arial!important;
|
||||||
|
margin: 20px 0 10px 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user