Commit 59970bc2 by wong.peiyi

消耗确认

parent 17eac387
...@@ -79,6 +79,9 @@ ...@@ -79,6 +79,9 @@
align-self center align-self center
margin-bottom 30px margin-bottom 30px
&__inner
@extend .row
&__disabled &__disabled
background-color #BBBBBB background-color #BBBBBB
...@@ -89,3 +92,6 @@ ...@@ -89,3 +92,6 @@
&__disabled &__disabled
color rgba(255, 255, 255, 0.5) color rgba(255, 255, 255, 0.5)
.ml10
margin-left 10px
...@@ -20,6 +20,7 @@ import ImageForm from './image' ...@@ -20,6 +20,7 @@ import ImageForm from './image'
import { g, isBlank, show, debounce } from '../../utils/utils' import { g, isBlank, show, debounce } from '../../utils/utils'
import Consumables from '../../pages/consume/selected-consumables' import Consumables from '../../pages/consume/selected-consumables'
import styles from './index.styl' import styles from './index.styl'
import { ActivityIndicator } from '@ant-design/react-native'
type IProps = { type IProps = {
fields: IFromField[] fields: IFromField[]
...@@ -104,7 +105,7 @@ export default class Form extends Component<IProps> { ...@@ -104,7 +105,7 @@ export default class Form extends Component<IProps> {
render() { render() {
const { fields = [], data = {} } = this.props const { fields = [], data = {} } = this.props
const { scrollable, modal, canSubmit } = this.state const { scrollable, modal, canSubmit, submiting } = this.state
return ( return (
<View style={g(styles, 'container')}> <View style={g(styles, 'container')}>
...@@ -131,19 +132,34 @@ export default class Form extends Component<IProps> { ...@@ -131,19 +132,34 @@ export default class Form extends Component<IProps> {
})} })}
<TouchableOpacity <TouchableOpacity
style={g(styles, { 'submit-btn': true, 'submit-btn__disabled': !canSubmit })} style={g(styles, {
disabled={!canSubmit} 'submit-btn': true,
'submit-btn__disabled': !canSubmit || submiting,
})}
disabled={!canSubmit || submiting}
activeOpacity={0.8} activeOpacity={0.8}
onPress={this.submitHandler} onPress={this.submitHandler}
> >
<Text {submiting ? (
style={g(styles, { <View style={g(styles, 'submit-btn__inner')}>
'submit-btn__text': true, <ActivityIndicator
'btn-primary__text__disabled': !canSubmit, style={g(styles, 'submit-btn__loading')}
})} color="rgba(255,255,255,0.5)"
> />
提交 <Text style={g(styles, 'submit-btn__text', 'submit-btn__text__disabled', 'ml10')}>
</Text> 提交中
</Text>
</View>
) : (
<Text
style={g(styles, {
'submit-btn__text': true,
'submit-btn__text__disabled': !canSubmit,
})}
>
提交
</Text>
)}
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</ScrollView> </ScrollView>
......
...@@ -66,7 +66,6 @@ class Consume extends Component<IProps> { ...@@ -66,7 +66,6 @@ class Consume extends Component<IProps> {
} }
state = { state = {
scrollable: true,
data: { data: {
sellerCode: this.props.userStore.userName, sellerCode: this.props.userStore.userName,
}, },
...@@ -211,6 +210,7 @@ class Consume extends Component<IProps> { ...@@ -211,6 +210,7 @@ class Consume extends Component<IProps> {
componentWillUnmount() { componentWillUnmount() {
this.props.consumeStore.resetOrderLines() this.props.consumeStore.resetOrderLines()
this.props.consumeStore.setSelectedLines([]) this.props.consumeStore.setSelectedLines([])
console.log('Consume page will unmount')
} }
/** /**
...@@ -502,10 +502,19 @@ class Consume extends Component<IProps> { ...@@ -502,10 +502,19 @@ class Consume extends Component<IProps> {
* @description: 提交 * @description: 提交
*/ */
async submitHandler() { async submitHandler() {
const { data } = this.state const { data, submitting } = this.state
data.lines = R.map(R.assoc('consumedQuantity', 1))(data.lines) data.lines = R.map(R.assoc('consumedQuantity', 1))(data.lines)
const res = await this.props.consumeStore.submit(data) const res = await this.props.consumeStore.submit({ data })
if (res.errorCode === 0) {
this.props.navigation.navigate('Success', {
orderNumber: res.consumeOrderNumber,
title: '器械消耗',
})
} else {
show(res.errorMsg)
}
} }
render() { render() {
......
...@@ -73,7 +73,7 @@ class Index extends Component<IProps> { ...@@ -73,7 +73,7 @@ class Index extends Component<IProps> {
navigateToBizPage(fun: IFunction) { navigateToBizPage(fun: IFunction) {
const pages = { const pages = {
MOBILE_BORROW_ORDER: '', MOBILE_BORROW_ORDER: '',
MOBILE_SELF_HELP_ORDER: '', MOBILE_SELF_HELP_ORDER: 'Success',
MOBILE_CONSUMP_CONFIRMA: 'Consume', MOBILE_CONSUMP_CONFIRMA: 'Consume',
MOBILE_DEVICE_INFORMATION: '', MOBILE_DEVICE_INFORMATION: '',
MOBILE_TRANSFER_APPLICATION: '', MOBILE_TRANSFER_APPLICATION: '',
......
@import '../../assets/styles/base.styl'
@import '../../assets/styles/variable.styl'
.body
flex 1
justify-content center
align-items center
.success
&-title
margin-top 10px
font-size 17px
color primary_text_color
font-family font_family_medium
&-text
margin-top 21px
font-size 14px
color second_text_color
font-family font_family_regular
.btn
width 333px
height 50px
border-radius 25px
background-color primary_color
justify-content center
align-items center
margin-top 38px
margin-bottom 100px
&-text
color btn_color
font-size 17px
font-family font_family_regular
import React, { Component } from 'react'
import { View, Text, ScrollView, Clipboard, Image, TouchableOpacity } from 'react-native'
import { IOrganization, ISurgeryCollectHeader, IFee } from 'bonehouse'
import * as R from 'ramda'
import Header from '../../components/header/header'
import { g, getFormItem, isBlank, isNotBlank, show } from '../../utils/utils'
import styles from './success.styl'
type IProps = {
navigation: any
}
export default ({ navigation }) => {
const { orderNumber, title } = navigation.state.params
return (
<View style={g(styles, 'container')}>
<Header title={title} backCallback={() => navigation.navigate('Main')} />
<View style={g(styles, 'body')}>
<Image
style={g(styles, 'success-icon')}
source={require('../../assets/images/cor_green.png')}
></Image>
<Text style={g(styles, 'success-title')}>提交成功</Text>
<Text style={g(styles, 'success-text')}>订单号:{orderNumber || '未知订单号'}</Text>
<TouchableOpacity
style={g(styles, 'btn')}
activeOpacity={0.8}
onPress={async () => {
let hide
if (orderNumber) {
Clipboard.setString(orderNumber)
await Clipboard.getString()
hide = show('复制成功')
}
setTimeout(
() => {
hide && hide()
navigation.navigate('Main')
},
hide ? 1000 : 0,
)
}}
>
<Text style={g(styles, 'btn-text')}>复制订单号并返回主页</Text>
</TouchableOpacity>
</View>
</View>
)
}
...@@ -14,6 +14,7 @@ import Signin from './pages/signin/signin' ...@@ -14,6 +14,7 @@ import Signin from './pages/signin/signin'
import Consume from './pages/consume/consume' import Consume from './pages/consume/consume'
import Consumables from './pages/consume/consumables' import Consumables from './pages/consume/consumables'
import ConsumeFee from './pages/consume/fee' import ConsumeFee from './pages/consume/fee'
import Success from './pages/success/success'
function createNavigator() { function createNavigator() {
const options = { const options = {
...@@ -88,6 +89,7 @@ function createNavigator() { ...@@ -88,6 +89,7 @@ function createNavigator() {
Consume: { screen: Consume }, Consume: { screen: Consume },
Consumables: { screen: Consumables }, Consumables: { screen: Consumables },
ConsumeFee: { screen: ConsumeFee }, ConsumeFee: { screen: ConsumeFee },
Success: { screen: Success },
}, },
{ initialRouteName: 'Main', ...options }, { initialRouteName: 'Main', ...options },
) )
......
...@@ -56,8 +56,16 @@ export const request = (args: Partial<RequestConfig>) => { ...@@ -56,8 +56,16 @@ export const request = (args: Partial<RequestConfig>) => {
...args, ...args,
} }
if (options.needToken) { if (options.needToken && store.token) {
options.data.accessToken = store.token options.data.accessToken = store.token
if (options.method.toUpperCase() === 'POST') {
const token = 'access_token=' + store.token
options.url += R.ifElse(
R.includes('?'),
R.always('&' + token),
R.always('?' + token),
)(options.url)
}
} }
args.data = transformObject(options.data, 'toLine') args.data = transformObject(options.data, 'toLine')
......
...@@ -105,6 +105,11 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio ...@@ -105,6 +105,11 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio
toast = null toast = null
}, },
}) })
return () => {
if (isNotBlank(toast)) {
Toast.hide(toast)
}
}
} }
const X_WIDTH = 375 const X_WIDTH = 375
......
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