Split my and admin
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
toEdit,
|
||||
toAdd,
|
||||
submit,
|
||||
} = useRepositories(1)
|
||||
} = useRepositories('my')
|
||||
|
||||
onMounted(getList)
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@
|
||||
<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-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 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-form-item>
|
||||
<el-form-item label="ID" prop="id" required>
|
||||
@@ -174,7 +174,7 @@
|
||||
</template>
|
||||
|
||||
<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 { toWebClientLink } from '@/utils/webclient'
|
||||
import { T } from '@/utils/i18n'
|
||||
@@ -185,32 +185,33 @@
|
||||
import { CopyDocument } from '@element-plus/icons'
|
||||
import PlatformIcons from '@/components/icons/platform.vue'
|
||||
|
||||
const is_my = 1
|
||||
const appStore = useAppStore()
|
||||
|
||||
const {
|
||||
listRes,
|
||||
listQuery,
|
||||
getList,
|
||||
handlerQuery,
|
||||
collectionListRes,
|
||||
getCollectionList,
|
||||
|
||||
del,
|
||||
|
||||
formVisible,
|
||||
platformList,
|
||||
formData,
|
||||
toEdit,
|
||||
toAdd,
|
||||
submit,
|
||||
shareToWebClientVisible,
|
||||
shareToWebClientForm,
|
||||
toShowShare,
|
||||
// collectionListQuery,
|
||||
collectionListRes,
|
||||
getCollectionList,
|
||||
tagListRes,
|
||||
changeCollection,
|
||||
} = useRepositories(is_my)
|
||||
changeCollectionForUpdate,
|
||||
getCollectionListForUpdate,
|
||||
collectionListResForUpdate,
|
||||
// collectionListQuery,
|
||||
|
||||
} = useRepositories('my')
|
||||
|
||||
onMounted(getCollectionList)
|
||||
onMounted(getCollectionListForUpdate)
|
||||
onMounted(getList)
|
||||
onActivated(getList)
|
||||
|
||||
@@ -218,6 +219,16 @@
|
||||
|
||||
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 {
|
||||
tagListRes: tagListResForBatchEdit,
|
||||
getTagList: getTagListForBatchEdit,
|
||||
@@ -225,7 +236,7 @@
|
||||
show: showBatchEditTags,
|
||||
formData: batchEditTagsFormData,
|
||||
submit: _submitBatchEditTags,
|
||||
} = useBatchUpdateTagsRepositories(is_my)
|
||||
} = useBatchUpdateTagsRepositories()
|
||||
onMounted(getTagListForBatchEdit)
|
||||
const submitBatchEditTags = async () => {
|
||||
const res = await _submitBatchEditTags().catch(_ => false)
|
||||
|
||||
+22
-19
@@ -22,7 +22,7 @@
|
||||
<el-form-item>
|
||||
<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="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>-->
|
||||
<el-button type="primary" @click="toBatchAddToAB">{{ T('BatchAddToAB') }}</el-button>
|
||||
|
||||
</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 type="primary" @click="toAddressBook(row)">{{ T('AddToAddressBook') }}</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>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -105,9 +105,9 @@
|
||||
<el-dialog v-model="ABFormVisible" width="800" :title="T('Create')">
|
||||
<el-form class="dialog-form" ref="form" :model="ABFormData" label-width="120px">
|
||||
<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 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-form-item>
|
||||
<el-form-item label="ID" prop="id" required>
|
||||
@@ -153,9 +153,9 @@
|
||||
<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-select v-model="batchABFormData.collection_id" clearable @change="changeCollectionForBatchCreateAB">
|
||||
<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-form-item>
|
||||
<el-form-item :label="T('Tags')" prop="tags">
|
||||
@@ -179,8 +179,7 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, onActivated, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { batchRemove, remove } from '@/api/peer'
|
||||
import { myPeer } from '@/api/user'
|
||||
import { list } from '@/api/my/peer'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { toWebClientLink } from '@/utils/webclient'
|
||||
import { T } from '@/utils/i18n'
|
||||
@@ -191,7 +190,7 @@
|
||||
import { connectByClient } from '@/utils/peer'
|
||||
import { CopyDocument } from '@element-plus/icons'
|
||||
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 listRes = reactive({
|
||||
@@ -207,7 +206,7 @@
|
||||
|
||||
const getList = async () => {
|
||||
listRes.loading = true
|
||||
const res = await myPeer(listQuery).catch(_ => false)
|
||||
const res = await list(listQuery).catch(_ => false)
|
||||
listRes.loading = false
|
||||
if (res) {
|
||||
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') }), {
|
||||
confirmButtonText: T('Confirm'),
|
||||
cancelButtonText: T('Cancel'),
|
||||
@@ -237,7 +236,7 @@
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
getList()
|
||||
}
|
||||
}
|
||||
}*/
|
||||
onMounted(getList)
|
||||
onActivated(getList)
|
||||
|
||||
@@ -305,14 +304,14 @@
|
||||
platformList: ABPlatformList,
|
||||
formVisible: ABFormVisible,
|
||||
formData: ABFormData,
|
||||
collectionListRes,
|
||||
getCollectionList,
|
||||
collectionListResForUpdate,
|
||||
getCollectionListForUpdate,
|
||||
tagListRes,
|
||||
changeCollection,
|
||||
changeCollectionForUpdate,
|
||||
submit: ABSubmit,
|
||||
fromPeer,
|
||||
} = useABRepositories(1)
|
||||
onMounted(getCollectionList)
|
||||
} = useABRepositories('my')
|
||||
onMounted(getCollectionListForUpdate)
|
||||
const toAddressBook = (peer) => {
|
||||
fromPeer(peer)
|
||||
ABFormVisible.value = true
|
||||
@@ -322,7 +321,7 @@
|
||||
const handleSelectionChange = (val) => {
|
||||
multipleSelection.value = val
|
||||
}
|
||||
const toBatchDelete = async () => {
|
||||
/*const toBatchDelete = async () => {
|
||||
if (!multipleSelection.value.length) {
|
||||
ElMessage.warning(T('PleaseSelectData'))
|
||||
return false
|
||||
@@ -341,7 +340,7 @@
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
getList()
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
const batchABFormVisible = ref(false)
|
||||
const toBatchAddToAB = () => {
|
||||
@@ -352,6 +351,10 @@
|
||||
tags: [],
|
||||
peer_ids: [],
|
||||
})
|
||||
const changeCollectionForBatchCreateAB = (val) => {
|
||||
batchABFormData.value.tags = []
|
||||
changeCollectionForUpdate(val)
|
||||
}
|
||||
const submitBatchAddToAB = async () => {
|
||||
if (multipleSelection.value.length === 0) {
|
||||
ElMessage.warning(T('PleaseSelectData'))
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
||||
<el-table-column :label="`${T('ExpireTime')}(${T('Second')})`" prop="expire" align="center">
|
||||
<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>
|
||||
</el-table-column>
|
||||
<el-table-column :label="T('Actions')" align="center" width="400">
|
||||
@@ -39,95 +39,31 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onActivated, onMounted, ref, watch, reactive } from 'vue'
|
||||
import { onActivated, onMounted, watch } from 'vue'
|
||||
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 { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useRepositories } from '@/views/share_record'
|
||||
|
||||
const listRes = reactive({
|
||||
list: [], total: 0, loading: false,
|
||||
})
|
||||
const listQuery = reactive({
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
})
|
||||
const {
|
||||
listRes,
|
||||
listQuery,
|
||||
getList,
|
||||
handlerQuery,
|
||||
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)
|
||||
onActivated(getList)
|
||||
|
||||
watch(() => listQuery.page, getList)
|
||||
|
||||
watch(() => listQuery.page_size, handlerQuery)
|
||||
const multipleSelection = ref([])
|
||||
const handleSelectionChange = (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>
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<el-form-item :label="T('AddressBookName')">
|
||||
<el-select v-model="formData.collection_id" clearable>
|
||||
<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-form-item>
|
||||
<el-form-item :label="T('Name')" prop="name" required>
|
||||
@@ -86,7 +86,6 @@
|
||||
import { onMounted, watch, onActivated } from 'vue'
|
||||
import { useRepositories } from '@/views/tag'
|
||||
import { T } from '@/utils/i18n'
|
||||
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
||||
|
||||
const {
|
||||
listRes,
|
||||
@@ -101,9 +100,13 @@
|
||||
submit,
|
||||
activeChange,
|
||||
currentColor,
|
||||
} = useRepositories()
|
||||
|
||||
listQuery.is_my = 1
|
||||
collectionListRes,
|
||||
getCollectionList,
|
||||
|
||||
collectionListResForUpdate,
|
||||
getCollectionListForUpdate,
|
||||
} = useRepositories('my')
|
||||
|
||||
onMounted(getList)
|
||||
onActivated(getList)
|
||||
@@ -112,14 +115,8 @@
|
||||
|
||||
watch(() => listQuery.page_size, handlerQuery)
|
||||
|
||||
const {
|
||||
listRes: collectionListRes,
|
||||
listQuery: collectionListQuery,
|
||||
getList: getCollectionList,
|
||||
} = useCollectionRepositories()
|
||||
collectionListQuery.is_my = 1
|
||||
collectionListQuery.page_size = 999
|
||||
onMounted(getCollectionList)
|
||||
onMounted(getCollectionListForUpdate)
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user