Commit ec53b230 by peii

添加音频及快速下单选项

parent 79296dfb
...@@ -31,3 +31,32 @@ ...@@ -31,3 +31,32 @@
&__text &__text
font-size second_text_size font-size second_text_size
color #333 color #333
.recorded
@extend .row
align-items center
&-item
background-color home_background_color
padding 10px
border-radius 10px
&__text
font-size second_text_size
font-family font_family_regular
&__delete
padding 0 8px
background-color primary_color
height 22px
@extend .middle
border-radius 5px
margin-left 20px
&-text
font-size third_text_size
color #fff
line-height 22px
.unactive
display none
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/components/form/audio.tsx * @FilePath: /BoneHouse_Business_APP/src/components/form/audio.tsx
* @Author: peii * @Author: peii
* @Date: 2021-06-19 22:37:22 * @Date: 2021-06-19 22:37:22
* @LastEditTime: 2021-06-27 15:46:04 * @LastEditTime: 2021-06-30 00:29:20
* @LastEditors: peii * @LastEditors: peii
* @Vision: 1.0 * @Vision: 1.0
* @Description: 录音组件 * @Description: 录音组件
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
// @ts-nocheck // @ts-nocheck
import React, { Component } from 'react' import React, { Component } from 'react'
import { View, Text, Image, TouchableOpacity, ScrollView, Alert, Linking, Platform, NativeModules } from 'react-native' import { View, Text, Image, TouchableOpacity, Alert, Linking, Platform, NativeModules } from 'react-native'
import Sound from 'react-native-sound'
import { IFormField } from 'bonehouse' import { IFormField } from 'bonehouse'
import * as R from 'ramda' import * as R from 'ramda'
import { AudioRecorder, AudioUtils } from 'react-native-audio' import { AudioRecorder, AudioUtils } from 'react-native-audio'
...@@ -42,6 +43,7 @@ export default class Audio extends Component<IProps, IState> { ...@@ -42,6 +43,7 @@ export default class Audio extends Component<IProps, IState> {
recorded: false, recorded: false,
currentTime: 0, currentTime: 0,
} }
sound = null
constructor(props: IProps) { constructor(props: IProps) {
super(props) super(props)
...@@ -51,6 +53,7 @@ export default class Audio extends Component<IProps, IState> { ...@@ -51,6 +53,7 @@ export default class Audio extends Component<IProps, IState> {
this.recordHandler = this.recordHandler.bind(this) this.recordHandler = this.recordHandler.bind(this)
this.stopRecordingHandler = this.stopRecordingHandler.bind(this) this.stopRecordingHandler = this.stopRecordingHandler.bind(this)
this.deleteHandler = this.deleteHandler.bind(this) this.deleteHandler = this.deleteHandler.bind(this)
this.playHandler = this.playHandler.bind(this)
} }
componentDidMount() { componentDidMount() {
...@@ -93,12 +96,10 @@ export default class Audio extends Component<IProps, IState> { ...@@ -93,12 +96,10 @@ export default class Audio extends Component<IProps, IState> {
if (!isAuthor) return this.openAppSetting() if (!isAuthor) return this.openAppSetting()
this.setState({ hasPermission: isAuthor }) this.setState({ hasPermission: isAuthor })
this.prepareRecordingPath(this.state.audioPath) // this.prepareRecordingPath(this.state.audioPath)
// 录音进展 // 录音进展
AudioRecorder.onProgress = data => { AudioRecorder.onProgress = data => {
console.log(data)
this.setState({ this.setState({
currentTime: Math.ceil(data.currentTime), currentTime: Math.ceil(data.currentTime),
}) })
...@@ -106,7 +107,7 @@ export default class Audio extends Component<IProps, IState> { ...@@ -106,7 +107,7 @@ export default class Audio extends Component<IProps, IState> {
// 完成录音 // 完成录音
AudioRecorder.onFinished = data => { AudioRecorder.onFinished = data => {
// data 录音数据 // data 录音数据
console.log(this.state.currentTime) console.log(data)
} }
}) })
} }
...@@ -141,12 +142,10 @@ export default class Audio extends Component<IProps, IState> { ...@@ -141,12 +142,10 @@ export default class Audio extends Component<IProps, IState> {
try { try {
if (!this.state.hasPermission) return this.openAppSetting() if (!this.state.hasPermission) return this.openAppSetting()
if (this.state.recorded) { await this.prepareRecordingPath(this.state.audioPath)
this.prepareRecordingPath(this.state.audioPath) this.sound = null
} AudioRecorder.startRecording()
show('录音开始') show('录音开始')
await AudioRecorder.startRecording()
} catch (err) { } catch (err) {
console.error(err) console.error(err)
} }
...@@ -168,25 +167,56 @@ export default class Audio extends Component<IProps, IState> { ...@@ -168,25 +167,56 @@ export default class Audio extends Component<IProps, IState> {
} }
/** /**
* @description: 录音播放
* @param {*}
* @return {*}
*/
playHandler() {
if (this.state.playing) return
if (isBlank(this.sound)) {
this.sound = new Sound(this.state.audioPath, '', err => {
if (err) {
return show('音频加载失败')
}
this.setState({ playing: true })
this.sound.play(success => {
this.setState({ playing: false })
success ? show('播放完毕') : show('播放失败')
})
})
} else {
this.setState({ playing: true })
this.sound.play(success => {
this.setState({ playing: false })
success ? show('播放完毕') : show('播放失败')
})
}
}
/**
* @description: 删除操作 * @description: 删除操作
* @param {*} * @param {*}
* @return {*} * @return {*}
*/ */
deleteHandler() {} deleteHandler() {
this.setState({ recorded: false })
this.sound = null
}
render() { render() {
const { recorded, currentTime } = this.state const { recorded, currentTime } = this.state
return ( return (
<View style={g(styles, 'audio')}> <View style={g(styles, 'audio')}>
{!recorded ? ( <View style={g(styles, { 'not-record': true, unactive: recorded })}>
<View style={g(styles, 'not-record')}>
<Text style={g(styles, 'not-record-tip')}>还有什么要安排的,可录音备注哟!</Text> <Text style={g(styles, 'not-record-tip')}>还有什么要安排的,可录音备注哟!</Text>
<TouchableOpacity <TouchableOpacity
style={g(styles, 'record-btn')} style={g(styles, 'record-btn')}
touchableOpacity={0.8} touchableOpacity={0.8}
onLongPress={this.recordHandler} onLongPress={this.recordHandler.bind(this)}
onPressOut={this.stopRecordingHandler} onPressOut={this.stopRecordingHandler}
ref={ref => (this.recordBtnRef = ref)}
> >
<Image <Image
style={g(styles, 'record-btn__icon')} style={g(styles, 'record-btn__icon')}
...@@ -196,16 +226,14 @@ export default class Audio extends Component<IProps, IState> { ...@@ -196,16 +226,14 @@ export default class Audio extends Component<IProps, IState> {
<Text style={g(styles, 'record-btn__text')}>长按录音</Text> <Text style={g(styles, 'record-btn__text')}>长按录音</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
) : ( <View style={g(styles, { recorded: true, unactive: !recorded })}>
<View style={g(styles, 'recorded')}> <TouchableOpacity style={g(styles, 'recorded-item')} onPress={this.playHandler}>
<TouchableOpacity style={g(styles, 'recorded-item')}>
<Text style={g(styles, 'recorded-item__text')}>点击播放 {currentTime}"</Text> <Text style={g(styles, 'recorded-item__text')}>点击播放 {currentTime}"</Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity style={g(styles, 'recorded-item__delete')}> <TouchableOpacity style={g(styles, 'recorded-item__delete')} onPress={this.deleteHandler}>
<Text style={g(styles, 'recorded-item__delete-text')}>删除</Text> <Text style={g(styles, 'recorded-item__delete-text')}>删除</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
)}
</View> </View>
) )
} }
......
...@@ -17,6 +17,7 @@ import System from '../stores/system' ...@@ -17,6 +17,7 @@ import System from '../stores/system'
import User from '../stores/user' import User from '../stores/user'
import Organization from '../stores/organization' import Organization from '../stores/organization'
import Consume from '../stores/consume' import Consume from '../stores/consume'
import Order from '../stores/order'
const container = new Container({ defaultScope: 'Singleton' }) const container = new Container({ defaultScope: 'Singleton' })
...@@ -26,5 +27,6 @@ container.bind<System>(TYPES.SysStore).to(System) ...@@ -26,5 +27,6 @@ container.bind<System>(TYPES.SysStore).to(System)
container.bind<User>(TYPES.UserStore).to(User) container.bind<User>(TYPES.UserStore).to(User)
container.bind<Organization>(TYPES.OrgStore).to(Organization) container.bind<Organization>(TYPES.OrgStore).to(Organization)
container.bind<Consume>(TYPES.Consume).to(Consume) container.bind<Consume>(TYPES.Consume).to(Consume)
container.bind<Order>(TYPES.Order).to(Order)
export default container export default container
...@@ -15,4 +15,5 @@ export const TYPES = { ...@@ -15,4 +15,5 @@ export const TYPES = {
UserStore: Symbol.for('user'), UserStore: Symbol.for('user'),
OrgStore: Symbol.for('organization'), OrgStore: Symbol.for('organization'),
Consume: Symbol.for('consume'), Consume: Symbol.for('consume'),
Order: Symbol.for('order'),
} }
...@@ -10,15 +10,14 @@ ...@@ -10,15 +10,14 @@
*/ */
// @ts-nocheck // @ts-nocheck
import React, { Component } from 'react' import React, { Component } from 'react'
import { View, Text, ScrollView } from 'react-native' import { View } from 'react-native'
import { inject, observer } from 'mobx-react' import { inject, observer } from 'mobx-react'
import { toJS } from 'mobx'
import { IOrganization, ISurgeryCollectHeader, IFee } from 'bonehouse' import { IOrganization, ISurgeryCollectHeader, IFee } from 'bonehouse'
import * as R from 'ramda' import * as R from 'ramda'
import Form from '../../components/form' import Form from '../../components/form'
import { FieldType } from '../../enums' import { FieldType } from '../../enums'
import Header from '../../components/header/header' import Header from '../../components/header/header'
import { g, getFormItem, isBlank, isNotBlank, show } from '../../utils/utils' import { g, getFormItem, isBlank, isNotBlank, show, translateSysprofile } from '../../utils/utils'
import Consumables from './components/selected-consumables' import Consumables from './components/selected-consumables'
import Fees from './components/fees' import Fees from './components/fees'
import styles from './consume.styl' import styles from './consume.styl'
...@@ -222,8 +221,9 @@ class Consume extends Component<IProps> { ...@@ -222,8 +221,9 @@ class Consume extends Component<IProps> {
setOptionsFormItems() { setOptionsFormItems() {
const { sysProfiles } = this.props.sysStore const { sysProfiles } = this.props.sysStore
let { formItems } = this.state let { formItems } = this.state
let depSetting = translateSysprofile(sysProfiles.OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY)
// 部门(00)第一位显示、第二位必需 // 部门(00)第一位显示、第二位必需
if (R.pathEq(['OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY', 0], '1', sysProfiles)) { if (depSetting.show) {
formItems = R.insert( formItems = R.insert(
2, 2,
{ {
...@@ -234,7 +234,7 @@ class Consume extends Component<IProps> { ...@@ -234,7 +234,7 @@ class Consume extends Component<IProps> {
options: [], options: [],
rules: [ rules: [
{ {
required: R.pathEq(['OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY', 1], '1', sysProfiles), required: depSetting.required,
message: '请选择客户', message: '请选择客户',
}, },
], ],
...@@ -244,7 +244,8 @@ class Consume extends Component<IProps> { ...@@ -244,7 +244,8 @@ class Consume extends Component<IProps> {
) )
} }
// 跟台(00)第一位显示、第二位必需 // 跟台(00)第一位显示、第二位必需
if (R.pathEq(['OBS_MOBILE_CONSU_FOLLOW_DISPLAY', 0], '1', sysProfiles)) { const follerSetting = translateSysprofile(sysProfiles.OBS_MOBILE_CONSU_FOLLOW_DISPLAY)
if (follerSetting.show) {
const idx = R.findIndex(R.propEq('field', 'surgeryCollectNumber'))(formItems) const idx = R.findIndex(R.propEq('field', 'surgeryCollectNumber'))(formItems)
formItems = R.insert( formItems = R.insert(
idx + 1, idx + 1,
...@@ -256,7 +257,7 @@ class Consume extends Component<IProps> { ...@@ -256,7 +257,7 @@ class Consume extends Component<IProps> {
options: [], options: [],
rules: [ rules: [
{ {
required: R.pathEq(['OBS_MOBILE_CONSU_FOLLOW_DISPLAY', 1], '1', sysProfiles), required: follerSetting.required,
message: '请选择跟台员', message: '请选择跟台员',
}, },
], ],
...@@ -266,7 +267,8 @@ class Consume extends Component<IProps> { ...@@ -266,7 +267,8 @@ class Consume extends Component<IProps> {
) )
} }
// 医生(00)第一位显示、第二位必需 // 医生(00)第一位显示、第二位必需
if (R.pathEq(['OBS_MOBILE_CONSU_DOCTOR_DISPLAY', 0], '1', sysProfiles)) { const doctorSetting = translateSysprofile(sysProfiles.OBS_MOBILE_CONSU_DOCTOR_DISPLAY)
if (doctorSetting.show) {
const idx = R.findIndex(R.propEq('field', 'consumeDate'))(formItems) const idx = R.findIndex(R.propEq('field', 'consumeDate'))(formItems)
formItems = R.insert( formItems = R.insert(
idx + 1, idx + 1,
...@@ -278,7 +280,7 @@ class Consume extends Component<IProps> { ...@@ -278,7 +280,7 @@ class Consume extends Component<IProps> {
options: [], options: [],
rules: [ rules: [
{ {
required: R.pathEq(['OBS_MOBILE_CONSU_DOCTOR_DISPLAY', 1], '1', sysProfiles), required: doctorSetting.required,
message: '请输入医生姓名', message: '请输入医生姓名',
}, },
], ],
...@@ -395,11 +397,7 @@ class Consume extends Component<IProps> { ...@@ -395,11 +397,7 @@ class Consume extends Component<IProps> {
async setSurgeryCollectNumberCallback() { async setSurgeryCollectNumberCallback() {
const { data, formItems } = this.state const { data, formItems } = this.state
let followers = this.props.orgStore.followers( let followers = this.props.orgStore.followers(data.sellerCode, data.orgCode, data.departmentCode)
data.sellerCode,
data.orgCode,
data.departmentCode,
)
const orderFollower = this.props.consumeStore.orderFollower( const orderFollower = this.props.consumeStore.orderFollower(
data.sellerCode, data.sellerCode,
data.orgCode, data.orgCode,
......
...@@ -33,6 +33,9 @@ type IProps = { ...@@ -33,6 +33,9 @@ type IProps = {
// APP下单是否显示送货员权限 // APP下单是否显示送货员权限
OBS_MOBILE_DELIVERYMAN_DISPLAY: string OBS_MOBILE_DELIVERYMAN_DISPLAY: string
} }
sysValueSets: {
ORTHOPEDICS_PRODUCT_CLASS: []
}
} }
userStore: { userStore: {
userName: string userName: string
...@@ -43,10 +46,17 @@ type IProps = { ...@@ -43,10 +46,17 @@ type IProps = {
orgs: Function orgs: Function
getCustomers: Function getCustomers: Function
customers: Function customers: Function
billToSites: Function
shipToSites: Function
doctors: Function
getDepartmentsBySellerAndOrg: Function getDepartmentsBySellerAndOrg: Function
departments: Function departments: Function
followers: Function followers: Function
} }
orderStore: {
surgeryTemplates: []
getTemplates: Function
}
} }
class QuickOrder extends Component<IProps> { class QuickOrder extends Component<IProps> {
...@@ -102,7 +112,7 @@ class QuickOrder extends Component<IProps> { ...@@ -102,7 +112,7 @@ class QuickOrder extends Component<IProps> {
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择收单地点' }], rules: [{ required: true, message: '请选择收单地点' }],
refrence: ['orgCode', 'customerCode'], refrence: ['orgCode', 'customerCode'],
callback: this.setCustomerCallback.bind(this), callback: this.setBillToSitesCallback.bind(this),
}, },
{ {
field: 'shipToSiteCode', field: 'shipToSiteCode',
...@@ -111,8 +121,8 @@ class QuickOrder extends Component<IProps> { ...@@ -111,8 +121,8 @@ class QuickOrder extends Component<IProps> {
options: [], options: [],
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择收货地点' }], rules: [{ required: true, message: '请选择收货地点' }],
refrence: ['orgCode', 'customerCode'], refrence: ['orgCode', 'customerCode', 'billToSiteCode'],
// callback: this.setCustomerCallback.bind(this), callback: this.setShipToSiteCallback.bind(this),
}, },
{ {
field: 'doctorName', field: 'doctorName',
...@@ -120,19 +130,26 @@ class QuickOrder extends Component<IProps> { ...@@ -120,19 +130,26 @@ class QuickOrder extends Component<IProps> {
type: FieldType.SELECT, type: FieldType.SELECT,
options: [], options: [],
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择主治医生' }], // rules: [{ required: true, message: '请选择主治医生' }],
refrence: ['orgCode', 'customerCode'], refrence: ['orgCode', 'customerCode', 'billToSiteCode', 'shipToSiteCode'],
// callback: this.setCustomerCallback.bind(this), // callback: this.setCustomerCallback.bind(this),
}, },
{ {
field: 'surgeryTypeName', field: 'surgeryType',
label: '手术类型', label: '手术类型',
type: FieldType.SELECT, type: FieldType.SELECT,
options: [], options: R.compose(
R.map(
R.applySpec({
label: R.prop('valueName'),
value: R.prop('valueCode'),
}),
),
R.pathOr([], ['sysStore', 'sysValueSets', 'ORTHOPEDICS_PRODUCT_CLASS']),
)(this.props),
placeholder: '请选择', placeholder: '请选择',
rules: [], rules: [],
refrence: ['orgCode', 'customerCode'], callback: this.getSurgeryTemplates.bind(this),
// callback: this.setCustomerCallback.bind(this),
}, },
{ {
field: 'templateCollectNumber', field: 'templateCollectNumber',
...@@ -141,7 +158,7 @@ class QuickOrder extends Component<IProps> { ...@@ -141,7 +158,7 @@ class QuickOrder extends Component<IProps> {
options: [], options: [],
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择手术模板' }], rules: [{ required: true, message: '请选择手术模板' }],
refrence: ['orgCode', 'customerCode'], refrence: ['sellerCode', 'orgCode', 'customerCode', 'surgeryType'],
}, },
{ {
field: 'surgeryDate', field: 'surgeryDate',
...@@ -179,6 +196,8 @@ class QuickOrder extends Component<IProps> { ...@@ -179,6 +196,8 @@ class QuickOrder extends Component<IProps> {
componentDidMount() { componentDidMount() {
this.setOptionsFormItems() this.setOptionsFormItems()
console.log(toJS(this.props.sysStore.sysValueSets.ORTHOPEDICS_PRODUCT_CLASS))
} }
/** /**
...@@ -242,9 +261,128 @@ class QuickOrder extends Component<IProps> { ...@@ -242,9 +261,128 @@ class QuickOrder extends Component<IProps> {
}) })
} }
setOrgCallback() {} /**
* @description: 组织选择完回调
* @param {*}
* @return {*}
*/
async setOrgCallback() {
const sysProfiles = this.props.sysStore.sysProfiles
const { show, required } = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
if (show) {
this.getDepartments.call(this)
}
this.getCustomers.call(this)
}
/**
* @description: 获取部门列表
* @param {*}
* @return {*}
*/
async getDepartments() {
const { data, formItems } = this.state
const { orgCode, sellerCode } = data
let departments = this.props.orgStore.departments(sellerCode, orgCode)
const item = getFormItem(formItems, 'departmentCode')
if (isBlank(departments)) {
item.loading = true
await this.props.orgStore.getDepartmentsBySellerAndOrg(sellerCode, orgCode)
item.loading = false
departments = this.props.orgStore.departments(sellerCode, orgCode)
}
item.options = departments
this.setState({ formItems })
}
/**
* @description: 获取客户列表
* @param {*}
* @return {*}
*/
async getCustomers() {
const { data, formItems } = this.state
const { orgCode, sellerCode } = data
let customers = this.props.orgStore.customers(sellerCode, orgCode)
const item = getFormItem(formItems, 'customerCode')
if (isBlank(customers)) {
item.loading = true
await this.props.orgStore.getCustomers(sellerCode, orgCode)
item.loading = false
customers = this.props.orgStore.customers(sellerCode, orgCode)
}
item.options = customers
this.setState({ formItems })
}
/**
* @description: 客户选择完回调
* @param {*}
* @return {*}
*/
setCustomerCallback() {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode } = data
const billToSites = this.props.orgStore.billToSites(sellerCode, orgCode, customerCode)
const item = getFormItem(formItems, 'billToSiteCode')
item.options = billToSites
this.setState({ formItems })
}
/**
* @description: 收单地点选择完回调
* @param {*}
* @return {*}
*/
setBillToSitesCallback() {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode, billToSiteCode } = data
const shipToSites = this.props.orgStore.shipToSites(sellerCode, orgCode, customerCode, billToSiteCode)
const item = getFormItem(formItems, 'shipToSiteCode')
item.options = shipToSites
this.setState({ formItems })
}
setCustomerCallback() {} /**
* @description: 收货地点
* @param {*}
* @return {*}
*/
setShipToSiteCallback() {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode, billToSiteCode } = data
const doctors = this.props.orgStore.doctors(sellerCode, orgCode, customerCode, billToSiteCode)
const item = getFormItem(formItems, 'doctorName')
item.options = doctors
this.setState({ formItems })
}
/**
* @description: 获取手术模板
* @param {*}
* @return {*}
*/
async getSurgeryTemplates() {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode, surgeryType, doctorName } = data
const item = getFormItem(formItems, 'templateCollectNumber')
let templates = this.props.orderStore.surgeryTemplates
// if (isBlank(templates)) {
item.loading = true
await this.props.orderStore.getTemplates(sellerCode, orgCode, customerCode, surgeryType, doctorName)
item.loading = false
// }
// templates = this.props.orderStore.surgeryTemplates
// console.log(templates)
}
submitHandler() {} submitHandler() {}
...@@ -275,4 +413,4 @@ class QuickOrder extends Component<IProps> { ...@@ -275,4 +413,4 @@ class QuickOrder extends Component<IProps> {
} }
} }
export default inject('sysStore', 'userStore', 'orgStore')(observer(QuickOrder)) export default inject('sysStore', 'userStore', 'orgStore', 'orderStore')(observer(QuickOrder))
...@@ -64,10 +64,12 @@ class Signin extends Component<IProps> { ...@@ -64,10 +64,12 @@ class Signin extends Component<IProps> {
if (isBlank(username)) return show('请输入您的用户名') if (isBlank(username)) return show('请输入您的用户名')
if (isBlank(password)) return show('请输入您的密码') if (isBlank(password)) return show('请输入您的密码')
this.setState({ loading: true }) this.setState({ loading: true })
await this.props.userStore.signin(username, password) const res = await this.props.userStore.signin(username, password)
this.setState({ loading: false }) this.setState({ loading: false })
if (res) {
navigation.navigate('Main') navigation.navigate('Main')
} }
}
/** /**
* 打开域名弹窗 * 打开域名弹窗
...@@ -151,10 +153,7 @@ class Signin extends Component<IProps> { ...@@ -151,10 +153,7 @@ class Signin extends Component<IProps> {
> >
{loading ? ( {loading ? (
<> <>
<ActivityIndicator <ActivityIndicator style={g(styles, 'login-card__loading')} color="#ffffff" />
style={g(styles, 'login-card__loading')}
color="#ffffff"
/>
<Text style={g(styles, 'login-card__btn-text')}>登录中</Text> <Text style={g(styles, 'login-card__btn-text')}>登录中</Text>
</> </>
) : ( ) : (
......
...@@ -120,6 +120,7 @@ export const request = (args: Partial<RequestConfig>) => { ...@@ -120,6 +120,7 @@ export const request = (args: Partial<RequestConfig>) => {
return doRequest() return doRequest()
} }
failHandler(e, store, pid) failHandler(e, store, pid)
return reject(transformObject(e.error_code ? e : {error_code: 1, error_msg: '请求失败'}, 'toHump'))
}) })
} }
......
...@@ -117,4 +117,13 @@ export default class Service { ...@@ -117,4 +117,13 @@ export default class Service {
createConsumeOrder(data: any) { createConsumeOrder(data: any) {
return request({ url: `${ctx}/surgery/consume_order/create`, data, method: 'post' }) return request({ url: `${ctx}/surgery/consume_order/create`, data, method: 'post' })
} }
/**
* @description: 请求手术模板
* @param {any} data
* @return {*}
*/
getSurgeryTemplates(data: any) {
return request({ url: `${ctx}/surgery/template_header/search`, data })
}
} }
...@@ -129,6 +129,8 @@ export default class Consume { ...@@ -129,6 +129,8 @@ export default class Consume {
*/ */
getOrders = flow(function* (this: Consume, params: any) { getOrders = flow(function* (this: Consume, params: any) {
const res = yield this.service.getCollectOrders(params) as any const res = yield this.service.getCollectOrders(params) as any
if (res.errorCode) return
const { sellerCode, orgCode, customerCode } = params const { sellerCode, orgCode, customerCode } = params
this._orders[`${sellerCode}_${orgCode}_${customerCode}`] = res.data.surgeryCollectHeaders this._orders[`${sellerCode}_${orgCode}_${customerCode}`] = res.data.surgeryCollectHeaders
}) })
...@@ -145,6 +147,8 @@ export default class Consume { ...@@ -145,6 +147,8 @@ export default class Consume {
filterNoneFlag: 'Y', filterNoneFlag: 'Y',
}) })
this.loading = false this.loading = false
if (res.errorCode) return
this._orderLines[surgeryCollectNumber] = R.compose( this._orderLines[surgeryCollectNumber] = R.compose(
R.reject(R.propEq('raisedConsume', 'Y')), R.reject(R.propEq('raisedConsume', 'Y')),
R.pathOr([], ['data', 'lines']), R.pathOr([], ['data', 'lines']),
......
...@@ -18,6 +18,7 @@ const sysStore = container.get<any>(TYPES.SysStore) ...@@ -18,6 +18,7 @@ const sysStore = container.get<any>(TYPES.SysStore)
const userStore = container.get<any>(TYPES.UserStore) const userStore = container.get<any>(TYPES.UserStore)
const orgStore = container.get<any>(TYPES.OrgStore) const orgStore = container.get<any>(TYPES.OrgStore)
const consumeStore = container.get<any>(TYPES.Consume) const consumeStore = container.get<any>(TYPES.Consume)
const orderStore = container.get<any>(TYPES.Order)
const hydrate = create({ const hydrate = create({
storage: AsyncStorage, storage: AsyncStorage,
...@@ -30,4 +31,4 @@ hydrate('sysStore', sysStore) ...@@ -30,4 +31,4 @@ hydrate('sysStore', sysStore)
hydrate('userStore', userStore) hydrate('userStore', userStore)
hydrate('orgStore', orgStore) hydrate('orgStore', orgStore)
export default { store, sysStore, userStore, orgStore, consumeStore } export default { store, sysStore, userStore, orgStore, consumeStore, orderStore }
/*
* @FilePath: /BoneHouse_Business_APP/src/stores/order.ts
* @Author: peii
* @Date: 2021-07-04 14:52:03
* @LastEditTime: 2021-07-04 18:02:51
* @LastEditors: peii
* @Vision: 1.0
* @Description: 订单store
*/
// @ts-nocheck
import { observable, action, runInAction, toJS, flow } from 'mobx'
import { persist } from 'mobx-persist'
import { injectable, inject } from 'inversify'
import Service from '../services/service'
import { IOrganization, ICustomer, IDepartment } from 'bonehouse'
import * as R from 'ramda'
import { isBlank, isNotBlank } from '../utils/utils'
import { TYPES } from '../inversify/types'
@injectable()
export default class Order {
@inject(TYPES.Service)
private service!: Service
@observable surgeryTemplates: { [key: string]: any[] }
/**
* @description: 请求手术模板
* @param {*}
* @return {*}
*/
getTemplates = flow(function* (
this: Order,
sellerCode: string,
orgCode: string,
customerCode: string,
surgeryType: string,
doctorName?: string,
) {
const params = {
sellerCode,
orgCode,
customerCode,
surgeryType,
doctorName,
}
const res = yield this.service.getSurgeryTemplates(params)
if (res.errorCode) return
console.log(res)
})
}
...@@ -16,7 +16,7 @@ import { injectable, inject } from 'inversify' ...@@ -16,7 +16,7 @@ import { injectable, inject } from 'inversify'
import Service from '../services/service' import Service from '../services/service'
import { IOrganization, ICustomer, IDepartment } from 'bonehouse' import { IOrganization, ICustomer, IDepartment } from 'bonehouse'
import * as R from 'ramda' import * as R from 'ramda'
import { isBlank } from '../utils/utils' import { isBlank, isNotBlank } from '../utils/utils'
import { TYPES } from '../inversify/types' import { TYPES } from '../inversify/types'
@injectable() @injectable()
...@@ -61,6 +61,101 @@ export default class Organization { ...@@ -61,6 +61,101 @@ export default class Organization {
} }
/** /**
* @description: 收单地点选项
* @param {string} sellerCode
* @param {string} orgCode
* @param {string} customerCode
* @param {string} uniq 唯一性字段
* @return {*}
*/
billToSites(sellerCode: string, orgCode: string, customerCode: string, uniq = 'billToSiteCode') {
const customers = this._customers[`${sellerCode}_${orgCode}`] || []
if (isBlank(customers)) return []
const customer = R.find(R.propEq('customerCode', customerCode))(customers)
if (isBlank(customer)) return []
let billToSites = R.compose(
R.map(
R.applySpec({
label: R.prop('billToSiteName'),
value: R.prop('billToSiteCode'),
shipToSites: R.prop('shipToSites'),
}),
),
R.propOr([], 'billToSites'),
)(customer)
if (isNotBlank(uniq)) {
billToSites = R.uniqWith(R.eqBy(R.prop(uniq)))(billToSites)
}
return billToSites
}
/**
* @description:
* @param {string} sellerCode
* @param {string} orgCode
* @param {string} customerCode
* @param {string} billToSiteCode
* @param {string} uniq
* @return {*}
*/
shipToSites(
sellerCode: string,
orgCode: string,
customerCode: string,
billToSiteCode: string,
uniq = 'shipToSiteCode',
) {
const billToSites = this.billToSites(sellerCode, orgCode, customerCode, null)
if (isBlank(billToSites)) return []
const billToSite = R.find(R.propEq('value', billToSiteCode))(billToSites)
if (isBlank(billToSite)) return []
let shipToSites = R.compose(
R.map(
R.applySpec({
label: R.prop('shipToSiteName'),
value: R.prop('shipToSiteCode'),
customerDoctor: R.prop('customerDoctor'),
}),
),
R.propOr([], 'shipToSites'),
)(billToSite)
if (isNotBlank(uniq)) {
shipToSites = R.uniqWith(R.eqBy(R.prop(uniq)))(shipToSites)
}
return shipToSites
}
/**
* @description:
* @param {string} sellerCode
* @param {string} orgCode
* @param {string} customerCode
* @param {string} billToSiteCode
* @param {string} shipToSiteCode
* @return {*}
*/
doctors(sellerCode: string, orgCode: string, customerCode: string, billToSiteCode: string) {
const shipToSites = this.shipToSites(sellerCode, orgCode, customerCode, billToSiteCode, null)
if (isBlank(shipToSites)) return []
return R.compose(
R.uniqWith(R.eqBy(R.prop('value'))),
R.map(
R.applySpec({
label: R.prop('customerDoctor'),
value: R.prop('customerDoctor'),
}),
),
)(shipToSites)
}
/**
* @description: 部门选项 * @description: 部门选项
* @param {string} sellerCode * @param {string} sellerCode
* @param {string} orgCode * @param {string} orgCode
...@@ -108,10 +203,9 @@ export default class Organization { ...@@ -108,10 +203,9 @@ export default class Organization {
*/ */
getOrganizations = flow(function* (this: Organization) { getOrganizations = flow(function* (this: Organization) {
const res = yield this.service.getOrganizations() const res = yield this.service.getOrganizations()
this.organizations = R.compose( if (res.errorCode) return
R.uniqBy(R.prop('orgCode')),
R.pathOr([], ['data', 'organizations']), this.organizations = R.compose(R.uniqBy(R.prop('orgCode')), R.pathOr([], ['data', 'organizations']))(res)
)(res)
this.inventories = res.data.inventories this.inventories = res.data.inventories
}) })
...@@ -122,6 +216,8 @@ export default class Organization { ...@@ -122,6 +216,8 @@ export default class Organization {
*/ */
getCustomers = flow(function* (this: Organization, sellerCode: string, orgCode: string) { getCustomers = flow(function* (this: Organization, sellerCode: string, orgCode: string) {
const res = yield this.service.getCustomers({ orgCode, sellerCode }) const res = yield this.service.getCustomers({ orgCode, sellerCode })
if (res.errorCode) return
this._customers[`${sellerCode}_${orgCode}`] = res.data.customers this._customers[`${sellerCode}_${orgCode}`] = res.data.customers
}) })
...@@ -137,6 +233,8 @@ export default class Organization { ...@@ -137,6 +233,8 @@ export default class Organization {
scopeFlag = 'Y', scopeFlag = 'Y',
) { ) {
const res = yield this.service.getDepartmentsBySellerAndOrg({ sellerCode, orgCode, scopeFlag }) const res = yield this.service.getDepartmentsBySellerAndOrg({ sellerCode, orgCode, scopeFlag })
if (res.errorCode) return
this._departments[`${sellerCode}_${orgCode}`] = res.data.relationships this._departments[`${sellerCode}_${orgCode}`] = res.data.relationships
}) })
} }
...@@ -48,6 +48,9 @@ export default class System { ...@@ -48,6 +48,9 @@ export default class System {
@persist('map') @observable sysValueSets = { @persist('map') @observable sysValueSets = {
// 消耗明细费用类型 // 消耗明细费用类型
SUR_FEE_TYPE: [], SUR_FEE_TYPE: [],
// 手术类型
ORTHOPEDICS_PRODUCT_CLASS: []
} }
@action @action
...@@ -63,6 +66,8 @@ export default class System { ...@@ -63,6 +66,8 @@ export default class System {
getSysProfile = flow(function* (this: System) { getSysProfile = flow(function* (this: System) {
const getProfiles = async (key: any) => { const getProfiles = async (key: any) => {
const res = (await this.service.getSysProfile({ profileCode: key })) as any const res = (await this.service.getSysProfile({ profileCode: key })) as any
if (res.errorCode) return
runInAction(() => { runInAction(() => {
// @ts-ignore // @ts-ignore
this.sysProfiles[key] = isNaN(res.data.profileValue) this.sysProfiles[key] = isNaN(res.data.profileValue)
...@@ -82,12 +87,14 @@ export default class System { ...@@ -82,12 +87,14 @@ export default class System {
getSysValueSet = flow(function* (this: System) { getSysValueSet = flow(function* (this: System) {
const getValueSets = async (key: any) => { const getValueSets = async (key: any) => {
const res = (await this.service.getSysValueSet({ valueSetCode: key })) as any const res = (await this.service.getSysValueSet({ valueSetCode: key })) as any
if (res.errorCode) return
runInAction(() => { runInAction(() => {
// @ts-ignore // @ts-ignore
this.sysValueSets[key] = res.data.sysValues this.sysValueSets[key] = res.data.sysValues
}) })
} }
R.compose(R.map(getValueSets), R.keys)(this.sysValueSets) R.compose(R.map(getValueSets), R.tap(x => console.log(x)), R.keys)(this.sysValueSets)
}) })
} }
...@@ -66,8 +66,9 @@ export default class UserStore { ...@@ -66,8 +66,9 @@ export default class UserStore {
user_password: password, user_password: password,
}, },
} }
const res = yield this.service.signin(params) const res = yield this.service.signin(params)
if (res.errorCode) return false
this.username = username this.username = username
this.password = password this.password = password
...@@ -83,5 +84,6 @@ export default class UserStore { ...@@ -83,5 +84,6 @@ export default class UserStore {
this.store.setFunctions(res.functions) this.store.setFunctions(res.functions)
this.sysStore.getSysProfile() this.sysStore.getSysProfile()
this.sysStore.getSysValueSet() this.sysStore.getSysValueSet()
return true
}) })
} }
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