add batch create ab from peer
add batch update ab tags
This commit is contained in:
@@ -52,3 +52,19 @@ export function shareByWebClient (data) {
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function batchCreateFromPeers (data) {
|
||||
return request({
|
||||
url: '/address_book/batchCreateFromPeers',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function batchUpdateTags (data) {
|
||||
return request({
|
||||
url: '/address_book/batchUpdateTags',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -450,5 +450,11 @@
|
||||
},
|
||||
"UserToken": {
|
||||
"One": "User Token"
|
||||
},
|
||||
"BatchAddToAB": {
|
||||
"One": "Batch Add To Address Book"
|
||||
},
|
||||
"BatchEditTags": {
|
||||
"One": "Batch Edit Tags"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,5 +453,11 @@
|
||||
},
|
||||
"MyPeer": {
|
||||
"One": "Mis pares"
|
||||
},
|
||||
"BatchAddToAB": {
|
||||
"One": "Agregar en bloque a la libreta de direcciones"
|
||||
},
|
||||
"BatchEditTags": {
|
||||
"One": "Editar etiquetas en bloque"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,5 +439,11 @@
|
||||
},
|
||||
"MyPeer": {
|
||||
"One": "내 피어"
|
||||
},
|
||||
"BatchAddToAB": {
|
||||
"One": "주소록에 일괄 추가"
|
||||
},
|
||||
"BatchEditTags": {
|
||||
"One": "태그 일괄 편집"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,6 +453,12 @@
|
||||
},
|
||||
"MyPeer": {
|
||||
"One": "Мои партнеры"
|
||||
},
|
||||
"BatchAddToAB": {
|
||||
"One": "Пакетное добавление в адресную книгу"
|
||||
},
|
||||
"BatchEditTags": {
|
||||
"One": "Пакетное редактирование тегов"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -469,5 +469,11 @@
|
||||
},
|
||||
"Information": {
|
||||
"One": "信息"
|
||||
},
|
||||
"BatchAddToAB": {
|
||||
"One": "批量添加到地址簿"
|
||||
},
|
||||
"BatchEditTags": {
|
||||
"One": "批量编辑标签"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { create, list, remove, update } from '@/api/address_book'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { batchUpdateTags, create, list, remove, update } from '@/api/address_book'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { T } from '@/utils/i18n'
|
||||
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
||||
@@ -246,3 +246,53 @@ export function useRepositories (is_my = 0) {
|
||||
fromPeer,
|
||||
}
|
||||
}
|
||||
|
||||
export function useBatchUpdateTagsRepositories (is_my = 0) {
|
||||
const {
|
||||
listRes: tagListRes,
|
||||
listQuery: tagListQuery,
|
||||
getList: getTagList,
|
||||
} = useTagRepositories(is_my)
|
||||
tagListQuery.page_size = 9999
|
||||
|
||||
const visible = ref(false)
|
||||
const show = () => {
|
||||
if (formData.value.row_ids.length === 0) {
|
||||
ElMessage.warning(T('PleaseSelectData'))
|
||||
return
|
||||
}
|
||||
visible.value = true
|
||||
}
|
||||
const formData = ref({
|
||||
tags: [],
|
||||
row_ids: [],
|
||||
})
|
||||
const submit = async () => {
|
||||
if (formData.value.row_ids.length === 0) {
|
||||
ElMessage.warning(T('PleaseSelectData'))
|
||||
return false
|
||||
}
|
||||
if (formData.value.tags.length === 0) {
|
||||
ElMessage.warning(T('PleaseSelectData'))
|
||||
return false
|
||||
}
|
||||
const res = await batchUpdateTags(formData.value).catch(_ => false)
|
||||
if (res) {
|
||||
ElMessage.success(T('Success'))
|
||||
visible.value = false
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return {
|
||||
tagListQuery,
|
||||
getTagList,
|
||||
tagListRes,
|
||||
|
||||
visible,
|
||||
formData,
|
||||
show,
|
||||
submit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
||||
<el-button type="danger" @click="toAdd">{{ T('Add') }}</el-button>
|
||||
<el-button type="primary" @click="showBatchEditTags">{{ T('BatchEditTags') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="list-body" shadow="hover">
|
||||
<!-- <el-tag type="danger" style="margin-bottom: 10px">不建议在此操作地址簿,可能会造成数据不同步</el-tag>-->
|
||||
<el-table :data="listRes.list" v-loading="listRes.loading" border>
|
||||
<el-table :data="listRes.list" v-loading="listRes.loading" border @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center"></el-table-column>
|
||||
<el-table-column prop="id" label="ID" align="center" width="200">
|
||||
<template #default="{row}">
|
||||
<div>
|
||||
@@ -151,13 +152,31 @@
|
||||
@cancel="shareToWebClientVisible=false"
|
||||
@success=""/>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="batchEditTagVisible" width="800">
|
||||
<el-form :model="batchEditTagsFormData" label-width="120px" class="dialog-form">
|
||||
<el-form-item :label="T('Tags')" prop="tags">
|
||||
<el-select v-model="batchEditTagsFormData.tags" multiple>
|
||||
<el-option
|
||||
v-for="item in tagListResForBatchEdit.list"
|
||||
:key="item.name"
|
||||
:label="item.name"
|
||||
:value="item.name"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="batchEditTagVisible = false">{{ T('Cancel') }}</el-button>
|
||||
<el-button @click="submitBatchEditTags" type="primary">{{ T('Submit') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onActivated, onMounted, ref, watch } from 'vue'
|
||||
import { list as fetchTagList } from '@/api/tag'
|
||||
import { useRepositories } from '@/views/address_book'
|
||||
import { useBatchUpdateTagsRepositories, useRepositories } from '@/views/address_book'
|
||||
import { toWebClientLink } from '@/utils/webclient'
|
||||
import { T } from '@/utils/i18n'
|
||||
import shareByWebClient from '@/views/address_book/components/shareByWebClient.vue'
|
||||
@@ -166,6 +185,9 @@
|
||||
import { handleClipboard } from '@/utils/clipboard'
|
||||
import { CopyDocument } from '@element-plus/icons'
|
||||
import PlatformIcons from '@/components/icons/platform.vue'
|
||||
import { batchUpdateTags } from '@/api/address_book'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useRepositories as useTagRepositories } from '@/views/tag'
|
||||
|
||||
const is_my = 1
|
||||
const appStore = useAppStore()
|
||||
@@ -199,6 +221,31 @@
|
||||
watch(() => listQuery.page, getList)
|
||||
|
||||
watch(() => listQuery.page_size, handlerQuery)
|
||||
|
||||
const {
|
||||
tagListRes: tagListResForBatchEdit,
|
||||
getTagList: getTagListForBatchEdit,
|
||||
visible: batchEditTagVisible,
|
||||
show: showBatchEditTags,
|
||||
formData: batchEditTagsFormData,
|
||||
submit: _submitBatchEditTags,
|
||||
} = useBatchUpdateTagsRepositories(is_my)
|
||||
onMounted(getTagListForBatchEdit)
|
||||
const submitBatchEditTags = async () => {
|
||||
const res = await _submitBatchEditTags().catch(_ => false)
|
||||
if (res) {
|
||||
getList()
|
||||
}
|
||||
}
|
||||
|
||||
const multipleSelection = ref([])
|
||||
const handleSelectionChange = (val) => {
|
||||
multipleSelection.value = val
|
||||
|
||||
batchEditTagsFormData.value.row_ids = val.map(v => v.row_id)
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</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="primary" @click="toBatchAddToAB">{{ T('BatchAddToAB') }}</el-button>
|
||||
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
@@ -147,6 +149,31 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="batchABFormVisible" width="800" :title="T('Create')">
|
||||
<el-form class="dialog-form" ref="form" :model="batchABFormData" label-width="120px">
|
||||
<el-form-item :label="T('AddressBookName')" required prop="collection_id">
|
||||
<el-select v-model="batchABFormData.collection_id" clearable @change="changeCollection">
|
||||
<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-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="T('Tags')" prop="tags">
|
||||
<el-select v-model="batchABFormData.tags" multiple>
|
||||
<el-option
|
||||
v-for="item in tagListRes.list"
|
||||
:key="item.name"
|
||||
:label="item.name"
|
||||
:value="item.name"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="batchABFormVisible = false">{{ T('Cancel') }}</el-button>
|
||||
<el-button @click="submitBatchAddToAB" type="primary">{{ T('Submit') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -164,6 +191,7 @@
|
||||
import { connectByClient } from '@/utils/peer'
|
||||
import { CopyDocument } from '@element-plus/icons'
|
||||
import { handleClipboard } from '@/utils/clipboard'
|
||||
import { batchCreateFromPeers } from '@/api/address_book'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const listRes = reactive({
|
||||
@@ -282,8 +310,8 @@
|
||||
tagListRes,
|
||||
changeCollection,
|
||||
submit: ABSubmit,
|
||||
fromPeer
|
||||
} = useABRepositories()
|
||||
fromPeer,
|
||||
} = useABRepositories(1)
|
||||
onMounted(getCollectionList)
|
||||
const toAddressBook = (peer) => {
|
||||
fromPeer(peer)
|
||||
@@ -314,6 +342,36 @@
|
||||
getList()
|
||||
}
|
||||
}
|
||||
|
||||
const batchABFormVisible = ref(false)
|
||||
const toBatchAddToAB = () => {
|
||||
batchABFormVisible.value = true
|
||||
}
|
||||
const batchABFormData = ref({
|
||||
collection_id: 0,
|
||||
tags: [],
|
||||
peer_ids: [],
|
||||
})
|
||||
const submitBatchAddToAB = async () => {
|
||||
if (multipleSelection.value.length === 0) {
|
||||
ElMessage.warning(T('PleaseSelectData'))
|
||||
return false
|
||||
}
|
||||
batchABFormData.value.peer_ids = multipleSelection.value.map(i => i.row_id)
|
||||
if (!batchABFormData.value.peer_ids.length) {
|
||||
ElMessage.warning(T('PleaseSelectData'))
|
||||
return false
|
||||
}
|
||||
|
||||
const res = await batchCreateFromPeers(batchABFormData.value).catch(_ => false)
|
||||
if (res) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
batchABFormVisible.value = false
|
||||
getList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -106,12 +106,6 @@ export function useRepositories (is_my = 0) {
|
||||
getList()
|
||||
}
|
||||
}
|
||||
onMounted(getList)
|
||||
onActivated(getList)
|
||||
|
||||
watch(() => listQuery.page, getList)
|
||||
|
||||
watch(() => listQuery.page_size, handlerQuery)
|
||||
|
||||
const formVisible = ref(false)
|
||||
const formData = reactive({
|
||||
|
||||
Reference in New Issue
Block a user