diff --git a/src/components/SelectSaleRankingIndicators/index.module.scss b/src/components/SelectSaleRankingIndicators/index.module.scss new file mode 100644 index 0000000..f9e161d --- /dev/null +++ b/src/components/SelectSaleRankingIndicators/index.module.scss @@ -0,0 +1,6 @@ +.grid { + padding: 24px 40px; + display: grid; + grid-gap: 24px 24px; + grid-template-columns: 1fr 1fr; +} diff --git a/src/components/SelectSaleRankingIndicators/index.tsx b/src/components/SelectSaleRankingIndicators/index.tsx new file mode 100644 index 0000000..3958b8b --- /dev/null +++ b/src/components/SelectSaleRankingIndicators/index.tsx @@ -0,0 +1,68 @@ +import { FC, useEffect, useMemo, useState } from 'react' +import DropDownItem from '../dropDown-item' +import FilterButton from '../filterButton' +import { EnumMarketingDepartmentApi } from '@/api/index' +import { View } from '@tarojs/components' +import styles from './index.module.scss' + +type ChangedValue = string | number + +interface SelectSaleTypeProps { + onChange?: (value: ChangedValue) => void +} + +type EnumList = { + id: number + code: string + name: string +} +// 销售排行指标 +const SelectSaleRankingIndicators: FC = props => { + + const selectName = '排行指标' + + const { onChange } = props + console.log(props) + const { fetchData } = EnumMarketingDepartmentApi() + + const getData = async () => { + const res = await fetchData() + setEnumList([{ id: -1, code: '', name: '全部' }, ...res.data.list]) + } + + const [enumList, setEnumList] = useState([]) + + useEffect(() => { + getData() + }, []) + + const [currentValue, setCurrentValue] = useState(-1) + + const handleClick = (value: ChangedValue) => { + setCurrentValue(value) + onChange?.(value) + } + + const displayTitle = useMemo(() => { + if (currentValue === -1) { + return selectName + } + return !!enumList.length ? enumList.filter(option => option.id === currentValue)?.[0]?.name : selectName + }, [enumList, currentValue]) + + return ( + + + {!!enumList.length && + enumList.map((item: EnumList) => { + return ( + handleClick(item.id)}> + {item.name} + + ) + })} + + + ) +} +export default SelectSaleRankingIndicators diff --git a/src/components/SelectTimePicker/index.tsx b/src/components/SelectTimePicker/index.tsx index 3b0cc80..eed4faf 100644 --- a/src/components/SelectTimePicker/index.tsx +++ b/src/components/SelectTimePicker/index.tsx @@ -1,13 +1,14 @@ +import { formatDateTime } from '@/common/format' import { View, Text } from '@tarojs/components' import dayjs from 'dayjs' import { FC, useState } from 'react' import DropDownItem from '../dropDown-item' import FilterButton from '../filterButton' import IconFont from '../iconfont/iconfont' -import TimePicker from '../timePicker' +import TimePickerPopup from '../timePickerPopup' import styles from './index.module.scss' -type ChangedValue = string | number +export type ChangedValue = string[] interface SelectSaleTypeProps { onChange?: (value: ChangedValue) => void @@ -16,8 +17,8 @@ interface SelectSaleTypeProps { const FilterTimeOptions = { '0': { name: '全部', - date_min: undefined, - date_max: undefined, + date_min: '', + date_max: '', }, '1': { name: '今天', @@ -64,50 +65,85 @@ const FilterTimeOptions = { .add(0, 'day') .format('YYYY-MM-DD')} 00:00:00`, }, -} as const + '6': { + name: '自定义时间', + date_min: '', + date_max: '', + }, +} type Key = keyof typeof FilterTimeOptions -type Value = (typeof FilterTimeOptions)[Key] +type Value = typeof FilterTimeOptions[Key] const SelectTimePicker: FC = props => { const { onChange: change } = props + const [currentValue, setCurrentValue] = useState('0') const [currentDate, setCurrentDate] = useState({ - start: new Date(), - end: new Date(), + start: new Date().toLocaleDateString(), + end: '', }) - + // 展示时间筛选 + const [showTime, setShowTime] = useState(false) + + // 点击关闭时间筛选 + const handClose = () => { + setShowTime(false) - const onSelectDate = time => { - console.log(time) - change?.(time) } const handleClick = (key: Key) => { setCurrentValue(key) + change?.([FilterTimeOptions[key].date_min, FilterTimeOptions[key].date_max]) + setCustomFilterButtonText('自定义时间') + } + // 选择时间 + const onSelectDate = event => { + console.log(event?.value, 'event?.value?.start') + setCurrentDate({ + start: event?.value?.start, + end: event?.value?.end, + }) + setShowTime(false) + setCustomFilterButtonText(`${formatDateTime(event?.value?.start, 'YYYY年MM月DD日')} 至 ${formatDateTime(event?.value?.end, 'YYYY年MM月DD日')}`) + change?.([event?.value?.start, event?.value?.end]) + } + + const [customFilterButtonText, setCustomFilterButtonText] = useState('自定义时间') + + // 点击自定义时间 + const handleCustomTime = () => { + setCurrentValue('6') + setShowTime(true) } return ( - - - {Object.entries(FilterTimeOptions).map(([key, value]) => { - return ( - handleClick(key as Key)}> - {value.name} - - ) - })} - handleClick('6' as Key)}> - 自定义时间 - - - - - - - + <> + + + {Object.entries(FilterTimeOptions) + .slice(0, -1) + .map(([key, value]) => { + return ( + handleClick(key as Key)}> + {value.name} + + ) + })} + + {customFilterButtonText} + + + + + + ) } export default SelectTimePicker diff --git a/src/components/cell/index.tsx b/src/components/cell/index.tsx index f5c65ee..abdb217 100644 --- a/src/components/cell/index.tsx +++ b/src/components/cell/index.tsx @@ -5,7 +5,7 @@ import IconFont, { IconNames } from "../iconfont/iconfont" import styles from './index.module.scss' interface CellPropsType { - title: string + title: string | React.ReactNode desc: string isLink?: boolean onClick?: () => void @@ -28,7 +28,7 @@ const Cell:FC = (props) => { {iconName && } - {title} + {title} {desc} diff --git a/src/pages/saleStatistic/index.module.scss b/src/pages/saleStatistic/index.module.scss index 2f4d103..0e8f290 100644 --- a/src/pages/saleStatistic/index.module.scss +++ b/src/pages/saleStatistic/index.module.scss @@ -1,4 +1,11 @@ +page { + height: 100%; + overflow: hidden; +} .saleStatistic { + display: flex; + flex-flow: column nowrap; + height: 100%; &--filterBar { display: flex; flex-flow: row nowrap; @@ -7,4 +14,40 @@ width: 100%; background-color: white; } + &--content { + flex: 1 1 auto; + padding-top: 24px; + overflow-y: scroll; + } +} +.title { + margin: 0 10px; + font-size: $font_size; + color: $color_font_one; +} +.cell-desc { + font-weight: 550; + color: $color_font_one; + font-size: 34px; +} +.totalSummary { + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; + padding: 24px 0; + &--title { + font-size: $font_size; + margin: 0 10px; + color: $color_font_three; + } + &--current { + color: $color_main; + font-size: 42px; + font-weight: 550; + } + &--totalNum { + color: $color_font_three; + font-size: $font_size; + } } diff --git a/src/pages/saleStatistic/index.tsx b/src/pages/saleStatistic/index.tsx index 07652e3..2c6e6a0 100644 --- a/src/pages/saleStatistic/index.tsx +++ b/src/pages/saleStatistic/index.tsx @@ -1,45 +1,33 @@ import AtCalendar from '@/components/calendar' +import Cell from '@/components/cell' +import Divider from '@/components/Divider' import DropDownItem, { DropDownOptions } from '@/components/dropDown-item' +import Iconfont from '@/components/iconfont/iconfont' +import LayoutBlock from '@/components/layoutBlock' import SelectMarketingDepartment from '@/components/SelectMarketingDepartment' +import SelectSaleRankingIndicators from '@/components/SelectSaleRankingIndicators' import SelectSaleType from '@/components/SelectSaleType' -import SelectTimePicker from '@/components/SelectTimePicker' +import SelectTimePicker, { ChangedValue } from '@/components/SelectTimePicker' import TimePicker from '@/components/timePicker' -import { View } from '@tarojs/components' +import { View, Text } from '@tarojs/components' import classnames from 'classnames' import dayjs from 'dayjs' import { useState } from 'react' import styles from './index.module.scss' const saleStatistic = () => { - const [options, setOptions] = useState([ - { - text: 'name', - value: 0, - }, - { - text: 'name1', - value: 1, - }, - { - text: 'name2', - value: 2, - }, - { - text: 'name3', - value: 3, - }, - ]) - - const onChangeTimePicker = (value) => { + const onChangeTimePicker = (value: ChangedValue) => { console.log(value) } - const onChangeSaleType = (saleType) => { - console.log(saleType) - + const onChangeSaleType = (saleType: number) => { + console.log('saleType', saleType) + } + const onChangeDepartment = (department: number) => { + console.log('department', department) } - const onChangeDepartment = (department) => { - console.log(department) + const onChangeIndicators = (indicators: number) => { + console.log('indicators', indicators) } return ( @@ -49,6 +37,216 @@ const saleStatistic = () => { + + + + + 订单 + + + + + 订单总数 + + + 3425 + (共432423匹) + + + 待配布订单 + + + } + desc={'323'} + customClassName={styles['cell-desc']}> + + 已配布订单 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + + + + 配布 + + + + + 已配布匹数 + + + 3425 + (共计 ¥231.23w) + + + 待收款单数 + + + } + desc={'323'} + customClassName={styles['cell-desc']}> + + 待收款匹数 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + 待收款金额 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + + 待发货单数 + + + } + desc={'323'} + customClassName={styles['cell-desc']}> + + 待发货匹数 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + 待发货金额 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + + 已发货单数 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + 已发货匹数 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + 已发货金额 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + + + + 货款 + + + + + 货款金额 + + + 56133.32 + + + 未收金额 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + 已收金额 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + + + + 退货 + + + + + 退货单数 + + + 42 + + + 退货匹数 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + 退货金额 + + + } + desc={'2972'} + customClassName={styles['cell-desc']}> + + {/* 销售排行 */} + + + + + 销售排行 + + + + + + + + ) }