✨ feat(颜色取样): 新增颜色取样模块
This commit is contained in:
@@ -15,7 +15,6 @@ import { dataLoadingStatus, debounce, getFilterData } from '@/common/util'
|
||||
import { ShoppingProvider } from './components/shoppingCart/index'
|
||||
import { Goods, ShoppingDispatchType, useShoppingDispatch, useShoppingState } from './context'
|
||||
import { alert, goLink, isEmptyObject } from '@/common/common'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
|
||||
export const Shopping: FC = memo(() => {
|
||||
// 计算总的预估金额
|
||||
@@ -126,7 +125,7 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
||||
useEffect(() => {
|
||||
if (state.success) {
|
||||
// startTransition(() => {
|
||||
setShoppingCartData({ list: state.data, total: state.data.length })
|
||||
setShoppingCartData({ list: state.data, total: state.data.length })
|
||||
// })
|
||||
}
|
||||
}, [state])
|
||||
@@ -134,11 +133,11 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
||||
// 结算
|
||||
const handleSettleAccount = debounce(() => {
|
||||
const multipleSelection = colorStore?.[currentCheckedPurchaserId]?.['multipleSelection']
|
||||
if (!multipleSelection) return Taro.showToast({ title: '请先选择客户', icon: 'error' })
|
||||
if (!multipleSelection) return alert.error('请先选择客户')
|
||||
const checkedGoodsKind = Object.values(multipleSelection).reduce((prev, item: Goods) => {
|
||||
return [...prev, item.id]
|
||||
}, [])
|
||||
if (checkedGoodsKind.length === 0) return Taro.showToast({ title: '请先选择商品', icon: 'error' })
|
||||
if (checkedGoodsKind.length === 0) return alert.error('请先选择商品')
|
||||
goLink('/pages/submitOrder/index', {
|
||||
purchaser_id: currentCheckedPurchaserId,
|
||||
sale_mode: currentCheckedSaleMode,
|
||||
@@ -154,17 +153,19 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
||||
const multipleSelection = colorStore?.[currentCheckedPurchaserId].multipleSelection
|
||||
let checked: Goods[] = Object.values(multipleSelection!)
|
||||
if (checked.length === 0) {
|
||||
return Taro.showToast({ title: '请选择商品', icon: 'error' })
|
||||
return alert.error('请选择商品')
|
||||
}
|
||||
console.log('checked==>', checked)
|
||||
Taro.showModal({
|
||||
title: '要删除这些商品吗?',
|
||||
success: async function(res) {
|
||||
if (res.confirm) {
|
||||
alert.showLoading('删除中')
|
||||
const res = await deleteApi({
|
||||
ids: checked.map(item => item.id).join(','),
|
||||
})
|
||||
if (res.success) {
|
||||
alert.hideLoading()
|
||||
alert.success('删除成功')
|
||||
// 清空多选
|
||||
dispatch({
|
||||
@@ -178,6 +179,7 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
||||
fetchData(searchOptions)
|
||||
// Observer.notify(currentCheckedPurchaserId)
|
||||
} else {
|
||||
alert.hideLoading()
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
@@ -186,13 +188,10 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
||||
}
|
||||
// 全选
|
||||
const handleSelectAllCheckbox = (isSelectAll: boolean) => {
|
||||
console.log('handleSelectAllCheckbox', isSelectAll)
|
||||
const targetGoodsKind = colorStore?.[currentCheckedPurchaserId]?.['goodsKind']
|
||||
if (!targetGoodsKind) return Taro.showToast({ title: '请先选择客户', icon: 'error' })
|
||||
console.log('targetGoodsKind==>', targetGoodsKind)
|
||||
const targetGoodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind
|
||||
if (!targetGoodsKind) return alert.error('请先选择客户')
|
||||
|
||||
const tempObject = { ...targetGoodsKind }
|
||||
console.log('tempObject==>', tempObject)
|
||||
dispatch({
|
||||
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||
data: {
|
||||
@@ -210,12 +209,10 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
||||
setRefreshStatus(true)
|
||||
const res = await fetchData(searchOptions)
|
||||
if (res.success) {
|
||||
console.log('请求 成功')
|
||||
setRefreshStatus(false)
|
||||
Taro.showToast({ title: '刷新成功', icon: 'success' })
|
||||
alert.success('刷新成功')
|
||||
} else {
|
||||
console.log('请求 失败')
|
||||
Taro.showToast({ title: '刷新失败', icon: 'error' })
|
||||
alert.error('刷新失败')
|
||||
setRefreshStatus(false)
|
||||
}
|
||||
}
|
||||
@@ -237,11 +234,10 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
|
||||
<View className={classnames('flex-item', 'flex-col', styles['shopping--context'])}>
|
||||
<View id='shoppingListContainer' className={classnames(styles.shopping__list__container, 'flex-item')} style={{ height: listHeightRef.current }}>
|
||||
<InfiniteScroll statusMore={statusMore} refresherEnabled={true} selfOnRefresherRefresh={handleRefresh} refresherTriggered={refreshStatus}>
|
||||
{
|
||||
// isPending ? (
|
||||
{// isPending ? (
|
||||
// null
|
||||
// ) : (
|
||||
!!shoppingCartData?.list?.length &&
|
||||
!!shoppingCartData?.list?.length &&
|
||||
shoppingCartData?.list?.map((item, index) => {
|
||||
return <ItemList itemData={item} key={index}></ItemList>
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user