Commit 61eab372 by peii

order

parent ce6b3f46
......@@ -131,7 +131,7 @@ export const reqSelfSurgeryHospital = async (global_domain_config, params) => {
}
// 获取订单类型 params={access_token:'', value_set_code:'SUR_ORDER_TYPE'}
export function requestSelfOrderType(params, url) {
export function requestSelfOrderType(params, url, cb = () => {}) {
return (dispatch, getState) => {
dispatch(requestListDataing())
let { global_domain_config } = getState().login
......@@ -144,7 +144,7 @@ export function requestSelfOrderType(params, url) {
console.log('获取订单类型 res=====', res)
// 兼容老的接口,有的环境没有实现获取订单类型接口
if (res.status === 404) {
return dispatch(requestSelfOrderType(params, '/system/value_set/search'))
return dispatch(requestSelfOrderType(params, '/system/value_set/search', cb))
}
if (res.error_code == 0) {
let data = []
......@@ -159,13 +159,14 @@ export function requestSelfOrderType(params, url) {
data = res.data.sys_values
}
dispatch(requestListDataSuccess(data))
cb(data)
} else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
})
.catch(err => {
if (!url) {
requestSelfOrderType(params, '/system/value_set/search')
requestSelfOrderType(params, '/system/value_set/search', cb)
} else {
showErrorMessage(dispatch, err, requestListDataFail, '获取订单类型')
}
......
......@@ -50,7 +50,7 @@ class HomePage extends Component {
MOBILE_SELF_HELP_ORDER: {
icon: require('../../images/self_order.png'),
title: '自助下单',
page: 'SelfOrder',
page: 'SelfOrderPage',
params: {
isLendOrder: false,
},
......@@ -396,7 +396,7 @@ const mapDispatchToProps = dispatch => ({
dispatch(getLendOrderCodeValues())
},
getOrganizationData: () => {
dispatch(getOrganizations())
dispatch(getOrganizations(null, { success: () => {} }))
},
})
......
......@@ -36,6 +36,7 @@ const defaultState = {
OBS_MOBILE_BM_DISPLAY: '00',
OBS_MOBILE_SUR_FOLLOWER_DISPLAY: '00',
OBS_MOBILE_DELIVERYMAN_DISPLAY: '00',
OBS_MOBILE_BOR_WARE_REQUIRED: '00'
},
sysValueSets: {
SUR_FEE_TYPE: [],
......@@ -59,6 +60,7 @@ export const originSysProfiles = {
OBS_MOBILE_SUR_FOLLOWER_DISPLAY: '00',
// APP下单是否显示送货员权限
OBS_MOBILE_DELIVERYMAN_DISPLAY: '00',
OBS_MOBILE_BOR_WARE_REQUIRED: '00'
}
export const originSysValueSets = {
......
......@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/actions/action-types.ts
* @Author: PEII
* @Date: 2022-11-02 16:41:21
* @LastEditTime: 2022-11-04 18:00:41
* @LastEditTime: 2022-11-24 16:33:56
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
......@@ -12,3 +12,5 @@ export const GET_ORGANIZATIONS = 'GET_ORGANIZATIONS'
export const GET_CUSTOMERS = 'GET_CUSTOMERS'
export const GET_COLLECT_SETTING = 'GET_COLLECT_SETTING'
export const GET_DEPARTMENTS = 'GET_DEPARTMENTS'
\ No newline at end of file
......@@ -2,17 +2,30 @@
* @FilePath: /BoneHouse_Business_APP/src/actions/userAction.ts
* @Author: PEII
* @Date: 2022-11-02 16:09:29
* @LastEditTime: 2022-11-04 18:51:56
* @LastEditTime: 2022-11-24 16:35:34
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
*/
import { createApiAction } from './utils'
import { GET_ORGANIZATIONS, GET_CUSTOMERS, GET_COLLECT_SETTING } from './action-types'
import { GET_ORGANIZATIONS, GET_CUSTOMERS, GET_COLLECT_SETTING, GET_DEPARTMENTS } from './action-types'
import api from '../services/api'
import service from '../services/service'
/**
* @description: 获取组织
* @return {*}
*/
export const getOrganizations = createApiAction(GET_ORGANIZATIONS, api.getOrganizations)
/**
* @description: 获取部门
* @return {*}
*/
export const getDepartments = createApiAction(GET_DEPARTMENTS, service.getDepartmentsBySellerAndOrg)
export const getCustomers = createApiAction(GET_CUSTOMERS, api.getCustomers)
export const getCollectSetting = createApiAction(GET_COLLECT_SETTING, api.getCollectSetting)
......@@ -38,6 +38,8 @@ export const createApiAction: IApiAction = (actionType: string, fn: Function) =>
return (params = {}, callback = { success: <U>(p: U) => {}, fail: <R>(p: R) => {} }, customActionType = actionType) =>
async (dispatch: Function) => {
try {
console.log({ type: `${customActionType}_REQUEST`, params })
dispatch({ type: `${customActionType}_REQUEST`, params })
if (type(fn) !== 'Function') {
throw new Error(`参数【${fn.toString()}】不是可调用函数`)
......
......@@ -79,7 +79,7 @@ export default class Form extends Component<IProps> {
checkSubmit() {
const { fields, data } = this.props
for (const item of fields) {
if (isBlank(item.rules)) continue
if (item.show === false || isBlank(item.rules)) continue
// 校验是否可以提交
for (const rule of item.rules) {
......@@ -124,6 +124,8 @@ export default class Form extends Component<IProps> {
<ScrollView style={g(styles, 'form')}>
<KeyboardAvoidingView style={g(styles, 'form-inner')} behavior="padding" enabled>
{fields.map(item => {
if (item.show === false) return <></>
let FormComponent = formComponents[item.type] || Select
if (item.type === FieldType.CUSTOM) {
......
......@@ -70,7 +70,11 @@ export default class Select extends Component<IProps> {
}
// 换了options,表示依赖的项没有了,把当前设置为空
const val = getText(item, value)
if (isNotBlank(value) && isBlank(val) && R.complement(R.equals)(this.props.data, nextProps.data)) {
if (
isNotBlank(value) &&
isBlank(val) &&
(R.complement(R.equals)(this.props.data, nextProps.data) || isBlank(item.options))
) {
this.onChange(null)
}
......
......@@ -286,7 +286,7 @@ class Filter extends React.Component<IProps, IState> {
const mapStateToProps = state => ({
userInfo: state.login.userInfo,
sysProfiles: state.login.sysProfiles,
organizations: state.login.organizations,
organizations: state.user.organizations,
})
const mapDispatchToProps = dispatch => ({})
......
......@@ -257,7 +257,7 @@ class Filter extends React.Component<IProps, IState> {
const mapStateToProps = state => ({
userInfo: state.login.userInfo,
sysProfiles: state.login.sysProfiles,
organizations: state.login.organizations,
organizations: state.user.organizations,
})
const mapDispatchToProps = dispatch => ({})
......
......@@ -546,7 +546,7 @@ class ConsumeForm extends Component<IProps, IState> {
const mapStateToProps = state => ({
list: state.mixConsume.orders,
userInfo: state.login.userInfo,
organizations: state.login.organizations,
organizations: state.user.organizations,
sysProfiles: state.login.sysProfiles,
})
......
/*
* @FilePath: /BoneHouse_Business_APP/src/pages/order/hoc/order.tsx
* @Author: PEII
* @Date: 2022-11-22 16:47:26
* @LastEditTime: 2022-11-24 22:36:13
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 订单类型form
*/
// @ts-nocheck
import React, { Component } from 'react'
import * as R from 'ramda'
import { g, getFormItem, isBlank, isNotBlank, show, getOrderSysProfile } from '../../../utils/utils'
import service from '../../../services/service'
import api from '../../../services/api'
type IProps = {
navigation: INavigation
userInfo: any
organizations: IOrganization[]
allCustomers: {}
getCustomers: (sellerCode: string, orgCode: string) => Promise<any>
getCollectSetting: (orgCode, customerCode, billToSiteCode, shipToSiteCode) => Promise<any>
getOrderTypes: (token, orgCode) => Promise<any>
}
type IState = {
data: { [key: string]: any[] }
formItems: IFormField[]
doctorNames: string[]
invs: { string: any[] }
departments: { string: any[] }
}
export default function Order(WrapComponent: Component<IProps, IState>) {
return class Order extends WrapComponent {
constructor(props) {
super(props)
this.setData = this.setData.bind(this)
this.submitHandler = this.submitHandler.bind(this)
}
state = {
data: {
sellerCode: this.props.userInfo.user_name,
replaceItemFlag: 'N',
Caller: 'dingding',
},
invs: {},
orderTypes: {},
departments: {},
}
/**
* @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 { show } = getOrderSysProfile('OBS_MOBILE_DEPARTMENT_DISPLAY')
this.getOrderTypes()
// 设置完组织获取部门和客户
if (show) {
this.getDepartments.call(this)
}
this.getCustomers.call(this)
}
/**
* @description: 获取部门列表
* @param {*}
* @return {*}
*/
async getDepartments() {
let { data, formItems, departments } = this.state
const { orgCode, sellerCode } = data
const key = `${sellerCode}${orgCode}`
const item = getFormItem(formItems, 'departmentCode')
if (isBlank(departments[key])) {
item.loading = true
const res = await service.getDepartmentsBySellerAndOrg({ orgCode, sellerCode, scopeFlag: 'Y' })
item.loading = false
departments[key] = R.pathOr([], ['data', 'relationships'])(res)
}
item.options = R.map(
R.applySpec({
value: R.prop('department_code'),
label: R.prop('department_name'),
}),
)(departments[key] || [])
this.setState({ formItems, departments })
}
/**
* @description: 设置部门后回调
* @param {*}
* @return {*}
*/
async setDepartmentCallback() {
const { data, formItems, departments } = this.state
const { orgCode, sellerCode, departmentCode } = data
const key = `${sellerCode}${orgCode}`
const dep = R.compose(R.find(R.propEq('department_code', departmentCode)), R.propOr([], key))(departments)
console.log(dep)
// 设置业务经理
const bmItem = getFormItem(formItems, 'businessManagerCode')
if (bmItem.show) {
bmItem.options = R.compose(
R.map(
R.applySpec({
value: R.prop('business_manager_code'),
label: R.prop('business_manager_name'),
}),
),
R.propOr([], 'business_manager_list'),
)(dep)
}
// 设置跟台员
const followerItem = getFormItem(formItems, 'surgeryFollowerCode')
if (followerItem.show) {
followerItem.options = R.compose(
R.map(
R.applySpec({
value: R.prop('surgery_follower_code'),
label: R.prop('surgery_follower_name'),
}),
),
R.propOr([], 'surgery_follower_list'),
)(dep)
}
// 设置送货员
const item = getFormItem(formItems, 'deliverymanCode')
if (item.show) {
item.options = R.compose(
R.map(
R.applySpec({
value: R.prop('deliveryman_code'),
label: R.prop('deliveryman_name'),
}),
),
R.propOr([], 'surgery_follower_list'),
)(dep)
}
this.setState({ formItems })
}
/**
* @description: 获取客户列表
* @param {*}
* @return {*}
*/
async getCustomers() {
const { data, formItems, allCustomers } = this.state
const { orgCode, sellerCode } = data
let customers = R.propOr([], orgCode)(allCustomers)
const item = getFormItem(formItems, 'customerCode')
if (isBlank(customers)) {
item.loading = true
await this.props.getCustomers(sellerCode, orgCode)
item.loading = false
customers = R.propOr([], orgCode)(this.props.allCustomers)
}
item.options = R.map(
R.applySpec({
label: R.prop('customer_name'),
value: R.prop('customer_code'),
}),
)(customers)
this.setState({ formItems })
}
/**
* @description: 客户选择完回调
* @param {*}
* @return {*}
*/
setCustomerCallback() {
const { formItems, data, allCustomers } = this.state
const { orgCode, customerCode } = data
const customer = R.find(R.propEq('customer_code', customerCode))(allCustomers[orgCode] || [])
const item = getFormItem(formItems, 'billToSiteCode')
if (isBlank(customer)) {
item.options = []
} else {
item.options = R.map(
R.applySpec({
label: R.prop('bill_to_site_name'),
value: R.prop('bill_to_site_code'),
shipToSites: R.propOr([], 'ship_to_sites'),
}),
)(customer.bill_to_sites)
}
this.setState({ formItems })
}
/**
* @description: 收单地点选择完回调
* @param {*}
* @return {*}
*/
setBillToSitesCallback() {
let { formItems, data, doctorNames } = this.state
const { billToSiteCode } = data
const item = getFormItem(formItems, 'shipToSiteCode')
const billItem = getFormItem(formItems, 'billToSiteCode')
const billToSiteItem = R.find(R.propEq('value', billToSiteCode))(billItem.options || [])
const doctorItem = getFormItem(formItems, 'doctorName')
if (isBlank(billToSiteItem)) {
item.options = []
doctorNames = []
doctorItem.options = []
} else {
doctorNames = R.compose(R.filter(isNotBlank), R.uniq, R.pluck('customer_name'))(billToSiteItem.shipToSites)
doctorItem.options = R.map(R.applySpec({ label: R.identity, value: R.identity }))(doctorNames)
item.options = R.compose(
R.map(
R.applySpec({
label: R.prop('ship_to_site_name'),
value: R.prop('ship_to_site_code'),
doctorName: R.prop('customer_doctor'),
authorization: R.prop('authorization'),
sal_seller_customer_product_authorization: R.prop('sal_seller_customer_product_authorization'),
}),
),
)(billToSiteItem.shipToSites || [])
}
this.setState({ formItems, doctorNames })
}
/**
* @description: 收货地点选择完回调
* @param {*}
* @return {*}
*/
setShipToSiteCallback() {
const { shipToSiteCode } = this.state.data
// 借货仓库依赖收货地址
if (isNotBlank(shipToSiteCode)) {
this.getInventories()
}
}
/**
* @description: 获取借货仓库
* @param {*}
* @return {*}
*/
async getInventories() {
const { formItems, data, invs } = this.state
const { orgCode, customerCode, billToSiteCode, shipToSiteCode } = data
const item = getFormItem(formItems, 'collectSrcInvCode')
let invRes = await api.getCollectSetting({
orgCode,
customerCode,
billToSiteCode,
shipToSiteCode,
processCode: 'COLLECT',
})
item.options = R.compose(
R.uniqBy(R.prop('source_inv_code')),
R.map(
R.applySpec({
label: R.prop('source_inv_name'),
value: R.prop('source_inv_code'),
}),
),
R.propOr([], 'data'),
)(invRes)
this.setState({ formItems })
}
/**
* @description: 订单类型
* @return {*}
*/
async getOrderTypes() {
let { data, orderTypes, formItems } = this.state
const { token } = this.props
if (isBlank(orderTypes[data.orgCode])) {
const res = await this.props.getOrderTypes(token, data.orgCode)
orderTypes[data.orgCode] = res
}
const item = getFormItem(formItems, 'orderTypeCode')
item.options = R.compose(
R.uniqBy(R.prop('value')),
R.map(
R.applySpec({
label: R.prop('value_name'),
value: R.prop('value_code'),
}),
),
)(orderTypes[data.orgCode] || [])
this.setState({ formItems })
}
/**
* @description:
* @param {*}
* @return {*}
*/
submitHandler() {
console.log('submit')
}
render() {
return super.render()
}
}
}
......@@ -2,17 +2,24 @@
* @FilePath: /BoneHouse_Business_APP/src/pages/order/self.formItem.ts
* @Author: PEII
* @Date: 2022-10-27 15:10:32
* @LastEditTime: 2022-11-02 12:16:05
* @LastEditTime: 2022-11-24 21:12:12
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 自助下单formItem数据
*/
// @ts-nocheck
import * as R from 'ramda'
import { FieldType, SelectMode } from '../../enums'
import { IFormField } from 'bonehouse'
import { FieldType, SelectMode } from '../../enums'
import { getOrderSysProfile } from '../../utils/utils'
export function getSelfFormItems(): IFormField[] {
const srcInvProfile = getOrderSysProfile('OBS_MOBILE_BOR_WARE_REQUIRED')
const departmentProfile = getOrderSysProfile('OBS_MOBILE_DEPARTMENT_DISPLAY')
const businessManagerProfile = getOrderSysProfile('OBS_MOBILE_BM_DISPLAY')
const followerProfile = getOrderSysProfile('OBS_MOBILE_SUR_FOLLOWER_DISPLAY')
const deliverymanProfile = getOrderSysProfile('OBS_MOBILE_DELIVERYMAN_DISPLAY')
return [
{
field: 'sellerCode',
......@@ -40,7 +47,7 @@ export function getSelfFormItems(): IFormField[] {
value: R.prop('org_code'),
}),
),
R.uniqBy(R.prop('org_code'))
R.uniqBy(R.prop('org_code')),
)(this.props.organizations || [])
})(),
placeholder: '请选择',
......@@ -48,6 +55,47 @@ export function getSelfFormItems(): IFormField[] {
callback: this.setOrgCallback.bind(this),
},
{
field: 'departmentCode',
label: '部门',
type: FieldType.SELECT,
placeholder: '请选择',
show: departmentProfile.show,
options: [],
rules: [{ required: departmentProfile.required, message: '请选择客户' }],
refrence: ['orgCode'],
callback: this.setDepartmentCallback.bind(this),
},
{
field: 'businessManagerCode',
label: '业务经理',
type: FieldType.SELECT,
placeholder: '请选择',
show: businessManagerProfile.show,
options: [],
rules: [{ required: businessManagerProfile.required, message: '请选择业务经理' }],
refrence: ['orgCode', 'departmentCode'],
},
{
field: 'surgeryFollowerCode',
label: '跟台员',
type: FieldType.SELECT,
placeholder: '请选择',
show: followerProfile.show,
options: [],
rules: [{ required: followerProfile.required, message: '请选择跟台员' }],
refrence: ['orgCode', 'departmentCode'],
},
{
field: 'deliverymanCode',
label: '送货员',
type: FieldType.SELECT,
placeholder: '请选择',
show: deliverymanProfile.show,
options: [],
rules: [{ required: deliverymanProfile.required, message: '请选择送货员' }],
refrence: ['orgCode', 'departmentCode'],
},
{
field: 'customerCode',
label: '客户',
type: FieldType.SELECT,
......@@ -80,10 +128,10 @@ export function getSelfFormItems(): IFormField[] {
{
field: 'doctorName',
label: '主治医生',
type: FieldType.SELECT,
options: [],
placeholder: '请选择',
refrence: ['orgCode', 'customerCode', 'billToSiteCode', 'shipToSiteCode'],
type: FieldType.TEXT,
// options: [],
placeholder: '请输入',
// refrence: ['orgCode', 'customerCode', 'billToSiteCode', 'shipToSiteCode'],
},
{
field: 'surgeryDate',
......@@ -99,15 +147,7 @@ export function getSelfFormItems(): IFormField[] {
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),
options: [],
},
{
field: 'products',
......@@ -124,7 +164,9 @@ export function getSelfFormItems(): IFormField[] {
label: '借货仓库',
type: FieldType.SELECT,
placeholder: '请选择',
show: srcInvProfile.show,
options: [],
rules: [{ required: srcInvProfile.required, message: '请选择借货仓库' }],
refrence: ['orgCode', 'sellerCode', 'customerCode', 'billToSiteCode', 'shipToSiteCode'],
},
{
......@@ -171,5 +213,10 @@ export function getSelfFormItems(): IFormField[] {
type: FieldType.VOICE,
placeholder: '还有什么要安排的,可录音备注哟!',
},
{
field: 'imageUrl',
label: '添加图片',
type: FieldType.IMAGE,
},
]
}
......@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/pages/order/self.tsx
* @Author: peii
* @Date: 2021-07-13 22:40:12
* @LastEditTime: 2022-11-21 15:21:52
* @LastEditTime: 2022-11-24 21:20:19
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 自助下单
......@@ -17,11 +17,13 @@ import * as R from 'ramda'
import { connect } from 'react-redux'
import Resolution from '../../components/common/Resolution'
import Form from '../../components/form'
import Order from './hoc/order'
import { FieldType, SelectMode } from '../../enums'
import Header from '../../components/header/header'
import { g, getFormItem, isBlank, isNotBlank, show, getOrderSysProfile } from '../../utils/utils'
import { getSelfFormItems } from './self.formItem'
import { getCustomers, getCollectSetting } from '../../actions/userAction'
import { requestSelfOrderType } from '../../../app/action/SelfAction'
import styles from './self.styl'
type IProps = {
......@@ -31,6 +33,7 @@ type IProps = {
allCustomers: {}
getCustomers: (sellerCode: string, orgCode: string) => Promise<any>
getCollectSetting: (orgCode, customerCode, billToSiteCode, shipToSiteCode) => Promise<any>
getOrderTypes: (token, orgCode) => Promise<any>
}
type IState = {
......@@ -41,344 +44,38 @@ type IState = {
}
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.userInfo.user_name,
replaceItemFlag: 'N',
Caller: 'dingding',
},
formItems: [],
invs: {},
}
componentDidMount() {
const formItems = getSelfFormItems.call(this)
this.setState({ formItems }, () => {
this.setOptionsFormItems()
this.setState({ data: this.state.data })
})
}
componentWillUnmount() {}
/**
* @description: 设置配置性的表单字段(部门,业务经理,跟台员,送货员)
*/
setOptionsFormItems() {
let { formItems } = this.state
// 部门(00)第一位显示、第二位必需
let dep = getOrderSysProfile('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 = getOrderSysProfile('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 = getOrderSysProfile('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 = getOrderSysProfile('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 { show } = getOrderSysProfile('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: 获取客户列表
* @description: 产品选择点击回调
* @param {*}
* @return {*}
*/
async getCustomers() {
selectProductsBeforeHandler() {
const { data, formItems } = this.state
const { orgCode, sellerCode } = data
let customers = R.propOr([], orgCode)(this.props.allCustomers)
const item = getFormItem(formItems, 'customerCode')
if (isBlank(customers)) {
item.loading = true
await this.props.getCustomers(sellerCode, orgCode)
item.loading = false
customers = R.propOr([], orgCode)(this.props.allCustomers)
}
console.log(customers)
item.options = R.map(
R.applySpec({
label: R.prop('customer_name'),
value: R.prop('customer_code'),
}),
)(customers)
this.setState({ formItems })
}
/**
* @description: 客户选择完回调
* @param {*}
* @return {*}
*/
setCustomerCallback() {
const { formItems, data } = this.state
const { orgCode, customerCode } = data
const customer = R.find(R.propEq('customer_code', customerCode))(this.props.allCustomers[orgCode] || [])
const item = getFormItem(formItems, 'billToSiteCode')
item.options = R.map(
R.applySpec({
label: R.prop('bill_to_site_name'),
value: R.prop('bill_to_site_code'),
shipToSites: R.propOr([], 'ship_to_sites'),
}),
)(customer.bill_to_sites)
this.setState({ formItems })
}
/**
* @description: 收单地点选择完回调
* @param {*}
* @return {*}
*/
setBillToSitesCallback() {
let { formItems, data, doctorNames } = this.state
const { billToSiteCode } = data
console.log(data)
const item = getFormItem(formItems, 'shipToSiteCode')
const billItem = getFormItem(formItems, 'billToSiteCode')
const billToSiteItem = R.find(R.propEq('value', billToSiteCode))(billItem.options || [])
doctorNames = R.compose(R.uniq, R.pluck('customer_name'))(billToSiteItem.shipToSites)
const doctorItem = getFormItem(formItems, 'doctorName')
doctorItem.options = R.map(R.applySpec({ label: R.identity, value: R.identity }))(doctorNames)
item.options = R.compose(
R.map(
R.applySpec({
label: R.prop('ship_to_site_name'),
value: R.prop('ship_to_site_code'),
doctorName: R.prop('customer_doctor'),
}),
),
)(billToSiteItem.shipToSites || [])
this.setState({ formItems, doctorNames })
}
/**
* @description: 收货地点选择完回调
* @param {*}
* @return {*}
*/
setShipToSiteCallback() {
const { shipToSiteCode } = this.state.data
// 借货仓库依赖收货地址
if (isNotBlank(shipToSiteCode)) {
this.getInventories()
}
}
/**
* @description: 获取借货仓库
* @param {*}
* @return {*}
*/
async getInventories() {
const { formItems, data, invs } = this.state
const { orgCode, customerCode, billToSiteCode, shipToSiteCode } = data
const item = getFormItem(formItems, 'collectSrcInvCode')
const key = `${orgCode}_${customerCode}_${billToSiteCode}_${shipToSiteCode}`
if (isBlank(invs[key])) {
let invRes = await this.props.getCollectSetting(orgCode, customerCode, billToSiteCode, shipToSiteCode)
const options = R.compose(
R.uniqBy(R.prop('value')),
R.map(
R.applySpec({
value: R.prop('source_inv_code'),
label: R.prop('source_inv_name'),
}),
),
R.propOr([], 'payload'),
)(invRes)
invs[key] = options
}
item.options = invs[key]
console.log(item.options)
const value = R.find(R.propEq('value', data.shipToSiteCode))(item.options)
console.log(value)
this.setState({ formItems, invs })
}
/**
* @description: 产品选择点击回调
* @param {*}
* @return {*}
*/
selectProductsBeforeHandler() {
// const { data } = this.state
// this.props.navigation.navigate('Productions', {
// orgCode: data.orgCode,
// callback: productions => {
// console.log(productions)
// },
// })
this.props.navigation.navigate('ChooseProductPage', {
title: `选择产品`,
selfData: {
org_code: data.orgCode,
},
productCallBack: productions => {
console.log(productions)
},
})
}
/**
* @description:
* @param {*}
* @return {*}
*/
submitHandler() {}
render() {
const { formItems, data } = this.state
const { navigation } = this.props
......@@ -409,9 +106,11 @@ class SelfOrder extends Component<IProps, IState> {
}
const mapStateToProps = state => ({
token: state.login.token,
userInfo: state.login.userInfo,
organizations: state.user.organizations,
allCustomers: state.user.customers,
srcInvs: state.user.srcInvs,
})
const mapDispatchToProps = dispatch => ({
......@@ -421,6 +120,14 @@ const mapDispatchToProps = dispatch => ({
})
},
/**
* @description: 借货设置
* @param {*} orgCode
* @param {*} customerCode
* @param {*} billToSiteCode
* @param {*} shipToSiteCode
* @return {*}
*/
getCollectSetting(orgCode, customerCode, billToSiteCode, shipToSiteCode) {
return new Promise(resolve => {
dispatch(
......@@ -435,6 +142,23 @@ const mapDispatchToProps = dispatch => ({
)
})
},
/**
* @description: 获取订单类型
* @param {*} access_token
* @param {*} org_code
* @return {*}
*/
getOrderTypes(access_token, org_code) {
const params = { access_token, org_code, value_set_code: 'SUR_ORDER_TYPE', order_type: 'SUR_ORDER_TYPE' }
return new Promise(resolve => {
dispatch(
requestSelfOrderType(params, null, res => {
resolve(res)
}),
)
})
},
})
export default connect(mapStateToProps, mapDispatchToProps)(SelfOrder)
export default connect(mapStateToProps, mapDispatchToProps)(Order(SelfOrder))
......@@ -267,7 +267,7 @@ class Filter extends React.Component<IProps, IState> {
const mapStateToProps = state => ({
userInfo: state.login.userInfo,
sysProfiles: state.login.sysProfiles,
organizations: state.login.organizations,
organizations: state.user.organizations,
})
const mapDispatchToProps = dispatch => ({})
......
......@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/reducers/user.ts
* @Author: PEII
* @Date: 2022-11-02 16:02:14
* @LastEditTime: 2022-11-04 18:39:31
* @LastEditTime: 2022-11-24 16:32:06
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
......@@ -15,7 +15,7 @@ const initState = {
organizations: [],
inventories: [],
customers: {},
srcInvs: {},
srcInvs: [],
}
type IAction = {
......@@ -38,7 +38,6 @@ export const user = createReducer(initState, {
},
[GET_COLLECT_SETTING](state: any, action: IAction) {
console.log(action)
return state
return {...state, srcInvs: action.payload}
},
})
......@@ -73,6 +73,7 @@ declare module 'bonehouse' {
order?: number
minuteInterval?: number
symmetric?: string
show?: boolean
[key: string]: any
}
......
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