lejianwen 1 год назад
Родитель
Сommit
8ecfe9cbd0

+ 0 - 7
src/api/address_book.js

@@ -61,10 +61,3 @@ export function batchCreateFromPeers (data) {
61
   })
61
   })
62
 }
62
 }
63
 
63
 
64
-export function batchUpdateTags (data) {
65
-  return request({
66
-    url: '/address_book/batchUpdateTags',
67
-    method: 'post',
68
-    data,
69
-  })
70
-}

+ 0 - 39
src/api/my.js

@@ -1,39 +0,0 @@
1
-import request from '@/utils/request'
2
-
3
-export function share_record_list (params) {
4
-  return request({
5
-    url: '/my/share_record/list',
6
-    params,
7
-  })
8
-}
9
-
10
-export function share_record_remove (data) {
11
-  return request({
12
-    url: '/my/share_record/delete',
13
-    method: 'post',
14
-    data,
15
-  })
16
-}
17
-
18
-export function share_record_batchDelete (data) {
19
-  return request({
20
-    url: '/my/share_record/batchDelete',
21
-    method: 'post',
22
-    data,
23
-  })
24
-}
25
-
26
-export function peer_list (params) {
27
-  return request({
28
-    url: '/my/peer/list',
29
-    params,
30
-  })
31
-}
32
-
33
-export function address_book_batchCreateFromPeers (data) {
34
-  return request({
35
-    url: '/my/address_book/batchCreateFromPeers',
36
-    method: 'post',
37
-    data,
38
-  })
39
-}

+ 48 - 0
src/api/my/address_book.js

@@ -0,0 +1,48 @@
1
+import request from '@/utils/request'
2
+
3
+export function list (params) {
4
+  return request({
5
+    url: '/my/address_book/list',
6
+    params,
7
+  })
8
+}
9
+
10
+export function batchCreateFromPeers (data) {
11
+  return request({
12
+    url: '/my/address_book/batchCreateFromPeers',
13
+    method: 'post',
14
+    data,
15
+  })
16
+}
17
+
18
+export function batchUpdateTags (data) {
19
+  return request({
20
+    url: '/my/address_book/batchUpdateTags',
21
+    method: 'post',
22
+    data,
23
+  })
24
+}
25
+
26
+export function create (data) {
27
+  return request({
28
+    url: '/my/address_book/create',
29
+    method: 'post',
30
+    data,
31
+  })
32
+}
33
+
34
+export function update (data) {
35
+  return request({
36
+    url: '/my/address_book/update',
37
+    method: 'post',
38
+    data,
39
+  })
40
+}
41
+
42
+export function remove (data) {
43
+  return request({
44
+    url: '/my/address_book/delete',
45
+    method: 'post',
46
+    data,
47
+  })
48
+}

+ 33 - 0
src/api/my/address_book_collection.js

@@ -0,0 +1,33 @@
1
+import request from '@/utils/request'
2
+
3
+export function list (params) {
4
+  return request({
5
+    url: '/my/address_book_collection/list',
6
+    params,
7
+  })
8
+}
9
+
10
+export function create (data) {
11
+  return request({
12
+    url: '/my/address_book_collection/create',
13
+    method: 'post',
14
+    data,
15
+  })
16
+}
17
+
18
+export function update (data) {
19
+  return request({
20
+    url: '/my/address_book_collection/update',
21
+    method: 'post',
22
+    data,
23
+  })
24
+}
25
+
26
+export function remove (data) {
27
+  return request({
28
+    url: '/my/address_book_collection/delete',
29
+    method: 'post',
30
+    data,
31
+  })
32
+}
33
+

+ 40 - 0
src/api/my/address_book_collection_rule.js

@@ -0,0 +1,40 @@
1
+import request from '@/utils/request'
2
+
3
+export function list (params) {
4
+  return request({
5
+    url: '/my/address_book_collection_rule/list',
6
+    params,
7
+  })
8
+}
9
+
10
+export function create (data) {
11
+  return request({
12
+    url: '/my/address_book_collection_rule/create',
13
+    method: 'post',
14
+    data,
15
+  })
16
+}
17
+
18
+export function update (data) {
19
+  return request({
20
+    url: '/my/address_book_collection_rule/update',
21
+    method: 'post',
22
+    data,
23
+  })
24
+}
25
+
26
+export function remove (data) {
27
+  return request({
28
+    url: '/my/address_book_collection_rule/delete',
29
+    method: 'post',
30
+    data,
31
+  })
32
+}
33
+
34
+export function batchCreate (data) {
35
+  return request({
36
+    url: '/my/address_book_collection_rule/batchCreate',
37
+    method: 'post',
38
+    data,
39
+  })
40
+}

+ 8 - 0
src/api/my/peer.js

@@ -0,0 +1,8 @@
1
+import request from '@/utils/request'
2
+
3
+export function list (params) {
4
+  return request({
5
+    url: '/my/peer/list',
6
+    params,
7
+  })
8
+}

+ 24 - 0
src/api/my/share_record.js

@@ -0,0 +1,24 @@
1
+import request from '@/utils/request'
2
+
3
+export function list (params) {
4
+  return request({
5
+    url: '/my/share_record/list',
6
+    params,
7
+  })
8
+}
9
+
10
+export function remove (data) {
11
+  return request({
12
+    url: '/my/share_record/delete',
13
+    method: 'post',
14
+    data,
15
+  })
16
+}
17
+
18
+export function batchDelete (data) {
19
+  return request({
20
+    url: '/my/share_record/batchDelete',
21
+    method: 'post',
22
+    data,
23
+  })
24
+}

+ 33 - 0
src/api/my/tag.js

@@ -0,0 +1,33 @@
1
+import request from '@/utils/request'
2
+
3
+export function list (params) {
4
+  return request({
5
+    url: '/my/tag/list',
6
+    params,
7
+  })
8
+}
9
+
10
+export function create (data) {
11
+  return request({
12
+    url: '/my/tag/create',
13
+    method: 'post',
14
+    data,
15
+  })
16
+}
17
+
18
+export function update (data) {
19
+  return request({
20
+    url: '/my/tag/update',
21
+    method: 'post',
22
+    data,
23
+  })
24
+}
25
+
26
+export function remove (data) {
27
+  return request({
28
+    url: '/my/tag/delete',
29
+    method: 'post',
30
+    data,
31
+  })
32
+}
33
+

+ 1 - 0
src/components/icons/platform.vue

@@ -17,6 +17,7 @@
17
     name: {
17
     name: {
18
       type: String,
18
       type: String,
19
       required: true,
19
       required: true,
20
+      default: '',
20
       values: ['windows', 'android', 'mac', 'linux'],
21
       values: ['windows', 'android', 'mac', 'linux'],
21
     },
22
     },
