From e8f050bcbbab41bdb27ca8e5795ac5d06e266e76 Mon Sep 17 00:00:00 2001 From: czm <2192718639@qq.com> Date: Mon, 9 Jan 2023 19:30:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(=E7=A0=81=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=97=A5=E6=9C=9F=E4=BC=98=E5=8C=96):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/timePicker/index.tsx | 4 +-- .../codeList/components/codeModel/index.tsx | 29 ++++++++++++++----- src/pages/codeList/index.tsx | 3 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/components/timePicker/index.tsx b/src/components/timePicker/index.tsx index ef69af0..a1dd230 100644 --- a/src/components/timePicker/index.tsx +++ b/src/components/timePicker/index.tsx @@ -18,8 +18,8 @@ const TimePicker = (props: Props) => { const handTime = (e) => { const { start, end } = e.value - // 如果选的是同一天的日期, end 自动加一天 if (!end) { + // 如果选的是同一天的日期, end 自动加一天 // 判断如果没选下一天的时候 e.value.end = `${dayjs(new Date(start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00` } @@ -35,7 +35,7 @@ const TimePicker = (props: Props) => { setTime(e) } const currentDate = useMemo(() => { - return (!start && !end) ? null : { start, end } + return (!start && !end) ? { start: `${dayjs(new Date()).format('YYYY-MM-DD')} 00:00:00`, end } : { start, end } }, [props]) // 由于小程序的bug,部分ios和安卓显示时间的时候会有问题,原因是格式化时有`-`这个横杠 return ( diff --git a/src/pages/codeList/components/codeModel/index.tsx b/src/pages/codeList/components/codeModel/index.tsx index 6bbd847..0149b87 100644 --- a/src/pages/codeList/components/codeModel/index.tsx +++ b/src/pages/codeList/components/codeModel/index.tsx @@ -1,18 +1,16 @@ import { Text, View } from '@tarojs/components' import { useDidHide, useDidShow } from '@tarojs/taro' -import { useEffect, useRef, useState } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' import ColorItem from '../colorItem' import styles from './index.module.scss' import IconFont from '@/components/iconfont/iconfont' import SelectList from '@/components/selectList' import Search from '@/components/search' import { GetCustomCodeLApi } from '@/api/codeManage' +import TimePickerPopup from '@/components/timePickerPopup' +import { alert } from '@/common/common' -interface ParamType { - onClickData: () => void -} -export default (props: ParamType) => { - const { onClickData } = props +export default () => { const [formData, setFormData] = useState<{ sale_start_time?: string; sale_end_time?: string; any_query?: string }|null>(null) // 获取码单列表 const [list, setList] = useState([]) @@ -32,12 +30,26 @@ export default (props: ParamType) => { }) const onSearch = (val) => { - formData == null ? setFormData(() => ({ any_query: val })) : setFormData(e => ({ ...e, any_query: val })) + setFormData(e => ({ ...e, any_query: val })) } + + const [showTime, setShowTime] = useState(false) + const handClose = useCallback(() => { + setShowTime(false) + }, []) + const onSelectDate = useCallback((val) => { + if (!val.value?.start && !val.value?.end) { + alert.error('请选择日期') + } + else { + setFormData(e => ({ ...e, sale_start_time: val.value.start, sale_end_time: val.value.end })) + } + console.log('val::', val) + }, []) return - + setShowTime(true)}> 日期 @@ -49,5 +61,6 @@ export default (props: ParamType) => { })} + } diff --git a/src/pages/codeList/index.tsx b/src/pages/codeList/index.tsx index 6ab083b..7b96f4b 100644 --- a/src/pages/codeList/index.tsx +++ b/src/pages/codeList/index.tsx @@ -1,5 +1,5 @@ import { View } from '@tarojs/components' -import { useEffect, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import styles from './index.module.scss' import CodeModel from './components/codeModel' import CompanyModel from './components/companyModel' @@ -17,6 +17,5 @@ export default () => { setSelectIndex(index)} /> {selectIndex == 1 && } {selectIndex == 2 && } - {/* */} }