123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <div v-if="visible" class="home-info-container">
- <el-card>
- <div slot="header" class="clearfix">
- <span class="info-title">消息通知</span>
- <i class="el-icon-close info-close-btn" @click="close" />
- </div>
- <el-table
- v-loading="loading"
- :data="tableData"
- :show-header="false"
- stripe
- size="mini"
- height="300"
- style="width: 100%;"
- @cell-click="cellClick"
- >
- <el-table-column prop="title" label="标题" show-overflow-tooltip />
- </el-table>
- <div class="info-footer" @click="showMore"><span class="info-more-btn">点击查看更多</span></div>
- </el-card>
- </div>
- </template>
- <script>
- import { hasValidRecords } from '@/utils/convert'
- import { fetchTableList } from '@/api/info'
- export default {
- name: 'HomeInfo',
- props: {},
- data() {
- return {
- // dialog
- visible: false,
- // table
- current: 1,
- size: 50,
- tableData: [],
- // others
- loading: false
- }
- },
- created() {
- this.searchTable()
- },
- methods: {
- open(message) {
- this.visible = true
- this.tableData.unshift(message)
- },
- close() {
- this.visible = false
- },
- // 点击搜索按钮
- searchTable() {
- this.current = 1
- this.getTablelist()
- },
- // 获取table数据
- getTablelist() {
- this.loading = true
- const params = {
- current: this.current,
- size: this.size,
- delFlag: 0
- }
- fetchTableList(params).then(response => {
- this.loading = false
- if (hasValidRecords(response)) {
- this.tableData = response.data.records
- this.total = response.data.total
- } else {
- this.tableData = []
- this.total = 0
- }
- }).catch(error => {
- console.log(error)
- this.loading = false
- this.$message({
- type: 'error',
- duration: 0,
- showClose: true,
- message: '获取消息列表出错: ' + error.message
- })
- })
- },
- cellClick(row, column, cell) {
- },
- showMore() {
- this.visible = false
- this.$router.push('/info')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .home-info-container {
- position: fixed;
- left: 20px;
- bottom: 10px;
- width: 400px;
- z-index: 1500;
- ::v-deep {
- .el-card__header {
- padding: 10px 10px 10px 20px;
- background-color: #0056dd;
- }
- .el-card__body {
- padding: 0;
- }
- .el-table td {
- padding-left: 10px;
- }
- }
- .info-title {
- color: #ffffff;
- }
- .info-close-btn {
- float: right;
- cursor: pointer;
- color: #ffffff;
- }
- .info-footer {
- height: 30px;
- line-height: 30px;
- font-size: 15px;
- text-align: center;
- padding-right: 20px;
- }
- .info-more-btn {
- cursor: pointer;
- }
- }
- </style>
|