22
     color: {
23
     color: {

+ 11 - 6
src/views/address_book/collection.js

@@ -1,23 +1,28 @@
1
 import { reactive, ref } from 'vue'
1
 import { reactive, ref } from 'vue'
2
-import { create, list, remove, update } from '@/api/address_book_collection'
2
+import { list as admin_list, create as admin_create, update as admin_update, remove as admin_remove } from '@/api/address_book_collection'
3
+import { list as my_list, create as my_create, update as my_update, remove as my_remove } from '@/api/my/address_book_collection'
3
 import { ElMessage, ElMessageBox } from 'element-plus'
4
 import { ElMessage, ElMessageBox } from 'element-plus'
4
 import { T } from '@/utils/i18n'
5
 import { T } from '@/utils/i18n'
5
 
6
 
6
-export function useRepositories (is_my) {
7
+const apis = {
8
+  admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
9
+  my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
10
+}
11
+
12
+export function useRepositories (api_type = 'my') {
7
   const listRes = reactive({
13
   const listRes = reactive({
8
     list: [], total: 0, loading: false,
14
     list: [], total: 0, loading: false,
9
   })
15
   })
10
   const listQuery = reactive({
16
   const listQuery = reactive({
11
     page: 1,
17
     page: 1,
12
     page_size: 10,
18
     page_size: 10,
13
-    is_my,
14
     name: null,
19
     name: null,
15
     user_id: null,
20
     user_id: null,
16
   })
21
   })
17
 
22
 
18
   const getList = async () => {
23
   const getList = async () => {
19
     listRes.loading = true
24
     listRes.loading = true
20
-    const res = await list(listQuery).catch(_ => false)
25
+    const res = await apis[api_type].list(listQuery).catch(_ => false)
21
     listRes.loading = false
26
     listRes.loading = false
22
     if (res) {
27
     if (res) {
23
       listRes.list = res.data.list
28
       listRes.list = res.data.list
@@ -42,7 +47,7 @@ export function useRepositories (is_my) {
42
       return false
47
       return false
43
     }
48
     }
44
 
49
 
45
-    const res = await remove({ id: row.id }).catch(_ => false)
50
+    const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
46
     if (res) {
51
     if (res) {
47
       ElMessage.success(T('OperationSuccess'))
52
       ElMessage.success(T('OperationSuccess'))
48
       getList()
53
       getList()
@@ -72,7 +77,7 @@ export function useRepositories (is_my) {
72
 
77
 
73
   }
78
   }
74
   const submit = async () => {
79
   const submit = async () => {
75
-    const api = formData.id ? update : create
80
+    const api = formData.id ? apis[api_type].update : apis[api_type].create
76
     const res = await api(formData).catch(_ => false)
81
     const res = await api(formData).catch(_ => false)
77
     if (res) {
82
     if (res) {
78
       ElMessage.success(T('OperationSuccess'))
83
       ElMessage.success(T('OperationSuccess'))

+ 1 - 1
src/views/address_book/collection.vue

@@ -96,7 +96,7 @@
96
     toEdit,
96
     toEdit,
97
     toAdd,
97
     toAdd,
98
     submit,
98
     submit,
99
-  } = useRepositories()
99
+  } = useRepositories('admin')
100
 
100
 
101
   listQuery.is_my = 0
101
   listQuery.is_my = 0
102
 
102
 

+ 45 - 51
src/views/address_book/index.js

@@ -1,28 +1,24 @@
1
 import { reactive, ref } from 'vue'
1
 import { reactive, ref } from 'vue'
2
-import { batchUpdateTags, create, list, remove, update } from '@/api/address_book'
2
+import { create as admin_create, list as admin_list, remove as admin_remove, update as admin_update } from '@/api/address_book'
3
+import { batchUpdateTags, list as my_list, create as my_create, update as my_update, remove as my_remove } from '@/api/my/address_book'
3
 import { ElMessage, ElMessageBox } from 'element-plus'
4
 import { ElMessage, ElMessageBox } from 'element-plus'
4
 import { T } from '@/utils/i18n'
5
 import { T } from '@/utils/i18n'
5
 import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
6
 import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
6
 import { useRepositories as useTagRepositories } from '@/views/tag/index'
7
 import { useRepositories as useTagRepositories } from '@/views/tag/index'
7
-import { loadAllUsers } from '@/global'
8
 import { simpleData } from '@/api/peer'
8
 import { simpleData } from '@/api/peer'
9
 
9
 
10
-export function useRepositories (is_my = 0) {
11
-
12
-  const { allUsers, getAllUsers } = loadAllUsers()
10
+const apis = {
11
+  admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
12
+  my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
13
+}
13
 
14
 
15
+export function useRepositories (api_type = 'my') {
14
   const {
16
   const {
15
     listRes: collectionListRes,
17
     listRes: collectionListRes,
16
     listQuery: collectionListQuery,
18
     listQuery: collectionListQuery,
17
     getList: getCollectionList,
19
     getList: getCollectionList,
18
-  } = useCollectionRepositories(is_my)
20
+  } = useCollectionRepositories(api_type)
19
   collectionListQuery.page_size = 9999
21
   collectionListQuery.page_size = 9999
20
-  const {
21
-    listRes: tagListRes,
22
-    listQuery: tagListQuery,
23
-    getList: getTagList,
24
-  } = useTagRepositories(is_my)
25
-  tagListQuery.page_size = 9999
26
 
22
 
27
   const listRes = reactive({
23
   const listRes = reactive({
28
     list: [], total: 0, loading: false,
24
     list: [], total: 0, loading: false,
@@ -30,7 +26,6 @@ export function useRepositories (is_my = 0) {
30
   const listQuery = reactive({
26
   const listQuery = reactive({
31
     page: 1,
27
     page: 1,
32
     page_size: 10,
28
     page_size: 10,
33
-    is_my,
34
     id: null,
29
     id: null,
35
     user_id: null,
30
     user_id: null,
36
     username: null,
31
     username: null,
@@ -40,7 +35,7 @@ export function useRepositories (is_my = 0) {
40
 
35
 
41
   const getList = async () => {
36
   const getList = async () => {
42
     listRes.loading = true
37
     listRes.loading = true
43
-    const res = await list(listQuery).catch(_ => false)
38
+    const res = await apis[api_type].list(listQuery).catch(_ => false)
44
     listRes.loading = false
39
     listRes.loading = false
45
     if (res) {
40
     if (res) {
46
       const ids = res.data.list.map(item => item.id)
41
       const ids = res.data.list.map(item => item.id)
@@ -78,13 +73,14 @@ export function useRepositories (is_my = 0) {
78
       return false
73
       return false
79
     }
74
     }
80
 
75
 
81
-    const res = await remove({ row_id: row.row_id }).catch(_ => false)
76
+    const res = await apis[api_type].remove({ row_id: row.row_id }).catch(_ => false)
82
     if (res) {
77
     if (res) {
83
       ElMessage.success(T('OperationSuccess'))
78
       ElMessage.success(T('OperationSuccess'))
84
       getList()
79
       getList()
85
     }
80
     }
86
   }
81
   }
87
 
82
 
83
+  //创建或者修改
88
   const platformList = [
84
   const platformList = [
89
     { label: 'Windows', value: 'Windows', icon: 'windows' },
85
     { label: 'Windows', value: 'Windows', icon: 'windows' },
90
     { label: 'Linux', value: 'Linux', icon: 'linux' },
86
     { label: 'Linux', value: 'Linux', icon: 'linux' },
@@ -112,6 +108,18 @@ export function useRepositories (is_my = 0) {
112
     'username': '',
108
     'username': '',
113
     collection_id: null,
109
     collection_id: null,
114
   })
110
   })
111
+  const {
112
+    listRes: collectionListResForUpdate,
113
+    listQuery: collectionListQueryForUpdate,
114
+    getList: getCollectionListForUpdate,
115
+  } = useCollectionRepositories(api_type)
116
+  collectionListQueryForUpdate.page_size = 9999
117
+  const {
118
+    listRes: tagListRes,
119
+    listQuery: tagListQuery,
120
+    getList: getTagList,
121
+  } = useTagRepositories(api_type)
122
+  tagListQuery.page_size = 9999
115
 
123
 
116
   const toEdit = (row) => {
124
   const toEdit = (row) => {
117
     formVisible.value = true
125
     formVisible.value = true
@@ -119,9 +127,9 @@ export function useRepositories (is_my = 0) {
119
     Object.keys(formData).forEach(key => {
127
     Object.keys(formData).forEach(key => {
120
       formData[key] = row[key]
128
       formData[key] = row[key]
121
     })
129
     })
122
-    collectionListQuery.user_id = row.user_id
123
-    getCollectionList()
130
+    collectionListQueryForUpdate.user_id = row.user_id
124
     tagListQuery.collection_id = row.collection_id
131
     tagListQuery.collection_id = row.collection_id
132
+    getCollectionListForUpdate()
125
     getTagList()
133
     getTagList()
126
 
134
 
127
   }
135
   }
@@ -147,7 +155,7 @@ export function useRepositories (is_my = 0) {
147
 
155
 
148
   }
156
   }
149
   const submit = async () => {
157
   const submit = async () => {
150
-    const api = formData.row_id ? update : create
158
+    const api = formData.row_id ? apis[api_type].update : apis[api_type].create
151
     const res = await api(formData).catch(_ => false)
159
     const res = await api(formData).catch(_ => false)
152
     if (res) {
160
     if (res) {
153
       ElMessage.success(T('OperationSuccess'))
161
       ElMessage.success(T('OperationSuccess'))
@@ -155,16 +163,6 @@ export function useRepositories (is_my = 0) {
155
       getList()
163
       getList()
156
     }
164
     }
157
   }
165
   }
158
-  const shareToWebClientVisible = ref(false)
159
-  const shareToWebClientForm = reactive({
160
-    id: '',
161
-    hash: '',
162
-  })
163
-  const toShowShare = (row) => {
164
-    shareToWebClientForm.id = row.id
165
-    shareToWebClientForm.hash = row.hash
166
-    shareToWebClientVisible.value = true
167
-  }
168
 
166
 
169
   const changeQueryUser = async (val) => {
167
   const changeQueryUser = async (val) => {
170
     tagListRes.list = []
168
     tagListRes.list = []
@@ -176,18 +174,18 @@ export function useRepositories (is_my = 0) {
176
       getCollectionList()
174
       getCollectionList()
177
     }
175
     }
178
   }
176
   }
179
-  const changeUser = async (val) => {
177
+  const changeUserForUpdate = async (val) => {
180
     tagListRes.list = []
178
     tagListRes.list = []
181
     formData.tags = []
179
     formData.tags = []
182
     formData.collection_id = 0
180
     formData.collection_id = 0
183
     if (!val) {
181
     if (!val) {
184
-      collectionListRes.list = []
182
+      collectionListResForUpdate.list = []
185
     } else {
183
     } else {
186
-      collectionListQuery.user_id = val
187
-      getCollectionList()
184
+      collectionListQueryForUpdate.user_id = val
185
+      getCollectionListForUpdate()
188
     }
186
     }
189
   }
187
   }
190
-  const changeCollection = async (val) => {
188
+  const changeCollectionForUpdate = async (val) => {
191
     tagListRes.list = []
189
     tagListRes.list = []
192
     formData.tags = []
190
     formData.tags = []
193
     tagListQuery.user_id = formData.user_id
191
     tagListQuery.user_id = formData.user_id
@@ -217,42 +215,38 @@ export function useRepositories (is_my = 0) {
217
     listQuery,
215
     listQuery,
218
     getList,
216
     getList,
219
     handlerQuery,
217
     handlerQuery,
220
-    del,
218
+    collectionListQuery,
219
+    getCollectionList,
220
+    collectionListRes,
221
+    changeQueryUser,
222
+
221
     platformList,
223
     platformList,
224
+
225
+    del,
226
+
222
     formVisible,
227
     formVisible,
223
     formData,
228
     formData,
224
     toEdit,
229
     toEdit,
225
     toAdd,
230
     toAdd,
226
     submit,
231
     submit,
227
-    shareToWebClientVisible,
228
-    shareToWebClientForm,
229
-    toShowShare,
230
-
231
-    collectionListQuery,
232
-    getCollectionList,
233
-    collectionListRes,
234
-
232
+    getCollectionListForUpdate,
233
+    collectionListResForUpdate,
234
+    changeUserForUpdate,
235
+    changeCollectionForUpdate,
235
     tagListQuery,
236
     tagListQuery,
236
     getTagList,
237
     getTagList,
237
     tagListRes,
238
     tagListRes,
238
 
239
 
239
-    allUsers,
240
-    getAllUsers,
241
-
242
-    changeQueryUser,
243
-    changeUser,
244
-    changeCollection,
245
-
246
     fromPeer,
240
     fromPeer,
247
   }
241
   }
248
 }
242
 }
249
 
243
 
250
-export function useBatchUpdateTagsRepositories (is_my = 0) {
244
+export function useBatchUpdateTagsRepositories () {
251
   const {
245
   const {
252
     listRes: tagListRes,
246
     listRes: tagListRes,
253
     listQuery: tagListQuery,
247
     listQuery: tagListQuery,
254
     getList: getTagList,
248
     getList: getTagList,
255
-  } = useTagRepositories(is_my)
249
+  } = useTagRepositories('my')
256
   tagListQuery.page_size = 9999
250
   tagListQuery.page_size = 9999
257
 
251
 
258
   const visible = ref(false)
252
   const visible = ref(false)

+ 13 - 19
src/views/address_book/index.vue

@@ -89,7 +89,7 @@
89
     <el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
89
     <el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
90
       <el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
90
       <el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
91
         <el-form-item :label="T('Owner')" prop="user_id" required>
91
         <el-form-item :label="T('Owner')" prop="user_id" required>
92
-          <el-select v-model="formData.user_id" @change="changeUser">
92
+          <el-select v-model="formData.user_id" @change="changeUserForUpdate">
93
             <el-option
93
             <el-option
94
                 v-for="item in allUsers"
94
                 v-for="item in allUsers"
95
                 :key="item.id"
95
                 :key="item.id"
@@ -99,9 +99,9 @@
99
           </el-select>
99
           </el-select>
100
         </el-form-item>
100
         </el-form-item>
101
         <el-form-item :label="T('AddressBookName')">
101
         <el-form-item :label="T('AddressBookName')">
102
-          <el-select v-model="formData.collection_id" clearable @change="changeCollection">
102
+          <el-select v-model="formData.collection_id" clearable @change="changeCollectionForUpdate">
103
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
103
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
104
-            <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
104
+            <el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
105
           </el-select>
105
           </el-select>
106
         </el-form-item>
106
         </el-form-item>
107
         <el-form-item label="ID" prop="id" required>
107
         <el-form-item label="ID" prop="id" required>
@@ -162,7 +162,6 @@
162
                 <el-switch v-model="formData.sameServer"></el-switch>
162
                 <el-switch v-model="formData.sameServer"></el-switch>
163
               </el-form-item>-->
163
               </el-form-item>-->
164
 
164
 
165
-
166
         <el-form-item>
165
         <el-form-item>
167
           <el-button @click="formVisible = false">{{ T('Cancel') }}</el-button>
166
           <el-button @click="formVisible = false">{{ T('Cancel') }}</el-button>
168
           <el-button @click="submit" type="primary">{{ T('Submit') }}</el-button>
167
           <el-button @click="submit" type="primary">{{ T('Submit') }}</el-button>
@@ -179,9 +178,9 @@
179
 </template>
178
 </template>
180
 
179
 
181
 <script setup>
180
 <script setup>
182
-  import { onActivated, onMounted, reactive, ref, watch } from 'vue'
181
+  import { onActivated, onMounted, watch } from 'vue'
183
   import { useRepositories } from '@/views/address_book/index'
182
   import { useRepositories } from '@/views/address_book/index'
184
-  import { toWebClientLink, getPeerSlat } from '@/utils/webclient'
183
+  import { toWebClientLink } from '@/utils/webclient'
185
   import { T } from '@/utils/i18n'
184
   import { T } from '@/utils/i18n'
186
   import { useRoute } from 'vue-router'
185
   import { useRoute } from 'vue-router'
187
   import { connectByClient } from '@/utils/peer'
186
   import { connectByClient } from '@/utils/peer'
@@ -189,18 +188,19 @@
189
   import { handleClipboard } from '@/utils/clipboard'
188
   import { handleClipboard } from '@/utils/clipboard'
190
   import { CopyDocument } from '@element-plus/icons'
189
   import { CopyDocument } from '@element-plus/icons'
191
   import PlatformIcons from '@/components/icons/platform.vue'
190
   import PlatformIcons from '@/components/icons/platform.vue'
192
-
193
-
191
+  import { loadAllUsers } from '@/global'
194
 
192
 
195
   const appStore = useAppStore()
193
   const appStore = useAppStore()
196
   const route = useRoute()
194
   const route = useRoute()
197
-
195
+  const { allUsers, getAllUsers } = loadAllUsers()
198
 
196
 
199
   const {
197
   const {
200
     listRes,
198
     listRes,
201
     listQuery,
199
     listQuery,
202
     getList,
200
     getList,
203
     handlerQuery,
201
     handlerQuery,
202
+    collectionListRes,
203
+
204
     del,
204
     del,
205
     formVisible,
205
     formVisible,
206
     platformList,
206
     platformList,
@@ -208,19 +208,13 @@
208
     toEdit,
208
     toEdit,
209
     toAdd,
209
     toAdd,
210
     submit,
210
     submit,
211
-    // shareToWebClientVisible,
212
-    // shareToWebClientForm,
213
-    // toShowShare,
214
-    collectionListRes,
215
-
211
+    changeUserForUpdate,
212
+    changeCollectionForUpdate,
213
+    collectionListResForUpdate,
216
     tagListRes,
214
     tagListRes,
217
 
215
 
218
-    allUsers, getAllUsers,
219
-
220
     changeQueryUser,
216
     changeQueryUser,
221
-    changeUser,
222
-    changeCollection
223
-  } = useRepositories()
217
+  } = useRepositories('admin')
224
 
218
 
225
   if (route.query?.user_id) {
219
   if (route.query?.user_id) {
226
     listQuery.user_id = parseInt(route.query.user_id)
220
     listQuery.user_id = parseInt(route.query.user_id)

+ 11 - 7
src/views/address_book/rule.js

@@ -1,11 +1,16 @@
1
 import { computed, reactive, ref } from 'vue'
1
 import { computed, reactive, ref } from 'vue'
2
-import { create, list, remove, update } from '@/api/address_book_collection_rule'
2
+import { list as admin_list, create as admin_create, update as admin_update, remove as admin_remove } from '@/api/address_book_collection_rule'
3
+import { list as my_list, create as my_create, update as my_update, remove as my_remove } from '@/api/my/address_book_collection_rule'
3
 import { groupUsers } from '@/api/user'
4
 import { groupUsers } from '@/api/user'
4
 import { ElMessage, ElMessageBox } from 'element-plus'
5
 import { ElMessage, ElMessageBox } from 'element-plus'
5
 import { T } from '@/utils/i18n'
6
 import { T } from '@/utils/i18n'
6
-import collection from '@element-plus/icons/lib/Collection'
7
 
7
 
8
-export function useRepositories (is_my) {
8
+const apis = {
9
+  admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
10
+  my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
11
+}
12
+
13
+export function useRepositories (api_type = 'my') {
9
   const listRes = reactive({
14
   const listRes = reactive({
10
     list: [], total: 0, loading: false,
15
     list: [], total: 0, loading: false,
11
   })
16
   })
@@ -13,12 +18,11 @@ export function useRepositories (is_my) {
13
     page: 1,
18
     page: 1,
14
     page_size: 10,
19
     page_size: 10,
15
     collection_id: null,
20
     collection_id: null,
16
-    is_my,
17
   })
21
   })
18
 
22
 
19
   const getList = async () => {
23
   const getList = async () => {
20
     listRes.loading = true
24
     listRes.loading = true
21
-    const res = await list(listQuery).catch(_ => false)
25
+    const res = await apis[api_type].list(listQuery).catch(_ => false)
22
     listRes.loading = false
26
     listRes.loading = false
23
     if (res) {
27
     if (res) {
24
       listRes.list = res.data.list
28
       listRes.list = res.data.list
@@ -43,7 +47,7 @@ export function useRepositories (is_my) {
43
       return false
47
       return false
44
     }
48
     }
45
 
49
 
46
-    const res = await remove({ id: row.id }).catch(_ => false)
50
+    const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
47
     if (res) {
51
     if (res) {
48
       ElMessage.success(T('OperationSuccess'))
52
       ElMessage.success(T('OperationSuccess'))
49
       getList()
53
       getList()
@@ -79,7 +83,7 @@ export function useRepositories (is_my) {
79
 
83
 
80
   }
84
   }
81
   const submit = async () => {
85
   const submit = async () => {
82
-    const api = formData.id ? update : create
86
+    const api = formData.id ? apis[api_type].update : apis[api_type].create
83
     const res = await api(formData).catch(_ => false)
87
     const res = await api(formData).catch(_ => false)
84
     if (res) {
88
     if (res) {
85
       ElMessage.success(T('OperationSuccess'))
89
       ElMessage.success(T('OperationSuccess'))

+ 2 - 2
src/views/address_book/rule.vue

@@ -56,7 +56,7 @@
56
           </el-radio-group>
56
           </el-radio-group>
57
         </el-form-item>
57
         </el-form-item>
58
         <el-form-item :label="T('ShareTo')" prop="to_id" required>
58
         <el-form-item :label="T('ShareTo')" prop="to_id" required>
59
-<!--          <el-input-number v-model="formData.to_id"></el-input-number>-->
59
+          <!--          <el-input-number v-model="formData.to_id"></el-input-number>-->
60
           <el-select v-model="formData.to_id">
60
           <el-select v-model="formData.to_id">
61
             <el-option
61
             <el-option
62
                 v-for="item in groupUsersList"
62
                 v-for="item in groupUsersList"
@@ -106,7 +106,7 @@
106
     rules,
106
     rules,
107
     groupUsersList,
107
     groupUsersList,
108
     getGroupUsers,
108
     getGroupUsers,
109
-  } = useRepositories(props.is_my)
109
+  } = useRepositories(props.is_my ? 'my' : 'admin')
110
 
110
 
111
   formData.collection_id = props.collection.id
111
   formData.collection_id = props.collection.id
112
   formData.user_id = props.collection.user_id
112
   formData.user_id = props.collection.user_id

+ 1 - 1
src/views/my/address_book/collection.vue

@@ -71,7 +71,7 @@
71
     toEdit,
71
     toEdit,
72
     toAdd,
72
     toAdd,
73
     submit,
73
     submit,
74
-  } = useRepositories(1)
74
+  } = useRepositories('my')
75
 
75
 
76
   onMounted(getList)
76
   onMounted(getList)
77
 
77
 

+ 25 - 14
src/views/my/address_book/index.vue

@@ -76,9 +76,9 @@
76
     <el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
76
     <el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
77
       <el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
77
       <el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
78
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
78
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
79
-          <el-select v-model="formData.collection_id" clearable @change="changeCollection">
79
+          <el-select v-model="formData.collection_id" clearable @change="changeCollectionForUpdate">
80
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
80
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
81
-            <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
81
+            <el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
82
           </el-select>
82
           </el-select>
83
         </el-form-item>
83
         </el-form-item>
84
         <el-form-item label="ID" prop="id" required>
84
         <el-form-item label="ID" prop="id" required>
@@ -174,7 +174,7 @@
174
 </template>
174
 </template>
175
 
175
 
176
 <script setup>
176
 <script setup>
177
-  import { onActivated, onMounted, ref, watch } from 'vue'
177
+  import { onActivated, onMounted, reactive, ref, watch } from 'vue'
178
   import { useBatchUpdateTagsRepositories, useRepositories } from '@/views/address_book'
178
   import { useBatchUpdateTagsRepositories, useRepositories } from '@/views/address_book'
179
   import { toWebClientLink } from '@/utils/webclient'
179
   import { toWebClientLink } from '@/utils/webclient'
180
   import { T } from '@/utils/i18n'
180
   import { T } from '@/utils/i18n'
@@ -185,32 +185,33 @@
185
   import { CopyDocument } from '@element-plus/icons'
185
   import { CopyDocument } from '@element-plus/icons'
186
   import PlatformIcons from '@/components/icons/platform.vue'
186
   import PlatformIcons from '@/components/icons/platform.vue'
187
 
187
 
188
-  const is_my = 1
189
   const appStore = useAppStore()
188
   const appStore = useAppStore()
190
-
191
   const {
189
   const {
192
     listRes,
190
     listRes,
193
     listQuery,
191
     listQuery,
194
     getList,
192
     getList,
195
     handlerQuery,
193
     handlerQuery,
194
+    collectionListRes,
195
+    getCollectionList,
196
+
196
     del,
197
     del,
198
+
197
     formVisible,
199
     formVisible,
198
     platformList,
200
     platformList,
199
     formData,
201
     formData,
200
     toEdit,
202
     toEdit,
201
     toAdd,
203
     toAdd,
202
     submit,
204
     submit,
203
-    shareToWebClientVisible,
204
-    shareToWebClientForm,
205
-    toShowShare,
206
-    // collectionListQuery,
207
-    collectionListRes,
208
-    getCollectionList,
209
     tagListRes,
205
     tagListRes,
210
-    changeCollection,
211
-  } = useRepositories(is_my)
206
+    changeCollectionForUpdate,
207
+    getCollectionListForUpdate,
208
+    collectionListResForUpdate,
209
+    // collectionListQuery,
210
+
211
+  } = useRepositories('my')
212
 
212
 
213
   onMounted(getCollectionList)
213
   onMounted(getCollectionList)
214
+  onMounted(getCollectionListForUpdate)
214
   onMounted(getList)
215
   onMounted(getList)
215
   onActivated(getList)
216
   onActivated(getList)
216
 
217
 
@@ -218,6 +219,16 @@
218
 
219
 
219
   watch(() => listQuery.page_size, handlerQuery)
220
   watch(() => listQuery.page_size, handlerQuery)
220
 
221
 
222
+  const shareToWebClientVisible = ref(false)
223
+  const shareToWebClientForm = reactive({
224
+    id: '',
225
+    hash: '',
226
+  })
227
+  const toShowShare = (row) => {
228
+    shareToWebClientForm.id = row.id
229
+    shareToWebClientForm.hash = row.hash
230
+    shareToWebClientVisible.value = true
231
+  }
221
   const {
232
   const {
222
     tagListRes: tagListResForBatchEdit,
233
     tagListRes: tagListResForBatchEdit,
223
     getTagList: getTagListForBatchEdit,
234
     getTagList: getTagListForBatchEdit,
@@ -225,7 +236,7 @@
225
     show: showBatchEditTags,
236
     show: showBatchEditTags,
226
     formData: batchEditTagsFormData,
237
     formData: batchEditTagsFormData,
227
     submit: _submitBatchEditTags,
238
     submit: _submitBatchEditTags,
228
-  } = useBatchUpdateTagsRepositories(is_my)
239
+  } = useBatchUpdateTagsRepositories()
229
   onMounted(getTagListForBatchEdit)
240
   onMounted(getTagListForBatchEdit)
230
   const submitBatchEditTags = async () => {
241
   const submitBatchEditTags = async () => {
231
     const res = await _submitBatchEditTags().catch(_ => false)
242
     const res = await _submitBatchEditTags().catch(_ => false)

+ 22 - 19
src/views/my/peer/index.vue

@@ -22,7 +22,7 @@
22
         <el-form-item>
22
         <el-form-item>
23
           <el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
23
           <el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
24
           <el-button type="success" @click="toExport">{{ T('Export') }}</el-button>
24
           <el-button type="success" @click="toExport">{{ T('Export') }}</el-button>
25
-          <el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>
25
+          <!--          <el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>-->
26
           <el-button type="primary" @click="toBatchAddToAB">{{ T('BatchAddToAB') }}</el-button>
26
           <el-button type="primary" @click="toBatchAddToAB">{{ T('BatchAddToAB') }}</el-button>
27
 
27
 
28
         </el-form-item>
28
         </el-form-item>
@@ -59,7 +59,7 @@
59
             <el-button v-if="appStore.setting.appConfig.web_client" type="success" @click="toWebClientLink(row)">Web Client</el-button>
59
             <el-button v-if="appStore.setting.appConfig.web_client" type="success" @click="toWebClientLink(row)">Web Client</el-button>
60
             <el-button type="primary" @click="toAddressBook(row)">{{ T('AddToAddressBook') }}</el-button>
60
             <el-button type="primary" @click="toAddressBook(row)">{{ T('AddToAddressBook') }}</el-button>
61
             <el-button @click="toView(row)">{{ T('View') }}</el-button>
61
             <el-button @click="toView(row)">{{ T('View') }}</el-button>
62
-            <el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>
62
+            <!--            <el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>-->
63
           </template>
63
           </template>
64
         </el-table-column>
64
         </el-table-column>
65
       </el-table>
65
       </el-table>
@@ -105,9 +105,9 @@
105
     <el-dialog v-model="ABFormVisible" width="800" :title="T('Create')">
105
     <el-dialog v-model="ABFormVisible" width="800" :title="T('Create')">
106
       <el-form class="dialog-form" ref="form" :model="ABFormData" label-width="120px">
106
       <el-form class="dialog-form" ref="form" :model="ABFormData" label-width="120px">
107
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
107
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
108
-          <el-select v-model="ABFormData.collection_id" clearable @change="changeCollection">
108
+          <el-select v-model="ABFormData.collection_id" clearable @change="changeCollectionForUpdate">
109
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
109
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
110
-            <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
110
+            <el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
111
           </el-select>
111
           </el-select>
112
         </el-form-item>
112
         </el-form-item>
113
         <el-form-item label="ID" prop="id" required>
113
         <el-form-item label="ID" prop="id" required>
@@ -153,9 +153,9 @@
153
     <el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
153
     <el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
154
       <el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
154
       <el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
155
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
155
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
156
-          <el-select v-model="batchABFormData.collection_id" clearable @change="changeCollection">
156
+          <el-select v-model="batchABFormData.collection_id" clearable @change="changeCollectionForBatchCreateAB">
157
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
157
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
158
-            <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
158
+            <el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
159
           </el-select>
159
           </el-select>
160
         </el-form-item>
160
         </el-form-item>
161
         <el-form-item :label="T('Tags')" prop="tags">
161
         <el-form-item :label="T('Tags')" prop="tags">
@@ -179,8 +179,7 @@
179
 
179
 
180
 <script setup>
180
 <script setup>
181
   import { computed, onActivated, onMounted, reactive, ref, watch } from 'vue'
181
   import { computed, onActivated, onMounted, reactive, ref, watch } from 'vue'
182
-  import { batchRemove, remove } from '@/api/peer'
183
-  import { myPeer } from '@/api/user'
182
+  import { list } from '@/api/my/peer'
184
   import { ElMessage, ElMessageBox } from 'element-plus'
183
   import { ElMessage, ElMessageBox } from 'element-plus'
185
   import { toWebClientLink } from '@/utils/webclient'
184
   import { toWebClientLink } from '@/utils/webclient'
186
   import { T } from '@/utils/i18n'
185
   import { T } from '@/utils/i18n'
@@ -191,7 +190,7 @@
191
   import { connectByClient } from '@/utils/peer'
190
   import { connectByClient } from '@/utils/peer'
192
   import { CopyDocument } from '@element-plus/icons'
191
   import { CopyDocument } from '@element-plus/icons'
193
   import { handleClipboard } from '@/utils/clipboard'
192
   import { handleClipboard } from '@/utils/clipboard'
194
-  import { address_book_batchCreateFromPeers as batchCreateFromPeers } from '@/api/my'
193
+  import { batchCreateFromPeers } from '@/api/my/address_book'
195
 
194
 
196
   const appStore = useAppStore()
195
   const appStore = useAppStore()
197
   const listRes = reactive({
196
   const listRes = reactive({
@@ -207,7 +206,7 @@
207
 
206
 
208
   const getList = async () => {
207
   const getList = async () => {
209
     listRes.loading = true
208
     listRes.loading = true
210
-    const res = await myPeer(listQuery).catch(_ => false)
209
+    const res = await list(listQuery).catch(_ => false)
211
     listRes.loading = false
210
     listRes.loading = false
212
     if (res) {
211
     if (res) {
213
       listRes.list = res.data.list
212
       listRes.list = res.data.list
@@ -222,7 +221,7 @@
222
     }
221
     }
223
   }
222
   }
224
 
223
 
225
-  const del = async (row) => {
224
+  /*const del = async (row) => {
226
     const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
225
     const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
227
       confirmButtonText: T('Confirm'),
226
       confirmButtonText: T('Confirm'),
228
       cancelButtonText: T('Cancel'),
227
       cancelButtonText: T('Cancel'),
@@ -237,7 +236,7 @@
237
       ElMessage.success(T('OperationSuccess'))
236
       ElMessage.success(T('OperationSuccess'))
238
       getList()
237
       getList()
239
     }
238
     }
240
-  }
239
+  }*/
241
   onMounted(getList)
240
   onMounted(getList)
242
   onActivated(getList)
241
   onActivated(getList)
243
 
242
 
@@ -305,14 +304,14 @@
305
     platformList: ABPlatformList,
304
     platformList: ABPlatformList,
306
     formVisible: ABFormVisible,
305
     formVisible: ABFormVisible,
307
     formData: ABFormData,
306
     formData: ABFormData,
308
-    collectionListRes,
309
-    getCollectionList,
307
+    collectionListResForUpdate,
308
+    getCollectionListForUpdate,
310
     tagListRes,
309
     tagListRes,
311
-    changeCollection,
310
+    changeCollectionForUpdate,
312
     submit: ABSubmit,
311
     submit: ABSubmit,
313
     fromPeer,
312
     fromPeer,
314
-  } = useABRepositories(1)
315
-  onMounted(getCollectionList)
313
+  } = useABRepositories('my')
314
+  onMounted(getCollectionListForUpdate)
316
   const toAddressBook = (peer) => {
315
   const toAddressBook = (peer) => {
317
     fromPeer(peer)
316
     fromPeer(peer)
318
     ABFormVisible.value = true
317
     ABFormVisible.value = true
@@ -322,7 +321,7 @@
322
   const handleSelectionChange = (val) => {
321
   const handleSelectionChange = (val) => {
323
     multipleSelection.value = val
322
     multipleSelection.value = val
324
   }
323
   }
325
-  const toBatchDelete = async () => {
324
+  /*const toBatchDelete = async () => {
326
     if (!multipleSelection.value.length) {
325
     if (!multipleSelection.value.length) {
327
       ElMessage.warning(T('PleaseSelectData'))
326
       ElMessage.warning(T('PleaseSelectData'))
328
       return false
327
       return false
@@ -341,7 +340,7 @@
341
       ElMessage.success(T('OperationSuccess'))
340
       ElMessage.success(T('OperationSuccess'))
342
       getList()
341
       getList()
343
     }
342
     }
344
-  }
343
+  }*/
345
 
344
 
346
   const batchABFormVisible = ref(false)
345
   const batchABFormVisible = ref(false)
347
   const toBatchAddToAB = () => {
346
   const toBatchAddToAB = () => {
@@ -352,6 +351,10 @@
352
     tags: [],
351
     tags: [],
353
     peer_ids: [],
352
     peer_ids: [],
354
   })
353
   })
354
+  const changeCollectionForBatchCreateAB = (val) => {
355
+    batchABFormData.value.tags = []
356
+    changeCollectionForUpdate(val)
357
+  }
355
   const submitBatchAddToAB = async () => {
358
   const submitBatchAddToAB = async () => {
356
     if (multipleSelection.value.length === 0) {
359
     if (multipleSelection.value.length === 0) {
357
       ElMessage.warning(T('PleaseSelectData'))
360
       ElMessage.warning(T('PleaseSelectData'))

+ 13 - 77
src/views/my/share_record/index.vue

@@ -16,7 +16,7 @@
16
         <el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
16
         <el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
17
         <el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
17
         <el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
18
           <template #default="{row}">
18
           <template #default="{row}">
19
-            <el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : '-' }}</el-tag>
19
+            <el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : T('Forever') }}</el-tag>
20
           </template>
20
           </template>
21
         </el-table-column>
21
         </el-table-column>
22
         <el-table-column :label="T('Actions')" align="center" width="400">
22
         <el-table-column :label="T('Actions')" align="center" width="400">
@@ -39,95 +39,31 @@
39
 </template>
39
 </template>
40
 
40
 
41
 <script setup>
41
 <script setup>
42
-  import { onActivated, onMounted, ref, watch, reactive } from 'vue'
42
+  import { onActivated, onMounted, watch } from 'vue'
43
   import { T } from '@/utils/i18n'
43
   import { T } from '@/utils/i18n'
44
-  import { share_record_remove as remove, share_record_list as list, share_record_batchDelete as batchDelete } from '@/api/my'
45
-  import { ElMessage, ElMessageBox } from 'element-plus'
44
+  import { useRepositories } from '@/views/share_record'
46
 
45
 
47
-  const listRes = reactive({
48
-    list: [], total: 0, loading: false,
49
-  })
50
-  const listQuery = reactive({
51
-    page: 1,
52
-    page_size: 10,
53
-  })
46
+  const {
47
+    listRes,
48
+    listQuery,
49
+    getList,
50
+    handlerQuery,
51
+    del,
52
+    multipleSelection,
53
+    toBatchDelete,
54
+    expired,
55
+  } = useRepositories('my')
54
 
56
 
55
-  const getList = async () => {
56
-    listRes.loading = true
57
-    const res = await list(listQuery).catch(_ => false)
58
-    listRes.loading = false
59
-    if (res) {
60
-      listRes.list = res.data.list
61
-      listRes.total = res.data.total
62
-    }
63
-  }
64
-  const handlerQuery = () => {
65
-    if (listQuery.page === 1) {
66
-      getList()
67
-    } else {
68
-      listQuery.page = 1
69
-    }
70
-  }
71
-
72
-  const del = async (row) => {
73
-    const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
74
-      confirmButtonText: T('Confirm'),
75
-      cancelButtonText: T('Cancel'),
76
-      type: 'warning',
77
-    }).catch(_ => false)
78
-    if (!cf) {
79
-      return false
80
-    }
81
-    const res = await remove({ id: row.id }).catch(_ => false)
82
-    if (res) {
83
-      ElMessage.success(T('OperationSuccess'))
84
-      getList()
85
-    }
86
-  }
87
   onMounted(getList)
57
   onMounted(getList)
88
   onActivated(getList)
58
   onActivated(getList)
89
 
59
 
90
   watch(() => listQuery.page, getList)
60
   watch(() => listQuery.page, getList)
91
 
61
 
92
   watch(() => listQuery.page_size, handlerQuery)
62
   watch(() => listQuery.page_size, handlerQuery)
93
-  const multipleSelection = ref([])
94
   const handleSelectionChange = (val) => {
63
   const handleSelectionChange = (val) => {
95
     multipleSelection.value = val
64
     multipleSelection.value = val
96
   }
65
   }
97
-  const toBatchDelete = () => {
98
-    if (multipleSelection.value.length === 0) {
99
-      return
100
-    }
101
-    batchdel(multipleSelection.value)
102
-  }
103
 
66
 
104
-  const batchdel = async (rows) => {
105
-    const ids = rows.map(r => r.id)
106
-    if (!ids.length) {
107
-      ElMessage.warning(T('PleaseSelectData'))
108
-      return false
109
-    }
110
-    const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
111
-      confirmButtonText: T('Confirm'),
112
-      cancelButtonText: T('Cancel'),
113
-      type: 'warning',
114
-    }).catch(_ => false)
115
-    if (!cf) {
116
-      return false
117
-    }
118
-
119
-    const res = await batchDelete({ ids }).catch(_ => false)
120
-    if (res) {
121
-      ElMessage.success(T('OperationSuccess'))
122
-      getList()
123
-    }
124
-  }
125
-
126
-  const expired = (row) => {
127
-    const now = new Date().getTime()
128
-    const created_at = new Date(row.created_at).getTime()
129
-    return row.expire * 1000 + created_at < now
130
-  }
131
 
67
 
132
 </script>
68
 </script>
133
 
69
 

+ 8 - 11
src/views/my/tag/index.vue

@@ -58,7 +58,7 @@
58
         <el-form-item :label="T('AddressBookName')">
58
         <el-form-item :label="T('AddressBookName')">
59
           <el-select v-model="formData.collection_id" clearable>
59
           <el-select v-model="formData.collection_id" clearable>
60
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
60
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
61
-            <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
61
+            <el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
62
           </el-select>
62
           </el-select>
63
         </el-form-item>
63
         </el-form-item>
64
         <el-form-item :label="T('Name')" prop="name" required>
64
         <el-form-item :label="T('Name')" prop="name" required>
@@ -86,7 +86,6 @@
86
   import { onMounted, watch, onActivated } from 'vue'
86
   import { onMounted, watch, onActivated } from 'vue'
87
   import { useRepositories } from '@/views/tag'
87
   import { useRepositories } from '@/views/tag'
88
   import { T } from '@/utils/i18n'
88
   import { T } from '@/utils/i18n'
89
-  import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
90
 
89
 
91
   const {
90
   const {
92
     listRes,
91
     listRes,
@@ -101,9 +100,13 @@
101
     submit,
100
     submit,
102
     activeChange,
101
     activeChange,
103
     currentColor,
102
     currentColor,
104
-  } = useRepositories()
105
 
103
 
106
-  listQuery.is_my = 1
104
+    collectionListRes,
105
+    getCollectionList,
106
+
107
+    collectionListResForUpdate,
108
+    getCollectionListForUpdate,
109
+  } = useRepositories('my')
107
 
110
 
108
   onMounted(getList)
111
   onMounted(getList)
109
   onActivated(getList)
112
   onActivated(getList)
@@ -112,14 +115,8 @@
112
 
115
 
113
   watch(() => listQuery.page_size, handlerQuery)
116
   watch(() => listQuery.page_size, handlerQuery)
114
 
117
 
115
-  const {
116
-    listRes: collectionListRes,
117
-    listQuery: collectionListQuery,
118
-    getList: getCollectionList,
119
-  } = useCollectionRepositories()
120
-  collectionListQuery.is_my = 1
121
-  collectionListQuery.page_size = 999
122
   onMounted(getCollectionList)
118
   onMounted(getCollectionList)
119
+  onMounted(getCollectionListForUpdate)
123
 
120
 
124
 </script>
121
 </script>
125
 
122
 

+ 20 - 15
src/views/peer/index.vue

@@ -163,7 +163,7 @@
163
     <el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
163
     <el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
164
       <el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
164
       <el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
165
         <el-form-item :label="T('Owner')" prop="user_id" required>
165
         <el-form-item :label="T('Owner')" prop="user_id" required>
166
-          <el-select v-model="batchABFormData.user_id" @change="changeUser">
166
+          <el-select v-model="batchABFormData.user_id" @change="changeUserForBatchCreateAB">
167
             <el-option
167
             <el-option
168
                 v-for="item in allUsers"
168
                 v-for="item in allUsers"
169
                 :key="item.id"
169
                 :key="item.id"
@@ -173,9 +173,9 @@
173
           </el-select>
173
           </el-select>
174
         </el-form-item>
174
         </el-form-item>
175
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
175
         <el-form-item :label="T('AddressBookName')" required prop="collection_id">
176
-          <el-select v-model="batchABFormData.collection_id" clearable @change="changeCollection">
176
+          <el-select v-model="batchABFormData.collection_id" clearable>
177
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
177
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
178
-            <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
178
+            <el-option v-for="c in collectionListResForBatchCreateAB.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
179
           </el-select>
179
           </el-select>
180
         </el-form-item>
180
         </el-form-item>
181
         <!--        <el-form-item :label="T('Tags')" prop="tags">
181
         <!--        <el-form-item :label="T('Tags')" prop="tags">
@@ -214,6 +214,7 @@
214
   import { CopyDocument } from '@element-plus/icons'
214
   import { CopyDocument } from '@element-plus/icons'
215
   import { handleClipboard } from '@/utils/clipboard'
215
   import { handleClipboard } from '@/utils/clipboard'
216
   import { batchCreateFromPeers } from '@/api/address_book'
216
   import { batchCreateFromPeers } from '@/api/address_book'
217
+  import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
217
 
218
 
218
   const appStore = useAppStore()
219
   const appStore = useAppStore()
219
   const listRes = reactive({
220
   const listRes = reactive({
@@ -345,16 +346,15 @@
345
     }
346
     }
346
   }
347
   }
347
 
348
 
349
+  //添加到地址簿 start
350
+  const { allUsers, getAllUsers } = loadAllUsers()
351
+  onMounted(getAllUsers)
348
   const {
352
   const {
349
     platformList: ABPlatformList,
353
     platformList: ABPlatformList,
350
     formVisible: ABFormVisible,
354
     formVisible: ABFormVisible,
351
     formData: ABFormData,
355
     formData: ABFormData,
352
     fromPeer,
356
     fromPeer,
353
-    changeCollection,
354
-    collectionListRes,
355
-    collectionListQuery,
356
-    getCollectionList,
357
-  } = useABRepositories()
357
+  } = useABRepositories('admin')
358
   const toAddressBook = (peer) => {
358
   const toAddressBook = (peer) => {
359
     fromPeer(peer)
359
     fromPeer(peer)
360
     ABFormVisible.value = true
360
     ABFormVisible.value = true
@@ -366,8 +366,6 @@
366
       ABFormVisible.value = false
366
       ABFormVisible.value = false
367
     }
367
     }
368
   }
368
   }
369
-
370
-  const { allUsers, getAllUsers } = loadAllUsers()
371
   const tagList = ref([])
369
   const tagList = ref([])
372
   const fetchTagListData = async (user_id) => {
370
   const fetchTagListData = async (user_id) => {
373
     const res = await fetchTagList({ user_id }).catch(_ => false)
371
     const res = await fetchTagList({ user_id }).catch(_ => false)
@@ -381,8 +379,8 @@
381
       tagList.value = ls.map(item => ({ name: item }))
379
       tagList.value = ls.map(item => ({ name: item }))
382
     }
380
     }
383
   }
381
   }
384
-  onMounted(getAllUsers)
385
   onMounted(fetchTagListData)
382
   onMounted(fetchTagListData)
383
+  // 添加到地址簿 end
386
 
384
 
387
   const multipleSelection = ref([])
385
   const multipleSelection = ref([])
388
   const handleSelectionChange = (val) => {
386
   const handleSelectionChange = (val) => {
@@ -409,11 +407,17 @@
409
     }
407
     }
410
   }
408
   }
411
 
409
 
412
-  // 批量添加到地址簿
413
-  const changeUser = (val) => {
414
-    collectionListQuery.user_id = val
410
+  // 批量添加到地址簿 start
411
+  const {
412
+    listRes: collectionListResForBatchCreateAB,
413
+    listQuery: collectionListQueryForBatchCreateAB,
414
+    getList: getCollectionListForBatchCreateAB,
415
+  } = useCollectionRepositories('admin')
416
+  collectionListQueryForBatchCreateAB.page_size = 9999
417
+  const changeUserForBatchCreateAB = (val) => {
415
     batchABFormData.value.collection_id = 0
418
     batchABFormData.value.collection_id = 0
416
-    getCollectionList()
419
+    collectionListQueryForBatchCreateAB.user_id = val
420
+    getCollectionListForBatchCreateAB()
417
   }
421
   }
418
   const batchABFormVisible = ref(false)
422
   const batchABFormVisible = ref(false)
419
   const toBatchAddToAB = () => {
423
   const toBatchAddToAB = () => {
@@ -442,6 +446,7 @@
442
       batchABFormVisible.value = false
446
       batchABFormVisible.value = false
443
     }
447
     }
444
   }
448
   }
449
+  // 批量添加到地址簿 end
445
 
450
 
446
 </script>
451
 </script>
447
 
452
 

+ 100 - 0
src/views/share_record/index.js

@@ -0,0 +1,100 @@
1
+import { reactive, ref } from 'vue'
2
+import { batchDelete as admin_batchDelete, list as admin_list, remove as admin_remove } from '@/api/share_record'
3
+import { batchDelete as my_batchDelete, list as my_list, remove as my_remove } from '@/api/my/share_record'
4
+import { ElMessage, ElMessageBox } from 'element-plus'
5
+import { T } from '@/utils/i18n'
6
+
7
+const apis = {
8
+  admin: { batchDelete: admin_batchDelete, list: admin_list, remove: admin_remove },
9
+  my: { batchDelete: my_batchDelete, list: my_list, remove: my_remove },
10
+}
11
+
12
+export function useRepositories (api_type = 'my') {
13
+  const listRes = reactive({
14
+    list: [], total: 0, loading: false,
15
+  })
16
+  const listQuery = reactive({
17
+    page: 1,
18
+    page_size: 10,
19
+  })
20
+
21
+  const getList = async () => {
22
+    listRes.loading = true
23
+    const res = await apis[api_type].list(listQuery).catch(_ => false)
24
+    listRes.loading = false
25
+    if (res) {
26
+      listRes.list = res.data.list
27
+      listRes.total = res.data.total
28
+    }
29
+  }
30
+  const handlerQuery = () => {
31
+    if (listQuery.page === 1) {
32
+      getList()
33
+    } else {
34
+      listQuery.page = 1
35
+    }
36
+  }
37
+
38
+  const del = async (row) => {
39
+    const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
40
+      confirmButtonText: T('Confirm'),
41
+      cancelButtonText: T('Cancel'),
42
+      type: 'warning',
43
+    }).catch(_ => false)
44
+    if (!cf) {
45
+      return false
46
+    }
47
+    const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
48
+    if (res) {
49
+      ElMessage.success(T('OperationSuccess'))
50
+      getList()
51
+    }
52
+  }
53
+
54
+  const multipleSelection = ref([])
55
+  const toBatchDelete = async () => {
56
+    if (multipleSelection.value.length === 0) {
57
+      return
58
+    }
59
+
60
+    const ids = multipleSelection.value.map(r => r.id)
61
+    if (!ids.length) {
62
+      ElMessage.warning(T('PleaseSelectData'))
63
+      return false
64
+    }
65
+    const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
66
+      confirmButtonText: T('Confirm'),
67
+      cancelButtonText: T('Cancel'),
68
+      type: 'warning',
69
+    }).catch(_ => false)
70
+    if (!cf) {
71
+      return false
72
+    }
73
+
74
+    const res = await apis[api_type].batchDelete({ ids }).catch(_ => false)
75
+    if (res) {
76
+      ElMessage.success(T('OperationSuccess'))
77
+      getList()
78
+    }
79
+  }
80
+
81
+  const expired = (row) => {
82
+    if (row.expire === 0) {
83
+      return false
84
+    }
85
+    const now = new Date().getTime()
86
+    const created_at = new Date(row.created_at).getTime()
87
+    return row.expire * 1000 + created_at < now
88
+  }
89
+
90
+  return {
91
+    listRes,
92
+    listQuery,
93
+    getList,
94
+    handlerQuery,
95
+    del,
96
+    multipleSelection,
97
+    toBatchDelete,
98
+    expired,
99
+  }
100
+}

+ 12 - 75
src/views/share_record/index.vue

@@ -31,7 +31,7 @@
31
         <el-table-column prop="created_at" :label="T('CreatedAt')" 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">
32
         <el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
33
           <template #default="{row}">
33
           <template #default="{row}">
34
-            <el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : '-' }}</el-tag>
34
+            <el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : T('Forever') }}</el-tag>
35
           </template>
35
           </template>
36
         </el-table-column>
36
         </el-table-column>
37
         <el-table-column :label="T('Actions')" align="center" width="400">
37
         <el-table-column :label="T('Actions')" align="center" width="400">
@@ -59,95 +59,32 @@
59
   import { T } from '@/utils/i18n'
59
   import { T } from '@/utils/i18n'
60
   import { remove, list, batchDelete } from '@/api/share_record'
60
   import { remove, list, batchDelete } from '@/api/share_record'
61
   import { ElMessage, ElMessageBox } from 'element-plus'
61
   import { ElMessage, ElMessageBox } from 'element-plus'
62
+  import { useRepositories } from '@/views/share_record/index'
62
 
63
 
63
   const { allUsers, getAllUsers } = loadAllUsers()
64
   const { allUsers, getAllUsers } = loadAllUsers()
64
   getAllUsers()
65
   getAllUsers()
65
 
66
 
66
-  const listRes = reactive({
67
-    list: [], total: 0, loading: false,
68
-  })
69
-  const listQuery = reactive({
70
-    page: 1,
71
-    page_size: 10,
72
-    is_my: 0,
73
-    user_id: null,
74
-  })
67
+  const {
68
+    listRes,
69
+    listQuery,
70
+    getList,
71
+    handlerQuery,
72
+    del,
73
+    multipleSelection,
74
+    toBatchDelete,
75
+    expired,
76
+  } = useRepositories('admin')
75
 
77
 
76
-  const getList = async () => {
77
-    listRes.loading = true
78
-    const res = await list(listQuery).catch(_ => false)
79
-    listRes.loading = false
80
-    if (res) {
81
-      listRes.list = res.data.list
82
-      listRes.total = res.data.total
83
-    }
84
-  }
85
-  const handlerQuery = () => {
86
-    if (listQuery.page === 1) {
87
-      getList()
88
-    } else {
89
-      listQuery.page = 1
90
-    }
91
-  }
92
-  const expired = (row) => {
93
-    const now = new Date().getTime()
94
-    const created_at = new Date(row.created_at).getTime()
95
-    return row.expire * 1000 + created_at  < now
96
-  }
97
-
98
-  const del = async (row) => {
99
-    const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
100
-      confirmButtonText: T('Confirm'),
101
-      cancelButtonText: T('Cancel'),
102
-      type: 'warning',
103
-    }).catch(_ => false)
104
-    if (!cf) {
105
-      return false
106
-    }
107
-    const res = await remove({ id: row.id }).catch(_ => false)
108
-    if (res) {
109
-      ElMessage.success(T('OperationSuccess'))
110
-      getList()
111
-    }
112
-  }
113
   onMounted(getList)
78
   onMounted(getList)
114
   onActivated(getList)
79
   onActivated(getList)
115
 
80
 
116
   watch(() => listQuery.page, getList)
81
   watch(() => listQuery.page, getList)
117
 
82
 
118
   watch(() => listQuery.page_size, handlerQuery)
83
   watch(() => listQuery.page_size, handlerQuery)
119
-  const multipleSelection = ref([])
120
   const handleSelectionChange = (val) => {
84
   const handleSelectionChange = (val) => {
121
     multipleSelection.value = val
85
     multipleSelection.value = val
122
   }
86
   }
123
-  const toBatchDelete = () => {
124
-    if (multipleSelection.value.length === 0) {
125
-      return
126
-    }
127
-    batchdel(multipleSelection.value)
128
-  }
129
 
87
 
130
-  const batchdel = async (rows) => {
131
-    const ids = rows.map(r => r.id)
132
-    if (!ids.length) {
133
-      ElMessage.warning(T('PleaseSelectData'))
134
-      return false
135
-    }
136
-    const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
137
-      confirmButtonText: T('Confirm'),
138
-      cancelButtonText: T('Cancel'),
139
-      type: 'warning',
140
-    }).catch(_ => false)
141
-    if (!cf) {
142
-      return false
143
-    }
144
-
145
-    const res = await batchDelete({ ids }).catch(_ => false)
146
-    if (res) {
147
-      ElMessage.success(T('OperationSuccess'))
148
-      getList()
149
-    }
150
-  }
151
 
88
 
152
 </script>
89
 </script>
153
 
90
 

+ 40 - 25
src/views/tag/index.js

@@ -1,20 +1,18 @@
1
 import { reactive, ref } from 'vue'
1
 import { reactive, ref } from 'vue'
2
-import { create, list, remove, update } from '@/api/tag'
2
+import { create as admin_create, list as admin_list, remove as admin_remove, update as admin_update } from '@/api/tag'
3
+import { create as my_create, list as my_list, remove as my_remove, update as my_update } from '@/api/my/tag'
3
 import { ElMessage, ElMessageBox } from 'element-plus'
4
 import { ElMessage, ElMessageBox } from 'element-plus'
4
 import { useRoute } from 'vue-router'
5
 import { useRoute } from 'vue-router'
5
 import { T } from '@/utils/i18n'
6
 import { T } from '@/utils/i18n'
6
-import { loadAllUsers } from '@/global'
7
 import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
7
 import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
8
 
8
 
9
-export function useRepositories (is_my = 0) {
10
-  const { allUsers, getAllUsers } = loadAllUsers()
9
+const apis = {
10
+  admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
11
+  my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
12
+}
13
+
14
+export function useRepositories (api_type = 'my') {
11
 
15
 
12
-  const {
13
-    listRes: collectionListRes,
14
-    listQuery: collectionListQuery,
15
-    getList: getCollectionList,
16
-  } = useCollectionRepositories(is_my)
17
-  collectionListQuery.page_size = 9999
18
   //获取query
16
   //获取query
19
   const route = useRoute()
17
   const route = useRoute()
20
   const user_id = route.query?.user_id
18
   const user_id = route.query?.user_id
@@ -24,7 +22,6 @@ export function useRepositories (is_my = 0) {
24
   const listQuery = reactive({
22
   const listQuery = reactive({
25
     page: 1,
23
     page: 1,
26
     page_size: 10,
24
     page_size: 10,
27
-    is_my,
28
     user_id: user_id ? parseInt(user_id) : null,
25
     user_id: user_id ? parseInt(user_id) : null,
29
     collection_id: null,
26
     collection_id: null,
30
   })
27
   })
@@ -72,7 +69,7 @@ export function useRepositories (is_my = 0) {
72
 
69
 
73
   const getList = async () => {
70
   const getList = async () => {
74
     listRes.loading = true
71
     listRes.loading = true
75
-    const res = await list(listQuery).catch(_ => false)
72
+    const res = await apis[api_type].list(listQuery).catch(_ => false)
76
     listRes.loading = false
73
     listRes.loading = false
77
     if (res) {
74
     if (res) {
78
       listRes.list = res.data.list.map(item => {
75
       listRes.list = res.data.list.map(item => {
@@ -100,7 +97,7 @@ export function useRepositories (is_my = 0) {
100
       return false
97
       return false
101
     }
98
     }
102
 
99
 
103
-    const res = await remove({ id: row.id }).catch(_ => false)
100
+    const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
104
     if (res) {
101
     if (res) {
105
       ElMessage.success(T('OperationSuccess'))
102
       ElMessage.success(T('OperationSuccess'))
106
       getList()
103
       getList()
@@ -112,12 +109,11 @@ export function useRepositories (is_my = 0) {
112
     id: 0,
109
     id: 0,
113
     name: '',
110
     name: '',
114
     color: 0,
111
     color: 0,
115
-    user_id: 0,
116
-    collection_id: 0,
112
+    user_id: null,
113
+    collection_id: null,
117
   })
114
   })
118
   const currentColor = ref('')
115
   const currentColor = ref('')
119
   const activeChange = (c) => {
116
   const activeChange = (c) => {
120
-    console.log(c)
121
     currentColor.value = c
117
     currentColor.value = c
122
   }
118
   }
123
   const toEdit = (row) => {
119
   const toEdit = (row) => {
@@ -137,7 +133,7 @@ export function useRepositories (is_my = 0) {
137
     formData.name = ''
133
     formData.name = ''
138
     formData.color = ''
134
     formData.color = ''
139
     formData.user_id = null
135
     formData.user_id = null
140
-    formData.collection_id = 0
136
+    formData.collection_id = null
141
   }
137
   }
142
   const submit = async () => {
138
   const submit = async () => {
143
     console.log(formData)
139
     console.log(formData)
@@ -145,7 +141,7 @@ export function useRepositories (is_my = 0) {
145
       ElMessage.error('请选择颜色')
141
       ElMessage.error('请选择颜色')
146
       return
142
       return
147
     }
143
     }
148
-    const api = formData.id ? update : create
144
+    const api = formData.id ? apis[api_type].update : apis[api_type].create
149
     const data = {
145
     const data = {
150
       ...formData,
146
       ...formData,
151
       color: rgba2flutterColor(formData.color),
147
       color: rgba2flutterColor(formData.color),
@@ -159,8 +155,15 @@ export function useRepositories (is_my = 0) {
159
     }
155
     }
160
   }
156
   }
161
 
157
 
162
-  const changeQueryUser = async (val) => {
163
-    listQuery.collection_id = null
158
+  //query form collection
159
+  const {
160
+    listRes: collectionListRes,
161
+    listQuery: collectionListQuery,
162
+    getList: getCollectionList,
163
+  } = useCollectionRepositories(api_type)
164
+  collectionListQuery.page_size = 9999
165
+  const changeUser = async (val) => {
166
+    formData.collection_id = 0
164
     if (!val) {
167
     if (!val) {
165
       collectionListRes.list = []
168
       collectionListRes.list = []
166
     } else {
169
     } else {
@@ -168,13 +171,21 @@ export function useRepositories (is_my = 0) {
168
       getCollectionList()
171
       getCollectionList()
169
     }
172
     }
170
   }
173
   }
171
-  const changeUser = async (val) => {
172
-    formData.collection_id = 0
174
+
175
+  const {
176
+    listRes: collectionListResForUpdate,
177
+    listQuery: collectionListQueryForUpdate,
178
+    getList: getCollectionListForUpdate,
179
+  } = useCollectionRepositories(api_type)
180
+  collectionListQueryForUpdate.page_size = 9999
181
+  //create or update form collection
182
+  const changeUserForUpdate = async (val) => {
183
+    listQuery.collection_id = null
173
     if (!val) {
184
     if (!val) {
174
       collectionListRes.list = []
185
       collectionListRes.list = []
175
     } else {
186
     } else {
176
       collectionListQuery.user_id = val
187
       collectionListQuery.user_id = val
177
-      getCollectionList()
188
+      getCollectionListForUpdate()
178
     }
189
     }
179
   }
190
   }
180
   return {
191
   return {
@@ -192,8 +203,12 @@ export function useRepositories (is_my = 0) {
192
     currentColor,
203
     currentColor,
193
 
204
 
194
     collectionListRes,
205
     collectionListRes,
195
-    allUsers, getAllUsers,
196
-    changeQueryUser,
197
     changeUser,
206
     changeUser,
207
+    getCollectionList,
208
+
209
+    collectionListResForUpdate,
210
+    changeUserForUpdate,
211
+    getCollectionListForUpdate,
212
+
198
   }
213
   }
199
 }
214
 }

+ 14 - 7
src/views/tag/index.vue

@@ -3,7 +3,7 @@
3
     <el-card class="list-query" shadow="hover">
3
     <el-card class="list-query" shadow="hover">
4
       <el-form inline label-width="120px">
4
       <el-form inline label-width="120px">
5
         <el-form-item :label="T('Owner')">
5
         <el-form-item :label="T('Owner')">
6
-          <el-select v-model="listQuery.user_id" clearable @change="changeQueryUser">
6
+          <el-select v-model="listQuery.user_id" clearable @change="changeUser">
7
             <el-option
7
             <el-option
8
                 v-for="item in allUsers"
8
                 v-for="item in allUsers"
9
                 :key="item.id"
9
                 :key="item.id"
@@ -71,7 +71,7 @@
71
     <el-dialog v-model="formVisible" :title="!formData.id?T('Create'):T('Update')" width="800">
71
     <el-dialog v-model="formVisible" :title="!formData.id?T('Create'):T('Update')" width="800">
72
       <el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
72
       <el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
73
         <el-form-item :label="T('Owner')" prop="user_id" required>
73
         <el-form-item :label="T('Owner')" prop="user_id" required>
74
-          <el-select v-model="formData.user_id" @change="changeUser">
74
+          <el-select v-model="formData.user_id" @change="changeUserForUpdate">
75
             <el-option
75
             <el-option
76
                 v-for="item in allUsers"
76
                 v-for="item in allUsers"
77
                 :key="item.id"
77
                 :key="item.id"
@@ -83,7 +83,7 @@
83
         <el-form-item :label="T('AddressBookName')" prop="collection_id" required>
83
         <el-form-item :label="T('AddressBookName')" prop="collection_id" required>
84
           <el-select v-model="formData.collection_id" clearable>
84
           <el-select v-model="formData.collection_id" clearable>
85
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
85
             <el-option :value="0" :label="T('MyAddressBook')"></el-option>
86
-            <el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
86
+            <el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
87
           </el-select>
87
           </el-select>
88
         </el-form-item>
88
         </el-form-item>
89
         <el-form-item :label="T('Name')" prop="name" required>
89
         <el-form-item :label="T('Name')" prop="name" required>
@@ -111,7 +111,10 @@
111
   import { onMounted, reactive, watch, ref, onActivated } from 'vue'
111
   import { onMounted, reactive, watch, ref, onActivated } from 'vue'
112
   import { useRepositories } from '@/views/tag/index'
112
   import { useRepositories } from '@/views/tag/index'
113
   import { T } from '@/utils/i18n'
113
   import { T } from '@/utils/i18n'
114
+  import { loadAllUsers } from '@/global'
114
 
115
 
116
+  const { allUsers, getAllUsers } = loadAllUsers()
117
+  onMounted(getAllUsers)
115
   const {
118
   const {
116
     listRes,
119
     listRes,
117
     listQuery,
120
     listQuery,
@@ -125,12 +128,16 @@
125
     submit,
128
     submit,
126
     activeChange,
129
     activeChange,
127
     currentColor,
130
     currentColor,
131
+
128
     collectionListRes,
132
     collectionListRes,
129
-    allUsers, getAllUsers,
130
-    changeQueryUser,
131
     changeUser,
133
     changeUser,
132
-  } = useRepositories()
133
-  onMounted(getAllUsers)
134
+    // getCollectionList,
135
+
136
+    collectionListResForUpdate,
137
+    changeUserForUpdate,
138
+    // getCollectionListForUpdate,
139
+  } = useRepositories('admin')
140
+
134
   onMounted(getList)
141
   onMounted(getList)
135
   onActivated(getList)
142
   onActivated(getList)
136
 
143