🐞 fix(ID1001342取消掉已经添加的剪样后刷新页面依然显示继续添加):
This commit is contained in:
parent
aab41c0653
commit
02f807824d
@ -33,7 +33,7 @@ export interface ColorItem {
|
||||
export interface Param {
|
||||
show: boolean
|
||||
product_id: number
|
||||
onClose?: () => void
|
||||
onClose?: (val: number) => void
|
||||
onSelected?: (val: ColorItem[]) => void
|
||||
defaultValueIds?: number[]
|
||||
}
|
||||
@ -60,7 +60,7 @@ export default memo((props: Param) => {
|
||||
|
||||
const initData = (data) => {
|
||||
if (defaultValueIds.length > 0) {
|
||||
return data.map((item, index) => {
|
||||
return data?.map((item, index) => {
|
||||
if (defaultValueIds.includes(item.id)) {
|
||||
return data[index] = { ...item, status: true }
|
||||
}
|
||||
@ -97,8 +97,16 @@ export default memo((props: Param) => {
|
||||
})
|
||||
onSelected?.(data)
|
||||
}
|
||||
|
||||
const onCloseEven = () => {
|
||||
let num = 0
|
||||
colorList?.map((item) => {
|
||||
if (item.status) { num++ }
|
||||
})
|
||||
onClose?.(num)
|
||||
}
|
||||
return <View className={styles.main}>
|
||||
<Popup show={show} showTitle={false} onClose={onClose}>
|
||||
<Popup show={show} showTitle={false} onClose={onCloseEven}>
|
||||
<View className={styles.header}>
|
||||
<Text>请选择色号剪样( {colorList.length} )</Text>
|
||||
<Text>剪样大小为A4,大约22cm*30cm</Text>
|
||||
@ -113,7 +121,7 @@ export default memo((props: Param) => {
|
||||
</ScrollView>
|
||||
</View>
|
||||
<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>
|
||||
</Popup>
|
||||
|
||||
@ -45,7 +45,6 @@ export default memo((props: ParamType) => {
|
||||
return false
|
||||
}
|
||||
}, [selectList])
|
||||
|
||||
return <Index value={props.value} onSelect={props.onSelect} isDisabled={isDisabled} />
|
||||
})
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ export default () => {
|
||||
const onSelectData = (val: ParamItem) => {
|
||||
setShowColorList(true)
|
||||
setSelectItem(val)
|
||||
|
||||
setSelectColorIds([])
|
||||
// 获取该面料下的颜色数据
|
||||
const index = selectProsuctIds.indexOf(val.id)
|
||||
if (index !== -1) {
|
||||
@ -114,7 +114,13 @@ export default () => {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user