Split my and admin
This commit is contained in:
@@ -61,10 +61,3 @@ export function batchCreateFromPeers (data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function batchUpdateTags (data) {
|
|
||||||
return request({
|
|
||||||
url: '/address_book/batchUpdateTags',
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import request from '@/utils/request'
|
|
||||||
|
|
||||||
export function share_record_list (params) {
|
|
||||||
return request({
|
|
||||||
url: '/my/share_record/list',
|
|
||||||
params,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function share_record_remove (data) {
|
|
||||||
return request({
|
|
||||||
url: '/my/share_record/delete',
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function share_record_batchDelete (data) {
|
|
||||||
return request({
|
|
||||||
url: '/my/share_record/batchDelete',
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function peer_list (params) {
|
|
||||||
return request({
|
|
||||||
url: '/my/peer/list',
|
|
||||||
params,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function address_book_batchCreateFromPeers (data) {
|
|
||||||
return request({
|
|
||||||
url: '/my/address_book/batchCreateFromPeers',
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function list (params) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book/list',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function batchCreateFromPeers (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book/batchCreateFromPeers',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function batchUpdateTags (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book/batchUpdateTags',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book/create',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function update (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book/update',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book/delete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function list (params) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection/list',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection/create',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function update (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection/update',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection/delete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function list (params) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection_rule/list',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection_rule/create',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function update (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection_rule/update',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection_rule/delete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function batchCreate (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/address_book_collection_rule/batchCreate',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function list (params) {
|
||||||
|
return request({
|
||||||
|
url: '/my/peer/list',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function list (params) {
|
||||||
|
return request({
|
||||||
|
url: '/my/share_record/list',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/share_record/delete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function batchDelete (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/share_record/batchDelete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function list (params) {
|
||||||
|
return request({
|
||||||
|
url: '/my/tag/list',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/tag/create',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function update (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/tag/update',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/tag/delete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
default: '',
|
||||||
values: ['windows', 'android', 'mac', 'linux'],
|
values: ['windows', 'android', 'mac', 'linux'],
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
|
|||||||
@@ -1,23 +1,28 @@
|
|||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import { create, list, remove, update } from '@/api/address_book_collection'
|
import { list as admin_list, create as admin_create, update as admin_update, remove as admin_remove } from '@/api/address_book_collection'
|
||||||
|
import { list as my_list, create as my_create, update as my_update, remove as my_remove } from '@/api/my/address_book_collection'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
|
|
||||||
export function useRepositories (is_my) {
|
const apis = {
|
||||||
|
admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
|
||||||
|
my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRepositories (api_type = 'my') {
|
||||||
const listRes = reactive({
|
const listRes = reactive({
|
||||||
list: [], total: 0, loading: false,
|
list: [], total: 0, loading: false,
|
||||||
})
|
})
|
||||||
const listQuery = reactive({
|
const listQuery = reactive({
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 10,
|
page_size: 10,
|
||||||
is_my,
|
|
||||||
name: null,
|
name: null,
|
||||||
user_id: null,
|
user_id: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
listRes.loading = true
|
listRes.loading = true
|
||||||
const res = await list(listQuery).catch(_ => false)
|
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||||
listRes.loading = false
|
listRes.loading = false
|
||||||
if (res) {
|
if (res) {
|
||||||
listRes.list = res.data.list
|
listRes.list = res.data.list
|
||||||
@@ -42,7 +47,7 @@ export function useRepositories (is_my) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await remove({ id: row.id }).catch(_ => false)
|
const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
@@ -72,7 +77,7 @@ export function useRepositories (is_my) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
const api = formData.id ? update : create
|
const api = formData.id ? apis[api_type].update : apis[api_type].create
|
||||||
const res = await api(formData).catch(_ => false)
|
const res = await api(formData).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
toEdit,
|
toEdit,
|
||||||
toAdd,
|
toAdd,
|
||||||
submit,
|
submit,
|
||||||
} = useRepositories()
|
} = useRepositories('admin')
|
||||||
|
|
||||||
listQuery.is_my = 0
|
listQuery.is_my = 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,24 @@
|
|||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import { batchUpdateTags, create, list, remove, update } from '@/api/address_book'
|
import { create as admin_create, list as admin_list, remove as admin_remove, update as admin_update } from '@/api/address_book'
|
||||||
|
import { batchUpdateTags, list as my_list, create as my_create, update as my_update, remove as my_remove } from '@/api/my/address_book'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
||||||
import { useRepositories as useTagRepositories } from '@/views/tag/index'
|
import { useRepositories as useTagRepositories } from '@/views/tag/index'
|
||||||
import { loadAllUsers } from '@/global'
|
|
||||||
import { simpleData } from '@/api/peer'
|
import { simpleData } from '@/api/peer'
|
||||||
|
|
||||||
export function useRepositories (is_my = 0) {
|
const apis = {
|
||||||
|
admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
|
||||||
const { allUsers, getAllUsers } = loadAllUsers()
|
my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRepositories (api_type = 'my') {
|
||||||
const {
|
const {
|
||||||
listRes: collectionListRes,
|
listRes: collectionListRes,
|
||||||
listQuery: collectionListQuery,
|
listQuery: collectionListQuery,
|
||||||
getList: getCollectionList,
|
getList: getCollectionList,
|
||||||
} = useCollectionRepositories(is_my)
|
} = useCollectionRepositories(api_type)
|
||||||
collectionListQuery.page_size = 9999
|
collectionListQuery.page_size = 9999
|
||||||
const {
|
|
||||||
listRes: tagListRes,
|
|
||||||
listQuery: tagListQuery,
|
|
||||||
getList: getTagList,
|
|
||||||
} = useTagRepositories(is_my)
|
|
||||||
tagListQuery.page_size = 9999
|
|
||||||
|
|
||||||
const listRes = reactive({
|
const listRes = reactive({
|
||||||
list: [], total: 0, loading: false,
|
list: [], total: 0, loading: false,
|
||||||
@@ -30,7 +26,6 @@ export function useRepositories (is_my = 0) {
|
|||||||
const listQuery = reactive({
|
const listQuery = reactive({
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 10,
|
page_size: 10,
|
||||||
is_my,
|
|
||||||
id: null,
|
id: null,
|
||||||
user_id: null,
|
user_id: null,
|
||||||
username: null,
|
username: null,
|
||||||
@@ -40,7 +35,7 @@ export function useRepositories (is_my = 0) {
|
|||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
listRes.loading = true
|
listRes.loading = true
|
||||||
const res = await list(listQuery).catch(_ => false)
|
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||||
listRes.loading = false
|
listRes.loading = false
|
||||||
if (res) {
|
if (res) {
|
||||||
const ids = res.data.list.map(item => item.id)
|
const ids = res.data.list.map(item => item.id)
|
||||||
@@ -78,13 +73,14 @@ export function useRepositories (is_my = 0) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await remove({ row_id: row.row_id }).catch(_ => false)
|
const res = await apis[api_type].remove({ row_id: row.row_id }).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//创建或者修改
|
||||||
const platformList = [
|
const platformList = [
|
||||||
{ label: 'Windows', value: 'Windows', icon: 'windows' },
|
{ label: 'Windows', value: 'Windows', icon: 'windows' },
|
||||||
{ label: 'Linux', value: 'Linux', icon: 'linux' },
|
{ label: 'Linux', value: 'Linux', icon: 'linux' },
|
||||||
@@ -112,6 +108,18 @@ export function useRepositories (is_my = 0) {
|
|||||||
'username': '',
|
'username': '',
|
||||||
collection_id: null,
|
collection_id: null,
|
||||||
})
|
})
|
||||||
|
const {
|
||||||
|
listRes: collectionListResForUpdate,
|
||||||
|
listQuery: collectionListQueryForUpdate,
|
||||||
|
getList: getCollectionListForUpdate,
|
||||||
|
} = useCollectionRepositories(api_type)
|
||||||
|
collectionListQueryForUpdate.page_size = 9999
|
||||||
|
const {
|
||||||
|
listRes: tagListRes,
|
||||||
|
listQuery: tagListQuery,
|
||||||
|
getList: getTagList,
|
||||||
|
} = useTagRepositories(api_type)
|
||||||
|
tagListQuery.page_size = 9999
|
||||||
|
|
||||||
const toEdit = (row) => {
|
const toEdit = (row) => {
|
||||||
formVisible.value = true
|
formVisible.value = true
|
||||||
@@ -119,9 +127,9 @@ export function useRepositories (is_my = 0) {
|
|||||||
Object.keys(formData).forEach(key => {
|
Object.keys(formData).forEach(key => {
|
||||||
formData[key] = row[key]
|
formData[key] = row[key]
|
||||||
})
|
})
|
||||||
collectionListQuery.user_id = row.user_id
|
collectionListQueryForUpdate.user_id = row.user_id
|
||||||
getCollectionList()
|
|
||||||
tagListQuery.collection_id = row.collection_id
|
tagListQuery.collection_id = row.collection_id
|
||||||
|
getCollectionListForUpdate()
|
||||||
getTagList()
|
getTagList()
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -147,7 +155,7 @@ export function useRepositories (is_my = 0) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
const api = formData.row_id ? update : create
|
const api = formData.row_id ? apis[api_type].update : apis[api_type].create
|
||||||
const res = await api(formData).catch(_ => false)
|
const res = await api(formData).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
@@ -155,16 +163,6 @@ export function useRepositories (is_my = 0) {
|
|||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const shareToWebClientVisible = ref(false)
|
|
||||||
const shareToWebClientForm = reactive({
|
|
||||||
id: '',
|
|
||||||
hash: '',
|
|
||||||
})
|
|
||||||
const toShowShare = (row) => {
|
|
||||||
shareToWebClientForm.id = row.id
|
|
||||||
shareToWebClientForm.hash = row.hash
|
|
||||||
shareToWebClientVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const changeQueryUser = async (val) => {
|
const changeQueryUser = async (val) => {
|
||||||
tagListRes.list = []
|
tagListRes.list = []
|
||||||
@@ -176,18 +174,18 @@ export function useRepositories (is_my = 0) {
|
|||||||
getCollectionList()
|
getCollectionList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const changeUser = async (val) => {
|
const changeUserForUpdate = async (val) => {
|
||||||
tagListRes.list = []
|
tagListRes.list = []
|
||||||
formData.tags = []
|
formData.tags = []
|
||||||
formData.collection_id = 0
|
formData.collection_id = 0
|
||||||
if (!val) {
|
if (!val) {
|
||||||
collectionListRes.list = []
|
collectionListResForUpdate.list = []
|
||||||
} else {
|
} else {
|
||||||
collectionListQuery.user_id = val
|
collectionListQueryForUpdate.user_id = val
|
||||||
getCollectionList()
|
getCollectionListForUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const changeCollection = async (val) => {
|
const changeCollectionForUpdate = async (val) => {
|
||||||
tagListRes.list = []
|
tagListRes.list = []
|
||||||
formData.tags = []
|
formData.tags = []
|
||||||
tagListQuery.user_id = formData.user_id
|
tagListQuery.user_id = formData.user_id
|
||||||
@@ -217,42 +215,38 @@ export function useRepositories (is_my = 0) {
|
|||||||
listQuery,
|
listQuery,
|
||||||
getList,
|
getList,
|
||||||
handlerQuery,
|
handlerQuery,
|
||||||
del,
|
collectionListQuery,
|
||||||
|
getCollectionList,
|
||||||
|
collectionListRes,
|
||||||
|
changeQueryUser,
|
||||||
|
|
||||||
platformList,
|
platformList,
|
||||||
|
|
||||||
|
del,
|
||||||
|
|
||||||
formVisible,
|
formVisible,
|
||||||
formData,
|
formData,
|
||||||
toEdit,
|
toEdit,
|
||||||
toAdd,
|
toAdd,
|
||||||
submit,
|
submit,
|
||||||
shareToWebClientVisible,
|
getCollectionListForUpdate,
|
||||||
shareToWebClientForm,
|
collectionListResForUpdate,
|
||||||
toShowShare,
|
changeUserForUpdate,
|
||||||
|
changeCollectionForUpdate,
|
||||||
collectionListQuery,
|
|
||||||
getCollectionList,
|
|
||||||
collectionListRes,
|
|
||||||
|
|
||||||
tagListQuery,
|
tagListQuery,
|
||||||
getTagList,
|
getTagList,
|
||||||
tagListRes,
|
tagListRes,
|
||||||
|
|
||||||
allUsers,
|
|
||||||
getAllUsers,
|
|
||||||
|
|
||||||
changeQueryUser,
|
|
||||||
changeUser,
|
|
||||||
changeCollection,
|
|
||||||
|
|
||||||
fromPeer,
|
fromPeer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useBatchUpdateTagsRepositories (is_my = 0) {
|
export function useBatchUpdateTagsRepositories () {
|
||||||
const {
|
const {
|
||||||
listRes: tagListRes,
|
listRes: tagListRes,
|
||||||
listQuery: tagListQuery,
|
listQuery: tagListQuery,
|
||||||
getList: getTagList,
|
getList: getTagList,
|
||||||
} = useTagRepositories(is_my)
|
} = useTagRepositories('my')
|
||||||
tagListQuery.page_size = 9999
|
tagListQuery.page_size = 9999
|
||||||
|
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
<el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
|
<el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
|
||||||
<el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
|
<el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
|
||||||
<el-form-item :label="T('Owner')" prop="user_id" required>
|
<el-form-item :label="T('Owner')" prop="user_id" required>
|
||||||
<el-select v-model="formData.user_id" @change="changeUser">
|
<el-select v-model="formData.user_id" @change="changeUserForUpdate">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in allUsers"
|
v-for="item in allUsers"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -99,9 +99,9 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="T('AddressBookName')">
|
<el-form-item :label="T('AddressBookName')">
|
||||||
<el-select v-model="formData.collection_id" clearable @change="changeCollection">
|
<el-select v-model="formData.collection_id" clearable @change="changeCollectionForUpdate">
|
||||||
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
||||||
<el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
<el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="ID" prop="id" required>
|
<el-form-item label="ID" prop="id" required>
|
||||||
@@ -162,7 +162,6 @@
|
|||||||
<el-switch v-model="formData.sameServer"></el-switch>
|
<el-switch v-model="formData.sameServer"></el-switch>
|
||||||
</el-form-item>-->
|
</el-form-item>-->
|
||||||
|
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button @click="formVisible = false">{{ T('Cancel') }}</el-button>
|
<el-button @click="formVisible = false">{{ T('Cancel') }}</el-button>
|
||||||
<el-button @click="submit" type="primary">{{ T('Submit') }}</el-button>
|
<el-button @click="submit" type="primary">{{ T('Submit') }}</el-button>
|
||||||
@@ -179,9 +178,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onActivated, onMounted, reactive, ref, watch } from 'vue'
|
import { onActivated, onMounted, watch } from 'vue'
|
||||||
import { useRepositories } from '@/views/address_book/index'
|
import { useRepositories } from '@/views/address_book/index'
|
||||||
import { toWebClientLink, getPeerSlat } from '@/utils/webclient'
|
import { toWebClientLink } from '@/utils/webclient'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { connectByClient } from '@/utils/peer'
|
import { connectByClient } from '@/utils/peer'
|
||||||
@@ -189,18 +188,19 @@
|
|||||||
import { handleClipboard } from '@/utils/clipboard'
|
import { handleClipboard } from '@/utils/clipboard'
|
||||||
import { CopyDocument } from '@element-plus/icons'
|
import { CopyDocument } from '@element-plus/icons'
|
||||||
import PlatformIcons from '@/components/icons/platform.vue'
|
import PlatformIcons from '@/components/icons/platform.vue'
|
||||||
|
import { loadAllUsers } from '@/global'
|
||||||
|
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const { allUsers, getAllUsers } = loadAllUsers()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
listRes,
|
listRes,
|
||||||
listQuery,
|
listQuery,
|
||||||
getList,
|
getList,
|
||||||
handlerQuery,
|
handlerQuery,
|
||||||
|
collectionListRes,
|
||||||
|
|
||||||
del,
|
del,
|
||||||
formVisible,
|
formVisible,
|
||||||
platformList,
|
platformList,
|
||||||
@@ -208,19 +208,13 @@
|
|||||||
toEdit,
|
toEdit,
|
||||||
toAdd,
|
toAdd,
|
||||||
submit,
|
submit,
|
||||||
// shareToWebClientVisible,
|
changeUserForUpdate,
|
||||||
// shareToWebClientForm,
|
changeCollectionForUpdate,
|
||||||
// toShowShare,
|
collectionListResForUpdate,
|
||||||
collectionListRes,
|
|
||||||
|
|
||||||
tagListRes,
|
tagListRes,
|
||||||
|
|
||||||
allUsers, getAllUsers,
|
|
||||||
|
|
||||||
changeQueryUser,
|
changeQueryUser,
|
||||||
changeUser,
|
} = useRepositories('admin')
|
||||||
changeCollection
|
|
||||||
} = useRepositories()
|
|
||||||
|
|
||||||
if (route.query?.user_id) {
|
if (route.query?.user_id) {
|
||||||
listQuery.user_id = parseInt(route.query.user_id)
|
listQuery.user_id = parseInt(route.query.user_id)
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import { computed, reactive, ref } from 'vue'
|
import { computed, reactive, ref } from 'vue'
|
||||||
import { create, list, remove, update } from '@/api/address_book_collection_rule'
|
import { list as admin_list, create as admin_create, update as admin_update, remove as admin_remove } from '@/api/address_book_collection_rule'
|
||||||
|
import { list as my_list, create as my_create, update as my_update, remove as my_remove } from '@/api/my/address_book_collection_rule'
|
||||||
import { groupUsers } from '@/api/user'
|
import { groupUsers } from '@/api/user'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import collection from '@element-plus/icons/lib/Collection'
|
|
||||||
|
|
||||||
export function useRepositories (is_my) {
|
const apis = {
|
||||||
|
admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
|
||||||
|
my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRepositories (api_type = 'my') {
|
||||||
const listRes = reactive({
|
const listRes = reactive({
|
||||||
list: [], total: 0, loading: false,
|
list: [], total: 0, loading: false,
|
||||||
})
|
})
|
||||||
@@ -13,12 +18,11 @@ export function useRepositories (is_my) {
|
|||||||
page: 1,
|
page: 1,
|
||||||
page_size: 10,
|
page_size: 10,
|
||||||
collection_id: null,
|
collection_id: null,
|
||||||
is_my,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
listRes.loading = true
|
listRes.loading = true
|
||||||
const res = await list(listQuery).catch(_ => false)
|
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||||
listRes.loading = false
|
listRes.loading = false
|
||||||
if (res) {
|
if (res) {
|
||||||
listRes.list = res.data.list
|
listRes.list = res.data.list
|
||||||
@@ -43,7 +47,7 @@ export function useRepositories (is_my) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await remove({ id: row.id }).catch(_ => false)
|
const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
@@ -79,7 +83,7 @@ export function useRepositories (is_my) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
const api = formData.id ? update : create
|
const api = formData.id ? apis[api_type].update : apis[api_type].create
|
||||||
const res = await api(formData).catch(_ => false)
|
const res = await api(formData).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
|
|||||||
@@ -106,7 +106,7 @@
|
|||||||
rules,
|
rules,
|
||||||
groupUsersList,
|
groupUsersList,
|
||||||
getGroupUsers,
|
getGroupUsers,
|
||||||
} = useRepositories(props.is_my)
|
} = useRepositories(props.is_my ? 'my' : 'admin')
|
||||||
|
|
||||||
formData.collection_id = props.collection.id
|
formData.collection_id = props.collection.id
|
||||||
formData.user_id = props.collection.user_id
|
formData.user_id = props.collection.user_id
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
toEdit,
|
toEdit,
|
||||||
toAdd,
|
toAdd,
|
||||||
submit,
|
submit,
|
||||||
} = useRepositories(1)
|
} = useRepositories('my')
|
||||||
|
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
|
|
||||||
|
|||||||
@@ -76,9 +76,9 @@
|
|||||||
<el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
|
<el-dialog v-model="formVisible" width="800" :title="!formData.row_id?T('Create') :T('Update') ">
|
||||||
<el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
|
<el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
|
||||||
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
||||||
<el-select v-model="formData.collection_id" clearable @change="changeCollection">
|
<el-select v-model="formData.collection_id" clearable @change="changeCollectionForUpdate">
|
||||||
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
||||||
<el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
<el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="ID" prop="id" required>
|
<el-form-item label="ID" prop="id" required>
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onActivated, onMounted, ref, watch } from 'vue'
|
import { onActivated, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { useBatchUpdateTagsRepositories, useRepositories } from '@/views/address_book'
|
import { useBatchUpdateTagsRepositories, useRepositories } from '@/views/address_book'
|
||||||
import { toWebClientLink } from '@/utils/webclient'
|
import { toWebClientLink } from '@/utils/webclient'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
@@ -185,32 +185,33 @@
|
|||||||
import { CopyDocument } from '@element-plus/icons'
|
import { CopyDocument } from '@element-plus/icons'
|
||||||
import PlatformIcons from '@/components/icons/platform.vue'
|
import PlatformIcons from '@/components/icons/platform.vue'
|
||||||
|
|
||||||
const is_my = 1
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
listRes,
|
listRes,
|
||||||
listQuery,
|
listQuery,
|
||||||
getList,
|
getList,
|
||||||
handlerQuery,
|
handlerQuery,
|
||||||
|
collectionListRes,
|
||||||
|
getCollectionList,
|
||||||
|
|
||||||
del,
|
del,
|
||||||
|
|
||||||
formVisible,
|
formVisible,
|
||||||
platformList,
|
platformList,
|
||||||
formData,
|
formData,
|
||||||
toEdit,
|
toEdit,
|
||||||
toAdd,
|
toAdd,
|
||||||
submit,
|
submit,
|
||||||
shareToWebClientVisible,
|
|
||||||
shareToWebClientForm,
|
|
||||||
toShowShare,
|
|
||||||
// collectionListQuery,
|
|
||||||
collectionListRes,
|
|
||||||
getCollectionList,
|
|
||||||
tagListRes,
|
tagListRes,
|
||||||
changeCollection,
|
changeCollectionForUpdate,
|
||||||
} = useRepositories(is_my)
|
getCollectionListForUpdate,
|
||||||
|
collectionListResForUpdate,
|
||||||
|
// collectionListQuery,
|
||||||
|
|
||||||
|
} = useRepositories('my')
|
||||||
|
|
||||||
onMounted(getCollectionList)
|
onMounted(getCollectionList)
|
||||||
|
onMounted(getCollectionListForUpdate)
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
onActivated(getList)
|
onActivated(getList)
|
||||||
|
|
||||||
@@ -218,6 +219,16 @@
|
|||||||
|
|
||||||
watch(() => listQuery.page_size, handlerQuery)
|
watch(() => listQuery.page_size, handlerQuery)
|
||||||
|
|
||||||
|
const shareToWebClientVisible = ref(false)
|
||||||
|
const shareToWebClientForm = reactive({
|
||||||
|
id: '',
|
||||||
|
hash: '',
|
||||||
|
})
|
||||||
|
const toShowShare = (row) => {
|
||||||
|
shareToWebClientForm.id = row.id
|
||||||
|
shareToWebClientForm.hash = row.hash
|
||||||
|
shareToWebClientVisible.value = true
|
||||||
|
}
|
||||||
const {
|
const {
|
||||||
tagListRes: tagListResForBatchEdit,
|
tagListRes: tagListResForBatchEdit,
|
||||||
getTagList: getTagListForBatchEdit,
|
getTagList: getTagListForBatchEdit,
|
||||||
@@ -225,7 +236,7 @@
|
|||||||
show: showBatchEditTags,
|
show: showBatchEditTags,
|
||||||
formData: batchEditTagsFormData,
|
formData: batchEditTagsFormData,
|
||||||
submit: _submitBatchEditTags,
|
submit: _submitBatchEditTags,
|
||||||
} = useBatchUpdateTagsRepositories(is_my)
|
} = useBatchUpdateTagsRepositories()
|
||||||
onMounted(getTagListForBatchEdit)
|
onMounted(getTagListForBatchEdit)
|
||||||
const submitBatchEditTags = async () => {
|
const submitBatchEditTags = async () => {
|
||||||
const res = await _submitBatchEditTags().catch(_ => false)
|
const res = await _submitBatchEditTags().catch(_ => false)
|
||||||
|
|||||||
+22
-19
@@ -22,7 +22,7 @@
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
||||||
<el-button type="success" @click="toExport">{{ T('Export') }}</el-button>
|
<el-button type="success" @click="toExport">{{ T('Export') }}</el-button>
|
||||||
<el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>
|
<!-- <el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>-->
|
||||||
<el-button type="primary" @click="toBatchAddToAB">{{ T('BatchAddToAB') }}</el-button>
|
<el-button type="primary" @click="toBatchAddToAB">{{ T('BatchAddToAB') }}</el-button>
|
||||||
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
<el-button v-if="appStore.setting.appConfig.web_client" type="success" @click="toWebClientLink(row)">Web Client</el-button>
|
<el-button v-if="appStore.setting.appConfig.web_client" type="success" @click="toWebClientLink(row)">Web Client</el-button>
|
||||||
<el-button type="primary" @click="toAddressBook(row)">{{ T('AddToAddressBook') }}</el-button>
|
<el-button type="primary" @click="toAddressBook(row)">{{ T('AddToAddressBook') }}</el-button>
|
||||||
<el-button @click="toView(row)">{{ T('View') }}</el-button>
|
<el-button @click="toView(row)">{{ T('View') }}</el-button>
|
||||||
<el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>
|
<!-- <el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>-->
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -105,9 +105,9 @@
|
|||||||
<el-dialog v-model="ABFormVisible" width="800" :title="T('Create')">
|
<el-dialog v-model="ABFormVisible" width="800" :title="T('Create')">
|
||||||
<el-form class="dialog-form" ref="form" :model="ABFormData" label-width="120px">
|
<el-form class="dialog-form" ref="form" :model="ABFormData" label-width="120px">
|
||||||
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
||||||
<el-select v-model="ABFormData.collection_id" clearable @change="changeCollection">
|
<el-select v-model="ABFormData.collection_id" clearable @change="changeCollectionForUpdate">
|
||||||
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
||||||
<el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
<el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="ID" prop="id" required>
|
<el-form-item label="ID" prop="id" required>
|
||||||
@@ -153,9 +153,9 @@
|
|||||||
<el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
|
<el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
|
||||||
<el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
|
<el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
|
||||||
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
||||||
<el-select v-model="batchABFormData.collection_id" clearable @change="changeCollection">
|
<el-select v-model="batchABFormData.collection_id" clearable @change="changeCollectionForBatchCreateAB">
|
||||||
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
||||||
<el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
<el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="T('Tags')" prop="tags">
|
<el-form-item :label="T('Tags')" prop="tags">
|
||||||
@@ -179,8 +179,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onActivated, onMounted, reactive, ref, watch } from 'vue'
|
import { computed, onActivated, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { batchRemove, remove } from '@/api/peer'
|
import { list } from '@/api/my/peer'
|
||||||
import { myPeer } from '@/api/user'
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { toWebClientLink } from '@/utils/webclient'
|
import { toWebClientLink } from '@/utils/webclient'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
@@ -191,7 +190,7 @@
|
|||||||
import { connectByClient } from '@/utils/peer'
|
import { connectByClient } from '@/utils/peer'
|
||||||
import { CopyDocument } from '@element-plus/icons'
|
import { CopyDocument } from '@element-plus/icons'
|
||||||
import { handleClipboard } from '@/utils/clipboard'
|
import { handleClipboard } from '@/utils/clipboard'
|
||||||
import { address_book_batchCreateFromPeers as batchCreateFromPeers } from '@/api/my'
|
import { batchCreateFromPeers } from '@/api/my/address_book'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const listRes = reactive({
|
const listRes = reactive({
|
||||||
@@ -207,7 +206,7 @@
|
|||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
listRes.loading = true
|
listRes.loading = true
|
||||||
const res = await myPeer(listQuery).catch(_ => false)
|
const res = await list(listQuery).catch(_ => false)
|
||||||
listRes.loading = false
|
listRes.loading = false
|
||||||
if (res) {
|
if (res) {
|
||||||
listRes.list = res.data.list
|
listRes.list = res.data.list
|
||||||
@@ -222,7 +221,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const del = async (row) => {
|
/*const del = async (row) => {
|
||||||
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
||||||
confirmButtonText: T('Confirm'),
|
confirmButtonText: T('Confirm'),
|
||||||
cancelButtonText: T('Cancel'),
|
cancelButtonText: T('Cancel'),
|
||||||
@@ -237,7 +236,7 @@
|
|||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
onActivated(getList)
|
onActivated(getList)
|
||||||
|
|
||||||
@@ -305,14 +304,14 @@
|
|||||||
platformList: ABPlatformList,
|
platformList: ABPlatformList,
|
||||||
formVisible: ABFormVisible,
|
formVisible: ABFormVisible,
|
||||||
formData: ABFormData,
|
formData: ABFormData,
|
||||||
collectionListRes,
|
collectionListResForUpdate,
|
||||||
getCollectionList,
|
getCollectionListForUpdate,
|
||||||
tagListRes,
|
tagListRes,
|
||||||
changeCollection,
|
changeCollectionForUpdate,
|
||||||
submit: ABSubmit,
|
submit: ABSubmit,
|
||||||
fromPeer,
|
fromPeer,
|
||||||
} = useABRepositories(1)
|
} = useABRepositories('my')
|
||||||
onMounted(getCollectionList)
|
onMounted(getCollectionListForUpdate)
|
||||||
const toAddressBook = (peer) => {
|
const toAddressBook = (peer) => {
|
||||||
fromPeer(peer)
|
fromPeer(peer)
|
||||||
ABFormVisible.value = true
|
ABFormVisible.value = true
|
||||||
@@ -322,7 +321,7 @@
|
|||||||
const handleSelectionChange = (val) => {
|
const handleSelectionChange = (val) => {
|
||||||
multipleSelection.value = val
|
multipleSelection.value = val
|
||||||
}
|
}
|
||||||
const toBatchDelete = async () => {
|
/*const toBatchDelete = async () => {
|
||||||
if (!multipleSelection.value.length) {
|
if (!multipleSelection.value.length) {
|
||||||
ElMessage.warning(T('PleaseSelectData'))
|
ElMessage.warning(T('PleaseSelectData'))
|
||||||
return false
|
return false
|
||||||
@@ -341,7 +340,7 @@
|
|||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const batchABFormVisible = ref(false)
|
const batchABFormVisible = ref(false)
|
||||||
const toBatchAddToAB = () => {
|
const toBatchAddToAB = () => {
|
||||||
@@ -352,6 +351,10 @@
|
|||||||
tags: [],
|
tags: [],
|
||||||
peer_ids: [],
|
peer_ids: [],
|
||||||
})
|
})
|
||||||
|
const changeCollectionForBatchCreateAB = (val) => {
|
||||||
|
batchABFormData.value.tags = []
|
||||||
|
changeCollectionForUpdate(val)
|
||||||
|
}
|
||||||
const submitBatchAddToAB = async () => {
|
const submitBatchAddToAB = async () => {
|
||||||
if (multipleSelection.value.length === 0) {
|
if (multipleSelection.value.length === 0) {
|
||||||
ElMessage.warning(T('PleaseSelectData'))
|
ElMessage.warning(T('PleaseSelectData'))
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
||||||
<el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
|
<el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
<el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : '-' }}</el-tag>
|
<el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : T('Forever') }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="T('Actions')" align="center" width="400">
|
<el-table-column :label="T('Actions')" align="center" width="400">
|
||||||
@@ -39,95 +39,31 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onActivated, onMounted, ref, watch, reactive } from 'vue'
|
import { onActivated, onMounted, watch } from 'vue'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import { share_record_remove as remove, share_record_list as list, share_record_batchDelete as batchDelete } from '@/api/my'
|
import { useRepositories } from '@/views/share_record'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
||||||
|
|
||||||
const listRes = reactive({
|
const {
|
||||||
list: [], total: 0, loading: false,
|
listRes,
|
||||||
})
|
listQuery,
|
||||||
const listQuery = reactive({
|
getList,
|
||||||
page: 1,
|
handlerQuery,
|
||||||
page_size: 10,
|
del,
|
||||||
})
|
multipleSelection,
|
||||||
|
toBatchDelete,
|
||||||
|
expired,
|
||||||
|
} = useRepositories('my')
|
||||||
|
|
||||||
const getList = async () => {
|
|
||||||
listRes.loading = true
|
|
||||||
const res = await list(listQuery).catch(_ => false)
|
|
||||||
listRes.loading = false
|
|
||||||
if (res) {
|
|
||||||
listRes.list = res.data.list
|
|
||||||
listRes.total = res.data.total
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handlerQuery = () => {
|
|
||||||
if (listQuery.page === 1) {
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
listQuery.page = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const del = async (row) => {
|
|
||||||
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
|
||||||
confirmButtonText: T('Confirm'),
|
|
||||||
cancelButtonText: T('Cancel'),
|
|
||||||
type: 'warning',
|
|
||||||
}).catch(_ => false)
|
|
||||||
if (!cf) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const res = await remove({ id: row.id }).catch(_ => false)
|
|
||||||
if (res) {
|
|
||||||
ElMessage.success(T('OperationSuccess'))
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
onActivated(getList)
|
onActivated(getList)
|
||||||
|
|
||||||
watch(() => listQuery.page, getList)
|
watch(() => listQuery.page, getList)
|
||||||
|
|
||||||
watch(() => listQuery.page_size, handlerQuery)
|
watch(() => listQuery.page_size, handlerQuery)
|
||||||
const multipleSelection = ref([])
|
|
||||||
const handleSelectionChange = (val) => {
|
const handleSelectionChange = (val) => {
|
||||||
multipleSelection.value = val
|
multipleSelection.value = val
|
||||||
}
|
}
|
||||||
const toBatchDelete = () => {
|
|
||||||
if (multipleSelection.value.length === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
batchdel(multipleSelection.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const batchdel = async (rows) => {
|
|
||||||
const ids = rows.map(r => r.id)
|
|
||||||
if (!ids.length) {
|
|
||||||
ElMessage.warning(T('PleaseSelectData'))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
|
|
||||||
confirmButtonText: T('Confirm'),
|
|
||||||
cancelButtonText: T('Cancel'),
|
|
||||||
type: 'warning',
|
|
||||||
}).catch(_ => false)
|
|
||||||
if (!cf) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await batchDelete({ ids }).catch(_ => false)
|
|
||||||
if (res) {
|
|
||||||
ElMessage.success(T('OperationSuccess'))
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const expired = (row) => {
|
|
||||||
const now = new Date().getTime()
|
|
||||||
const created_at = new Date(row.created_at).getTime()
|
|
||||||
return row.expire * 1000 + created_at < now
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
<el-form-item :label="T('AddressBookName')">
|
<el-form-item :label="T('AddressBookName')">
|
||||||
<el-select v-model="formData.collection_id" clearable>
|
<el-select v-model="formData.collection_id" clearable>
|
||||||
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
||||||
<el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
<el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="T('Name')" prop="name" required>
|
<el-form-item :label="T('Name')" prop="name" required>
|
||||||
@@ -86,7 +86,6 @@
|
|||||||
import { onMounted, watch, onActivated } from 'vue'
|
import { onMounted, watch, onActivated } from 'vue'
|
||||||
import { useRepositories } from '@/views/tag'
|
import { useRepositories } from '@/views/tag'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
listRes,
|
listRes,
|
||||||
@@ -101,9 +100,13 @@
|
|||||||
submit,
|
submit,
|
||||||
activeChange,
|
activeChange,
|
||||||
currentColor,
|
currentColor,
|
||||||
} = useRepositories()
|
|
||||||
|
|
||||||
listQuery.is_my = 1
|
collectionListRes,
|
||||||
|
getCollectionList,
|
||||||
|
|
||||||
|
collectionListResForUpdate,
|
||||||
|
getCollectionListForUpdate,
|
||||||
|
} = useRepositories('my')
|
||||||
|
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
onActivated(getList)
|
onActivated(getList)
|
||||||
@@ -112,14 +115,8 @@
|
|||||||
|
|
||||||
watch(() => listQuery.page_size, handlerQuery)
|
watch(() => listQuery.page_size, handlerQuery)
|
||||||
|
|
||||||
const {
|
|
||||||
listRes: collectionListRes,
|
|
||||||
listQuery: collectionListQuery,
|
|
||||||
getList: getCollectionList,
|
|
||||||
} = useCollectionRepositories()
|
|
||||||
collectionListQuery.is_my = 1
|
|
||||||
collectionListQuery.page_size = 999
|
|
||||||
onMounted(getCollectionList)
|
onMounted(getCollectionList)
|
||||||
|
onMounted(getCollectionListForUpdate)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+20
-15
@@ -163,7 +163,7 @@
|
|||||||
<el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
|
<el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
|
||||||
<el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
|
<el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
|
||||||
<el-form-item :label="T('Owner')" prop="user_id" required>
|
<el-form-item :label="T('Owner')" prop="user_id" required>
|
||||||
<el-select v-model="batchABFormData.user_id" @change="changeUser">
|
<el-select v-model="batchABFormData.user_id" @change="changeUserForBatchCreateAB">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in allUsers"
|
v-for="item in allUsers"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -173,9 +173,9 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
||||||
<el-select v-model="batchABFormData.collection_id" clearable @change="changeCollection">
|
<el-select v-model="batchABFormData.collection_id" clearable>
|
||||||
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
||||||
<el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
<el-option v-for="c in collectionListResForBatchCreateAB.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item :label="T('Tags')" prop="tags">
|
<!-- <el-form-item :label="T('Tags')" prop="tags">
|
||||||
@@ -214,6 +214,7 @@
|
|||||||
import { CopyDocument } from '@element-plus/icons'
|
import { CopyDocument } from '@element-plus/icons'
|
||||||
import { handleClipboard } from '@/utils/clipboard'
|
import { handleClipboard } from '@/utils/clipboard'
|
||||||
import { batchCreateFromPeers } from '@/api/address_book'
|
import { batchCreateFromPeers } from '@/api/address_book'
|
||||||
|
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const listRes = reactive({
|
const listRes = reactive({
|
||||||
@@ -345,16 +346,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//添加到地址簿 start
|
||||||
|
const { allUsers, getAllUsers } = loadAllUsers()
|
||||||
|
onMounted(getAllUsers)
|
||||||
const {
|
const {
|
||||||
platformList: ABPlatformList,
|
platformList: ABPlatformList,
|
||||||
formVisible: ABFormVisible,
|
formVisible: ABFormVisible,
|
||||||
formData: ABFormData,
|
formData: ABFormData,
|
||||||
fromPeer,
|
fromPeer,
|
||||||
changeCollection,
|
} = useABRepositories('admin')
|
||||||
collectionListRes,
|
|
||||||
collectionListQuery,
|
|
||||||
getCollectionList,
|
|
||||||
} = useABRepositories()
|
|
||||||
const toAddressBook = (peer) => {
|
const toAddressBook = (peer) => {
|
||||||
fromPeer(peer)
|
fromPeer(peer)
|
||||||
ABFormVisible.value = true
|
ABFormVisible.value = true
|
||||||
@@ -366,8 +366,6 @@
|
|||||||
ABFormVisible.value = false
|
ABFormVisible.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { allUsers, getAllUsers } = loadAllUsers()
|
|
||||||
const tagList = ref([])
|
const tagList = ref([])
|
||||||
const fetchTagListData = async (user_id) => {
|
const fetchTagListData = async (user_id) => {
|
||||||
const res = await fetchTagList({ user_id }).catch(_ => false)
|
const res = await fetchTagList({ user_id }).catch(_ => false)
|
||||||
@@ -381,8 +379,8 @@
|
|||||||
tagList.value = ls.map(item => ({ name: item }))
|
tagList.value = ls.map(item => ({ name: item }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(getAllUsers)
|
|
||||||
onMounted(fetchTagListData)
|
onMounted(fetchTagListData)
|
||||||
|
// 添加到地址簿 end
|
||||||
|
|
||||||
const multipleSelection = ref([])
|
const multipleSelection = ref([])
|
||||||
const handleSelectionChange = (val) => {
|
const handleSelectionChange = (val) => {
|
||||||
@@ -409,11 +407,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量添加到地址簿
|
// 批量添加到地址簿 start
|
||||||
const changeUser = (val) => {
|
const {
|
||||||
collectionListQuery.user_id = val
|
listRes: collectionListResForBatchCreateAB,
|
||||||
|
listQuery: collectionListQueryForBatchCreateAB,
|
||||||
|
getList: getCollectionListForBatchCreateAB,
|
||||||
|
} = useCollectionRepositories('admin')
|
||||||
|
collectionListQueryForBatchCreateAB.page_size = 9999
|
||||||
|
const changeUserForBatchCreateAB = (val) => {
|
||||||
batchABFormData.value.collection_id = 0
|
batchABFormData.value.collection_id = 0
|
||||||
getCollectionList()
|
collectionListQueryForBatchCreateAB.user_id = val
|
||||||
|
getCollectionListForBatchCreateAB()
|
||||||
}
|
}
|
||||||
const batchABFormVisible = ref(false)
|
const batchABFormVisible = ref(false)
|
||||||
const toBatchAddToAB = () => {
|
const toBatchAddToAB = () => {
|
||||||
@@ -442,6 +446,7 @@
|
|||||||
batchABFormVisible.value = false
|
batchABFormVisible.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 批量添加到地址簿 end
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import { reactive, ref } from 'vue'
|
||||||
|
import { batchDelete as admin_batchDelete, list as admin_list, remove as admin_remove } from '@/api/share_record'
|
||||||
|
import { batchDelete as my_batchDelete, list as my_list, remove as my_remove } from '@/api/my/share_record'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { T } from '@/utils/i18n'
|
||||||
|
|
||||||
|
const apis = {
|
||||||
|
admin: { batchDelete: admin_batchDelete, list: admin_list, remove: admin_remove },
|
||||||
|
my: { batchDelete: my_batchDelete, list: my_list, remove: my_remove },
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRepositories (api_type = 'my') {
|
||||||
|
const listRes = reactive({
|
||||||
|
list: [], total: 0, loading: false,
|
||||||
|
})
|
||||||
|
const listQuery = reactive({
|
||||||
|
page: 1,
|
||||||
|
page_size: 10,
|
||||||
|
})
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
listRes.loading = true
|
||||||
|
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||||
|
listRes.loading = false
|
||||||
|
if (res) {
|
||||||
|
listRes.list = res.data.list
|
||||||
|
listRes.total = res.data.total
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const handlerQuery = () => {
|
||||||
|
if (listQuery.page === 1) {
|
||||||
|
getList()
|
||||||
|
} else {
|
||||||
|
listQuery.page = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const del = async (row) => {
|
||||||
|
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
||||||
|
confirmButtonText: T('Confirm'),
|
||||||
|
cancelButtonText: T('Cancel'),
|
||||||
|
type: 'warning',
|
||||||
|
}).catch(_ => false)
|
||||||
|
if (!cf) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
|
||||||
|
if (res) {
|
||||||
|
ElMessage.success(T('OperationSuccess'))
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const multipleSelection = ref([])
|
||||||
|
const toBatchDelete = async () => {
|
||||||
|
if (multipleSelection.value.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const ids = multipleSelection.value.map(r => r.id)
|
||||||
|
if (!ids.length) {
|
||||||
|
ElMessage.warning(T('PleaseSelectData'))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
|
||||||
|
confirmButtonText: T('Confirm'),
|
||||||
|
cancelButtonText: T('Cancel'),
|
||||||
|
type: 'warning',
|
||||||
|
}).catch(_ => false)
|
||||||
|
if (!cf) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await apis[api_type].batchDelete({ ids }).catch(_ => false)
|
||||||
|
if (res) {
|
||||||
|
ElMessage.success(T('OperationSuccess'))
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const expired = (row) => {
|
||||||
|
if (row.expire === 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const now = new Date().getTime()
|
||||||
|
const created_at = new Date(row.created_at).getTime()
|
||||||
|
return row.expire * 1000 + created_at < now
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
listRes,
|
||||||
|
listQuery,
|
||||||
|
getList,
|
||||||
|
handlerQuery,
|
||||||
|
del,
|
||||||
|
multipleSelection,
|
||||||
|
toBatchDelete,
|
||||||
|
expired,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
||||||
<el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
|
<el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
<el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : '-' }}</el-tag>
|
<el-tag :type="expired(row)?'info':'success'">{{ row.expire ? row.expire : T('Forever') }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="T('Actions')" align="center" width="400">
|
<el-table-column :label="T('Actions')" align="center" width="400">
|
||||||
@@ -59,95 +59,32 @@
|
|||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import { remove, list, batchDelete } from '@/api/share_record'
|
import { remove, list, batchDelete } from '@/api/share_record'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { useRepositories } from '@/views/share_record/index'
|
||||||
|
|
||||||
const { allUsers, getAllUsers } = loadAllUsers()
|
const { allUsers, getAllUsers } = loadAllUsers()
|
||||||
getAllUsers()
|
getAllUsers()
|
||||||
|
|
||||||
const listRes = reactive({
|
const {
|
||||||
list: [], total: 0, loading: false,
|
listRes,
|
||||||
})
|
listQuery,
|
||||||
const listQuery = reactive({
|
getList,
|
||||||
page: 1,
|
handlerQuery,
|
||||||
page_size: 10,
|
del,
|
||||||
is_my: 0,
|
multipleSelection,
|
||||||
user_id: null,
|
toBatchDelete,
|
||||||
})
|
expired,
|
||||||
|
} = useRepositories('admin')
|
||||||
|
|
||||||
const getList = async () => {
|
|
||||||
listRes.loading = true
|
|
||||||
const res = await list(listQuery).catch(_ => false)
|
|
||||||
listRes.loading = false
|
|
||||||
if (res) {
|
|
||||||
listRes.list = res.data.list
|
|
||||||
listRes.total = res.data.total
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handlerQuery = () => {
|
|
||||||
if (listQuery.page === 1) {
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
listQuery.page = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const expired = (row) => {
|
|
||||||
const now = new Date().getTime()
|
|
||||||
const created_at = new Date(row.created_at).getTime()
|
|
||||||
return row.expire * 1000 + created_at < now
|
|
||||||
}
|
|
||||||
|
|
||||||
const del = async (row) => {
|
|
||||||
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), {
|
|
||||||
confirmButtonText: T('Confirm'),
|
|
||||||
cancelButtonText: T('Cancel'),
|
|
||||||
type: 'warning',
|
|
||||||
}).catch(_ => false)
|
|
||||||
if (!cf) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const res = await remove({ id: row.id }).catch(_ => false)
|
|
||||||
if (res) {
|
|
||||||
ElMessage.success(T('OperationSuccess'))
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
onActivated(getList)
|
onActivated(getList)
|
||||||
|
|
||||||
watch(() => listQuery.page, getList)
|
watch(() => listQuery.page, getList)
|
||||||
|
|
||||||
watch(() => listQuery.page_size, handlerQuery)
|
watch(() => listQuery.page_size, handlerQuery)
|
||||||
const multipleSelection = ref([])
|
|
||||||
const handleSelectionChange = (val) => {
|
const handleSelectionChange = (val) => {
|
||||||
multipleSelection.value = val
|
multipleSelection.value = val
|
||||||
}
|
}
|
||||||
const toBatchDelete = () => {
|
|
||||||
if (multipleSelection.value.length === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
batchdel(multipleSelection.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const batchdel = async (rows) => {
|
|
||||||
const ids = rows.map(r => r.id)
|
|
||||||
if (!ids.length) {
|
|
||||||
ElMessage.warning(T('PleaseSelectData'))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
|
|
||||||
confirmButtonText: T('Confirm'),
|
|
||||||
cancelButtonText: T('Cancel'),
|
|
||||||
type: 'warning',
|
|
||||||
}).catch(_ => false)
|
|
||||||
if (!cf) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await batchDelete({ ids }).catch(_ => false)
|
|
||||||
if (res) {
|
|
||||||
ElMessage.success(T('OperationSuccess'))
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+44
-29
@@ -1,20 +1,18 @@
|
|||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import { create, list, remove, update } from '@/api/tag'
|
import { create as admin_create, list as admin_list, remove as admin_remove, update as admin_update } from '@/api/tag'
|
||||||
|
import { create as my_create, list as my_list, remove as my_remove, update as my_update } from '@/api/my/tag'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
import { loadAllUsers } from '@/global'
|
|
||||||
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
||||||
|
|
||||||
export function useRepositories (is_my = 0) {
|
const apis = {
|
||||||
const { allUsers, getAllUsers } = loadAllUsers()
|
admin: { list: admin_list, remove: admin_remove, update: admin_update, create: admin_create },
|
||||||
|
my: { list: my_list, remove: my_remove, create: my_create, update: my_update },
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRepositories (api_type = 'my') {
|
||||||
|
|
||||||
const {
|
|
||||||
listRes: collectionListRes,
|
|
||||||
listQuery: collectionListQuery,
|
|
||||||
getList: getCollectionList,
|
|
||||||
} = useCollectionRepositories(is_my)
|
|
||||||
collectionListQuery.page_size = 9999
|
|
||||||
//获取query
|
//获取query
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const user_id = route.query?.user_id
|
const user_id = route.query?.user_id
|
||||||
@@ -24,7 +22,6 @@ export function useRepositories (is_my = 0) {
|
|||||||
const listQuery = reactive({
|
const listQuery = reactive({
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 10,
|
page_size: 10,
|
||||||
is_my,
|
|
||||||
user_id: user_id ? parseInt(user_id) : null,
|
user_id: user_id ? parseInt(user_id) : null,
|
||||||
collection_id: null,
|
collection_id: null,
|
||||||
})
|
})
|
||||||
@@ -72,7 +69,7 @@ export function useRepositories (is_my = 0) {
|
|||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
listRes.loading = true
|
listRes.loading = true
|
||||||
const res = await list(listQuery).catch(_ => false)
|
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||||
listRes.loading = false
|
listRes.loading = false
|
||||||
if (res) {
|
if (res) {
|
||||||
listRes.list = res.data.list.map(item => {
|
listRes.list = res.data.list.map(item => {
|
||||||
@@ -100,7 +97,7 @@ export function useRepositories (is_my = 0) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await remove({ id: row.id }).catch(_ => false)
|
const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
@@ -112,12 +109,11 @@ export function useRepositories (is_my = 0) {
|
|||||||
id: 0,
|
id: 0,
|
||||||
name: '',
|
name: '',
|
||||||
color: 0,
|
color: 0,
|
||||||
user_id: 0,
|
user_id: null,
|
||||||
collection_id: 0,
|
collection_id: null,
|
||||||
})
|
})
|
||||||
const currentColor = ref('')
|
const currentColor = ref('')
|
||||||
const activeChange = (c) => {
|
const activeChange = (c) => {
|
||||||
console.log(c)
|
|
||||||
currentColor.value = c
|
currentColor.value = c
|
||||||
}
|
}
|
||||||
const toEdit = (row) => {
|
const toEdit = (row) => {
|
||||||
@@ -137,7 +133,7 @@ export function useRepositories (is_my = 0) {
|
|||||||
formData.name = ''
|
formData.name = ''
|
||||||
formData.color = ''
|
formData.color = ''
|
||||||
formData.user_id = null
|
formData.user_id = null
|
||||||
formData.collection_id = 0
|
formData.collection_id = null
|
||||||
}
|
}
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
console.log(formData)
|
console.log(formData)
|
||||||
@@ -145,7 +141,7 @@ export function useRepositories (is_my = 0) {
|
|||||||
ElMessage.error('请选择颜色')
|
ElMessage.error('请选择颜色')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const api = formData.id ? update : create
|
const api = formData.id ? apis[api_type].update : apis[api_type].create
|
||||||
const data = {
|
const data = {
|
||||||
...formData,
|
...formData,
|
||||||
color: rgba2flutterColor(formData.color),
|
color: rgba2flutterColor(formData.color),
|
||||||
@@ -159,15 +155,13 @@ export function useRepositories (is_my = 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeQueryUser = async (val) => {
|
//query form collection
|
||||||
listQuery.collection_id = null
|
const {
|
||||||
if (!val) {
|
listRes: collectionListRes,
|
||||||
collectionListRes.list = []
|
listQuery: collectionListQuery,
|
||||||
} else {
|
getList: getCollectionList,
|
||||||
collectionListQuery.user_id = val
|
} = useCollectionRepositories(api_type)
|
||||||
getCollectionList()
|
collectionListQuery.page_size = 9999
|
||||||
}
|
|
||||||
}
|
|
||||||
const changeUser = async (val) => {
|
const changeUser = async (val) => {
|
||||||
formData.collection_id = 0
|
formData.collection_id = 0
|
||||||
if (!val) {
|
if (!val) {
|
||||||
@@ -177,6 +171,23 @@ export function useRepositories (is_my = 0) {
|
|||||||
getCollectionList()
|
getCollectionList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
listRes: collectionListResForUpdate,
|
||||||
|
listQuery: collectionListQueryForUpdate,
|
||||||
|
getList: getCollectionListForUpdate,
|
||||||
|
} = useCollectionRepositories(api_type)
|
||||||
|
collectionListQueryForUpdate.page_size = 9999
|
||||||
|
//create or update form collection
|
||||||
|
const changeUserForUpdate = async (val) => {
|
||||||
|
listQuery.collection_id = null
|
||||||
|
if (!val) {
|
||||||
|
collectionListRes.list = []
|
||||||
|
} else {
|
||||||
|
collectionListQuery.user_id = val
|
||||||
|
getCollectionListForUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
listRes,
|
listRes,
|
||||||
listQuery,
|
listQuery,
|
||||||
@@ -192,8 +203,12 @@ export function useRepositories (is_my = 0) {
|
|||||||
currentColor,
|
currentColor,
|
||||||
|
|
||||||
collectionListRes,
|
collectionListRes,
|
||||||
allUsers, getAllUsers,
|
|
||||||
changeQueryUser,
|
|
||||||
changeUser,
|
changeUser,
|
||||||
|
getCollectionList,
|
||||||
|
|
||||||
|
collectionListResForUpdate,
|
||||||
|
changeUserForUpdate,
|
||||||
|
getCollectionListForUpdate,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-7
@@ -3,7 +3,7 @@
|
|||||||
<el-card class="list-query" shadow="hover">
|
<el-card class="list-query" shadow="hover">
|
||||||
<el-form inline label-width="120px">
|
<el-form inline label-width="120px">
|
||||||
<el-form-item :label="T('Owner')">
|
<el-form-item :label="T('Owner')">
|
||||||
<el-select v-model="listQuery.user_id" clearable @change="changeQueryUser">
|
<el-select v-model="listQuery.user_id" clearable @change="changeUser">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in allUsers"
|
v-for="item in allUsers"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
<el-dialog v-model="formVisible" :title="!formData.id?T('Create'):T('Update')" width="800">
|
<el-dialog v-model="formVisible" :title="!formData.id?T('Create'):T('Update')" width="800">
|
||||||
<el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
|
<el-form class="dialog-form" ref="form" :model="formData" label-width="120px">
|
||||||
<el-form-item :label="T('Owner')" prop="user_id" required>
|
<el-form-item :label="T('Owner')" prop="user_id" required>
|
||||||
<el-select v-model="formData.user_id" @change="changeUser">
|
<el-select v-model="formData.user_id" @change="changeUserForUpdate">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in allUsers"
|
v-for="item in allUsers"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
<el-form-item :label="T('AddressBookName')" prop="collection_id" required>
|
<el-form-item :label="T('AddressBookName')" prop="collection_id" required>
|
||||||
<el-select v-model="formData.collection_id" clearable>
|
<el-select v-model="formData.collection_id" clearable>
|
||||||
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
<el-option :value="0" :label="T('MyAddressBook')"></el-option>
|
||||||
<el-option v-for="c in collectionListRes.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
<el-option v-for="c in collectionListResForUpdate.list" :key="c.id" :label="c.name" :value="c.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="T('Name')" prop="name" required>
|
<el-form-item :label="T('Name')" prop="name" required>
|
||||||
@@ -111,7 +111,10 @@
|
|||||||
import { onMounted, reactive, watch, ref, onActivated } from 'vue'
|
import { onMounted, reactive, watch, ref, onActivated } from 'vue'
|
||||||
import { useRepositories } from '@/views/tag/index'
|
import { useRepositories } from '@/views/tag/index'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
|
import { loadAllUsers } from '@/global'
|
||||||
|
|
||||||
|
const { allUsers, getAllUsers } = loadAllUsers()
|
||||||
|
onMounted(getAllUsers)
|
||||||
const {
|
const {
|
||||||
listRes,
|
listRes,
|
||||||
listQuery,
|
listQuery,
|
||||||
@@ -125,12 +128,16 @@
|
|||||||
submit,
|
submit,
|
||||||
activeChange,
|
activeChange,
|
||||||
currentColor,
|
currentColor,
|
||||||
|
|
||||||
collectionListRes,
|
collectionListRes,
|
||||||
allUsers, getAllUsers,
|
|
||||||
changeQueryUser,
|
|
||||||
changeUser,
|
changeUser,
|
||||||
} = useRepositories()
|
// getCollectionList,
|
||||||
onMounted(getAllUsers)
|
|
||||||
|
collectionListResForUpdate,
|
||||||
|
changeUserForUpdate,
|
||||||
|
// getCollectionListForUpdate,
|
||||||
|
} = useRepositories('admin')
|
||||||
|
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
onActivated(getList)
|
onActivated(getList)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user