jinlin
2023-11-03 35435e8b1995e6775c82b86652381e07e3faff54
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
<template>
  <el-card class="aui-card--fill" shadow="never">
    <div class="mod-demo__sysnotice">
      <zt-table-wraper v-slot="{ table }" delete-url="/sys/notice" query-url="/sys/notice/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()"/>
            <zt-button type="add" @click="table.editHandle()"/>
            <zt-button type="delete" @click="table.deleteHandle()"/>
          </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"/>
          <zt-table-column-dict :label="$t('notice.type')" dict="notice_type" prop="type" width="150"/>
          <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.status')" prop="status" width="130">
            <template v-slot="{ row }">
              <el-tag v-if="row.status === 0" size="small" type="danger">{{ $t('notice.status0') }}</el-tag>
              <el-tag v-else size="small" type="success">{{ $t('notice.status1') }}</el-tag>
            </template>
          </el-table-column>
          <zt-table-column-handle :has-edit="canEdit" :table="table" width="150">
            <template v-slot="{ row }">
              <zt-table-button v-if="row.status === 1" @click="viewHandle(row)">{{
                  $t('notice.view')
                }}
              </zt-table-button>
            </template>
          </zt-table-column-handle>
        </el-table>
        <!-- 弹窗, 新增 / 修改 -->
        <add-or-update @refreshDataList="table.query"/>
      </zt-table-wraper>
    </div>
  </el-card>
</template>
 
<script>
import AddOrUpdate from './notice-add-or-update'
import {addDynamicRoute} from '../../../router'
 
export default {
  data() {
    return {
      dataForm: {
        type: ''
      }
    }
  },
  components: {
    AddOrUpdate
  },
  methods: {
    canEdit(row) {
      return row.status === 0
    },
    viewHandle(row) {
      // 路由参数
      const routeParams = {
        routeName: `${this.$route.name}__${row.id}`,
        title: this.$t('notice.view1'),
        path: 'notice/notice-view',
        params: {
          id: row.id
        }
      }
      // 动态路由
      addDynamicRoute(routeParams)
    }
  }
}
</script>