xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<template>
  <el-card class="aui-card--fill" shadow="never">
    <div class="mod-demo__sysnoticeuser">
      <zt-table-wraper v-slot="{ table }" query-url="/sys/notice/my/page">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
          <el-form-item>
            <zt-dict v-model="dataForm.type" :placeholder="$t('notice.type')" dict="notice_type"></zt-dict>
          </el-form-item>
          <el-form-item class="message-btn">
            <zt-button type="query" @click="table.query()"/>
          </el-form-item>
        </el-form>
        <el-table v-adaptive="{bottomOffset:60}"
                  v-loading="table.dataLoading"
                  :data="table.dataList"
                  border height="650px" @selection-change="table.selectionChangeHandle">
          <el-table-column type="selection" width="40"/>
          <el-table-column :label="$t('notice.title')" prop="title"/>
          <el-table-column :label="$t('notice.type')" prop="type" width="150">
            <template v-slot="{ row }">
              {{ $store.getters.getDictLabel("notice_type", row.type) }}
            </template>
          </el-table-column>
          <el-table-column :label="$t('notice.senderName')" prop="senderName" width="150"/>
          <el-table-column :label="$t('notice.senderDate')" prop="senderDate" width="170"/>
          <el-table-column :label="$t('notice.readStatus')" prop="readStatus" width="130">
            <template v-slot="{ row }">
              <el-tag v-if="row.readStatus === 0" size="small" type="danger">{{ $t('notice.readStatus0') }}</el-tag>
              <el-tag v-else size="small" type="success">{{ $t('notice.readStatus1') }}</el-tag>
            </template>
          </el-table-column>
          <zt-table-column-handle :has-edit="false" :has-update="false" :table="table">
            <template v-slot="{ row }">
              <zt-table-button @click="viewHandle(row)">{{ $t('notice.view') }}</zt-table-button>
            </template>
          </zt-table-column-handle>
        </el-table>
      </zt-table-wraper>
    </div>
  </el-card>
</template>
 
<script>
import {addDynamicRoute} from '../../../router'
 
export default {
  data() {
    return {
      dataForm: {
        type: ''
      }
    }
  },
  methods: {
    viewHandle(row) {
      // 路由参数
      const routeParams = {
        routeName: `${this.$route.name}__${row.id}`,
        title: this.$t('notice.view2'),
        path: 'notice/notice-user-view',
        params: {
          id: row.id
        }
      }
 
      // 如果未读,则标记为已读
      if (row.readStatus === 0) {
        this.updateReadStatus(row.id)
      }
 
      // 动态路由
      addDynamicRoute(routeParams)
    },
    updateReadStatus(noticeId) {
      this.$http['put']('/sys/notice/my/read/' + noticeId).then(res => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
      }).catch(() => {
      })
    }
  }
}
</script>