123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <div>
- <a-row>
- <a-col :span="24">
- <div class="container search-container">
- <a-form
- layout="inline"
- :model="formState"
- @finish="handleFinish"
- @finishFailed="handleFinishFailed"
- >
- <a-form-item label="房间名称" name="roomTitle">
- <a-input
- v-model:value="formState.roomTitle"
- placeholder="房间名称"
- >
- </a-input>
- </a-form-item>
- <a-form-item label="使用时间" name="username">
- <a-range-picker
- :show-time="{ format: 'HH:mm' }"
- format="YYYY-MM-DD HH:mm"
- style="width: 80%"
- v-model:value="formState.userTime"
- />
- </a-form-item>
- <a-form-item>
- <a-button type="primary" html-type="submit"> 确定 </a-button>
- </a-form-item>
- </a-form>
- </div>
- </a-col>
- </a-row>
- <a-row>
- <div class="container">
- <a-table
- align="center"
- :columns="columns"
- :data-source="msgList"
- :pagination="pagination"
- bordered
- >
- <template #bodyCell="{ column, text }">
- <template v-if="column.dataIndex === 'firstInRoomTime'">
- {{ dayjs(text).format('YYYY-MM-DD HH:mm') }}
- </template>
- <template v-if="column.dataIndex === 'lastOutRoomTime'">
- {{ dayjs(text).format('YYYY-MM-DD HH:mm') }}
- </template>
- <template v-if="column.dataIndex === 'texts'">
- {{ text.join(';') }}
- </template>
- </template>
- </a-table>
- </div>
- </a-row>
- </div>
- </template>
- <script lang="ts" setup>
- import { computed, onMounted, UnwrapRef, reactive } from 'vue'
- import { TableColumnProps } from 'ant-design-vue'
- import { useStatisticStore } from '@/store/modules/statistic'
- import dayjs from 'dayjs'
- const statisticStore = useStatisticStore()
- const msgList = computed(() => statisticStore.roomMsg.list)
- const pagination = reactive({
- current: 1,
- total: statisticStore.roomMsg.total,
- pageSize: 20, //每页中显示10条数据
- showSizeChanger: true,
- pageSizeOptions: ['10', '20', '50', '100'], //每页中显示的数据
- showTotal: (total: string) => `共有 ${total} 条数据` //分页中显示总的数据
- })
- console.log('msgList', msgList)
- interface FormState {
- roomTitle: string
- userTime: string[]
- }
- const formState: UnwrapRef<FormState> = reactive({
- roomTitle: '',
- userTime: []
- })
- const columns: TableColumnProps[] = [
- {
- title: '昵称',
- dataIndex: 'nickName'
- },
- {
- title: '手机号',
- // className: 'column-money',
- dataIndex: 'phoneNumber'
- },
- {
- title: '房间名称',
- dataIndex: 'roomTitle'
- },
- {
- title: '时长/分',
- dataIndex: 'onlineTime',
- width: 120
- },
- {
- title: '初次进入房间',
- dataIndex: 'firstInRoomTime',
- width: 200
- },
- {
- title: '最后离开房间',
- dataIndex: 'lastOutRoomTime',
- width: 200
- },
- {
- title: '数量',
- dataIndex: 'textCount',
- width: 80
- },
- {
- title: '留言内容',
- dataIndex: 'texts',
- width: 140
- }
- ]
- onMounted(async () => {
- await statisticStore.fetchRoomMsglist({
- pageNum: 1,
- pageSize: 20,
- startTime: '',
- endTime: ''
- })
- })
- const handleFinish = () => {
- try {
- statisticStore.fetchRoomMsglist({
- startTime: formState.userTime ? formState.userTime[0] : '',
- endTime: formState.userTime ? formState.userTime[1] : '',
- pageNum: 1,
- pageSize: 20,
- roomTitle: formState.roomTitle
- })
- } catch (error) {
- console.error('error', error)
- }
- }
- const handleFinishFailed = () => {}
- </script>
- <style lang="less">
- .container {
- background-color: #fff;
- padding: 25px;
- width: 100%;
- margin-bottom: 25px;
- }
- </style>
|