|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div>
|
|
|
3
|
+ <el-card class="list-query" shadow="hover">
|
|
|
4
|
+ <el-form inline label-width="80px">
|
|
|
5
|
+ <el-form-item :label="T('User')">
|
|
|
6
|
+ <el-select v-model="listQuery.user_id" clearable>
|
|
|
7
|
+ <el-option
|
|
|
8
|
+ v-for="item in allUsers"
|
|
|
9
|
+ :key="item.id"
|
|
|
10
|
+ :label="item.username"
|
|
|
11
|
+ :value="item.id"
|
|
|
12
|
+ ></el-option>
|
|
|
13
|
+ </el-select>
|
|
|
14
|
+ </el-form-item>
|
|
|
15
|
+ <el-form-item>
|
|
|
16
|
+ <el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
|
|
17
|
+ <el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>
|
|
|
18
|
+ </el-form-item>
|
|
|
19
|
+ </el-form>
|
|
|
20
|
+ </el-card>
|
|
|
21
|
+ <el-card class="list-body" shadow="hover">
|
|
|
22
|
+ <el-table :data="listRes.list" v-loading="listRes.loading" border @selection-change="handleSelectionChange">
|
|
|
23
|
+ <el-table-column type="selection" align="center" width="50"/>
|
|
|
24
|
+ <el-table-column prop="id" label="ID" align="center" width="100"/>
|
|
|
25
|
+ <el-table-column :label="T('User')" align="center" width="120">
|
|
|
26
|
+ <template #default="{row}">
|
|
|
27
|
+ <span v-if="row.user_id"> <el-tag>{{ allUsers?.find(u => u.id === row.user_id)?.username }}</el-tag> </span>
|
|
|
28
|
+ </template>
|
|
|
29
|
+ </el-table-column>
|
|
|
30
|
+ <el-table-column prop="peer_id" :label="T('Peer')" align="center"/>
|
|
|
31
|
+ <el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
|
|
32
|
+ <el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
|
|
|
33
|
+ </el-table-column>
|
|
|
34
|
+ <el-table-column :label="T('Actions')" align="center" width="400">
|
|
|
35
|
+ <template #default="{row}">
|
|
|
36
|
+ <el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>
|
|
|
37
|
+ </template>
|
|
|
38
|
+ </el-table-column>
|
|
|
39
|
+ </el-table>
|
|
|
40
|
+ </el-card>
|
|
|
41
|
+ <el-card class="list-page" shadow="hover">
|
|
|
42
|
+ <el-pagination background
|
|
|
43
|
+ layout="prev, pager, next, sizes, jumper"
|
|
|
44
|
+ :page-sizes="[10,20,50,100]"
|
|
|
45
|
+ v-model:page-size="listQuery.page_size"
|
|
|
46
|
+ v-model:current-page="listQuery.page"
|
|
|
47
|
+ :total="listRes.total">
|
|
|
48
|
+ </el-pagination>
|
|
|
49
|
+ </el-card>
|
|
|
50
|
+ </div>
|
|
|
51
|
+</template>
|
|
|
52
|
+
|
|
|
53
|
+<script setup>
|
|
|
54
|
+ import { onActivated, onMounted, ref, watch, reactive } from 'vue'
|
|
|
55
|
+ import { loadAllUsers } from '@/global'
|
|
|
56
|
+ import { T } from '@/utils/i18n'
|
|
|
57
|
+ import { remove, list, batchDelete } from '@/api/share_record'
|
|
|
58
|
+ import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
59
|
+
|
|
|
60
|
+ const { allUsers, getAllUsers } = loadAllUsers()
|
|
|
61
|
+ getAllUsers()
|
|
|
62
|
+
|
|
|
63
|
+ const listRes = reactive({
|
|
|
64
|
+ list: [], total: 0, loading: false,
|
|
|
65
|
+ })
|
|
|
66
|
+ const listQuery = reactive({
|
|
|
67
|
+ page: 1,
|
|
|
68
|
+ page_size: 10,
|
|
|
69
|
+ is_my: 0,
|
|
|
70
|
+ user_id: null,
|
|
|
71
|
+ })
|
|
|
72
|
+
|
|
|
73
|
+ const getList = async () => {
|
|
|
74
|
+ listRes.loading = true
|
|
|
75
|
+ const res = await list(listQuery).catch(_ => false)
|
|
|
76
|
+ listRes.loading = false
|
|
|
77
|
+ if (res) {
|
|
|
78
|
+ listRes.list = res.data.list
|
|
|
79
|
+ listRes.total = res.data.total
|
|
|
80
|
+ }
|
|
|
81
|
+ }
|
|
|
82
|
+ const handlerQuery = () => {
|
|
|
83
|
+ if (listQuery.page === 1) {
|
|
|
84
|
+ getList()
|
|
|
85
|
+ } else {
|
|
|
86
|
+ listQuery.page = 1
|
|
|
87
|
+ }
|
|
|
88
|
+ }
|
|
|
89
|
+ const expired = (row) => {
|
|
|
90
|
+ const now = new Date().getTime()
|
|
|
91
|
+ return row.expire * 1000 < now
|
|
|
92
|
+ }
|
|
|
93
|
+
|
|
|
94
|
+ const del = async (row) => {
|
|
|
95
|
+ const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
|
|
96
|
+ confirmButtonText: T('Confirm'),
|
|
|
97
|
+ cancelButtonText: T('Cancel'),
|
|
|
98
|
+ type: 'warning',
|
|
|
99
|
+ }).catch(_ => false)
|
|
|
100
|
+ if (!cf) {
|
|
|
101
|
+ return false
|
|
|
102
|
+ }
|
|
|
103
|
+ const res = await remove({ id: row.id }).catch(_ => false)
|
|
|
104
|
+ if (res) {
|
|
|
105
|
+ ElMessage.success(T('OperationSuccess'))
|
|
|
106
|
+ getList()
|
|
|
107
|
+ }
|
|
|
108
|
+ }
|
|
|
109
|
+ onMounted(getList)
|
|
|
110
|
+ onActivated(getList)
|
|
|
111
|
+
|
|
|
112
|
+ watch(() => listQuery.page, getList)
|
|
|
113
|
+
|
|
|
114
|
+ watch(() => listQuery.page_size, handlerQuery)
|
|
|
115
|
+ const multipleSelection = ref([])
|
|
|
116
|
+ const handleSelectionChange = (val) => {
|
|
|
117
|
+ multipleSelection.value = val
|
|
|
118
|
+ }
|
|
|
119
|
+ const toBatchDelete = () => {
|
|
|
120
|
+ if (multipleSelection.value.length === 0) {
|
|
|
121
|
+ return
|
|
|
122
|
+ }
|
|
|
123
|
+ batchdel(multipleSelection.value)
|
|
|
124
|
+ }
|
|
|
125
|
+
|
|
|
126
|
+ const batchdel = async (rows) => {
|
|
|
127
|
+ const ids = rows.map(r => r.id)
|
|
|
128
|
+ if (!ids.length) {
|
|
|
129
|
+ ElMessage.warning(T('PleaseSelectData'))
|
|
|
130
|
+ return false
|
|
|
131
|
+ }
|
|
|
132
|
+ const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
|
|
|
133
|
+ confirmButtonText: T('Confirm'),
|
|
|
134
|
+ cancelButtonText: T('Cancel'),
|
|
|
135
|
+ type: 'warning',
|
|
|
136
|
+ }).catch(_ => false)
|
|
|
137
|
+ if (!cf) {
|
|
|
138
|
+ return false
|
|
|
139
|
+ }
|
|
|
140
|
+
|
|
|
141
|
+ const res = await batchDelete({ ids }).catch(_ => false)
|
|
|
142
|
+ if (res) {
|
|
|
143
|
+ ElMessage.success(T('OperationSuccess'))
|
|
|
144
|
+ getList()
|
|
|
145
|
+ }
|
|
|
146
|
+ }
|
|
|
147
|
+
|
|
|
148
|
+</script>
|
|
|
149
|
+
|
|
|
150
|
+<style scoped lang="scss">
|
|
|
151
|
+.list-query .el-select {
|
|
|
152
|
+ --el-select-width: 160px;
|
|
|
153
|
+}
|
|
|
154
|
+
|
|
|
155
|
+
|
|
|
156
|
+</style>
|