Commit 9e604b4b by Denglingling

完善 单选耗材(已选时,统一查看,取消已选仍按当前菜单查看),修改相关已选、清空操作

(cherry picked from commit 12a55f69)
parent 675f3776
......@@ -26,6 +26,13 @@ class PicTitDetaiCalcu extends Component {
listImgIcon: PropTypes.string,
listStyleImg: PropTypes.objec,
plusCallBack: PropTypes.func, // 加法的回调函数
reduceCallBack: PropTypes.func, // 减法的回调函数
// listShowChildNum: PropTypes.string, // 已选展示的子类数量,标题显示父级标题
showClearIcon: PropTypes.bool, // 展示减少x图标,不展示加减
showClearIndex: PropTypes.number, // 展示index
listCardActIndex: PropTypes.number, // 父级index = 展示index
listStyleClearBtn: PropTypes.object,
clearCallBack: PropTypes.func, // 清空图标回调函数
}
constructor(props) {
......@@ -36,6 +43,11 @@ class PicTitDetaiCalcu extends Component {
}
}
// // 清空图标
// handelClearCheck(item, index) {
// reduceCallBack(item, index)
// }
/**
* 点击加减
* @param {object} item 当前小类数据
......@@ -43,13 +55,18 @@ class PicTitDetaiCalcu extends Component {
* @param {boolean} isPlus 默认减法 false,加法 true,
*/
handelCalculation(item, index, isPlus) {
let {calField, plusCallBack} = this.props
let {calField, plusCallBack, reduceCallBack} = this.props
if(!isPlus && reduceCallBack){
// console.log('减法回调======')
reduceCallBack(item, index)
return
}
if(isPlus && plusCallBack){
console.log('加法回调======', item, index)
// console.log('加法回调======', item, index)
plusCallBack(item, index)
return
}
console.log('加法======')
// console.log('加减======', item, index, isPlus)
item[calField] = Number(item[calField])
if(Number.isNaN(item[calField])){
item[calField] = 0
......@@ -63,7 +80,8 @@ class PicTitDetaiCalcu extends Component {
}
render() {
let {listItem, listIndex, calField, listStyleBox, listStyleTit, listStyleTip, listStyleCalBtn, listPicType, titCallBack,titText, tipTextStr, tipTextOne, tipTextTwo, listImgIcon, listStyleImg} = this.props
let {listItem, listIndex, calField, listStyleBox, listStyleTit, listStyleTip, listStyleCalBtn, listPicType, titCallBack,
titText, tipTextStr, tipTextOne, tipTextTwo, listImgIcon, listStyleImg, showClearIcon, showClearIndex, listCardActIndex, listStyleClearBtn, clearCallBack} = this.props
let {listPicTypeArr, picStyleArr} = this.state
let picOthStyle = ''
if(listPicTypeArr.indexOf(listPicType) > -1){
......@@ -75,9 +93,60 @@ class PicTitDetaiCalcu extends Component {
calIcon = require('../../../images/plur_big_act.png')
}
// console.log('picOthStyle----', picOthStyle)
console.log('每一列----',showClearIcon, listCardActIndex, showClearIndex, (showClearIcon && listIndex === showClearIndex))
return (
// <View>
// { curListArr.map((curListItem, curListIndex) => {
// <View style={[styles.ri_inner, listStyleBox]}>
// { listImgIcon ?
// <View style={[styles.oth_img_box, styles[picOthStyle], listStyleImg]}>
// <Image style={icon_style} source={curListItem.imgIcon}/>
// </View> : null }
// <View style={styles.ri_text_box}>
// <TouchableOpacity
// activeOpacity={.8}
// onPress={() => {titCallBack ? titCallBack(curListItem, listIndex) : {}}}
// style={styles.oth_box}
// >
// <Text numberOfLines={1} style={[styles.thr_ot, listStyleTit]}>
// { curListItem[titText] }
// </Text>
// </TouchableOpacity>
// { curListItem[tipTextStr] ? <Text numberOfLines={1} style={[styles.ri_te_ot, styles.te_ot_str, listStyleTip]}>{curListItem[tipTextStr]}</Text> : null }
// { curListItem[tipTextOne] ? <Text numberOfLines={1} style={[styles.ri_te_ot, listStyleTip]}>{curListItem[tipTextOne]}</Text> : null }
// { curListItem[tipTextTwo] ? <Text numberOfLines={1} style={[styles.ri_te_ot, listStyleTip]}>{curListItem[tipTextTwo]}</Text> : null }
// </View>
// <View style={styles.ri_num_box}>
// { curListItem[calField] !== 0 ?
// <TouchableOpacity
// activeOpacity={.9}
// style={[styles.btn_inner, listStyleCalBtn]}
// onPress={() => this.handelCalculation(curListItem, listIndex)}
// >
// <View style={[styles.thr_num_btn, styles.thr_btn_left]}>
// <Image source={require('../../../images/less_icon_big.png')} style={icon_style}></Image>
// </View>
// </TouchableOpacity> : null }
// { curListItem[calField] !== 0 ? <Text style={styles.thr_num}>{ curListItem[calField] }</Text> : null}
// <TouchableOpacity
// activeOpacity={.9}
// style={[styles.btn_inner, listStyleCalBtn]}
// onPress={() => this.handelCalculation(curListItem, listIndex, true)}
// >
// <View style={[styles.thr_num_btn, styles.thr_btn_right]}>
// <Image source={calIcon} style={icon_style}></Image>
// </View>
// </TouchableOpacity>
// </View>
// </View>
// })
// }
// </View>
<View style={[styles.ri_inner, listStyleBox]}>
{ listImgIcon ?
<View style={[styles.oth_img_box, styles[picOthStyle], listStyleImg]}>
......@@ -97,7 +166,19 @@ class PicTitDetaiCalcu extends Component {
{ listItem[tipTextOne] ? <Text numberOfLines={1} style={[styles.ri_te_ot, listStyleTip]}>{listItem[tipTextOne]}</Text> : null }
{ listItem[tipTextTwo] ? <Text numberOfLines={1} style={[styles.ri_te_ot, listStyleTip]}>{listItem[tipTextTwo]}</Text> : null }
</View>
<View style={styles.ri_num_box}>
{
(showClearIcon && listCardActIndex === showClearIndex) ?
<View style={styles.btn_cle_box}>
<TouchableOpacity
activeOpacity={.9}
style={[styles.btn_clear_inner, listStyleClearBtn]}
onPress={() => clearCallBack(listItem, listIndex)}
>
<View style={[styles.icon_cle_btn]}>
<Image source={require('../../../images/close_icon.png')} style={icon_style}></Image>
</View>
</TouchableOpacity>
</View> : <View style={styles.ri_num_box}>
{ listItem[calField] !== 0 ?
<TouchableOpacity
activeOpacity={.9}
......@@ -119,7 +200,10 @@ class PicTitDetaiCalcu extends Component {
</View>
</TouchableOpacity>
</View>
}
</View>
);
}
}
......@@ -177,6 +261,19 @@ const styles = StyleSheet.create({
height: pxSize(30)
},
btn_inner: {},
btn_cle_box:{
marginRight: 6,
// backgroundColor: 'red',
paddingHorizontal: 4,
paddingVertical: 4
},
btn_clear_inner:{
},
icon_cle_btn:{
width: pxSize(22),
height: pxSize(22)
},
ri_num_box: {
flexDirection: 'row',
alignItems: 'center',
......
......@@ -37,11 +37,15 @@ import ProductRightStyle from './ProductRightStyle';
import ProductModel from '../../common/ProductModel';
import StatusBarView from '../../common/StatusBarView';
import ChooseCardList from '../../common/listDataComponent/ChooseCardList';
import {cloneObject} from '../../../utils/Utils';
import localMockData from './mock/sen_mock';
// import ScrollableTabView, { ScrollableTabBar } from 'react-native-scrollable-tab-view';
// import TopTabBar from './customTabbar/TopTabBar';
// import LeftTabBar from './customTabbar/LeftTabBar';
const DEFAULT_FIELD = 'quantity' // 计算的字段
const CHILD_DATA_NAME = 'childrenLineData' // 显示的子类数组名称
const SELECTED_QUQNTITY = 'selectedQuantity' // 中类数量
const SELECTED_DATA_ARR = 'selectedDataArr' // 中类已选元素
const DEFAULT_SECOND_DATA = 'localSecondData' // 中类原本元素
......@@ -66,11 +70,11 @@ class ChooseProductPage extends Component {
}
componentDidMount() {
console.log('本地测试数据====localMockData===', localMockData)
// console.log('本地测试数据====localMockData===', localMockData)
// 赋值测试数据
this.setState({
topProcOptionList: localMockData.localTopProcOption,
leftOptionList: localMockData.localLeftOption
topProcOptionList: cloneObject(localMockData.localTopProcOption),
leftOptionList: cloneObject(localMockData.localLeftOption)
})
}
......@@ -101,10 +105,107 @@ class ChooseProductPage extends Component {
})
}
// 计算中级数量
// 计算三级回调函数
handleChangeThird(childData, superIndex){
let {leftActiveIndex, leftOptionList} = this.state
// console.log("计算三级的回调函数",childData, superIndex, leftActiveIndex)
// console.log(leftOptionList)
// 初始化
leftOptionList[leftActiveIndex][SELECTED_QUQNTITY] = 0
leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = []
leftOptionList.map(function(leItem, leIndex) {
if(!leItem[SELECTED_QUQNTITY]){
leItem[SELECTED_QUQNTITY] = 0
}
if(!leItem[SELECTED_DATA_ARR]){
leItem[SELECTED_DATA_ARR] = []
}
if(leIndex === leftActiveIndex) {
// console.log('外面 childData----', childData)
if(leItem[DEFAULT_SECOND_DATA].length && leItem[DEFAULT_SECOND_DATA][superIndex] && childData.length){
// leItem[DEFAULT_SECOND_DATA][superIndex]
// let superTip = ''
let sumCount = 0
// console.log('childData----', childData)
childData.map((chDa, chInd) => {
// let splitStr = ' / '
// if(chInd === childData.length - 1){
// splitStr = ''
// }
// superTip += `${chDa.title}x${chDa.selectedQuantity}${splitStr}`
if(!chDa[DEFAULT_FIELD]){
chDa[DEFAULT_FIELD] = 0
}
sumCount += chDa[DEFAULT_FIELD]
})
let chDa = leItem[DEFAULT_SECOND_DATA][superIndex]
let curObj = {
superId: chDa['id'], // 本地测试
superIndex: superIndex, // 本地测试
superTit: leItem['title'], // 本地测试
superImg: chDa['imgIcon'], // 本地测试
superTip: `${chDa['title'] }x${sumCount}`, // 本地测试
curTitle: chDa['title'], // 本地测试
version: 0,
lineOptions: childData,
[DEFAULT_FIELD]: sumCount
}
// 初始化
leItem[DEFAULT_SECOND_DATA][superIndex][CHILD_DATA_NAME] = []
leItem[DEFAULT_SECOND_DATA][superIndex][CHILD_DATA_NAME].push(curObj)
leItem[DEFAULT_SECOND_DATA][superIndex][DEFAULT_FIELD] = sumCount
}
// 初始化
leItem[SELECTED_QUQNTITY] = 0
leItem[SELECTED_DATA_ARR] = []
if(leItem[DEFAULT_SECOND_DATA].length){ // 本地测试 localSecondData DEFAULT_SECOND_DATA
leItem[DEFAULT_SECOND_DATA].forEach(function(chItem) {
if(chItem[DEFAULT_FIELD] > 0){
leItem[SELECTED_QUQNTITY] += Number(chItem[DEFAULT_FIELD])
leItem[SELECTED_DATA_ARR].push(chItem)
}
})
}
// // 当前选择项
// leItem[SELECTED_QUQNTITY] = count
// if(leItem[DEFAULT_SECOND_DATA].length){ // 本地测试 localSecondData DEFAULT_SECOND_DATA
// leItem[DEFAULT_SECOND_DATA].forEach(function(chItem) {
// if(chItem[coutFieName]){
// leItem[SELECTED_DATA_ARR].push(chItem)
// }
// })
// }
}
})
// console.log('计算三级之后数据---', leftOptionList)
this.setState({
leftOptionList
})
}
// 计算中级数量回调
handleChangeCount(count, coutFieName) {
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] = []
......@@ -156,10 +257,11 @@ class ChooseProductPage extends Component {
}
// 点击共计已选
handleSubSelected(show) {
handleSubSelected() {
// console.log('show-----', show)
let {selectShowPopup} = this.state
if(this.getAllCountQuantity() !== 0) {
this.handleCloseSelectModal(!show)
this.handleCloseSelectModal(!selectShowPopup)
}
}
......@@ -265,6 +367,9 @@ class ChooseProductPage extends Component {
// superStencilData={rightSecondData}
superStencilData={curRigSecoOption}
superCallBack={(count, coutFieName) => this.handleChangeCount(count, coutFieName)}
superReduceBack={() => this.handleSubSelected()}
thirdCallBack={(childData, superIndex) => this.handleChangeThird(childData, superIndex)}
superLeftData={leftOptionList[leftActiveIndex]}
/>
</View>
)
......@@ -276,7 +381,7 @@ class ChooseProductPage extends Component {
let allCountQuantity = this.getAllCountQuantity()
// console.log('返回底部按钮----', selectShowPopup)
console.log('左侧数据----', leftOptionList)
return (
<View style={list_common_item.sub_box}>
......@@ -284,7 +389,7 @@ class ChooseProductPage extends Component {
<TouchableOpacity
activeOpacity={.8}
style={list_common_item.lef_btn}
onPress={() => this.handleSubSelected(selectShowPopup)}
onPress={() => this.handleSubSelected()}
>
<Text style={list_common_item.lef_tip}>{'已选:'}{allCountQuantity}</Text>
</TouchableOpacity>
......
......@@ -54,9 +54,8 @@ class EditThirdLevelPage extends Component {
componentDidMount() {
let {params} = this.props.navigation.state
let that = this
console.log('本地测试数据====localMockData===', localMockData)
console.log('本地测试数据====localMockData===', localMockData.localThridOption[0][DEFAULT_SECOND_DATA][0])
console.log('父组件传递的值==', params)
// console.log('本地测试数据====localMockData===', localMockData)
// console.log('父组件传递的值==', params)
// 赋值测试数据
this.setState({
......@@ -120,9 +119,9 @@ class EditThirdLevelPage extends Component {
let {topProcOptionList} = this.state
let {params} = this.props.navigation.state
console.log('编辑完成====>', topProcOptionList, params.superData.superIndex)
// console.log('编辑完成====>', topProcOptionList, params.superData)
console.log(topProcOptionList[0][DEFAULT_SECOND_DATA][0])
// console.log(topProcOptionList[0][DEFAULT_SECOND_DATA][0])
params.childrenPageCallBack(topProcOptionList, params.superData.superIndex)
this.props.navigation.goBack()
......
......@@ -165,7 +165,7 @@ const localSingleSeleHead_4 = [{
}]
// 人工髋关节假体等数据 -- 大类
const localSingleSeleHead = [{
const localSingleSeleHead_5 = [{
"id": "0",
title: '中置器(PE)',
imgIcon: require('../../../../images/model_test.png'),
......@@ -176,7 +176,7 @@ const localSingleSeleHead = [{
},
{
"id": "1",
title: '内衬Harmony 28/10°OD(P 2',
title: '内衬Harmony---',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
......@@ -185,7 +185,7 @@ const localSingleSeleHead = [{
},
{
"id": "2",
title: '内衬Harmony 28/10°OD(P',
title: '内衬Harmony 28/10°OD',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
......@@ -239,6 +239,110 @@ const localSingleSeleHead = [{
}
]
const localSingleSeleHead_6= [{
"id": "0",
title: '6-中置器(PE)11',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
},
{
"id": "1",
title: '6-中置器(PE)22',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
},
{
"id": "2",
title: '6-中置器(PE)33',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
}
]
const localSingleSeleHead_7 = [{
"id": "0",
title: 'h7-中置器(PE)1111',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
},
{
"id": "1",
title: 'h7-中置器(PE)2222',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
},
{
"id": "2",
title: 'h7-中置器(PE)3333',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
}
]
const localSingleSeleHead_8 = [{
"id": "0",
title: 'h8-中置器(PE)11',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
}
]
const localSingleSeleHead_9 = [{
"id": "0",
title: 'h9-中置器(PE)',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
}
]
const localSingleSeleHead_10 = [{
"id": "0",
title: 'h10-中置器(PE)11',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
}
]
const localSingleSeleHead_11 = [{
"id": "0",
title: 'h11-中置器',
imgIcon: require('../../../../images/model_test.png'),
tip1: '创建人:金城武',
tip2: '创建时间:2020.03.01',
select: false,
quantity: 0
}
]
// 人工髋关节假体等数据 -- 小类
const localSingleRowData = [
{
......@@ -246,53 +350,41 @@ const localSingleRowData = [
title: '规格:JS-CGO PE 10',
tip1: '型号:10',
tip2: '物料代码:JUST00000104',
value: 20,
select: false,
quantity: 0
},
{
"id": "1",
title: '规格:JS-CGO PE 10 11',
title: '规格:JS-CGO PE 11',
tip1: '型号:10',
tip2: '物料代码:JUST00000104',
value: 0,
select: false,
tip2: '物料代码:JUST00000102',
quantity: 0
},
{
"id": "2",
title: '规格:JS-CGO PE 10 22',
title: '规格:JS-CGO PE 12',
tip1: '型号:10',
tip2: '物料代码:JUST00000104',
value: 0,
select: false,
tip2: '物料代码:JUST00000107',
quantity: 0
},
{
"id": "3",
title: '规格:JS-CGO PE 10 33',
title: '规格:JS-CGO PE 13',
tip1: '型号:10',
tip2: '物料代码:JUST00000104',
value: 0,
select: false,
tip2: '物料代码:JUST00000108',
quantity: 0
},
{
"id": "4",
title: '规格:JS-CGO PE 10 44',
title: '规格:JS-CGO PE 14',
tip1: '型号:10',
tip2: '物料代码:JUST00000104',
value: 0,
select: false,
tip2: '物料代码:JUST00000109',
quantity: 0
},
{
"id": "5",
title: '规格:JS-CGO PE 10 55',
title: '规格:JS-CGO PE 15',
tip1: '型号:10',
tip2: '物料代码:JUST00000104',
value: 0,
select: false,
tip2: '物料代码:JUST00000110',
quantity: 0
}
]
......@@ -321,31 +413,31 @@ const localLeftOption = [
},
{
title: '人工髋关节假体',
localSecondData: localSingleSeleHead
localSecondData: localSingleSeleHead_5
},
{
title: '膝关节假体备份',
localSecondData: localSingleSeleHead
localSecondData: localSingleSeleHead_6
},
{
title: '骨小梁髋关节假体',
localSecondData: localSingleSeleHead
localSecondData: localSingleSeleHead_7
},
{
title: '骨小梁髋关节假体22',
localSecondData: localSingleSeleHead
title: '骨小梁髋22',
localSecondData: localSingleSeleHead_8
},
{
title: '骨小梁髋关节假体33',
localSecondData: localSingleSeleHead
title: '骨小梁33',
localSecondData: localSingleSeleHead_9
},
{
title: '骨小梁髋关节假体44',
localSecondData: localSingleSeleHead
title: '骨小44',
localSecondData: localSingleSeleHead_10
},
{
title: '骨小梁髋关节假体55',
localSecondData: localSingleSeleHead
title: '关节假体55',
localSecondData: localSingleSeleHead_11
},
]
......@@ -622,7 +714,7 @@ const localBottomOption = [
export default{
localTopProcOption,
localLeftOption,
localSingleSeleHead,
// localSingleSeleHead,
localSingleRowData,
localTestImageUrls,
localThridOption,
......
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