Blame view

src/views/user/userLoginList.vue 5.91 KB
1705091d   wuxw   开发完成 admin 台账功能
1
2
3
4
5
6
7
  <template>
    <div class="user-login-container">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-card class="store-list-card">
            <div class="store-list">
              <ul class="store-ul">
20ca5dc6   wuxw   优化登陆日志
8
9
10
                <li v-for="(item, index) in userLoginInfo.stores" :key="index" @click="swatchStore(item)"
                  :class="{ 'selected-store': userLoginInfo.conditions.storeId == item.storeId }">
                  {{ item.name }}<span v-if="item.storeTypeName">({{ item.storeTypeName }})</span>
1705091d   wuxw   开发完成 admin 台账功能
11
12
13
14
15
16
17
18
19
20
21
22
                </li>
              </ul>
            </div>
          </el-card>
        </el-col>
        <el-col :span="20">
          <el-card class="search-card">
            <div slot="header" class="clearfix text-left">
              <span>{{ $t('userLogin.search.title') }}</span>
            </div>
            <el-row :gutter="20">
              <el-col :span="4">
20ca5dc6   wuxw   优化登陆日志
23
                <el-input :placeholder="$t('userLogin.search.name')" v-model="userLoginInfo.conditions.name" clearable />
1705091d   wuxw   开发完成 admin 台账功能
24
25
              </el-col>
              <el-col :span="4">
20ca5dc6   wuxw   优化登陆日志
26
                <el-input type="number" :placeholder="$t('userLogin.search.tel')" v-model="userLoginInfo.conditions.tel"
1705091d   wuxw   开发完成 admin 台账功能
27
28
29
                  clearable />
              </el-col>
              <el-col :span="4">
20ca5dc6   wuxw   优化登陆日志
30
31
                <el-date-picker v-model="userLoginInfo.conditions.startTime" type="datetime"
                  :placeholder="$t('userLogin.search.startTime')" value-format="yyyy-MM-dd HH:mm:ss">
1705091d   wuxw   开发完成 admin 台账功能
32
33
34
                </el-date-picker>
              </el-col>
              <el-col :span="4">
20ca5dc6   wuxw   优化登陆日志
35
36
                <el-date-picker v-model="userLoginInfo.conditions.endTime" type="datetime"
                  :placeholder="$t('userLogin.search.endTime')" value-format="yyyy-MM-dd HH:mm:ss">
1705091d   wuxw   开发完成 admin 台账功能
37
38
                </el-date-picker>
              </el-col>
20ca5dc6   wuxw   优化登陆日志
39
              <el-col :span="4">
1705091d   wuxw   开发完成 admin 台账功能
40
41
42
43
44
45
46
47
48
49
50
                <el-button type="primary" @click="_queryUserLoginMethod">
                  <i class="el-icon-search"></i> {{ $t('common.search') }}
                </el-button>
              </el-col>
            </el-row>
          </el-card>
  
          <el-card class="table-card">
            <div slot="header" class="clearfix text-left">
              <span>{{ $t('userLogin.table.title') }}</span>
            </div>
20ca5dc6   wuxw   优化登陆日志
51
52
53
            <el-table v-loading="loading" :data="userLoginInfo.logs" border style="width: 100%">
              <el-table-column prop="loginId" :label="$t('userLogin.table.loginId')" align="center" />
              <el-table-column prop="parentOrgName" :label="$t('userLogin.table.parentOrgName')" align="center">
1705091d   wuxw   开发完成 admin 台账功能
54
55
56
57
                <template slot-scope="scope">
                  {{ scope.row.parentOrgName || '-' }}
                </template>
              </el-table-column>
20ca5dc6   wuxw   优化登陆日志
58
59
60
61
              <el-table-column prop="orgName" :label="$t('userLogin.table.orgName')" align="center" />
              <el-table-column prop="userName" :label="$t('userLogin.table.userName')" align="center" />
              <el-table-column prop="loginTime" :label="$t('userLogin.table.loginTime')" align="center" />
              <el-table-column prop="userId" :label="$t('userLogin.table.userId')" align="center" />
1705091d   wuxw   开发完成 admin 台账功能
62
63
            </el-table>
  
20ca5dc6   wuxw   优化登陆日志
64
65
66
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
              :current-page="pagination.current" :page-sizes="[10, 20, 30, 50]" :page-size="pagination.size"
              layout="total, sizes, prev, pager, next, jumper" :total="pagination.total" style="margin-top: 20px;">
1705091d   wuxw   开发完成 admin 台账功能
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
            </el-pagination>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
  import { queryUserLogin, listStores } from '@/api/user/userLoginApi'
  
  export default {
    name: 'UserLoginList',
    data() {
      return {
        loading: false,
        userLoginInfo: {
          logs: [],
          stores: [],
          conditions: {
            name: '',
            tel: '',
            storeId: '',
            startTime: '',
            endTime: '',
            page: 1,
            row: 10
          }
        },
        pagination: {
          current: 1,
          size: 10,
          total: 0
        }
      }
    },
    created() {
      this.loadData()
      this._listListStores()
    },
    methods: {
      async loadData() {
        try {
          this.loading = true
          const params = {
            ...this.userLoginInfo.conditions,
            page: this.pagination.current,
            row: this.pagination.size
          }
20ca5dc6   wuxw   优化登陆日志
115
          const { data, total } = await queryUserLogin(params)
1705091d   wuxw   开发完成 admin 台账功能
116
          this.userLoginInfo.logs = data
20ca5dc6   wuxw   优化登陆日志
117
          this.pagination.total = total
1705091d   wuxw   开发完成 admin 台账功能
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
        } catch (error) {
          this.$message.error(this.$t('userLogin.fetchError'))
        } finally {
          this.loading = false
        }
      },
      async _listListStores() {
        try {
          const params = {
            page: 1,
            row: 100
          }
          const { data } = await listStores(params)
          this.userLoginInfo.stores = [
            { storeId: '', name: this.$t('userLogin.allStores') },
            ...data
          ]
        } catch (error) {
          this.$message.error(this.$t('userLogin.storeFetchError'))
        }
      },
      swatchStore(item) {
        this.userLoginInfo.conditions.storeId = item.storeId
        this.pagination.current = 1
        this.loadData()
      },
      _queryUserLoginMethod() {
        this.pagination.current = 1
        this.loadData()
      },
      handleSizeChange(val) {
        this.pagination.size = val
        this.loadData()
      },
      handleCurrentChange(val) {
        this.pagination.current = val
        this.loadData()
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .user-login-container {
    padding: 20px;
  
    .store-list-card {
      height: 100%;
  
      .store-list {
        .store-ul {
          list-style: none;
          padding: 0;
          margin: 0;
  
          li {
            padding: 10px;
            cursor: pointer;
            border-radius: 4px;
            margin-bottom: 5px;
            text-align: center;
  
            &:hover {
              background-color: #f5f7fa;
            }
  
            &.selected-store {
              background-color: #409eff;
              color: white;
            }
          }
        }
      }
    }
  
    .search-card {
      margin-bottom: 20px;
    }
  }
  </style>