Commit 7848348c by peii

self f

parent 84708222
......@@ -71,8 +71,11 @@ const Router = createAppContainer(
TransSearchPage: { screen: TransSearchPage },
HistoricalOrderPage: { screen: HistoricalOrderPage },
LineOrderPage: { screen: LineOrderPage },
SubSuccPage: { screen: SubSuccPage },
BarCodePage: { screen: BarCodePage },
// 结算
Settlement: { screen: Settlement },
SettlementCollection: { screen: SettlementCollection },
SettlementReject: { screen: SettlementReject },
......@@ -85,10 +88,12 @@ const Router = createAppContainer(
DirectionInvoice: { screen: DirectionInvoice },
DirectionInvoiceCollections: { screen: DirectionInvoiceCollections },
DirectionInvoiceApplyDetail: { screen: DirectionInvoiceApplyDetail },
ConsumeFee: { screen: ConsumeFee },
MixConsume: { screen: MixConsume },
MixConsumeForm: { screen: MixConsumeForm },
MixConsumeItems: { screen: MixConsumeItems },
},
{
navigationOptions: {
......
@import '../../assets/styles/base.styl'
@import '../../assets/styles/variable.styl'
\ No newline at end of file
/*
* @FilePath: /BoneHouse_Business_APP/src/pages/order/self.tsx
* @Author: peii
* @Date: 2021-07-13 22:40:12
* @LastEditTime: 2022-10-27 15:16:37
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 自助下单
*/
// @ts-nocheck
import React, { Component } from 'react'
import { View, Text, ScrollView } from 'react-native'
// import { inject, observer } from 'mobx-react'
import { IOrganization, IFormField } from 'bonehouse'
import * as R from 'ramda'
import { connect } from 'react-redux'
import Resolution from '../../components/common/Resolution'
import Form from '../../components/form'
import { FieldType, SelectMode } from '../../enums'
import Header from '../../components/header/header'
import { g, getFormItem, isBlank, isNotBlank, show, translateSysprofile } from '../../utils/utils'
import styles from './self.styl'
type IProps = {
sysStore: {
sysProfiles: {
// APP下单是否显示部门权限
OBS_MOBILE_DEPARTMENT_DISPLAY: string
// APP下单是否显示业务经理权限
OBS_MOBILE_BM_DISPLAY: string
// APP下单是否显示跟台员权限
OBS_MOBILE_SUR_FOLLOWER_DISPLAY: string
// APP下单是否显示送货员权限
OBS_MOBILE_DELIVERYMAN_DISPLAY: string
}
sysValueSets: {
SUR_ORDER_TYPE: []
}
}
userStore: {
userName: string
personName: string
}
orgStore: {
organizations: IOrganization[]
orgs: Function
getCustomers: Function
customers: Function
billToSites: Function
shipToSites: Function
doctors: Function
getDepartmentsBySellerAndOrg: Function
departments: Function
followers: Function
businessManagers: Function
delivermen: Function
}
orderStore: {
templates: Function
getTemplates: Function
invs: Function
getInventories: Function
submit: Function
}
productionStore: {
resetCategory: () => void
resetSupplier: () => void
}
}
type IState = {
data: { [key: string]: any[] }
formItems: IFormField[]
}
class SelfOrder extends Component<IProps, IState> {
constructor(props) {
super(props)
this.setData = this.setData.bind(this)
this.submitHandler = this.submitHandler.bind(this)
}
state = {
data: {
sellerCode: this.props.userStore.userName,
replaceItemFlag: 'N',
Caller: 'dingding',
},
formItems: [
{
field: 'sellerCode',
label: '销售员',
type: FieldType.SELECT,
options: [
{
label: this.props.userStore.personName,
value: this.props.userStore.userName,
},
],
placeholder: '请选择',
rules: [{ required: true, message: '请选择销售员' }],
disabled: true,
},
{
field: 'orgCode',
label: '组织',
type: FieldType.SELECT,
options: this.props.orgStore.orgs(),
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: 'billToSiteCode',
label: '收单地点',
type: FieldType.SELECT,
options: [],
placeholder: '请选择',
rules: [{ required: true, message: '请选择收单地点' }],
refrence: ['orgCode', 'customerCode'],
callback: this.setBillToSitesCallback.bind(this),
},
{
field: 'shipToSiteCode',
label: '收货地点',
type: FieldType.SELECT,
options: [],
placeholder: '请选择',
rules: [{ required: true, message: '请选择收货地点' }],
refrence: ['orgCode', 'customerCode', 'billToSiteCode'],
callback: this.setShipToSiteCallback.bind(this),
},
{
field: 'doctorName',
label: '主治医生',
type: FieldType.SELECT,
options: [],
placeholder: '请选择',
refrence: ['orgCode', 'customerCode', 'billToSiteCode', 'shipToSiteCode'],
},
{
field: 'surgeryDate',
label: '手术时间',
type: FieldType.DATE,
dateMode: 'datetime',
placeholder: '请选择',
rules: [{ required: true, message: '请选择手术时间' }],
},
{
field: 'orderTypeCode',
label: '订单类型',
type: FieldType.SELECT,
placeholder: '请选择',
rules: [{ required: true, message: '请选择订单类型' }],
options: R.compose(
R.map(
R.applySpec({
label: R.prop('valueName'),
value: R.prop('valueCode'),
}),
),
R.pathOr([], ['sysStore', 'sysValueSets', 'SUR_ORDER_TYPE']),
)(this.props),
},
{
field: 'products',
label: '选择产品',
type: FieldType.SELECT,
selectMode: SelectMode.PAGE,
placeholder: '请选择',
rules: [{ required: true, message: '请选择产品' }],
refrence: ['orgCode'],
customHandler: this.selectProductsBeforeHandler.bind(this),
},
{
field: 'collectSrcInvCode',
label: '借货仓库',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
refrence: ['orgCode', 'sellerCode', 'customerCode', 'billToSiteCode', 'shipToSiteCode'],
},
{
field: 'takeCertFlag',
label: '需要携带合格证',
type: FieldType.RADIO,
rules: [{ required: true, message: '请选择是否需要携带合格证' }],
options: [
{
label: '是',
value: 'Y',
},
{
label: '否',
value: 'N',
},
],
},
{
field: 'replaceItemFlag',
label: '同意替换器械包',
type: FieldType.RADIO,
options: [
{
label: '是',
value: 'Y',
},
{
label: '否',
value: 'N',
},
],
},
{
field: 'surgeryDesc',
label: '备注',
type: FieldType.TEXT,
placeholder: '请输入备注',
multiline: true,
},
{
field: 'voiceUrl',
label: '录音',
type: FieldType.VOICE,
placeholder: '还有什么要安排的,可录音备注哟!',
},
],
}
componentDidMount() {
this.setOptionsFormItems()
}
componentWillUnmount() {
this.props.productionStore.resetSupplier()
this.props.productionStore.resetCategory()
}
/**
* @description: 设置配置性的表单字段(部门,业务经理,跟台员,送货员)
*/
setOptionsFormItems() {
const { sysProfiles } = this.props.sysStore
let { formItems } = this.state
// 部门(00)第一位显示、第二位必需
let dep = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
if (dep.show) {
formItems = R.insert(
2,
{
field: 'departmentCode',
label: '部门',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
rules: [{ required: dep.required, message: '请选择客户' }],
refrence: ['orgCode'],
callback: this.setDepartmentCallback.bind(this),
},
formItems,
)
}
// 业务经理(00)第一位显示、第二位必需
let businessManager = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
if (businessManager.show) {
formItems = R.insert(
3,
{
field: 'businessManagerCode',
label: '业务经理',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
rules: [{ required: businessManager.required, message: '请选择业务经理' }],
refrence: ['orgCode', 'departmentCode'],
},
formItems,
)
}
// 跟台员(00)第一位显示、第二位必需
let follower = translateSysprofile(sysProfiles.OBS_MOBILE_SUR_FOLLOWER_DISPLAY)
if (follower.show) {
formItems = R.insert(
4,
{
field: 'surgeryFollowerCode',
label: '跟台员',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
rules: [{ required: follower.required, message: '请选择跟台员' }],
refrence: ['orgCode', 'departmentCode'],
},
formItems,
)
}
// 送货员(00)第一位显示、第二位必需
let deliver = translateSysprofile(sysProfiles.OBS_MOBILE_DELIVERYMAN_DISPLAY)
if (deliver.show) {
formItems = R.insert(
5,
{
field: 'deliverymanCode',
label: '送货员',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
rules: [{ required: follower.required, message: '请选择送货员' }],
refrence: ['orgCode', 'departmentCode'],
},
formItems,
)
}
this.setState({ formItems })
}
/**
* @description: 设置修改值
* @param {*} key
* @param {*} vlaue
* @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)
item && item.callback && item.callback()
resolve()
})
})
}
/**
* @description: 组织选择完回调
* @param {*}
* @return {*}
*/
async setOrgCallback() {
const sysProfiles = this.props.sysStore.sysProfiles
const { show } = 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 setDepartmentCallback() {
const { data, formItems } = this.state
const { orgCode, sellerCode, departmentCode } = data
// 设置业务经理
const bmItem = getFormItem(formItems, 'businessManagerCode')
if (isNotBlank(bmItem)) {
bmItem.options = this.props.orgStore.businessManagers(sellerCode, orgCode, departmentCode)
}
// 设置跟台员
const followerItem = getFormItem(formItems, 'surgeryFollowerCode')
if (isNotBlank(followerItem)) {
followerItem.options = this.props.orgStore.followers(sellerCode, orgCode, departmentCode)
}
// 设置送货员
const item = getFormItem(formItems, 'deliverymanCode')
if (isNotBlank(item)) {
item.options = this.props.orgStore.delivermen(sellerCode, orgCode, departmentCode)
}
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 })
}
/**
* @description: 收货地点选择完回调
* @param {*}
* @return {*}
*/
setShipToSiteCallback() {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode, billToSiteCode, shipToSiteCode } = data
const doctors = this.props.orgStore.doctors(sellerCode, orgCode, customerCode, billToSiteCode)
const item = getFormItem(formItems, 'doctorName')
item.options = doctors
this.setState({ formItems })
// 借货仓库依赖收货地址
if (isNotBlank(shipToSiteCode)) {
this.getInventories()
}
}
/**
* @description: 获取借货仓库
* @param {*}
* @return {*}
*/
async getInventories() {
const { formItems, data } = this.state
const { orgCode, customerCode, billToSiteCode, shipToSiteCode } = data
const item = getFormItem(formItems, 'collectSrcInvCode')
let invs = this.props.orderStore.invs(orgCode, customerCode, billToSiteCode, shipToSiteCode)
if (isBlank(invs)) {
item.loading = true
await this.props.orderStore.getInventories(orgCode, customerCode, billToSiteCode, shipToSiteCode)
item.loading = false
}
invs = this.props.orderStore.invs(orgCode, customerCode, billToSiteCode, shipToSiteCode)
item.options = R.map(
R.applySpec({
value: R.prop('sourceInvCode'),
label: R.prop('sourceInvName'),
}),
)(invs)
this.setState({ formItems })
}
/**
* @description: 产品选择点击回调
* @param {*}
* @return {*}
*/
selectProductsBeforeHandler() {
const { data } = this.state
this.props.navigation.navigate('Productions', {
orgCode: data.orgCode,
callback: productions => {
console.log(productions)
},
})
}
/**
* @description:
* @param {*}
* @return {*}
*/
submitHandler() {}
render() {
const { formItems, data } = this.state
const { navigation } = this.props
const title = navigation.getParam('title', '骨科智慧仓')
return (
<View style={g(styles, 'container', 'bg-gray')}>
<Resolution.FixWidthView>
<Header
title={title}
backCallback={() => {
navigation.goBack()
}}
/>
{/* form表单 */}
<Form
fields={formItems}
data={data}
onChange={this.setData}
ref={ref => (this.formRef = ref)}
submitHandler={this.submitHandler}
/>
</Resolution.FixWidthView>
</View>
)
}
}
const mapStateToProps = state => ({})
const mapDispatchToProps = dispatch => ({})
export default connect(mapStateToProps, mapDispatchToProps)(SelfOrder)
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