@@ -3,17 +3,17 @@ 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'
interface props {
clickAdd : ( any ) = > void
// onInputEven?: (a: any, c: any) => void,
clickReduce : ( any ) = > void
handPlus : ( any ) = > void
modeFont? : number
value : {
showInput? : boolean
nums? : string
bulk_price? : Number | 0
bulk_price? : Number
length_cut_price? : Number
weight_cut_price? : Number
code? : string
@@ -33,21 +33,31 @@ interface props {
onBlur ? : ( a : any , c : any ) = > void
}
const GoodsItem = ( props : props ) = > {
const [ value , setValue ] = useState < any > ( { count : props.value.nums } )
const {
clickAdd ,
clickReduce ,
handPlus ,
modeFont ,
value : valueInfo ,
onBlur ,
} = props
const [ value , setValue ] = useState < any > ( { count : valueInfo.nums } )
console . log ( value . count , 'value.count' )
const onInputEven = ( e ) = > {
const res = e . detail . value
if ( props . modeFont == 0 ) {
if ( modeFont == 0 ) {
if ( Number ( res ) < 1 ) {
setValue ( { count : '' } )
}
}
if ( props . modeFont == 1 ) {
if ( modeFont == 1 ) {
if ( Number ( res ) < 0 ) {
setValue ( { count : '' } )
}
}
if ( props . modeFont == 2 ) {
if ( modeFont == 2 ) {
if ( Number ( res ) < 0 ) {
setValue ( { count : '' } )
}
@@ -55,63 +65,50 @@ const GoodsItem = (props: props) => {
}
const type = useMemo ( ( ) = > {
if ( props . modeFont === 0 ) {
if ( modeFont === 0 ) {
return 'number'
}
else {
return 'digit'
}
} , [ props . modeFont ] )
} , [ modeFont ] )
const labAndImgObj = useCallback ( ( item ) = > {
return { lab : item.lab , rgb : item.rgb , texture_url : item.texture_url }
} , [ ] )
return (
< View className = { styles . goodsBox } >
{ /* {
props?.value?.rgb?.r == 0 && props?.value?.rgb?.g == 0 && props?.value?.rgb?.b == 0 && <Image className={styles.pic} mode="aspectFill" src="https://test.cdn.zzfzyc.com/mall/no_img.png"></Image>
}
{
(props?.value?.rgb?.r != 0 || props?.value?.rgb?.g != 0 || props?.value?.rgb?.b != 0)
&& <View className={styles.pic} style={{ backgroundColor: `rgb(${props?.value?.rgb?.r} ${props?.value?.rgb?.g} ${props?.value.rgb?.b})` }}></View>
} */ }
< View className = { styles . pic } >
< LabAndImg value = { labAndImgObj ( props . value ) } / >
< LabAndImg value = { labAndImgObj ( valueInfo ) } / >
< / View >
< View className = { styles . rightGoodbox } >
< View className = { styles . leftFontsbox } >
< View className = { styles . title } > { props . value ? . code } { props . value ? . name } < / View >
< View className = { styles . productNums } > 剩 : { props . value ? . roll } 件 < / View >
< View className = { styles . title } > { valueInfo ? . code } { valueInfo ? . name } < / View >
< View className = { styles . productNums } > 剩 : { valueInfo ? . roll } 件 < / View >
{
props ? . modeFont === 0 && < View className = { styles . productName } > 空 差 : { props ? . value ? . weight_error as number / 1000 || 0 } Kg < / View >
modeFont === 0 && < View className = { styles . productName } > 空 差 : { formatWeightDiv ( valueInfo ? . weight_error ) || 0 } Kg < / View >
}
< / View >
< View className = { styles . rightFontsbox } >
< View className = { styles . moneyFlex } >
{
props ? . modeFont === 0 && props . value ? . last_bulk_price !== props . value ? . bulk_price && < View className = { styles . lastBox } > ¥ { props ? . modeFont === 0 ? Number ( props . value ? . last_bulk_price ) / 100 : props.modeFont === 1 ? Number ( props . value ? . last_length_cut_price ) / 100 : Number ( props . value ? . last_weight_cut_price ) / 100 } { props . modeFont as any != 1 ? '/Kg' : '/m' } < / View >
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 >
}
< View className = { styles . money } > ¥ { props ? . modeFont === 0 ? Number ( props . value ? . bulk_price ) / 100 : props.modeFont === 1 ? Number ( props . value ? . length_cut_price ) / 100 : Number ( props . value ? . weight_cut_price ) / 100 } { props . modeFont != 1 ? '/Kg' : '/m' } < / View >
< 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 >
{
props . value . showInput && < View className = { styles . inputBox } >
< View className = { styles . reduceBox } onClick = { ( ) = > { props . clickReduce ? . ( props . value ) } } >
< View className = { styles . reduce } >
< / View >
valueInfo . showInput
? < View className = { styles . inputBox } >
< View className = { styles . reduceBox } onClick = { ( ) = > { clickReduce ? . ( valueInfo ) } } >
< View className = { styles . reduce } > < / View >
< / View >
< View className = { styles . numsBox } >
< Input alwaysEmbed cursorSpacing = { 100 } adjustPosition type = { type as any } value = { value . count } onInput = { onInputEven } onBlur = { e = > props . onBlur ? . ( e , props . value . id ) } > < / Input >
{ /* <Input type={type as any} value={value.count} onInput={($event) => onInputEven($event, props.value)}></Input> */ }
< Input alwaysEmbed cursorSpacing = { 100 } adjustPosition type = { type as any } value = { value . count } onInput = { onInputEven } onBlur = { e = > onBlur ? . ( e , valueInfo . id ) } > < / Input >
< / View >
< View className = { styles . addBox } onClick = { ( ) = > { props . handPlus ? . ( props . value ) } } >
+
< View className = { styles . addBox } onClick = { ( ) = > handPlus ? . ( valueInfo ) } > + < / View >
< / View >
< / View >
}
{
! props . value . showInput && < View className = { styles . addtine } onClick = { ( ) = > props . clickAdd ? . ( props . value ) } > + < / View >
: < View className = { styles . addtine } onClick = { ( ) = > clickAdd ? . ( valueInfo ) } > + < / View >
}
< / View >
< / View >
@@ -119,4 +116,3 @@ const GoodsItem = (props: props) => {
)
}
export default memo ( GoodsItem )
// ($event) => onInputEven($event, props.value)