Files
dvcp_v2_webapp/components/layout/AiDvTable/AiDvTable.vue

265 lines
5.4 KiB
Vue
Raw Normal View History

2023-03-08 15:45:56 +08:00
<template>
2023-03-10 17:15:31 +08:00
<div class="aiDvTable" :class="'aiDvTable-' + theme">
2023-04-24 10:34:41 +08:00
<div class="header" :style="headerStyle">
2023-03-08 17:03:00 +08:00
<span
v-for="(item, index) in header"
:key="index"
:style="{
2023-03-15 15:18:19 +08:00
width: config[index].width ? config[index].width + 'px' : '',
textAlign: config[index].align,
flex: config[index].width ? 'inherit' : 1
2023-03-08 17:16:03 +08:00
}">
2023-03-08 17:03:00 +08:00
{{ item.v }}
</span>
2023-03-08 15:45:56 +08:00
</div>
<div class="body">
2023-03-09 08:52:07 +08:00
<div class="row" v-for="(item, index) in body" :class="[stripe === '1' ? 'stripe' : '']" :key="index">
2023-03-08 17:03:00 +08:00
<div
v-for="(column, i) in item"
:key="i"
2023-03-08 17:32:42 +08:00
:style="{
2023-03-15 15:18:19 +08:00
color: config[i].color,
textAlign: config[i].align,
2023-04-24 10:34:41 +08:00
fontSize: config[i].fontSize,
2023-03-15 15:18:19 +08:00
width: config[i].width ? config[i].width + 'px' : '',
flex: config[i].width ? 'inherit' : 1
2023-03-08 17:32:42 +08:00
}">
2023-03-08 17:03:00 +08:00
<i v-if="isShowIndex === '1' && i === 0">{{ index + 1 }}</i>
2023-03-14 14:51:40 +08:00
<span :title="column.v">{{ column.v }}</span>
2023-03-08 17:03:00 +08:00
</div>
2023-03-08 15:45:56 +08:00
</div>
</div>
</div>
</template>
<script>
export default {
name: 'AiDvTable',
props: {
data: {
type: Array,
default: () => []
2023-03-08 17:03:00 +08:00
},
2023-04-24 10:34:41 +08:00
headerStyle: {
type: Object,
default: () => {}
},
2023-03-08 17:03:00 +08:00
isShowIndex: {
type: String,
default: '0'
2023-03-08 17:32:42 +08:00
},
stripe: {
type: String,
default: '1'
2023-03-10 17:15:31 +08:00
},
theme: {
type: String,
default: '0'
2023-03-15 15:18:19 +08:00
},
config: {
type: Array,
default: () => []
2023-03-08 15:45:56 +08:00
}
},
data () {
return {
header: [],
2023-04-24 10:34:41 +08:00
body: []
2023-03-08 15:45:56 +08:00
}
},
watch: {
data: {
handler (v) {
this.init(v)
},
deep: true,
immediate: true
}
},
mounted () {
},
methods: {
init (value) {
if (!value.length) {
this.header = []
this.body = []
return false
}
const headerKey = Object.keys(value[0])[0]
2023-03-08 17:03:00 +08:00
const bodyKey = Object.keys(value[0]).filter(v => {
2023-03-15 16:10:33 +08:00
return v !== headerKey
2023-03-08 17:03:00 +08:00
})
this.header = value.map(v => {
return {
2023-03-15 16:10:33 +08:00
v: v[headerKey]
2023-03-08 17:03:00 +08:00
}
})
2023-03-08 17:16:03 +08:00
2023-03-08 15:45:56 +08:00
this.body = bodyKey.map(v => {
2023-03-08 17:03:00 +08:00
return value.map(e => {
return {
2023-03-15 16:10:33 +08:00
v: e[v]
2023-03-08 17:03:00 +08:00
}
})
2023-03-08 15:45:56 +08:00
})
}
}
}
</script>
<style lang="scss" scoped>
.aiDvTable {
2023-03-08 17:03:00 +08:00
height: 100%;
overflow: hidden;
2023-03-10 17:15:31 +08:00
::-webkit-scrollbar {
width: 5px;
height: 14px;
}
::-webkit-scrollbar-corner {
background: transparent;
}
::-webkit-scrollbar-thumb {
min-height: 20px;
background-clip: content-box;
box-shadow: 0 0 0 5px rgba(116, 148, 170, 0.5) inset;
}
::-webkit-scrollbar-track {
box-shadow: 1px 1px 5px rgba(116, 148, 170, 0.5) inset;
}
2023-03-08 15:45:56 +08:00
.header {
display: flex;
align-items: center;
width: 100%;
height: 40px;
2023-04-24 10:34:41 +08:00
font-size: 16px;
2023-03-10 10:05:02 +08:00
padding: 0 16px;
2023-04-24 10:34:41 +08:00
color: rgba(255, 255, 255, 0.7);
2023-03-08 17:32:42 +08:00
background: rgba(70, 70, 70, 0.35);
2023-03-08 15:45:56 +08:00
span {
flex: 1;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow:ellipsis;
&:first-child {
text-align: left;
}
}
}
.body {
2023-03-08 17:03:00 +08:00
height: calc(100% - 40px);
2023-03-08 17:32:42 +08:00
padding: 10px 0;
2023-03-08 17:03:00 +08:00
overflow-y: auto;
box-sizing: border-box;
2023-03-08 15:45:56 +08:00
.row {
display: flex;
align-items: center;
width: 100%;
height: 52px;
2023-03-10 10:05:02 +08:00
padding: 0 16px;
2023-03-08 17:32:42 +08:00
box-sizing: border-box;
&.stripe:nth-of-type(2n) {
background: rgba(48, 48, 48, 0.4);
}
2023-03-08 15:45:56 +08:00
2023-03-08 17:03:00 +08:00
div {
display: flex;
align-items: center;
justify-content: center;
2023-03-08 15:45:56 +08:00
flex: 1;
font-size: 16px;
text-align: center;
color: #ffffff;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow:ellipsis;
2023-03-08 17:03:00 +08:00
span {
flex: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow:ellipsis;
}
i {
width: 20px;
height: 20px;
line-height: 20px;
margin-right: 10px;
text-align: center;
font-size: 12px;
color: #18FEFE;
font-style: normal;
background: url(./asset/rankbg.png) no-repeat;
background-size: 100% 100%;
}
2023-03-08 15:45:56 +08:00
&:first-child {
2023-03-08 17:03:00 +08:00
justify-content: start;
2023-03-08 15:45:56 +08:00
text-align: left;
}
}
}
}
2023-03-10 17:15:31 +08:00
&.aiDvTable-1 {
::-webkit-scrollbar {
width: 5px;
height: 14px;
}
::-webkit-scrollbar-corner {
background: transparent;
}
::-webkit-scrollbar-thumb {
min-height: 20px;
background-clip: content-box;
box-shadow: 0 0 0 5px rgba(250, 181, 108, 0.5) inset;
}
::-webkit-scrollbar-track {
box-shadow: 1px 1px 5px rgba(50, 181, 108, 0.5) inset;
}
.header {
2023-03-14 17:11:17 +08:00
background: rgba(226, 121, 81, 0.2);
2023-03-10 17:15:31 +08:00
}
.body {
div {
i {
color: #FFA086;
background: url(./asset/rankbg-dj.png) no-repeat;
background-size: 100% 100%;
}
}
}
}
2023-03-08 15:45:56 +08:00
}
</style>