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: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: '',
|
||||
values: ['windows', 'android', 'mac', 'linux'],
|
||||
},
|
||||
color: {
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
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 { 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({
|
||||
list: [], total: 0, loading: false,
|
||||
})
|
||||
const listQuery = reactive({
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
is_my,
|
||||
name: null,
|
||||
user_id: null,
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
listRes.loading = true
|
||||
const res = await list(listQuery).catch(_ => false)
|
||||
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||
listRes.loading = false
|
||||
if (res) {
|
||||
listRes.list = res.data.list
|
||||
@@ -42,7 +47,7 @@ export function useRepositories (is_my) {
|
||||
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) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
getList()
|
||||
@@ -72,7 +77,7 @@ export function useRepositories (is_my) {
|
||||
|
||||
}
|
||||
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)
|
||||
if (res) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
toEdit,
|
||||
toAdd,
|
||||
submit,
|
||||
} = useRepositories()
|
||||
} = useRepositories('admin')
|
||||
|
||||
listQuery.is_my = 0
|
||||
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
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 { T } from '@/utils/i18n'
|
||||
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
||||
import { useRepositories as useTagRepositories } from '@/views/tag/index'
|
||||
import { loadAllUsers } from '@/global'
|
||||
import { simpleData } from '@/api/peer'
|
||||
|
||||
export function useRepositories (is_my = 0) {
|
||||
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
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: collectionListRes,
|
||||
listQuery: collectionListQuery,
|
||||
getList: getCollectionList,
|
||||
} = useCollectionRepositories(is_my)
|
||||
} = useCollectionRepositories(api_type)
|
||||
collectionListQuery.page_size = 9999
|
||||
const {
|
||||
listRes: tagListRes,
|
||||
listQuery: tagListQuery,
|
||||
getList: getTagList,
|
||||
} = useTagRepositories(is_my)
|
||||
tagListQuery.page_size = 9999
|
||||
|
||||
const listRes = reactive({
|
||||
list: [], total: 0, loading: false,
|
||||
@@ -30,7 +26,6 @@ export function useRepositories (is_my = 0) {
|
||||
const listQuery = reactive({
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
is_my,
|
||||
id: null,
|
||||
user_id: null,
|
||||
username: null,
|
||||
@@ -40,7 +35,7 @@ export function useRepositories (is_my = 0) {
|
||||
|
||||
const getList = async () => {
|
||||
listRes.loading = true
|
||||
const res = await list(listQuery).catch(_ => false)
|
||||
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||
listRes.loading = false
|
||||
if (res) {
|
||||
const ids = res.data.list.map(item => item.id)
|
||||
@@ -78,13 +73,14 @@ export function useRepositories (is_my = 0) {
|
||||
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) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
getList()
|
||||
}
|
||||
}
|
||||
|
||||
//创建或者修改
|
||||
const platformList = [
|
||||
{ label: 'Windows', value: 'Windows', icon: 'windows' },
|
||||
{ label: 'Linux', value: 'Linux', icon: 'linux' },
|
||||
@@ -112,6 +108,18 @@ export function useRepositories (is_my = 0) {
|
||||
'username': '',
|
||||
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) => {
|
||||
formVisible.value = true
|
||||
@@ -119,9 +127,9 @@ export function useRepositories (is_my = 0) {
|
||||
Object.keys(formData).forEach(key => {
|
||||
formData[key] = row[key]
|
||||
})
|
||||
collectionListQuery.user_id = row.user_id
|
||||
getCollectionList()
|
||||
collectionListQueryForUpdate.user_id = row.user_id
|
||||
tagListQuery.collection_id = row.collection_id
|
||||
getCollectionListForUpdate()
|
||||
getTagList()
|
||||
|
||||
}
|
||||
@@ -147,7 +155,7 @@ export function useRepositories (is_my = 0) {
|
||||
|
||||
}
|
||||
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)
|
||||
if (res) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
@@ -155,16 +163,6 @@ export function useRepositories (is_my = 0) {
|
||||
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) => {
|
||||
tagListRes.list = []
|
||||
@@ -176,18 +174,18 @@ export function useRepositories (is_my = 0) {
|
||||
getCollectionList()
|
||||
}
|
||||
}
|
||||
const changeUser = async (val) => {
|
||||
const changeUserForUpdate = async (val) => {
|
||||
tagListRes.list = []
|
||||
formData.tags = []
|
||||
formData.collection_id = 0
|
||||
if (!val) {
|
||||
collectionListRes.list = []
|
||||
collectionListResForUpdate.list = []
|
||||
} else {
|
||||
collectionListQuery.user_id = val
|
||||
getCollectionList()
|
||||
collectionListQueryForUpdate.user_id = val
|
||||
getCollectionListForUpdate()
|
||||
}
|
||||
}
|
||||
const changeCollection = async (val) => {
|
||||
const changeCollectionForUpdate = async (val) => {
|
||||
tagListRes.list = []
|
||||
formData.tags = []
|
||||
tagListQuery.user_id = formData.user_id
|
||||
@@ -217,42 +215,38 @@ export function useRepositories (is_my = 0) {
|
||||
listQuery,
|
||||
getList,
|
||||
handlerQuery,
|
||||
del,
|
||||
collectionListQuery,
|
||||
getCollectionList,
|
||||
collectionListRes,
|
||||
changeQueryUser,
|
||||
|
||||
platformList,
|
||||
|
||||
del,
|
||||
|
||||
formVisible,
|
||||
formData,
|
||||
toEdit,
|
||||
toAdd,
|
||||
submit,
|
||||
shareToWebClientVisible,
|
||||
shareToWebClientForm,
|
||||
toShowShare,
|
||||
|
||||
collectionListQuery,
|
||||
getCollectionList,
|
||||
collectionListRes,
|
||||
|
||||
getCollectionListForUpdate,
|
||||
collectionListResForUpdate,
|
||||
changeUserForUpdate,
|
||||
changeCollectionForUpdate,
|
||||
tagListQuery,
|
||||
getTagList,
|
||||
tagListRes,
|
||||
|
||||
allUsers,
|
||||
getAllUsers,
|
||||
|
||||
changeQueryUser,
|
||||
changeUser,
|
||||
changeCollection,
|
||||
|
||||
fromPeer,
|
||||
}
|
||||
}
|
||||
|
||||
export function useBatchUpdateTagsRepositories (is_my = 0) {
|
||||
export function useBatchUpdateTagsRepositories () {
|
||||
const {
|
||||
listRes: tagListRes,
|
||||
listQuery: tagListQuery,
|
||||
getList: getTagList,
|
||||
} = useTagRepositories(is_my)
|
||||
} = useTagRepositories('my')
|
||||
tagListQuery.page_size = 9999
|
||||
|
||||
const visible = ref(false)
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
<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('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
|
||||
v-for="item in allUsers"
|
||||
:key="item.id"
|
||||
@@ -99,9 +99,9 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<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 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>
|
||||
@@ -162,7 +162,6 @@
|
||||
<el-switch v-model="formData.sameServer"></el-switch>
|
||||
</el-form-item>-->
|
||||
|
||||
|
||||
<el-form-item>
|
||||
<el-button @click="formVisible = false">{{ T('Cancel') }}</el-button>
|
||||
<el-button @click="submit" type="primary">{{ T('Submit') }}</el-button>
|
||||
@@ -179,9 +178,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onActivated, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { onActivated, onMounted, watch } from 'vue'
|
||||
import { useRepositories } from '@/views/address_book/index'
|
||||
import { toWebClientLink, getPeerSlat } from '@/utils/webclient'
|
||||
import { toWebClientLink } from '@/utils/webclient'
|
||||
import { T } from '@/utils/i18n'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { connectByClient } from '@/utils/peer'
|
||||
@@ -189,18 +188,19 @@
|
||||
import { handleClipboard } from '@/utils/clipboard'
|
||||
import { CopyDocument } from '@element-plus/icons'
|
||||
import PlatformIcons from '@/components/icons/platform.vue'
|
||||
|
||||
|
||||
import { loadAllUsers } from '@/global'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const route = useRoute()
|
||||
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
|
||||
const {
|
||||
listRes,
|
||||
listQuery,
|
||||
getList,
|
||||
handlerQuery,
|
||||
collectionListRes,
|
||||
|
||||
del,
|
||||
formVisible,
|
||||
platformList,
|
||||
@@ -208,19 +208,13 @@
|
||||
toEdit,
|
||||
toAdd,
|
||||
submit,
|
||||
// shareToWebClientVisible,
|
||||
// shareToWebClientForm,
|
||||
// toShowShare,
|
||||
collectionListRes,
|
||||
|
||||
changeUserForUpdate,
|
||||
changeCollectionForUpdate,
|
||||
collectionListResForUpdate,
|
||||
tagListRes,
|
||||
|
||||
allUsers, getAllUsers,
|
||||
|
||||
changeQueryUser,
|
||||
changeUser,
|
||||
changeCollection
|
||||
} = useRepositories()
|
||||
} = useRepositories('admin')
|
||||
|
||||
if (route.query?.user_id) {
|
||||
listQuery.user_id = parseInt(route.query.user_id)
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
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 { ElMessage, ElMessageBox } from 'element-plus'
|
||||
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({
|
||||
list: [], total: 0, loading: false,
|
||||
})
|
||||
@@ -13,12 +18,11 @@ export function useRepositories (is_my) {
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
collection_id: null,
|
||||
is_my,
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
listRes.loading = true
|
||||
const res = await list(listQuery).catch(_ => false)
|
||||
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||
listRes.loading = false
|
||||
if (res) {
|
||||
listRes.list = res.data.list
|
||||
@@ -43,7 +47,7 @@ export function useRepositories (is_my) {
|
||||
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) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
getList()
|
||||
@@ -79,7 +83,7 @@ export function useRepositories (is_my) {
|
||||
|
||||
}
|
||||
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)
|
||||
if (res) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
rules,
|
||||
groupUsersList,
|
||||
getGroupUsers,
|
||||
} = useRepositories(props.is_my)
|
||||
} = useRepositories(props.is_my ? 'my' : 'admin')
|
||||
|
||||
formData.collection_id = props.collection.id
|
||||
formData.user_id = props.collection.user_id
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
+20
-15
@@ -163,7 +163,7 @@
|
||||
<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('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
|
||||
v-for="item in allUsers"
|
||||
:key="item.id"
|
||||
@@ -173,9 +173,9 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<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 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-form-item>
|
||||
<!-- <el-form-item :label="T('Tags')" prop="tags">
|
||||
@@ -214,6 +214,7 @@
|
||||
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'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const listRes = reactive({
|
||||
@@ -345,16 +346,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
//添加到地址簿 start
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
onMounted(getAllUsers)
|
||||
const {
|
||||
platformList: ABPlatformList,
|
||||
formVisible: ABFormVisible,
|
||||
formData: ABFormData,
|
||||
fromPeer,
|
||||
changeCollection,
|
||||
collectionListRes,
|
||||
collectionListQuery,
|
||||
getCollectionList,
|
||||
} = useABRepositories()
|
||||
} = useABRepositories('admin')
|
||||
const toAddressBook = (peer) => {
|
||||
fromPeer(peer)
|
||||
ABFormVisible.value = true
|
||||
@@ -366,8 +366,6 @@
|
||||
ABFormVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
const tagList = ref([])
|
||||
const fetchTagListData = async (user_id) => {
|
||||
const res = await fetchTagList({ user_id }).catch(_ => false)
|
||||
@@ -381,8 +379,8 @@
|
||||
tagList.value = ls.map(item => ({ name: item }))
|
||||
}
|
||||
}
|
||||
onMounted(getAllUsers)
|
||||
onMounted(fetchTagListData)
|
||||
// 添加到地址簿 end
|
||||
|
||||
const multipleSelection = ref([])
|
||||
const handleSelectionChange = (val) => {
|
||||
@@ -409,11 +407,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 批量添加到地址簿
|
||||
const changeUser = (val) => {
|
||||
collectionListQuery.user_id = val
|
||||
// 批量添加到地址簿 start
|
||||
const {
|
||||
listRes: collectionListResForBatchCreateAB,
|
||||
listQuery: collectionListQueryForBatchCreateAB,
|
||||
getList: getCollectionListForBatchCreateAB,
|
||||
} = useCollectionRepositories('admin')
|
||||
collectionListQueryForBatchCreateAB.page_size = 9999
|
||||
const changeUserForBatchCreateAB = (val) => {
|
||||
batchABFormData.value.collection_id = 0
|
||||
getCollectionList()
|
||||
collectionListQueryForBatchCreateAB.user_id = val
|
||||
getCollectionListForBatchCreateAB()
|
||||
}
|
||||
const batchABFormVisible = ref(false)
|
||||
const toBatchAddToAB = () => {
|
||||
@@ -442,6 +446,7 @@
|
||||
batchABFormVisible.value = false
|
||||
}
|
||||
}
|
||||
// 批量添加到地址簿 end
|
||||
|
||||
</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 :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">
|
||||
@@ -59,95 +59,32 @@
|
||||
import { T } from '@/utils/i18n'
|
||||
import { remove, list, batchDelete } from '@/api/share_record'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useRepositories } from '@/views/share_record/index'
|
||||
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
getAllUsers()
|
||||
|
||||
const listRes = reactive({
|
||||
list: [], total: 0, loading: false,
|
||||
})
|
||||
const listQuery = reactive({
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
is_my: 0,
|
||||
user_id: null,
|
||||
})
|
||||
const {
|
||||
listRes,
|
||||
listQuery,
|
||||
getList,
|
||||
handlerQuery,
|
||||
del,
|
||||
multipleSelection,
|
||||
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)
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
+44
-29
@@ -1,20 +1,18 @@
|
||||
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 { useRoute } from 'vue-router'
|
||||
import { T } from '@/utils/i18n'
|
||||
import { loadAllUsers } from '@/global'
|
||||
import { useRepositories as useCollectionRepositories } from '@/views/address_book/collection'
|
||||
|
||||
export function useRepositories (is_my = 0) {
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
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: collectionListRes,
|
||||
listQuery: collectionListQuery,
|
||||
getList: getCollectionList,
|
||||
} = useCollectionRepositories(is_my)
|
||||
collectionListQuery.page_size = 9999
|
||||
//获取query
|
||||
const route = useRoute()
|
||||
const user_id = route.query?.user_id
|
||||
@@ -24,7 +22,6 @@ export function useRepositories (is_my = 0) {
|
||||
const listQuery = reactive({
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
is_my,
|
||||
user_id: user_id ? parseInt(user_id) : null,
|
||||
collection_id: null,
|
||||
})
|
||||
@@ -72,7 +69,7 @@ export function useRepositories (is_my = 0) {
|
||||
|
||||
const getList = async () => {
|
||||
listRes.loading = true
|
||||
const res = await list(listQuery).catch(_ => false)
|
||||
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||
listRes.loading = false
|
||||
if (res) {
|
||||
listRes.list = res.data.list.map(item => {
|
||||
@@ -100,7 +97,7 @@ export function useRepositories (is_my = 0) {
|
||||
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) {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
getList()
|
||||
@@ -112,12 +109,11 @@ export function useRepositories (is_my = 0) {
|
||||
id: 0,
|
||||
name: '',
|
||||
color: 0,
|
||||
user_id: 0,
|
||||
collection_id: 0,
|
||||
user_id: null,
|
||||
collection_id: null,
|
||||
})
|
||||
const currentColor = ref('')
|
||||
const activeChange = (c) => {
|
||||
console.log(c)
|
||||
currentColor.value = c
|
||||
}
|
||||
const toEdit = (row) => {
|
||||
@@ -137,7 +133,7 @@ export function useRepositories (is_my = 0) {
|
||||
formData.name = ''
|
||||
formData.color = ''
|
||||
formData.user_id = null
|
||||
formData.collection_id = 0
|
||||
formData.collection_id = null
|
||||
}
|
||||
const submit = async () => {
|
||||
console.log(formData)
|
||||
@@ -145,7 +141,7 @@ export function useRepositories (is_my = 0) {
|
||||
ElMessage.error('请选择颜色')
|
||||
return
|
||||
}
|
||||
const api = formData.id ? update : create
|
||||
const api = formData.id ? apis[api_type].update : apis[api_type].create
|
||||
const data = {
|
||||
...formData,
|
||||
color: rgba2flutterColor(formData.color),
|
||||
@@ -159,15 +155,13 @@ export function useRepositories (is_my = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
const changeQueryUser = async (val) => {
|
||||
listQuery.collection_id = null
|
||||
if (!val) {
|
||||
collectionListRes.list = []
|
||||
} else {
|
||||
collectionListQuery.user_id = val
|
||||
getCollectionList()
|
||||
}
|
||||
}
|
||||
//query form collection
|
||||
const {
|
||||
listRes: collectionListRes,
|
||||
listQuery: collectionListQuery,
|
||||
getList: getCollectionList,
|
||||
} = useCollectionRepositories(api_type)
|
||||
collectionListQuery.page_size = 9999
|
||||
const changeUser = async (val) => {
|
||||
formData.collection_id = 0
|
||||
if (!val) {
|
||||
@@ -177,6 +171,23 @@ export function useRepositories (is_my = 0) {
|
||||
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 {
|
||||
listRes,
|
||||
listQuery,
|
||||
@@ -192,8 +203,12 @@ export function useRepositories (is_my = 0) {
|
||||
currentColor,
|
||||
|
||||
collectionListRes,
|
||||
allUsers, getAllUsers,
|
||||
changeQueryUser,
|
||||
changeUser,
|
||||
getCollectionList,
|
||||
|
||||
collectionListResForUpdate,
|
||||
changeUserForUpdate,
|
||||
getCollectionListForUpdate,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+14
-7
@@ -3,7 +3,7 @@
|
||||
<el-card class="list-query" shadow="hover">
|
||||
<el-form inline label-width="120px">
|
||||
<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
|
||||
v-for="item in allUsers"
|
||||
:key="item.id"
|
||||
@@ -71,7 +71,7 @@
|
||||
<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-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
|
||||
v-for="item in allUsers"
|
||||
:key="item.id"
|
||||
@@ -83,7 +83,7 @@
|
||||
<el-form-item :label="T('AddressBookName')" prop="collection_id" required>
|
||||
<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>
|
||||
@@ -111,7 +111,10 @@
|
||||
import { onMounted, reactive, watch, ref, onActivated } from 'vue'
|
||||
import { useRepositories } from '@/views/tag/index'
|
||||
import { T } from '@/utils/i18n'
|
||||
import { loadAllUsers } from '@/global'
|
||||
|
||||
const { allUsers, getAllUsers } = loadAllUsers()
|
||||
onMounted(getAllUsers)
|
||||
const {
|
||||
listRes,
|
||||
listQuery,
|
||||
@@ -125,12 +128,16 @@
|
||||
submit,
|
||||
activeChange,
|
||||
currentColor,
|
||||
|
||||
collectionListRes,
|
||||
allUsers, getAllUsers,
|
||||
changeQueryUser,
|
||||
changeUser,
|
||||
} = useRepositories()
|
||||
onMounted(getAllUsers)
|
||||
// getCollectionList,
|
||||
|
||||
collectionListResForUpdate,
|
||||
changeUserForUpdate,
|
||||
// getCollectionListForUpdate,
|
||||
} = useRepositories('admin')
|
||||
|
||||
onMounted(getList)
|
||||
onActivated(getList)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user