longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
  <flex-layout>
    <div slot="header" class="drawer-header">
      <el-button type="primary" size="mini" :disabled="!selectList" @click="setToRead">标记已读</el-button>
    </div>
    <el-table
        stripe
        size="small"
        :data="list"
        height="100%"
      @selection-change="selectionChange">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>
      <el-table-column
          v-for="header in headers"
          :key="header.prop"
          :prop="header.prop"
          :label="header.label"
          :width="header.width"
          :min-width="header.minWidth"
          align="center"
          show-overflow-tooltip
      ></el-table-column>
    </el-table>
  </flex-layout>
</template>
 
<script>
export default {
  name: "singularDrawer",
  data() {
    return {
      headers: [
        {
          prop: "UName",
          label: "异常来源",
          width: 120,
        },
        {
          prop: "uOprateMsg",
          label: "异常信息",
          minWidth: 220,
        },
        {
          prop: "uOprateDay",
          label: "异常日期",
          width: 180,
        },
      ],
      list: [],
      selectList: "",
    }
  },
  methods: {
    unReadLog(){
      let loading = this.$layer.loading();
      this.$apis.userMager.operationRecord.unReadLog().then(res=>{
        this.$layer.close(loading);
        let rs = JSON.parse(res.data.result);
        let data = [];
        if(rs.code == 1) {
          console.log(rs.data);
          data = rs.data.map(item=>{
            return {
              num: item.ulog.num,
              UName: item.uinf.UName,
              uOprateMsg: item.ulog.uOprateMsg,
              uOprateDay: item.ulog.uOprateDay
            };
          });
        }
        this.list = data;
      }).catch(error => {
        this.$layer.close(loading);
      });
    },
    selectionChange(rows) {
      let list = rows.map(item=>{
        return item.num;
      }).join(',');
      // 设置选中列表
      this.selectList = list?list:"";
    },
    setToRead() {
      let loading = this.$layer.loading();
      this.$apis.userMager.operationRecord.setToRead(this.selectList).then(res=>{
        this.$layer.close(loading);
        let rs = JSON.parse(res.data.result);
        let data = [];
        if(rs.code == 1) {
          this.unReadLog();
        }else {
          this.$layer.msg("标记失败");
        }
      }).catch(error => {
        this.$layer.close(loading);
        this.$layer.msg("网络请求异常");
        this.unReadLog();
      });
    }
  },
  mounted() {
    this.unReadLog();
  }
}
</script>
 
<style scoped>
.drawer-header {
  padding: 16px;
}
</style>