Commit 8b7dccdd by yeyubin

消耗确认页面修改

parent 4231d95c
...@@ -9,7 +9,8 @@ import HomePage from './containers/home/HomePage'; ...@@ -9,7 +9,8 @@ import HomePage from './containers/home/HomePage';
import SelfOrderPage from './containers/selfOrder/SelfOrderPage'; import SelfOrderPage from './containers/selfOrder/SelfOrderPage';
import ChooseProductPage from './containers/selfOrder/module/ChooseProductPage'; import ChooseProductPage from './containers/selfOrder/module/ChooseProductPage';
import EditThirdLevelPage from './containers/selfOrder/module/EditThirdLevelPage'; import EditThirdLevelPage from './containers/selfOrder/module/EditThirdLevelPage';
import EquipConsuPage from './containers/equipConsu/EquipConsuPage'; // import EquipConsuPage from './containers/equipConsu/EquipConsuPage';
import EquipConsuPage from '../src/pages/consume_order/consume';
import ConsumDetailsPage from './containers/equipConsu/module/ConsumDetailsPage'; import ConsumDetailsPage from './containers/equipConsu/module/ConsumDetailsPage';
import ChargeDetailsPage from './containers/equipConsu/module/ChargeDetailsPageRef'; import ChargeDetailsPage from './containers/equipConsu/module/ChargeDetailsPageRef';
import FillUnitPricePage from './containers/equipConsu/module/FillUnitPricePage'; import FillUnitPricePage from './containers/equipConsu/module/FillUnitPricePage';
...@@ -25,6 +26,7 @@ import HistoricalOrderPage from './containers/historicalOrder/HistoricalOrderPag ...@@ -25,6 +26,7 @@ import HistoricalOrderPage from './containers/historicalOrder/HistoricalOrderPag
import LineOrderPage from './containers/historicalOrder/module/LineOrderPage'; import LineOrderPage from './containers/historicalOrder/module/LineOrderPage';
import SubSuccPage from './containers/common/SubSuccPage'; import SubSuccPage from './containers/common/SubSuccPage';
import BarCodePage from './containers/common/BarCodePage'; import BarCodePage from './containers/common/BarCodePage';
import Success from '../src/pages/success/success';
// 结算 // 结算
import Settlement from '../src/pages/settlement/index'; import Settlement from '../src/pages/settlement/index';
...@@ -65,6 +67,7 @@ const Router = createAppContainer(createStackNavigator({ ...@@ -65,6 +67,7 @@ const Router = createAppContainer(createStackNavigator({
LineOrderPage: {screen: LineOrderPage}, LineOrderPage: {screen: LineOrderPage},
SubSuccPage: {screen: SubSuccPage}, SubSuccPage: {screen: SubSuccPage},
BarCodePage: {screen: BarCodePage}, BarCodePage: {screen: BarCodePage},
Success: {screen: Success},
Settlement: {screen: Settlement}, Settlement: {screen: Settlement},
SettlementCollection: {screen: SettlementCollection}, SettlementCollection: {screen: SettlementCollection},
SettlementReject: {screen: SettlementReject}, SettlementReject: {screen: SettlementReject},
......
...@@ -11,6 +11,7 @@ import LodingModel from '../../common/LodingModel'; ...@@ -11,6 +11,7 @@ import LodingModel from '../../common/LodingModel';
import { exitLoginStatus } from '../../../action/LoginAction'; import { exitLoginStatus } from '../../../action/LoginAction';
import { OBS_MOBILE_EQU_CON_DISPLAY_PRICE } from '../../../base/BaseConstants'; import { OBS_MOBILE_EQU_CON_DISPLAY_PRICE } from '../../../base/BaseConstants';
import { LOGIN_NO } from '../../../base/ActionTypes'; import { LOGIN_NO } from '../../../base/ActionTypes';
import FilterModal from '../../../../src/pages/consume_order/components/FilterModel'
import moment from 'moment'; import moment from 'moment';
import * as R from 'ramda'; import * as R from 'ramda';
...@@ -28,7 +29,8 @@ class ConsumDetailsPage extends Component { ...@@ -28,7 +29,8 @@ class ConsumDetailsPage extends Component {
localSelectOption: [], // 已选数据 localSelectOption: [], // 已选数据
isSubLoding: true, // 加载中弹窗 isSubLoding: true, // 加载中弹窗
lodingTitle: '加载中', lodingTitle: '加载中',
userEnteredPrice: 'Y' userEnteredPrice: 'Y',
isShowFilterModal: false
} }
} }
...@@ -63,7 +65,7 @@ class ConsumDetailsPage extends Component { ...@@ -63,7 +65,7 @@ class ConsumDetailsPage extends Component {
let {global_domain_config} = this.props let {global_domain_config} = this.props
let params = { let params = {
access_token: this.props.token, access_token: this.props.token,
surgery_collect_number: orderId raised_consume: 'N',
} }
let detailResult = await requestEquipDetails(global_domain_config, params) let detailResult = await requestEquipDetails(global_domain_config, params)
console.log('消耗明细 res===', detailResult) console.log('消耗明细 res===', detailResult)
...@@ -258,6 +260,32 @@ class ConsumDetailsPage extends Component { ...@@ -258,6 +260,32 @@ class ConsumDetailsPage extends Component {
} }
} }
// 点击 显示筛选框
showFilterModal(show){
this.setState({isShowFilterModal:show})
}
// 筛选数据处理
filterSubmitCheck(params){
let { conDetaOption,allConOption } = this.state
for (const key in params) {
if (isBlank(params[key])) {
delete params[key]
}
}
if (isBlank(params)) {
this.setState({ conDetaOption: allConOption })
return
}
conDetaOption = conDetaOption.filter(item=>{
for (const key in params) {
return R.includes(params[key],item[key])
}
return true
})
this.setState({conDetaOption,isShowFilterModal:false})
}
// 返回搜索元素 // 返回搜索元素
renderSearchItem() { renderSearchItem() {
return ( return (
...@@ -428,9 +456,20 @@ class ConsumDetailsPage extends Component { ...@@ -428,9 +456,20 @@ class ConsumDetailsPage extends Component {
{ this.renderSearchItem() } { this.renderSearchItem() }
{ this.renderContItem() } { this.renderContItem() }
{this.renderLodingItem()} {this.renderLodingItem()}
<FilterModal
show={this.state.isShowFilterModal}
filterSubmitCheck={(params) => { this.filterSubmitCheck(params) }}
/>
</View> </View>
{this.renderFooterBtnItem()} {this.renderFooterBtnItem()}
</SafeAreaView> </SafeAreaView>
<TouchableOpacity
activeOpacity={0.8}
style={styles.filter}
onPress={()=>this.showFilterModal(!this.state.isShowFilterModal)}
>
<Image source={require('../../../images/filter_icon.png')} style={icon_style}></Image>
</TouchableOpacity>
</View> </View>
); );
} }
...@@ -444,7 +483,8 @@ const styles = StyleSheet.create({ ...@@ -444,7 +483,8 @@ const styles = StyleSheet.create({
margin: 0 margin: 0
}, },
cu_dl_main: { cu_dl_main: {
flex: 1 flex: 1,
position:'relative'
}, },
list_cont: { list_cont: {
flex: 1 flex: 1
...@@ -522,6 +562,13 @@ const styles = StyleSheet.create({ ...@@ -522,6 +562,13 @@ const styles = StyleSheet.create({
top: 20, top: 20,
width: pxSize(22), width: pxSize(22),
height: pxSize(22), height: pxSize(22),
},
filter:{
position:'absolute',
top:15,
right:10,
width:pxSize(30),
height:pxSize(30)
} }
}) })
......
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
} from '../../base/BaseStyle' } from '../../base/BaseStyle'
import { exitLoginStatus, requestSysProfile, setNavigation } from '../../action/LoginAction' import { exitLoginStatus, requestSysProfile, setNavigation } from '../../action/LoginAction'
import { getSettlementStatus, getInvoiceStatus } from '../../action/SettlementAction' import { getSettlementStatus, getInvoiceStatus } from '../../action/SettlementAction'
import { getOrganizations } from '../../../src/action/consumeAction'
import HeadBackItem from '../common/HeadBackItem' import HeadBackItem from '../common/HeadBackItem'
import StatusBarView from '../common/StatusBarView' import StatusBarView from '../common/StatusBarView'
import TabBottomItem from './module/TabBottomItem' import TabBottomItem from './module/TabBottomItem'
...@@ -115,6 +116,7 @@ class HomePage extends Component { ...@@ -115,6 +116,7 @@ class HomePage extends Component {
this.getSysConfigValue() this.getSysConfigValue()
this.props.setNavigation(this.props.navigation) this.props.setNavigation(this.props.navigation)
this.getSettlementStatus() this.getSettlementStatus()
this.props.getOrganizations()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
...@@ -350,6 +352,9 @@ const mapDispatchToProps = dispatch => ({ ...@@ -350,6 +352,9 @@ const mapDispatchToProps = dispatch => ({
getInvoiceStatus: () => { getInvoiceStatus: () => {
dispatch(getInvoiceStatus()) dispatch(getInvoiceStatus())
}, },
getOrganizations: () => {
dispatch(getOrganizations())
},
}) })
export default connect(mapStateToProps, mapDispatchToProps)(HomePage) export default connect(mapStateToProps, mapDispatchToProps)(HomePage)
...@@ -37,6 +37,7 @@ export const originSysProfiles = { ...@@ -37,6 +37,7 @@ export const originSysProfiles = {
OBS_SHOW_ORG_FLAG: 'Y', OBS_SHOW_ORG_FLAG: 'Y',
SUR_MOBILE_HISTORY_SALE_PRICE_SHOW_FLAG: 'Y', SUR_MOBILE_HISTORY_SALE_PRICE_SHOW_FLAG: 'Y',
SUR_MOBILE_INV_PRODUCT_LINE_CATEGORY_FLAG: 0, SUR_MOBILE_INV_PRODUCT_LINE_CATEGORY_FLAG: 0,
OBS_MOBILE_DEPARTMENT_DISPLAY:0,
OBS_MOBILE_APP_TITLE: '骨科智慧仓' OBS_MOBILE_APP_TITLE: '骨科智慧仓'
} }
......
import {createStore, applyMiddleware, compose} from 'redux'; import {createStore, applyMiddleware, compose} from 'redux';
import thunkMiddleware from 'redux-thunk'; import thunkMiddleware from 'redux-thunk';
import rootReducer from '../reducers'; import rootReducer from '../reducers';
import srcRootReducer from '../../src/reducers/index';
import {persistStore,persistCombineReducers} from 'redux-persist'; import {persistStore,persistCombineReducers} from 'redux-persist';
import reconciler from 'redux-persist/lib/stateReconciler/autoMergeLevel2'; import reconciler from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
import storage from 'redux-persist/es/storage'; import storage from 'redux-persist/es/storage';
...@@ -17,7 +18,7 @@ const middleWares = [ ...@@ -17,7 +18,7 @@ const middleWares = [
thunkMiddleware thunkMiddleware
]; ];
const reducers = persistCombineReducers(config,rootReducer); const reducers = persistCombineReducers(config,{...rootReducer,...srcRootReducer});
const enhances = [applyMiddleware(...middleWares)]; const enhances = [applyMiddleware(...middleWares)];
......
import api from '../services/api'
import {
CONSUME_ORDER_ORG,
CONSUME_ORDER_DEPARTMENTS,
} from '../base/ActionTypes'
import * as R from 'ramda'
import { show } from '../../app/utils/Utils'
/**
* @description:获取组织
*/
export const getOrganizations = params => {
return dispatch => {
api.getOrganizations(params).then(res => {
console.log(res)
if (res.error_code === 0) {
const organizations = R.compose(R.uniqBy(R.prop('org_code')), R.pathOr([], ['data', 'organizations']))(res)
const inventories = res.data.inventories
dispatch(setOrganizationsSuccess({ organizations, inventories }))
}
})
}
}
/**
* @description:根据组织和销售员获取部门
*/
export function getDepartmentsBySellerAndOrg(params) {
return dispatch => {
api.getDepartmentsBySellerAndOrg(params).then(res => {
console.log(res)
if (res.error_code === 0) {
dispatch(setDepartments(res.data.relationships))
} else {
show(res.error_msg)
}
})
}
}
export function setOrganizationsSuccess(data) {
return {
type: CONSUME_ORDER_ORG,
orgData: data,
}
}
export function setDepartments(data) {
return {
type: CONSUME_ORDER_DEPARTMENTS,
departmentsData: data,
}
}
/**
* @description:组织数据转换option
* @param {} organizations
* @returns
*/
export function getOrgOption(organizations) {
return R.map(
R.applySpec({
label: R.prop('org_name'),
value: R.prop('org_code'),
}),
)(organizations)
}
/**
* @description:部门数据转换option
* @param {} departmentsOption
* @returns
*/
export function getDepartmentsOption(departments) {
return R.map(
R.applySpec({
label: R.prop('department_name'),
value: R.prop('department_code'),
}),
)(departments)
}
/**
* @description:客户数据转换option
* @param {} departmentsOption
* @returns
*/
export function getCustomersOption(customers) {
return R.map(
R.applySpec({
label: R.prop('customer_name'),
value: R.prop('customer_code'),
}),
)(customers)
}
\ No newline at end of file
//-----------consume---------------------------
export const CONSUME_ORDER_ORG = 'CONSUME_ORDER_ORG'
export const CONSUME_ORDER_DEPARTMENTS = 'CONSUME_ORDER_DEPARTMENTS'
\ No newline at end of file
...@@ -18,7 +18,7 @@ export default class Resolution { ...@@ -18,7 +18,7 @@ export default class Resolution {
let pxRatio = PixelRatio.get() let pxRatio = PixelRatio.get()
let { width, height } = Dimensions.get(dim) let { width, height } = Dimensions.get(dim)
if (dim != 'screen') height -= navHeight if (dim != 'screen') height -= navHeight
designSize.width = width // 设置为屏幕宽度
let w = PixelRatio.getPixelSizeForLayoutSize(width) let w = PixelRatio.getPixelSizeForLayoutSize(width)
let h = PixelRatio.getPixelSizeForLayoutSize(height) let h = PixelRatio.getPixelSizeForLayoutSize(height)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
height 100% height 100%
&-item &-item
width 378px width 100%
height 58px height 58px
background-color #fff background-color #fff
padding 0 18px padding 0 18px
......
...@@ -92,7 +92,7 @@ export default class Form extends Component<IProps> { ...@@ -92,7 +92,7 @@ export default class Form extends Component<IProps> {
if (rule.required && isBlank(data[item.field])) { if (rule.required && isBlank(data[item.field])) {
return this.setState({ canSubmit: false }) return this.setState({ canSubmit: false })
} }
if (rule.pattern && R.complement(R.test)(rule.pattern, data[item.field])) { if (rule.pattern && !R.test(rule.pattern, data[item.field])) {
return this.setState({ canSubmit: false }) return this.setState({ canSubmit: false })
} }
} }
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { View, Text, ScrollView, TouchableOpacity, Image } from 'react-native' import { View, Text, ScrollView, TouchableOpacity, Image } from 'react-native'
import { inject, observer } from 'mobx-react'
import { IFormField, ISurgeryCollectLine } from 'bonehouse' import { IFormField, ISurgeryCollectLine } from 'bonehouse'
import * as R from 'ramda' import * as R from 'ramda'
import { g, isBlank, isNotBlank } from '../../../utils/utils' import { g, isBlank, isNotBlank } from '../../../utils/utils'
...@@ -25,12 +24,12 @@ export default (props: IProps) => { ...@@ -25,12 +24,12 @@ export default (props: IProps) => {
<Text style={g(styles, 'bd-title')}>耗材({R.length(value || [])})</Text> <Text style={g(styles, 'bd-title')}>耗材({R.length(value || [])})</Text>
{value.map((val, idx) => { {value.map((val, idx) => {
return ( return (
<View style={g(styles, 'item')} key={val.serialNumber}> <View style={g(styles, 'item')} key={val.serial_number}>
<Text style={g(styles, 'item-title')}> <Text style={g(styles, 'item-title')}>
{idx + 1}. {val.itemName} {idx + 1}. {val.item_name}
</Text> </Text>
<Text style={g(styles, 'item-text')}>序列号: {val.serialNumber}</Text> <Text style={g(styles, 'item-text')}>序列号: {val.serial_number}</Text>
<Text style={g(styles, 'item-text')}>单价(¥): {val.salePrice}</Text> <Text style={g(styles, 'item-text')}>单价(¥): {val.sale_price}</Text>
</View> </View>
) )
})} })}
......
import React, { Component } from 'react'
import {
View,
Text,
Modal,
SafeAreaView,
TextInput,
StyleSheet,
TouchableOpacity,
Image,
ScrollView,
} from 'react-native'
import StatusBarView from '../../../../app/containers/common/StatusBarView'
import HeadBackItem from '../../../../app/containers/common/StatusBarView'
import DateModel from '../../../../app/containers/common/DateModel'
import DialogModel from '../../../../app/containers/common/DialogModel'
import { SelectModal } from '../../../components/form/select-modal'
import { g } from '../../../utils/utils'
import styles from './filterModal.styl'
import { pxSize } from '../../../assets/styles/base'
type Iprops = {}
class Filter extends Component<Iprops> {
constructor(props) {
super(props)
this.state = {
isVisible: false,
dateModelPop: false,
currentDateVal: new Date(), // 当前日期值
currentTitle: '',
filterParams: {
surgery_collect_number: '',
collected_date_start: '',
collected_date_end: '',
surgery_name: '',
remark: '',
},
}
}
componentWillReceiveProps(nextProps) {
let { isVisible } = this.state
if (isVisible != nextProps.show) {
this.setState({
isVisible: nextProps.show,
})
}
}
handleSearchInput(text, typeName) {
const { filterParams } = this.state
if (typeName === 'sur_order') {
} else if (typeName === 'sur_order') {
}
switch (typeName) {
case 'sur_order':
filterParams.surgery_collect_number = text
break
case 'sur_name':
filterParams.surgery_name = text
break
case 'remark':
filterParams.remark = text
break
default:
break
}
this.setState({ filterParams })
}
/**
* @description:日期弹窗
*/
handleSurDateCheck(typeName) {
let { currentTitle } = this.state
currentTitle = typeName
this.setState({ dateModelPop: true, currentTitle })
}
/**
* @description:关闭日期弹窗
*/
closeDateModal() {
this.setState({ dateModelPop: false })
}
/**
* @description:日期选择回调
*/
dateModalCallback(date) {
let { currentTitle, filterParams } = this.state
if (currentTitle === 'start') {
filterParams.collected_date_start = date
this.setState({ filterParams })
} else {
filterParams.collected_date_end = date
this.setState({ filterParams })
}
}
/**
* @description:关闭弹窗
*/
closeModal() {
this.setState({
isVisible: false,
})
}
/**
* @description:重置
*/
handleSubResetCheck() {
const { filterParams } = this.state
for (const key in filterParams) {
filterParams[key] = ''
}
this.setState({ filterParams })
}
/**
* @description:确定
*/
handleFilterSubmitCheck() {
const { filterParams } = this.state
this.closeModal()
this.props.filterSubmitCheck(filterParams)
}
/**
* @description:渲染弹窗内容
* @returns
*/
renderContent() {
const { filterParams } = this.state
return (
<View style={g(styles, 'sea_wrap')}>
<View style={g(styles, 'sea_qui_select')}>
<Text style={g(styles, 'sea_qui_tit')}>快捷筛选</Text>
<View style={g(styles, 'sea_qui_box')}>
<View style={g(styles, 'qui_cell')}>
<Text style={[g(styles, 'styles.qui_cell_tit'), { width: pxSize(100) }]}>借货订单号</Text>
<TextInput
placeholder={'请输入借货订单号'}
style={g(styles, 'sea_input')}
value={filterParams.surgery_collect_number}
onChangeText={text => this.handleSearchInput(text, 'sur_order')}
/>
</View>
<View style={g(styles, 'qui_cell')}>
<Text style={[g(styles, 'styles.qui_cell_tit'), { width: pxSize(100) }]}>订单日期</Text>
<TouchableOpacity
activeOpacity={0.8}
style={g(styles, 'qui_date_box')}
onPress={() => this.handleSurDateCheck('start')}
>
<Text style={g(styles, 'qui_date_inp')}>{filterParams.collected_date_start || '开始日期'}</Text>
<View style={{ width: pxSize(14), height: pxSize(14) }}>
<Image source={require('../../../assets/images/date_icon.png')} style={g(styles, 'icon_style')} />
</View>
</TouchableOpacity>
<Text style={styles.qui_date_line}></Text>
<TouchableOpacity
activeOpacity={0.8}
style={g(styles, 'qui_date_box')}
onPress={() => this.handleSurDateCheck('end')}
>
<Text style={g(styles, 'qui_date_inp')}>{filterParams.collected_date_end || '结束日期'}</Text>
<View style={{ width: pxSize(14), height: pxSize(14) }}>
<Image source={require('../../../assets/images/date_icon.png')} style={g(styles, 'icon_style')} />
</View>
</TouchableOpacity>
</View>
<View style={g(styles, 'qui_cell')}>
<Text style={[g(styles, 'styles.qui_cell_tit'), { width: pxSize(100) }]}>手术名称</Text>
<TextInput
placeholder={'请输入手术名称'}
style={g(styles, 'sea_input')}
value={filterParams.surgery_name}
onChangeText={text => this.handleSearchInput(text, 'sur_name')}
/>
</View>
<View style={g(styles, 'qui_cell')}>
<Text style={[g(styles, 'styles.qui_cell_tit'), { width: pxSize(100) }]}>备注</Text>
<TextInput
placeholder={'请输入备注'}
style={g(styles, 'sea_input')}
value={filterParams.remark}
onChangeText={text => this.handleSearchInput(text, 'remark')}
/>
</View>
</View>
</View>
<View style={g(styles, 'sea_btn_box')}>
<TouchableOpacity
activeOpacity={0.9}
style={g(styles, 'sea_btn_inner', 'sea_btn_lef')}
onPress={() => this.handleSubResetCheck()}
>
<Text style={[styles.sea_btn_tit, styles.sea_btn_reset]}>重置</Text>
</TouchableOpacity>
<TouchableOpacity
activeOpacity={0.9}
style={g(styles, 'sea_btn_inner')}
onPress={() => this.handleFilterSubmitCheck()}
>
<Text style={styles.sea_btn_tit}>确定</Text>
</TouchableOpacity>
</View>
</View>
)
}
render(): React.ReactNode {
let { navigation } = this.props
const { isVisible, dateModelPop, currentDateVal } = this.state
return (
<>
{isVisible ? (
<View style={g(styles, 'dia_container')}>
{this.renderContent()}
<DateModel
date={currentDateVal}
closeModal={show => this.closeDateModal(show)}
show={dateModelPop}
callback={date => this.dateModalCallback(date)}
date_mode={'date'}
/>
</View>
) : null}
</>
)
}
}
export default Filter
@import '../../../assets/styles/base.styl'
@import '../../../assets/styles/variable.styl'
.dia_container
flex: 1
position absolute
// top: 118px
left: 0
width: 100%
height: 120%
z-index: 199
background-color: rgba(0 0, 0, 0.5)
.container
flex: 1
.sea_wrap
background-color #F5F5F5
padding: 10px 15px
.sea_qui_tit
color: first_text_color
font-size second_text_size
font-family: font_family_medium
margin-top 22px
.qui_cell
flex-direction: row
justify-content space-between
align-items center
margin-top: 10px
.qui_cell_tit
color: first_text_color
font-size 14px
font-family font_family_regular
.qui_cell_rig
flex: 1
height: 40
background-color: foundation_color
flex-direction: row
align-items center
justify-content flex-end
padding: 6px 0
.arr_icon_box
margin-left 6px
.icon_style
@extend .icon
.sea_btn_box
flex-direction: row
margin-top: 10px
.sea_btn_inner
background-color primary_color
width: 50%
height: 38px
.sea_btn_lef
background-color: #E7F1FD
.sea_btn_tit
font-size 14px
font-family: font_family_regular
text-align center
line-height 36px
color: title_text_color
.sea_btn_reset
color: #007EFF
.sea_input
width: 100%
.qui_date_box
flex-direction: row
align-items center
justify-content space-evenly
width 30%
// background-color foundation_color
padding: 10px 0
.qui_date_inp
line-height 38px
color: third_text_color
font-size 14px
font-family: font_family_regular
.qui_date_line
font-size 14px
color: third_text_color
\ No newline at end of file
import React, { Component } from 'react'
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'
import { connect } from 'react-redux'
import * as R from 'ramda'
import Header from '../../components/header/header'
import Form from '../../components/form'
import {
getDepartmentsBySellerAndOrg,
getOrgOption,
getDepartmentsOption,
getCustomersOption,
} from '../../action/consumeAction'
import { setSubdetailOption, setCharDetailsOption } from '../../../app/action/EquipAction'
import api from '../../services/api'
import { g, getFormItem, isBlank, isNotBlank, show } from '../../utils/utils'
import { FieldType } from '../../enums'
import { toBinaryNumber } from '../../utils/utils'
import Consumables from '../consume/components/selected-consumables'
import { toLine } from '../../utils/transform'
type Iprops = {
navigation: any
token: string
getDepartmentsBySellerAndOrg: Function
getOrgOption: Function
setSubdetailOption: Function
setCharDetailsOption: Function
userInfo: {
person_name: string
user_name: string
}
org: {
organizations: Object
}
departments: []
customers: []
sysProfiles: {
OBS_MOBILE_DEPARTMENT_DISPLAY: string | number
}
}
class Consume extends Component<Iprops> {
constructor(props) {
super(props)
this.setData = this.setData.bind(this)
this.submitHandler = this.submitHandler.bind(this)
}
state = {
data: {
sellerCode: this.props.userInfo.user_name,
},
formItems: [
{
field: 'sellerCode',
label: '销售员',
type: FieldType.SELECT,
options: [
{
label: this.props.userInfo.person_name,
value: this.props.userInfo.user_name,
},
],
placeholder: '请选择',
rules: [{ required: true, message: '请选择销售员' }],
disabled: true,
},
{
field: 'orgCode',
label: '组织',
type: FieldType.SELECT,
options: getOrgOption(this.props.org.organizations),
placeholder: '请选择',
rules: [{ required: true, message: '请选择组织' }],
callback: this.setOrgCallback.bind(this),
},
{
field: 'customerCode',
label: '客户',
type: FieldType.SELECT,
options: [],
placeholder: '请选择',
rules: [{ required: true, message: '请选择客户' }],
refrence: ['orgCode'],
// callback: this.setCustomerCallback.bind(this),
},
{
field: 'consumeDate',
label: '消耗时间',
type: FieldType.DATE,
dateMode: 'datetime',
options: [],
placeholder: '请选择',
rules: [{ required: true, message: '请选择消耗时间' }],
},
{
field: 'patientName',
label: '患者姓名',
type: FieldType.TEXT,
placeholder: '请输入患者姓名',
rules: [{ required: true, message: '请输入患者姓名' }],
},
{
field: 'patientGender',
label: '性别',
type: FieldType.SELECT,
options: [
{
label: '男',
value: '男',
},
{
label: '女',
value: '女',
},
],
placeholder: '请选择',
rules: [{ required: true, message: '请选择性别' }],
},
{
field: 'patientAge',
label: '年龄',
type: FieldType.TEXT,
placeholder: '请输入年龄',
rules: [
{ required: true, message: '请输入年龄' },
{ pattern: /\d{1,3}/, message: '请输入正确的年龄' },
],
},
{
field: 'patientBed',
label: '床位',
type: FieldType.TEXT,
placeholder: '请输入床位',
rules: [{ required: true, message: '请输入床位' }],
},
{
field: 'patientId',
label: '病历号',
type: FieldType.TEXT,
placeholder: '请输入病历号',
rules: [{ required: true, message: '请输入病历' }],
},
{
field: 'remark',
label: '备注',
type: FieldType.TEXT,
placeholder: '请输入备注',
multiline: true,
rules: [],
},
{
field: 'lines',
label: '耗材明细',
type: FieldType.CUSTOM, // 自定义类型
component: Consumables, // ReactElement
customHandler: this.orderBeforeHandler.bind(this, 'lines'),
rules: [{ required: true, message: '请选择耗材' }],
refrence: ['orgCode'],
},
{
field: 'imgUrl',
label: '添加图片',
type: FieldType.IMAGE,
},
],
fees: [],
}
async componentDidMount() {
this.initSetOptsValue()
}
componentWillReceiveProps(nextProps) {
const { data } = this.state
data.lines = nextProps.subDetOption
this.formRef.checkCanSubmit()
}
// 初始化数据
initSetOptsValue() {
let { props } = this
props.setSubdetailOption([])
props.setCharDetailsOption([])
}
/**
* @description: 设置修改值
* @param {*} key
* @param {*} value
* @return {*}
*/
setData(key: string, value: any) {
return new Promise<any>((resolve, reject) => {
const { data, formItems } = this.state
data[key] = value
this.setState({ data }, () => {
const item = getFormItem(formItems, key)
console.log(item)
item && item.callback && item.callback()
resolve()
})
})
}
/**
* @description: 选择完组织
* @param {*}
* @return {*}
*/
setOrgCallback() {
const { OBS_MOBILE_DEPARTMENT_DISPLAY } = this.props.sysProfiles
if (R.pathEq([0], '1', toBinaryNumber(OBS_MOBILE_DEPARTMENT_DISPLAY))) {
// 获取部门
// this.getDepartments.call(this)
}
// 获取客户列表
this.getCustomers.call(this)
this.props.setSubdetailOption([])
}
/**
* @description: 获取部门
* @param {*}
* @return {*}
*/
async getDepartments() {
const { data, formItems } = this.state
const { orgCode, sellerCode } = data
let departments = getDepartmentsOption(this.props.departments)
const item: any = getFormItem(formItems, 'departmentCode')
if (isBlank(item)) return
if (isBlank(departments)) {
item.loading = true
await this.props.getDepartmentsBySellerAndOrg({ org_code: orgCode, seller_code: sellerCode })
item.loading = false
getDepartmentsOption(this.props.departments)
}
// item.options = departments
this.setState({ formItems })
}
/**
* 获取客户列表
*/
async getCustomers() {
const { data, formItems } = this.state
const { orgCode, sellerCode } = data
let customers = []
const item: any = getFormItem(formItems, 'customerCode')
if (isBlank(item)) return
item.loading = true
const res: any = await api.getCustomers({ seller_code: sellerCode, org_code: orgCode })
if (res.error_code === 0) {
customers = getCustomersOption(res.data.customers)
}
item.loading = false
item.options = customers
this.setState({ formItems })
}
/**
* @description: 依赖项检查
* @param {*} itemName
* @return {*}
*/
refrenceCheck(itemName: string) {
const { data, formItems } = this.state
const item = R.find(R.propEq('field', itemName))(formItems)
if (isBlank(item)) {
return true
}
// 需要先选择依赖的字段
for (const ref of item.refrence || []) {
if (isBlank(data[ref])) {
const field = R.find(R.propEq('field', ref))(formItems)
if (isNotBlank(field)) {
show(`请先选择${field.label}`)
return false
}
}
}
return true
}
/**
* @description: 获取消耗费用
* @param {*}
* @return {*}
*/
async getConsumeFeeLines() {
const params = {
access_token: this.props.token,
// surgery_collect_number: 'SC20220228000001',
// app_code: 'APP',
}
try {
const res: any = await api.getFeeLines(params)
console.log(res)
this.setState({ fees: res.data })
if (res.error_code !== 0) return {}
return res.data
} catch (error) {
console.log(error)
return {}
}
}
/**
* @description: 添加消耗明细跳转前处理
* @param {*}
* @return {*}
*/
orderBeforeHandler(itemName: string) {
if (!this.refrenceCheck(itemName)) return
const { data } = this.state
this.props.navigation.navigate('ConsumDetailsPage', {
title: '器械消耗 - 添加明细',
// orderId: listOptionData[3].value,
// userEnteredPrice
})
}
/**
* @description: 提交
*/
async submitHandler() {
const { data } = this.state
data.lines = R.map(R.assoc('consumed_quantity', 1))(data.lines)
for (const key in data) {
const newKey = toLine(key)
data[newKey] = data[key]
}
console.log(data)
const params = R.compose(
R.map(item => {
return {
...data,
lines: item,
surgery_collect_number: item[0].surgery_collect_number,
}
}),
R.groupWith((a: any, b: any) => a.surgery_collect_number === b.surgery_collect_number),
R.sort(R.descend(R.prop('surgery_collect_number'))),
)(data.lines)
console.log(params)
const res = await api.createConsumeOrder({ data: params })
console.log(res)
if (res.error_code === 0) {
this.props.navigation.navigate('Success', {
orderNumber: res.data.join(','),
title: '器械消耗',
})
} else {
show(res.error_msg)
}
}
render() {
const { navigation } = this.props
const { data, formItems } = this.state
console.log(this.props.userInfo)
const title = navigation.getParam('title', '骨科智慧仓')
return (
<View style={styles.container}>
<Header
title={title}
backCallback={() => {
navigation.goBack()
}}
/>
{/* form表单 */}
<Form
fields={formItems}
data={data}
onChange={this.setData}
ref={ref => (this.formRef = ref)}
submitHandler={this.submitHandler}
/>
</View>
)
}
}
const mapStateToProps = state => ({
token: state.login.token,
userInfo: state.login.userInfo,
sysProfiles: state.login.sysProfiles,
org: state.consume.org,
departments: state.consume.departments,
subDetOption: state.equip.subDetOption,
})
const mapDispatchToProps = (dispatch: any) => {
return {
getDepartmentsBySellerAndOrg: (params: any) => {
dispatch(getDepartmentsBySellerAndOrg(params))
},
setSubdetailOption: (data: any) => {
dispatch(setSubdetailOption(data))
},
setCharDetailsOption: (data: any) => {
dispatch(setCharDetailsOption(data))
},
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
})
export default connect(mapStateToProps, mapDispatchToProps)(Consume)
...@@ -38,7 +38,7 @@ export default ({ navigation }) => { ...@@ -38,7 +38,7 @@ export default ({ navigation }) => {
setTimeout( setTimeout(
() => { () => {
hide && hide() hide && hide()
navigation.navigate('Main') navigation.navigate('HomePage')
}, },
hide ? 1000 : 0, hide ? 1000 : 0,
) )
......
import storage from 'redux-persist/es/storage'
import { persistReducer } from 'redux-persist'
import consume from './module/consumeConfig'
const consumeConfig = {
key: 'consume',
storage,
debug: false,
blackList: [],
}
const rootReducer = {
consume: persistReducer(consumeConfig, consume),
}
export default rootReducer
import {
CONSUME_ORDER_ORG,
CONSUME_ORDER_DEPARTMENTS,
} from '../../base/ActionTypes'
// 快速下单状态
const defaultState = {
consum_list_status: CONSUME_ORDER_ORG, // 获取数据状态
// submit_quick_order_status: QUICK_SUBMIT_NO, // 提交订单状态
org: {}, // 组织数据
departments: [], // 部门数据
}
const consume = (state = defaultState, action: any) => {
switch (action.type) {
case CONSUME_ORDER_ORG:
return Object.assign({}, state, {
org: action.orgData,
})
case CONSUME_ORDER_DEPARTMENTS:
return Object.assign({}, state, {
departments: action.departmentsData,
})
default:
return state
}
}
export default consume
...@@ -25,6 +25,16 @@ export default { ...@@ -25,6 +25,16 @@ export default {
}, },
/** /**
* @description: 根据组织和销售员获取部门信息
* @param {object} data
* @return {*}
*/
getDepartmentsBySellerAndOrg(data: { org_ode: string; seller_ode: string; scopeFlag: string }) {
return request({ url: `${v}/sale/sale_relationship/search`, data })
},
/**
* @description: 请求客户 * @description: 请求客户
* @param {*} * @param {*}
* @return {*} * @return {*}
...@@ -132,4 +142,31 @@ export default { ...@@ -132,4 +142,31 @@ export default {
}) { }) {
return request({ url: `${v}/consume/update`, data, method: `POST` }) return request({ url: `${v}/consume/update`, data, method: `POST` })
}, },
/**
* @description: 获取借货订单行
* @param {*} data
* @return {*}
*/
getCollectOrderLines(data?: { surgeryCollectNumber: string }) {
return request({ url: `${v}/surgery/collected_order_line/search`, data })
},
/**
* @description:获取费用明细
* @param data
* @returns
*/
getFeeLines(data?: { surgery_collect_number?: string }) {
return request({ url: `${v}/surgery/consume_fee_line/search`, data })
},
/**
* @description: 按组创建消耗订单
* @param {any} data
* @return {*}
*/
createConsumeOrder(data: any) {
return request({ url: `${v}/surgery/consume_group_order/create`, data, method: 'post' })
}
} }
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