Commit b2a29589 by Denglingling

增加已选弹窗,清空当前所有选择,以及增加可打开已选弹窗的判断

(cherry picked from commit 8c00faca)
parent ae4d1023
...@@ -69,7 +69,7 @@ class ProductModel extends Component { ...@@ -69,7 +69,7 @@ class ProductModel extends Component {
// } // }
// ], // ],
topActiveIndex: 0, topActiveIndex: 0,
allCountQuantity: 0, // allCountQuantity: 0,
// SELECTED_QUQNTITY: 'selectedQuantity', // 中类数量 // SELECTED_QUQNTITY: 'selectedQuantity', // 中类数量
// SELECTED_DATA_ARR: 'selectedDataArr', // 中类已选元素 // SELECTED_DATA_ARR: 'selectedDataArr', // 中类已选元素
...@@ -195,7 +195,7 @@ class ProductModel extends Component { ...@@ -195,7 +195,7 @@ class ProductModel extends Component {
// 修改列表计算后数据 // 修改列表计算后数据
handleCalCallBack(item, index, dataName){ handleCalCallBack(item, index, dataName){
let {topProcOptionList, topActiveIndex, allCountQuantity} = this.state let {topProcOptionList, topActiveIndex} = this.state
let {modelOption} = this.props let {modelOption} = this.props
console.log('--已选===',item, topActiveIndex, index) console.log('--已选===',item, topActiveIndex, index)
...@@ -238,7 +238,7 @@ class ProductModel extends Component { ...@@ -238,7 +238,7 @@ class ProductModel extends Component {
// 修改左侧分类汇总 // 修改左侧分类汇总
// 本地测试 // 本地测试
let curCalField = 'quantity' let curCalField = 'quantity'
allCountQuantity = 0 // 初始化 let allCountQuantity = 0 // 初始化
if(topProcOptionList[topActiveIndex][SELECTED_DATA_ARR].length > 0) { if(topProcOptionList[topActiveIndex][SELECTED_DATA_ARR].length > 0) {
topProcOptionList[topActiveIndex][SELECTED_QUQNTITY] = 0 topProcOptionList[topActiveIndex][SELECTED_QUQNTITY] = 0
topProcOptionList[topActiveIndex][SELECTED_DATA_ARR].map((selItem) => { topProcOptionList[topActiveIndex][SELECTED_DATA_ARR].map((selItem) => {
...@@ -258,22 +258,16 @@ class ProductModel extends Component { ...@@ -258,22 +258,16 @@ class ProductModel extends Component {
} }
allCountQuantity += proItem[SELECTED_QUQNTITY] allCountQuantity += proItem[SELECTED_QUQNTITY]
}) })
this.setState({ // this.setState({
allCountQuantity // allCountQuantity
}) // })
// 回调函数 // 回调函数
console.log('---计算后 ', topProcOptionList, allCountQuantity) console.log('---计算后 ', topProcOptionList, allCountQuantity)
this.props.modelCallBack(topProcOptionList) this.props.modelCallBack(topProcOptionList)
if(allCountQuantity === 0){
// this.setState({ this.closeModal()
// topProcOptionList }
// })
} }
} }
...@@ -288,6 +282,27 @@ class ProductModel extends Component { ...@@ -288,6 +282,27 @@ class ProductModel extends Component {
// 清空 // 清空
handleClearRubbish() { handleClearRubbish() {
console.log('清空======') console.log('清空======')
let {topProcOptionList} = this.state
// 本地测试
let curCalField = 'quantity'
topProcOptionList.map(function(listItem) {
listItem[SELECTED_QUQNTITY] = 0
listItem[SELECTED_DATA_ARR] = []
listItem[DEFAULT_SECOND_DATA].forEach(function(deIt) {
deIt[curCalField] = 0
})
})
// this.setState({
// allCountQuantity: 0
// })
// 回调函数
console.log('---清空之后===== ', topProcOptionList)
this.props.modelCallBack(topProcOptionList)
this.closeModal()
} }
// 返回清空 // 返回清空
...@@ -311,7 +326,7 @@ class ProductModel extends Component { ...@@ -311,7 +326,7 @@ class ProductModel extends Component {
// 返回顶部编辑选项 // 返回顶部编辑选项
renderTopProItem() { renderTopProItem() {
let { topProcOptionList, topActiveIndex } = this.state let { topProcOptionList, topActiveIndex } = this.state
let {modelOption} = this.props // let {modelOption} = this.props
return ( return (
<ChooseCardList <ChooseCardList
...@@ -374,7 +389,8 @@ class ProductModel extends Component { ...@@ -374,7 +389,8 @@ class ProductModel extends Component {
// } // }
let {modelOption} = this.props // let {modelOption} = this.props
let curData = topProcOptionList[topActiveIndex] let curData = topProcOptionList[topActiveIndex]
console.log('已选展示信息 === curData---', topProcOptionList, topActiveIndex, curData) console.log('已选展示信息 === curData---', topProcOptionList, topActiveIndex, curData)
let localBottomContData = [] let localBottomContData = []
...@@ -410,7 +426,6 @@ class ProductModel extends Component { ...@@ -410,7 +426,6 @@ class ProductModel extends Component {
activeOpacity={1} activeOpacity={1}
style={styles.column_container}> style={styles.column_container}>
<PicTitDetaiCalcu <PicTitDetaiCalcu
listItem={item} listItem={item}
listIndex={index} listIndex={index}
...@@ -418,15 +433,12 @@ class ProductModel extends Component { ...@@ -418,15 +433,12 @@ class ProductModel extends Component {
// subCalCallBack={(item,index) => this.handleCalCallBack(item,index,'localBottomContData')} // subCalCallBack={(item,index) => this.handleCalCallBack(item,index,'localBottomContData')}
subCalCallBack={(item,index) => this.handleCalCallBack(item,index)} subCalCallBack={(item,index) => this.handleCalCallBack(item,index)}
titText={'title'} titText={'title'}
// tipTextOne={'tip1'}
// tipTextTwo={'tip2'}
listImgIcon={'imgIcon'} listImgIcon={'imgIcon'}
listPicType={'SQUARE'} listPicType={'SQUARE'}
listStyleImg={styles.list_icon} listStyleImg={styles.list_icon}
listStyleTit={styles.list_tit} listStyleTit={styles.list_tit}
/> />
{/* <View style={styles.ri_inner}> {/* <View style={styles.ri_inner}>
<View style={styles.oth_img_box}> <View style={styles.oth_img_box}>
<Image style={styles.oth_img} source={item.imgIcon}/> <Image style={styles.oth_img} source={item.imgIcon}/>
...@@ -467,7 +479,7 @@ class ProductModel extends Component { ...@@ -467,7 +479,7 @@ class ProductModel extends Component {
// 返回底部按钮 // 返回底部按钮
renderFooterBtnItem() { renderFooterBtnItem() {
let {topProcOptionList, selectShowPopup} = this.state let {topProcOptionList} = this.state
let allCountQuantity = 0 let allCountQuantity = 0
topProcOptionList.map(proItem => { topProcOptionList.map(proItem => {
......
...@@ -61,7 +61,7 @@ class ChooseProductPage extends Component { ...@@ -61,7 +61,7 @@ class ChooseProductPage extends Component {
// SELECTED_QUQNTITY: 'selectedQuantity', // 中类数量 // SELECTED_QUQNTITY: 'selectedQuantity', // 中类数量
// SELECTED_DATA_ARR: 'selectedDataArr', // 中类已选元素 // SELECTED_DATA_ARR: 'selectedDataArr', // 中类已选元素
// DEFAULT_SECOND_DATA: 'localSecondData', // 中类原本元素 // DEFAULT_SECOND_DATA: 'localSecondData', // 中类原本元素
allCountQuantity: 0 // allCountQuantity: 0
} }
} }
...@@ -76,7 +76,7 @@ class ChooseProductPage extends Component { ...@@ -76,7 +76,7 @@ class ChooseProductPage extends Component {
// 顶部产品点击 // 顶部产品点击
handleTopNav(item, index) { handleTopNav(item, index) {
console.warn('top产品--',item, index) console.log('top产品--',item, index)
this.setState({ this.setState({
topActiveIndex: index topActiveIndex: index
}) })
...@@ -84,12 +84,12 @@ class ChooseProductPage extends Component { ...@@ -84,12 +84,12 @@ class ChooseProductPage extends Component {
// 左侧标题点击 // 左侧标题点击
handleLeftNav(item, index) { handleLeftNav(item, index) {
console.warn('左侧标题--', index, item) console.log('左侧标题--', index, item)
let {leftOptionList} = this.state let {leftOptionList} = this.state
this.setState({ this.setState({
leftActiveIndex: index, leftActiveIndex: index,
rightSecondData: leftOptionList[index][DEFAULT_SECOND_DATA] // 本地数据 rightSecondData: leftOptionList[index][DEFAULT_SECOND_DATA] // 本地数据
// rightSecondData: leftOptionList[index].localSecondData // 本地数据 // rightSecondData: leftOptionList[index].localSecondData // 本地数据
}) })
} }
...@@ -103,11 +103,10 @@ class ChooseProductPage extends Component { ...@@ -103,11 +103,10 @@ class ChooseProductPage extends Component {
// 计算中级数量 // 计算中级数量
handleChangeCount(count, coutFieName) { handleChangeCount(count, coutFieName) {
let {leftActiveIndex, leftOptionList, allCountQuantity, defaultThridShow, rightSecondData} = this.state let {leftActiveIndex, leftOptionList, defaultThridShow, rightSecondData} = this.state
console.log('计算中级数量===', count, leftActiveIndex, defaultThridShow, rightSecondData, coutFieName) console.log('计算中级数量===', count, leftActiveIndex, defaultThridShow, rightSecondData, coutFieName)
// leftOptionList[leftActiveIndex][SELECTED_QUQNTITY] = count
allCountQuantity = 0 // 初始化 // let allCountQuantity = 0 // 初始化
leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = [] leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = []
leftOptionList.map(function(leItem, leIndex) { leftOptionList.map(function(leItem, leIndex) {
...@@ -128,35 +127,49 @@ class ChooseProductPage extends Component { ...@@ -128,35 +127,49 @@ class ChooseProductPage extends Component {
}) })
} }
} }
allCountQuantity += leItem[SELECTED_QUQNTITY] // allCountQuantity += leItem[SELECTED_QUQNTITY]
// allCountQuantity += leItem[SELECTED_DATA_ARR].length
}) })
console.log('allCountQuantity---', allCountQuantity, leftOptionList) console.log('计算中级之后---', leftOptionList)
this.setState({ this.setState({
leftOptionList, leftOptionList,
allCountQuantity // allCountQuantity
}) })
} }
// 共计已选弹窗 // 共计已选弹窗
handleCloseSelectModal(show) { handleCloseSelectModal(show) {
console.warn('修改共计已选', show) console.log('修改共计已选', show)
this.setState({ this.setState({
selectShowPopup: show selectShowPopup: show
}) })
} }
// 计算所有已选数量
getAllCountQuantity() {
let {leftOptionList} = this.state
let allCountQuantity = 0
leftOptionList.map(leItem => {
if(!leItem[SELECTED_QUQNTITY]){
leItem[SELECTED_QUQNTITY] = 0
}
allCountQuantity += leItem[SELECTED_QUQNTITY]
})
return allCountQuantity
}
// 点击共计已选 // 点击共计已选
handleSubSelected(show) { handleSubSelected(show) {
// console.log('show-----', show) // console.log('show-----', show)
this.handleCloseSelectModal(!show) if(this.getAllCountQuantity() !== 0) {
this.handleCloseSelectModal(!show)
}
} }
// 点击选好了 // 点击选好了
handleSubmit() { handleSubmit() {
console.warn('选好了', this.props.navigation.navigate) console.log('选好了', this.props.navigation.navigate)
this.handleCloseSelectModal(false) this.handleCloseSelectModal(false)
console.warn('携带数据,返回到自助下单') console.log('携带数据,返回到自助下单')
} }
// 已选修改回调 // 已选修改回调
...@@ -326,33 +339,20 @@ class ChooseProductPage extends Component { ...@@ -326,33 +339,20 @@ class ChooseProductPage extends Component {
// 返回底部按钮 // 返回底部按钮
renderFooterBtnItem() { renderFooterBtnItem() {
let {selectShowPopup, leftOptionList} = this.state let {selectShowPopup, leftOptionList} = this.state
let allCountQuantity = 0 // let allCountQuantity = 0
leftOptionList.map(leItem => { // leftOptionList.map(leItem => {
if(!leItem[SELECTED_QUQNTITY]){ // if(!leItem[SELECTED_QUQNTITY]){
leItem[SELECTED_QUQNTITY] = 0 // leItem[SELECTED_QUQNTITY] = 0
} // }
allCountQuantity += leItem[SELECTED_QUQNTITY] // allCountQuantity += leItem[SELECTED_QUQNTITY]
}) // })
let allCountQuantity = this.getAllCountQuantity()
// console.log('返回底部按钮----', selectShowPopup) // console.log('返回底部按钮----', selectShowPopup)
return ( return (
<View style={list_common_item.sub_box}> <View style={list_common_item.sub_box}>
{/* <FooterBtnStyle
style={styles.sub_btn_left}
activeOpacity={.8}
title={'共计已选:666'}
textStyle= {[styles.sub_btn_tit, styles.sub_btn_left_text]}
onPress={() => this.handleSubSelected(selectShowPopup)}
/>
<FooterBtnStyle
style={styles.sub_btn_rig}
activeOpacity={.8}
title={'选好了'}
textStyle= {[styles.sub_btn_tit, styles.sub_btn_rig_text]}
onPress={() => this.handleSubmit(selectShowPopup)}
/> */}
<View style={list_common_item.sub_two_btn}> <View style={list_common_item.sub_two_btn}>
<TouchableOpacity <TouchableOpacity
activeOpacity={.8} activeOpacity={.8}
...@@ -374,7 +374,6 @@ class ChooseProductPage extends Component { ...@@ -374,7 +374,6 @@ class ChooseProductPage extends Component {
// modelShow={selectShowPopup} // modelShow={selectShowPopup}
show={ selectShowPopup } show={ selectShowPopup }
closeModal={(show) => this.handleCloseSelectModal(show)} closeModal={(show) => this.handleCloseSelectModal(show)}
// closeSelected={(show) => this.handleSubSelected(show)}
closeSubmit={() => this.handleSubmit()} closeSubmit={() => this.handleSubmit()}
modelOption={leftOptionList} modelOption={leftOptionList}
modelCallBack={(options) => this.handleSelectCallBack(options)} modelCallBack={(options) => this.handleSelectCallBack(options)}
......
...@@ -300,7 +300,7 @@ class ProductRightStyle extends Component { ...@@ -300,7 +300,7 @@ class ProductRightStyle extends Component {
// 单选耗材 -- 大类 // 单选耗材 -- 大类
renderOtherStyle() { renderOtherStyle() {
return( return(
<View style={styles.stencil_cont}> <View style={styles.cont_other_cont}>
<FlatList <FlatList
style={styles.cont_other_list} style={styles.cont_other_list}
keyExtractor={item => item.id} keyExtractor={item => item.id}
...@@ -448,12 +448,15 @@ const styles = StyleSheet.create({ ...@@ -448,12 +448,15 @@ const styles = StyleSheet.create({
height: '100%' height: '100%'
}, },
// other right // other right
cont_other_cont: {},
cont_other_list: { cont_other_list: {
paddingTop: 14 // paddingTop: 14
}, },
oth_container: { oth_container: {
flex: 1, // flex: 1,
marginBottom: 14 // marginBottom: 14
// paddingTop: 0,
// marginTop: 0
}, },
oth_inner: {}, oth_inner: {},
oth_box: {}, oth_box: {},
...@@ -509,52 +512,52 @@ const styles = StyleSheet.create({ ...@@ -509,52 +512,52 @@ const styles = StyleSheet.create({
}, },
cont_thr_list: {}, cont_thr_list: {},
thr_container: {}, thr_container: {},
thr_inner: { // thr_inner: {
paddingVertical: 0, // paddingVertical: 0,
paddingBottom: 26 // paddingBottom: 26
}, // },
thr_ot: { // thr_ot: {
fontFamily: font_family_regular, // fontFamily: font_family_regular,
fontSize: second_text_size, // fontSize: second_text_size,
color: first_text_color // color: first_text_color
}, // },
ri_num_box: { // ri_num_box: {
flexDirection: 'row', // flexDirection: 'row',
alignItems: 'center' // alignItems: 'center'
}, // },
thr_num_btn: { // thr_num_btn: {
width: pxSize(24), // width: pxSize(24),
height: pxSize(24), // height: pxSize(24),
// justifyContent: 'center', // // justifyContent: 'center',
// alignItems: 'center', // // alignItems: 'center',
// borderRadius: 50, // // borderRadius: 50,
// borderWidth: 1 // // borderWidth: 1
}, // },
thr_btn_left: { // thr_btn_left: {
// borderColor: '#E6E6E6' // // borderColor: '#E6E6E6'
marginRight: 4 // marginRight: 4
}, // },
thr_btn_right: { // thr_btn_right: {
// borderColor: foundation_color, // // borderColor: foundation_color,
// backgroundColor: promary_color // // backgroundColor: promary_color
marginLeft: 4 // marginLeft: 4
}, // },
thr_num_icon: { // thr_num_icon: {
// fontSize: 16 // // fontSize: 16
width: '100%', // width: '100%',
height: '100%' // height: '100%'
}, // },
thr_icon_left: { // thr_icon_left: {
// color: third_text_color // // color: third_text_color
}, // },
thr_icon_right: { // thr_icon_right: {
// color: title_text_color // // color: title_text_color
}, // },
btn_inner: {}, // btn_inner: {},
thr_num: { // thr_num: {
minWidth: pxSize(20), // minWidth: pxSize(20),
textAlign: 'center' // textAlign: 'center'
}, // },
}) })
export default ProductRightStyle; export default ProductRightStyle;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment