Commit f2adaad1 by wong.peiyi

消耗确认配置字段

parent cbce4f88
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
&-multi &-multi
height 160px height 160px
padding 18px
flex-direction column flex-direction column
align-items flex-start align-items flex-start
......
...@@ -47,6 +47,7 @@ export default class Input extends Component<IProps> { ...@@ -47,6 +47,7 @@ export default class Input extends Component<IProps> {
'form-text-input': true, 'form-text-input': true,
'form-text-input__multi': item.multiline, 'form-text-input__multi': item.multiline,
})} })}
defaultValue={value}
autoCapitalize="none" autoCapitalize="none"
placeholder={item.placeholder || '请输入'} placeholder={item.placeholder || '请输入'}
onChangeText={this.onChangeText} onChangeText={this.onChangeText}
......
...@@ -12,10 +12,11 @@ import React, { Component } from 'react' ...@@ -12,10 +12,11 @@ import React, { Component } from 'react'
import { View, Text, ScrollView } from 'react-native' import { View, Text, ScrollView } from 'react-native'
import { inject, observer } from 'mobx-react' import { inject, observer } from 'mobx-react'
import { IOrganization, ISurgeryCollectHeader } from 'bonehouse' import { IOrganization, ISurgeryCollectHeader } from 'bonehouse'
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 } from '../../utils/utils' import { g, getFormItem, isBlank, isNotBlank } from '../../utils/utils'
import styles from './consume.styl' import styles from './consume.styl'
type IProps = { type IProps = {
...@@ -24,16 +25,27 @@ type IProps = { ...@@ -24,16 +25,27 @@ type IProps = {
userName: string userName: string
personName: string personName: string
} }
sysStore: {} sysStore: {
sysProfiles: {
OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY: string
OBS_MOBILE_CONSU_DOCTOR_DISPLAY: string
OBS_MOBILE_CONSU_FOLLOW_DISPLAY: string
}
}
orgStore: { orgStore: {
organizations: IOrganization[] organizations: IOrganization[]
orgs: Function orgs: Function
getCustomers: Function getCustomers: Function
customers: Function customers: Function
getDepartmentsBySellerAndOrg: Function
departments: Function
followers: Function
} }
consumeStore: { consumeStore: {
orders: ISurgeryCollectHeader[] orders: ISurgeryCollectHeader[]
getOrders: Function getOrders: Function
orderFollower: Function
orderDoctor: Function
} }
} }
...@@ -70,7 +82,7 @@ class Consume extends Component<IProps> { ...@@ -70,7 +82,7 @@ class Consume extends Component<IProps> {
options: this.props.orgStore.orgs(), options: this.props.orgStore.orgs(),
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择组织' }], rules: [{ required: true, message: '请选择组织' }],
callback: this.getCustomers.bind(this), callback: this.setOrgCallback.bind(this),
}, },
{ {
field: 'customerCode', field: 'customerCode',
...@@ -80,7 +92,7 @@ class Consume extends Component<IProps> { ...@@ -80,7 +92,7 @@ class Consume extends Component<IProps> {
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择客户' }], rules: [{ required: true, message: '请选择客户' }],
refrence: ['orgCode'], refrence: ['orgCode'],
callback: this.customerCallback.bind(this), callback: this.setCustomerCallback.bind(this),
}, },
{ {
field: 'surgeryCollectNumber', field: 'surgeryCollectNumber',
...@@ -90,6 +102,7 @@ class Consume extends Component<IProps> { ...@@ -90,6 +102,7 @@ class Consume extends Component<IProps> {
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择订单' }], rules: [{ required: true, message: '请选择订单' }],
refrence: ['orgCode', 'customerCode'], refrence: ['orgCode', 'customerCode'],
callback: this.setSurgeryCollectNumberCallback.bind(this),
}, },
{ {
field: 'consumeDate', field: 'consumeDate',
...@@ -156,7 +169,84 @@ class Consume extends Component<IProps> { ...@@ -156,7 +169,84 @@ class Consume extends Component<IProps> {
], ],
} }
componentDidMount() {} componentDidMount() {
this.setOptionsFormItems()
}
/**
* @description: 设置配置性的表单字段
* @param {*}
* @return {*}
*/
setOptionsFormItems() {
const { sysProfiles } = this.props.sysStore
let { formItems } = this.state
// 部门(00)第一位显示、第二位必需
if (R.pathEq(['OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY', 0], '1', sysProfiles)) {
formItems = R.insert(
2,
{
field: 'departmentCode',
label: '部门',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
rules: [
{
required: R.pathEq(['OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY', 1], '1', sysProfiles),
message: '请选择客户',
},
],
refrence: ['orgCode'],
},
formItems,
)
}
// 跟台(00)第一位显示、第二位必需
if (R.pathEq(['OBS_MOBILE_CONSU_FOLLOW_DISPLAY', 0], '1', sysProfiles)) {
const idx = R.findIndex(R.propEq('field', 'surgeryCollectNumber'))(formItems)
formItems = R.insert(
idx + 1,
{
field: 'surgeryFollowerCode',
label: '跟台员',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
rules: [
{
required: R.pathEq(['OBS_MOBILE_CONSU_FOLLOW_DISPLAY', 1], '1', sysProfiles),
message: '请选择跟台员',
},
],
refrence: ['orgCode', 'customerCode', 'surgeryCollectNumber'],
},
formItems,
)
}
// 医生(00)第一位显示、第二位必需
if (R.pathEq(['OBS_MOBILE_CONSU_DOCTOR_DISPLAY', 0], '1', sysProfiles)) {
const idx = R.findIndex(R.propEq('field', 'consumeDate'))(formItems)
formItems = R.insert(
idx + 1,
{
field: 'doctorName',
label: '医生',
type: FieldType.TEXT,
placeholder: '请输入医生姓名',
options: [],
rules: [
{
required: R.pathEq(['OBS_MOBILE_CONSU_DOCTOR_DISPLAY', 1], '1', sysProfiles),
message: '请输入医生姓名',
},
],
},
formItems,
)
}
this.setState({ formItems })
}
/** /**
* @description: 设置修改值 * @description: 设置修改值
...@@ -176,6 +266,41 @@ class Consume extends Component<IProps> { ...@@ -176,6 +266,41 @@ class Consume extends Component<IProps> {
} }
/** /**
* @description: 选择完组织
* @param {*}
* @return {*}
*/
setOrgCallback() {
const { OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY } = this.props.sysStore.sysProfiles
// 显示了部门
if (R.pathEq([0], '1', OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY)) {
// 获取部门
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)
if (isBlank(departments)) {
await this.props.orgStore.getDepartmentsBySellerAndOrg(sellerCode, orgCode)
departments = this.props.orgStore.departments(sellerCode, orgCode)
}
const item = getFormItem(formItems, 'departmentCode')
item.options = departments
this.setState({ formItems })
}
/**
* 获取客户列表 * 获取客户列表
*/ */
async getCustomers() { async getCustomers() {
...@@ -196,7 +321,7 @@ class Consume extends Component<IProps> { ...@@ -196,7 +321,7 @@ class Consume extends Component<IProps> {
* @param {*} * @param {*}
* @return {*} * @return {*}
*/ */
async customerCallback() { async setCustomerCallback() {
const { data, formItems } = this.state const { data, formItems } = this.state
let orders = this.props.consumeStore.orders(data.sellerCode, data.orgCode, data.customerCode) let orders = this.props.consumeStore.orders(data.sellerCode, data.orgCode, data.customerCode)
if (isBlank(orders)) { if (isBlank(orders)) {
...@@ -214,6 +339,46 @@ class Consume extends Component<IProps> { ...@@ -214,6 +339,46 @@ class Consume extends Component<IProps> {
this.setState({ formItems }) this.setState({ formItems })
} }
/**
* @description: 订单信息选择完回调
* @param {*}
* @return {*}
*/
async setSurgeryCollectNumberCallback() {
const { data, formItems } = this.state
let followers = this.props.orgStore.followers(
data.sellerCode,
data.orgCode,
data.departmentCode,
)
const orderFollower = this.props.consumeStore.orderFollower(
data.sellerCode,
data.orgCode,
data.customerCode,
data.surgeryCollectNumber,
)
const doctor = this.props.consumeStore.orderDoctor(
data.sellerCode,
data.orgCode,
data.customerCode,
data.surgeryCollectNumber,
)
data.doctorName = doctor
if (isNotBlank(orderFollower)) {
followers = R.append(orderFollower, followers)
data.surgeryFollowerCode = orderFollower.value
}
const item = getFormItem(formItems, 'surgeryFollowerCode')
if (isNotBlank(item)) {
item.options = followers
this.setState({ formItems }, () => {
this.setState({ data })
})
}
}
render() { render() {
const { formItems, data, scrollable } = this.state const { formItems, data, scrollable } = this.state
const { navigation } = this.props const { navigation } = this.props
......
...@@ -53,6 +53,15 @@ export default class Service { ...@@ -53,6 +53,15 @@ export default class Service {
} }
/** /**
* @description: 根据组织和销售员获取部门信息
* @param {object} data
* @return {*}
*/
getDepartmentsBySellerAndOrg(data: { orgCode: string; sellerCode: string; scopeFlag: string }) {
return request({ url: `${ctx}/sale/sale_relationship/search`, data })
}
/**
* @description: 获取借货订单 * @description: 获取借货订单
* @param {*} * @param {*}
* @return {*} * @return {*}
......
...@@ -14,6 +14,7 @@ import { observable, flow, runInAction, action } from 'mobx' ...@@ -14,6 +14,7 @@ import { observable, flow, runInAction, action } from 'mobx'
import { ISurgeryCollectHeader } from 'bonehouse' import { ISurgeryCollectHeader } from 'bonehouse'
import { injectable, inject } from 'inversify' import { injectable, inject } from 'inversify'
import * as R from 'ramda' import * as R from 'ramda'
import { isNotBlank } from '../utils/utils'
import Service from '../services/service' import Service from '../services/service'
import { TYPES } from '../inversify/types' import { TYPES } from '../inversify/types'
import dayjs from 'dayjs' import dayjs from 'dayjs'
...@@ -60,6 +61,34 @@ export default class Consume { ...@@ -60,6 +61,34 @@ export default class Consume {
} }
/** /**
* @description: 订单跟台员
* @param {string} surgeryCollectNumber
* @return {*}
*/
orderFollower(sellerCode, orgCode, customerCode, surgeryCollectNumber) {
const orders = this._orders[`${sellerCode}_${orgCode}_${customerCode}`] || []
const order = R.find(R.propEq('surgeryCollectNumber', surgeryCollectNumber))(orders)
if (isNotBlank(order) && isNotBlank(order.surgeryFollowerCode)) {
return { value: order.surgeryFollowerCode, label: order.surgeryFollowerName }
}
}
/**
* @description: 订单医生
* @param {*} sellerCode
* @param {*} orgCode
* @param {*} customerCode
* @param {*} surgeryCollectNumber
* @return {*}
*/
orderDoctor(sellerCode, orgCode, customerCode, surgeryCollectNumber) {
const orders = this._orders[`${sellerCode}_${orgCode}_${customerCode}`] || []
const order = R.find(R.propEq('surgeryCollectNumber', surgeryCollectNumber))(orders)
return R.propOr('', 'doctorName')(order)
}
/**
* @description: 获取借货订单 * @description: 获取借货订单
* @param {*} * @param {*}
* @return {*} * @return {*}
......
...@@ -14,7 +14,7 @@ import { observable, action, runInAction, toJS, flow } from 'mobx' ...@@ -14,7 +14,7 @@ import { observable, action, runInAction, toJS, flow } from 'mobx'
import { persist } from 'mobx-persist' import { persist } from 'mobx-persist'
import { injectable, inject } from 'inversify' import { injectable, inject } from 'inversify'
import Service from '../services/service' import Service from '../services/service'
import { IOrganization, ICustomer } 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 } from '../utils/utils'
import { TYPES } from '../inversify/types' import { TYPES } from '../inversify/types'
...@@ -32,6 +32,9 @@ export default class Organization { ...@@ -32,6 +32,9 @@ export default class Organization {
// 客户 // 客户
@observable _customers: { [key: string]: ICustomer[] } = {} @observable _customers: { [key: string]: ICustomer[] } = {}
// 部门
@observable _departments: { [key: string]: IDepartment[] } = {}
orgs(): IOrganization[] { orgs(): IOrganization[] {
return R.map( return R.map(
R.applySpec({ R.applySpec({
...@@ -57,6 +60,43 @@ export default class Organization { ...@@ -57,6 +60,43 @@ export default class Organization {
)(customers as any) as any )(customers as any) as any
} }
/**
* @description: 部门选项
* @param {string} sellerCode
* @param {string} orgCode
* @return {*}
*/
departments(sellerCode: string, orgCode: string) {
const deps = this._departments[`${sellerCode}_${orgCode}`] || []
return R.map(
R.applySpec({
label: R.prop('departmentName'),
value: R.prop('departmentCode'),
}),
)(deps)
}
/**
* @description: 跟台员
* @param {string} sellerCode
* @param {string} orgCode
* @param {string} departmentCode
* @return {*}
*/
followers(sellerCode: string, orgCode: string, departmentCode: string) {
const deps = this._departments[`${sellerCode}_${orgCode}`] || []
const dep = R.find(R.propEq('departmentCode', departmentCode))(deps)
return R.compose(
R.map(
R.applySpec({
label: R.prop('surgeryFollowerName'),
value: R.prop('surgeryFollowerCode'),
}),
),
R.propOr([], 'surgeryFollowerList'),
)(dep)
}
@action @action
resetCustomers() { resetCustomers() {
this._customers = {} this._customers = {}
...@@ -81,4 +121,19 @@ export default class Organization { ...@@ -81,4 +121,19 @@ export default class Organization {
const res = yield this.service.getCustomers({ orgCode, sellerCode }) const res = yield this.service.getCustomers({ orgCode, sellerCode })
this._customers[`${sellerCode}_${orgCode}`] = res.data.customers this._customers[`${sellerCode}_${orgCode}`] = res.data.customers
}) })
/**
* @description: 根据组织和销售员获取部门
* @param {*}
* @return {*}
*/
getDepartmentsBySellerAndOrg = flow(function* (
this: Organization,
sellerCode: string,
orgCode: string,
scopeFlag = 'Y',
) {
const res = yield this.service.getDepartmentsBySellerAndOrg({ sellerCode, orgCode, scopeFlag })
this._departments[`${sellerCode}_${orgCode}`] = res.data.relationships
})
} }
...@@ -55,6 +55,7 @@ export const getStyles = (styles: any, ...cls: any[]) => { ...@@ -55,6 +55,7 @@ export const getStyles = (styles: any, ...cls: any[]) => {
*/ */
export const g = getStyles export const g = getStyles
let toast = null
/** /**
* 提示框 * 提示框
* @param {*} data 提示内容 * @param {*} data 提示内容
...@@ -89,7 +90,10 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio ...@@ -89,7 +90,10 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio
} else if (type == MsgType.SUCCESS) { } else if (type == MsgType.SUCCESS) {
data = `√ ${data}` data = `√ ${data}`
} }
Toast.show(data, { if (isNotBlank(toast)) {
Toast.hide(toast)
}
toast = Toast.show(data, {
duration: Toast.durations.LONG, duration: Toast.durations.LONG,
position, position,
shadow: false, shadow: false,
...@@ -99,6 +103,9 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio ...@@ -99,6 +103,9 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio
backgroundColor: colors.backColor, backgroundColor: colors.backColor,
textColor: colors.textColor, textColor: colors.textColor,
shadowColor: colors.textColor, shadowColor: colors.textColor,
onHidden() {
toast = null
},
}) })
} }
......
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