From f7aa4f04ad409c31ad911cd87daeeeb6141cb3cb Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 8 Jul 2024 23:26:11 +0800 Subject: [PATCH] up --- src/constants.ts | 4 +- src/pages/Dashboard/BusinessViews.tsx | 79 +++++++++++++--- src/pages/Dashboard/ChannelStatistics.tsx | 90 ++++++++++++++++--- src/pages/Dashboard/ScanDetail.tsx | 82 +++++++++++------ src/pages/Dashboard/index.tsx | 76 ++++++++++++---- .../OperationsDashboard/BusinessDetail.tsx | 9 +- .../OperationsDashboard/ProductDetail.tsx | 9 +- src/pages/OperationsDashboard/index.tsx | 4 +- .../pop-b2b2c/pbcUserRecordLogController.ts | 15 ++++ src/services/pop-b2b2c/typings.d.ts | 9 ++ 10 files changed, 297 insertions(+), 80 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 6533e6d..090f679 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -102,8 +102,8 @@ const Constants = { * 新老客 */ pbcMembersType: { - 0: '新客', - 1: '老客' + 0: '老客', + 1: '新客' }, /** * 会员来源渠道 diff --git a/src/pages/Dashboard/BusinessViews.tsx b/src/pages/Dashboard/BusinessViews.tsx index e4d3a98..9fbe4e5 100644 --- a/src/pages/Dashboard/BusinessViews.tsx +++ b/src/pages/Dashboard/BusinessViews.tsx @@ -1,17 +1,17 @@ -import { - pbcUsersPageUsingPost, -} from '@/services/pop-b2b2c/pbcUsersController'; -import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; +import { businessViewRankUsingPost, exportBusinessViewRankUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController'; +import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-layout'; -import { Link, useAccess } from '@umijs/max'; +import { Link } from '@umijs/max'; +import { Button, message } from 'antd'; +import moment from 'moment'; import React, { useRef } from 'react'; /** * 查询表格 * @param param0 */ -const fetchData = async (params: API.PageVO) => { - const msg = await pbcUsersPageUsingPost(params); +const fetchData = async (params: API.PbcOperationalDashboardDTO) => { + const msg = await businessViewRankUsingPost(params); return { data: msg.data?.records, total: msg.data?.total, @@ -19,15 +19,44 @@ const fetchData = async (params: API.PageVO) => { } as any; }; +const handleExport = async (values?: API.PbcOperationalDashboardDTO) => { + + const hide = message.loading('正在处理', 0); + try { + await exportBusinessViewRankUsingPost( + { ...values }, + { + responseType: 'blob', + getResponse: true, + parseResponse: false, + data: { ...values, fileName: '导出' }, + }, + ); + hide(); + return false; + } catch (error) { + console.log(error); + hide(); + message.error('处理失败,请重试'); + return false; + } +}; + // eslint-disable-next-line @typescript-eslint/ban-types const TableList: React.FC<{}> = () => { const actionRef = useRef(); - const access: any = useAccess(); + const ref = useRef>(); - const columns: ProColumns[] = [ + const columns: ProColumns[] = [ + { + title: '序号', + width: 80, + dataIndex: 'serialNumber', + search: false + }, { title: '浏览次数', - dataIndex: 'pbcBusinessName', + dataIndex: 'pbcProductVisitCount', search: false }, { @@ -76,7 +105,7 @@ const TableList: React.FC<{}> = () => { width: 140, valueType: 'option', render: (text, record) => ( - 详情 + 详情 ), }, ]; @@ -87,17 +116,39 @@ const TableList: React.FC<{}> = () => { breadcrumb: {}, }} > - + columns={columns} actionRef={actionRef} - request={fetchData} - rowKey="pbcId" + request={(param: any) => { + const queryParam = { + ...param, + startDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[0] : undefined, + endDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[1] : undefined, + pbcCreateAt: undefined + } + return fetchData(queryParam); + }} + rowKey="businessId" size="small" bordered search={{ labelWidth: 'auto', span: 6, }} + formRef={ref} + toolbar={{ + actions: [ + + ] + }} pagination={{ defaultPageSize: 20, showSizeChanger: true, diff --git a/src/pages/Dashboard/ChannelStatistics.tsx b/src/pages/Dashboard/ChannelStatistics.tsx index 5d94b72..e8181c2 100644 --- a/src/pages/Dashboard/ChannelStatistics.tsx +++ b/src/pages/Dashboard/ChannelStatistics.tsx @@ -1,29 +1,62 @@ import Constants from '@/constants'; -import { - pbcUsersPageUsingPost, - } from '@/services/pop-b2b2c/pbcUsersController'; - import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; - import { PageContainer } from '@ant-design/pro-layout'; - import React, { useRef } from 'react'; +import { channelMerchantDetailUsingPost, exportChannelMerchantDetailUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController'; +import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/pro-components'; +import { PageContainer } from '@ant-design/pro-layout'; +import { useSearchParams } from '@umijs/max'; +import { Button, message } from 'antd'; +import moment from 'moment'; + import React, { useEffect, useRef } from 'react'; /** * 查询表格 * @param param0 */ - const fetchData = async (params: API.PageVO) => { - const msg = await pbcUsersPageUsingPost(params); + const fetchData = async (params: API.PbcOperationalDashboardDTO) => { + const msg = await channelMerchantDetailUsingPost(params); return { data: msg.data?.records, total: msg.data?.total, success: msg.retcode, } as any; }; + + const handleExport = async (values?: API.PbcOperationalDashboardDTO) => { + + const hide = message.loading('正在处理', 0); + try { + await exportChannelMerchantDetailUsingPost( + { ...values }, + { + responseType: 'blob', + getResponse: true, + parseResponse: false, + data: { ...values, fileName: '导出' }, + }, + ); + hide(); + return false; + } catch (error) { + console.log(error); + hide(); + message.error('处理失败,请重试'); + return false; + } + }; // eslint-disable-next-line @typescript-eslint/ban-types const TableList: React.FC<{}> = () => { const actionRef = useRef(); + const ref = useRef>(); + const [searchParams] = useSearchParams(); + const type = searchParams.get('type'); - const columns: ProColumns[] = [ + const columns: ProColumns[] = [ + { + title: '序号', + width: 80, + dataIndex: 'serialNumber', + search: false + }, { title: '商户编号', dataIndex: 'pbcBusinessCode', @@ -36,7 +69,7 @@ import { }, { title: '渠道', - dataIndex: 'pbcVisitSourceEnum', + dataIndex: 'pbcDataSource', valueType: 'select', valueEnum: Constants.pbcVisitSourceEnum }, @@ -46,9 +79,15 @@ import { width: 150, hideInTable: true, valueType: 'dateTimeRange', - render: (text, record) => record.pbcCreateAt, + render: (text, record: any) => record.pbcCreateAt, }, ]; + + useEffect(() => { + ref.current?.setFieldValue("pbcDataSource", type) + actionRef.current?.reload() + }, [type]) + return ( - + columns={columns} actionRef={actionRef} - request={fetchData} - rowKey="pbcId" + request={(param: any) => { + const queryParam = { + ...param, + pbcDataSource: param.pbcDataSource, + startDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[0] : undefined, + endDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[1] : undefined + } + return fetchData(queryParam); + }} + rowKey="serialNumber" size="small" bordered search={{ labelWidth: 'auto', span: 6, }} + formRef={ref} + toolbar={{ + actions: [ + + ] + }} + manualRequest={false} pagination={{ defaultPageSize: 20, showSizeChanger: true, diff --git a/src/pages/Dashboard/ScanDetail.tsx b/src/pages/Dashboard/ScanDetail.tsx index 68a7c6c..3a0114b 100644 --- a/src/pages/Dashboard/ScanDetail.tsx +++ b/src/pages/Dashboard/ScanDetail.tsx @@ -1,18 +1,17 @@ import Constants from '@/constants'; -import { - pbcUsersPageUsingPost, -} from '@/services/pop-b2b2c/pbcUsersController'; -import { handlePageQuery } from '@/utils/utils'; -import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; +import { exportPeopleScanDetailUsingPost, peopleScanDetailUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController'; +import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-layout'; +import { Button, message } from 'antd'; +import moment from 'moment'; import React, { useRef } from 'react'; /** * 查询表格 * @param param0 */ -const fetchData = async (params: API.PageVO) => { - const msg = await pbcUsersPageUsingPost(params); +const fetchData = async (params: API.PbcOperationalDashboardDTO) => { + const msg = await peopleScanDetailUsingPost(params); return { data: msg.data?.records, total: msg.data?.total, @@ -20,14 +19,38 @@ const fetchData = async (params: API.PageVO) => { } as any; }; +const handleExport = async (values?: API.PbcOperationalDashboardDTO) => { + + const hide = message.loading('正在处理', 0); + try { + await exportPeopleScanDetailUsingPost( + { ...values }, + { + responseType: 'blob', + getResponse: true, + parseResponse: false, + data: { ...values, fileName: '导出' }, + }, + ); + hide(); + return false; + } catch (error) { + console.log(error); + hide(); + message.error('处理失败,请重试'); + return false; + } +}; + // eslint-disable-next-line @typescript-eslint/ban-types const TableList: React.FC<{}> = () => { const actionRef = useRef(); + const ref = useRef>(); - const columns: ProColumns[] = [ + const columns: ProColumns[] = [ { title: '人员名称', - dataIndex: 'pbcUserNickName', + dataIndex: 'pbcUserName', search: false }, { @@ -37,7 +60,7 @@ const TableList: React.FC<{}> = () => { }, { title: '新老客', - dataIndex: 'pbcVipGradeName', + dataIndex: 'pbcUserType', valueType: 'select', valueEnum: Constants.pbcMembersType }, @@ -55,33 +78,40 @@ const TableList: React.FC<{}> = () => { breadcrumb: {}, }} > - + columns={columns} actionRef={actionRef} - request={(param: any) => { - console.log(param) - let hasUserType = false - if (param.pbcUserType) { - param.pbcUserType = parseInt(param.pbcUserType) - hasUserType = true - } - const queryParam = handlePageQuery(param); - if (!hasUserType && queryParam.filters) { - queryParam.filters.push({ - key: 'pbcUserType'.replace(/([A-Z])/g, '_$1').toLowerCase(), - value: 1, - action: '<=', - }); + request={(param) => { + const queryParam = { + ...param, + pbcNewCodeScanState: param.pbcUserType, + startDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[0] : undefined, + endDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[1] : undefined } return fetchData(queryParam); }} - rowKey="pbcId" + rowKey="serialNumber" size="small" bordered search={{ labelWidth: 'auto', span: 6, }} + formRef={ref} + toolbar={{ + actions: [ + + ] + }} pagination={{ defaultPageSize: 20, showSizeChanger: true, diff --git a/src/pages/Dashboard/index.tsx b/src/pages/Dashboard/index.tsx index 950a875..ac3db5a 100644 --- a/src/pages/Dashboard/index.tsx +++ b/src/pages/Dashboard/index.tsx @@ -1,11 +1,35 @@ -import { dashboardUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController'; +import { dashboardUsingPost, exportDashboardDetailUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController'; import { Bar, Pie, WordCloud, WordCloudConfig } from '@ant-design/plots'; import dayjs from 'dayjs'; import { PageContainer, ProCard, ProForm, ProFormDateRangePicker, ProFormGroup, ProFormInstance, ProFormRadio } from '@ant-design/pro-components'; -import { Card, Col, DatePickerProps, Row, Spin, Statistic } from 'antd'; +import { Button, Card, Col, DatePickerProps, message, Row, Spin, Statistic } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; import { querySearchKeyRankUsingPost } from '@/services/pop-b2b2c/pbcSearchKeyController'; import { history, Link } from '@umijs/max'; +import Constants from '@/constants'; + +const handleExport = async (values?: API.PbcDashBoardDTO) => { + + const hide = message.loading('正在处理', 0); + try { + await exportDashboardDetailUsingPost( + { ...values }, + { + responseType: 'blob', + getResponse: true, + parseResponse: false, + data: { ...values, fileName: '导出' }, + }, + ); + hide(); + return false; + } catch (error) { + console.log(error); + hide(); + message.error('处理失败,请重试'); + return false; + } +}; const Welcome: React.FC = () => { @@ -59,19 +83,11 @@ const Welcome: React.FC = () => { }, }; - const asyncFetch = () => { - fetch('https://gw.alipayobjects.com/os/antfincdn/jPKbal7r9r/mock.json') - .then((response) => response.json()) - .then((json) => setData5(json)) - .catch((error) => { - console.log('fetch data failed', error); - }); - }; const wordCloudConfig: WordCloudConfig = { data: data5, - wordField: 'x', - weightField: 'value', - colorField: 'x', + wordField: 'pbcSearchWord', + weightField: 'number', + colorField: 'pbcSearchWord', wordStyle: { fontFamily: 'Verdana', fontSize: [14, 60], @@ -128,6 +144,7 @@ const Welcome: React.FC = () => { value: e.pbcProductCollectCount } })) + setData5(res.data.searchWordListVO) } }).catch(() => { handleLoadChange(true) @@ -151,7 +168,6 @@ const Welcome: React.FC = () => { useEffect(() => { getData() - asyncFetch() }, []) return ( @@ -181,6 +197,20 @@ const Welcome: React.FC = () => { display: 'none', }, }, + render(props, dom) { + return [ + dom, + + ] + }, }} onFinish={async (values) => { console.log(values) @@ -258,14 +288,26 @@ const Welcome: React.FC = () => { plot.on('plot:click', (evt: { x: any; y: any; }) => { const { x, y } = evt; const tooltipData = plot.chart.getTooltipItems({ x, y }); - console.log(tooltipData); - history.push('/dashboard/channel-statistics') + console.log(tooltipData[0]); + let type = "" + if (tooltipData && tooltipData.length > 0) { + for (const key in Constants.pbcVisitSourceEnum) { + if (Object.prototype.hasOwnProperty.call(Constants.pbcVisitSourceEnum, key)) { + //@ts-ignore + const element = Constants.pbcVisitSourceEnum[key]; + if (element === tooltipData[0].name) { + type = key + } + } + } + } + history.push('/dashboard/channel-statistics?type='+type) }); }} /> - + diff --git a/src/pages/OperationsDashboard/BusinessDetail.tsx b/src/pages/OperationsDashboard/BusinessDetail.tsx index 1eb2cfd..80fa73f 100644 --- a/src/pages/OperationsDashboard/BusinessDetail.tsx +++ b/src/pages/OperationsDashboard/BusinessDetail.tsx @@ -4,6 +4,7 @@ import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/p import { PageContainer } from '@ant-design/pro-layout'; import { useSearchParams } from '@umijs/max'; import { Button, message } from 'antd'; +import moment from 'moment'; import React, { useRef } from 'react'; /** @@ -53,6 +54,7 @@ const TableList: React.FC<{}> = () => { const columns: ProColumns[] = [ { title: '序号', + width: 80, dataIndex: 'serialNumber', search: false }, @@ -118,13 +120,14 @@ const TableList: React.FC<{}> = () => { actionRef={actionRef} request={(param: any) => { const queryParam = { + ...param, userId: userId ? parseInt(userId) : undefined, startDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[0] : undefined, endDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[1] : undefined } return fetchData(queryParam); }} - rowKey="pbcId" + rowKey="serialNumber" size="small" bordered search={{ @@ -142,8 +145,8 @@ const TableList: React.FC<{}> = () => { const values = ref.current?.getFieldsValue(); const queryParam = { userId: userId ? parseInt(userId) : undefined, - startDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? values?.pbcCreateAt[0] : undefined, - endDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? values?.pbcCreateAt[1] : undefined + startDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? moment(values?.pbcCreateAt[0]).format("YYYY-MM-DD HH:mm:ss") : undefined, + endDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? moment(values?.pbcCreateAt[1]).format("YYYY-MM-DD HH:mm:ss") : undefined } handleExport(queryParam) }}>导出 diff --git a/src/pages/OperationsDashboard/ProductDetail.tsx b/src/pages/OperationsDashboard/ProductDetail.tsx index 1ca303f..139dbb2 100644 --- a/src/pages/OperationsDashboard/ProductDetail.tsx +++ b/src/pages/OperationsDashboard/ProductDetail.tsx @@ -4,6 +4,7 @@ import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/p import { PageContainer } from '@ant-design/pro-layout'; import { useSearchParams } from '@umijs/max'; import { Button, message } from 'antd'; +import moment from 'moment'; import React, { useRef } from 'react'; /** @@ -53,6 +54,7 @@ const TableList: React.FC<{}> = () => { const columns: ProColumns[] = [ { title: '序号', + width: 80, dataIndex: 'serialNumber', search: false }, @@ -102,13 +104,14 @@ const TableList: React.FC<{}> = () => { actionRef={actionRef} request={(param: any) => { const queryParam = { + ...param, userId: userId ? parseInt(userId) : undefined, startDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[0] : undefined, endDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[1] : undefined } return fetchData(queryParam); }} - rowKey="pbcId" + rowKey="serialNumber" size="small" bordered search={{ @@ -126,8 +129,8 @@ const TableList: React.FC<{}> = () => { const values: any = ref.current?.getFieldsValue(); const queryParam = { userId: userId ? parseInt(userId) : undefined, - startDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? values?.pbcCreateAt[0] : undefined, - endDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? values?.pbcCreateAt[1] : undefined + startDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? moment(values?.pbcCreateAt[0]).format("YYYY-MM-DD HH:mm:ss") : undefined, + endDate: values?.pbcCreateAt && values?.pbcCreateAt.length > 1 ? moment(values?.pbcCreateAt[1]).format("YYYY-MM-DD HH:mm:ss") : undefined } handleExport(queryParam) }}>导出 diff --git a/src/pages/OperationsDashboard/index.tsx b/src/pages/OperationsDashboard/index.tsx index 1100ba9..e9364f4 100644 --- a/src/pages/OperationsDashboard/index.tsx +++ b/src/pages/OperationsDashboard/index.tsx @@ -50,6 +50,7 @@ const TableList: React.FC<{}> = () => { const columns: ProColumns[] = [ { title: '序号', + width: 80, dataIndex: 'serialNumber', search: false }, @@ -104,12 +105,13 @@ const TableList: React.FC<{}> = () => { actionRef={actionRef} request={(param: any) => { const queryParam = { + ...param, userName: param.pbcUserName, roleId: param.pbcUserRole } return fetchData(queryParam); }} - rowKey="pbcId" + rowKey="serialNumber" size="small" bordered search={{ diff --git a/src/services/pop-b2b2c/pbcUserRecordLogController.ts b/src/services/pop-b2b2c/pbcUserRecordLogController.ts index 4983a71..7461469 100644 --- a/src/services/pop-b2b2c/pbcUserRecordLogController.ts +++ b/src/services/pop-b2b2c/pbcUserRecordLogController.ts @@ -95,6 +95,21 @@ export async function exportChannelMerchantDetailUsingPost( }); } +/** 导出仪表盘明细 POST /b2b2c/statical/exportDashboardDetail */ +export async function exportDashboardDetailUsingPost( + body: API.PbcDashBoardDTO, + options?: { [key: string]: any }, +) { + return request('/b2b2c/statical/exportDashboardDetail', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} + /** 导出运营人员的导入商户数据 POST /b2b2c/statical/exportOperationalBusinessData */ export async function exportOperationalBusinessDataUsingPost( body: API.PbcOperationalDashboardDTO, diff --git a/src/services/pop-b2b2c/typings.d.ts b/src/services/pop-b2b2c/typings.d.ts index 110c35b..79b101d 100644 --- a/src/services/pop-b2b2c/typings.d.ts +++ b/src/services/pop-b2b2c/typings.d.ts @@ -1330,7 +1330,9 @@ declare namespace API { }; type PbcBusinessViewCountVO = { + /** 商户名称 */ pbcBusinessName?: string; + /** 商户浏览量 */ pbcBusinessVisitCount?: number; }; @@ -1755,7 +1757,9 @@ declare namespace API { businessId?: number; /** 商户名称 */ businessName?: string; + /** 收藏次数 */ pbcProductCollectCount?: number; + /** 商品名称 */ pbcProductName?: string; }; @@ -1950,7 +1954,9 @@ declare namespace API { businessId?: number; /** 商户名称 */ businessName?: string; + /** 商品名称 */ pbcProductName?: string; + /** 商品浏览次数 */ pbcProductVisitCount?: number; }; @@ -2596,8 +2602,11 @@ declare namespace API { }; type PbcVisitStaticalVO = { + /** 链接数量 */ pbcLinkNumber?: number; + /** 扫码数量 */ pbcScanNumber?: number; + /** 分享数量 */ pbcShareNumber?: number; };