Merge branch 'dev' of ssh://git.online.zzfzyc.com:10022/mp/spider_cloud_warehouse into 订单页

This commit is contained in:
Haiyi 2022-09-28 19:16:52 +08:00
commit 6b59d688db
5 changed files with 41 additions and 94 deletions

View File

@ -1,5 +1,6 @@
import { View, Text } from "@tarojs/components" import { View, Text } from "@tarojs/components"
import { memo } from "react" import { memo } from "react"
import IconFont from "../iconfont/iconfont"
import style from "./index.module.scss" import style from "./index.module.scss"
type Params = { type Params = {
@ -9,12 +10,10 @@ type Params = {
export default memo(({onClose, styleObj = {}}:Params) => { export default memo(({onClose, styleObj = {}}:Params) => {
return ( return (
<View <View style={styleObj} className={style.icon_a_cuowuwrong_self} onClick={onClose}>
style={styleObj} <View className={style.icon_a_btn}>
className={style.icon_a_cuowuwrong_self} <IconFont name='icon-guanbi' size={30} color='#ccc'></IconFont>
onClick={onClose}
>
<Text className={`iconfont icon-guanbi ${style.icon_a_btn}`}></Text>
</View> </View>
</View>
) )
}) })

View File

@ -19,7 +19,6 @@
height: 60px; height: 60px;
flex: 1 1 auto; flex: 1 1 auto;
padding-left: 60px; padding-left: 60px;
padding-right: 30px;
background: #eee; background: #eee;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;

View File

@ -14,7 +14,6 @@ import Taro from '@tarojs/taro'
interface SearchFilter { interface SearchFilter {
type?: number type?: number
timeKey?: string timeKey?: string
delivery_notice_order_no?: string
} }
export interface SearchField extends Omit<SearchFilter, 'timeKey'> { export interface SearchField extends Omit<SearchFilter, 'timeKey'> {
@ -77,7 +76,6 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
const [searchFilter, setSearchFilter] = useState<SearchFilter>({ const [searchFilter, setSearchFilter] = useState<SearchFilter>({
type: undefined, type: undefined,
timeKey: '0', timeKey: '0',
delivery_notice_order_no: '',
}) })
const handleSelectedType = (type: string | number) => { const handleSelectedType = (type: string | number) => {
console.log('type==>', type) console.log('type==>', type)
@ -89,11 +87,6 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
} }
const handleSearchBarChange = useCallback((searchValue: string) => {
console.log('searchValue==>', searchValue)
setSearchFilter((prevProps) => ({ ...prevProps, delivery_notice_order_no: searchValue }))
}, [])
const typeList = useMemo<{ id: number; name: string }[]>(() => { const typeList = useMemo<{ id: number; name: string }[]>(() => {
return state.data.list return state.data.list
}, [state]) }, [state])
@ -130,13 +123,12 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
} }
const handleReset = () => { const handleReset = () => {
setSearchFilter({ type: undefined, timeKey: '0', delivery_notice_order_no: '' }) setSearchFilter({ type: undefined, timeKey: '0' })
onReset?.() onReset?.()
} }
const handleConfirm = () => { const handleConfirm = () => {
const changedField = { const changedField = {
type: searchFilter.type, type: searchFilter.type,
delivery_notice_order_no: searchFilter.delivery_notice_order_no,
date_min: customTime.date_min, date_min: customTime.date_min,
date_max: customTime.date_max, date_max: customTime.date_max,
} }
@ -144,40 +136,8 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
onConfirm?.(changedField, searchFilter.timeKey) onConfirm?.(changedField, searchFilter.timeKey)
} }
const scanIcon = () => {
// 扫描
const handleScan = () => {
Taro.scanCode({
success(res) {
setSearchFilter((prevProps) => ({ ...prevProps, delivery_notice_order_no: res.result }))
},
fail(res) {
console.log(res)
},
})
}
return (
<View onClick={handleScan} className={styles.scanHandler}>
<IconFont name='icon-saomiao' size={40}></IconFont>
</View>
)
}
return ( return (
<> <>
<View className={styles.filterItem}>
<View className={styles['filterItem--title']}></View>
<View className={classnames(styles['filterItem--wrapper'], styles['filter--inputBar'])}>
<Search
placeholder='请输入或扫描条形码'
showBtn={false}
adjustPosition={true}
changeOnSearch={handleSearchBarChange}
debounceTime={300}
defaultValue={searchFilter.delivery_notice_order_no}
customRightSlot={scanIcon()}></Search>
</View>
</View>
<View className={styles.filterItem}> <View className={styles.filterItem}>
<View className={styles['filterItem--title']}></View> <View className={styles['filterItem--title']}></View>
<View className={classnames(styles['filterItem--wrapper'], styles['filter--type'])}> <View className={classnames(styles['filterItem--wrapper'], styles['filter--type'])}>

View File

@ -45,7 +45,7 @@ export const Shopping: FC = memo(() => {
) )
}) })
interface InternalContainer { } interface InternalContainer {}
const ShoppingCartContainer: FC<InternalContainer> = () => { const ShoppingCartContainer: FC<InternalContainer> = () => {
const { isManageStatus, setManageStatus, selectedAmount, currentCheckedPurchaserId, currentCheckedSaleMode, colorStore, setColorStore } = useShoppingContext() const { isManageStatus, setManageStatus, selectedAmount, currentCheckedPurchaserId, currentCheckedSaleMode, colorStore, setColorStore } = useShoppingContext()
@ -59,12 +59,17 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
const { fetchData, state } = ShoppingCartListApi() const { fetchData, state } = ShoppingCartListApi()
const [searchOptions, setSearchOptions] = useState({
short_name_or_phone: '',
})
useEffect(() => {
fetchData(searchOptions)
}, [searchOptions])
// 输入了搜索关键字 // 输入了搜索关键字
const getSearchData = useCallback(e => { const getSearchData = useCallback(e => {
fetchData({ short_name_or_phone: e }) setSearchOptions(prev => ({ ...prev, short_name_or_phone: e }))
// pageNum.current.page = 1
// setOrderData(() => ({ list: [], total: 0 }))
// setSearchField((val) => ({ ...val, name: e, size: 10 }))
}, []) }, [])
const [shoppingCartData, setShoppingCartData] = useState<{ list: ShoppingCartData[]; total: number }>({ list: [], total: 0 }) const [shoppingCartData, setShoppingCartData] = useState<{ list: ShoppingCartData[]; total: number }>({ list: [], total: 0 })
@ -104,7 +109,7 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
if (!targetGoodsKind) return Taro.showToast({ title: '请先选择客户', icon: 'error' }) if (!targetGoodsKind) return Taro.showToast({ title: '请先选择客户', icon: 'error' })
const checkedGoodsKind = Object.values(targetGoodsKind).reduce((prev, item: Goods) => { const checkedGoodsKind = Object.values(targetGoodsKind).reduce((prev, item: Goods) => {
if (item.checked) { if (item.checked) {
return [...prev,item.id] return [...prev, item.id]
} }
return prev return prev
}, []) }, [])
@ -153,6 +158,24 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
setColorStore(() => tempObject) setColorStore(() => tempObject)
} }
// 加载刷新数据
const [refreshStatus, setRefreshStatus] = useState(false)
// 下拉刷新
const handleRefresh = async () => {
setRefreshStatus(true)
const res = await fetchData(searchOptions)
if (res.success) {
console.log('请求 成功')
setRefreshStatus(false)
Taro.showToast({ title: '刷新成功', icon: 'success' })
} else {
console.log('请求 失败')
Taro.showToast({ title: '刷新失败', icon: 'error' })
setRefreshStatus(false)
}
}
return ( return (
<View className={classnames('flex-col', styles.shopping)} id='shoppingContainer'> <View className={classnames('flex-col', styles.shopping)} id='shoppingContainer'>
<View className={styles['shopping--topBar']} id='topBar'> <View className={styles['shopping--topBar']} id='topBar'>
@ -168,7 +191,11 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
</View> </View>
<View className={classnames('flex-item', 'flex-col', styles['shopping--context'])}> <View className={classnames('flex-item', 'flex-col', styles['shopping--context'])}>
<View className={classnames(styles.shopping__list__container, 'flex-item')} style={{ height: listHeight }}> <View className={classnames(styles.shopping__list__container, 'flex-item')} style={{ height: listHeight }}>
<InfiniteScroll statusMore={statusMore}> <InfiniteScroll
statusMore={statusMore}
refresherEnabled={true}
selfOnRefresherRefresh={handleRefresh}
refresherTriggered={refreshStatus}>
{!!shoppingCartData?.list?.length && {!!shoppingCartData?.list?.length &&
shoppingCartData?.list?.map((item, index) => { shoppingCartData?.list?.map((item, index) => {
return <ItemList itemData={item} key={index}></ItemList> return <ItemList itemData={item} key={index}></ItemList>

View File

@ -14,7 +14,6 @@ import Taro from '@tarojs/taro'
interface SearchFilter { interface SearchFilter {
take_goods_order_type?: number take_goods_order_type?: number
timeKey?: string timeKey?: string
take_goods_order_no?: string
} }
export interface SearchField extends Omit<SearchFilter, 'timeKey'> { export interface SearchField extends Omit<SearchFilter, 'timeKey'> {
@ -77,7 +76,6 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
const [searchFilter, setSearchFilter] = useState<SearchFilter>({ const [searchFilter, setSearchFilter] = useState<SearchFilter>({
take_goods_order_type: undefined, take_goods_order_type: undefined,
timeKey: '0', timeKey: '0',
take_goods_order_no: '',
}) })
const handleSelectedType = (type: string | number) => { const handleSelectedType = (type: string | number) => {
console.log('type==>', type) console.log('type==>', type)
@ -89,10 +87,6 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
} }
const handleSearchBarChange = useCallback((searchValue: string) => {
console.log('searchValue==>', searchValue)
setSearchFilter((prevProps) => ({ ...prevProps, take_goods_order_no: searchValue }))
}, [])
const typeList = useMemo<{ id: number; name: string }[]>(() => { const typeList = useMemo<{ id: number; name: string }[]>(() => {
return state.data.list return state.data.list
@ -130,13 +124,12 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
} }
const handleReset = () => { const handleReset = () => {
setSearchFilter({ take_goods_order_type: undefined, timeKey: '0', take_goods_order_no: '' }) setSearchFilter({ take_goods_order_type: undefined, timeKey: '0'})
onReset?.() onReset?.()
} }
const handleConfirm = () => { const handleConfirm = () => {
const changedField = { const changedField = {
take_goods_order_type: searchFilter.take_goods_order_type, take_goods_order_type: searchFilter.take_goods_order_type,
take_goods_order_no: searchFilter.take_goods_order_no,
date_min: customTime.date_min, date_min: customTime.date_min,
date_max: customTime.date_max, date_max: customTime.date_max,
} }
@ -144,40 +137,9 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
onConfirm?.(changedField, searchFilter.timeKey) onConfirm?.(changedField, searchFilter.timeKey)
} }
const scanIcon = () => {
// 扫描
const handleScan = () => {
Taro.scanCode({
success(res) {
setSearchFilter((prevProps) => ({ ...prevProps, take_goods_order_no: res.result }))
},
fail(res) {
console.log(res)
},
})
}
return (
<View onClick={handleScan} className={styles.scanHandler}>
<IconFont name='icon-saomiao' size={40}></IconFont>
</View>
)
}
return ( return (
<> <>
<View className={styles.filterItem}>
<View className={styles['filterItem--title']}></View>
<View className={classnames(styles['filterItem--wrapper'], styles['filter--inputBar'])}>
<Search
placeholder='请输入或扫描条形码'
showBtn={false}
adjustPosition={true}
changeOnSearch={handleSearchBarChange}
debounceTime={300}
defaultValue={searchFilter.take_goods_order_no}
customRightSlot={scanIcon()}></Search>
</View>
</View>
<View className={styles.filterItem}> <View className={styles.filterItem}>
<View className={styles['filterItem--title']}></View> <View className={styles['filterItem--title']}></View>
<View className={classnames(styles['filterItem--wrapper'], styles['filter--type'])}> <View className={classnames(styles['filterItem--wrapper'], styles['filter--type'])}>