Commit 675f3776 by Denglingling

完善自助下单功能

(cherry picked from commit 0d182f54)
parent dab70cd1
...@@ -54,82 +54,9 @@ class ProductModel extends Component { ...@@ -54,82 +54,9 @@ class ProductModel extends Component {
this.state = { this.state = {
isVisible: this.props.show, isVisible: this.props.show,
topProcOptionList: [], topProcOptionList: [],
// [
// {
// title: '编辑产品'
// },
// {
// title: '螺钉盒'
// },
// {
// title: '器械包'
// },
// {
// title: '工具'
// }
// ],
topActiveIndex: 0, topActiveIndex: 0,
// allCountQuantity: 0,
// SELECTED_QUQNTITY: 'selectedQuantity', // 中类数量 // SELECTED_QUQNTITY: 'selectedQuantity', // 中类数量
// SELECTED_DATA_ARR: 'selectedDataArr', // 中类已选元素 // SELECTED_DATA_ARR: 'selectedDataArr', // 中类已选元素
// contOptionData: [ // 底部产品内容
// {
// "id": "0",
// title: '规格:JS-CGO PE 10',
// tip1: '型号:10',
// tip2: '物料代码:JUST00000104',
// value: 20,
// imgIcon: require('../../images/model_test.png'),
// select: false
// },
// {
// "id": "1",
// title: '规格:JS-CGO PE 10 11',
// tip1: '型号:10',
// tip2: '物料代码:JUST00000104',
// value: 0,
// imgIcon: require('../../images/model_test.png'),
// select: false
// },
// {
// "id": "2",
// title: '规格:JS-CGO PE 10 22',
// tip1: '型号:10',
// tip2: '物料代码:JUST00000104',
// value: 0,
// imgIcon: require('../../images/model_test.png'),
// select: false
// },
// {
// "id": "3",
// title: '规格:JS-CGO PE 10 33',
// tip1: '型号:10',
// tip2: '物料代码:JUST00000104',
// value: 0,
// imgIcon: require('../../images/model_test.png'),
// select: false
// },
// {
// "id": "4",
// title: '规格:JS-CGO PE 10 44',
// tip1: '型号:10',
// tip2: '物料代码:JUST00000104',
// value: 0,
// imgIcon: require('../../images/model_test.png'),
// select: false
// },
// {
// "id": "5",
// title: '规格:JS-CGO PE 10 55',
// tip1: '型号:10',
// tip2: '物料代码:JUST00000104',
// value: 0,
// imgIcon: require('../../images/model_test.png'),
// select: false
// }
// ]
} }
} }
...@@ -172,25 +99,6 @@ class ProductModel extends Component { ...@@ -172,25 +99,6 @@ class ProductModel extends Component {
this.props.closeModal(false); this.props.closeModal(false);
} }
/**
* 点击当前产品加减
* @param {object} item 当前小类数据
* @param {number} index 当前角标
* @param {boolean} isPlus 默认减法 false,加法 true,
*/
handelCalculationList(item, index, isPlus) {
// let { contOptionData } = this.state
// let { value } = contOptionData[index]
// if(isPlus) {
// contOptionData[index].value += 1
// } else if(!isPlus && value > 0) {
// contOptionData[index].value -= 1
// }
// this.setState({
// contOptionData
// })
}
// 修改列表计算后数据 // 修改列表计算后数据
handleCalCallBack(item, index, dataName){ handleCalCallBack(item, index, dataName){
let {topProcOptionList, topActiveIndex} = this.state let {topProcOptionList, topActiveIndex} = this.state
...@@ -346,7 +254,7 @@ class ProductModel extends Component { ...@@ -346,7 +254,7 @@ class ProductModel extends Component {
localBottomContData = curData[SELECTED_DATA_ARR] localBottomContData = curData[SELECTED_DATA_ARR]
} }
// console.log('已选展示信息---',curData,topActiveIndex, localBottomContData) console.log('已选展示信息---',curData,topActiveIndex, localBottomContData)
return( return(
<View style={styles.edit_cont}> <View style={styles.edit_cont}>
......
...@@ -24,7 +24,8 @@ class PicTitDetaiCalcu extends Component { ...@@ -24,7 +24,8 @@ class PicTitDetaiCalcu extends Component {
tipTextTwo: PropTypes.string, tipTextTwo: PropTypes.string,
tipTextTwoTit: PropTypes.string, tipTextTwoTit: PropTypes.string,
listImgIcon: PropTypes.string, listImgIcon: PropTypes.string,
listStyleImg: PropTypes.objec listStyleImg: PropTypes.objec,
plusCallBack: PropTypes.func, // 加法的回调函数
} }
constructor(props) { constructor(props) {
...@@ -42,9 +43,13 @@ class PicTitDetaiCalcu extends Component { ...@@ -42,9 +43,13 @@ class PicTitDetaiCalcu extends Component {
* @param {boolean} isPlus 默认减法 false,加法 true, * @param {boolean} isPlus 默认减法 false,加法 true,
*/ */
handelCalculation(item, index, isPlus) { handelCalculation(item, index, isPlus) {
// let { thridOptionData } = this.state let {calField, plusCallBack} = this.props
// let { value } = thridOptionData[index] if(isPlus && plusCallBack){
let {calField} = this.props console.log('加法回调======', item, index)
plusCallBack(item, index)
return
}
console.log('加法======')
item[calField] = Number(item[calField]) item[calField] = Number(item[calField])
if(Number.isNaN(item[calField])){ if(Number.isNaN(item[calField])){
item[calField] = 0 item[calField] = 0
...@@ -138,10 +143,6 @@ const styles = StyleSheet.create({ ...@@ -138,10 +143,6 @@ const styles = StyleSheet.create({
color: third_text_color, color: third_text_color,
fontFamily: font_family_regular fontFamily: font_family_regular
}, },
// ri_img_box: {
// width: 18,
// height: 18
// },
oth_box: { oth_box: {
paddingBottom: 2 paddingBottom: 2
}, },
...@@ -191,8 +192,6 @@ const styles = StyleSheet.create({ ...@@ -191,8 +192,6 @@ const styles = StyleSheet.create({
fontSize: 14, fontSize: 14,
color: first_text_color color: first_text_color
}, },
}) })
export default PicTitDetaiCalcu; export default PicTitDetaiCalcu;
\ No newline at end of file
...@@ -106,6 +106,7 @@ class ChooseProductPage extends Component { ...@@ -106,6 +106,7 @@ class ChooseProductPage extends Component {
let {leftActiveIndex, leftOptionList, 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] = 0
leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = [] leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = []
leftOptionList.map(function(leItem, leIndex) { leftOptionList.map(function(leItem, leIndex) {
......
...@@ -33,8 +33,13 @@ import StatusBarView from '../../common/StatusBarView'; ...@@ -33,8 +33,13 @@ import StatusBarView from '../../common/StatusBarView';
import ChooseCardList from '../../common/listDataComponent/ChooseCardList'; import ChooseCardList from '../../common/listDataComponent/ChooseCardList';
import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu'; import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu';
import PictureZoom from '../../common/listDataComponent/PictureZoom'; import PictureZoom from '../../common/listDataComponent/PictureZoom';
import localMockData from './mock/sen_mock';
import {cloneObject} from '../../../utils/Utils'; import {cloneObject} from '../../../utils/Utils';
import localMockData from './mock/sen_mock';
const SELECTED_QUQNTITY = 'selectedQuantity' // 三级数量
const SELECTED_DATA_ARR = 'selectedDataArr' // 三级已选元素
const DEFAULT_SECOND_DATA = 'localThridContData' // 三级原本元素
const DEFAULT_FIELD = 'quantity' // 计算的字段
class EditThirdLevelPage extends Component { class EditThirdLevelPage extends Component {
...@@ -48,31 +53,60 @@ class EditThirdLevelPage extends Component { ...@@ -48,31 +53,60 @@ class EditThirdLevelPage extends Component {
componentDidMount() { componentDidMount() {
let {params} = this.props.navigation.state let {params} = this.props.navigation.state
let that = this
console.log('本地测试数据====localMockData===', localMockData) console.log('本地测试数据====localMockData===', localMockData)
console.log('本地测试数据====localMockData===', localMockData.localThridOption[0].localThridContData[0]) console.log('本地测试数据====localMockData===', localMockData.localThridOption[0][DEFAULT_SECOND_DATA][0])
console.log('父组件传递的值==', params) console.log('父组件传递的值==', params)
// 赋值测试数据 // 赋值测试数据
this.setState({ this.setState({
topProcOptionList: cloneObject(localMockData.localThridOption) topProcOptionList: cloneObject(localMockData.localThridOption)
}, () => {
that.setAllSelectData()
}) })
} }
// 修改列表计算后数据 // 修改列表计算后数据
handleCalCallBack(item, index, dataName){ handleCalCallBack(item, index, dataName){
let {topProcOptionList, topActiveIndex} = this.state let {topProcOptionList, topActiveIndex} = this.state
let that = this
// console.log('修改列表计算后数据',item, index, dataName)
if(dataName && topProcOptionList[topActiveIndex][dataName]) { if(dataName && topProcOptionList[topActiveIndex][dataName]) {
topProcOptionList.map(function(listItem, listIndex) { topProcOptionList.map(function(listItem, listIndex) {
if(listIndex === topActiveIndex){ if(listIndex === topActiveIndex){
listItem[dataName][index] = item listItem[dataName][index] = item
} }
}) })
this.setState({ that.setState({
topProcOptionList topProcOptionList
},() => {
that.setAllSelectData()
}) })
} }
} }
// 设置当前所有已选值
setAllSelectData() {
let {topProcOptionList} = this.state
topProcOptionList.map(function(listItem) {
listItem[SELECTED_QUQNTITY] = 0
listItem[SELECTED_DATA_ARR] = []
if(listItem[DEFAULT_SECOND_DATA].length){
listItem[DEFAULT_SECOND_DATA].forEach(function(chItem) {
if(chItem[DEFAULT_FIELD]){
listItem[SELECTED_QUQNTITY] += Number(chItem[DEFAULT_FIELD])
listItem[SELECTED_DATA_ARR].push(chItem)
}
})
}
})
// console.log('设置当前所有已选值---', topProcOptionList)
this.setState({
topProcOptionList
})
}
// 点击顶部菜单 // 点击顶部菜单
handleTopNav(item, index) { handleTopNav(item, index) {
// console.log('item, index----', item, index) // console.log('item, index----', item, index)
...@@ -88,7 +122,7 @@ class EditThirdLevelPage extends Component { ...@@ -88,7 +122,7 @@ class EditThirdLevelPage extends Component {
console.log('编辑完成====>', topProcOptionList, params.superData.superIndex) console.log('编辑完成====>', topProcOptionList, params.superData.superIndex)
console.log(topProcOptionList[0].localThridContData[0]) console.log(topProcOptionList[0][DEFAULT_SECOND_DATA][0])
params.childrenPageCallBack(topProcOptionList, params.superData.superIndex) params.childrenPageCallBack(topProcOptionList, params.superData.superIndex)
this.props.navigation.goBack() this.props.navigation.goBack()
...@@ -112,6 +146,8 @@ class EditThirdLevelPage extends Component { ...@@ -112,6 +146,8 @@ class EditThirdLevelPage extends Component {
cardItemTitle={'title'} cardItemTitle={'title'}
curActIndex={topActiveIndex} curActIndex={topActiveIndex}
cardCallBack={(item, index) => this.handleTopNav(item, index)} cardCallBack={(item, index) => this.handleTopNav(item, index)}
cardCountName={SELECTED_QUQNTITY}
cardStyleType={'DEFAULT'}
/> />
) )
} }
...@@ -125,8 +161,8 @@ class EditThirdLevelPage extends Component { ...@@ -125,8 +161,8 @@ class EditThirdLevelPage extends Component {
let localThridContData = [] let localThridContData = []
let iconImg = '' let iconImg = ''
if(curData && curData.localThridContData) { if(curData && curData[DEFAULT_SECOND_DATA]) {
localThridContData = curData.localThridContData localThridContData = curData[DEFAULT_SECOND_DATA]
} }
if(curData && curData.iconImg){ if(curData && curData.iconImg){
iconImg = curData.iconImg iconImg = curData.iconImg
...@@ -166,7 +202,7 @@ class EditThirdLevelPage extends Component { ...@@ -166,7 +202,7 @@ class EditThirdLevelPage extends Component {
listItem={item} listItem={item}
listIndex={index} listIndex={index}
calField={'quantity'} calField={'quantity'}
subCalCallBack={(item,index) => this.handleCalCallBack(item,index,'localThridContData')} subCalCallBack={(item,index) => this.handleCalCallBack(item,index,DEFAULT_SECOND_DATA)}
titText={'title'} titText={'title'}
tipTextStr={'tip1'} tipTextStr={'tip1'}
tipTextOne={'tip2'} tipTextOne={'tip2'}
...@@ -334,7 +370,7 @@ const styles = StyleSheet.create({ ...@@ -334,7 +370,7 @@ const styles = StyleSheet.create({
btom_btn_box: { btom_btn_box: {
backgroundColor: foundation_color, backgroundColor: foundation_color,
paddingTop: 14, paddingTop: 14,
shadowColor: btn_sub_color, shadowColor: 'rgba(0, 0, 0, 0.12)',
shadowOffset: { shadowOffset: {
width: 1, width: 1,
height: 2 height: 2
......
...@@ -22,9 +22,9 @@ import { ...@@ -22,9 +22,9 @@ import {
font_family_regular, font_family_regular,
icon_style icon_style
} from '../../../base/BaseStyle'; } from '../../../base/BaseStyle';
import ShowModel from '../../common/ShowModel';
import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu'; import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu';
import PictureZoom from '../../common/listDataComponent/PictureZoom'; import PictureZoom from '../../common/listDataComponent/PictureZoom';
import {cloneObject} from '../../../utils/Utils';
const PropTypes = require('prop-types'); const PropTypes = require('prop-types');
import localMockData from './mock/sen_mock'; import localMockData from './mock/sen_mock';
...@@ -55,7 +55,7 @@ class ProductRightStyle extends Component { ...@@ -55,7 +55,7 @@ class ProductRightStyle extends Component {
// 赋值测试数据 // 赋值测试数据
this.setState({ this.setState({
singleHeadData: localMockData.localSingleSeleHead, singleHeadData: localMockData.localSingleSeleHead,
rowSingleData: localMockData.localSingleRowData rowSingleData: cloneObject(localMockData.localSingleRowData)
}) })
} }
...@@ -114,6 +114,8 @@ class ProductRightStyle extends Component { ...@@ -114,6 +114,8 @@ class ProductRightStyle extends Component {
// 传递函数,编辑完成时调用 // 传递函数,编辑完成时调用
}) })
}else { }else {
// 单选耗材中级标题点击之后
this.changeThrShow(true, item.title) this.changeThrShow(true, item.title)
} }
// else if ( superIndex > 0 && superIndex < 4) { // else if ( superIndex > 0 && superIndex < 4) {
...@@ -183,25 +185,6 @@ class ProductRightStyle extends Component { ...@@ -183,25 +185,6 @@ class ProductRightStyle extends Component {
// this.props.changeThrShow(show) ============???? // this.props.changeThrShow(show) ============????
} }
/**
* 点击当前小类加减
* @param {object} item 当前小类数据
* @param {number} index 当前角标
* @param {boolean} isPlus 默认减法 false,加法 true,
*/
// handleCalculationThr(item, index, isPlus) {
// let { rowSingleData } = this.state
// let { value } = rowSingleData[index]
// if(isPlus) {
// rowSingleData[index].value += 1
// } else if(!isPlus && value > 0) {
// rowSingleData[index].value -= 1
// }
// this.setState({
// rowSingleData
// })
// }
// 单选耗材 - 头数据 // 单选耗材 - 头数据
handleHeadCalCallBack(item, index) { handleHeadCalCallBack(item, index) {
let { singleHeadData } = this.state let { singleHeadData } = this.state
...@@ -267,6 +250,7 @@ class ProductRightStyle extends Component { ...@@ -267,6 +250,7 @@ class ProductRightStyle extends Component {
tipTextTwo={'tip2'} tipTextTwo={'tip2'}
listImgIcon={'imgIcon'} listImgIcon={'imgIcon'}
listPicType={'SQUARE'} listPicType={'SQUARE'}
plusCallBack={(item, index) => this.TitleClickEvent(item,index)}
/> />
</SafeAreaView> </SafeAreaView>
) )
...@@ -296,7 +280,6 @@ class ProductRightStyle extends Component { ...@@ -296,7 +280,6 @@ class ProductRightStyle extends Component {
listItem={item} listItem={item}
listIndex={index} listIndex={index}
calField={curCalField} calField={curCalField}
// subCalCallBack={(item,index) => this.handleRowCalCallBack(item,index)}
subCalCallBack={(item,index) => this.handleCalCallBack(item,index, 'rowSingleData')} subCalCallBack={(item,index) => this.handleCalCallBack(item,index, 'rowSingleData')}
titText={'title'} titText={'title'}
tipTextOne={'tip1'} tipTextOne={'tip1'}
...@@ -331,11 +314,11 @@ class ProductRightStyle extends Component { ...@@ -331,11 +314,11 @@ class ProductRightStyle extends Component {
listIndex={index} listIndex={index}
calField={curCalField} calField={curCalField}
listPicType={'ROUND'} listPicType={'ROUND'}
// subCalCallBack={(item,index) => this.handleHeadCalCallBack(item,index)}
subCalCallBack={(item,index) => this.handleCalCallBack(item, index, 'singleHeadData', curCalField)} subCalCallBack={(item,index) => this.handleCalCallBack(item, index, 'singleHeadData', curCalField)}
titCallBack={(item,index) => this.TitleClickEvent(item, index)} titCallBack={(item,index) => this.TitleClickEvent(item, index)}
titText={'title'} titText={'title'}
listImgIcon={'imgIcon'} listImgIcon={'imgIcon'}
plusCallBack={(item, index) => this.TitleClickEvent(item,index)}
/> />
</SafeAreaView> </SafeAreaView>
) )
......
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