城阳pc工作端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
5.3 KiB

4 years ago
<template>
<div class="m-table">
3 years ago
<table class="table"
border="0"
cellspacing="0"
cellpadding="0">
<col :align="item.align"
:width="item.width"
:key="'col' + index"
v-for="(item, index) in colList" />
4 years ago
<thead>
<tr class="table-header">
3 years ago
<th class="table-header-th"
v-for="item in header"
:key="item">
4 years ago
{{ item }}
</th>
</tr>
</thead>
<tbody class="table-body">
3 years ago
<tr class="table-body-tr"
v-for="(value, index) in list"
:key="index">
<td class="td"
v-for="(item, indexs) in value"
:key="indexs">
<div v-if="typeof item === 'string' || typeof item === 'number'">
{{ item }}
</div>
<div v-if="typeof item === 'object' && item && item.type == 'index'">
3 years ago
<img v-if="highlightTop3 && index == 0"
src="@/assets/img/shuju/top/1.png"
alt="" />
<img v-else-if="highlightTop3 && index == 1"
src="@/assets/img/shuju/top/2.png"
alt="" />
<img v-else-if="highlightTop3 && index == 2"
src="@/assets/img/shuju/top/3.png"
alt="" />
4 years ago
<span v-else>{{ index + 1 }}</span>
</div>
3 years ago
<a v-else-if="typeof item === 'object' && item && item.type == 'operate'"
v-for="btn in item.list"
:key="'operate' + index + btn"
@click="handleClickBtn(index, btn)">{{ btn }}</a>
<a v-else-if="typeof item === 'object' && item && item.type == 'people'"
@click="handleClickPeople(item)">{{ item.name }}</a>
4 years ago
</td>
</tr>
</tbody>
</table>
3 years ago
<div class="table-status"
v-if="loading">
4 years ago
<screen-loading>加载中</screen-loading>
</div>
3 years ago
<div class="table-status"
v-if="list.length == 0 && !loading">
4 years ago
<div class="no-data">
3 years ago
<img src="@/assets/img/modules/visual/noData.png"
class="no-data-img" />
4 years ago
</div>
</div>
</div>
</template>
<script>
import ScreenLoading from "./loading";
import Vue from "vue";
export default {
name: "table",
components: {
ScreenLoading,
},
props: {
colList: {
type: Array,
default: () => {
return [
// {
// align: "center",
// width: "50%",
// },
];
},
},
header: {
type: Array,
required: false,
default: () => {
return [
// "序号", "所属网格", "操作"
];
},
},
list: {
type: Array,
required: false,
default: () => {
return [
// [
// 1,
// "商丘路社区第一网格",
// {
// type: "operate",
// list: ["查看"],
// },
// ],
// [
// 2,
// "商丘路社区第一网格",
// {
// type: "operate",
// list: ["查看"],
// },
// ],
];
},
},
loading: {
type: Boolean,
default: true,
},
highlightTop3: {
type: Boolean,
default: false,
},
},
3 years ago
data () {
4 years ago
return {};
},
watch: {},
3 years ago
mounted () { },
4 years ago
3 years ago
created () { },
4 years ago
methods: {
3 years ago
handleClickBtn (index, type) {
4 years ago
this.$emit("operate", index, type);
},
3 years ago
handleClickPeople (item) {
this.$router.push({
path: `/main-shuju/visual-basicinfo-people/${item.uid}`,
});
},
4 years ago
},
};
</script>
<style lang="scss" scoped>
.m-table {
.table {
box-sizing: border-box;
width: 100%;
height: 100%;
border: none;
table-layout: fixed;
4 years ago
&-header {
width: 100%;
height: 50px;
background: rgba(8, 37, 134, 0.85);
font-size: 16px;
font-weight: 400;
color: #ffffff;
&-th {
text-align: center;
border: none;
// width: calc(100% / 5);
}
}
&-body {
box-sizing: border-box;
width: 100%;
font-size: 16px;
font-weight: 400;
color: #ffffff;
&-tr {
box-sizing: border-box;
width: 100%;
min-height: 50px;
.td {
box-sizing: border-box;
4 years ago
text-align: center;
border: none;
3 years ago
padding: 20px 5px;
> div {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
word-wrap: normal;
}
4 years ago
a {
font-size: 16px;
font-weight: 400;
color: #e4dc00;
position: relative;
cursor: pointer;
}
}
}
&-tr:nth-child(2n) {
background: rgba(16, 75, 164, 0.24);
}
&-tr:hover {
background: url("../../../../assets/img/modules/visual/hover-bac.png")
no-repeat center;
background-size: 100% 100%;
}
}
}
.table-status {
position: relative;
height: 300px;
// 暂无数据
.no-data {
&-img {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
}
}
}
</style>