-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<!-- [sticky-header] 固定列表格 --> | ||
<template> | ||
<div> | ||
<div class="page-header"> | ||
<el-button type="primary" @click="showName = !showName"> | ||
{{ showName ? '隐藏姓名' : '显示姓名' }} | ||
</el-button> | ||
</div> | ||
<el-table | ||
v-sticky-header="{ offsetTop: 'calc(40px + 1rem)' }" | ||
stripe | ||
border | ||
:data="tableData" | ||
style="width: 100%" | ||
> | ||
<el-table-column | ||
fixed | ||
prop="date" | ||
label="日期" | ||
width="150" | ||
/> | ||
<el-table-column | ||
v-if="showName" | ||
fixed | ||
prop="name" | ||
label="姓名" | ||
width="120" | ||
/> | ||
<el-table-column | ||
prop="province" | ||
label="省份" | ||
width="120" | ||
/> | ||
<el-table-column | ||
prop="city" | ||
label="市区" | ||
width="120" | ||
/> | ||
<el-table-column | ||
prop="address" | ||
label="地址" | ||
min-width="1000" | ||
/> | ||
<el-table-column | ||
prop="zip" | ||
label="邮编" | ||
width="120" | ||
/> | ||
<el-table-column | ||
fixed="right" | ||
label="操作" | ||
width="100" | ||
> | ||
<template slot-scope="scope"> | ||
<el-button type="text" size="small" @click="handleClick(scope.row)"> | ||
查看 | ||
</el-button> | ||
<el-button type="text" size="small"> | ||
编辑 | ||
</el-button> | ||
</template> | ||
</el-table-column> | ||
</el-table> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'TableFixedColView', | ||
data() { | ||
return { | ||
showName: true, | ||
tableData: [], | ||
} | ||
}, | ||
mounted() { | ||
for (let i = 0; i < 100; i++) { | ||
this.tableData.push({ | ||
date: '2016-05-01', | ||
name: '王小虎', | ||
city: '普陀区', | ||
address: '上海市普陀区金沙江路 1518 弄', | ||
zip: 200333 | ||
}) | ||
} | ||
}, | ||
methods: { | ||
handleClick(row) { | ||
console.log(row) | ||
} | ||
}, | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.page-header { | ||
background-color: #fff; | ||
position: sticky; | ||
top: 0; | ||
z-index: 4; | ||
padding-block: 0.5rem; | ||
box-shadow: 1rem 0 0 rgba(255, 255, 255, 1); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<!-- [sticky-scroller] 固定横向滚动条 --> | ||
<template> | ||
<div> | ||
<div class="page-header"> | ||
<el-button type="primary" @click="showName = !showName"> | ||
{{ showName ? '隐藏姓名' : '显示姓名' }} | ||
</el-button> | ||
</div> | ||
<el-table | ||
v-sticky-scroller | ||
stripe | ||
border | ||
:data="tableData" | ||
style="width: 100%" | ||
> | ||
<el-table-column | ||
fixed | ||
prop="date" | ||
label="日期" | ||
width="150" | ||
/> | ||
<el-table-column | ||
v-if="showName" | ||
fixed | ||
prop="name" | ||
label="姓名" | ||
width="120" | ||
/> | ||
<el-table-column | ||
prop="province" | ||
label="省份" | ||
width="120" | ||
/> | ||
<el-table-column | ||
prop="city" | ||
label="市区" | ||
width="120" | ||
/> | ||
<el-table-column | ||
prop="address" | ||
label="地址" | ||
min-width="1000" | ||
/> | ||
<el-table-column | ||
prop="zip" | ||
label="邮编" | ||
width="120" | ||
/> | ||
<el-table-column | ||
fixed="right" | ||
label="操作" | ||
width="100" | ||
> | ||
<template slot-scope="scope"> | ||
<el-button type="text" size="small" @click="handleClick(scope.row)"> | ||
查看 | ||
</el-button> | ||
<el-button type="text" size="small"> | ||
编辑 | ||
</el-button> | ||
</template> | ||
</el-table-column> | ||
</el-table> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'TableFixedColView', | ||
data() { | ||
return { | ||
showName: true, | ||
tableData: [], | ||
} | ||
}, | ||
mounted() { | ||
for (let i = 0; i < 100; i++) { | ||
this.tableData.push({ | ||
date: '2016-05-01', | ||
name: '王小虎', | ||
city: '普陀区', | ||
address: '上海市普陀区金沙江路 1518 弄', | ||
zip: 200333 | ||
}) | ||
} | ||
}, | ||
methods: { | ||
handleClick(row) { | ||
console.log(row) | ||
} | ||
}, | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.page-header { | ||
background-color: #fff; | ||
position: sticky; | ||
top: 0; | ||
z-index: 4; | ||
padding-block: 0.5rem; | ||
box-shadow: 1rem 0 0 rgba(255, 255, 255, 1); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!-- [sticky-footer] 表尾合计行 --> | ||
<template> | ||
<div> | ||
<el-table | ||
v-sticky-header | ||
v-sticky-footer | ||
:data="tableData" | ||
border | ||
:summary-method="getSummaries" | ||
show-summary | ||
> | ||
<el-table-column | ||
prop="id" | ||
label="ID" | ||
width="180" | ||
/> | ||
<el-table-column | ||
prop="name" | ||
label="姓名" | ||
width="500" | ||
/> | ||
<el-table-column | ||
prop="amount1" | ||
label="数值 1(元)" | ||
width="300" | ||
/> | ||
<el-table-column | ||
prop="amount2" | ||
label="数值 2(元)" | ||
width="300" | ||
/> | ||
<el-table-column | ||
prop="amount3" | ||
label="数值 3(元)" | ||
width="300" | ||
/> | ||
</el-table> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'StickySumView', | ||
data() { | ||
return { | ||
tableData: [], | ||
} | ||
}, | ||
mounted() { | ||
for (let i = 0; i < 100; i++) { | ||
this.tableData.push({ | ||
id: '1298712' + i, | ||
name: '王小虎', | ||
amount1: '234', | ||
amount2: '3.2', | ||
amount3: 10 | ||
}) | ||
} | ||
}, | ||
methods: { | ||
getSummaries(param) { | ||
const { columns, data } = param | ||
const sums = [] | ||
columns.forEach((column, index) => { | ||
if (index === 0) { | ||
sums[index] = '总价' | ||
return | ||
} | ||
const values = data.map(item => Number(item[column.property])) | ||
if (!values.every(value => isNaN(value))) { | ||
sums[index] = values.reduce((prev, curr) => { | ||
const value = Number(curr) | ||
if (!isNaN(value)) { | ||
return prev + curr | ||
} else { | ||
return prev | ||
} | ||
}, 0) | ||
sums[index] += ' 元' | ||
} else { | ||
sums[index] = 'N/A' | ||
} | ||
}) | ||
return sums | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1022,6 +1022,15 @@ | |
"@babel/helper-validator-identifier" "^7.22.5" | ||
to-fast-properties "^2.0.0" | ||
|
||
"@cell-x/el-table-sticky@^1.0.2": | ||
version "1.0.2" | ||
resolved "https://registry.npmjs.org/@cell-x/el-table-sticky/-/el-table-sticky-1.0.2.tgz#6a53742d6f4c1ed5c89b31e29f3f678f18324517" | ||
integrity sha512-m2st1HuCkFZ8E1rxcPsoUbhC/Tgoj0WoAT0+59HhUgpZKE+bMxh70idhd2v2ItwNkDJAY6hYaVQC1h9qA8J0qQ== | ||
dependencies: | ||
gemini-scrollbar "^1.5.3" | ||
resize-observer-polyfill "^1.5.0" | ||
throttle-debounce "^1.0.1" | ||
|
||
"@discoveryjs/[email protected]": | ||
version "0.5.7" | ||
resolved "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz" | ||
|
@@ -3692,6 +3701,11 @@ functional-red-black-tree@^1.0.1: | |
resolved "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz" | ||
integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== | ||
|
||
gemini-scrollbar@^1.5.3: | ||
version "1.5.3" | ||
resolved "https://registry.npmjs.org/gemini-scrollbar/-/gemini-scrollbar-1.5.3.tgz#7abc916e103e11f983f15856ef8c583cedef95cf" | ||
integrity sha512-3Q4SrxkJ+ei+I5PlcRZCfPePv3EduP7xusOWp7Uw0+XywEWred7Nq9hoaP2IQh1vRjoidaVODV3rO3icFH/e5A== | ||
|
||
gensync@^1.0.0-beta.2: | ||
version "1.0.0-beta.2" | ||
resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz" | ||
|