Commit f2adaad1 by wong.peiyi

消耗确认配置字段

parent cbce4f88
......@@ -28,6 +28,7 @@
&-multi
height 160px
padding 18px
flex-direction column
align-items flex-start
......
......@@ -47,6 +47,7 @@ export default class Input extends Component<IProps> {
'form-text-input': true,
'form-text-input__multi': item.multiline,
})}
defaultValue={value}
autoCapitalize="none"
placeholder={item.placeholder || '请输入'}
onChangeText={this.onChangeText}
......
......@@ -12,10 +12,11 @@ import React, { Component } from 'react'
import { View, Text, ScrollView } from 'react-native'
import { inject, observer } from 'mobx-react'
import { IOrganization, ISurgeryCollectHeader } from 'bonehouse'
import * as R from 'ramda'
import Form from '../../components/form'
import { FieldType } from '../../enums'
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'
type IProps = {
......@@ -24,16 +25,27 @@ type IProps = {
userName: 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: {
organizations: IOrganization[]
orgs: Function
getCustomers: Function
customers: Function
getDepartmentsBySellerAndOrg: Function
departments: Function
followers: Function
}
consumeStore: {
orders: ISurgeryCollectHeader[]
getOrders: Function
orderFollower: Function
orderDoctor: Function
}
}
......@@ -70,7 +82,7 @@ class Consume extends Component<IProps> {
options: this.props.orgStore.orgs(),
placeholder: '请选择',
rules: [{ required: true, message: '请选择组织' }],
callback: this.getCustomers.bind(this),
callback: this.setOrgCallback.bind(this),
},
{
field: 'customerCode',
......@@ -80,7 +92,7 @@ class Consume extends Component<IProps> {
placeholder: '请选择',
rules: [{ required: true, message: '请选择客户' }],
refrence: ['orgCode'],
callback: this.customerCallback.bind(this),
callback: this.setCustomerCallback.bind(this),
},
{
field: 'surgeryCollectNumber',
......@@ -90,6 +102,7 @@ class Consume extends Component<IProps> {
placeholder: '请选择',
rules: [{ required: true, message: '请选择订单' }],
refrence: ['orgCode', 'customerCode'],
callback: this.setSurgeryCollectNumberCallback.bind(this),
},
{
field: 'consumeDate',
......@@ -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: 设置修改值
......@@ -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() {
......@@ -196,7 +321,7 @@ class Consume extends Component<IProps> {
* @param {*}
* @return {*}
*/
async customerCallback() {
async setCustomerCallback() {
const { data, formItems } = this.state
let orders = this.props.consumeStore.orders(data.sellerCode, data.orgCode, data.customerCode)
if (isBlank(orders)) {
......@@ -214,6 +339,46 @@ class Consume extends Component<IProps> {
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() {
const { formItems, data, scrollable } = this.state
const { navigation } = this.props
......
......@@ -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: 获取借货订单
* @param {*}
* @return {*}
......
......@@ -14,6 +14,7 @@ import { observable, flow, runInAction, action } from 'mobx'
import { ISurgeryCollectHeader } from 'bonehouse'
import { injectable, inject } from 'inversify'
import * as R from 'ramda'
import { isNotBlank } from '../utils/utils'
import Service from '../services/service'
import { TYPES } from '../inversify/types'
import dayjs from 'dayjs'
......@@ -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: 获取借货订单
* @param {*}
* @return {*}
......
......@@ -14,7 +14,7 @@ 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 } from 'bonehouse'
import { IOrganization, ICustomer, IDepartment } from 'bonehouse'
import * as R from 'ramda'
import { isBlank } from '../utils/utils'
import { TYPES } from '../inversify/types'
......@@ -32,6 +32,9 @@ export default class Organization {
// 客户
@observable _customers: { [key: string]: ICustomer[] } = {}
// 部门
@observable _departments: { [key: string]: IDepartment[] } = {}
orgs(): IOrganization[] {
return R.map(
R.applySpec({
......@@ -57,6 +60,43 @@ export default class Organization {
)(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
resetCustomers() {
this._customers = {}
......@@ -81,4 +121,19 @@ export default class Organization {
const res = yield this.service.getCustomers({ orgCode, sellerCode })
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[]) => {
*/
export const g = getStyles
let toast = null
/**
* 提示框
* @param {*} data 提示内容
......@@ -89,7 +90,10 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio
} else if (type == MsgType.SUCCESS) {
data = `√ ${data}`
}
Toast.show(data, {
if (isNotBlank(toast)) {
Toast.hide(toast)
}
toast = Toast.show(data, {
duration: Toast.durations.LONG,
position,
shadow: false,
......@@ -99,6 +103,9 @@ export const show = (data: string, type = MsgType.INFO, position = Toast.positio
backgroundColor: colors.backColor,
textColor: 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