Compare commits

...

10 Commits

Author SHA1 Message Date
xuan
2510e7ac93 feat(ID1001621): 【订单详情】-待发货状态且货到付款状态时,不是申请退款,是“取消订单”
【【订单详情】-待发货状态且货到付款状态时,不是申请退款,是“取消订单”】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001621
2023-04-03 14:59:50 +08:00
czm
0aa47cb0e5 🐞 fix(ID1001619收款列表新建收款时报错): 2023-03-29 11:18:16 +08:00
xuan
5c8c164904 feat(ID1000956): 【内部小程序】补充立即下单功能
【【内部小程序】补充立即下单功能】 https://www.tapd.cn/53459131/prong/stories/view/1153459131001000956
2023-03-27 19:54:47 +08:00
xuan
488fc66481 🐞 fix(ID1001599): 【内部小程序】-购物车提交订单后,预估金额没有更新
【【内部小程序】-购物车提交订单后,预估金额没有更新】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001599
2023-03-23 19:54:00 +08:00
xuan
fab0652997 🐞 fix(ID1001592): 【内部小程序】- 搜索不出内容,需要重新退出进去才能搜索到。
【【内部小程序】- 搜索不出内容,需要重新退出进去才能搜索到。】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001592
2023-03-23 16:52:21 +08:00
xuan
7afb11bc74 feat(ID1000958): 【领取色卡】快速备注文案
【【领取色卡】快速备注文案】 https://www.tapd.cn/53459131/prong/stories/view/1153459131001000958
2023-03-23 16:36:05 +08:00
xuan
ef0a52f658 🐞 fix(购物车): 修复全选时删除失败的问题 2023-03-22 17:06:11 +08:00
xuan
af3aa008e4 🐞 fix(ID1001585): 【内部商城】-功能{-购物车}:选择全部删除面料,提示无法删除面料
【【内部商城】-功能{-购物车}:选择全部删除面料,提示无法删除面料】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001585
2023-03-22 15:48:11 +08:00
xuan
e56f538244 🐞 fix(色卡剪样): 限制提交订单按钮 2023-03-22 14:42:07 +08:00
xuan
7f82f6f2e4 🐞 fix(确认单): 批量修改添加数字校验 2023-03-20 16:57:42 +08:00
32 changed files with 755 additions and 401 deletions

View File

@ -32,6 +32,7 @@
"disableUseStrict": false,
"useCompilerPlugins": false,
"minifyWXML": true,
"condition": false,
"ignoreUploadUnusedFiles": true
},
"compileType": "miniprogram",

View File

@ -4,7 +4,6 @@ module.exports = {
env: {
NODE_ENV: '"pre"',
},
outputRoot: 'dist',
defineConstants: {
CURRENT_BASE_URL: '"https://pre.zzfzyc.com/lymarket"',
CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: '"https://pre.zzfzyc.com"',

View File

@ -4,7 +4,6 @@ module.exports = {
env: {
NODE_ENV: '"production"',
},
outputRoot: 'build',
defineConstants: {
CURRENT_BASE_URL: '"https://www.zzfzyc.com/lymarket"',
CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: '"https://www.zzfzyc.com"',

View File

@ -31,7 +31,8 @@
},
"disableUseStrict": false,
"useCompilerPlugins": false,
"minifyWXML": true
"minifyWXML": true,
"condition": false
},
"compileType": "miniprogram",
"libVersion": "2.24.5",

View File

@ -128,6 +128,27 @@
"query": "id=34311",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/submitOrder/index",
"query": "purchaser_id=1873&sale_mode=0&shopping_cart_product_color_list=%5B75484%2C75485%5D&purchaser_name=%E5%AD%9C%E7%84%B6%E7%83%A4%E9%B1%BF%E9%B1%BC",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/getColorCard/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/submitOrder/index",
"query": "purchaser_id=1861&sale_mode=0&shopping_cart_product_color_list=%5B75615%5D&purchaser_name=%E5%93%88%E5%96%BD",
"launchMode": "default",
"scene": null
}
]
}

View File

@ -248,3 +248,19 @@ export const RefuseAdjustPriceAudit = () => {
method: 'put',
})
}
// 立即下单(预览)
export const SaleOrderPreViewBuyNow = () => {
return useRequest({
url: '/v2/mp/saleOrder/preView/atOnce',
method: 'put',
})
}
// 立即下单(提交订单)
export const SaleOrderSubmitBuyNow = () => {
return useRequest({
url: '/v2/mp/saleOrder/atOnce',
method: 'post',
})
}

View File

@ -1,21 +1,14 @@
export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = `http://192.168.0.75:50001/lymarket`
// export const BASE_URL = `http://192.168.0.89:50001/lymarket`
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
// export const BASE_URL = `http://192.168.0.89:40001/lymarket`
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
// export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境
// export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布
// export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发
// export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发
// export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发
export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
// export const BASE_URL = 'https://www.zzfzyc.com/lymarket' // 正式环境
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
// export const BASE_URL = 'http://192.168.1.7:50002/lymarket' // 添
// export const BASE_URL = 'http://192.168.1.42:50002/lymarket' // 杰
// export const BASE_URL = `http://192.168.1.95:40001/lymarket` // 华
// export const BASE_URL = 'http://192.168.1.28:50002/lymarket' // 婷
// CDN
// 生成密钥

View File

@ -1,60 +0,0 @@
.bottomBox {
width: 100%;
height: 132px;
background: #FFFFFF;
box-shadow: 0px -5px 20px -8px rgba(0, 0, 0, 0.06);
display: flex;
padding-top: 16px;
align-items: center;
justify-content: space-between;
overflow: hidden;
.leftBottom {
display: flex;
align-items: center;
margin-left: 12px;
.nowFont {
font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #000000;
}
.selctFont {
font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #236AFF;
margin-left: 10px;
}
}
.button {
margin-right: 50px;
width: 256px;
height: 80px;
background: #4581FF;
border-radius: 40px;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
text-align: center;
line-height: 80px;
}
.activeButton {
margin-right: 50px;
width: 256px;
height: 80px;
background: #68b4ff;
border-radius: 40px;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #fff;
text-align: center;
line-height: 80px;
}
}

View File

@ -1,35 +0,0 @@
import { Button, View } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { memo } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
interface prosObj {
isDisabled: boolean
handSure?: () => void
clientId?: Number
clientName?: string
}
const BottomCustomer = (props: prosObj) => {
const {
isDisabled = true,
handSure,
clientName = '',
} = props
const navTo = () => {
Taro.navigateTo({
url: `/pages/customerPage/index?clientId=${props?.clientId}`,
})
}
return (
<View className={styles.bottomBox}>
<View className={styles.leftBottom} onClick={() => { navTo() }}>
<View className={styles.nowFont}></View>
<View className={styles.selctFont}>{clientName === '' ? '请选择客户 >' : `${clientName} >`}</View>
</View>
<Button className={classnames(isDisabled ? styles.activeButton : styles.button)} disabled={isDisabled} onClick={() => { handSure?.() }}> </Button >
</View >
)
}
export default memo(BottomCustomer)

View File

