Commit d1aac3ae by pangchong

feat: 列表接口对接

parent 5e7fa399
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@alova/mock": "^1.5.1", "@alova/mock": "^1.5.1",
"@alova/scene-vue": "^1.5.0",
"@vueuse/core": "^10.9.0", "@vueuse/core": "^10.9.0",
"alova": "^2.17.0", "alova": "^2.17.0",
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
...@@ -68,6 +69,11 @@ ...@@ -68,6 +69,11 @@
"resolved": "https://registry.npmmirror.com/@alova/mock/-/mock-1.5.1.tgz", "resolved": "https://registry.npmmirror.com/@alova/mock/-/mock-1.5.1.tgz",
"integrity": "sha512-Ojt+hhn9ddexBWlWy2NeQn5SK+oOPPDJjvmJCV2Dg6W/NcBizdWur4pRjaUDskVB5CAhAewoZmGj4kStS5IkLw==" "integrity": "sha512-Ojt+hhn9ddexBWlWy2NeQn5SK+oOPPDJjvmJCV2Dg6W/NcBizdWur4pRjaUDskVB5CAhAewoZmGj4kStS5IkLw=="
}, },
"node_modules/@alova/scene-vue": {
"version": "1.5.0",
"resolved": "https://registry.npmmirror.com/@alova/scene-vue/-/scene-vue-1.5.0.tgz",
"integrity": "sha512-S/F/9I0psuscpan06H15CxkxwCDIb0FzpLqkykzsFjcHpfy44Cl4cDDP+pnSFHZrjWYl7Me7wjL3QJJYZaRj5A=="
},
"node_modules/@antfu/utils": { "node_modules/@antfu/utils": {
"version": "0.7.7", "version": "0.7.7",
"resolved": "https://registry.npmmirror.com/@antfu/utils/-/utils-0.7.7.tgz", "resolved": "https://registry.npmmirror.com/@antfu/utils/-/utils-0.7.7.tgz",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@alova/mock": "^1.5.1", "@alova/mock": "^1.5.1",
"@alova/scene-vue": "^1.5.0",
"@vueuse/core": "^10.9.0", "@vueuse/core": "^10.9.0",
"alova": "^2.17.0", "alova": "^2.17.0",
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
......
...@@ -48,15 +48,13 @@ export const alova = createAlova({ ...@@ -48,15 +48,13 @@ export const alova = createAlova({
} }
if (response.url.endsWith('/admin/getCaptcha')) { if (response.url.endsWith('/admin/getCaptcha')) {
return await response.blob() return await response.blob()
}
const json = await response.json()
if (json.code === 200) {
return json['data']
} else { } else {
return await response.json() return json
} }
// const json = await response.json()
// if (json.code === 200) {
// return json['data']
// } else {
// return json
// }
}, },
// 请求错误时将会进入该拦截器 // 请求错误时将会进入该拦截器
onError(error) { onError(error) {
......
...@@ -65,7 +65,7 @@ const ps = withDefaults(defineProps<Props>(), { ...@@ -65,7 +65,7 @@ const ps = withDefaults(defineProps<Props>(), {
placeholder: () => ['开始时间', '结束时间'], placeholder: () => ['开始时间', '结束时间'],
separator: '-', separator: '-',
format: 'YYYY-MM-DD', format: 'YYYY-MM-DD',
valueFormat: 'YYYYMMDD' valueFormat: 'YYYY-MM-DD'
}) })
const modelStartDate = defineModel('startDate') const modelStartDate = defineModel('startDate')
const modelEndDate = defineModel('endDate') const modelEndDate = defineModel('endDate')
......
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ContactsState } from './types' import { ContactsState } from './types'
export const CallState = { const CallState = {
callIn: 'callIn', callIn: 'callIn',
callOut: 'callout', callOut: 'callout',
calling: 'calling', calling: 'calling',
...@@ -9,13 +9,18 @@ export const CallState = { ...@@ -9,13 +9,18 @@ export const CallState = {
const useContactsStore = defineStore('contacts', { const useContactsStore = defineStore('contacts', {
state: (): ContactsState => { state: (): ContactsState => {
return { return {
showWait: false showWait: false,
chooseUser: undefined
} }
}, },
getters: {}, getters: {},
actions: { actions: {
//设置当前选中联系人
setChooseUser(info: ContactsState['chooseUser']) {
this.chooseUser = info
},
changeWait(val: boolean) { changeWait(val: boolean) {
this.showWait = val this.showWait = val
} }
......
export interface UserItemDto {
id: string
nickname: string
remark: string
videoGroup: 0 | 1
}
export interface ContactsState { export interface ContactsState {
showWait: boolean showWait: boolean //是否等待接通
chooseUser?: UserItemDto //当前选中的联系人
} }
...@@ -66,15 +66,15 @@ const handleLogin = async () => { ...@@ -66,15 +66,15 @@ const handleLogin = async () => {
} }
loginSuccess((respond) => { loginSuccess((respond) => {
const res = respond.data const res = respond.data
if (res.code == 200) { if (res.code == 500) {
userStore.setUserInfo(res.data)
Notification.success({
content: '登录成功'
})
} else {
Notification.error({ Notification.error({
content: res.message content: res.message
}) })
} else {
userStore.setUserInfo(res)
Notification.success({
content: '登录成功'
})
} }
}) })
//获取验证码 //获取验证码
......
<template> <template>
<div class="g-block"> <a-spin class="g-block" :loading="loading" tip="加载中...">
<div class="flex justify-between items-center h-10 px-4"> <div class="flex justify-between items-center h-10 px-4">
<span class="text-base">联系人</span> <span class="text-base">联系人</span>
<a-checkbox value="1">只显示在线人员</a-checkbox> <a-checkbox value="1">只显示在线人员</a-checkbox>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<a-tabs class="h-full"> <a-tabs class="h-full">
<a-tab-pane title="默认列表"> <a-tab-pane title="默认列表">
<div class="px-4"> <div class="px-4">
<a-input-search placeholder="搜索"></a-input-search> <a-input-search placeholder="搜索" v-model="searchParams.groupName"></a-input-search>
<a-button class="rounded-full my-4" type="primary" long style="min-height: 32px"> <a-button class="rounded-full my-4" type="primary" long style="min-height: 32px">
<template #icon> <template #icon>
<global-icon icon="plus-circle" :size="14" color="var(--color-bg-white)" /> <global-icon icon="plus-circle" :size="14" color="var(--color-bg-white)" />
...@@ -16,11 +16,8 @@ ...@@ -16,11 +16,8 @@
</a-button> </a-button>
</div> </div>
<a-collapse :bordered="false"> <a-collapse :bordered="false">
<a-collapse-item header="维修员列表" :key="1"> <a-collapse-item :header="key + '列表'" :key="index" v-for="(value, key, index) in getUserListGroup">
<contacts-list :data="list"></contacts-list> <contacts-list :data="value"></contacts-list>
</a-collapse-item>
<a-collapse-item header="专家列表" :key="2">
<contacts-list :data="list"></contacts-list>
</a-collapse-item> </a-collapse-item>
</a-collapse> </a-collapse>
</a-tab-pane> </a-tab-pane>
...@@ -28,11 +25,14 @@ ...@@ -28,11 +25,14 @@
<div class="px-4">我是群组列表</div> <div class="px-4">我是群组列表</div>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</div> </a-spin>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import contactsList from './contactsList.vue' import contactsList from './contactsList.vue'
import { alova } from '@/api/alova-instance'
import type { UserItemDto } from '@/store/contacts/types'
import { useRequest } from 'alova'
interface Props { interface Props {
showGroup?: boolean showGroup?: boolean
...@@ -40,26 +40,43 @@ interface Props { ...@@ -40,26 +40,43 @@ interface Props {
const ps = withDefaults(defineProps<Props>(), { const ps = withDefaults(defineProps<Props>(), {
showGroup: true showGroup: true
}) })
//联系人列表
interface UserItemDto {
id: string
nickname: string
remark: string
videoGroup: 0 | 1
}
const list = ref([
{ id: '1', name: '张三', phone: '13687222908', active: true },
{ id: '1', name: '张三', phone: '13687222908' },
{ id: '1', name: '张三', phone: '13687222908' },
{ id: '1', name: '张三', phone: '13687222908' },
{ id: '1', name: '张三', phone: '13687222908' },
{ id: '1', name: '张三', phone: '13687222908' },
{ id: '1', name: '张三', phone: '13687222908', disabled: true }
])
//是否显示群组列表 //是否显示群组列表
const getShowGroup = computed(() => { const getShowGroup = computed(() => {
return ps.showGroup ? 'block' : 'none' return ps.showGroup ? 'block' : 'none'
}) })
//联系人列表
const videoGroup: { [key in UserItemDto['videoGroup']]: string } = {
0: '专家',
1: '维修人'
}
const { loading, data: userList } = useRequest(
() =>
alova.Post<UserItemDto[]>('/admin/getUserListVideo', {
pageIndex: 1,
pageSize: 99999
}),
{
immediate: true
}
)
const searchParams = reactive({
groupName: ''
})
//获取联系人分组
const getUserListGroup = computed(() => {
return userList.value
?.sort((a, b) => a.videoGroup - b.videoGroup)
.reduce((result: any, item) => {
const groupName = videoGroup[item.videoGroup]
if (!result[groupName]) {
result[groupName] = []
}
if (item.nickname.indexOf(searchParams.groupName) != -1) {
result[groupName].push(item)
}
return result
}, {})
})
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@import './styles/contactsInfo.less'; @import './styles/contactsInfo.less';
......
<template> <template>
<template v-for="(item, index) in data" :key="item.id"> <template v-for="(item, index) in data" :key="item.id">
<div class="item flex items-center px-4 py-3 rounded cursor-pointer" :class="{ active: item.active }"> <div class="item flex items-center px-4 py-3 rounded cursor-pointer" :class="{ active: chooseUser?.id == item.id }" @click="handleClick(item)">
<global-avatar></global-avatar> <global-avatar></global-avatar>
<div class="ml-[9px] inline-block">张三</div> <div class="ml-[9px] inline-block">{{ item.nickname }}</div>
<div class="flex items-center ml-6"> <div class="flex items-center ml-6">
<global-icon icon="camera" :size="14" class="mr-2"></global-icon> <global-icon icon="camera" :size="14" class="mr-2"></global-icon>
<global-icon icon="mic" :size="14"></global-icon> <global-icon icon="mic" :size="14"></global-icon>
</div> </div>
<div class="flex-auto text-right"> <div class="flex-auto text-right">
<a-button type="primary" shape="circle" :disabled="item.disabled" @click.stop="handleCall"><global-icon icon="phone" :size="14" color="var(--color-bg-white)"></global-icon></a-button> <a-button type="primary" shape="circle" @click.stop="handleCall"><global-icon icon="phone" :size="14" color="var(--color-bg-white)"></global-icon></a-button>
</div> </div>
</div> </div>
</template> </template>
...@@ -16,18 +16,35 @@ ...@@ -16,18 +16,35 @@
<script setup lang="ts"> <script setup lang="ts">
import useContactsStore from '@/store/contacts/index' import useContactsStore from '@/store/contacts/index'
import { storeToRefs } from 'pinia'
interface UserItemDto {
id: string
nickname: string
remark: string
videoGroup: 0 | 1
}
interface Props { interface Props {
data?: Array<any> data?: Array<UserItemDto>
} }
const ps = withDefaults(defineProps<Props>(), { const ps = withDefaults(defineProps<Props>(), {
data: () => [] data: () => []
}) })
//拨打视频 //拨打视频
const { changeWait } = useContactsStore() const { changeWait, setChooseUser } = useContactsStore()
const handleCall = () => { const handleCall = () => {
changeWait(true) changeWait(true)
} }
//当前联系人
const { chooseUser } = storeToRefs(useContactsStore())
//点击联系人
const handleClick = (item: UserItemDto) => {
setChooseUser(item)
}
onBeforeUnmount(() => {
//清空当前联系人
setChooseUser(undefined)
})
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.item.active, .item.active,
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
<div class="g-block ml-4"> <div class="g-block ml-4">
<!-- 搜索条件 --> <!-- 搜索条件 -->
<div class="flex items-center justify-between mb-4 px-4"> <div class="flex items-center justify-between mb-4 px-4">
<range-pickey v-model:start-date="searchParams.startDate" v-model:end-date="searchParams.endDate"></range-pickey> <range-pickey v-model:start-date="beginTime" v-model:end-date="endTime"></range-pickey>
<a-input-search placeholder="搜索" class="w-[240px]"></a-input-search> <a-input-search placeholder="搜索" class="w-[240px]"></a-input-search>
</div> </div>
<!-- table展示 --> <!-- table展示 -->
<div class="flex-auto overflow-y-auto px-4"> <div class="flex-auto overflow-y-auto px-4">
<a-table :columns="columns" :data="tableData" :bordered="false"> <a-table :columns="columns" :data="tableData" :bordered="false" :loading="loading" @page-change="pageChange" @page-size-change="pageSizeChange">
<template #initiator="{ record }"> <template #initiator="{ record }">
<div class="flex items-center"> <div class="flex items-center">
<global-avatar :avatar-size="24" :icon-size="12"></global-avatar> <global-avatar :avatar-size="24" :icon-size="12"></global-avatar>
...@@ -23,13 +23,69 @@ ...@@ -23,13 +23,69 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { columns, tableData } from './constants/data.config' import { usePagination } from '@alova/scene-vue'
import { columns } from './constants/data.config'
import { alova } from '@/api/alova-instance'
import useContactsStore from '@/store/contacts/index'
import { storeToRefs } from 'pinia'
const beginTime = ref('')
const endTime = ref('')
//当前联系人
const { chooseUser } = storeToRefs(useContactsStore())
//表格搜索 //表格搜索
const searchParams = reactive({ const getEventList = (pageIndex: number, pageSize: number) => {
startDate: '', const params = {
endDate: '' userId: chooseUser?.value?.id,
}) pageIndex,
pageSize,
uid: 2,
projectName: 'mu'
} as any
if (beginTime.value) {
params.beginTime = beginTime.value
}
if (endTime.value) {
params.endTime = endTime.value
}
return alova.Post<any>('/call/getEventList', params)
}
const {
// 加载状态
loading,
// 列表数据
data: tableData,
// 是否为最后一页
// 下拉加载时可通过此参数判断是否还需要加载
isLastPage,
// 当前页码,改变此页码将自动触发请求
page,
// 每页数据条数
pageSize,
// 分页页数
pageCount,
// 总数据量
total
} = usePagination(
// Method实例获取函数,它将接收page和pageSize,并返回一个Method实例
(pageIndex: number, pageSize: number) => getEventList(pageIndex, pageSize),
{
watchingStates: [beginTime, endTime, () => chooseUser?.value?.id],
// 请求前的初始数据(接口返回的数据格式)
initialData: {
total: 0,
data: []
},
initialPage: 1, // 初始页码,默认为1
initialPageSize: 10, // 初始每页数据条数,默认为10
debounce: [800],
abortLast: true,
total: (res) => res.data.total,
data: (res) => res.data.list
}
)
const pageChange = () => {}
const pageSizeChange = () => {}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.arco-table-th) { :deep(.arco-table-th) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment