zhongrj
2024-03-27 cc1c0a396698648256c350f6f0fe2cb2f0b02c7e
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<template>
  <div>
    <basic-container class="witerFontColorInput">
      <avue-crud
        :option="option"
        :data="data"
        :page.sync="page"
        :search.sync="search"
        :table-loading="loading"
        @on-load="onLoad(page)"
        @search-change="searchChange"
        @search-reset="searchReset"
        @refresh-change="refreshChange"
      >
      <template slot="menuLeft">
      <el-button
              type="warning"
              size="small"
              plain
              icon="el-icon-download"
              @click="handleExportLoginRecord"
              >导出
            </el-button>
      </template>
      </avue-crud>
      
    </basic-container>
  </div>
</template>
 
<script>
import { getInformationLoginPage } from "@/api/loginRecord/loginRecord";
import {  lazyTrees } from "@/api/index/index";
import {dictionaryList} from "@/api/statisticalQueryManagement/statisticalQueryManagement";
import Qs from "qs";
import { getToken } from "@/util/auth";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      query: {},
      search: {},
      data: [],
      option: {
        delBtn: false,
        editBtn: false,
        addBtn: false,
        selection: false,
        menu: false,
        align: "center",
        height: "auto",
        calcHeight: 30,
        tip: false,
        searchShowBtn: false,
        searchShow: true,
        searchMenuSpan: 6,
        index: true,
        column: [
          {
            label: "登录时间",
            prop: "releaseTimeRange",
            type: "datetime",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            searchRange: true,
            hide: true,
            search: true,
            searchSpan: 6,
            rules: [
              {
                required: true,
                message: "请输入登录时间",
                trigger: "blur",
              },
            ],
          },
          {
            label: "企业名称",
            prop: "deptName",
            disabled: true,
            overHidden: true,
            searchSpan: 5,
            search: true,
          },
          {
            label: "所属辖区",
            prop: "jurisdictionName",
            searchSpan: 4,
            type: "tree",
            props: {
              label: "title",
              value: "id",
            },
            dicData: [],
            search: true,
            rules: [
              {
                required: true,
                message: "请选择所属辖区",
                trigger: "blur",
              },
            ],
          },
          {
            label: "企业属性",
            prop: "stats",
            search: true,
            searchSpan: 4,
            display: false,
            type: "select",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dicData: [],
          },
          {
            label: "最近一次登录时间",
            prop: "createTime",
            minWidth: 100,
            display: false,
          },
          {
            label: "登录次数",
            prop: "num",
            disabled: false,
          },
          {
            label: "是否有登录",
            prop: "types",
            search: true,
            disabled: false,
            searchLabelWidth: 100,
            type: "select",
            searchSpan: 4,
            hide: true,
            dicData: [
              {
                label: "全部",
                value: 3,
              },
              {
                label: "是",
                value: 2,
              },
              {
                label: "否",
                value: 1,
              },
            ],
          },
        ],
      },
    };
  },
  computed: {
    ...mapGetters(["permission"]),
  },
  created(){
    //分别查询辖区和字典数据
    this.getSubOfficeData();
    this.getDictionaryList();
  },
  methods: {
    //登录数据导出
    handleExportLoginRecord() {
      this.$confirm("是否导出企业登录记录数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        //获取查询条件
        const { releaseTimeRange } = this.search;
        if (releaseTimeRange) {
          this.search["startTime"] = releaseTimeRange[0];
          this.search["endTime"] = releaseTimeRange[1];
        }
        var data = {
          jurisdiction: this.search.jurisdictionName,
          stats: this.search.stats,
          deptName: this.search.deptName,
          types: this.search.types,
          startTime: this.search.startTime,
          endTime: this.search.endTime,
        };
        // console.log(data,123);
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/loginRecord/export-login-record?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    },
    //获取辖区数据
    getSubOfficeData() {
      lazyTrees().then((res) => {
        if (res.data.code === 200) {
          this.option.column.forEach((item) => {
            if (item.label == "所属辖区") {
              item.dicData = res.data.data;
            }
          });
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    //获取字典表数
    getDictionaryList() {
      dictionaryList().then((res) => {
        if (res.data.code === 200) {
          this.option.column.forEach((item) => {
            if (item.label == "企业属性") {
              item.dicData = res.data.data;
            }
          });
        }
      });
    },
    onLoad(page, params = {}) {
      //属性值转换
      params["jurisdiction"] = params["jurisdictionName"] || "";
 
      const { releaseTimeRange } = this.search;
 
      let values = {
        ...params,
      };
      if (releaseTimeRange) {
        values = {
          ...params,
          startTime: releaseTimeRange[0],
          endTime: releaseTimeRange[1],
          ...this.query,
        };
        values.releaseTimeRange = null;
      }
 
      getInformationLoginPage(page.currentPage, page.pageSize, values).then(
        (res) => {
          const data = res.data.data;
          this.data = data.records;
          this.page.total = data.total;
          this.loading = false;
        }
      );
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.refreshChange();
      done();
    },
    searchReset() {
      this.query = {};
      this.page.currentPage = 1;
      this.refreshChange();
    },
  },
};
</script>
 
<style scoped>
</style>