From 2a6bda9b9e3e6f1a8c40748eea94973a9cbeb3f6 Mon Sep 17 00:00:00 2001 From: lejianwen <84855512@qq.com> Date: Fri, 20 Dec 2024 11:10:06 +0800 Subject: [PATCH] optimize add ab from peer --- src/views/peer/createABForm.vue | 129 ++++++++++++++++++++++++++++++++ src/views/peer/index.vue | 96 +++--------------------- 2 files changed, 138 insertions(+), 87 deletions(-) create mode 100644 src/views/peer/createABForm.vue diff --git a/src/views/peer/createABForm.vue b/src/views/peer/createABForm.vue new file mode 100644 index 0000000..d752833 --- /dev/null +++ b/src/views/peer/createABForm.vue @@ -0,0 +1,129 @@ + + + + diff --git a/src/views/peer/index.vue b/src/views/peer/index.vue index 39d4b2f..16c0f7c 100644 --- a/src/views/peer/index.vue +++ b/src/views/peer/index.vue @@ -107,59 +107,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ T('Cancel') }} - {{ T('Submit') }} - - + + - @@ -205,16 +156,14 @@ import { T } from '@/utils/i18n' import { timeAgo } from '@/utils/time' import { jsonToCsv, downBlob } from '@/utils/file' - import { useRepositories as useABRepositories } from '@/views/address_book/index' import { loadAllUsers } from '@/global' - import { list as fetchTagList } from '@/api/tag' - import { batchCreate } from '@/api/address_book' import { useAppStore } from '@/store/app' import { connectByClient } from '@/utils/peer' import { CopyDocument } from '@element-plus/icons' import { handleClipboard } from '@/utils/clipboard' import { batchCreateFromPeers } from '@/api/address_book' import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection' + import createABForm from '@/views/peer/createABForm.vue' const appStore = useAppStore() const listRes = reactive({ @@ -346,41 +295,12 @@ } } - //添加到地址簿 start - const { allUsers, getAllUsers } = loadAllUsers() - onMounted(getAllUsers) - const { - platformList: ABPlatformList, - formVisible: ABFormVisible, - formData: ABFormData, - fromPeer, - } = useABRepositories('admin') - const toAddressBook = (peer) => { - fromPeer(peer) + const ABFormVisible = ref(false) + const clickRow = ref({}) + const toAddressBook = (row) => { + clickRow.value = row ABFormVisible.value = true } - const ABSubmit = async () => { - const res = await batchCreate(ABFormData).catch(_ => false) - if (res) { - ElMessage.success(T('OperationSuccess')) - ABFormVisible.value = false - } - } - const tagList = ref([]) - const fetchTagListData = async (user_id) => { - const res = await fetchTagList({ user_id }).catch(_ => false) - if (res) { - const ls = [] - res.data.list.map(item => { - if (!ls.includes(item.name)) { - ls.push(item.name) - } - }) - tagList.value = ls.map(item => ({ name: item })) - } - } - onMounted(fetchTagListData) - // 添加到地址簿 end const multipleSelection = ref([]) const handleSelectionChange = (val) => { @@ -408,6 +328,8 @@ } // 批量添加到地址簿 start + const { allUsers, getAllUsers } = loadAllUsers() + onMounted(getAllUsers) const { listRes: collectionListResForBatchCreateAB, listQuery: collectionListQueryForBatchCreateAB,