zhitong.yu
8 天以前 378d781e6f35f89652aa36e079a8b7fc44cea77e
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
  <el-table :data="tableData" :show-overflow-tooltip="true" class="alarmTable">
    <el-table-column prop="name" :label="t('attendsCount.areaName')" align="center" width="130"> </el-table-column>
    <el-table-column prop="tagid" :label="t('attendsCount.areaPersonCount')" align="center" width="130" />
    <el-table-column prop="intime" :label="t('Config.time')" align="center" width="130" />
  </el-table>
</template>
<script lang="ts">
import { defineComponent, onMounted, reactive, ref, toRefs, nextTick, onUnmounted } from "vue";
import { FindRealAttendanceInfo } from "@/api/modules/hxzk/statistics/historyAttendance";
import { useI18n } from "vue-i18n";
 
export default defineComponent({
  name: "AttendsCount",
  setup() {
    const { t } = useI18n({ useScope: "global" });
 
    // 表格的数据类型
    interface tableType {
      name: string;
      money: number;
    }
    const data = reactive({
      tableData: [] as Array<tableType>, // 表格的数据
      currentPage: 1, // 当前展示的页码
      pageSize: 6, // 当前表格一页展示多少条数据
      tableDom: {} as HTMLElement // 表格内容的dom
    });
    let timeInterval: NodeJS.Timer; // 定时器的对象
    let tableScroll = ref(false); // 是否需要滚动
 
    onMounted(() => {
      // 初始化表格的数据
      list();
      scrollTable();
    });
 
    onUnmounted(() => {
      clearInterval(timeInterval);
    });
 
    // 初始化表格的数据
    const list = () => {
      const tableList = {
        pageNum: 1,
        pageSize: 1000
      };
      const params = {
        tableList
      };
      FindRealAttendanceInfo(params).then(dt => {
        data.tableData = dt;
      });
    };
 
    // 表格的数据滚动
    const scrollTable = () => {
      nextTick(() => {
        // 获取当前表格内容的dom
        let table = document.getElementsByClassName("alarmTable")[0];
        data.tableDom = table.getElementsByClassName("el-scrollbar__wrap")[0]! as HTMLElement;
        // 鼠标放在表格内容,暂停滚动
        data.tableDom.addEventListener("mouseover", () => {
          tableScroll.value = false;
        });
 
        //
        timeInterval = setInterval(() => {
          if (tableScroll.value) {
            // 每次内容滚动的距离
            data.tableDom.scrollTop += 1;
            if (data.tableDom.clientHeight + data.tableDom.scrollTop == data.tableDom.scrollHeight) {
              data.tableDom.scrollTop = 0;
            }
          }
        }, 10);
      });
    };
 
    return {
      ...toRefs(data),
      t
    };
  }
});
</script>
<style lang="scss" scoped>
.alarmTable {
  height: 100%;
  padding: 10px 0;
  margin-top: 10px;
  overflow: hidden;
  font-size: 14px;
  font-weight: bolder;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000;
  scroll-behavior: smooth;
}
</style>
<style lang="scss">
.alarmTable,
.alarmTable::before,
.alarmTable--border .el-table__inner-wrapper::after,
.alarmTable--border::after,
.alarmTable--border::before,
.el-table__inner-wrapper::before {
  background: rgb(36 77 207 / 0%);
  border: 0;
}
.alarmTable thead tr {
  background: none !important;
}
.alarmTable tr {
  height: 50px;
  color: white;
  background: url("../images/tr.png") no-repeat;
  background-size: 100% 100%;
  border-bottom: 10px solid #3a66d6 !important;
  &:nth-child(2n) {
    color: white;
    background: url("../images/tr.png") no-repeat;
    background-size: 100% 100%;
    border-bottom: 10px solid #3a66d6;
  }
}
.alarmTable th.el-table__cell {
  height: 30px;
  padding: 0;
  background: rgb(237 250 49 / 0%) !important;
}
.el-table tr:hover > td {
  cursor: pointer;
  background-color: rgb(0 148 255 / 10%) !important;
}
.el-table td.el-table__cell,
.el-table th.el-table__cell.is-leaf {
  border-bottom: none;
}
</style>