🐞 fix(ID1001342取消掉已经添加的剪样后刷新页面依然显示继续添加):

This commit is contained in:
czm 2023-03-01 17:30:30 +08:00
parent aab41c0653
commit 02f807824d
3 changed files with 20 additions and 7 deletions

View File

@ -33,7 +33,7 @@ export interface ColorItem {
export interface Param { export interface Param {
show: boolean show: boolean
product_id: number product_id: number
onClose?: () => void onClose?: (val: number) => void
onSelected?: (val: ColorItem[]) => void onSelected?: (val: ColorItem[]) => void
defaultValueIds?: number[] defaultValueIds?: number[]
} }
@ -60,7 +60,7 @@ export default memo((props: Param) => {
const initData = (data) => { const initData = (data) => {
if (defaultValueIds.length > 0) { if (defaultValueIds.length > 0) {
return data.map((item, index) => { return data?.map((item, index) => {
if (defaultValueIds.includes(item.id)) { if (defaultValueIds.includes(item.id)) {
return data[index] = { ...item, status: true } return data[index] = { ...item, status: true }
} }
@ -97,8 +97,16 @@ export default memo((props: Param) => {
}) })
onSelected?.(data) onSelected?.(data)
} }
const onCloseEven = () => {
let num = 0
colorList?.map((item) => {
if (item.status) { num++ }
})
onClose?.(num)
}
return <View className={styles.main}> return <View className={styles.main}>
<Popup show={show} showTitle={false} onClose={onClose}> <Popup show={show} showTitle={false} onClose={onCloseEven}>
<View className={styles.header}> <View className={styles.header}>
<Text>( {colorList.length} )</Text> <Text>( {colorList.length} )</Text>
<Text>A422cm*30cm</Text> <Text>A422cm*30cm</Text>
@ -113,7 +121,7 @@ export default memo((props: Param) => {
</ScrollView> </ScrollView>
</View> </View>
<View className={styles.btns}> <View className={styles.btns}>
<View className={styles.cancel} onClick={onClose}></View> <View className={styles.cancel} onClick={onCloseEven}></View>
<View className={classNames(styles.submit, selectCount && styles.selected)} onClick={onSubmit}>({selectCount})</View> <View className={classNames(styles.submit, selectCount && styles.selected)} onClick={onSubmit}>({selectCount})</View>
</View> </View>
</Popup> </Popup>

View File

@ -45,7 +45,6 @@ export default memo((props: ParamType) => {
return false return false
} }
}, [selectList]) }, [selectList])
return <Index value={props.value} onSelect={props.onSelect} isDisabled={isDisabled} /> return <Index value={props.value} onSelect={props.onSelect} isDisabled={isDisabled} />
}) })

View File

@ -103,7 +103,7 @@ export default () => {
const onSelectData = (val: ParamItem) => { const onSelectData = (val: ParamItem) => {
setShowColorList(true) setShowColorList(true)
setSelectItem(val) setSelectItem(val)
setSelectColorIds([])
// 获取该面料下的颜色数据 // 获取该面料下的颜色数据
const index = selectProsuctIds.indexOf(val.id) const index = selectProsuctIds.indexOf(val.id)
if (index !== -1) { if (index !== -1) {
@ -114,7 +114,13 @@ export default () => {
setSelectColorIds(colorIds) setSelectColorIds(colorIds)
} }
} }
const onClose = () => { const onClose = (val: number) => {
if (!val) {
const res = selectProcutColors?.filter(item => item.id !== selectItem?.id)
const res2 = selectProsuctIds?.filter(item => item !== selectItem?.id)
setSelectProcutColors(() => res)
setSelectProsuctIds(() => res2)
}
setShowColorList(false) setShowColorList(false)
} }