Commit cb8feca4 by Denglingling

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

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