@ -1,14 +1,14 @@
import type { InputProps } from '@tarojs/components'
import { CustomWrapper, Input, View } from '@tarojs/components'
import type { FC } from 'react'
import React from 'react'
// 解决 input 组件输入过快会出现闪烁的问题
// https://github.com/NervJS/taro/issues/9664
interface PropsType {
interface PropsType extends InputProps {
customClassName?: string
customStyle?: React.CSSProperties
customInputStyle?: React.CSSProperties
customInputClassName?: string
[Property: string]: any
}
const InputX: FC<PropsType> = (props) => {
const { customClassName, customStyle, customInputStyle, customInputClassName, ...inputProps } = props

View File

@ -1,9 +1,10 @@
import { Image, Input, ScrollView, View } from '@tarojs/components'
import { Image, Input, ScrollView, Text, View } from '@tarojs/components'
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
import LabAndImg from '@/components/LabAndImg'
import { formatPriceDiv, formatWeightDiv } from '@/common/format'
import { EnumSaleMode } from '@/common/Enumerate'
interface props {
clickAdd: (any) => void
@ -87,15 +88,19 @@ const GoodsItem = (props: props) => {
<View className={styles.title}>{valueInfo?.code} {valueInfo?.name}</View>
<View className={styles.productNums}>{valueInfo?.roll}</View>
{
modeFont === 0 && <View className={styles.productName}>{formatWeightDiv(valueInfo?.weight_error) || 0}Kg</View>
modeFont === EnumSaleMode.Bulk && <View className={styles.productName}>{formatWeightDiv(valueInfo?.weight_error) || 0}Kg</View>
}
</View>
<View className={styles.rightFontsbox}>
<View className={styles.moneyFlex}>
{
modeFont === 0 && valueInfo?.last_bulk_price !== valueInfo?.bulk_price && <View className={styles.lastBox}>¥{modeFont === 0 ? formatPriceDiv(valueInfo?.last_bulk_price) : modeFont === 1 ? formatPriceDiv(valueInfo?.last_length_cut_price) : formatPriceDiv(valueInfo?.last_weight_cut_price)} {modeFont as any != 1 ? '/Kg' : '/m'}</View>
(modeFont === EnumSaleMode.Bulk) && (valueInfo?.last_bulk_price !== valueInfo?.bulk_price)
? <View className={styles.lastBox}>
¥{formatPriceDiv(valueInfo?.last_bulk_price)} /Kg
</View>
: null
}
<View className={styles.money}>¥{modeFont === 0 ? formatPriceDiv(valueInfo?.bulk_price) : modeFont === 1 ? formatPriceDiv(valueInfo?.length_cut_price) : formatPriceDiv(valueInfo?.weight_cut_price)}{modeFont != 1 ? '/Kg' : '/m'}</View>
<View className={styles.money}>¥{modeFont === EnumSaleMode.Bulk ? formatPriceDiv(valueInfo?.bulk_price) : modeFont === EnumSaleMode.Plate ? formatPriceDiv(valueInfo?.length_cut_price) : formatPriceDiv(valueInfo?.weight_cut_price)}{modeFont !== EnumSaleMode.Plate ? '/Kg' : '/m'}</View>
</View>
{
valueInfo.showInput

View File

@ -2,7 +2,12 @@ import { View } from '@tarojs/components'
import { memo, useMemo } from 'react'
import style from './index.module.scss'
const Loading = ({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
interface LoadingProps {
width?: number
color?: string
}
const Loading = (props: LoadingProps) => {
const { width = 60, color = '#6190e8' } = props
const styleObj = useMemo(() => {
let obj = {}
if (width > 0) { obj = { width: `${width}rpx`, height: `${width}rpx` } }

View File

@ -10,7 +10,7 @@
text-align: center;
color: #fff;
box-sizing: border-box;
&--normal {
height: 72px;
font-size: $font_size_medium;
@ -76,12 +76,9 @@
align-items: center;
color: currentColor;
.loading {
position: absolute;
display: inline-block;
margin-right: 20px;
pointer-events: none;
left: -40px;
top: 50%;
transform: translateY(-50%);
z-index: 1;
}
}
// active 伪类

View File

@ -49,6 +49,13 @@ const NormalButton: FC<NormalButtonPropsType> = (props) => {
return classObject
}
const loadingColor = type === 'primary' ? '#fff' : ''
let loadingComponent: JSX.Element | null = null
if (loading) {
loadingComponent = <View className={styles.loading}>
<Loading width={30} color={loadingColor} />
</View>
}
const handleClick = (event) => {
if (disabled) {
return
@ -59,7 +66,7 @@ const NormalButton: FC<NormalButtonPropsType> = (props) => {
return (
<View className={classnames(styles.button, getClassName(), customClassName)} style={customStyles} onClick={handleClick}>
<View className={classnames(styles['button--text'], customTextClassName)}>
<View className={styles.loading}>{loading && <Loading width={30} />}</View>
{loadingComponent}
{children}</View>
</View>
)

View File

@ -95,7 +95,7 @@ const Search = (
customStyle={{ width: '100%' }}
/>
<View className={styles.search_closeBtn}>
{!!inputCon && <CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />}
{!!inputCon && <CloseBtn onClose={clearInput} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />}
</View>
{showScan && (
<View

View File

@ -5,7 +5,7 @@
font-size: 32px;
font-weight: 500;
color: #000000;
margin-top: 24px;
padding-top: 24px;
margin-bottom: 8px;
}
@ -97,19 +97,15 @@
margin-bottom: 32px;
}
.scrollviewBig {
.scrollview {
// height: 300px;
.kongBox {
height: 181px;
width: 100%;
}
.virtualList {
.kongBox {
height: 181px;
width: 100%;
}
}
.kongOne {
height: 200px;
height: 80px;
}
.loading_more {
@ -132,12 +128,63 @@
.noBottom {
width: 100%;
position: fixed;
z-index: 999;
bottom: env(safe-area-inset-bottom);
}
}
.scrllStyle {
.popupHeight {
display: flex;
flex-flow: column nowrap;
height: 75vh;
.shopcartBox {
flex: 1 1 auto;
display: flex;
flex-flow: column nowrap;
overflow: hidden;
.virtualListContainer {
flex: 1 1 auto;
overflow: auto;
}
}
}
// 底部按钮
.bottomBox {
width: 100%;
padding: 20px 20px;
background: #ffffff;
box-shadow: 0px -5px 20px -8px rgba(0, 0, 0, 0.06);
display: flex;
padding-top: 16px;
align-items: center;
justify-content: space-between;
overflow: hidden;
box-sizing: border-box;
.leftBottom {
width: 50%;
display: flex;
align-items: center;
.nowFont {
font-size: 28px;
white-space: nowrap;
font-weight: 400;
color: #000000;
}
.selctFont {
flex: 1 1 auto;
@include common_ellipsis();
font-size: 28px;
font-weight: 400;
color: #236aff;
}
}
.rightBottom {
width: 50%;
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
}
}

View File

@ -1,16 +1,18 @@
import { ScrollView, View } from '@tarojs/components'
import { useDidShow } from '@tarojs/taro'
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
import { Button, ScrollView, View } from '@tarojs/components'
import Taro, { nextTick, useDidShow } from '@tarojs/taro'
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import VirtualList from '@tarojs/components/virtual-list'
import Divider from '../divider'
import NormalButton from '../normalButton'
import styles from './index.module.scss'
import Search from '@/components/search'
import Popup from '@/components/popup'
import Goods from '@/components/goodsItem'
import BottomCustomer from '@/components/BottomCustomer'
import DotLoading from '@/components/dotLoading'
import { formatDateTime, formatHashTag, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/format'
import { formatDateTime, formatHashTag, formatMeterMul, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/format'
import { goLink } from '@/common/common'
import { EnumSaleMode } from '@/common/Enumerate'
interface prosObj {
showPopup?: false | true
@ -29,7 +31,7 @@ interface prosObj {
name?: string
}
modeFont: Number | string
modeFont: EnumSaleMode
clientName: string
clientId: Number
hasBottom?: true | false // 默认不占位底部
@ -48,7 +50,7 @@ const ShoppingCart = (props: prosObj, ref) => {
getSearchData,
handPlus,
obj = {},
modeFont = 0,
modeFont = EnumSaleMode.Bulk,
clientName = '',
clientId = -1,
handSure,
@ -125,18 +127,81 @@ const ShoppingCart = (props: prosObj, ref) => {
}
const Rows = memo(rows)
const isDisabled = useMemo(() => {
return !(selectTotal > 0 && clientName !== '')
}, [selectTotal, clientName])
const navTo = () => {
Taro.navigateTo({
url: `/pages/customerPage/index?clientId=${clientId}`,
})
}
const handBuyNow = () => {
console.log('goodList', goodList, modeFont)
const checkedGoodsKind = goodList.filter(item => item.showInput).map(item => ({
id: item.id,
length: modeFont !== EnumSaleMode.Bulk ? formatMeterMul(item?.nums) : 0,
roll: modeFont === EnumSaleMode.Bulk ? item.nums : 0,
sale_price: formatPriceDiv(item?.sale_price),
}))
goLink('/pages/submitOrder/index', {
purchaser_id: clientId,
sale_mode: modeFont,
sale_order_product_color_list: JSON.stringify(checkedGoodsKind),
purchaser_name: clientName,
isBuyNew: true,
})
}
const [virtualListHeight, setVirtualListHeight] = useState(400)
useLayoutEffect(() => {
console.log('useEffect')
if (showPopup && goodList.length !== 0) {
getVirtualListHeight()
}
}, [showPopup, goodList])
const getVirtualListHeight = () => {
nextTick(() => {
const query = Taro.createSelectorQuery()
query.select('#virtualListContainer').boundingClientRect((res) => {
console.log(res)
const virtualListHeight = res.height
console.log('setVirtualListHeight res', res)
setVirtualListHeight(virtualListHeight)
})
query.exec()
})
}
// useLayoutEffect(() => {
// console.log('useLayoutEffect')
// if (showPopup) {
// const query = Taro.createSelectorQuery()
// query.select('#shopCartBox').boundingClientRect()
// query.select('#virtualList').boundingClientRect()
// query.exec((res) => {
// console.log(res)
// const shopCartBoxHeight = res[0].height
// const virtualListTop = res[1].top
// console.log('setVirtualListHeight res', res)
// setVirtualListHeight(shopCartBoxHeight - virtualListTop)
// })
// }
// }, [showPopup])
return (
<Popup showTitle={false} show={showPopup} onClose={() => closePopup?.()}>
<ScrollView className={styles.scrllStyle} scrollY>
<View className={styles.shopcartBox}>
<View className={styles.popupHeight}>
<View className={styles.shopcartBox} id="shopCartBox">
<View className={styles.topTitle}>
{formatHashTag(obj?.code, obj?.name)}
</View>
<View className={styles.selectFont}>
1 {selectTotal} {selectNums} {showModefont}
</View>
<Divider direction="horizontal" customStyles={{ margin: '12px 0' }}></Divider>
<View className={styles.typeFont}></View>
<View className={styles.flexType}>
{typeList.map((item, index) => {
return (
@ -171,12 +236,12 @@ const ShoppingCart = (props: prosObj, ref) => {
/>
</View>
</View>
{goodList.length > 0 && (
<>
<View className={styles.scrollviewBig}>
<View id="virtualListContainer" className={styles.virtualListContainer}>
{goodList.length > 0 && (
<>
<VirtualList
className={styles.scrollview}
height={300} /* 列表的高度 */
className={styles.virtualList}
height={virtualListHeight} /* 列表的高度 */
width="100%" /* 列表的宽度 */
itemData={goodList} /* 渲染列表的数据 */
itemCount={goodList.length + 0} /* 渲染列表的长度 */
@ -185,31 +250,32 @@ const ShoppingCart = (props: prosObj, ref) => {
>
{Rows}
</VirtualList>
</View>
<View className={styles.kongOne}></View>
</>
)}
{/* <View className={styles.kongOne}></View> */}
</>
)}
</View>
{goodList.length === 0 && (
<View className={styles.loading_more}>
{/* <DotLoading /> */}
</View>
)}
{!hasBottom && <View style={{ height: '100rpx' }}></View>}
{/* <View className={classnames(hasBottom === true ? styles.posBox : styles.noBottom)}> */}
<View className={styles.noBottom}>
<BottomCustomer
clientName={clientName}
clientId={clientId}
isDisabled={!(selectTotal > 0 && clientName !== '')}
handSure={() => {
handSure()
}}
></BottomCustomer>
</View>
{/* {!hasBottom && <View style={{ height: '100rpx' }}></View>} */}
</View>
</ScrollView>
<View className={styles.noBottom}>
<View className={styles.bottomBox}>
<View className={styles.leftBottom} onClick={navTo}>
<View className={styles.nowFont}></View>
<View className={styles.selctFont}>{clientName === '' ? '请选择客户 >' : `${clientName} >`}</View>
</View>
<View className={styles.rightBottom}>
<NormalButton round type="primary" disabled={isDisabled} onClick={handBuyNow}></NormalButton>
<NormalButton round type="primary" disabled={isDisabled} onClick={handSure}></NormalButton>
</View>
</View >
</View>
</View>
</Popup>
)
}

View File

@ -2,6 +2,7 @@ import { Button, Input, Textarea, View } from '@tarojs/components'
import Taro, { useDidShow } from '@tarojs/taro'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import Big from 'big.js'
import styles from './index.module.scss'
import Form from './components/form'
import {
@ -128,7 +129,7 @@ const AddCollection = () => {
const query = {
payment_credential_url: picUrl.current,
purchaser_id: Query.purchaser_id,
receipt_amount: Number(Query.money) * 100,
receipt_amount: parseFloat(new Big(Query.money).times(100)),
receiving_account_id: Query.bankId,
remark: TextareaValue,
}

View File

@ -8,7 +8,6 @@ import styles from './index.module.scss'
import Divider from '@/components/divider'
import Search from '@/components/search'
import Popup from '@/components/popup'
import BottomCustomer from '@/components/BottomCustomer'
import DotLoading from '@/components/dotLoading'
import { formatDateTime, formatHashTag, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/format'

View File

@ -5,7 +5,7 @@ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from '
import classnames from 'classnames'
import Remark from '../orderDetails/components/remark'
import styles from './index.module.scss'
import Form from './components/form'
import Form from './components/Form'
import Popup from '@/components/popup'
import { debounce } from '@/common/util'
import { alert, goLink } from '@/common/common'
@ -370,7 +370,9 @@ const CustomerEditor = () => {
<View className={classnames(remarkDesc === '' ? styles.remarkFontactive : styles.remarkFont)}>{remarkDesc === '' ? '尚未备注信息' : remarkDesc}</View>
</DefaultBoxWithMemo>
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
<Remark onSave={e => getRemark(e)} defaultValue={infoObj?.remark} showInput={!!showDesc} />
{
showDesc && <Remark onSave={e => getRemark(e)} defaultValue={infoObj?.remark} />
}
</Popup>
<Address addressOnChange={val => handleSetSite(val)} defaultValue={addressArr} addressOnClose={() => onClose()} show={showSiteModal} />
<View className={styles.safeBox}></View>

View File

@ -15,6 +15,7 @@ import Remark from '@/pages/orderDetails/components/remark'
import { SubmitColorCardOrder } from '@/api/colorCard'
import NavBar from '@/pages/order/components/NavBar'
import { MpPurchaserAddressList } from '@/api/addressList'
import { debounce } from '@/common/util'
const AddColorCard = () => {
// 获取选择的客户
@ -92,9 +93,9 @@ const AddColorCard = () => {
// Taro.setStorageSync('colorCardCache', JSON.stringify(order))
}
const { fetchData } = SubmitColorCardOrder()
const { fetchData, state } = SubmitColorCardOrder()
// 提交订单
const handleSubmitOrder = async() => {
const handleSubmitOrder = debounce(async() => {
if (!addressInfo.address_id) {
return alert.none('请选择地址')
}
@ -102,6 +103,7 @@ const AddColorCard = () => {
return alert.none('请选择客户')
}
if (order.length === 0) { return alert.none('请选择色卡') }
// 请求数据
const res = await fetchData({
address_id: addressInfo.address_id,
@ -116,11 +118,9 @@ const AddColorCard = () => {
duration: 2000,
})
Taro.removeStorageSync('colorCardCache')
setTimeout(() => {
goLink('/pages/getColorCard/colorCardDetail/index', { id: res.data.id }, 'redirectTo')
}, 2000)
goLink('/pages/getColorCard/colorCardDetail/index', { id: res.data.id }, 'redirectTo')
}
}
}, 300)
const deleteColorCard = (id) => {
setOrder((prev) => {
@ -372,7 +372,9 @@ const AddColorCard = () => {
<NormalButton
customClassName={styles.bottomBar__button}
type="primary"
disabled={state.loading! || state.success!}
round
loading={state.loading!}
onClick={handleSubmitOrder}
>
@ -380,7 +382,9 @@ const AddColorCard = () => {
</View>
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
<Remark onSave={getRemark} defaultValue={remark} showInput={!!showDesc} />
{
showDesc && <Remark onSave={getRemark} defaultValue={remark} />
}
</Popup>
</View>
}

View File

@ -63,7 +63,7 @@ const BottomApply = (props: prosObj) => {
|| (obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
|| (obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 3 && goodsObj?.av_return_product?.length)
|| (obj.sale_mode === 0 && obj.status == 11 && (obj.collect_status == 1 || obj.collect_status == 2) && goodsObj?.av_return_product?.length)
|| (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 0 && goodsObj?.av_return_product?.length && !obj.is_shipper_picks_up)
// || (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 0 && goodsObj?.av_return_product?.length && !obj.is_shipper_picks_up)
|| (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 2 && goodsObj?.av_return_product?.length && !obj.is_shipper_picks_up)
|| (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 1 && goodsObj?.av_return_product?.length && !obj.is_shipper_picks_up)
|| (obj.sale_mode === 1 && obj.status == 0 && goodsObj?.av_return_product?.length)
@ -129,7 +129,8 @@ const BottomApply = (props: prosObj) => {
|| (obj.sale_mode === 2 && obj.status === 0 && obj.collect_status == 0)
|| (obj.sale_mode === 1 && obj.status === 10)
|| (obj.sale_mode === 2 && obj.status === 10)
|| (obj.sale_mode === 0 && obj.status === 13)
|| (obj.sale_mode === 0 && obj.status === 13)
|| (obj.collect_status == 0)
) {
return true
}

View File

@ -1,48 +1,62 @@
.order_popup{
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 0;
.order_popup_title{
color: $font_size_big;
font-weight: 700;
color: #000000;
padding-bottom: 20px;
}
.order_popup_input{
width: 100%;
padding: 0 25px;
box-sizing: border-box;
margin-top: 43px;
position: relative;
.descDataNum{
position: absolute;
right: 40px;
bottom: 10px;
height: 39px;
font-size: $font_size_medium;
color: $color_font_two;
}
textarea{
background-color: #f3f3f3;
border-radius: 10px;
width: 100%;
height: 313px;
padding: 20px;
padding-bottom: 50px;
box-sizing: border-box;
font-size: $font_size;
border: 2px solid #e6e6e6;
}
.order_popup {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 0;
.order_popup_title {
color: $font_size_big;
font-weight: 700;
color: #000000;
padding-bottom: 20px;
}
.order_popup_input {
width: 100%;
padding: 0 25px;
box-sizing: border-box;
margin-top: 43px;
position: relative;
.descDataNum {
position: absolute;
right: 40px;
bottom: 10px;
height: 39px;
font-size: $font_size_medium;
color: $color_font_two;
}
.order_save_address{
height: 82px;
background: #007aff;
border-radius: 40px;
width: 668px;
text-align: center;
line-height: 82px;
color: #fff;
margin-top: 60px;
}
}
textarea {
background-color: #f3f3f3;
border-radius: 10px;
width: 100%;
height: 313px;
padding: 20px;
padding-bottom: 50px;
box-sizing: border-box;
font-size: $font_size;
border: 2px solid #e6e6e6;
}
}
.recommend_remark {
margin: 10px 28px;
color: #808080;
font-size: 28px;
}
.recommend_remark_content {
margin: 0 20px;
.tag {
height: 50px;
margin: 0 8px;
margin-bottom: 10px;
}
}
.order_save_address {
height: 82px;
background: #007aff;
border-radius: 40px;
width: 668px;
text-align: center;
line-height: 82px;
color: #fff;
margin-top: 60px;
}
}

View File

@ -2,14 +2,57 @@ import { Textarea, View } from '@tarojs/components'
import { useCallback, useEffect, useState } from 'react'
import styles from './index.module.scss'
import Popup from '@/components/popup'
import Tag from '@/components/tag'
interface Param {
onBlur?: (val: any) => void
onSave?: (val: string) => void
defaultValue?: string
showInput: boolean
}
const Remark = ({ onBlur, onSave, defaultValue = '', showInput = false }: Param) => {
const recommendReport = [
{
id: 1,
value: '拿色片',
},
{
id: 2,
value: '顺丰',
},
{
id: 3,
value: '客户自提',
},
{
id: 4,
value: '加急一下',
},
{
id: 5,
value: '物流到',
},
{
id: 6,
value: '中台秀银',
},
{
id: 7,
value: '中台晓茵',
},
{
id: 8,
value: '中台淑婷',
},
{
id: 9,
value: '中台结慧',
},
{
id: 10,
value: '辛苦了',
},
]
const Remark = ({ onBlur, onSave, defaultValue = '' }: Param) => {
const [descData, setDescData] = useState({
number: 0,
value: '',
@ -30,16 +73,31 @@ const Remark = ({ onBlur, onSave, defaultValue = '', showInput = false }: Param)
useEffect(() => {
getDesc(defaultValue)
}, [defaultValue])
const onClickTag = (item) => {
setDescData(prev => ({
...prev,
value: prev.value + item.value,
}))
}
return (
<View className={styles.order_popup}>
<View className={styles.order_popup_title}></View>
{
showInput && <View className={styles.order_popup_input}>
<Textarea placeholder="请添加备注" value={descData?.value} maxlength={descData.count} cursorSpacing={100} onInput={e => getDesc(e.detail.value)} onBlur={e => onBlur?.(e)}></Textarea>
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
<View className={styles.order_popup_input}>
<Textarea placeholder="请添加备注" value={descData?.value} maxlength={descData.count} cursorSpacing={100} onInput={e => getDesc(e.detail.value)} onBlur={e => onBlur?.(e)}></Textarea>
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
</View>
<View>
<View className={styles.recommend_remark}></View>
<View className={styles.recommend_remark_content}>
{
recommendReport.map((item) => {
return <Tag type="info" plain onClick={() => onClickTag(item)} circle customClassName={styles.tag} key={item.id}>{item.value}</Tag>
})
}
</View>
}
</View>
<View className={styles.order_save_address} onClick={() => setSave()}></View>
</View>
)

View File

@ -18,6 +18,7 @@ import { formatRemoveHashTag } from '@/common/format'
import { SubmitCutSampleOrder } from '@/api/sampleCutting'
import NavBar from '@/pages/order/components/NavBar'
import { MpPurchaserAddressList } from '@/api/addressList'
import { debounce } from '@/common/util'
const AddColorCard = () => {
// 获取选择的客户
@ -87,9 +88,9 @@ const AddColorCard = () => {
goLink('/pages/sampleCutting/sampleCuttingList/index', { isGoBack: true, isAddSampleCutIdList: order.map(item => item.product_id) })
}
const { fetchData } = SubmitCutSampleOrder()
const { fetchData, state } = SubmitCutSampleOrder()
// 提交订单
const handleSubmitOrder = async() => {
const handleSubmitOrder = debounce(async() => {
if (!addressInfo.address_id) {
return alert.none('请选择地址')
}
@ -120,11 +121,9 @@ const AddColorCard = () => {
duration: 2000,
})
Taro.removeStorageSync('sampleCuttingCache')
setTimeout(() => {
goLink('/pages/sampleCutting/sampleCuttingDetail/index', { id: res.data.id }, 'redirectTo')
}, 2000)
goLink('/pages/sampleCutting/sampleCuttingDetail/index', { id: res.data.id }, 'redirectTo')
}
}
}, 300)
const labAndImgObj = useCallback((item) => {
return { lab: item?.lab, rgb: item?.rgb, texture_url: item?.texture_url }
@ -441,7 +440,9 @@ const AddColorCard = () => {
<NormalButton
customClassName={styles.bottomBar__button}
type="primary"
disabled={state.loading! || state.success!}
round
loading={state.loading!}
onClick={handleSubmitOrder}
>
@ -449,7 +450,9 @@ const AddColorCard = () => {
</View>
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
<Remark onSave={getRemark} defaultValue={remark} showInput={!!showDesc} />
{
showDesc && <Remark onSave={getRemark} defaultValue={remark} />
}
</Popup>
</View>
}

View File

@ -10,7 +10,6 @@ page {
font-size: 28px;
color: #000000;
margin-left: 32px;
margin-right: 32px;
}
.line {

View File

@ -302,21 +302,19 @@ const SearchPage = () => {
// 输入了搜索关键字
const getSearchData = useCallback((e) => {
if (e) {
setHasFonts(true)
getProduct(e)
}
else {
if (!e) {
setHasFonts(false)
setSearchList([])
}
setdefaultvalue(e)
}, [])
// 返回
const back = () => {
Taro.navigateBack({
delta: 1,
})
// 搜索
const onSearch = () => {
if (defaultvalue) {
setHasFonts(true)
getProduct(defaultvalue)
}
}
// 判断是否整数类型
function isInteger(obj) {
@ -419,8 +417,7 @@ const SearchPage = () => {
return (
<View className={styles.main}>
<View className={styles.topBox}>
<Search placeholder="请输入搜索布料" defaultValue={defaultvalue} showBtn={false} changeOnSearch={getSearchData} >
<View className={styles.cancelFont} onClick={() => back()}></View>
<Search placeholder="请输入搜索布料" defaultValue={defaultvalue} showBtn clickOnSearch={onSearch} changeOnSearch={getSearchData} >
</Search>
</View>
<View className={styles.line}></View>

View File

@ -167,7 +167,7 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
console.log('rerender component ShoppingCartItem', props, props.itemData?.purchaser_name)
const currentItemData = useRef<ShoppingCartData | undefined>(props.itemData)
// 即使更新 useRef 的数据 不然拿到的还是旧数据
// 及时更新 useRef 的数据 不然拿到的还是旧数据
currentItemData.current = props.itemData
const [itemData, setItemData] = usePropsValue({
@ -254,43 +254,47 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
// 更新当前客户的多选项
const updatePurchaserMultipleSelection = (purchaserId: number, payload: Goods, operationType: OperationType, goodsId: number) => {
console.log('delete', colorStore, purchaserId)
if (operationType === 'add') {
const multipleSelection = {
...colorStore?.[purchaserId]?.multipleSelection,
[goodsId]: payload,
if (itemData?.purchaser_id === purchaserId) {
console.log('updatePurchaserMultipleSelection', colorStore, purchaserId)
if (operationType === 'add') {
const multipleSelection = {
...colorStore?.[purchaserId]?.multipleSelection,
[goodsId]: payload,
}
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId,
multipleSelection,
},
})
// 全选标识
if (itemData?.[BackEndSaleModeListFieldMap[selected]].length === Object.keys(multipleSelection).length) {
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: true })
}
}
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId,
multipleSelection,
},
})
// 全选标识
if (currentItemData.current?.purchaser_id === purchaserId && currentItemData.current?.[BackEndSaleModeListFieldMap[selected]].length === Object.keys(multipleSelection).length) {
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: true })
else if (operationType === 'delete') {
const temp = { ...colorStore?.[purchaserId]?.multipleSelection }
delete temp?.[goodsId]
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId,
multipleSelection: temp,
},
})
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: false })
}
}
else if (operationType === 'delete') {
const temp = { ...colorStore?.[purchaserId]?.multipleSelection }
delete temp?.[goodsId]
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId,
multipleSelection: temp,
},
})
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: false })
}
}
const handleOtherHighLight = (purchaserId: number) => {
console.log('handleOtherHighLight', purchaserId, currentCheckedPurchaserId)
if (purchaserId === currentCheckedPurchaserId) {
const handleOtherHighLight = (purchaserId: number, deletedItemData: any) => {
if (purchaserId === itemData?.purchaser_id) {
// 当前订单类型还有数据,跳过
if (deletedItemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0) { return }
// 当前订单类型没有数据,高亮其他订单类型
for (let i = 0; i < BackEndSaleModeListField.length; i++) {
if (itemData?.[BackEndSaleModeListFieldMap[i]].length !== 0) {
if (deletedItemData?.[BackEndSaleModeListFieldMap[i]].length !== 0) {
// 控制高亮
onSelectOrderType(i)
return
@ -469,17 +473,7 @@ const withStateSlice = (comp, slice: (state: ShoppingStateContextValue, props: P
console.log('itemData 有变化')
needMemo = false
}
if (prevProps.itemData.purchaser_name === '皮特织业') {
console.log('------withStateSlice props-------')
console.log('withStateSlice props prevProps', prevProps)
console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData)
console.log('withStateSlice props nextProps', nextProps)
console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection)
console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId)
console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer)
console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state)
console.log('------withStateSlice props-------')
}
if (prevProps.state.Observer !== nextProps.state.Observer) {
console.log('Observer 有变化')
needMemo = false
@ -492,6 +486,18 @@ const withStateSlice = (comp, slice: (state: ShoppingStateContextValue, props: P
console.log('currentCheckedPurchaserId 有变化')
needMemo = false
}
if (prevProps.itemData.purchaser_name === '孜然烤鱿鱼') {
console.log('更新 孜然烤鱿鱼', !needMemo)
console.log('------withStateSlice props-------')
console.log('withStateSlice props prevProps', prevProps)
console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData)
console.log('withStateSlice props nextProps', nextProps)
console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection)
console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId)
console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer)
console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state)
console.log('------withStateSlice props-------')
}
return needMemo
})
const Wrapper = (props: PropsType, ref) => {

View File

@ -77,7 +77,7 @@ export interface ShoppingDispatchContextValue {
[ShoppingDispatchType.UPDATE_CURRENT_CHECKED_SALEMODE]: (saleMode: ShoppingStateContextValue['currentCheckedSaleMode']) => void
[ShoppingDispatchType.UPDATE_COLOR_STORE]: (colorStore: React.SetStateAction<ColorStore>) => void
[ShoppingDispatchType.UPDATE_SELECTED_AMOUNT]: (amount: React.SetStateAction<ShoppingStateContextValue['selectedAmount']>) => void
[ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX]: (amount: React.SetStateAction<ShoppingStateContextValue['selectedAmount']>) => void
[ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX]: (amount: React.SetStateAction<GoodsMeta>) => void
}
export interface ShoppingAction {

View File

@ -13,11 +13,12 @@ import { ShoppingDispatchType, useShoppingDispatch, useShoppingState } from './c
import { events } from './context/shoppingStore'
import { dataLoadingStatus, debounce, getFilterData } from '@/common/util'
import { ShoppingCartDeleteApi, ShoppingCartListApi } from '@/api/index'
import { formatPriceDiv } from '@/common/format'
import { formatMeterDiv, formatPriceDiv } from '@/common/format'
import InfiniteScroll from '@/components/infiniteScroll'
import IconText from '@/components/iconText'
import Search from '@/components/search'
import { alert, goLink, isEmptyObject } from '@/common/common'
import { EnumSaleMode } from '@/common/Enumerate'
interface SearchOptions {
short_name_or_phone?: string
@ -39,26 +40,75 @@ const ShoppingCartContainer: FC = () => {
}
const listHeightRef = useRef('auto')
// 强制刷新
const [, setForceUpdate] = useState({})
const { fetchData, state } = ShoppingCartListApi()
const [searchOptions, setSearchOptions] = useState<SearchOptions>({})
const clearMultiSelection = () => {
console.log('clearMultiSelection', shoppingCartData?.list)
const target = shoppingCartData?.list?.find(item => item.purchaser_id === currentCheckedPurchaserId)
console.log('BackEndSaleModeListFieldMap', BackEndSaleModeListFieldMap[currentCheckedSaleMode], target)
const newGoodsKind = Object.fromEntries(
target?.[BackEndSaleModeListFieldMap[currentCheckedSaleMode]].map(item => [
item?.id,
{
id: item?.id,
estimate_amount: item.estimate_amount,
product_code: item.product_code,
product_color_code: item.product_color_code,
sale_mode: item.sale_mode,
count: currentCheckedSaleMode === EnumSaleMode.Bulk ? item.roll : Number(formatMeterDiv(item.length)),
},
]),
)
const prevMultipleSelection = colorStore?.[currentCheckedPurchaserId]?.multipleSelection
console.log('clearMultiSelection', prevMultipleSelection)
const nextMultipleSelection = prevMultipleSelection
? Object.fromEntries(
Object.values(prevMultipleSelection).filter(value => !Object.keys(newGoodsKind).includes(String(value.id)))
.map(value => [
value.id,
{
id: value.id,
estimate_amount: value.estimate_amount,
product_code: value.product_code,
product_color_code: value.product_color_code,
sale_mode: value.sale_mode,
count: value.count,
},
],
))
: {}
console.log('nextMultipleSelection', nextMultipleSelection)
// 清空多选
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId: currentCheckedPurchaserId,
goodsKind: newGoodsKind,
multipleSelection: nextMultipleSelection,
},
})
}
useDidShow(() => {
const getData = async() => {
await fetchData(getFilterData(searchOptions))
clearMultiSelection()
}
useDidShow(async() => {
// 第二次进入该页面时触发
if (!isFirst.current) {
console.log('重新刷新')
// 重新刷新
// setShoppingCartData({ list: [], total: 0 })
fetchData(getFilterData(searchOptions))
getData()
}
})
useEffect(() => {
console.log('useEffect fetchData', getFilterData(searchOptions))
if (!isFirst.current) {
fetchData(getFilterData(searchOptions))
getData()
}
}, [searchOptions])
@ -91,21 +141,6 @@ const ShoppingCartContainer: FC = () => {
console.log('useLayoutEffect')
await fetchData(getFilterData(searchOptions))
isFirst.current = false
// const query = Taro.createSelectorQuery()
// console.log('query', query)
// query.select('#shoppingContainer').boundingClientRect()
// query.select('#topBar').boundingClientRect()
// query.select('#bottomBar').boundingClientRect()
// query.exec((res) => {
// console.log('res==>', res)
// const containerHeight = res[0].height
// const topBarHeight = res[1].height
// const bottomBarHeight = res[2].height
// const listHeight = containerHeight - topBarHeight - bottomBarHeight
// listHeightRef.current = `${listHeight}px`
// // 强制刷新
// setForceUpdate({})
// })
})()
}, [])
@ -129,6 +164,7 @@ const ShoppingCartContainer: FC = () => {
sale_mode: currentCheckedSaleMode,
shopping_cart_product_color_list: JSON.stringify(checkedGoodsKind),
purchaser_name: shoppingCartData?.list.find(item => item.purchaser_id === currentCheckedPurchaserId)?.purchaser_name,
isBuyNew: false,
})
}, 400)
@ -147,23 +183,44 @@ const ShoppingCartContainer: FC = () => {
async success(res) {
if (res.confirm) {
alert.showLoading('删除中')
const checkedIds = checked.map(item => item.id)
const res = await deleteApi({
ids: checked.map(item => item.id).join(','),
ids: checkedIds.join(','),
})
if (res.success) {
alert.hideLoading()
alert.success('删除成功')
console.log('colorStore?.[currentCheckedPurchaserId]', colorStore?.[currentCheckedPurchaserId])
let goodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind
if (goodsKind) {
goodsKind = Object.fromEntries(
Object.values(goodsKind).filter(value => !checkedIds.includes(value.id))
.map(value => [
value.id,
{
id: value.id,
estimate_amount: value.estimate_amount,
product_code: value.product_code,
product_color_code: value.product_color_code,
sale_mode: value.sale_mode,
count: value.count,
},
],
))
}
console.log('goodsKind', goodsKind)
// 清空多选
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId: currentCheckedPurchaserId,
goodsKind: colorStore?.[currentCheckedPurchaserId].goodsKind,
goodsKind,
multipleSelection: {},
},
})
fetchData(searchOptions)
events.trigger('handleOtherHighLight', currentCheckedPurchaserId)
const deleted = await fetchData(searchOptions)
events.trigger('handleOtherHighLight', currentCheckedPurchaserId, deleted.data.list.find(item => item.purchaser_id === currentCheckedPurchaserId))
// Observer.notify(currentCheckedPurchaserId)
}
else {
@ -176,10 +233,24 @@ const ShoppingCartContainer: FC = () => {
}
// 全选
const handleSelectAllCheckbox = (isSelectAll: boolean) => {
const targetGoodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind
if (!targetGoodsKind) { return alert.error('请先选择客户') }
if (!currentCheckedPurchaserId) { return alert.error('请先选择客户') }
const tempObject = { ...targetGoodsKind }
const targetGoodsKind = shoppingCartData.list.find(item => item.purchaser_id === currentCheckedPurchaserId)?.[BackEndSaleModeListFieldMap[currentCheckedSaleMode]]
const tempObject: Record<Goods['id'], Goods> = Object.fromEntries(
targetGoodsKind.map(item => [
item?.id,
{
id: item?.id,
estimate_amount: item.estimate_amount,
product_code: item.product_code,
product_color_code: item.product_color_code,
sale_mode: item.sale_mode,
count: currentCheckedSaleMode === EnumSaleMode.Bulk ? item.roll : Number(formatMeterDiv(item.length)),
},
]),
)
console.log('handleSelectAllCheckbox', tempObject)
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
@ -197,6 +268,7 @@ const ShoppingCartContainer: FC = () => {
setRefreshStatus(true)
const res = await fetchData(getFilterData(searchOptions))
if (res.success) {
clearMultiSelection()
setRefreshStatus(false)
alert.success('刷新成功')
}

View File

@ -1,5 +1,7 @@
import type { CommonEvent } from '@tarojs/components'
import { Input, Text, View } from '@tarojs/components'
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
import Big from 'big.js'
import type { ReactNode } from 'react'
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
@ -12,6 +14,8 @@ import { UseSubscriptionMessage } from '@/use/useCommon'
import {
MpSaleOrderPost,
MpSaleOrderPreview,
SaleOrderPreViewBuyNow,
SaleOrderSubmitBuyNow,
} from '@/api/order'
import { alert } from '@/common/common'
import { formatDateTime, formatMeterDiv, formatPriceDiv, formatPriceMul, formatRemoveHashTag, formatWeightDiv } from '@/common/format'
@ -24,6 +28,13 @@ import LayoutBlock from '@/components/layoutBlock'
import IconText from '@/components/iconText'
import Dialog from '@/components/Dialog'
import InputX from '@/components/InputX'
interface ExtendEvent {
target: {
value: string | number
}
}
// 卡片盒子元素
interface Obs {
title?: string
@ -63,10 +74,10 @@ interface PropGoods {
obj: {
sale_mode?: number | string
}
updateList: (list: any[]) => void
updateData: (data: Record<string, any>) => void
}
const GoodsItem = (props: PropGoods) => {
const { list = [], obj = {}, updateList } = props
const { list = [], obj = {}, updateData } = props
const [goodsList, setGoodsList] = useState(list)
@ -114,6 +125,19 @@ const GoodsItem = (props: PropGoods) => {
item.product_colors = item.product_colors.map((it) => {
if (it.id === editPayload.current[0]) {
it.sale_price = it.origin_price + formatPriceMul(value)
if (obj?.sale_mode === EnumSaleMode.Bulk) {
// 计算金额
it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatWeightDiv(it.estimate_weight) * it.roll)
}
else if (obj?.sale_mode === EnumSaleMode.Plate) {
// 剪板
it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length))
}
else {
// 散剪
it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length) / formatMeterDiv(it.length_to_weight_rate)).toFixed(0)
console.log('estimate_amount', it.estimate_amount, formatPriceDiv(it.estimate_amount, 100, true))
}
}
return it
})
@ -122,7 +146,11 @@ const GoodsItem = (props: PropGoods) => {
})
setGoodsList(res)
handleCancel()
updateList(res)
updateData({
product_list: res,
// 计算总金额
estimate_amount: res.reduce((acc, cur) => acc + cur.product_colors.reduce((a, c) => a + c.estimate_amount, 0), 0),
})
}
// 批量调整点击确认
@ -132,6 +160,18 @@ const GoodsItem = (props: PropGoods) => {
if (item.id === editPayload.current[0]) {
item.product_colors = item.product_colors.map((it) => {
it.sale_price = it.origin_price + formatPriceMul(value)
if (obj?.sale_mode === EnumSaleMode.Bulk) {
// 计算金额
it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatWeightDiv(it.estimate_weight) * it.roll)
}
else if (obj?.sale_mode === EnumSaleMode.Plate) {
// 剪板
it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length))
}
else {
// 散剪
it.estimate_amount = formatPriceMul(Number(formatPriceDiv(it.sale_price)) * formatMeterDiv(it.length) / formatMeterDiv(it.length_to_weight_rate))
}
return it
})
}
@ -139,20 +179,30 @@ const GoodsItem = (props: PropGoods) => {
})
setGoodsList(res)
handleCancel()
updateList(res)
updateData({
product_list: res,
// 计算总金额
estimate_amount: res.reduce((acc, cur) => acc + cur.product_colors.reduce((a, c) => a + c.estimate_amount, 0), 0),
})
}
// 批量调整
const defaultValue = '-1.5'
// 单价调整
const [value, setValue] = useState('-1.5')
const [value, setValue] = useState(defaultValue)
const handleInput = (e) => {
const handleInput = (e: CommonEvent & ExtendEvent) => {
const res = e.detail.value
setValue(res)
return res
}
const errorMsg = useMemo(() => {
let msg = ''
if (Number(value) < -3) {
console.log('errorMsg', value)
if (/[a-zA-Z]/.test(value) || Number.isNaN(Number(value))) {
msg = '请填写数字'
}
else if (Number(value) < -3) {
msg = '不能小于-3'
}
else {
@ -185,13 +235,31 @@ const GoodsItem = (props: PropGoods) => {
<View>
<View className={styles.item_right_top}>
<View className={styles.itemName}>{formatRemoveHashTag(it.code)}# {it.name}</View>
<View className={styles.itemNums}>x{obj?.sale_mode === EnumSaleMode.Bulk ? it.roll : formatMeterDiv(it.length)}{obj?.sale_mode === 0 ? '条' : 'm'}</View>
<View className={styles.itemNums}>x{obj?.sale_mode === EnumSaleMode.Bulk ? it.roll : formatMeterDiv(it.length)}{obj?.sale_mode === 0 ? '条' : ''}</View>
</View>
<View className={styles.item_right_Bottom}>
<View className={styles.flexBox}>
<View className={styles.itemMoney}>¥{formatPriceDiv(it.sale_price)}/{obj?.sale_mode === EnumSaleMode.Plate ? 'm' : 'kg'}</View>
<View className={styles.itemMoney}>¥{formatPriceDiv(it.sale_price, 100, true)}/{obj?.sale_mode === EnumSaleMode.Plate ? 'm' : 'kg'}</View>
{
(obj?.sale_mode === EnumSaleMode.Bulk && it?.sale_price !== it?.standard_price) ? <View className={styles.lastBox}>¥{formatPriceDiv(it?.standard_price)}/kg</View> : null
(obj?.sale_mode === EnumSaleMode.Bulk && it?.sale_price !== it?.standard_price)
? <View className={styles.lastBox}>
¥{formatPriceDiv(it?.standard_price, 100, true)}/kg
</View>
: null
}
{
(obj?.sale_mode === EnumSaleMode.Plate && it?.sale_price !== it?.standard_price)
? <View className={styles.lastBox}>
¥{formatPriceDiv(it?.standard_price, 100, true)}/m
</View>
: null
}
{
(obj?.sale_mode === EnumSaleMode.BulkCut && it?.sale_price !== it?.standard_price)
? <View className={styles.lastBox}>
¥{formatPriceDiv(it?.standard_price, 100, true)}/kg
</View>
: null
}
<View onClick={() => handleEdit(it.id, item.id)}>
<IconFont name="icon-bianji1" color="#3d85ff"></IconFont>
@ -261,6 +329,8 @@ const SubmitOrder = () => {
const [infoObj, setInfoObj] = useState<any>({})
let selectId = -1
const isBuyNew = useRef(false)
// 收货方法,1:自提2物流
const [receivingStatus, setReceivingStatus] = useState<any>(null)
// 切换自提或者物流
@ -300,7 +370,7 @@ const SubmitOrder = () => {
// 获取订单详情
const getDetail = async() => {
let arr: any[] = []
setPusername(decodeURIComponent(router.params.purchaser_name))
console.log('purchaser_name', router.params.purchaser_name)
arr = JSON.parse(decodeURIComponent(router.params.shopping_cart_product_color_list))
const list: any[] = []
arr?.forEach((item) => {
@ -328,6 +398,40 @@ const SubmitOrder = () => {
})
}
const { fetchData } = SaleOrderPreViewBuyNow()
// 立即购买
const getOnceDetail = async() => {
const sale_order_product_color_list = JSON.parse(router?.params?.sale_order_product_color_list as string) || []
if (sale_order_product_color_list?.length > 0) {
const arr: any[] = []
const sale_mode = Number(router?.params.sale_mode)
sale_order_product_color_list.forEach((item) => {
arr.push({
length: item?.length || 0,
roll: item.roll,
product_color_id: item.id,
sale_price: sale_mode === EnumSaleMode.Bulk ? item.bulk_price : sale_mode === EnumSaleMode.Plate ? item.length_cut_price : item.weight_cut_price,
})
})
const res = await fetchData({
sale_mode,
sale_order_product_color_list: arr,
purchaser_id: Number(router?.params.purchaser_id),
})
setInfoObj({
...res.data,
product_list: res.data.product_list?.map((item) => {
item.product_colors = item.product_colors.map((it) => {
// 用于存储原始价格,(单价/批量)调整价格
it.origin_price = it.sale_price
return it
})
return item
}),
})
}
}
// 备注操作
const [showDesc, setShowDesc] = useState(false)
const getRemark = useCallback(async(e) => {
@ -345,19 +449,34 @@ const SubmitOrder = () => {
// 提交订单
const { fetchData: postFetch } = MpSaleOrderPost()
const { fetchData: postOnceFetch } = SaleOrderSubmitBuyNow()
const handSure = () => {
if (receivingStatus == 2 && !infoObj.address_id) {
return alert.error('请选择地址')
}
const list: any[] = []
infoObj.product_list.forEach((item) => {
item.product_colors.forEach((it) => {
list.push({
sale_price: it.sale_price,
shopping_cart_product_color_id: Number(it.id),
if (!isBuyNew.current) {
infoObj.product_list.forEach((item) => {
item.product_colors.forEach((it) => {
list.push({
sale_price: it.sale_price,
shopping_cart_product_color_id: Number(it.id),
})
})
})
})
}
else {
infoObj.product_list.forEach((item) => {
item.product_colors.forEach((it) => {
list.push({
length: it.length,
roll: it.roll,
sale_price: it.sale_price,
product_color_id: Number(it.id),
})
})
})
}
const query = {
address_id: Number(infoObj.address_id) ? Number(infoObj.address_id) : 0,
list,
@ -378,7 +497,13 @@ const SubmitOrder = () => {
title: '请稍等...',
mask: true,
})
const res = await postFetch(query)
let res
if (isBuyNew.current) {
res = await postOnceFetch(query)
}
else {
res = await postFetch(query)
}
if (res?.msg === 'success') {
Taro.showToast({
title: '成功',
@ -448,13 +573,22 @@ const SubmitOrder = () => {
useEffect(() => {
getAddress()
getDetail()
console.log('isBuyNew', router.params.isBuyNew)
setPusername(decodeURIComponent(router.params.purchaser_name))
isBuyNew.current = JSON.parse(router.params.isBuyNew)
// 判断立即购买
if (isBuyNew.current) {
getOnceDetail()
}
else {
getDetail()
}
}, [])
const updateList = (list: any[]) => {
const updateData = (data: Record<string, any>) => {
setInfoObj(val => ({
...val,
product_list: list,
...data,
}))
}
@ -478,7 +612,7 @@ const SubmitOrder = () => {
</View>
</DefaultBoxWithMemo>
<View className={styles.productBox}>
<GoodsItemWithMemo list={infoObj?.product_list} obj={infoObj} updateList={updateList}></GoodsItemWithMemo>
<GoodsItemWithMemo list={infoObj?.product_list} obj={infoObj} updateData={updateData} ></GoodsItemWithMemo>
<View className={styles.flexMoney}>
<View className={styles.flexTotalBox}>
<View className={styles.totalFont}></View>
@ -499,11 +633,13 @@ const SubmitOrder = () => {
</View>
<View className={styles.bottomFlex}>{infoObj.product_list?.length} {infoObj.total_colors} {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View>
</View>
<View className={styles.rightBottom} onClick={() => handSure()}></View>
<View className={styles.rightBottom} onClick={handSure}></View>
</View>
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
<Remark onSave={e => getRemark(e)} defaultValue={infoObj.remark} showInput={!!showDesc} />
{
showDesc && <Remark onSave={e => getRemark(e)} defaultValue={infoObj.remark} />
}
</Popup>
</View>
)

View File

@ -1,48 +1,48 @@
.order_popup{
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 0;
.order_popup_title{
color: $font_size_big;
font-weight: 700;
color: #000000;
padding-bottom: 20px;
}
.order_popup_input{
width: 100%;
padding: 0 25px;
box-sizing: border-box;
margin-top: 43px;
position: relative;
.descDataNum{
position: absolute;
right: 40px;
bottom: 10px;
height: 39px;
font-size: $font_size_medium;
color: $color_font_two;
}
textarea{
background-color: #f3f3f3;
border-radius: 10px;
width: 100%;
height: 313px;
padding: 20px;
padding-bottom: 50px;
box-sizing: border-box;
font-size: $font_size;
border: 2px solid #e6e6e6;
}
.order_popup {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 0;
.order_popup_title {
color: $font_size_big;
font-weight: 700;
color: #000000;
padding-bottom: 20px;
}
.order_popup_input {
width: 100%;
padding: 0 25px;
box-sizing: border-box;
margin-top: 43px;
position: relative;
.descDataNum {
position: absolute;
right: 40px;
bottom: 10px;
height: 39px;
font-size: $font_size_medium;
color: $color_font_two;
}
.order_save_address{
height: 82px;
background: #007aff;
border-radius: 40px;
width: 668px;
text-align: center;
line-height: 82px;
color: #fff;
margin-top: 60px;
}
}
textarea {
background-color: white;
border-radius: 10px;
width: 100%;
height: 313px;
padding: 20px;
padding-bottom: 50px;
box-sizing: border-box;
font-size: $font_size;
border: 2px solid #e6e6e6;
}
}
.order_save_address {
height: 82px;
background: #007aff;
border-radius: 40px;
width: 668px;
text-align: center;
line-height: 82px;
color: #fff;
margin-top: 60px;
}
}