Commit cb8feca4 by Denglingling

调整APP-选择产品通过模拟接口数据实现

(cherry picked from commit c3b8571d)
parent bf6d88b2
......@@ -8,7 +8,8 @@ import {
SELF_SUBMIT_DOING,
SELF_SUBMIT_SUCCESS,
SELF_SUBMIT_FAILURE,
SELF_INIT_DATA
SELF_INIT_DATA,
SET_SELECT_PRODUCT_OPTS
} from '../base/ActionTypes';
import local_inter_mock from '../containers/selfOrder/module/mock/inter_mock'
......@@ -278,7 +279,11 @@ export const reqScatEquipmentSearch = async (global_domain_config, params) => {
// 选择产品-单点耗材查询接口
export const reqSingleConsumSearch = async (global_domain_config, params) => {
return local_inter_mock.inter_9
if(params.leftIndex && params.leftIndex%2 === 0){
return local_inter_mock.inter_9
}else {
return local_inter_mock.inter_99
}
return await GetRequest(global_domain_config, getUrlParams('/order/item_detail/search', params))
}
......@@ -306,4 +311,12 @@ export function setSelfInitData() {
return {
type: SELF_INIT_DATA
}
}
// 存储选择产品数据
export function setSelectProductOpts(data) {
return {
type: SET_SELECT_PRODUCT_OPTS,
rawData: data
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ export const SELF_SUBMIT_DOING = "SELF_SUBMIT_DOING"
export const SELF_SUBMIT_SUCCESS = "SELF_SUBMIT_SUCCESS"
export const SELF_SUBMIT_FAILURE = "SELF_SUBMIT_FAILURE"
export const SELF_INIT_DATA = "SELF_INIT_DATA"
export const SET_SELECT_PRODUCT_OPTS = "SET_SELECT_PRODUCT_OPTS"
//-----------quick order---------------------
export const QUICK_ORDER_LIST_NO = "QUICK_ORDER_LIST_NO"
export const QUICK_ORDER_LIST_DOING = "QUICK_ORDER_LIST_DOING"
......
......@@ -371,6 +371,9 @@ export const list_common_item = {
fontSize: 16,
fontFamily: font_family_regular
},
lef_tip_num:{
fontSize: 20
},
rig_btn: {
backgroundColor: promary_color,
width: '35%',
......
/**
* 存储监听事件类型
*/
export default class EmitterEvents {
/**
* 选择产品回到自助下单
*/
static BACK_TO_SELF_PAGE = 'BACK_TO_SELF_PAGE'
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ class LodingModel extends Component {
<View style={styles.container}>
<Modal
transparent={true}
visible={this.state.isVisible}
visible={!!this.state.isVisible}
animationType={'fade'}
// onRequestClose={() => this.closeModal()}>
>
......
......@@ -11,9 +11,12 @@ const PropTypes = require('prop-types');
const SELECTED_QUQNTITY = 'selectedQuantity' // 中类数量
const SELECTED_DATA_ARR = 'selectedDataArr' // 中类已选元素
const DEFAULT_SECOND_DATA = 'localSecondData' // 中类原本元素
const DEFAULT_QUANTITY = 'quantity' // 计算的字段
const CHILD_DATA_NAME = 'childrenLineData' // 显示的子类数组名称
const LOCAL_SECOND_DATA = 'localSecondData' // 中类原本元素
const QUANTITY_FIELD = 'quantity' // 计算的字段
const CHILDREN_LINE_NAME = 'childrenLineData' // 显示的子类数组名称
const SUPER_TITLE_NAME = 'super_title_name'
const SUPER_TITLE_TIP = 'super_title_tip'
const ONLY_TWO_LEVELS = 'onlyTwoLevels' // 只有两级的耗材
class ProductModel extends Component {
......@@ -62,20 +65,41 @@ class ProductModel extends Component {
let {orginOptionList} = this.state
let otherArr = []
let otherChildObj = {
title: '单选耗材',
category_code: 'local_sign_items',
category_name: '单选耗材',
[SELECTED_QUQNTITY]: 0,
[SELECTED_DATA_ARR]: [],
[DEFAULT_SECOND_DATA]: []
[LOCAL_SECOND_DATA]: []
}
orginOptionList.forEach((orItem, orIndex) => {
if(orIndex < 4) {
otherArr.push(orItem)
}else {
otherChildObj[DEFAULT_SECOND_DATA].push(orItem)
otherChildObj[LOCAL_SECOND_DATA].push(orItem)
if(orItem[SELECTED_QUQNTITY]){
otherChildObj[SELECTED_QUQNTITY] += Number(orItem[SELECTED_QUQNTITY])
}
if(orItem[SELECTED_DATA_ARR]){
// orItem[SUPER_TITLE_NAME] = orItem.category_name
// let end_str = ''
// if(sedInd < curData[SELECTED_DATA_ARR].length - 1){
// end_str = ' / '
// }
// if(!sedItem[SUPER_TITLE_TIP]){
// sedItem[SUPER_TITLE_TIP]=`${sedItem.category_name}x${sedItem[QUANTITY_FIELD]}${end_str}`
// }
// console.log('orItem---', orItem)
// if(!otherChildObj[SUPER_TITLE_TIP]){
// otherChildObj[SUPER_TITLE_TIP] = ''
// }
orItem[SELECTED_DATA_ARR].forEach(function(sign_it, si_ind) {
sign_it[SUPER_TITLE_NAME] = orItem.category_name
// let end_str = ''
// if(si_ind < orItem[SELECTED_DATA_ARR].length - 1){
// end_str = ' / '
// }
// otherChildObj[SUPER_TITLE_TIP] += `${sign_it.category_name}x${sign_it[QUANTITY_FIELD]}${end_str}`
})
otherChildObj[SELECTED_DATA_ARR].push(...orItem[SELECTED_DATA_ARR])
}
}
......@@ -116,20 +140,20 @@ class ProductModel extends Component {
// let delArr = []
// orgItem[SELECTED_DATA_ARR].map(function(seIt, seInd) {
// console.log('标题====', curSeChild['superTit'], seIt[CHILD_DATA_NAME][0]['superTit'])
// let orgCurChild = seIt[CHILD_DATA_NAME][0]
// console.log('标题====', curSeChild['superTit'], seIt[CHILDREN_LINE_NAME][0]['superTit'])
// let orgCurChild = seIt[CHILDREN_LINE_NAME][0]
// curOptions[SELECTED_DATA_ARR].forEach(function(curSeItem, curSeInd){
// let curSeChild = curSeItem[CHILD_DATA_NAME][0]
// let curSeChild = curSeItem[CHILDREN_LINE_NAME][0]
// if(curSeChild && orgCurChild && curSeChild['superTit'] === orgCurChild['superTit'] && curSeChild['id'] === orgCurChild['id']
// && curSeChild['superIndex'] === orgCurChild['superIndex'] && curSeChild['curTitle'] === orgCurChild['curTitle']){
// // seIt[CHILD_DATA_NAME][0]['lineOptions'] = curSeChild['lineOptions']
// // seIt[CHILDREN_LINE_NAME][0]['lineOptions'] = curSeChild['lineOptions']
// seIt = curSeChild
// }
// })
// // 是否在已选存在
// let isExitArr = curOptions[SELECTED_DATA_ARR].filter(item => {
// let curSeChild = curSeItem[CHILD_DATA_NAME][0]
// let curSeChild = curSeItem[CHILDREN_LINE_NAME][0]
// return curSeChild && orgCurChild && curSeChild['superTit'] === orgCurChild['superTit'] && curSeChild['id'] === orgCurChild['id']
// && curSeChild['superIndex'] === orgCurChild['superIndex'] && curSeChild['curTitle'] === orgCurChild['curTitle']
// })
......@@ -144,28 +168,28 @@ class ProductModel extends Component {
// if(delArr.length){
// for(let i=delArr.length-1; i>=0; i--){
// let seDelChild = orgItem[SELECTED_DATA_ARR][i][CHILD_DATA_NAME][0]
// let seDelChild = orgItem[SELECTED_DATA_ARR][i][CHILDREN_LINE_NAME][0]
// if(orgItem[DEFAULT_SECOND_DATA] && orgItem[DEFAULT_SECOND_DATA].length > 0 && seDelChild){
// // for(let deIt of orgItem[DEFAULT_SECOND_DATA]){
// if(orgItem[LOCAL_SECOND_DATA] && orgItem[LOCAL_SECOND_DATA].length > 0 && seDelChild){
// // for(let deIt of orgItem[LOCAL_SECOND_DATA]){
// // let deItChild = deIt[CHILD_DATA_NAME][0]
// // let deItChild = deIt[CHILDREN_LINE_NAME][0]
// // if(deItChild && seDelChild && deItChild['superTit'] === seDelChild['superTit'] && deItChild['id'] === seDelChild['id']
// // && deItChild['index'] === seDelChild['index']){
// // deIt[DEFAULT_QUANTITY] = 0
// // delete deIt[CHILD_DATA_NAME]
// // deIt[QUANTITY_FIELD] = 0
// // delete deIt[CHILDREN_LINE_NAME]
// // }
// // }
// orgItem[DEFAULT_SECOND_DATA].forEach(function(deIt) {
// let deItChild = deIt[CHILD_DATA_NAME][0]
// orgItem[LOCAL_SECOND_DATA].forEach(function(deIt) {
// let deItChild = deIt[CHILDREN_LINE_NAME][0]
// if(deItChild && seDelChild && deItChild['superTit'] === seDelChild['superTit'] && deItChild['id'] === seDelChild['id']
// && deItChild['index'] === seDelChild['index']){
// deIt[DEFAULT_QUANTITY] = 0
// delete deIt[CHILD_DATA_NAME]
// deIt[QUANTITY_FIELD] = 0
// delete deIt[CHILDREN_LINE_NAME]
// }
// })
......@@ -179,12 +203,12 @@ class ProductModel extends Component {
// }else {
// // 清空所有已选
// orgItem[SELECTED_DATA_ARR] = []
// orgItem[DEFAULT_QUANTITY] = 0
// if(orgItem[DEFAULT_SECOND_DATA] && orgItem[DEFAULT_SECOND_DATA].length > 0){
// orgItem[DEFAULT_SECOND_DATA].forEach(function(deIt) {
// deIt[DEFAULT_QUANTITY] = 0
// // deIt[CHILD_DATA_NAME] = []
// delete deIt[CHILD_DATA_NAME]
// orgItem[QUANTITY_FIELD] = 0
// if(orgItem[LOCAL_SECOND_DATA] && orgItem[LOCAL_SECOND_DATA].length > 0){
// orgItem[LOCAL_SECOND_DATA].forEach(function(deIt) {
// deIt[QUANTITY_FIELD] = 0
// // deIt[CHILDREN_LINE_NAME] = []
// delete deIt[CHILDREN_LINE_NAME]
// })
// }
// }
......@@ -215,110 +239,85 @@ class ProductModel extends Component {
this.props.closeModal(false);
}
// 清空图标回调
// 单选耗材清空图标回调
handleClearBack(item, index){
// console.log('清空图标回调---', item, index)
let {orginOptionList, topProcOptionList, topActiveIndex} = this.state
// console.log('清空图标回调---', item, index)
// console.log('原始已选数据==--===--', orginOptionList)
// console.log('当前已选数据==----', topProcOptionList, topActiveIndex)
// 单选耗材当前清空项
let deleOpts = cloneObject(topProcOptionList[topActiveIndex][SELECTED_DATA_ARR][index])
// let deleOpts = cloneObject(topProcOptionList[topActiveIndex][SELECTED_DATA_ARR][index])
let allCountQuantity = 0 // 初始化
orginOptionList.forEach(function(orgOpts, orgInd) {
if(orgInd >= 4){
if(orgOpts[DEFAULT_SECOND_DATA] && orgOpts[DEFAULT_SECOND_DATA].length > 0){
orgOpts[DEFAULT_SECOND_DATA].forEach(function(localDa, localInd) {
// console.log('localDa--CHILD_DATA_NAME-', localDa, CHILD_DATA_NAME)
if(localDa[CHILD_DATA_NAME] && deleOpts[CHILD_DATA_NAME]){
let curLine = localDa[CHILD_DATA_NAME][0]
// console.log('curLine---', curLine, deleOpts)
let deLi = deleOpts[CHILD_DATA_NAME][0]
if(curLine && deLi && curLine['superTit'] === deLi['superTit'] && curLine['id'] === deLi['id']
&& curLine['superIndex'] === deLi['superIndex'] && curLine['curTitle'] === deLi['curTitle']){
localDa[DEFAULT_QUANTITY] = 0
delete localDa[CHILD_DATA_NAME]
}
if(orgOpts[LOCAL_SECOND_DATA] && orgOpts[LOCAL_SECOND_DATA].length > 0){
orgOpts[LOCAL_SECOND_DATA].forEach(function(localDa, localInd) {
// if(localDa[CHILDREN_LINE_NAME] && deleOpts[CHILDREN_LINE_NAME]){
// let curLine = localDa[CHILDREN_LINE_NAME][0]
// // console.log('curLine---', curLine, deleOpts)
// let deLi = deleOpts[CHILDREN_LINE_NAME][0]
// if(curLine && deLi && curLine['superTit'] === deLi['superTit'] && curLine['id'] === deLi['id']
// && curLine['superIndex'] === deLi['superIndex'] && curLine['curTitle'] === deLi['curTitle']){
// localDa[QUANTITY_FIELD] = 0
// delete localDa[CHILDREN_LINE_NAME]
// }
// }
if(localDa[ONLY_TWO_LEVELS] && localDa['item_code'] === item['item_code']){
// 二级
localDa[QUANTITY_FIELD] = 0
}else if(!localDa[ONLY_TWO_LEVELS] && localDa['category_code'] === item['category_code']){
localDa[QUANTITY_FIELD] = 0
if(localDa.details && localDa.details.length > 0){
// 三级
localDa.details.forEach(function(da_it){
da_it[QUANTITY_FIELD] = 0
})
}
}
})
}
if(orgOpts[SELECTED_DATA_ARR] && orgOpts[SELECTED_DATA_ARR].length > 0){
let delArr = []
orgOpts[SELECTED_DATA_ARR].map((deIt, deIndex) => {
if(!deIt[CHILD_DATA_NAME]){
// if(!deIt[CHILDREN_LINE_NAME]){
// delArr.push(deIndex)
// }
if(deIt[ONLY_TWO_LEVELS] && deIt['item_code'] === item['item_code']){
delArr.push(deIndex)
}else if(!deIt[ONLY_TWO_LEVELS] && deIt['category_code'] === item['category_code']){
delArr.push(deIndex)
}
})
// console.log('delArr----', delArr)
for(let i=delArr.length-1; i>=0; i--){
// console.log('orgOpts--!!--', i, delArr[i],orgOpts[SELECTED_DATA_ARR])
orgOpts[SELECTED_DATA_ARR].splice(delArr[i], 1);
}
// console.log('orgOpts----', orgOpts[SELECTED_DATA_ARR])
}
// 初始化
orgOpts[SELECTED_QUQNTITY] = 0
if(orgOpts[SELECTED_DATA_ARR].length > 0){
orgOpts[SELECTED_DATA_ARR].map(itDa => {
if(!itDa[DEFAULT_QUANTITY]){
itDa[DEFAULT_QUANTITY] = 0
if(orgOpts[SELECTED_DATA_ARR] && orgOpts[SELECTED_DATA_ARR].length > 0){
orgOpts[SELECTED_DATA_ARR].map(function(itDa){
if(!itDa[QUANTITY_FIELD]){
itDa[QUANTITY_FIELD] = 0
}
orgOpts[SELECTED_QUQNTITY] += Number(itDa[DEFAULT_QUANTITY])
orgOpts[SELECTED_QUQNTITY] += Number(itDa[QUANTITY_FIELD])
})
}
// console.log('orgOpts[SELECTED_DATA_ARR]---', orgOpts[SELECTED_DATA_ARR], SELECTED_DATA_ARR)
// if(orgOpts[SELECTED_DATA_ARR] && orgOpts[SELECTED_DATA_ARR].length > 0){
// let deIndex = 0
// let deFlag = false
// orgOpts[SELECTED_DATA_ARR].forEach(function(selDa, selInde){
// if(selDa[CHILD_DATA_NAME] && deleOpts[CHILD_DATA_NAME]){
// let curLine = selDa[CHILD_DATA_NAME][0]
// console.log('curLine---', curLine)
// let deLi = deleOpts[CHILD_DATA_NAME][0]
// console.log('deLi---', deLi)
// if(curLine && deLi && curLine['superTit'] === deLi['superTit'] && curLine['id'] === deLi['id']
// && curLine['superIndex'] === deLi['superIndex']){
// console.log('---删除=!!!====-', curLine, deLi)
// deFlag = true
// deIndex = localInd
// // selDa[DEFAULT_QUANTITY] = 0
// // delete selDa[CHILD_DATA_NAME]
// }
// }
// })
// if(deFlag){
// console.log('---删除=====-', deFlag, deIndex)
// orgOpts[SELECTED_DATA_ARR].splice(deIndex, 1)
// }
// }
}
if(!orgOpts[SELECTED_QUQNTITY]){
orgOpts[SELECTED_QUQNTITY] = 0
}
allCountQuantity += orgOpts[SELECTED_QUQNTITY]
})
// console.log('修改后的已选=======---', topProcOptionList)
// console.log('修改后的数量---', allCountQuantity)
// console.log('修改后端所有数据---', orginOptionList)
this.props.modelCallBack(orginOptionList)
if(allCountQuantity === 0){
this.closeModal()
......@@ -339,21 +338,21 @@ class ProductModel extends Component {
topProcOptionList.map(function(listItem, listIndex) {
if(listIndex === topActiveIndex){
if(topActiveIndex === 1 || topActiveIndex === 3 || topActiveIndex === 2){
if(topActiveIndex === 1 || topActiveIndex === 2 || topActiveIndex === 3){
//钉盒 零散器械
//初始化 中类
let deleFlag = false
let deleInd = null
listItem[SELECTED_QUQNTITY] = 0
listItem[SELECTED_DATA_ARR].forEach(function(seDa, seInd) {
if(!seDa[DEFAULT_QUANTITY]){
seDa[DEFAULT_QUANTITY] = 0
if(!seDa[QUANTITY_FIELD]){
seDa[QUANTITY_FIELD] = 0
}
if(seDa[DEFAULT_QUANTITY] === 0){
if(seDa[QUANTITY_FIELD] === 0){
deleFlag = true
deleInd = seInd
}
listItem[SELECTED_QUQNTITY] += Number(seDa[DEFAULT_QUANTITY])
listItem[SELECTED_QUQNTITY] += Number(seDa[QUANTITY_FIELD])
})
if(deleFlag) {
listItem[SELECTED_DATA_ARR].splice(deleInd, 1)
......@@ -362,19 +361,19 @@ class ProductModel extends Component {
let deleFlag = false
let deleInd = null
// 初始化 三级
listItem[SELECTED_DATA_ARR][defauIndex][DEFAULT_QUANTITY] = 0
listItem[SELECTED_DATA_ARR][defauIndex][QUANTITY_FIELD] = 0
listItem[SELECTED_DATA_ARR][defauIndex]['childrenLineData'].forEach(function(chIt, chInd) {
if(_.isEqual(chIt, item)){
chIt = item
if(chIt[DEFAULT_QUANTITY] === 0){
if(chIt[QUANTITY_FIELD] === 0){
deleFlag = true
deleInd = chInd
}
}
if(!chIt[DEFAULT_QUANTITY]){
chIt[DEFAULT_QUANTITY] = 0
if(!chIt[QUANTITY_FIELD]){
chIt[QUANTITY_FIELD] = 0
}
listItem[SELECTED_DATA_ARR][defauIndex][DEFAULT_QUANTITY] += Number(chIt[DEFAULT_QUANTITY])
listItem[SELECTED_DATA_ARR][defauIndex][QUANTITY_FIELD] += Number(chIt[QUANTITY_FIELD])
})
if(deleFlag) {
listItem[SELECTED_DATA_ARR][defauIndex]['childrenLineData'].splice(deleInd, 1)
......@@ -383,17 +382,17 @@ class ProductModel extends Component {
// 初始化 中类
listItem[SELECTED_QUQNTITY] = 0
listItem[SELECTED_DATA_ARR].forEach(function(seDa) {
if(!seDa[DEFAULT_QUANTITY]){
seDa[DEFAULT_QUANTITY] = 0
if(!seDa[QUANTITY_FIELD]){
seDa[QUANTITY_FIELD] = 0
}
listItem[SELECTED_QUQNTITY] += Number(seDa[DEFAULT_QUANTITY])
listItem[SELECTED_QUQNTITY] += Number(seDa[QUANTITY_FIELD])
})
// 已选数量赋值之前默认数据
let curObj = listItem[SELECTED_DATA_ARR][defauIndex]
// console.log('curObj----', curObj)
if(listIndex < 4){
if(curObj.id){
listItem[DEFAULT_SECOND_DATA].forEach(function(deIt) {
listItem[LOCAL_SECOND_DATA].forEach(function(deIt) {
if(deIt.id === curObj.id){ // 本地测试'id'为唯一值
deIt = curObj
}
......@@ -430,9 +429,9 @@ class ProductModel extends Component {
orginOptionList.map(function(listItem) {
listItem[SELECTED_QUQNTITY] = 0
listItem[SELECTED_DATA_ARR] = []
listItem[DEFAULT_SECOND_DATA].forEach(function(deIt) {
deIt[DEFAULT_QUANTITY] = 0
deIt[CHILD_DATA_NAME] = []
listItem[LOCAL_SECOND_DATA].forEach(function(deIt) {
deIt[QUANTITY_FIELD] = 0
deIt[CHILDREN_LINE_NAME] = []
})
})
// 回调函数
......@@ -487,23 +486,47 @@ class ProductModel extends Component {
renderContItem() {
let {topProcOptionList, topActiveIndex} = this.state
let curData = topProcOptionList[topActiveIndex]
console.log('已选展示信息 === curData---', topProcOptionList)
console.log('已选展示信息 === curData---', topActiveIndex)
console.log('已选展示信息 === curData---', curData)
// console.log('已选展示信息 === curData---', topProcOptionList)
// console.log('已选展示信息 === curData---', topActiveIndex)
// console.log('已选展示信息 === curData---', curData)
let localBottomContData = []
if(curData && curData[SELECTED_DATA_ARR]){
// localBottomContData = curData[SELECTED_DATA_ARR]
curData[SELECTED_DATA_ARR].forEach(function(sedItem) {
if(topActiveIndex === 1 || topActiveIndex === 2 || topActiveIndex === 3){
//钉盒 零散器械
curData[SELECTED_DATA_ARR].forEach(function(sedItem, sedInd) {
if(topActiveIndex === 0){
// 手术模板
localBottomContData.push(...sedItem[CHILDREN_LINE_NAME])
}else {
if(topActiveIndex > 3){
// sedItem[SUPER_TITLE_NAME] = curData.category_name
// let end_str = ''
// if(sedInd < curData[SELECTED_DATA_ARR].length - 1){
// end_str = ' / '
// }
if(sedItem[ONLY_TWO_LEVELS]){
// 二级
sedItem[SUPER_TITLE_TIP]=`${sedItem.general_name} (${sedItem.item_code}) x ${sedItem[QUANTITY_FIELD]}`
}else {
// 三级
sedItem[SUPER_TITLE_TIP]=`${sedItem.category_name} (${sedItem.category_code}) x ${sedItem[QUANTITY_FIELD]}`
}
}
localBottomContData.push(sedItem)
}else if(sedItem[CHILD_DATA_NAME]){
localBottomContData.push(...sedItem[CHILD_DATA_NAME])
}
// if(topActiveIndex === 1 || topActiveIndex === 2 || topActiveIndex === 3){
// //钉盒 零散器械
// localBottomContData.push(sedItem)
// }else if(sedItem[CHILDREN_LINE_NAME]){
// localBottomContData.push(...sedItem[CHILDREN_LINE_NAME])
// }
})
}
// console.log('已选当前模块数据---',curData,topActiveIndex)
// console.log('已选展示信息---',localBottomContData)
return(
<View style={styles.edit_cont}>
<ScrollView
......@@ -525,26 +548,46 @@ class ProductModel extends Component {
// 返回每一列元素
renderContColumnItem(item, index) {
let {topActiveIndex} = this.state
let curTitText='', curTipTextOne='', curTipTextTwo=''
if(topActiveIndex === 1 || topActiveIndex === 2 || topActiveIndex === 3){
//钉盒 零散器械
curTitText = 'title'
curTipTextOne = 'tip1'
curTipTextTwo = 'tip2'
// if(topActiveIndex === 2){
// curTipTextOne = 'lineTip'
// curTipTextTwo = ''
// }
}else if(topActiveIndex === 2){
// 器械包
curTitText = 'item_name'
curTipTextOne = 'category_name'
curTipTextTwo = 'category_desc'
// let curTit='', curTipOne='', curTipTwo=''
let curTit='', curTipOne='', curTipTwo='', curTipOneTit='', curTipTwoTit='', curIcon=''
let curListMaxNum = ''
if(topActiveIndex === 0){
curTit = 'superTit'
curTipOne = 'superTip'
}else if(topActiveIndex === 1 || topActiveIndex === 2 || topActiveIndex === 3){
curTit = 'general_name'
curTipOne = 'specification'
curTipTwo = 'item_code'
curTipOneTit='规格型号'
curTipTwoTit='物料代码'
curIcon='photos'
if(topActiveIndex === 2){
curListMaxNum = 1
}
}else {
curTitText = 'superTit'
curTipTextOne = 'superTip'
curTit = SUPER_TITLE_NAME
curTipOne = SUPER_TITLE_TIP
}
// if(topActiveIndex === 1 || topActiveIndex === 2 || topActiveIndex === 3){
// //钉盒 零散器械
// curTit = 'title'
// curTipOne = 'tip1'
// curTipTwo = 'tip2'
// // if(topActiveIndex === 2){
// // curTipOne = 'lineTip'
// // curTipTwo = ''
// // }
// }
// else if(topActiveIndex === 2){
// // 器械包
// curTit = 'item_name'
// curTipOne = 'category_name'
// curTipTwo = 'category_desc'
// }else {
// curTit = 'superTit'
// curTipOne = 'superTip'
// }
return (
<TouchableOpacity
activeOpacity={1}
......@@ -553,11 +596,11 @@ class ProductModel extends Component {
<PicTitDetaiCalcu
listItem={item}
listIndex={index}
calField={DEFAULT_QUANTITY}
calField={QUANTITY_FIELD}
subCalCallBack={(item,index) => this.handleCalCallBack(item,index)}
titText={curTitText}
tipTextOne={curTipTextOne}
tipTextTwo={curTipTextTwo}
titText={curTit}
tipTextOne={curTipOne}
tipTextTwo={curTipTwo}
// listImgIcon={'superImg'}
listPicType={'SQUARE'}
listStyleImg={styles.list_icon}
......@@ -566,6 +609,7 @@ class ProductModel extends Component {
showClearIndex={4}
listCardActIndex={topActiveIndex}
clearCallBack={(item, index) => this.handleClearBack(item, index)}
listMaxNum ={curListMaxNum}
/>
</TouchableOpacity>
)
......@@ -589,7 +633,7 @@ class ProductModel extends Component {
style={list_common_item.lef_btn}
onPress={() => this.handleCloseSelected()}
>
<Text style={list_common_item.lef_tip}>{'已选:'}{allCountQuantity}</Text>
<Text style={list_common_item.lef_tip}>{'已选:'}<Text style={allCountQuantity!==0 ? list_common_item.lef_tip_num : ''}>{allCountQuantity}</Text></Text>
</TouchableOpacity>
<TouchableOpacity
activeOpacity={.8}
......
import React, { Component } from 'react';
import {
ActivityIndicator,
SafeAreaView,
View,
Text,
StyleSheet,
Modal
} from 'react-native';
import {
safe_view,
promary_color
} from '../../../base/BaseStyle';
/** 加载中 */
class LoadingModel extends Component {
constructor(props) {
super(props);
this.state = {
title: '加载中',
isVisible: false
}
}
show(newTitle){
let {title} = this.state
if(newTitle){
title = newTitle
}
this.setState({ isVisible: true, title: title })
}
hide(){
let {title} = this.state
this.setState({ isVisible: false, title: title})
}
render() {
let { title, size, color, style_back } = this.props
// console.log('==aaa=LoadingModel===', this.state.isVisible)
return (
<View style={styles.container}>
<Modal
transparent={true}
visible={!!this.state.isVisible}
animationType={'fade'}
>
<SafeAreaView style={safe_view}>
<View style={[styles.loding_cont, style_back]}>
<View style={styles.loding_title}>
<ActivityIndicator size={size ? size : "small"} color={color ? color : promary_color} />
<Text style={styles.tit_inner}>{title ? title : this.state.title}</Text>
</View>
</View>
</SafeAreaView>
</Modal>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
loding_cont: {
flex: 1,
backgroundColor: 'rgba(0, 0, 0, 0.1)',
paddingTop: '55%',
alignItems: 'center'
},
loding_title: {
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row'
},
tit_inner: {
fontSize: 16,
paddingLeft: 10,
color: promary_color
}
})
export default LoadingModel;
\ No newline at end of file
......@@ -37,6 +37,7 @@ class PicTitDetaiCalcu extends Component {
clearCallBack: PropTypes.func, // 清空图标回调函数
onlyShowNum: PropTypes.bool, // 只展示数字
onlyShowSelect: PropTypes.bool, // 只能单选
listMaxNum: PropTypes.number, // 数量限制最大值
}
constructor(props) {
......@@ -92,7 +93,7 @@ class PicTitDetaiCalcu extends Component {
render() {
let { listItem, listIndex, calField, listStyleBox, listStyleTit, listStyleTip, listStyleCalBtn, listPicType, titCallBack,
titText, tipTextStr, tipTextOne, tipTextTwo, listImgIcon, listStyleImg, showClearIcon, showClearIndex, listCardActIndex,
listStyleClearBtn, clearCallBack, onlyShowNum, onlyShowSelect, tipTextStrTit, tipTextOneTit, tipTextTwoTit, global_domain_config } = this.props
listStyleClearBtn, clearCallBack, onlyShowNum, onlyShowSelect, tipTextStrTit, tipTextOneTit, tipTextTwoTit, global_domain_config,listMaxNum } = this.props
let { listPicTypeArr, picStyleArr } = this.state
let picOthStyle = ''
if (listPicTypeArr.indexOf(listPicType) > -1) {
......@@ -107,6 +108,10 @@ class PicTitDetaiCalcu extends Component {
if (onlyShowSelect && listItem.select) {
defSelIcon = require('../../../images/radio_yes.png')
}
let showPlusIcon = true
if(listMaxNum && listItem[calField] === listMaxNum){
showPlusIcon = false
}
let cur_photos = []
if(listItem[listImgIcon] instanceof Array){
......@@ -180,7 +185,7 @@ class PicTitDetaiCalcu extends Component {
</View>
</TouchableOpacity> : null}
{(listItem[calField] !== 0 && !onlyShowSelect) ? <Text style={[styles.thr_num, onlyShowNum ? styles.show_num : null]}>{listItem[calField]}</Text> : null}
{(!onlyShowNum && !onlyShowSelect) ? <TouchableOpacity
{(!onlyShowNum && !onlyShowSelect && showPlusIcon) ? <TouchableOpacity
activeOpacity={.9}
style={[styles.btn_inner, listStyleCalBtn]}
onPress={() => this.handelCalculation(listItem, listIndex, true)}
......
import React, { Component } from 'react';
import { View, Text, SafeAreaView, StyleSheet, TouchableOpacity, Image, ScrollView, TextInput, Alert, Linking, NativeModules, Platform } from 'react-native';
import { View, Text, SafeAreaView, StyleSheet, TouchableOpacity, Image, ScrollView, TextInput, Alert, Linking, NativeModules, Platform, DeviceEventEmitter } from 'react-native';
import {connect} from 'react-redux';
import { home_background_color, placehold_text_color, promary_color, safe_view, icon_style, list_common_item } from '../../base/BaseStyle';
import {
......@@ -19,10 +19,11 @@ import LodingModel from '../common/LodingModel';
import DateModel from '../common/DateModel';
import { AudioRecorder, AudioUtils } from 'react-native-audio';
import Sound from 'react-native-sound';
import { requestSelfOrganizations, requestSelfSurgeryHospital, requestSelfOrderType, requestSelfTemplateCollect, requestSelfAudio, requestSelfSumbit, setSelfInitData, reqSelfSurgeryHospital, requestListDataSuccess, requestSelfSurgeryType } from '../../action/SelfAction';
import { requestSelfOrganizations, requestSelfSurgeryHospital, requestSelfOrderType, requestSelfTemplateCollect, requestSelfAudio, requestSelfSumbit, setSelfInitData, reqSelfSurgeryHospital, requestListDataSuccess, requestSelfSurgeryType, setSelectProductOpts } from '../../action/SelfAction';
import { exitLoginStatus } from '../../action/LoginAction';
import { SELF_ORDER_LIST_DOING, SELF_ORDER_LIST_SUCCESS, SELF_ORDER_LIST_FAILURE, LOGIN_NO, SELF_SUBMIT_DOING, SELF_SUBMIT_SUCCESS, SELF_SUBMIT_FAILURE } from '../../base/ActionTypes';
import PageListArrow from '../common/listDataComponent/PageListArrow';
import EmitterEvents from '../common/EmitterEvents';
class SelfOrderPage extends Component {
constructor(props) {
......@@ -161,6 +162,14 @@ class SelfOrderPage extends Component {
componentDidMount() {
this.getSellerName()
this.getAudioAuthorize()
this.subscription = DeviceEventEmitter.addListener(EmitterEvents.BACK_TO_SELF_PAGE, (params) => {
console.log('选择产品返回==', params)
})
}
componentWillUnmount() {
this.props.setSelectProductOpts([])
this.subscription.remove()
}
// 赋值销售员 初始化数据
......@@ -1835,7 +1844,8 @@ const mapStateToProps = (state) => {
self_list_status: state.selfOrder.self_list_status,
submit_self_order_status: state.selfOrder.submit_self_order_status,
selfOrderOption: state.selfOrder.selfOrderOption,
global_domain_config: state.login.global_domain_config
global_domain_config: state.login.global_domain_config,
local_sele_pro_options: state.selfOrder.local_sele_pro_options
}
}
......@@ -1867,6 +1877,9 @@ const mapDispatchToProps = (dispatch) => {
},
requestSelfSurgeryType: (params) => {
dispatch(requestSelfSurgeryType(params))
},
setSelectProductOpts: (data) => {
dispatch(setSelectProductOpts(data))
}
}
}
......
import React, { Component } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Image, TextInput } from 'react-native';
import { View, Text, StyleSheet, TouchableOpacity, Image, TextInput, DeviceEventEmitter, SafeAreaView } from 'react-native';
import { connect } from 'react-redux';
import { foundation_color, home_background_color, Width, third_text_size, pxSize, promary_color, safe_view, font_family_regular, icon_style, title_text_color, font_family_medium, list_common_item } from '../../../base/BaseStyle';
import HeadBackItem from '../../common/HeadBackItem';
......@@ -8,15 +8,18 @@ import ProductModel from '../../common/ProductModel';
import StatusBarView from '../../common/StatusBarView';
import ChooseCardList from '../../common/listDataComponent/ChooseCardList';
import { cloneObject, dedupQuoteArray, show } from '../../../utils/Utils';
import { reqPurSupplierSearch, reqProCategorySearch, reqSurTempHeadSearch, reqNailEquipHeadSearch, reqScatEquipmentSearch, reqSingleConsumSearch } from '../../../action/SelfAction';
import { reqPurSupplierSearch, reqProCategorySearch, reqSurTempHeadSearch, reqNailEquipHeadSearch, reqScatEquipmentSearch, reqSingleConsumSearch, setSelectProductOpts } from '../../../action/SelfAction';
import EmitterEvents from '../../common/EmitterEvents';
import LoadingModel from '../../common/listDataComponent/LoadingModel';
import localMockData from './mock/sen_mock';
const DEFAULT_FIELD = 'quantity' // 计算的字段
const CHILD_DATA_NAME = 'childrenLineData' // 显示的子类数组名称
const QUANTITY_FIELD = 'quantity' // 计算的字段
const CHILDREN_LINE_NAME = 'childrenLineData' // 显示的子类数组名称
const SELECTED_QUQNTITY = 'selectedQuantity' // 中类数量
const SELECTED_DATA_ARR = 'selectedDataArr' // 中类已选元素
const LOCAL_SECOND_DATA = 'localSecondData' // 中类原本元素
const ONLY_TWO_LEVELS = 'onlyTwoLevels' // 只有两级的耗材
class ChooseProductPage extends Component {
constructor(props) {
......@@ -70,10 +73,36 @@ class ChooseProductPage extends Component {
this.initGetData()
}
// 返回
handleGoBack() {
let { topProcOptionList } = this.state
let { setSelectProductOpts } = this.props
setSelectProductOpts(topProcOptionList)
// 并且=======调用返回
this.props.navigation.goBack()
DeviceEventEmitter.emit(EmitterEvents.BACK_TO_SELF_PAGE, { topProcOptionList: topProcOptionList, testOne: '你好' })
}
// 初始化获取数据
async initGetData() {
let that = this
let { token, global_domain_config, navigation } = that.props
let { token, global_domain_config, navigation, local_sele_pro_options } = that.props
// 判断 local_sele_pro_options 是否有值
// 进行本地转换
console.log('local_sele_pro_options====有值吗====>', local_sele_pro_options)
if (local_sele_pro_options && local_sele_pro_options.length > 0) {
// 之前选择过值
that.setState({
topProcOptionList: local_sele_pro_options
})
return
}
console.log('local_sele_pro_options====有值吗====>')
that.refs.LoadingModel.show()
let cur_org_code = ''
if (navigation.state.params.selfData) {
cur_org_code = navigation.state.params.selfData.org_code
......@@ -96,6 +125,7 @@ class ChooseProductPage extends Component {
that.setState({
topProcOptionList
}, () => {
that.refs.LoadingModel.hide()
that.handleTopNav(topProcOptionList[0], 0)
})
} else {
......@@ -105,9 +135,10 @@ class ChooseProductPage extends Component {
// 顶部产品点击,获取左侧数据
async handleTopNav(topItem, topIndex) {
// console.log('top产品--',topItem, topIndex)
console.log('top产品--', topItem, topIndex)
let that = this
let { token, global_domain_config } = that.props
that.refs.LoadingModel.show()
let params = {
access_token: token,
manufacturer_code: topItem.supplier_code,
......@@ -116,17 +147,22 @@ class ChooseProductPage extends Component {
console.log('res_2 : ', pro_scate_search)
if (pro_scate_search.error_code === 0) {
let { topProcOptionList, defalutLeftItem } = this.state
let { data } = pro_scate_search
topItem.leftOptionList = defalutLeftItem.concat(data.item)
topItem.leftOptionList.forEach(function (leftObj) {
leftObj['selectedQuantity'] = 0
leftObj['localSecondData'] = []
})
topProcOptionList[topIndex] = topItem
if (topItem[SELECTED_QUQNTITY] === 0) {
let { data } = pro_scate_search
topItem.leftOptionList = defalutLeftItem.concat(data.item)
topItem.leftOptionList.forEach(function (leftObj) {
leftObj['selectedQuantity'] = 0
leftObj['localSecondData'] = []
})
topProcOptionList[topIndex] = topItem
}
that.setState({
topActiveIndex: topIndex,
topProcOptionList: topProcOptionList
}, () => {
that.refs.LoadingModel.hide()
that.handleLeftNav(topItem['leftOptionList'][0], 0)
})
......@@ -142,16 +178,30 @@ class ChooseProductPage extends Component {
// 左侧标题点击
async handleLeftNav(leftItem, leftIndex) {
// console.log('左侧标题--', index, item)
let { topProcOptionList, topActiveIndex, leftOptionList } = this.state
let that = this
let { topProcOptionList, topActiveIndex, leftOptionList } = that.state
console.log('左侧标题--', topActiveIndex, leftItem, leftIndex)
let { token, global_domain_config, navigation, userInfo } = that.props
if (leftItem[SELECTED_QUQNTITY] !== 0) {
// topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = leftItem
that.setState({
leftActiveIndex: leftIndex,
// topProcOptionList: topProcOptionList
// leftOptionList: leftOptionList
})
return
}
that.refs.LoadingModel.show()
let cur_org_code = ''
if (navigation.state.params.selfData) {
cur_org_code = navigation.state.params.selfData.org_code
}
let topItem = topProcOptionList[topActiveIndex]
if (leftIndex === 0) {
let params = {
access_token: token,
org_code: cur_org_code,
......@@ -161,19 +211,28 @@ class ChooseProductPage extends Component {
let sur_head_search = await reqSurTempHeadSearch(global_domain_config, params)
console.log('res_3 : ', sur_head_search)
if (sur_head_search.error_code === 0) {
let { data } = sur_head_search
leftItem.localSecondData = cloneObject(data.surgery_template)
leftItem['localSecondData'].forEach(function (righDa) {
if (!righDa['quantity']) {
righDa['quantity'] = 0
} else {
righDa['quantity'] = Number(righDa['quantity'])
}
})
leftOptionList[leftIndex] = leftItem
// // if(leftItem[SELECTED_QUQNTITY] === 0){
// let { data } = sur_head_search
// leftItem.localSecondData = cloneObject(data.surgery_template)
// leftItem['localSecondData'].forEach(function (righDa) {
// if (!righDa['quantity']) {
// righDa['quantity'] = 0
// } else {
// righDa['quantity'] = Number(righDa['quantity'])
// }
// })
// topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = cloneObject(leftItem)
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(leftItem, sur_head_search.data.surgery_template)
// }
that.setState({
leftActiveIndex: leftIndex,
leftOptionList: leftOptionList
topProcOptionList: topProcOptionList
// leftOptionList: leftOptionList
}, () => {
that.refs.LoadingModel.hide()
})
} else {
......@@ -192,19 +251,28 @@ class ChooseProductPage extends Component {
let nail_equip_head_search = await reqNailEquipHeadSearch(global_domain_config, params)
console.log('res_3 : ', nail_equip_head_search)
if (nail_equip_head_search.error_code === 0) {
let { data } = nail_equip_head_search
leftItem.localSecondData = cloneObject(data.items)
leftItem['localSecondData'].forEach(function (righDa) {
if (!righDa['quantity']) {
righDa['quantity'] = 0
} else {
righDa['quantity'] = Number(righDa['quantity'])
}
})
leftOptionList[leftIndex] = leftItem
// // if(leftItem[SELECTED_QUQNTITY] === 0){
// let { data } = nail_equip_head_search
// leftItem.localSecondData = cloneObject(data.items)
// leftItem['localSecondData'].forEach(function (righDa) {
// if (!righDa['quantity']) {
// righDa['quantity'] = 0
// } else {
// righDa['quantity'] = Number(righDa['quantity'])
// }
// })
// topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = cloneObject(leftItem)
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(leftItem, nail_equip_head_search.data.items)
// }
that.setState({
leftActiveIndex: leftIndex,
leftOptionList: leftOptionList
topProcOptionList: topProcOptionList
// leftOptionList: leftOptionList
}, () => {
that.refs.LoadingModel.hide()
})
} else {
......@@ -217,47 +285,86 @@ class ChooseProductPage extends Component {
let scat_head_search = await reqScatEquipmentSearch(global_domain_config, params)
console.log('res_3 : ', scat_head_search)
if (scat_head_search.error_code === 0) {
let { data } = scat_head_search
leftItem.localSecondData = cloneObject(data.tools)
leftItem['localSecondData'].forEach(function (righDa) {
if (!righDa['quantity']) {
righDa['quantity'] = 0
} else {
righDa['quantity'] = Number(righDa['quantity'])
}
})
leftOptionList[leftIndex] = leftItem
// // if(leftItem[SELECTED_QUQNTITY] === 0){
// let { data } = scat_head_search
// leftItem.localSecondData = cloneObject(data.tools)
// leftItem['localSecondData'].forEach(function (righDa) {
// if (!righDa['quantity']) {
// righDa['quantity'] = 0
// } else {
// righDa['quantity'] = Number(righDa['quantity'])
// }
// })
// topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = cloneObject(leftItem)
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(leftItem, scat_head_search.data.tools)
// }
that.setState({
leftActiveIndex: leftIndex,
leftOptionList: leftOptionList
topProcOptionList: topProcOptionList
// leftOptionList: leftOptionList
}, () => {
that.refs.LoadingModel.hide()
})
} else {
that.showRrrorTip(scat_head_search)
}
} else {
} else if (leftIndex > 3) {
let params = {
access_token: token
access_token: token,
leftIndex: leftIndex, // 本地测试
}
let single_all_search = await reqSingleConsumSearch(global_domain_config, params)
console.log('res_3 : ', single_all_search)
console.log('res_3 : ', single_all_search, leftIndex, leftIndex % 2)
if (single_all_search.error_code === 0) {
let { data } = single_all_search
console.log('data : ', data, data instanceof Array)
if (data instanceof Array) {
// if(leftItem[SELECTED_QUQNTITY] === 0){
//大-中-小类
leftItem.localSecondData = cloneObject(data)
leftItem['localSecondData'].forEach(function (righDa) {
righDa[CHILDREN_LINE_NAME] = []
if (!righDa['quantity']) {
righDa['quantity'] = 0
} else {
righDa['quantity'] = Number(righDa['quantity'])
}
righDa[CHILD_DATA_NAME] = cloneObject(righDa['details'])
})
leftOptionList[leftIndex] = leftItem
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = cloneObject(leftItem)
// }
that.setState({
leftActiveIndex: leftIndex,
leftOptionList: leftOptionList
topProcOptionList: topProcOptionList
// leftOptionList: leftOptionList
}, () => {
that.refs.LoadingModel.hide()
})
} else {
//大-小类
// if(leftItem[SELECTED_QUQNTITY] === 0){
leftItem.localSecondData = cloneObject(data.details)
leftItem['localSecondData'].forEach(function (righDa) {
righDa['onlyTwoLevels'] = true
if (!righDa['quantity']) {
righDa['quantity'] = 0
} else {
righDa['quantity'] = Number(righDa['quantity'])
}
})
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = cloneObject(leftItem)
// }
that.setState({
leftActiveIndex: leftIndex,
topProcOptionList: topProcOptionList
// leftOptionList: leftOptionList
}, () => {
that.refs.LoadingModel.hide()
})
}
} else {
......@@ -273,6 +380,22 @@ class ChooseProductPage extends Component {
// })
}
// 初始化二级数据
getInitLocalSecondData(leftItem, resDa) {
if (!leftItem.localSecondData) {
leftItem.localSecondData = []
}
leftItem.localSecondData = cloneObject(resDa)
leftItem['localSecondData'].forEach(function (righDa) {
if (!righDa['quantity']) {
righDa['quantity'] = 0
} else {
righDa['quantity'] = Number(righDa['quantity'])
}
})
return cloneObject(leftItem)
}
// 修改
handleChangeThrShow(show) {
this.setState({
......@@ -280,7 +403,7 @@ class ChooseProductPage extends Component {
})
}
// 计算三级回调函数
// 计算三级回调函数 -- 未使用
handleChangeThird(childData, superIndex) {
let { leftActiveIndex, leftOptionList, topProcOptionList, topActiveIndex } = this.state
......@@ -289,67 +412,68 @@ class ChooseProductPage extends Component {
topProcOptionList[topActiveIndex].leftOptionList[leftActiveIndex][SELECTED_QUQNTITY] = 0
topProcOptionList[topActiveIndex].leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = []
// 初始化
leftOptionList[leftActiveIndex][SELECTED_QUQNTITY] = 0
leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = []
let top_sel_sum = 0
// 初始化
// leftOptionList[leftActiveIndex][SELECTED_QUQNTITY] = 0
// leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = []
// let top_sel_sum = 0
// 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) {
// if (leItem[LOCAL_SECOND_DATA].length && leItem[LOCAL_SECOND_DATA][superIndex] && childData.length) {
// let sumCount = 0
// childData.map((chDa, chInd) => {
// if (!chDa[QUANTITY_FIELD]) {
// chDa[QUANTITY_FIELD] = 0
// }
// sumCount += chDa[QUANTITY_FIELD]
// })
// let chDa = leItem[LOCAL_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,
// [QUANTITY_FIELD]: sumCount
// }
// // 初始化
// leItem[LOCAL_SECOND_DATA][superIndex][CHILDREN_LINE_NAME] = []
// leItem[LOCAL_SECOND_DATA][superIndex][CHILDREN_LINE_NAME].push(curObj)
// leItem[LOCAL_SECOND_DATA][superIndex][QUANTITY_FIELD] = sumCount
// }
// // 初始化
// leItem[SELECTED_QUQNTITY] = 0
// leItem[SELECTED_DATA_ARR] = []
// if (leItem[LOCAL_SECOND_DATA].length) { // 本地测试 localSecondData LOCAL_SECOND_DATA
// leItem[LOCAL_SECOND_DATA].forEach(function (chItem) {
// if (chItem[QUANTITY_FIELD] > 0) {
// leItem[SELECTED_QUQNTITY] += Number(chItem[QUANTITY_FIELD])
// leItem[SELECTED_DATA_ARR].push(chItem)
// }
// })
// }
// }
// // top_sel_sum += leItem[SELECTED_QUQNTITY]
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) {
if (leItem[LOCAL_SECOND_DATA].length && leItem[LOCAL_SECOND_DATA][superIndex] && childData.length) {
let sumCount = 0
childData.map((chDa, chInd) => {
if (!chDa[DEFAULT_FIELD]) {
chDa[DEFAULT_FIELD] = 0
}
sumCount += chDa[DEFAULT_FIELD]
})
let chDa = leItem[LOCAL_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[LOCAL_SECOND_DATA][superIndex][CHILD_DATA_NAME] = []
leItem[LOCAL_SECOND_DATA][superIndex][CHILD_DATA_NAME].push(curObj)
leItem[LOCAL_SECOND_DATA][superIndex][DEFAULT_FIELD] = sumCount
}
// 初始化
leItem[SELECTED_QUQNTITY] = 0
leItem[SELECTED_DATA_ARR] = []
if (leItem[LOCAL_SECOND_DATA].length) { // 本地测试 localSecondData LOCAL_SECOND_DATA
leItem[LOCAL_SECOND_DATA].forEach(function (chItem) {
if (chItem[DEFAULT_FIELD] > 0) {
leItem[SELECTED_QUQNTITY] += Number(chItem[DEFAULT_FIELD])
leItem[SELECTED_DATA_ARR].push(chItem)
}
})
}
}
// top_sel_sum += leItem[SELECTED_QUQNTITY]
})
// })
// topProcOptionList[topActiveIndex] = top_sel_sum
// // topProcOptionList[topActiveIndex] = top_sel_sum
topProcOptionList[topActiveIndex].leftOptionList.map(function (leItem, leIndex) {
if (!leItem[SELECTED_QUQNTITY]) {
......@@ -359,54 +483,55 @@ class ChooseProductPage extends Component {
leItem[SELECTED_DATA_ARR] = []
}
if (leIndex === leftActiveIndex) {
if (leItem[LOCAL_SECOND_DATA].length && leItem[LOCAL_SECOND_DATA][superIndex] && childData.length) {
let sumCount = 0
childData.map((chDa, chInd) => {
if (!chDa[DEFAULT_FIELD]) {
chDa[DEFAULT_FIELD] = 0
}
sumCount += chDa[DEFAULT_FIELD]
})
let chDa = leItem[LOCAL_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[LOCAL_SECOND_DATA][superIndex][CHILD_DATA_NAME] = []
leItem[LOCAL_SECOND_DATA][superIndex][CHILD_DATA_NAME].push(curObj)
leItem[LOCAL_SECOND_DATA][superIndex][DEFAULT_FIELD] = sumCount
}
// if (leItem[LOCAL_SECOND_DATA].length && leItem[LOCAL_SECOND_DATA][superIndex] && childData.length) {
// let sumCount = 0
// childData.map((chDa, chInd) => {
// if (!chDa[QUANTITY_FIELD]) {
// chDa[QUANTITY_FIELD] = 0
// }
// sumCount += chDa[QUANTITY_FIELD]
// })
// let chDa = leItem[LOCAL_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,
// [QUANTITY_FIELD]: sumCount
// }
// // 初始化
// leItem[LOCAL_SECOND_DATA][superIndex][CHILDREN_LINE_NAME] = []
// leItem[LOCAL_SECOND_DATA][superIndex][CHILDREN_LINE_NAME].push(curObj)
// leItem[LOCAL_SECOND_DATA][superIndex][QUANTITY_FIELD] = sumCount
// }
// 初始化
leItem[SELECTED_QUQNTITY] = 0
leItem[SELECTED_DATA_ARR] = []
if (leItem[LOCAL_SECOND_DATA].length) { // 本地测试 localSecondData LOCAL_SECOND_DATA
leItem[LOCAL_SECOND_DATA].forEach(function (chItem) {
if (chItem[DEFAULT_FIELD] > 0) {
leItem[SELECTED_QUQNTITY] += Number(chItem[DEFAULT_FIELD])
if (chItem[QUANTITY_FIELD] > 0) {
leItem[SELECTED_QUQNTITY] += Number(chItem[QUANTITY_FIELD])
leItem[SELECTED_DATA_ARR].push(chItem)
}
})
}
}
// top_sel_sum += leItem[SELECTED_QUQNTITY]
top_sel_sum += leItem[SELECTED_QUQNTITY]
})
topProcOptionList[topActiveIndex] = top_sel_sum
// console.log('计算三级之后数据---', topProcOptionList, top_sel_sum)
console.log('计算三级之后数据---', topProcOptionList)
this.setState({
leftOptionList,
// leftOptionList,
topProcOptionList
})
}
......@@ -414,34 +539,37 @@ class ChooseProductPage extends Component {
// 计算中级数量回调
handleChangeCount(count, coutFieName) {
let { leftActiveIndex, leftOptionList, topProcOptionList, topActiveIndex, defaultThridShow } = this.state
// console.log('计算中级数量回调===', count, leftActiveIndex, defaultThridShow, coutFieName)
console.log('计算中级数量回调===', count, leftActiveIndex, defaultThridShow, coutFieName)
// 初始化
topProcOptionList[topActiveIndex][SELECTED_QUQNTITY] = 0
topProcOptionList[topActiveIndex].leftOptionList[leftActiveIndex][SELECTED_QUQNTITY] = 0
topProcOptionList[topActiveIndex].leftOptionList[leftActiveIndex][SELECTED_DATA_ARR] = []
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) {
// 当前选择项
leItem[SELECTED_QUQNTITY] = count
if (leItem[LOCAL_SECOND_DATA].length) { // 本地测试 localSecondData LOCAL_SECOND_DATA
leItem[LOCAL_SECOND_DATA].forEach(function (chItem) {
if (chItem[coutFieName]) {
leItem[SELECTED_DATA_ARR].push(chItem)
}
})
}
}
})
// 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) {
// // 当前选择项
// leItem[SELECTED_QUQNTITY] = count
// if (leItem[LOCAL_SECOND_DATA].length) { // 本地测试 localSecondData LOCAL_SECOND_DATA
// leItem[LOCAL_SECOND_DATA].forEach(function (chItem) {
// if (chItem[coutFieName]) {
// leItem[SELECTED_DATA_ARR].push(chItem)
// }
// })
// }
// }
// })
let top_sel_sum = 0
topProcOptionList[topActiveIndex].leftOptionList.map(function (leItem, leIndex) {
if (!leItem[SELECTED_QUQNTITY]) {
leItem[SELECTED_QUQNTITY] = 0
......@@ -461,10 +589,13 @@ class ChooseProductPage extends Component {
})
}
}
top_sel_sum += leItem[SELECTED_QUQNTITY]
})
topProcOptionList[topActiveIndex][SELECTED_QUQNTITY] = top_sel_sum
// console.log('计算中级之后---', leftOptionList)
console.log('计算中级之后---', topProcOptionList)
this.setState({
leftOptionList,
// leftOptionList,
topProcOptionList
})
}
......@@ -506,9 +637,10 @@ class ChooseProductPage extends Component {
// 点击选好了
handleSubmit() {
console.log('选好了', this.props.navigation.navigate)
console.log('选好了')
this.handleCloseSelectModal(false)
console.log('携带数据,返回到自助下单')
this.handleGoBack()
}
// 已选修改回调
......@@ -524,6 +656,7 @@ class ChooseProductPage extends Component {
// 接口错误提示
showRrrorTip(result) {
this.refs.LoadingModel.hide()
if (result.error_code == 41006) {
show('登录过期,请重新登录');
this.props.exitLoginStatus();
......@@ -655,7 +788,7 @@ class ChooseProductPage extends Component {
superStencilData={curRigSecoOption}
superCallBack={(count, coutFieName) => this.handleChangeCount(count, coutFieName)}
superReduceBack={() => this.handleSubSelected()}
thirdCallBack={(childData, superIndex) => this.handleChangeThird(childData, superIndex)}
// thirdCallBack={(childData, superIndex) => this.handleChangeThird(childData, superIndex)}
// superLeftData={leftOptionList[leftActiveIndex]}
superLeftData={curSuperLeftOption}
/>
......@@ -667,12 +800,12 @@ class ChooseProductPage extends Component {
renderFooterBtnItem() {
let { selectShowPopup, leftOptionList, topProcOptionList, topActiveIndex } = this.state
let allCountQuantity = this.getAllCountQuantity()
console.log('左侧数据----', leftOptionList)
let cur_sel_options = []
// cur_sel_options = leftOptionList
if (topProcOptionList.length > 0) {
cur_sel_options = topProcOptionList[topActiveIndex].leftOptionList
}
console.log('返回底部按钮----', cur_sel_options)
return (
<View style={list_common_item.sub_box}>
<View style={list_common_item.sub_two_btn}>
......@@ -681,7 +814,7 @@ class ChooseProductPage extends Component {
style={list_common_item.lef_btn}
onPress={() => this.handleSubSelected()}
>
<Text style={list_common_item.lef_tip}>{'已选:'}{allCountQuantity}</Text>
<Text style={list_common_item.lef_tip}>{'已选:'}<Text style={allCountQuantity !== 0 ? list_common_item.lef_tip_num : ''}>{allCountQuantity}</Text></Text>
</TouchableOpacity>
<TouchableOpacity
activeOpacity={.8}
......@@ -700,10 +833,19 @@ class ChooseProductPage extends Component {
// modelOption={leftOptionList}
modelCallBack={(options) => this.handleSelectCallBack(options)}
/>
{ this.renderLodingItem()}
</View>
)
}
// 返回正在加载中
renderLodingItem() {
return (
<LoadingModel ref="LoadingModel" />
)
}
render() {
let { navigation } = this.props
let { title } = navigation.state.params
......@@ -714,15 +856,15 @@ class ChooseProductPage extends Component {
backgroundColor={promary_color}
barStyle='light-content'
/>
<View style={safe_view}>
<HeadBackItem title={title} navigation={navigation} />
<SafeAreaView style={safe_view}>
<HeadBackItem title={title} navigation={navigation} callback={() => this.handleGoBack()} />
<View style={styles.choo_main}>
{/* {this.renderSearchItem()} */}
{this.renderTopProItem()}
{this.renderContItem()}
</View>
{this.renderFooterBtnItem()}
</View>
</SafeAreaView>
</View>
);
}
......@@ -853,7 +995,8 @@ const mapStateToProps = (state) => {
userInfo: state.login.userInfo,
token: state.login.token,
loginState: state.login.loginState,
global_domain_config: state.login.global_domain_config
global_domain_config: state.login.global_domain_config,
local_sele_pro_options: state.selfOrder.local_sele_pro_options
}
}
......@@ -862,6 +1005,9 @@ const mapDispatchToProps = (dispatch) => {
exitLoginStatus: () => {
dispatch(exitLoginStatus())
},
setSelectProductOpts: (data) => {
dispatch(setSelectProductOpts(data))
}
}
}
......
......@@ -12,6 +12,7 @@ import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu';
import PictureZoom from '../../common/listDataComponent/PictureZoom';
import { cloneObject, show } from '../../../utils/Utils';
import { reqSurTempLineSearch, reqNailBoxLineSearch, reqEquipPackageLineSearch } from '../../../action/SelfAction';
import LoadingModel from '../../common/listDataComponent/LoadingModel';
import localMockData from './mock/sen_mock';
const SELECTED_QUQNTITY = 'selectedQuantity' // 三级数量
......@@ -89,6 +90,8 @@ class EditThirdLevelPage extends Component {
let { defalutTopItem, topProcOptionList } = that.state
let { leftIndex, superIndex, superItem, thirdShow } = superData
console.log('父组件传递的值==', leftIndex, superIndex, superItem, thirdShow)
that.refs.LoadingModel.show()
that.setState({
superData: cloneObject(superData)
})
......@@ -123,6 +126,7 @@ class EditThirdLevelPage extends Component {
that.setState({
topProcOptionList: topProcOptionList
}, () => {
that.refs.LoadingModel.hide()
that.setAllSelectData()
})
} else {
......@@ -148,7 +152,7 @@ class EditThirdLevelPage extends Component {
topProcOptionList: topProcOptionList,
onlyShow: true
}, () => {
// that.setAllSelectData()
that.refs.LoadingModel.hide()
})
} else {
that.showRrrorTip(nail_line_search)
......@@ -171,7 +175,7 @@ class EditThirdLevelPage extends Component {
topProcOptionList: topProcOptionList,
onlyShow: true
}, () => {
// that.setAllSelectData()
that.refs.LoadingModel.hide()
})
} else {
that.showRrrorTip(equip_line_search)
......@@ -260,6 +264,7 @@ class EditThirdLevelPage extends Component {
// 接口错误提示
showRrrorTip(result) {
this.refs.LoadingModel.hide()
if (result.error_code == 41006) {
show('登录过期,请重新登录');
this.props.exitLoginStatus();
......@@ -367,6 +372,9 @@ class EditThirdLevelPage extends Component {
renderItem={({ item, index }) => this.renderContColumnItem(item, index)}
/>
</ScrollView>
{ this.renderLodingItem() }
</View>
)
}
......@@ -432,6 +440,13 @@ class EditThirdLevelPage extends Component {
)
}
// 返回正在加载中
renderLodingItem() {
return(
<LoadingModel ref="LoadingModel"/>
)
}
render() {
let { navigation } = this.props
let { title } = navigation.state.params
......
......@@ -5,23 +5,24 @@ import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu';
import PictureZoom from '../../common/listDataComponent/PictureZoom';
import { cloneObject } from '../../../utils/Utils';
import _ from "lodash";
import localMockData from './mock/sen_mock';
import { connect } from 'react-redux';
import localMockData from './mock/sen_mock';
const PropTypes = require('prop-types');
const DEFAULT_FIELD = 'quantity' // 计算的字段
const CHILD_DATA_NAME = 'childrenLineData' // 显示的子类数组名称
const QUANTITY_FIELD = 'quantity' // 计算的字段
const CHILDREN_LINE_NAME = 'childrenLineData' // 显示的子类数组名称
const ONLY_TWO_LEVELS = 'onlyTwoLevels' // 只有两级的耗材
const SELECTED_QUQNTITY = 'selectedQuantity' // 中类数量
const SELECTED_DATA_ARR = 'selectedDataArr' // 中类已选元素
const DEFAULT_SECOND_DATA = 'localSecondData' // 中类原本元素
const LOCAL_SECOND_DATA = 'localSecondData' // 中类原本元素
class ProductRightStyle extends Component {
static propTypres = {
superCallBack: PropTypes.func, // 回调计算函数
superReduceBack: PropTypes.func, // 减法回调
thirdCallBack: PropTypes.func, // 三级小类的回调函数
// thirdCallBack: PropTypes.func, // 三级小类的回调函数
superLeftData: PropTypes.object, // 三级大类数据
superStencilData: PropTypes.array, // 当前右侧二级数据
leftIndex: PropTypes.numberm, // 左侧index
......@@ -86,7 +87,7 @@ class ProductRightStyle extends Component {
} else if (leftIndex === 3) {
// 零散器械
this.canPlusOrdReduceOne(item, index)
// this.handleCalCallBack(curData, curIndex, 'rightSecondData', DEFAULT_FIELD)
// this.handleCalCallBack(curData, curIndex, 'rightSecondData', QUANTITY_FIELD)
// this.setState({
// rightSecondData
// })
......@@ -110,71 +111,110 @@ class ProductRightStyle extends Component {
handleAllPlusReduce(curData, curIndex, isPlus) {
let { rightSecondData } = this.state
let { superLeftData } = this.props
// console.log('大类加减,整理加一/减一', curData, curIndex)
// console.log('右侧数据', rightSecondData, curData[CHILD_DATA_NAME])
console.log('大类加减,整理加一/减一', curData, curIndex, isPlus)
// console.log('右侧数据', rightSecondData, curData[CHILDREN_LINE_NAME])
let rowData = [] // 本地测试,需要获取接口数据(无数据时,加法)
rowData = cloneObject(localMockData.localSingleRowData) // 初始化数据
// let rowData = [] // 本地测试,需要获取接口数据(无数据时,加法)
// rowData = cloneObject(localMockData.localSingleRowData) // 初始化数据
// console.log('本地测试,获取接口数据--', curData)
// let rowData = []
// rowData = curData.details
if ((!curData[CHILD_DATA_NAME] || !curData[CHILD_DATA_NAME].length) && isPlus) {
let curObj = {
superId: curData['id'], // 本地测试
superIndex: curIndex, // 本地测试
superTit: superLeftData['title'], // 本地测试
superImg: curData['imgIcon'], // 本地测试
superTip: curData['title'], // 本地测试
curTitle: curData['title'], // 本地测试
version: 0,
lineOptions: rowData,
[DEFAULT_FIELD]: 0
}
// 初始化
curData[CHILD_DATA_NAME] = []
curData[CHILD_DATA_NAME].push(curObj)
curData[DEFAULT_FIELD] = 0
}
// console.log('本地测试,获取接口数据--', curData)
// console.log('本地测试,获取接口数据--', rightSecondData)
// console.log('本地测试,获取接口数据--', superLeftData)
// 加法/减法
if (curData[CHILD_DATA_NAME] && curData[CHILD_DATA_NAME].length > 0) {
if(curData.details && curData.details.length > 0){
let sumCount = 0
curData[CHILD_DATA_NAME][0].lineOptions.forEach(function (lineIt) {
if (!lineIt[DEFAULT_FIELD]) {
lineIt[DEFAULT_FIELD] = 0
curData[QUANTITY_FIELD] = 0 // 初始化
curData.details.forEach(function(line_val){
if (!line_val[QUANTITY_FIELD]) {
line_val[QUANTITY_FIELD] = 0
}
if (!isPlus) {
// 减法
if (lineIt[DEFAULT_FIELD]) {
lineIt[DEFAULT_FIELD] -= 1
} else {
lineIt[DEFAULT_FIELD] = 0
}
} else {
// 加法
lineIt[DEFAULT_FIELD] += 1
if(isPlus){
line_val[QUANTITY_FIELD] += 1
}else if(line_val[QUANTITY_FIELD] > 0){
line_val[QUANTITY_FIELD] -= 1
}
sumCount += lineIt[DEFAULT_FIELD]
sumCount += line_val[QUANTITY_FIELD]
})
if (sumCount) {
curData[CHILD_DATA_NAME][0][DEFAULT_FIELD] = sumCount
curData[DEFAULT_FIELD] = sumCount
curData[CHILD_DATA_NAME][0].superTip = `${curData['title']}x${sumCount}`
} else {
curData[DEFAULT_FIELD] = 0
delete curData[CHILD_DATA_NAME]
}
curData[QUANTITY_FIELD] = sumCount
this.handleCalCallBack(curData, curIndex, 'rightSecondData', QUANTITY_FIELD)
}
// console.log('修改后的数据', curData, rowData, curIndex)
this.handleCalCallBack(curData, curIndex, 'rightSecondData', DEFAULT_FIELD)
this.setState({
rightSecondData
})
// if ((!curData[CHILDREN_LINE_NAME] || !curData[CHILDREN_LINE_NAME].length) && isPlus) {
// let curObj = {
// superId: curData['category_code'],
// superIndex: curIndex,
// superTit: superLeftData['category_name'],
// superImg: curData['photos'],
// superTip: curData['category_name'],
// curTitle: curData['category_name'],
// version: 0,
// lineOptions: rowData,
// [QUANTITY_FIELD]: 0
// }
// // let curObj = {
// // superId: curData['id'], // 本地测试
// // superIndex: curIndex, // 本地测试
// // superTit: superLeftData['title'], // 本地测试
// // superImg: curData['imgIcon'], // 本地测试
// // superTip: curData['title'], // 本地测试
// // curTitle: curData['title'], // 本地测试
// // version: 0,
// // lineOptions: rowData,
// // [QUANTITY_FIELD]: 0
// // }
// // 初始化
// curData[CHILDREN_LINE_NAME] = []
// curData[CHILDREN_LINE_NAME].push(curObj)
// curData[QUANTITY_FIELD] = 0
// }
// // 加法/减法
// if (curData[CHILDREN_LINE_NAME] && curData[CHILDREN_LINE_NAME].length > 0) {
// let sumCount = 0
// curData[CHILDREN_LINE_NAME][0].lineOptions.forEach(function (lineIt) {
// if (!lineIt[QUANTITY_FIELD]) {
// lineIt[QUANTITY_FIELD] = 0
// }
// if (!isPlus) {
// // 减法
// if (lineIt[QUANTITY_FIELD]) {
// lineIt[QUANTITY_FIELD] -= 1
// } else {
// lineIt[QUANTITY_FIELD] = 0
// }
// } else {
// // 加法
// lineIt[QUANTITY_FIELD] += 1
// }
// sumCount += lineIt[QUANTITY_FIELD]
// })
// if (sumCount) {
// curData[CHILDREN_LINE_NAME][0][QUANTITY_FIELD] = sumCount
// curData[QUANTITY_FIELD] = sumCount
// curData[CHILDREN_LINE_NAME][0].superTip = `${curData['category_name']}x${sumCount}`
// } else {
// curData[QUANTITY_FIELD] = 0
// delete curData[CHILDREN_LINE_NAME]
// }
// }
console.log('修改后的数据', curData, curIndex)
// this.handleCalCallBack(curData, curIndex, 'rightSecondData', QUANTITY_FIELD)
// this.setState({
// rightSecondData
// })
}
// 编辑页面的回调
// 手术模板-编辑页面的回调
childrenPageCallBack(childData, index) {
let { rightSecondData } = this.state
let { leftIndex } = this.props
......@@ -182,14 +222,14 @@ class ProductRightStyle extends Component {
let that = this
if (leftIndex === 8) { // leftIndex === 2 器械包有问题
// rightSecondData.forEach(function(rsdItem, rsdIndex) {
// if(!rsdItem[CHILD_DATA_NAME]) {
// rsdItem[CHILD_DATA_NAME] = []
// if(!rsdItem[CHILDREN_LINE_NAME]) {
// rsdItem[CHILDREN_LINE_NAME] = []
// }
// if(!rsdItem[DEFAULT_FIELD]) {
// rsdItem[DEFAULT_FIELD] = 0
// if(!rsdItem[QUANTITY_FIELD]) {
// rsdItem[QUANTITY_FIELD] = 0
// }
// if(rsdIndex === index) {
// rsdItem[CHILD_DATA_NAME].push(childData)
// rsdItem[CHILDREN_LINE_NAME].push(childData)
// rsdItem.lineOptions = childData
// let superTip = '', tipObj = {}
// // childData.map((chDa) => {
......@@ -197,7 +237,7 @@ class ProductRightStyle extends Component {
// // superTip += `${chDa.title}`
// // }
// // })
// rsdItem[CHILD_DATA_NAME].map(chItem => {
// rsdItem[CHILDREN_LINE_NAME].map(chItem => {
// chItem.forEach(childDa => {
// if(childDa.select){
// if(!tipObj[childDa.title]) {
......@@ -214,18 +254,18 @@ class ProductRightStyle extends Component {
// }
// if(superTip){
// rsdItem.lineTip = superTip
// rsdItem[DEFAULT_FIELD] += 1
// rsdItem[QUANTITY_FIELD] += 1
// }
// that.handleCalCallBack(rsdItem, rsdIndex, 'rightSecondData', DEFAULT_FIELD)
// that.handleCalCallBack(rsdItem, rsdIndex, 'rightSecondData', QUANTITY_FIELD)
// }
// })
} else {
rightSecondData.forEach(function (rsdItem, rsdIndex) {
if (!rsdItem[CHILD_DATA_NAME]) {
rsdItem[CHILD_DATA_NAME] = []
if (!rsdItem[CHILDREN_LINE_NAME]) {
rsdItem[CHILDREN_LINE_NAME] = []
}
if (!rsdItem[DEFAULT_FIELD]) {
rsdItem[DEFAULT_FIELD] = 0
if (!rsdItem[QUANTITY_FIELD]) {
rsdItem[QUANTITY_FIELD] = 0
}
if (rsdIndex === index && leftIndex === 0) {
let superTip = ''
......@@ -245,7 +285,7 @@ class ProductRightStyle extends Component {
superTip: superTip,
version: 0,
lineOptions: childData,
[DEFAULT_FIELD]: 1
[QUANTITY_FIELD]: 1
}
// let curObj = {
// superId: rsdItem['id'], // 本地测试
......@@ -255,30 +295,30 @@ class ProductRightStyle extends Component {
// superTip: superTip, // 本地测试
// version: 0,
// lineOptions: childData,
// [DEFAULT_FIELD]: 1
// [QUANTITY_FIELD]: 1
// }
if (rsdItem[CHILD_DATA_NAME].length !== 0) {
curObj.version = rsdItem[CHILD_DATA_NAME].length
if (rsdItem[CHILDREN_LINE_NAME].length !== 0) {
curObj.version = rsdItem[CHILDREN_LINE_NAME].length
}
let filEquArr = rsdItem[CHILD_DATA_NAME].filter(function (lineItem) {
let filEquArr = rsdItem[CHILDREN_LINE_NAME].filter(function (lineItem) {
if (_.isEqual(lineItem.lineOptions, childData)) {
lineItem[DEFAULT_FIELD] += 1
lineItem[QUANTITY_FIELD] += 1
return lineItem
}
})
// 本地测试
if (filEquArr.length === 0) {
rsdItem[CHILD_DATA_NAME].push(curObj)
rsdItem[CHILDREN_LINE_NAME].push(curObj)
}
rsdItem[DEFAULT_FIELD] = Number(rsdItem[DEFAULT_FIELD]) + 1
rsdItem[QUANTITY_FIELD] = Number(rsdItem[QUANTITY_FIELD]) + 1
// console.log('回调后的rsdItem====', rsdItem)
that.handleCalCallBack(rsdItem, rsdIndex, 'rightSecondData', DEFAULT_FIELD)
that.handleCalCallBack(rsdItem, rsdIndex, 'rightSecondData', QUANTITY_FIELD)
}
})
}
console.log('回调后的数组====', rightSecondData)
// console.log('回调后的数组====', rightSecondData)
this.setState({
rightSecondData
})
......@@ -287,32 +327,62 @@ class ProductRightStyle extends Component {
// 修改当前小类是否展示
changeThrShow(show, superItem, superIndex) {
let { curThridObj, rowSingleData } = this.state
let {leftIndex} = this.props
let that = this
// console.log('修改当前小类是否展示----', show, superItem, superIndex)
// console.log('修改当前小类是否展示----', rowSingleData)
// console.log('修改当前小类是否展示----', curThridObj)
// console.log('修改当前小类是否展示----', leftIndex)
// let localTestImageUrls = localMockData.localTestImageUrls // 本地测试数据
// let curRowData = cloneObject(localMockData.localSingleRowData) // 本地测试数据 此处应该要请求接口,获取小类数据
if (superItem) {
// 中类点击时
if (show && superItem) {
// 大类点击标题时
let curRowData = cloneObject(superItem['details'])
curThridObj = {
superItem: superItem,
superIndex: superIndex,
// image: localTestImageUrls,
title: superItem.category_name
}
// if (superItem[CHILD_DATA_NAME] && superItem[CHILD_DATA_NAME].length > 0 && superItem[CHILD_DATA_NAME][0].lineOptions) {
// curRowData = cloneObject(superItem[CHILD_DATA_NAME][0].lineOptions)
// if (superItem[CHILDREN_LINE_NAME] && superItem[CHILDREN_LINE_NAME].length > 0 && superItem[CHILDREN_LINE_NAME][0].lineOptions) {
// curRowData = cloneObject(superItem[CHILDREN_LINE_NAME][0].lineOptions)
// }
}
this.setState({
thridIsVisible: show,
curThridObj: curThridObj,
rowSingleData: superItem['details']
// rowSingleData: curRowData
})
if (!show) {
that.setState({
thridIsVisible: show,
curThridObj: curThridObj,
rowSingleData: curRowData
})
}else{
// 小类点击标题
if(curThridObj.superItem){
let curDa = curThridObj.superItem
let curInd = curThridObj.superIndex
curDa.details = cloneObject(rowSingleData)
curDa[QUANTITY_FIELD] = 0
curDa.details.forEach(itVal => {
if(itVal[QUANTITY_FIELD] > 0){
curDa[QUANTITY_FIELD] += itVal[QUANTITY_FIELD]
}
})
that.handleCalCallBack(curDa, curInd, 'rightSecondData', QUANTITY_FIELD)
that.setState({
thridIsVisible: show
})
}
// this.setState({
// thridIsVisible: show
// })
// 小类点击标题时,回调函数修改左侧数据
this.props.thirdCallBack(rowSingleData, curThridObj.superIndex)
// this.props.thirdCallBack(rowSingleData, curThridObj.superIndex)
}
}
......@@ -346,6 +416,7 @@ class ProductRightStyle extends Component {
let { leftIndex } = this.props
let curTitCallBack = '', curPlusCallBack = '', curReduceCallBack = ''
let curTit='', curTipOne='', curTipTwo='', curTipOneTit='', curTipTwoTit='', curIcon=''
let curListMaxNum = ''
if(leftIndex === 0){
curTit = 'template_name'
curTipOne = 'surgery_type_name'
......@@ -378,6 +449,8 @@ class ProductRightStyle extends Component {
curTitCallBack = ((item, index) => this.TitleClickEvent(item, index))
curPlusCallBack = ''
curReduceCallBack = ''
curListMaxNum = 1
// if(item['childQuantity'] > 0) {
// 有数量时,需要点击进入选择
// curTitCallBack=((item,index) => this.TitleClickEvent(item,index))
......@@ -399,8 +472,8 @@ class ProductRightStyle extends Component {
<PicTitDetaiCalcu
listItem={item}
listIndex={index}
calField={DEFAULT_FIELD}
subCalCallBack={(item, index) => this.handleCalCallBack(item, index, 'rightSecondData', DEFAULT_FIELD)}
calField={QUANTITY_FIELD}
subCalCallBack={(item, index) => this.handleCalCallBack(item, index, 'rightSecondData', QUANTITY_FIELD)}
titCallBack={curTitCallBack}
titText={curTit}
tipTextOne={curTipOne}
......@@ -411,6 +484,7 @@ class ProductRightStyle extends Component {
listPicType={'SQUARE'}
plusCallBack={curPlusCallBack}
reduceCallBack={curReduceCallBack}
listMaxNum ={curListMaxNum}
/>
</SafeAreaView>
)
......@@ -438,12 +512,14 @@ class ProductRightStyle extends Component {
<PicTitDetaiCalcu
listItem={item}
listIndex={index}
calField={DEFAULT_FIELD}
calField={QUANTITY_FIELD}
subCalCallBack={(item, index) => this.handleCalCallBack(item, index, 'rowSingleData')}
titText={'title'}
tipTextOne={'tip1'}
tipTextTwo={'tip2'}
listImgIcon={'imgIconArr'}
titText={'general_name'}
tipTextOne={'item_name'}
tipTextTwo={'item_code'}
tipTextOneTit={'物料名称'}
tipTextTwoTit={'物料代码'}
listImgIcon={'photos'}
/>
</SafeAreaView>
)
......@@ -467,20 +543,42 @@ class ProductRightStyle extends Component {
// 单选耗材 -- 大类每一列
renderOtherListItem(item, index) {
let curTit= '',curTipOne='', curTipTwo='', curTipOneTit='', curTipTwoTit='', curIcon=''
let curSubCalCallBack= '',curTitCallBack='',curPlusCallBack='', curReduceCallBack=''
if(item[ONLY_TWO_LEVELS]){
// 两级
curTit= 'general_name'
curTipOne='item_code'
curTipOneTit='物料代码'
curIcon= 'photos'
}else {
// 三级
curTit= 'category_name'
curTipOne='category_code'
curTipOneTit='分类编码'
// curSubCalCallBack= ''
curTitCallBack=(item, index) => this.TitleClickEvent(item, index)
curPlusCallBack=(item, index) => this.handleAllPlusReduce(item, index, true)
curReduceCallBack=(item, index) => this.handleAllPlusReduce(item, index)
}
// console.log('大类===', item)
return (
<SafeAreaView style={styles.oth_container}>
<PicTitDetaiCalcu
listItem={item}
listIndex={index}
calField={DEFAULT_FIELD}
calField={QUANTITY_FIELD}
listImgIcon={curIcon}
listPicType={'ROUND'}
subCalCallBack={(item, index) => this.handleCalCallBack(item, index, 'rightSecondData', DEFAULT_FIELD)}
titCallBack={(item, index) => this.TitleClickEvent(item, index)}
titText={'category_name'}
tipTextOne={'category_code'}
tipTextOneTit={'分类编码'}
plusCallBack={(item, index) => this.handleAllPlusReduce(item, index, true)}
reduceCallBack={(item, index) => this.handleAllPlusReduce(item, index)}
subCalCallBack={(item, index) => this.handleCalCallBack(item, index, 'rightSecondData', QUANTITY_FIELD)}
titCallBack={curTitCallBack}
titText={curTit}
tipTextOne={curTipOne}
tipTextOneTit={curTipOneTit}
plusCallBack={curPlusCallBack}
reduceCallBack={curReduceCallBack}
/>
</SafeAreaView>
)
......
......@@ -7,14 +7,16 @@ import {
SELF_SUBMIT_DOING,
SELF_SUBMIT_SUCCESS,
SELF_SUBMIT_FAILURE,
SELF_INIT_DATA
SELF_INIT_DATA,
SET_SELECT_PRODUCT_OPTS
} from '../../base/ActionTypes';
// 自助下单状态
const defaultState = {
self_list_status: SELF_ORDER_LIST_NO, // 获取数据状态
submit_self_order_status: SELF_SUBMIT_NO, // 提交订单状态
selfOrderOption: {} // 当前临时存储数据
selfOrderOption: {}, // 当前临时存储数据
local_sele_pro_options: {}, // 选择产品临时存储
}
export default selfOrder = (state = defaultState, action) => {
......@@ -39,7 +41,8 @@ export default selfOrder = (state = defaultState, action) => {
case SELF_SUBMIT_SUCCESS:
return Object.assign({}, state, {
submit_self_order_status: SELF_SUBMIT_SUCCESS,
selfOrderOption: {} // 清空当前临时数据
selfOrderOption: {}, // 清空当前临时数据
local_sele_pro_options: {}
})
case SELF_SUBMIT_FAILURE:
return Object.assign({}, state, {
......@@ -50,7 +53,12 @@ export default selfOrder = (state = defaultState, action) => {
// 初始化数据
self_list_status: SELF_ORDER_LIST_NO,
submit_self_order_status: SELF_SUBMIT_NO,
selfOrderOption: {}
selfOrderOption: {},
local_sele_pro_options: {}
})
case SET_SELECT_PRODUCT_OPTS:
return Object.assign({}, state, {
local_sele_pro_options: action.rawData
})
default:
return state;
......
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