Commit 4b2389b1 by lhc Committed by peii

feat: 增加全局搜索

(cherry picked from commit e09dbcef)
parent ae71f4e4
import React, {Component} from 'react';
import {
Easing,
Animated
} from 'react-native';
import { createStackNavigator, createAppContainer} from 'react-navigation';
import LoginPage from './containers/login/LoginPage';
import HomePage from './containers/home/HomePage';
import SelfOrderPage from './containers/selfOrder/SelfOrderPage';
import ChooseProductPage from './containers/selfOrder/module/ChooseProductPage';
import EditThirdLevelPage from './containers/selfOrder/module/EditThirdLevelPage';
import EquipConsuPage from './containers/equipConsu/EquipConsuPage';
import ConsumDetailsPage from './containers/equipConsu/module/ConsumDetailsPage';
import ChargeDetailsPage from './containers/equipConsu/module/ChargeDetailsPageRef';
import FillUnitPricePage from './containers/equipConsu/module/FillUnitPricePage';
import OrdersPage from './containers/equipConsu/module/OrdersPage';
import ShowDetailPage from './containers/equipConsu/module/ShowDetailPage';
import QuickOrderPage from './containers/quickOrder/QuickOrderPage';
import surgeryTemplatePage from './containers/quickOrder/module/surgeryTemplatePage';
import surgeryDetailsPage from './containers/quickOrder/module/surgeryDetailsPage';
import TransOrderPage from './containers/transOrder/TransOrderPage';
import DeviceInfoPage from './containers/deviceInfo/DeviceInfoPage';
import TransSearchPage from './containers/transOrder/module/TransSearchPage';
import HistoricalOrderPage from './containers/historicalOrder/HistoricalOrderPage';
import LineOrderPage from './containers/historicalOrder/module/LineOrderPage';
import SubSuccPage from './containers/common/SubSuccPage';
import BarCodePage from './containers/common/BarCodePage';
import React, { Component } from 'react'
import { Easing, Animated } from 'react-native'
import { createStackNavigator, createAppContainer } from 'react-navigation'
import LoginPage from './containers/login/LoginPage'
import HomePage from './containers/home/HomePage'
import SelfOrderPage from './containers/selfOrder/SelfOrderPage'
import ChooseProductPage from './containers/selfOrder/module/ChooseProductPage'
import SearchPage from './containers/selfOrder/module/SearchPage'
import EditThirdLevelPage from './containers/selfOrder/module/EditThirdLevelPage'
import EquipConsuPage from './containers/equipConsu/EquipConsuPage'
import ConsumDetailsPage from './containers/equipConsu/module/ConsumDetailsPage'
import ChargeDetailsPage from './containers/equipConsu/module/ChargeDetailsPageRef'
import FillUnitPricePage from './containers/equipConsu/module/FillUnitPricePage'
import OrdersPage from './containers/equipConsu/module/OrdersPage'
import ShowDetailPage from './containers/equipConsu/module/ShowDetailPage'
import QuickOrderPage from './containers/quickOrder/QuickOrderPage'
import surgeryTemplatePage from './containers/quickOrder/module/surgeryTemplatePage'
import surgeryDetailsPage from './containers/quickOrder/module/surgeryDetailsPage'
import TransOrderPage from './containers/transOrder/TransOrderPage'
import DeviceInfoPage from './containers/deviceInfo/DeviceInfoPage'
import TransSearchPage from './containers/transOrder/module/TransSearchPage'
import HistoricalOrderPage from './containers/historicalOrder/HistoricalOrderPage'
import LineOrderPage from './containers/historicalOrder/module/LineOrderPage'
import SubSuccPage from './containers/common/SubSuccPage'
import BarCodePage from './containers/common/BarCodePage'
// 结算
import Settlement from '../src/pages/settlement/index';
import SettlementCollection from '../src/pages/settlement/collection';
import SettlementDetail from '../src/pages/settlement/detail';
import SettlementSaleDetail from '../src/pages/settlement/saleDetail';
import SettlementReject from '../src/pages/settlement/reject';
import Settlement from '../src/pages/settlement/index'
import SettlementCollection from '../src/pages/settlement/collection'
import SettlementDetail from '../src/pages/settlement/detail'
import SettlementSaleDetail from '../src/pages/settlement/saleDetail'
import SettlementReject from '../src/pages/settlement/reject'
// 分销开票
import DistributeInvoice from '../src/pages/invoice/distribution';
import DistributeInvoiceApplyDetail from '../src/pages/invoice/distribution/detail';
import DistributeInvoiceCollections from '../src/pages/invoice/distribution/collection';
import DistributeInvoiceCollectionDetail from '../src/pages/invoice/distribution/collection_detail';
import DistributeInvoice from '../src/pages/invoice/distribution'
import DistributeInvoiceApplyDetail from '../src/pages/invoice/distribution/detail'
import DistributeInvoiceCollections from '../src/pages/invoice/distribution/collection'
import DistributeInvoiceCollectionDetail from '../src/pages/invoice/distribution/collection_detail'
// 直销开票
import DirectionInvoice from '../src/pages/invoice/direct';
import DirectionInvoiceCollections from '../src/pages/invoice/direct/collections';
import DirectionInvoiceApplyDetail from '../src/pages/invoice/direct/detail';
import DirectionInvoice from '../src/pages/invoice/direct'
import DirectionInvoiceCollections from '../src/pages/invoice/direct/collections'
import DirectionInvoiceApplyDetail from '../src/pages/invoice/direct/detail'
const Router = createAppContainer(createStackNavigator({
const Router = createAppContainer(
createStackNavigator(
{
LoginPage: { screen: LoginPage },
HomePage: {screen: HomePage},
SelfOrderPage: {screen: SelfOrderPage},
ChooseProductPage: {screen: ChooseProductPage},
EditThirdLevelPage: {screen: EditThirdLevelPage},
EquipConsuPage: {screen: EquipConsuPage},
ConsumDetailsPage: {screen: ConsumDetailsPage},
ChargeDetailsPage: {screen: ChargeDetailsPage},
FillUnitPricePage: {screen: FillUnitPricePage},
OrdersPage: {screen: OrdersPage},
ShowDetailPage: {screen: ShowDetailPage},
QuickOrderPage: {screen: QuickOrderPage},
surgeryTemplatePage: {screen: surgeryTemplatePage},
surgeryDetailsPage: {screen: surgeryDetailsPage},
TransOrderPage: {screen: TransOrderPage},
DeviceInfoPage: {screen: DeviceInfoPage},
TransSearchPage: {screen: TransSearchPage},
HistoricalOrderPage: {screen: HistoricalOrderPage},
LineOrderPage: {screen: LineOrderPage},
SubSuccPage: {screen: SubSuccPage},
BarCodePage: {screen: BarCodePage},
Settlement: {screen: Settlement},
SettlementCollection: {screen: SettlementCollection},
SettlementReject: {screen: SettlementReject},
SettlementDetail: {screen: SettlementDetail},
SettlementSaleDetail: {screen: SettlementSaleDetail},
DistributeInvoice: {screen: DistributeInvoice},
DistributeInvoiceApplyDetail: {screen: DistributeInvoiceApplyDetail},
DistributeInvoiceCollections: {screen: DistributeInvoiceCollections},
DistributeInvoiceCollectionDetail: {screen: DistributeInvoiceCollectionDetail},
DirectionInvoice: {screen: DirectionInvoice},
DirectionInvoiceCollections: {screen: DirectionInvoiceCollections},
DirectionInvoiceApplyDetail: {screen: DirectionInvoiceApplyDetail},
}, {
HomePage: { screen: HomePage },
SelfOrderPage: { screen: SelfOrderPage },
ChooseProductPage: { screen: ChooseProductPage },
SearchPage: { screen: SearchPage },
EditThirdLevelPage: { screen: EditThirdLevelPage },
EquipConsuPage: { screen: EquipConsuPage },
ConsumDetailsPage: { screen: ConsumDetailsPage },
ChargeDetailsPage: { screen: ChargeDetailsPage },
FillUnitPricePage: { screen: FillUnitPricePage },
OrdersPage: { screen: OrdersPage },
ShowDetailPage: { screen: ShowDetailPage },
QuickOrderPage: { screen: QuickOrderPage },
surgeryTemplatePage: { screen: surgeryTemplatePage },
surgeryDetailsPage: { screen: surgeryDetailsPage },
TransOrderPage: { screen: TransOrderPage },
DeviceInfoPage: { screen: DeviceInfoPage },
TransSearchPage: { screen: TransSearchPage },
HistoricalOrderPage: { screen: HistoricalOrderPage },
LineOrderPage: { screen: LineOrderPage },
SubSuccPage: { screen: SubSuccPage },
BarCodePage: { screen: BarCodePage },
Settlement: { screen: Settlement },
SettlementCollection: { screen: SettlementCollection },
SettlementReject: { screen: SettlementReject },
SettlementDetail: { screen: SettlementDetail },
SettlementSaleDetail: { screen: SettlementSaleDetail },
DistributeInvoice: { screen: DistributeInvoice },
DistributeInvoiceApplyDetail: { screen: DistributeInvoiceApplyDetail },
DistributeInvoiceCollections: { screen: DistributeInvoiceCollections },
DistributeInvoiceCollectionDetail: { screen: DistributeInvoiceCollectionDetail },
DirectionInvoice: { screen: DirectionInvoice },
DirectionInvoiceCollections: { screen: DirectionInvoiceCollections },
DirectionInvoiceApplyDetail: { screen: DirectionInvoiceApplyDetail },
},
{
navigationOptions: {
gesturesEnabled: true
gesturesEnabled: true,
},
headerMode: 'none',
transitionConfig: () => ({
transitionSpec: {
duration: 300,
easing: Easing.out(Easing.poly(4)),
timing: Animated.timing
timing: Animated.timing,
},
screenInterpolator: sceneProps => {
const {layout, position, scene} = sceneProps;
const {index} = scene;
const Width = layout.initWidth;
const { layout, position, scene } = sceneProps
const { index } = scene
const Width = layout.initWidth
//沿X轴平移
const translateX = position.interpolate({
inputRange: [index - 1, index, index + 1],
outputRange: [Width, 0, -(Width - 10)],
});
})
//透明度
const opacity = position.interpolate({
inputRange: [index - 1, index - 0.99, index],
outputRange: [0, 1, 1]
});
return {opacity, transform: [{translateX}]};
}
outputRange: [0, 1, 1],
})
}))
return { opacity, transform: [{ translateX }] }
},
}),
},
),
)
// const defaultGetStateForAction = Router.router.getStateForAction;
// Router.router.getStateForAction = ((action, state) => {
......
import { PostRequest, GetRequest, UploadRequest } from '../network/RequestUtils';
import { show, getUrlParams, showWarnErrorMessage, showErrorMessage, dedupQuoteArray } from '../utils/Utils';
import { exitLoginStatus } from './LoginAction';
import { PostRequest, GetRequest, UploadRequest } from '../network/RequestUtils'
import { show, getUrlParams, showWarnErrorMessage, showErrorMessage, dedupQuoteArray } from '../utils/Utils'
import { exitLoginStatus } from './LoginAction'
import {
SELF_ORDER_LIST_DOING,
SELF_ORDER_LIST_SUCCESS,
......@@ -10,23 +10,25 @@ import {
SELF_SUBMIT_FAILURE,
SELF_INIT_DATA,
SET_SELECT_PRODUCT_OPTS,
SET_LEND_ORDER_VALUES
} from '../base/ActionTypes';
SET_LEND_ORDER_VALUES,
} from '../base/ActionTypes'
import local_inter_mock from '../containers/selfOrder/module/mock/inter_mock'
import * as R from 'ramda'
// 获取组织 params={access_token:''}
export function requestSelfOrganizations(params) {
return (dispatch, getState) => {
dispatch(requestListDataing());
let {global_domain_config} = getState().login
dispatch(requestListDataing())
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/authorized_inventory/search', params))
.then(res => {
console.log('获取组织 res=====', res);
if(res.error_code == 0) {
let { data: { organizations } } = res
dispatch(requestListDataSuccess(organizations));
}else {
console.log('获取组织 res=====', res)
if (res.error_code == 0) {
let {
data: { organizations },
} = res
dispatch(requestListDataSuccess(organizations))
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
......@@ -49,17 +51,17 @@ export function requestSelfOrganizations(params) {
// 获取未定单据借货设置 params={access_token:'', org_code:'', customer_code: '', bill_to_site_code: '', ship_to_site_code: '', process_code: ''}
export function requestQuickSurColSetting(params) {
return (dispatch, getState) => {
dispatch(requestListDataing());
let {global_domain_config} = getState().login
dispatch(requestListDataing())
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/surgery/collect_setting/search', params))
.then(res => {
console.log('获取未定单据借货设置 res=====', res);
if(res.error_code == 0) {
console.log('获取未定单据借货设置 res=====', res)
if (res.error_code == 0) {
let { data } = res
let filterOpt = dedupQuoteArray(data, 'source_inv_code')
dispatch(requestListDataSuccess(filterOpt));
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail);
dispatch(requestListDataSuccess(filterOpt))
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
......@@ -77,7 +79,7 @@ export function requestQuickSurColSetting(params) {
// console.log('------err-====获取未定单据借货设置----', Object.keys(err), err)
// show(err.error);
// dispatch(requestListDataFail());
showErrorMessage(dispatch, err, requestListDataFail, '获取未定单据借货设置');
showErrorMessage(dispatch, err, requestListDataFail, '获取未定单据借货设置')
})
}
}
......@@ -90,19 +92,20 @@ export const reqOrgDepartments = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/sale/sale_relationship/search', params))
}
// 获取客户名称 params={access_token:'', org_code:'', seller_code:''}
export function requestSelfSurgeryHospital(params) {
return (dispatch, getState) => {
dispatch(requestListDataing());
let {global_domain_config} = getState().login
dispatch(requestListDataing())
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/sale/seller_customer/search', params))
.then(res => {
console.log('获取客户名称 res=====', res);
if(res.error_code == 0) {
let { data: { customers } } = res
dispatch(requestListDataSuccess(customers));
}else {
console.log('获取客户名称 res=====', res)
if (res.error_code == 0) {
let {
data: { customers },
} = res
dispatch(requestListDataSuccess(customers))
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
......@@ -130,31 +133,33 @@ export const reqSelfSurgeryHospital = async (global_domain_config, params) => {
// 获取订单类型 params={access_token:'', value_set_code:'SUR_ORDER_TYPE'}
export function requestSelfOrderType(params, url) {
return (dispatch, getState) => {
dispatch(requestListDataing());
let {global_domain_config} = getState().login
dispatch(requestListDataing())
let { global_domain_config } = getState().login
// GetRequest(global_domain_config, getUrlParams('/system/value_set/search', params))
if (!url) {
url = '/system/order_type/search'
}
GetRequest(global_domain_config, getUrlParams(url, params))
.then(res => {
console.log('获取订单类型 res=====', res);
console.log('获取订单类型 res=====', res)
// 兼容老的接口,有的环境没有实现获取订单类型接口
if (res.status === 404) {
return dispatch(requestSelfOrderType(params, '/system/value_set/search'))
}
if(res.error_code == 0) {
if (res.error_code == 0) {
let data = []
if (R.includes('order_type', url)) {
data = R.map(R.applySpec({
data = R.map(
R.applySpec({
value_name: R.prop('order_type_name'),
value_code: R.prop('order_type_code'),
}))(res.data)
}),
)(res.data)
} else {
data = res.data.sys_values
}
dispatch(requestListDataSuccess(data));
}else {
dispatch(requestListDataSuccess(data))
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
})
......@@ -171,15 +176,17 @@ export function requestSelfOrderType(params, url) {
// 获取配台模板 params={access_token:'', org_code:'', seller_code: 'shi.ming', customer_code: '', surgery_type: '', doctor_name: ''}
export function requestSelfTemplateCollect(params) {
return (dispatch, getState) => {
dispatch(requestListDataing());
let {global_domain_config} = getState().login
dispatch(requestListDataing())
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/surgery/template_header/search', params))
.then(res => {
console.log('获取配台模板 res=====', res);
if(res.error_code == 0) {
let { data: { surgery_template_headers } } = res
dispatch(requestListDataSuccess(surgery_template_headers));
}else {
console.log('获取配台模板 res=====', res)
if (res.error_code == 0) {
let {
data: { surgery_template_headers },
} = res
dispatch(requestListDataSuccess(surgery_template_headers))
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
......@@ -203,19 +210,21 @@ export function requestSelfTemplateCollect(params) {
// 获取手术类型 params={access_token:'', value_set_code:'ORTHOPEDICS_PRODUCT_CLASS'}
export function requestSelfSurgeryType(params) {
return (dispatch, getState) => {
dispatch(requestListDataing());
let {global_domain_config} = getState().login
dispatch(requestListDataing())
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/system/value_set/search', params))
.then(res => {
console.log('获取手术类型 res=====', res);
if(res.error_code == 0) {
console.log('获取手术类型 res=====', res)
if (res.error_code == 0) {
let typeOption = []
let { data: { value_set_code, sys_values } } = res
if(value_set_code === 'ORTHOPEDICS_PRODUCT_CLASS' && sys_values && sys_values.length) {
let {
data: { value_set_code, sys_values },
} = res
if (value_set_code === 'ORTHOPEDICS_PRODUCT_CLASS' && sys_values && sys_values.length) {
typeOption = sys_values
}
dispatch(requestListDataSuccess(typeOption));
}else {
dispatch(requestListDataSuccess(typeOption))
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
......@@ -238,48 +247,51 @@ export function requestSelfSurgeryType(params) {
function requestListDataing() {
return {
type: SELF_ORDER_LIST_DOING
type: SELF_ORDER_LIST_DOING,
}
}
export function requestListDataSuccess(data) {
return {
type: SELF_ORDER_LIST_SUCCESS,
rawData: data
rawData: data,
}
}
function requestListDataFail() {
return {
type: SELF_ORDER_LIST_FAILURE
type: SELF_ORDER_LIST_FAILURE,
}
}
// 上传语音
export const requestSelfAudio = async (global_domain_config, params) => {
let { access_token, path } = params
let formData = new FormData()
let soundPath = `file://${path}`
let fileName = path.substring(path.lastIndexOf('/') + 1, path.length)
let file = { uri: soundPath, type: "multipart/form-data", name: fileName}
let file = { uri: soundPath, type: 'multipart/form-data', name: fileName }
formData.append('file', file)
return await UploadRequest(global_domain_config, getUrlParams('/dingding/upload_media', { access_token }), formData)
}
// 提交数据
export function requestSelfSumbit({access_token, ...params}) {
export function requestSelfSumbit({ access_token, ...params }) {
return (dispatch, getState) => {
dispatch(requestSubmiting());
let {global_domain_config} = getState().login
PostRequest(global_domain_config, getUrlParams('/surgery/collect_order/via_data/create', {access_token: access_token}), params)
dispatch(requestSubmiting())
let { global_domain_config } = getState().login
PostRequest(
global_domain_config,
getUrlParams('/surgery/collect_order/via_data/create', { access_token: access_token }),
params,
)
// PostRequest(global_domain_config, getUrlParams('/order/sur_requirement/create', {access_token: access_token}), params)
.then(res => {
console.log('提交数据 res=====', res);
if(res.error_code == 0) {
console.log('提交数据 res=====', res)
if (res.error_code == 0) {
let { data } = res
dispatch(requestSubmitSuccess(data));
}else {
dispatch(requestSubmitSuccess(data))
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestSubmitFail)
}
// else if(res.error_code === 41006) {
......@@ -334,14 +346,12 @@ export const reqNailEquipHeadSearch = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/inventory/item_package_header/search', params))
}
// 选择产品-螺钉盒明细查询接口
export const reqNailBoxLineSearch = async (global_domain_config, params) => {
// return local_inter_mock.inter_6
return await GetRequest(global_domain_config, getUrlParams('/inventory/nail_box_template_detail/search', params))
}
// 选择产品-器械包明细查询接口
export const reqEquipPackageLineSearch = async (global_domain_config, params) => {
// return local_inter_mock.inter_7
......@@ -364,7 +374,6 @@ export const reqScatEquipmentSearch = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/order/tool/search', params))
}
// 选择产品-单点耗材查询接口
export const reqSingleConsumSearch = async (global_domain_config, params) => {
// if(params.leftIndex && params.leftIndex%2 === 0){
......@@ -375,29 +384,33 @@ export const reqSingleConsumSearch = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/order/item_detail/search', params))
}
export const reqGlobalSearch = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/order/item/global_search', params))
}
function requestSubmiting() {
return {
type: SELF_SUBMIT_DOING
type: SELF_SUBMIT_DOING,
}
}
function requestSubmitSuccess(data) {
return {
type: SELF_SUBMIT_SUCCESS,
rawData: data
rawData: data,
}
}
function requestSubmitFail() {
return {
type: SELF_SUBMIT_FAILURE
type: SELF_SUBMIT_FAILURE,
}
}
// 初始化数据
export function setSelfInitData() {
return {
type: SELF_INIT_DATA
type: SELF_INIT_DATA,
}
}
......@@ -405,7 +418,7 @@ export function setSelfInitData() {
export function setSelectProductOpts(data) {
return {
type: SET_SELECT_PRODUCT_OPTS,
rawData: data
rawData: data,
}
}
......@@ -425,10 +438,10 @@ export async function requestSurgeryType(global_domain_config, params) {
*/
export function getLendOrderCodeValues() {
return (dispatch, getState) => {
let {global_domain_config, token} = getState().login
let { global_domain_config, token } = getState().login
const params = {
access_token: token,
value_set_code: 'OBS_MOBILE_LEND_ORDER'
value_set_code: 'OBS_MOBILE_LEND_ORDER',
}
GetRequest(global_domain_config, getUrlParams('/system/value_set/search', params)).then(res => {
const values = R.pathOr([], ['data', 'sys_values'])(res)
......@@ -440,6 +453,6 @@ export function getLendOrderCodeValues() {
export function setLendOrderCodeValues(values) {
return {
type: SET_LEND_ORDER_VALUES,
values
values,
}
}
import React, { Component } from 'react';
import { StyleSheet, Image, Text, TouchableOpacity, View } from 'react-native';
import { connect } from 'react-redux';
import { first_text_color, font_family_medium, font_family_regular, font_family_semibold, home_background_color, icon_style, pxSize, second_text_size, third_text_color, third_text_size, list_tit_color, list_str_color, list_one_color, list_thr_color, list_one_light_color } from '../../../base/BaseStyle';
import PictureZoom from '../../common/listDataComponent/PictureZoom';
import LocalVariable from '../LocalVariable';
const PropTypes = require('prop-types');
import React, { Component } from 'react'
import { StyleSheet, Image, Text, TouchableOpacity, View } from 'react-native'
import { connect } from 'react-redux'
import {
first_text_color,
font_family_medium,
font_family_regular,
font_family_semibold,
home_background_color,
icon_style,
pxSize,
second_text_size,
third_text_color,
third_text_size,
list_tit_color,
list_str_color,
list_one_color,
list_thr_color,
list_one_light_color,
} from '../../../base/BaseStyle'
import PictureZoom from '../../common/listDataComponent/PictureZoom'
import LocalVariable from '../LocalVariable'
const PropTypes = require('prop-types')
/**
* 列表组件,图片-标题(提示)-计算/关闭
*/
class PicTitDetaiCalcu extends Component {
static propTypres = {
listItem: PropTypes.object,
listIndex: PropTypes.number,
......@@ -48,12 +63,12 @@ class PicTitDetaiCalcu extends Component {
}
constructor(props) {
super(props);
super(props)
this.state = {
listPicTypeArr: ['ROUND', 'SQUARE', 'RECTANGLE'],
picStyleArr: ['round_pic', 'square_pic', 'rectan_pic'],
showOtherFlag: true,
showOtherTitle: '点击隐藏具体详情'
showOtherTitle: '点击隐藏具体详情',
}
}
......@@ -92,20 +107,49 @@ class PicTitDetaiCalcu extends Component {
}
// 具体详情
showAllTip(){
let {showOtherFlag} = this.state
showAllTip() {
let { showOtherFlag } = this.state
let curShowOtherTitle = showOtherFlag ? '点击查看具体详情' : '点击隐藏具体详情'
this.setState({
showOtherFlag: !showOtherFlag,
showOtherTitle: curShowOtherTitle
showOtherTitle: curShowOtherTitle,
})
}
render() {
let { listItem, listIndex, calField, listStyleBox, listStyleTit, listStyleTip, listStyleCalBtn, listPicType, titCallBack,
titText, tipTextStr, tipTextOne, tipTextTwo, tipTextThr, listImgIcon, listStyleImg, showClearIcon, showClearIndex, listCardActIndex,
listStyleClearBtn, clearCallBack, onlyShowNum, onlyShowSelect, titTextTit, tipTextStrTit, tipTextOneTit, tipTextTwoTit, tipTextThrTit,
global_domain_config, listMaxNum, listShowOthOptFlag } = this.props
let {
listItem,
listIndex,
calField,
listStyleBox,
listStyleTit,
listStyleTip,
listStyleCalBtn,
listPicType,
titCallBack,
titText,
tipTextStr,
tipTextOne,
tipTextTwo,
tipTextThr,
listImgIcon,
listStyleImg,
showClearIcon,
showClearIndex,
listCardActIndex,
listStyleClearBtn,
clearCallBack,
onlyShowNum,
onlyShowSelect,
titTextTit,
tipTextStrTit,
tipTextOneTit,
tipTextTwoTit,
tipTextThrTit,
global_domain_config,
listMaxNum,
listShowOthOptFlag,
} = this.props
let { listPicTypeArr, picStyleArr, showOtherFlag, showOtherTitle } = this.state
let picOthStyle = ''
......@@ -127,71 +171,87 @@ class PicTitDetaiCalcu extends Component {
}
let cur_photos = []
if (listItem[listImgIcon] instanceof Array) {
listItem[listImgIcon].map((iconIt) => {
listItem[listImgIcon].map(iconIt => {
cur_photos.push({ url: global_domain_config + '/jeecg-boot/sys/common/view/' + iconIt })
})
if(listItem[listImgIcon].length === 0){
cur_photos[0] = (require('../../../images/not_img.png'))
if (listItem[listImgIcon].length === 0) {
cur_photos[0] = require('../../../images/not_img.png')
}
}else if(typeof listItem[listImgIcon] === 'string'){
} else if (typeof listItem[listImgIcon] === 'string') {
cur_photos[0] = { url: global_domain_config + '/jeecg-boot/sys/common/view/' + listItem[listImgIcon] }
}
return (
<View style={[styles.ri_inner, listStyleBox]}>
{(listImgIcon && cur_photos.length > 0) ?
{listImgIcon && cur_photos.length > 0 ? (
<PictureZoom
listImageIndex={0}
listImageUrls={cur_photos}
listStyleImage={[styles.oth_img_box, styles[picOthStyle], listStyleImg]}
listPicType={listPicType}
/>
: null}
) : null}
<View style={styles.ri_text_box}>
<TouchableOpacity
activeOpacity={titCallBack ? .8 : 1}
onPress={() => { titCallBack ? titCallBack(listItem, listIndex) : {} }}
activeOpacity={titCallBack ? 0.8 : 1}
onPress={() => {
titCallBack ? titCallBack(listItem, listIndex) : {}
}}
style={styles.oth_box}
>
<Text numberOfLines={3} style={[styles.thr_ot, listStyleTit]}>
{listItem[titText] ? `${listIndex+1}. ${listItem[titText]}` : '' }
{!listItem[titText] && titTextTit ? `${listIndex+1}. ${titTextTit}: 无` : ''}
{listItem[titText] ? `${listIndex + 1}. ${listItem[titText]}` : ''}
{!listItem[titText] && titTextTit ? `${listIndex + 1}. ${titTextTit}: 无` : ''}
</Text>
{tipTextStrTit ? <Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_str, listStyleTip]}>
{tipTextStrTit ? (
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_str, listStyleTip]}>
{`${tipTextStrTit}:`} {listItem[tipTextStr] ? listItem[tipTextStr] : '无'}
</Text> : null}
{tipTextOneTit ? <Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_one,listStyleTip]}>
</Text>
) : null}
{tipTextOneTit ? (
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_one, listStyleTip]}>
{`${tipTextOneTit}:`} {listItem[tipTextOne] ? listItem[tipTextOne] : '无'}
</Text> : null}
{tipTextTwoTit ? <Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_two,listStyleTip]}>
</Text>
) : null}
{tipTextTwoTit ? (
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_two, listStyleTip]}>
{`${tipTextTwoTit}:`} {listItem[tipTextTwo] ? listItem[tipTextTwo] : '无'}
</Text> : null}
{tipTextThrTit ? <Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_thr,listStyleTip]}>
</Text>
) : null}
{tipTextThrTit ? (
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_thr, listStyleTip]}>
{`${tipTextThrTit}:`} {listItem[tipTextThr] ? listItem[tipTextThr] : '无'}
</Text> : null}
{listShowOthOptFlag && listItem[LocalVariable.SUPER_SEL_ALL_ARR] ? <View>
<TouchableOpacity
activeOpacity={.8}
onPress={() => this.showAllTip()}
>
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_thr,listStyleTip]}>{showOtherTitle}</Text>
</Text>
) : null}
{listShowOthOptFlag && listItem[LocalVariable.SUPER_SEL_ALL_ARR] ? (
<View>
<TouchableOpacity activeOpacity={0.8} onPress={() => this.showAllTip()}>
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_thr, listStyleTip]}>
{showOtherTitle}
</Text>
</TouchableOpacity>
{
showOtherFlag ? listItem[LocalVariable.SUPER_SEL_ALL_ARR].map((item, item_index) => {
return <View>
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_one,listStyleTip]}>
{item_index+1}. {item.item_name} - <Text style={[styles.ri_te_ot, styles.te_ot_main,listStyleTip]}>{item.manufacturer_product_code} - {item.specification}</Text> - {item.general_name} x {item[LocalVariable.QUANTITY_FIELD]}
{showOtherFlag
? listItem[LocalVariable.SUPER_SEL_ALL_ARR].map((item, item_index) => {
return (
<View>
<Text numberOfLines={3} style={[styles.ri_te_ot, styles.te_ot_one, listStyleTip]}>
{item_index + 1}. {item.item_name} -{' '}
<Text style={[styles.ri_te_ot, styles.te_ot_main, listStyleTip]}>
{item.manufacturer_product_code} - {item.specification}
</Text>{' '}
- {item.general_name} x {item[LocalVariable.QUANTITY_FIELD]}
</Text>
</View>
}) : null
}
</View> : null}
)
})
: null}
</View>
) : null}
</TouchableOpacity>
</View>
{
(showClearIcon && listCardActIndex === showClearIndex) ?
{showClearIcon && listCardActIndex === showClearIndex ? (
<View style={styles.btn_cle_box}>
<TouchableOpacity
activeOpacity={.9}
activeOpacity={0.9}
style={[styles.btn_clear_inner, listStyleClearBtn]}
onPress={() => clearCallBack(listItem, listIndex)}
>
......@@ -199,47 +259,53 @@ class PicTitDetaiCalcu extends Component {
<Image source={require('../../../images/close_icon.png')} style={icon_style}></Image>
</View>
</TouchableOpacity>
</View> :
</View>
) : (
<View style={[styles.ri_num_box, onlyShowNum ? styles.show_num_box : null]}>
{(listItem[calField] !== 0 && !onlyShowNum && !onlyShowSelect) ?
{listItem[calField] && !onlyShowNum && !onlyShowSelect ? (
<TouchableOpacity
activeOpacity={.9}
activeOpacity={0.9}
style={[styles.btn_inner, listStyleCalBtn]}
onPress={() => this.handelCalculation(listItem, listIndex)}
>
<View style={[styles.thr_num_btn, styles.thr_btn_left]}>
<Image source={require('../../../images/less_icon_big.png')} style={icon_style}></Image>
</View>
</TouchableOpacity> : null}
{(listItem[calField] !== 0 && !onlyShowSelect) ? <Text style={[styles.thr_num, onlyShowNum ? styles.show_num : null]}>{listItem[calField]}</Text> : null}
{(!onlyShowNum && !onlyShowSelect && showPlusIcon) ? <TouchableOpacity
activeOpacity={.9}
</TouchableOpacity>
) : null}
{listItem[calField] && !onlyShowSelect ? (
<Text style={[styles.thr_num, onlyShowNum ? styles.show_num : null]}>{listItem[calField]}</Text>
) : null}
{!onlyShowNum && !onlyShowSelect && showPlusIcon ? (
<TouchableOpacity
activeOpacity={0.9}
style={[styles.btn_inner, listStyleCalBtn]}
onPress={() => this.handelCalculation(listItem, listIndex, true)}
>
<View style={[styles.thr_num_btn, styles.thr_btn_right]}>
<Image source={calIcon} style={icon_style}></Image>
</View>
</TouchableOpacity> : null}
</TouchableOpacity>
) : null}
{onlyShowSelect ? <TouchableOpacity
activeOpacity={.9}
{onlyShowSelect ? (
<TouchableOpacity
activeOpacity={0.9}
style={[styles.btn_sel_inner]}
onPress={() => this.handelSelectCheck(listItem, listIndex)}
>
<View style={[styles.thr_sel_btn]}>
<Image source={defSelIcon} style={icon_style}></Image>
</View>
</TouchableOpacity> : null
}
</TouchableOpacity>
) : null}
</View>
}
)}
</View>
);
)
}
}
const styles = StyleSheet.create({
ri_inner: {
flexDirection: 'row',
......@@ -248,41 +314,41 @@ const styles = StyleSheet.create({
paddingTop: 16,
paddingBottom: 12,
borderBottomWidth: 1,
borderColor: 'rgba(241, 241, 241, 0.87)'
borderColor: 'rgba(241, 241, 241, 0.87)',
},
ri_text_box: {
flex: 1
flex: 1,
},
ri_te_ot: {
fontSize: third_text_size,
color: third_text_color,
fontFamily: font_family_regular,
paddingBottom: 2
paddingBottom: 2,
},
oth_box: {
paddingBottom: 2
paddingBottom: 2,
},
thr_ot: {
fontFamily: font_family_medium,
fontSize: second_text_size,
color: list_tit_color,
paddingBottom: 4
paddingBottom: 4,
},
te_ot_str: {
fontFamily: font_family_semibold,
color: list_str_color
color: list_str_color,
},
te_ot_one:{
color: list_one_color
te_ot_one: {
color: list_one_color,
},
te_ot_two:{
color: list_one_color
te_ot_two: {
color: list_one_color,
},
te_ot_thr:{
color: list_thr_color
te_ot_thr: {
color: list_thr_color,
},
te_ot_main: {
color: list_one_light_color
color: list_one_light_color,
},
oth_img_box: {
width: pxSize(58),
......@@ -290,11 +356,11 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignItems: 'center',
marginRight: 3,
padding: 3
padding: 3,
},
round_pic: {
borderColor: 'rgba(0, 0, 0, 0.12)',
borderWidth: .5,
borderWidth: 0.5,
borderRadius: 50,
},
square_pic: {},
......@@ -304,32 +370,32 @@ const styles = StyleSheet.create({
},
thr_num_btn: {
width: pxSize(24),
height: pxSize(30)
height: pxSize(30),
},
thr_sel_btn: {
width: pxSize(22),
height: pxSize(22)
height: pxSize(22),
},
btn_inner: {},
btn_sel_inner: {},
btn_cle_box: {
marginRight: 3,
paddingHorizontal: 4,
paddingVertical: 4
paddingVertical: 4,
},
btn_clear_inner: {},
icon_cle_btn: {
width: pxSize(22),
height: pxSize(22)
height: pxSize(22),
},
ri_num_box: {
flexDirection: 'row',
alignItems: 'center',
marginLeft: 3,
backgroundColor: home_background_color
backgroundColor: home_background_color,
},
show_num_box: {
backgroundColor: null
backgroundColor: null,
},
thr_btn_left: {},
thr_btn_right: {},
......@@ -338,20 +404,20 @@ const styles = StyleSheet.create({
textAlign: 'center',
fontFamily: font_family_regular,
fontSize: 14,
color: first_text_color
color: first_text_color,
},
show_num: {
fontSize: 18
}
fontSize: 18,
},
})
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
global_domain_config: state.login.global_domain_config
global_domain_config: state.login.global_domain_config,
}
}
const mapDispatchToProps = (dispatch) => {
const mapDispatchToProps = dispatch => {
return {
// exitLoginStatus: () => {
// dispatch(exitLoginStatus())
......@@ -359,4 +425,4 @@ const mapDispatchToProps = (dispatch) => {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(PicTitDetaiCalcu);
export default connect(mapStateToProps, mapDispatchToProps)(PicTitDetaiCalcu)
import React, { Component } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Image, TextInput, SafeAreaView } from 'react-native';
import { connect } from 'react-redux';
import debounce from 'debounce';
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, point_color } from '../../../base/BaseStyle';
import ChooseFilter from './ChooseFilter';
import HeadBackItem from '../../common/HeadBackItem';
import ProductRightStyle from './ProductRightStyle';
import ProductModel from '../../common/ProductModel';
import StatusBarView from '../../common/StatusBarView';
import ChooseCardList from '../../common/listDataComponent/ChooseCardList';
import { cloneObject, show, isNotBlank, isBlank } from '../../../utils/Utils';
import { reqPurSupplierSearch, reqProCategorySearch, reqSurTempHeadSearch, reqNailEquipHeadSearch, reqScatEquipmentSearch, reqSingleConsumSearch, setSelectProductOpts } from '../../../action/SelfAction';
import LoadingModel from '../../common/listDataComponent/LoadingModel';
import LocalVariable from '../../common/LocalVariable';
import { exitLoginStatus } from '../../../action/LoginAction';
import * as R from 'ramda';
import React, { Component } from 'react'
import { View, Text, StyleSheet, TouchableOpacity, Image, TextInput, SafeAreaView } from 'react-native'
import { connect } from 'react-redux'
import debounce from 'debounce'
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,
point_color,
} from '../../../base/BaseStyle'
import ChooseFilter from './ChooseFilter'
import HeadBackItem from '../../common/HeadBackItem'
import ProductRightStyle from './ProductRightStyle'
import ProductModel from '../../common/ProductModel'
import StatusBarView from '../../common/StatusBarView'
import ChooseCardList from '../../common/listDataComponent/ChooseCardList'
import { cloneObject, show, isNotBlank, isBlank } from '../../../utils/Utils'
import {
reqPurSupplierSearch,
reqProCategorySearch,
reqSurTempHeadSearch,
reqNailEquipHeadSearch,
reqScatEquipmentSearch,
reqSingleConsumSearch,
setSelectProductOpts,
} from '../../../action/SelfAction'
import LoadingModel from '../../common/listDataComponent/LoadingModel'
import LocalVariable from '../../common/LocalVariable'
import { exitLoginStatus } from '../../../action/LoginAction'
import * as R from 'ramda'
class ChooseProductPage extends Component {
constructor(props) {
super(props);
super(props)
this.state = {
searchValue: '',
topActiveIndex: 0,
......@@ -26,68 +48,83 @@ class ChooseProductPage extends Component {
leftActiveIndex: 0,
defaultThridShow: false, // 默认耗材-小类不显示
selectShowPopup: false, // 共计已选弹窗
defalutLeftItem: [{
"category_code": LocalVariable.SURGICAL_TEMPLATE,
"category_name": "手术套包",
"cate_local_icon": require('../../../images/surg_temp.png')
}, {
"category_code": LocalVariable.NAIL_BOX,
"category_name": "钉盒",
"cate_local_icon": require('../../../images/screw_box.png')
}, {
"category_code": LocalVariable.EQUIPMENT_BAG,
"category_name": "器械包",
"cate_local_icon": require('../../../images/equip_bag.png')
}, {
"category_code": LocalVariable.SCATTERED_EQUIPMENT,
"category_name": "零散器械",
"cate_local_icon": require('../../../images/auxili_tool.png')
}],
local_sel_options: [{
defalutLeftItem: [
{
category_code: LocalVariable.SURGICAL_TEMPLATE,
category_name: '手术套包',
cate_local_icon: require('../../../images/surg_temp.png'),
},
{
category_code: LocalVariable.NAIL_BOX,
category_name: '钉盒',
cate_local_icon: require('../../../images/screw_box.png'),
},
{
category_code: LocalVariable.EQUIPMENT_BAG,
category_name: '器械包',
cate_local_icon: require('../../../images/equip_bag.png'),
},
{
category_code: LocalVariable.SCATTERED_EQUIPMENT,
category_name: '零散器械',
cate_local_icon: require('../../../images/auxili_tool.png'),
},
],
local_sel_options: [
{
category_name: '手术套包',
category_code: LocalVariable.SURGICAL_TEMPLATE,
[LocalVariable.SELECTED_DATA_ARR]: [],
[LocalVariable.SELECTED_QUQNTITY]: 0
}, {
[LocalVariable.SELECTED_QUQNTITY]: 0,
},
{
category_name: '钉盒',
category_code: LocalVariable.NAIL_BOX,
[LocalVariable.SELECTED_DATA_ARR]: [],
[LocalVariable.SELECTED_QUQNTITY]: 0
}, {
[LocalVariable.SELECTED_QUQNTITY]: 0,
},
{
category_name: '器械包',
category_code: LocalVariable.EQUIPMENT_BAG,
[LocalVariable.SELECTED_DATA_ARR]: [],
[LocalVariable.SELECTED_QUQNTITY]: 0
}, {
[LocalVariable.SELECTED_QUQNTITY]: 0,
},
{
category_name: '零散器械',
category_code: LocalVariable.SCATTERED_EQUIPMENT,
[LocalVariable.SELECTED_DATA_ARR]: [],
[LocalVariable.SELECTED_QUQNTITY]: 0
}, {
[LocalVariable.SELECTED_QUQNTITY]: 0,
},
{
category_name: '耗材',
category_code: LocalVariable.SIGN_SELECT_CONSUMABLES,
[LocalVariable.SELECTED_DATA_ARR]: [],
[LocalVariable.SELECTED_QUQNTITY]: 0
}],
[LocalVariable.SELECTED_QUQNTITY]: 0,
},
],
local_cur_options: [],
cur_hc_opts: [],
filterData: [{
filterData: [
{
field: 'surgery_type',
label: '手术类型',
options: [],
value: '',
type: 'select'
}],
type: 'select',
},
],
productAuthorization: 'N',
authorizations: []
authorizations: [],
}
this.inputSearchValue = debounce(this.inputSearchValue.bind(this), 500)
}
componentDidMount() {
const {authorizations = [], productAuthorization = 'N'} = R.pathOr({}, ['state', 'params', 'selfData'])(this.props.navigation)
this.setState({authorizations, productAuthorization}, () => {
const { authorizations = [], productAuthorization = 'N' } = R.pathOr({}, ['state', 'params', 'selfData'])(
this.props.navigation,
)
this.setState({ authorizations, productAuthorization }, () => {
this.initGetData()
})
}
......@@ -97,6 +134,7 @@ class ChooseProductPage extends Component {
let { topProcOptionList, originManufacterList } = this.state
let { setSelectProductOpts } = this.props
setSelectProductOpts(originManufacterList)
console.log('originManufacterList', originManufacterList)
this.props.navigation.state.params.productCallBack(originManufacterList)
this.props.navigation.goBack()
}
......@@ -108,7 +146,6 @@ class ChooseProductPage extends Component {
let { productAuthorization, authorizations } = this.state
if (local_sele_pro_options && local_sele_pro_options.length > 0) {
let list = local_sele_pro_options
if (productAuthorization === 'Y') {
const filterSuppliers = R.pluck('supplier_code', authorizations)
......@@ -120,14 +157,17 @@ class ChooseProductPage extends Component {
}
// 之前选择过值
that.setState({
that.setState(
{
topProcOptionList: list,
originManufacterList: local_sele_pro_options
}, () => {
originManufacterList: local_sele_pro_options,
},
() => {
if (isNotBlank(list)) {
that.handleTopNav(list[0], 0)
}
})
},
)
return
}
that.refs.LoadingModel.show()
......@@ -167,15 +207,18 @@ class ChooseProductPage extends Component {
}
}
that.setState({
that.setState(
{
topProcOptionList: list,
originManufacterList: topProcOptionList,
}, () => {
},
() => {
that.refs.LoadingModel.hide()
if (isNotBlank(list)) {
that.handleTopNav(list[0], 0)
}
})
},
)
} else {
this.refs.LoadingModel.hide()
show('厂家数据为空,请联系管理员配置!')
......@@ -191,11 +234,14 @@ class ChooseProductPage extends Component {
let { token, global_domain_config } = that.props
let { topProcOptionList, defalutLeftItem } = this.state
if (topItem[LocalVariable.SELECTED_QUQNTITY] !== 0) {
that.setState({
topActiveIndex: topIndex
}, () => {
that.setState(
{
topActiveIndex: topIndex,
},
() => {
that.handleLeftNav(topItem['leftOptionList'][0], 0)
})
},
)
return
}
that.refs.LoadingModel.show()
......@@ -214,13 +260,16 @@ class ChooseProductPage extends Component {
leftObj[LocalVariable.LOCAL_SECOND_DATA] = []
})
topProcOptionList[topIndex] = topItem
that.setState({
that.setState(
{
topActiveIndex: topIndex,
topProcOptionList: topProcOptionList
}, () => {
topProcOptionList: topProcOptionList,
},
() => {
that.refs.LoadingModel.hide()
that.handleLeftNav(topItem['leftOptionList'][0], 0)
})
},
)
} else {
that.showRrrorTip(pro_scate_search)
}
......@@ -234,13 +283,15 @@ class ChooseProductPage extends Component {
that.handleChangeThrShow(false)
if (leftItem[LocalVariable.SELECTED_QUQNTITY] !== 0) {
that.setState({
leftActiveIndex: leftIndex
}, () => {
that.setState(
{
leftActiveIndex: leftIndex,
},
() => {
if (leftIndex) return
this.setFilterData(topProcOptionList[topActiveIndex].leftOptionList[leftIndex].localSecondData)
})
},
)
return
}
that.refs.LoadingModel.show()
......@@ -263,17 +314,23 @@ class ChooseProductPage extends Component {
console.log('res_3 : ', sur_head_search)
if (sur_head_search.error_code === 0) {
if (sur_head_search.data && sur_head_search.data.surgery_template_headers) {
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(leftItem, sur_head_search.data.surgery_template_headers)
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(
leftItem,
sur_head_search.data.surgery_template_headers,
)
this.setFilterData(topProcOptionList[topActiveIndex].leftOptionList[leftIndex].localSecondData)
} else {
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = []
}
that.setState({
that.setState(
{
leftActiveIndex: leftIndex,
topProcOptionList: topProcOptionList
}, () => {
topProcOptionList: topProcOptionList,
},
() => {
that.refs.LoadingModel.hide()
})
},
)
} else {
that.showRrrorTip(sur_head_search)
}
......@@ -292,39 +349,51 @@ class ChooseProductPage extends Component {
console.log('res_3 : ', nail_equip_head_search)
if (nail_equip_head_search.error_code === 0) {
if (nail_equip_head_search.data && nail_equip_head_search.data.items) {
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(leftItem, nail_equip_head_search.data.items)
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(
leftItem,
nail_equip_head_search.data.items,
)
} else {
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = []
}
that.setState({
that.setState(
{
leftActiveIndex: leftIndex,
topProcOptionList: topProcOptionList
}, () => {
topProcOptionList: topProcOptionList,
},
() => {
that.refs.LoadingModel.hide()
})
},
)
} else {
that.showRrrorTip(nail_equip_head_search)
}
} else if (leftIndex === 3) {
let params = {
access_token: token,
manufacturer_code: topItem.supplier_code
manufacturer_code: topItem.supplier_code,
}
console.log('params=', params)
let scat_head_search = await reqScatEquipmentSearch(global_domain_config, params)
console.log('res_3 : ', scat_head_search)
if (scat_head_search.error_code === 0) {
if (scat_head_search.data && scat_head_search.data.tools) {
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(leftItem, scat_head_search.data.tools)
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = that.getInitLocalSecondData(
leftItem,
scat_head_search.data.tools,
)
} else {
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = []
}
that.setState({
that.setState(
{
leftActiveIndex: leftIndex,
topProcOptionList: topProcOptionList
}, () => {
topProcOptionList: topProcOptionList,
},
() => {
that.refs.LoadingModel.hide()
})
},
)
} else {
that.showRrrorTip(scat_head_search)
}
......@@ -334,7 +403,7 @@ class ChooseProductPage extends Component {
category_code: leftItem.category_code,
manufacturer_code: topItem.supplier_code,
org_code: cur_org_code,
leftIndex: leftIndex // 测试
leftIndex: leftIndex, // 测试
}
console.log('params=', params)
let single_all_search = await reqSingleConsumSearch(global_domain_config, params)
......@@ -342,6 +411,7 @@ class ChooseProductPage extends Component {
if (single_all_search.error_code === 0) {
let { data } = single_all_search
if (data && data.items) {
console.log('data.items', data.items)
//大-中-小类
data.items = data.items.filter(fi_item => fi_item.details && fi_item.details.length > 0)
leftItem[LocalVariable.LOCAL_SECOND_DATA] = cloneObject(data.items)
......@@ -354,24 +424,30 @@ class ChooseProductPage extends Component {
})
}
})
console.log('leftItem', leftItem)
} else if (data && data.details) {
console.log('data.items', data.items)
//大-小类
leftItem[LocalVariable.LOCAL_SECOND_DATA] = cloneObject(data.details)
leftItem[LocalVariable.LOCAL_SECOND_DATA].forEach(function (righDa) {
righDa[LocalVariable.ONLY_TWO_LEVELS] = true
righDa[LocalVariable.QUANTITY_FIELD] = 0 // 默认
})
console.log('leftItem', leftItem)
} else {
// 空数据
leftItem.localSecondData = []
}
topProcOptionList[topActiveIndex].leftOptionList[leftIndex] = cloneObject(leftItem)
that.setState({
that.setState(
{
leftActiveIndex: leftIndex,
topProcOptionList: topProcOptionList
}, () => {
topProcOptionList: topProcOptionList,
},
() => {
that.refs.LoadingModel.hide()
})
},
)
} else {
that.showRrrorTip(single_all_search)
}
......@@ -393,7 +469,7 @@ class ChooseProductPage extends Component {
// 修改小类回调
handleChangeThrShow(show) {
this.setState({
defaultThridShow: show
defaultThridShow: show,
})
}
......@@ -416,6 +492,7 @@ class ChooseProductPage extends Component {
// 当前选择项
leItem[LocalVariable.SELECTED_QUQNTITY] = count
const selectData = R.filter(R.compose(R.lt(0), R.prop(coutFieName)))(leItem[LocalVariable.LOCAL_SECOND_DATA])
console.log('selectData', selectData)
leItem.selectedArr = selectData
// 原本是赋值给这个对象属性的,但不知道哪里这个对象属性会把第四个以后的所选耗材放到第四个上,
// 所以最后计算的时候使用属性 selectedArr
......@@ -430,7 +507,7 @@ class ChooseProductPage extends Component {
// 关闭已选弹窗
handleCloseSelectModal(show) {
this.setState({
selectShowPopup: show
selectShowPopup: show,
})
}
......@@ -502,10 +579,14 @@ class ChooseProductPage extends Component {
top_item[LocalVariable.SELECTED_QUQNTITY] = 0
if (top_item.leftOptionList && top_item.leftOptionList.length) {
top_item.leftOptionList.forEach(function (left_item, left_index) {
left_item[LocalVariable.SELECTED_QUQNTITY] = 0
if (left_item.category_code === LocalVariable.SURGICAL_TEMPLATE || left_item.category_code === LocalVariable.NAIL_BOX || left_item.category_code === LocalVariable.EQUIPMENT_BAG || left_item.category_code === LocalVariable.SCATTERED_EQUIPMENT) {
if (
left_item.category_code === LocalVariable.SURGICAL_TEMPLATE ||
left_item.category_code === LocalVariable.NAIL_BOX ||
left_item.category_code === LocalVariable.EQUIPMENT_BAG ||
left_item.category_code === LocalVariable.SCATTERED_EQUIPMENT
) {
if (left_item[LocalVariable.SELECTED_DATA_ARR] && left_item[LocalVariable.SELECTED_DATA_ARR].length) {
// 加减
left_item[LocalVariable.SELECTED_DATA_ARR].map(arr_obj => {
......@@ -523,7 +604,8 @@ class ChooseProductPage extends Component {
}
})
// 清空
if (cur_no_clear.length === 0 ||
if (
cur_no_clear.length === 0 ||
(left_item.category_code === LocalVariable.SURGICAL_TEMPLATE && localSurgicalOpts.length === 0) ||
(left_item.category_code === LocalVariable.NAIL_BOX && localNailOpts.length === 0) ||
(left_item.category_code === LocalVariable.EQUIPMENT_BAG && localQuipmentOpts.length === 0) ||
......@@ -545,30 +627,42 @@ class ChooseProductPage extends Component {
left_item[LocalVariable.SELECTED_DATA_ARR] = []
if (localSignOpts && localSignOpts.length) {
localSignOpts.forEach((sign_obj, sign_index) => {
if (sign_obj.supplier_code === top_item.supplier_code && sign_obj[LocalVariable.CHILDREN_LINE_NAME] && sign_obj[LocalVariable.CHILDREN_LINE_NAME].length > 0) {
if (
sign_obj.supplier_code === top_item.supplier_code &&
sign_obj[LocalVariable.CHILDREN_LINE_NAME] &&
sign_obj[LocalVariable.CHILDREN_LINE_NAME].length > 0
) {
sign_obj[LocalVariable.CHILDREN_LINE_NAME].forEach((si_line, si_ind) => {
if (si_line.left_category_code === left_item.category_code) {
left_item[LocalVariable.SELECTED_DATA_ARR].push(si_line)
left_item[LocalVariable.SELECTED_QUQNTITY] += si_line[LocalVariable.QUANTITY_FIELD]
}
})
}
})
}
if (left_item[LocalVariable.LOCAL_SECOND_DATA] && left_item[LocalVariable.LOCAL_SECOND_DATA].length) {
left_item[LocalVariable.LOCAL_SECOND_DATA].forEach(function (loc_da, loc_ind) {
if (left_item[LocalVariable.SELECTED_DATA_ARR] && left_item[LocalVariable.SELECTED_DATA_ARR].length === 0) {
if (
left_item[LocalVariable.SELECTED_DATA_ARR] &&
left_item[LocalVariable.SELECTED_DATA_ARR].length === 0
) {
loc_da[LocalVariable.QUANTITY_FIELD] = 0
if (loc_da.details && loc_da.details.length) {
loc_da.details.forEach(function (det_item) {
det_item[LocalVariable.QUANTITY_FIELD] = 0
})
}
} else if (left_item[LocalVariable.SELECTED_DATA_ARR] && left_item[LocalVariable.SELECTED_DATA_ARR].length) {
} else if (
left_item[LocalVariable.SELECTED_DATA_ARR] &&
left_item[LocalVariable.SELECTED_DATA_ARR].length
) {
let hasSignFlag = false
left_item[LocalVariable.SELECTED_DATA_ARR].map((se_sign) => {
if ((loc_da.details && se_sign.details && loc_da.category_code === se_sign.category_code) || (!se_sign.details && loc_da.item_code === se_sign.item_code)) {
left_item[LocalVariable.SELECTED_DATA_ARR].map(se_sign => {
if (
(loc_da.details && se_sign.details && loc_da.category_code === se_sign.category_code) ||
(!se_sign.details && loc_da.item_code === se_sign.item_code)
) {
loc_da = se_sign
hasSignFlag = true
}
......@@ -591,9 +685,8 @@ class ChooseProductPage extends Component {
}
})
this.setState({
topProcOptionList: topProcOptionList
topProcOptionList: topProcOptionList,
})
}
// 已选修改回调
......@@ -607,7 +700,7 @@ class ChooseProductPage extends Component {
}
})
this.setState({
topProcOptionList
topProcOptionList,
})
}
......@@ -633,7 +726,7 @@ class ChooseProductPage extends Component {
}
})
this.setState({
topProcOptionList: topProcOptionList
topProcOptionList: topProcOptionList,
})
}
......@@ -641,41 +734,44 @@ class ChooseProductPage extends Component {
showRrrorTip(result) {
this.refs.LoadingModel.hide()
if (result.error_code == 41006) {
show('登录过期,请重新登录');
this.props.exitLoginStatus();
show('登录过期,请重新登录')
this.props.exitLoginStatus()
} else {
let error_msg = result.error_msg || result.message
show(error_msg);
show(error_msg)
}
}
setFilterData(localSecondData) {
let options = R.compose(
R.groupBy(R.prop('value')),
R.map(R.applySpec({
R.map(
R.applySpec({
label: R.prop('surgery_type_name'),
value: R.prop('surgery_type')
})
), R.clone)(localSecondData)
value: R.prop('surgery_type'),
}),
),
R.clone,
)(localSecondData)
options = R.compose(
R.map( k => ({value: k, label: options[k][0].label})),
R.map(k => ({ value: k, label: options[k][0].label })),
R.filter(R.allPass([isNotBlank, R.complement(R.equals)('undefined')])),
R.keys
R.keys,
)(options)
const {filterData} = this.state
const { filterData } = this.state
filterData[0].value = ''
filterData[0].options = options
this.setState({filterData})
this.setState({ filterData })
}
inputSearchValue(text) {
this.setState({searchValue: text})
this.setState({ searchValue: text })
}
fillterCallback(key, value) {
const {filterData} = this.state
const { filterData } = this.state
const filter = R.find(R.propEq('field', key))(filterData)
if (!filter) return
filter.value = value
......@@ -688,7 +784,7 @@ class ChooseProductPage extends Component {
* @return {*}
*/
rightFilter(list = []) {
const {filterData, authorizations, productAuthorization, topActiveIndex, topProcOptionList} = this.state
const { filterData, authorizations, productAuthorization, topActiveIndex, topProcOptionList } = this.state
if (productAuthorization === 'Y') {
const curSupplier = topProcOptionList[topActiveIndex]
......@@ -701,7 +797,8 @@ class ChooseProductPage extends Component {
}
}
R.compose(R.map(filter => {
R.compose(
R.map(filter => {
const value = filter.value
if (isNotBlank(value)) {
const reg = new RegExp(value, 'g')
......@@ -709,7 +806,8 @@ class ChooseProductPage extends Component {
return R.test(reg, item[filter.field])
}, list)
}
}))(filterData)
}),
)(filterData)
return list
}
......@@ -721,9 +819,9 @@ class ChooseProductPage extends Component {
* @return {*}
*/
rightNameFilter(list = [], isChildFilter = false, isOperation = false) {
if(isBlank(list)) return []
if (isBlank(list)) return []
const {searchValue, authorizations, productAuthorization, topActiveIndex, topProcOptionList } = this.state
const { searchValue, authorizations, productAuthorization, topActiveIndex, topProcOptionList } = this.state
if (productAuthorization === 'Y') {
const curSupplier = topProcOptionList[topActiveIndex]
const auth = R.find(R.propEq('supplier_code', curSupplier.supplier_code))(authorizations)
......@@ -743,13 +841,21 @@ class ChooseProductPage extends Component {
}
if (isBlank(searchValue)) return list
const keys = ['general_name', 'item_name', 'specification', 'manufacturer_product_code', 'initials_pinyin', 'serial_number', 'category_name']
const keys = [
'general_name',
'item_name',
'specification',
'manufacturer_product_code',
'initials_pinyin',
'serial_number',
'category_name',
]
const includes = item => {
const preds = R.compose(
R.map(val => R.includes(R.__, val)),
R.filter(isNotBlank),
R.map(key => item[key])
R.map(key => item[key]),
)(keys)
return R.anyPass(preds)(searchValue)
}
......@@ -759,30 +865,88 @@ class ChooseProductPage extends Component {
// 返回搜索元素
renderSearchItem() {
const {leftActiveIndex, filterData} = this.state
const { navigation } = this.props
const { leftActiveIndex, filterData, authorizations, topProcOptionList } = this.state
let cur_org_code = ''
if (navigation.state.params.selfData) {
cur_org_code = navigation.state.params.selfData.org_code
}
if (leftActiveIndex) {
return (
<TouchableOpacity
onPress={() => {
navigation.navigate('SearchPage', {
title: `选择产品`,
topProcOptionList,
title: '搜索',
setTopProcOptionListCallBack: setTopProcOptionList => {
setTopProcOptionList.then(topProcOptionList => {
this.setState(
{
topProcOptionList: [...topProcOptionList],
},
() => {
this.props.navigation.goBack()
},
)
})
},
selfData: {
org_code: cur_org_code,
authorizations,
},
})
}}
>
<View style={list_common_item.ser_cont}>
<TextInput
placeholder={'请输入搜索关键词'}
style={list_common_item.ser_text_input}
defaultValue={this.state.searchValue}
onChangeText={(text) => this.inputSearchValue(text)}
/>
<View style={list_common_item.ser_text_input}></View>
<View style={list_common_item.ser_img_box}>
<Image source={require('../../../images/search_icon.png')} style={icon_style} />
</View>
</View>
</TouchableOpacity>
)
} else {
return <ChooseFilter filterData={filterData} onCallback={this.fillterCallback.bind(this)}/>
return (
<View>
<TouchableOpacity
onPress={() => {
navigation.navigate('SearchPage', {
title: `选择产品`,
topProcOptionList,
title: '搜索',
setTopProcOptionListCallBack: setTopProcOptionList => {
setTopProcOptionList.then(topProcOptionList => {
this.setState({
topProcOptionList: [...topProcOptionList],
})
})
},
selfData: {
org_code: cur_org_code,
authorizations,
},
})
}}
>
<View style={list_common_item.ser_cont}>
<View style={list_common_item.ser_text_input}></View>
<View style={list_common_item.ser_img_box}>
<Image source={require('../../../images/search_icon.png')} style={icon_style} />
</View>
</View>
</TouchableOpacity>
<ChooseFilter filterData={filterData} onCallback={this.fillterCallback.bind(this)} />
</View>
)
}
}
// 返回顶部厂家
renderTopProItem() {
let { topProcOptionList, topActiveIndex } = this.state
let cur_title = 'title', cur_icon = 'iconImg'
let cur_title = 'title',
cur_icon = 'iconImg'
cur_title = 'supplier_short_name'
cur_icon = 'supplier_icon'
......@@ -817,7 +981,8 @@ class ChooseProductPage extends Component {
if (topProcOptionList.length > 0) {
curLeftOptions = topProcOptionList[topActiveIndex].leftOptionList
}
let cur_title = 'title', cur_icon = 'iconImg'
let cur_title = 'title',
cur_icon = 'iconImg'
cur_title = 'category_name'
cur_icon = 'cate_local_icon'
......@@ -866,12 +1031,12 @@ class ChooseProductPage extends Component {
return (
<View style={styles.cont_bom_box}>
{ this.renderContLeftItem()}
{this.renderContLeftItem()}
<ProductRightStyle
navigation={this.props.navigation}
leftIndex={leftActiveIndex}
defaultThridShow={defaultThridShow}
changeThrShow={(defaultThridShow) => this.handleChangeThrShow(defaultThridShow)}
changeThrShow={defaultThridShow => this.handleChangeThrShow(defaultThridShow)}
superStencilData={curRigSecoOption}
superCallBack={(count, coutFieName) => this.handleChangeCount(count, coutFieName)}
superReduceBack={() => this.handleSubSelected()}
......@@ -884,7 +1049,16 @@ class ChooseProductPage extends Component {
// 返回底部按钮
renderFooterBtnItem() {
let { selectShowPopup, topProcOptionList, topActiveIndex, leftActiveIndex, filterData, local_sel_options, local_cur_options, cur_hc_opts} = this.state
let {
selectShowPopup,
topProcOptionList,
topActiveIndex,
leftActiveIndex,
filterData,
local_sel_options,
local_cur_options,
cur_hc_opts,
} = this.state
let allCountQuantity = this.getAllCountQuantity()
let cur_sel_options = []
let sel_tip = this.getAllCountQuantity(true)
......@@ -897,12 +1071,13 @@ class ChooseProductPage extends Component {
let leftOptionList = top_item.leftOptionList
leftOptionList.map(left_item => {
if (left_item[LocalVariable.SELECTED_QUQNTITY] > 0) {
console.log('left_item', left_item)
let cur_line_obj = {
supplier_code: top_item.supplier_code,
supplier_name: top_item.supplier_name,
supplier_short_name: top_item.supplier_short_name,
[LocalVariable.SELECTED_QUQNTITY]: left_item[LocalVariable.SELECTED_QUQNTITY],
[LocalVariable.CHILDREN_LINE_NAME]: left_item[LocalVariable.SELECTED_DATA_ARR]
[LocalVariable.CHILDREN_LINE_NAME]: left_item[LocalVariable.SELECTED_DATA_ARR],
}
let localNotSign = false
for (let selOpts of cur_sel_options) {
......@@ -919,9 +1094,18 @@ class ChooseProductPage extends Component {
// 耗材
cur_line_obj.category_code = cur_sel_options[cur_sel_options.length - 1].category_code
cur_line_obj.category_name = cur_sel_options[cur_sel_options.length - 1].category_name
cur_sel_options[cur_sel_options.length - 1][LocalVariable.SELECTED_QUQNTITY] += cur_line_obj[LocalVariable.SELECTED_QUQNTITY]
cur_sel_options[cur_sel_options.length - 1][LocalVariable.SELECTED_QUQNTITY] +=
cur_line_obj[LocalVariable.SELECTED_QUQNTITY]
if (cur_line_obj[LocalVariable.CHILDREN_LINE_NAME] && cur_line_obj[LocalVariable.CHILDREN_LINE_NAME].length > 0) {
console.log(
'cur_line_obj[LocalVariable.CHILDREN_LINE_NAME]',
cur_line_obj[LocalVariable.CHILDREN_LINE_NAME],
)
if (
cur_line_obj[LocalVariable.CHILDREN_LINE_NAME] &&
cur_line_obj[LocalVariable.CHILDREN_LINE_NAME].length > 0
) {
cur_line_obj[LocalVariable.CHILDREN_LINE_NAME].map(function (li_obj) {
li_obj.left_category_code = left_item.category_code
li_obj.left_category_name = left_item.category_name
......@@ -930,48 +1114,52 @@ class ChooseProductPage extends Component {
cur_sel_options[cur_sel_options.length - 1][LocalVariable.SELECTED_DATA_ARR].push(cur_line_obj)
}
}
})
}
})
let cur_hc_arr = [], cur_obj = {}
let cur_hc_arr = [],
cur_obj = {}
cur_hc_arr = cloneObject(cur_hc_opts)
if(cur_sel_options[cur_sel_options.length - 1][LocalVariable.SELECTED_DATA_ARR].length >0) {
if (cur_sel_options[cur_sel_options.length - 1][LocalVariable.SELECTED_DATA_ARR].length > 0) {
cur_sel_options[cur_sel_options.length - 1][LocalVariable.SELECTED_DATA_ARR].forEach((hc_item, hc_ind) => {
let curHasSup = cur_hc_arr.filter(su_obj => su_obj.supplier_code === hc_item.supplier_code)
if(curHasSup.length === 0){
if (curHasSup.length === 0) {
cur_hc_arr.push(hc_item)
}else {
} else {
console.log('curHasSup', curHasSup)
cur_hc_arr.map(function (end_item) {
if(end_item.supplier_code === hc_item.supplier_code){
if (end_item.supplier_code === hc_item.supplier_code) {
end_item[LocalVariable.SELECTED_QUQNTITY] += hc_item[LocalVariable.SELECTED_QUQNTITY]
for(let line_obj of hc_item[LocalVariable.CHILDREN_LINE_NAME]){
for (let line_obj of hc_item[LocalVariable.CHILDREN_LINE_NAME]) {
let cur_fil = end_item[LocalVariable.CHILDREN_LINE_NAME].filter(fi_obj => {
if(fi_obj.details && fi_obj.details.length > 0){
if (fi_obj.details && fi_obj.details.length > 0) {
return fi_obj.category_code === line_obj.category_code
}else {
} else {
return fi_obj.item_code === line_obj.item_code
}
})
if(cur_fil.length === 0 && line_obj[LocalVariable.QUANTITY_FIELD] > 0){
if (cur_fil.length === 0 && line_obj[LocalVariable.QUANTITY_FIELD] > 0) {
end_item[LocalVariable.CHILDREN_LINE_NAME].push(line_obj)
}
}
end_item[LocalVariable.CHILDREN_LINE_NAME] = end_item[LocalVariable.CHILDREN_LINE_NAME].filter(fil_ob => fil_ob[LocalVariable.QUANTITY_FIELD] > 0)
end_item[LocalVariable.CHILDREN_LINE_NAME] = end_item[LocalVariable.CHILDREN_LINE_NAME].filter(
fil_ob => fil_ob[LocalVariable.QUANTITY_FIELD] > 0,
)
}
})
}
})
cur_sel_options[cur_sel_options.length - 1][LocalVariable.SELECTED_DATA_ARR] = cur_hc_arr
}
}
console.log('cur_sel_options', cur_sel_options)
return (
<View style={list_common_item.sub_box}>
<View style={list_common_item.sub_two_btn}>
<TouchableOpacity
activeOpacity={.8}
activeOpacity={0.8}
style={[list_common_item.lef_btn, styles.fo_btn_lef]}
onPress={() => this.handleSubSelected()}
>
......@@ -979,38 +1167,33 @@ class ChooseProductPage extends Component {
{allCountQuantity === 0 ? <Text>{'未选'}</Text> : <Text>{'已选: '}</Text>}
{allCountQuantity === 0 ? null : <Text style={styles.lef_tip_txt}>{sel_tip}</Text>}
</Text>
{allCountQuantity === 0 ? null : <View style={styles.lef_btn_num}>
{allCountQuantity === 0 ? null : (
<View style={styles.lef_btn_num}>
<Text style={styles.lef_num_txt}>{allCountQuantity}</Text>
</View>}
</View>
)}
</TouchableOpacity>
<TouchableOpacity
activeOpacity={.8}
style={list_common_item.rig_btn}
onPress={() => this.handleSubmit()}
>
<TouchableOpacity activeOpacity={0.8} style={list_common_item.rig_btn} onPress={() => this.handleSubmit()}>
<Text style={list_common_item.rig_tip}>{'选好了'}</Text>
</TouchableOpacity>
</View>
<ProductModel
show={selectShowPopup}
closeModal={(show) => this.handleCloseSelectModal(show)}
closeModal={show => this.handleCloseSelectModal(show)}
closeSubmit={() => this.handleSubmit()}
modelOption={cur_sel_options}
modelCallBack={(options) => this.handleSelectCallBack(options)}
modelCallBack={options => this.handleSelectCallBack(options)}
clearRubbish={() => this.handleClearRubbish()}
changeCallBack={(options, clearFlag) => this.handleChangeCallBack(options, clearFlag)}
/>
{ this.renderLodingItem()}
{this.renderLodingItem()}
</View>
)
}
// 返回加载中
renderLodingItem() {
return (
<LoadingModel ref="LoadingModel" />
)
return <LoadingModel ref="LoadingModel" />
}
render() {
......@@ -1019,31 +1202,29 @@ class ChooseProductPage extends Component {
let { topProcOptionList, leftActiveIndex, filterData } = this.state
return (
<View style={styles.choo_container}>
<StatusBarView
isReactStackNavigator={true}
backgroundColor={promary_color}
barStyle='light-content'
/>
<View style={safe_view} >
<StatusBarView isReactStackNavigator={true} backgroundColor={promary_color} barStyle="light-content" />
<View style={safe_view}>
<HeadBackItem title={title} navigation={navigation} callback={() => this.handleGoBack()} />
<View style={!leftActiveIndex ?[styles.choo_main, styles.choo_main_pd]: styles.choo_main} pointerEvents="auto">
<View
style={!leftActiveIndex ? [styles.choo_main, styles.choo_main_pd] : styles.choo_main}
pointerEvents="auto"
>
{this.renderSearchItem()}
{topProcOptionList && topProcOptionList.length > 0 ? this.renderTopProItem() : null}
{topProcOptionList && topProcOptionList.length > 0 ? this.renderContItem() : null}
</View>
{this.renderFooterBtnItem()}
{/* {!leftActiveIndex && <ChooseFilter filterData={filterData} onCallback={this.fillterCallback.bind(this)}/>} */}
</View>
</View>
);
)
}
}
const styles = StyleSheet.create({
choo_container: {
flex: 1,
backgroundColor: home_background_color
backgroundColor: home_background_color,
},
choo_main: {
flex: 1,
......@@ -1059,19 +1240,19 @@ const styles = StyleSheet.create({
paddingHorizontal: 20,
paddingTop: 12,
borderBottomColor: '#F4F4F4',
borderBottomWidth: 1
borderBottomWidth: 1,
},
top_scroll_cont: {},
top_inner: {
borderBottomColor: foundation_color,
minWidth: 60,
paddingBottom: 10
paddingBottom: 10,
},
top_inner_act: {},
top_tit: {},
top_tit_act: {},
top_cot_num: {
right: 8
right: 8,
},
cont_bom_box: {
position: 'relative',
......@@ -1082,10 +1263,10 @@ const styles = StyleSheet.create({
width: 80,
height: '100%',
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
},
cont_left_scroll_cont: {
width: '100%'
width: '100%',
},
cont_left_inner: {
flexDirection: 'row',
......@@ -1095,27 +1276,27 @@ const styles = StyleSheet.create({
alignItems: 'center',
borderWidth: 0,
width: '100%',
borderBottomWidth: 0
borderBottomWidth: 0,
},
cont_left_inner_act: {
backgroundColor: foundation_color,
borderBottomWidth: 0,
borderBottomColor: null
borderBottomColor: null,
},
cont_left_img_box: {
width: pxSize(14),
height: pxSize(14),
marginRight: 4,
marginLeft: 6,
marginBottom: 5
marginBottom: 5,
},
cont_left_tit: {},
cont_left_noicon: {
textAlign: 'center',
paddingHorizontal: 14
paddingHorizontal: 14,
},
cont_left_tit_act: {
fontSize: third_text_size
fontSize: third_text_size,
},
sub_box: {
width: Width(),
......@@ -1124,49 +1305,49 @@ const styles = StyleSheet.create({
shadowColor: '#E5E5E5',
shadowOffset: {
width: 1,
height: 2
height: 2,
},
shadowOpacity: 1,
elevation: 10,
height: 80
height: 80,
},
sub_two_btn: {
width: Width(),
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 30,
paddingVertical: 14
paddingVertical: 14,
},
lef_btn: {
backgroundColor: '#4F4F4F',
width: '66%',
borderTopLeftRadius: 10,
borderBottomLeftRadius: 10,
height: 50
height: 50,
},
lef_tip: {
color: title_text_color,
lineHeight: 48,
paddingLeft: 20,
fontSize: 16,
fontFamily: font_family_regular
fontFamily: font_family_regular,
},
rig_btn: {
backgroundColor: promary_color,
width: '34%',
borderTopRightRadius: 10,
borderBottomRightRadius: 10,
height: 50
height: 50,
},
rig_tip: {
color: title_text_color,
lineHeight: 48,
textAlign: 'center',
fontSize: 16,
fontFamily: font_family_medium
fontFamily: font_family_medium,
},
fo_btn_lef: {
position: 'relative'
position: 'relative',
},
lef_btn_num: {
position: 'absolute',
......@@ -1179,32 +1360,32 @@ const styles = StyleSheet.create({
fontSize: 12,
color: title_text_color,
minWidth: 16,
textAlign: 'center'
textAlign: 'center',
},
lef_tip_txt: {
fontSize: 12
}
fontSize: 12,
},
})
const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
userInfo: state.login.userInfo,
token: state.login.token,
loginState: state.login.loginState,
global_domain_config: state.login.global_domain_config,
local_sele_pro_options: state.selfOrder.local_sele_pro_options
local_sele_pro_options: state.selfOrder.local_sele_pro_options,
}
}
const mapDispatchToProps = (dispatch) => {
const mapDispatchToProps = dispatch => {
return {
exitLoginStatus: () => {
dispatch(exitLoginStatus())
},
setSelectProductOpts: (data) => {
setSelectProductOpts: data => {
dispatch(setSelectProductOpts(data))
}
},
}
}
export default connect(mapStateToProps, mapDispatchToProps)(ChooseProductPage);
export default connect(mapStateToProps, mapDispatchToProps)(ChooseProductPage)
import React, { Component } from 'react'
import { icon_style, list_common_item, safe_view, foundation_color } from '../../../base/BaseStyle'
import { View, StyleSheet, Image, TextInput, SafeAreaView, ScrollView, FlatList } from 'react-native'
import HeadBackItem from '../../common/HeadBackItem'
import { PicListNoData } from '../../common/CellTextStyle'
import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu'
import LocalVariable from '../../common/LocalVariable'
import { reqGlobalSearch, reqSingleConsumSearch, reqProCategorySearch } from '../../../action/SelfAction'
import ChooseCardList from '../../common/listDataComponent/ChooseCardList'
import { connect } from 'react-redux'
import { cloneObject } from '../../../utils/Utils'
// import ChooseCardList from '../../common/listDataComponent/ChooseCardList';
import LoadingModel from '../../common/listDataComponent/LoadingModel'
import { Width } from '../../../base/BaseStyle'
class SearchPage extends Component {
constructor(props) {
super(props)
this.state = {
defalutLeftItem: [
{
category_code: LocalVariable.SURGICAL_TEMPLATE,
category_name: '手术套包',
cate_local_icon: require('../../../images/surg_temp.png'),
},
{
category_code: LocalVariable.NAIL_BOX,
category_name: '钉盒',
cate_local_icon: require('../../../images/screw_box.png'),
},
{
category_code: LocalVariable.EQUIPMENT_BAG,
category_name: '器械包',
cate_local_icon: require('../../../images/equip_bag.png'),
},
{
category_code: LocalVariable.SCATTERED_EQUIPMENT,
category_name: '零散器械',
cate_local_icon: require('../../../images/auxili_tool.png'),
},
],
searchValue: '金属脊柱',
dataList: [],
topActiveIndex: 0,
}
}
componentDidMount() {
this.getSearchData()
}
// 获取搜索数据
async getSearchData() {
const { navigation, global_domain_config, token } = this.props
const { topActiveIndex, searchValue } = this.state
const { selfData, topProcOptionList } = navigation.state.params
const { authorizations } = selfData
const productLineCategory = authorizations?.product_line_category_list
?.map(item => item.product_line_category_code)
?.join(',')
console.log('topProcOptionList', topProcOptionList[topActiveIndex])
const params = {
accessToken: token,
orgCode: selfData.org_code,
manufacturerCode: topProcOptionList[topActiveIndex].supplier_code,
productLineCategory,
keyword: encodeURIComponent(searchValue),
// pageSize: 9999,
}
this.refs.LoadingModel.show()
const single_all_search = await reqGlobalSearch(global_domain_config, JSON.parse(JSON.stringify(params)))
this.refs.LoadingModel.hide()
console.log('single_all_search', single_all_search)
this.setState({
dataList: single_all_search?.data?.item ? single_all_search?.data?.item : [],
})
}
// 获取搜索到的类目
async getLeftOptionList(item) {
const { navigation, global_domain_config, token } = this.props
const { topProcOptionList } = navigation.state.params
const { defalutLeftItem, topActiveIndex } = this.state
const params = {
access_token: token,
manufacturer_code: topProcOptionList[topActiveIndex].supplier_code,
}
console.log('params=', params)
this.refs.LoadingModel.show()
const pro_scate_search = await reqProCategorySearch(global_domain_config, params)
this.refs.LoadingModel.hide()
console.log('res_2 : ', pro_scate_search)
if (pro_scate_search.error_code === 0) {
const { data } = pro_scate_search
let newData = defalutLeftItem.concat(data.item)
// 记录找到的菜单的index
let index = -1
newData = newData.map((ele, i) => {
let selectedQuantity = ele[LocalVariable.SELECTED_QUQNTITY] || 0
if (ele.category_code === item.big_category.category_code) {
index = i
selectedQuantity += 1
}
return {
...ele,
[LocalVariable.SELECTED_QUQNTITY]: selectedQuantity,
[LocalVariable.LOCAL_SECOND_DATA]: [],
}
})
return Promise.resolve({ newData, index })
}
return Promise.resolve([])
}
// 获取搜索到的类目商品数据
async getLocalSecondData(item) {
const that = this
const { navigation, global_domain_config, token } = this.props
const { topActiveIndex } = this.state
const { topProcOptionList, selfData } = navigation.state.params
let params = {
access_token: token,
category_code: item.big_category.category_code,
manufacturer_code: topProcOptionList[topActiveIndex].supplier_code,
org_code: selfData.org_code,
// leftIndex: leftIndex, // 测试
}
console.log('params=', params)
this.refs.LoadingModel.show()
const single_all_search = await reqSingleConsumSearch(global_domain_config, params)
this.refs.LoadingModel.hide()
console.log('res_3 : ', single_all_search)
if (single_all_search.error_code === 0) {
const { data } = single_all_search
const { details, items } = data
if (details) {
const newData = details.map(ele => {
let quantity = ele[LocalVariable.QUANTITY_FIELD] || 0
if (ele.item_code === item.item_code) {
quantity += 1
}
return {
...ele,
[LocalVariable.ONLY_TWO_LEVELS]: true,
[LocalVariable.QUANTITY_FIELD]: quantity,
}
})
console.log('res_3:newData', newData)
return Promise.resolve(newData)
} else if (items) {
// 如果是四层结构
const newData = items.map(ele => {
let quantity = ele[LocalVariable.QUANTITY_FIELD] || 0
if (ele.category_code === item.middle_category.category_code) {
quantity += 1
console.log('ele.length', ele.details.length)
}
return {
...ele,
[LocalVariable.QUANTITY_FIELD]: quantity,
details: ele.details.map(ele1 => {
let quantity1 = ele1[LocalVariable.QUANTITY_FIELD] || 0
if (ele1.item_code === item.item_code) {
quantity1 += 1
console.log('item.item_code', item.item_code)
console.log('ele1', ele1)
}
return {
...ele1,
[LocalVariable.ONLY_TWO_LEVELS]: true,
[LocalVariable.QUANTITY_FIELD]: quantity1,
}
}),
}
})
return Promise.resolve(newData)
}
}
return Promise.resolve([])
}
// 把后台给的数据转成商品列表的格式,并添加数量
async formatToTopProcOptionList(item) {
const { navigation } = this.props
let { topProcOptionList } = navigation.state.params
const { topActiveIndex } = this.state
// 大类列表
let { leftOptionList } = topProcOptionList[topActiveIndex]
// 找搜索出来商品对应的大类
let leftOptionListItem = leftOptionList.find(ele => ele.category_code === item.big_category?.category_code)
console.log('leftOptionListItem', leftOptionListItem)
if (leftOptionListItem) {
console.log('已存在')
// 如果大类已存在
leftOptionListItem['selectedQuantity'] += 1
// 找耗材
let localSecondDataItem = leftOptionListItem.localSecondData?.find(ele => {
if (ele.item_code === item.item_code) {
return true
}
// 找中类
if (ele.details && item.middle_category) {
if (ele.category_code === item.middle_category.category_code) {
console.log('ele.category_code', ele.category_code)
return true
}
return false
}
return false
})
// 如果找到
if (localSecondDataItem) {
// 查找对应的产品 并添加数量、
const { details } = localSecondDataItem
if (details) {
// 如果是4层
const detail = details.find(ele => ele.item_code === item.item_code)
detail[LocalVariable.QUANTITY_FIELD] += 1
}
// 一般情况
localSecondDataItem[LocalVariable.QUANTITY_FIELD] += 1
} else {
// 如果找不到对应的产品
const localSecondData = await this.createLocalSecondData(item)
leftOptionListItem.localSecondData = localSecondData
console.log('localSecondDataItem', localSecondDataItem)
}
} else {
// 如果找不到当前商品大类,代表大类列表未加载
// 搜索出所有大类,并加入
leftOptionList = await this.createLeftOptionList(item)
console.log('leftOptionList', leftOptionList)
}
topProcOptionList[topActiveIndex] = {
...topProcOptionList[topActiveIndex],
[LocalVariable.SELECTED_QUQNTITY]: topProcOptionList[topActiveIndex][LocalVariable.SELECTED_QUQNTITY] + 1,
leftOptionList: leftOptionList.map(ele => {
const childrenLineData = this.getChildrenLineData(ele.localSecondData)
console.log('selectedDataArr', childrenLineData)
return {
...ele,
[LocalVariable.SELECTED_DATA_ARR]: childrenLineData,
}
}),
}
return Promise.resolve(topProcOptionList)
}
// 创建大类
async createLeftOptionList(item) {
// 获取该厂家下所有大类
let { newData: newLeftOptionList, index } = await this.getLeftOptionList(item)
console.log('newLeftOptionList', newLeftOptionList)
const localSecondData = await this.getLocalSecondData(item)
newLeftOptionList[index] = {
...newLeftOptionList[index],
localSecondData,
}
console.log('newLeftOptionList_index', newLeftOptionList[index])
return Promise.resolve(newLeftOptionList)
}
// 统计后塞入购物车
getChildrenLineData = data => {
console.log('getChildrenLineData', data)
return data.filter(item => item.quantity > 0)
}
// 返回每一列元素
renderContColumnItem(item, index) {
const { navigation } = this.props
const { setTopProcOptionListCallBack } = navigation.state.params
return (
<SafeAreaView style={styles.column_container} key={'item_code' + index}>
<PicTitDetaiCalcu
listItem={item}
listIndex={index}
calField={LocalVariable.QUANTITY_FIELD}
subCalCallBack={(item, idx) => {}}
titText={'manufacturer_product_code'}
tipTextStr={'item_name'}
tipTextOne={'general_name'}
tipTextTwo={'specification'}
titTextTit={'厂家产品代码'}
tipTextStrTit={'物料名称'}
tipTextOneTit={'通用名称'}
tipTextTwoTit={'规格型号'}
listImgIcon={'photos'}
plusCallBack={(item, index) => {
setTopProcOptionListCallBack(
this.formatToTopProcOptionList(item).then(data => {
this.props.navigation.goBack()
return Promise.resolve(data)
}),
)
}}
// reduceCallBack={() => this.props.handleAllPlusReduce(item, index)}
/>
</SafeAreaView>
)
}
handleTopNav(topItem, topActiveIndex) {
this.setState(
{
topActiveIndex,
},
() => {
this.getSearchData()
},
)
}
inputSearchValue(text) {
this.setState({ searchValue: text }, () => {
this.getSearchData()
})
}
render() {
const { navigation } = this.props
const { title, topProcOptionList } = navigation.state.params
const { dataList, topActiveIndex } = this.state
const cur_icon = 'supplier_icon'
console.log('dataList', dataList)
return (
<SafeAreaView style={safe_view}>
<HeadBackItem title={title} navigation={navigation} />
<View style={list_common_item.ser_cont}>
<TextInput
placeholder={'请输入搜索关键词'}
style={list_common_item.ser_text_input}
// defaultValue={this.state.searchValue}
onChangeText={text => this.inputSearchValue(text)}
/>
<View style={list_common_item.ser_img_box}>
<Image source={require('../../../images/search_icon.png')} style={icon_style} />
</View>
</View>
<ChooseCardList
cardStyleBox={styles.chooseCardList_box}
cardScrollEnabled={true}
cardHorizontal={true}
cardShowsHorizontalScrollIndicator={false}
cardStyleListItem={styles.top_inner}
cardListOptions={topProcOptionList}
// cardItemTitle={cur_title}
cardItemIcon={cur_icon}
curActIndex={topActiveIndex}
cardCallBack={(item, index) => this.handleTopNav(item, index)}
cardCountName={LocalVariable.SELECTED_QUQNTITY}
cardStyleType={'GRAPHICS'}
cardCouStyle={styles.top_cot_num}
cardShowDefIcon={true}
/>
<ScrollView showsVerticalScrollIndicator={false}>
{dataList.length > 0 ? (
<FlatList
keyExtractor={item => item.id}
data={dataList}
extraData={this.state}
renderItem={({ item, index }) => this.renderContColumnItem(item, index)}
/>
) : (
<PicListNoData />
)}
</ScrollView>
<LoadingModel ref="LoadingModel" />
</SafeAreaView>
)
}
}
const styles = StyleSheet.create({
top_box: {
width: Width(),
paddingHorizontal: 20,
paddingTop: 12,
},
chooseCardList_box: {
width: Width(),
height: 58,
backgroundColor: foundation_color,
paddingHorizontal: 20,
paddingTop: 12,
borderBottomColor: '#F4F4F4',
borderBottomWidth: 1,
},
top_inner: {
borderBottomColor: foundation_color,
minWidth: 60,
paddingBottom: 10,
},
top_cot_num: {
right: 8,
},
column_container: {
marginBottom: 10,
paddingHorizontal: 10,
paddingVertical: 6,
backgroundColor: foundation_color,
},
})
// export default SearchPage
const mapStateToProps = state => {
return {
userInfo: state.login.userInfo,
token: state.login.token,
loginState: state.login.loginState,
global_domain_config: state.login.global_domain_config,
local_sele_pro_options: state.selfOrder.local_sele_pro_options,
}
}
export default connect(mapStateToProps)(SearchPage)
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