Commit 55ab9255 by peii

user reducers

parent 7848348c
......@@ -3,7 +3,7 @@ import { Easing, Animated } from 'react-native'
import { createStackNavigator, createAppContainer } from 'react-navigation'
import LoginPage from './containers/login/LoginPage'
import HomePage from './containers/home/HomePage'
import SelfOrderPage from './containers/selfOrder/SelfOrderPage'
// import SelfOrderPage from './containers/selfOrder/SelfOrderPage'
import ChooseProductPage from './containers/selfOrder/module/ChooseProductPage'
import SearchPage from './containers/selfOrder/module/SearchPage'
import EditThirdLevelPage from './containers/selfOrder/module/EditThirdLevelPage'
......@@ -24,6 +24,9 @@ import LineOrderPage from './containers/historicalOrder/module/LineOrderPage'
import SubSuccPage from './containers/common/SubSuccPage'
import BarCodePage from './containers/common/BarCodePage'
// 下单
import SelfOrder from '../src/pages/order/self'
// 结算
import Settlement from '../src/pages/settlement/index'
import SettlementCollection from '../src/pages/settlement/collection'
......@@ -53,7 +56,7 @@ const Router = createAppContainer(
{
LoginPage: { screen: LoginPage },
HomePage: { screen: HomePage },
SelfOrderPage: { screen: SelfOrderPage },
SelfOrder: { screen: SelfOrder },
ChooseProductPage: { screen: ChooseProductPage },
SearchPage: { screen: SearchPage },
EditThirdLevelPage: { screen: EditThirdLevelPage },
......@@ -93,7 +96,6 @@ const Router = createAppContainer(
MixConsume: { screen: MixConsume },
MixConsumeForm: { screen: MixConsumeForm },
MixConsumeItems: { screen: MixConsumeItems },
},
{
navigationOptions: {
......
......@@ -17,6 +17,7 @@ import {
import { GetRequest, PostRequest } from '../network/RequestUtils';
import { getUrlParams, show, showWarnErrorMessage, showErrorMessage, isNotBlank } from '../utils/Utils';
import { originSysProfiles, originSysValueSets } from '../reducers/module/login';
import { toBinaryNumber } from '../../src/utils/utils';
export function requestLogin(params) {
return (dispatch, getState) => {
......@@ -183,7 +184,7 @@ export function getSysProfiles() {
console.log(profile_code, res)
let value = R.pathOr(originSysProfiles[profile_code], ['data', 'profile_value'])(res)
if (isNotBlank(value) && !isNaN(value)) value = parseInt(value)
if (isNotBlank(value) && !isNaN(value)) value = toBinaryNumber(value)
dispatch(setSysProfiles(profile_code, value))
})
}
......
......@@ -14,6 +14,7 @@ import {
font_family_regular,
} from '../../base/BaseStyle'
import { exitLoginStatus, requestSysProfile, setNavigation, getOrganizationData } from '../../action/LoginAction'
import { getOrganizations } from '../../../src/actions/userAction'
import { getLendOrderCodeValues } from '../../action/SelfAction'
import { getSettlementStatus, getInvoiceStatus, getArInvoiceStatus } from '../../action/SettlementAction'
import HeadBackItem from '../common/HeadBackItem'
......@@ -49,7 +50,7 @@ class HomePage extends Component {
MOBILE_SELF_HELP_ORDER: {
icon: require('../../images/self_order.png'),
title: '自助下单',
page: 'SelfOrderPage',
page: 'SelfOrder',
params: {
isLendOrder: false,
},
......@@ -230,7 +231,6 @@ class HomePage extends Component {
this.props.getInvoiceStatus()
// 分销开票状态
this.props.getArInvoiceStatus()
}
getLendOrderCodeValues() {
......@@ -396,8 +396,8 @@ const mapDispatchToProps = dispatch => ({
dispatch(getLendOrderCodeValues())
},
getOrganizationData: () => {
dispatch(getOrganizationData())
}
dispatch(getOrganizations())
},
})
export default connect(mapStateToProps, mapDispatchToProps)(HomePage)
......@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/app/reducers/index.js
* @Author: peii
* @Date: 2021-02-03 20:59:10
* @LastEditTime: 2022-08-04 17:36:19
* @LastEditTime: 2022-11-02 16:29:41
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
......@@ -19,6 +19,8 @@ import deviceInfo from './module/deviceInfo';
import settlement from './module/settlement';
import mixConsume from './module/mixConsume';
import { user } from '../../src/reducers/user';
const loginConfig = {
key: 'login',
storage,
......@@ -92,6 +94,7 @@ const rootReducer = {
deviceInfo: persistReducer(deviceConfig, deviceInfo),
settlement: persistReducer(settlementConfig, settlement),
mixConsume: persistReducer(mixConsumeConfig, mixConsume),
user
}
export default rootReducer;
\ No newline at end of file
import {
LOGIN_NO,
LOGIN_DOING,
LOGIN_SUCCESS,
LOGIN_FAILURE,
EXIT_LOGIN,
AUTO_LOGIN_SUCCESS,
AUTO_LOGIN_FAILURE,
SET_DOMAIN_CONFIGURATE,
SET_VERSION_APK,
SET_DOMAIN_FROM_ORIGIN,
SET_SYSPROFILE,
SET_SYSVALUESET,
SET_NAVIGATION,
SET_ORGANIZATION
} from '../../base/ActionTypes';
LOGIN_NO,
LOGIN_DOING,
LOGIN_SUCCESS,
LOGIN_FAILURE,
EXIT_LOGIN,
AUTO_LOGIN_SUCCESS,
AUTO_LOGIN_FAILURE,
SET_DOMAIN_CONFIGURATE,
SET_VERSION_APK,
SET_DOMAIN_FROM_ORIGIN,
SET_SYSPROFILE,
SET_SYSVALUESET,
SET_NAVIGATION,
SET_ORGANIZATION,
} from '../../base/ActionTypes'
// 登录状态
const defaultState = {
loginState:LOGIN_NO, // 登录状态
userInfo:{}, // 保存用户信息
token:null,
username:'',
password:'',
global_domain_config: 'https://obs.uat.guke.tech',
hasSetDomainFromOrigin: false,
local_version_apk: '',
navigation: null,
sysProfiles: {
OBS_SHOW_ORG_FLAG: 'Y',
SUR_MOBILE_HISTORY_SALE_PRICE_SHOW_FLAG: 'Y',
SUR_MOBILE_INV_PRODUCT_LINE_CATEGORY_FLAG: 0,
OBS_MOBILE_APP_TITLE: '骨科智慧仓',
OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY: 'N',
},
sysValueSets: {
SUR_FEE_TYPE: []
},
organizations: []
}
// 默认sysProfile,放state里时,会被持久化影响后面更新不了
export const originSysProfiles = {
loginState: LOGIN_NO, // 登录状态
userInfo: {}, // 保存用户信息
token: null,
username: '',
password: '',
global_domain_config: 'https://obs.uat.guke.tech',
hasSetDomainFromOrigin: false,
local_version_apk: '',
navigation: null,
sysProfiles: {
OBS_SHOW_ORG_FLAG: 'Y',
SUR_MOBILE_HISTORY_SALE_PRICE_SHOW_FLAG: 'Y',
SUR_MOBILE_INV_PRODUCT_LINE_CATEGORY_FLAG: 0,
SUR_MOBILE_INV_PRODUCT_LINE_CATEGORY_FLAG: '00',
OBS_MOBILE_APP_TITLE: '骨科智慧仓',
OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY: 'N',
OBS_MOBILE_DEPARTMENT_DISPLAY: '00',
OBS_MOBILE_BM_DISPLAY: '00',
OBS_MOBILE_SUR_FOLLOWER_DISPLAY: '00',
OBS_MOBILE_DELIVERYMAN_DISPLAY: '00',
},
sysValueSets: {
SUR_FEE_TYPE: [],
SUR_ORDER_TYPE: [],
},
organizations: [],
}
export const originSysValueSets = {
SUR_FEE_TYPE: []
// 默认sysProfile,放state里时,会被持久化影响后面更新不了
export const originSysProfiles = {
OBS_SHOW_ORG_FLAG: 'Y',
SUR_MOBILE_HISTORY_SALE_PRICE_SHOW_FLAG: 'Y',
SUR_MOBILE_INV_PRODUCT_LINE_CATEGORY_FLAG: '00',
OBS_MOBILE_APP_TITLE: '骨科智慧仓',
OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY: 'N',
// APP下单是否显示部门权限
OBS_MOBILE_DEPARTMENT_DISPLAY: '00',
// APP下单是否显示业务经理权限
OBS_MOBILE_BM_DISPLAY: '00',
// APP下单是否显示跟台员权限
OBS_MOBILE_SUR_FOLLOWER_DISPLAY: '00',
// APP下单是否显示送货员权限
OBS_MOBILE_DELIVERYMAN_DISPLAY: '00',
}
export const originSysValueSets = {
SUR_FEE_TYPE: [],
SUR_ORDER_TYPE: [],
}
export default login = (state = defaultState, action) => {
switch (action.type) {
case LOGIN_DOING:
return Object.assign({}, state, {
loginState: LOGIN_DOING
});
case LOGIN_SUCCESS:
return Object.assign({}, state, {
loginState:LOGIN_SUCCESS,
userInfo:action.rawData,
token:action.rawData.access_token,
username:action.username,
password:action.password
});
case LOGIN_FAILURE:
return Object.assign({}, state, {
loginState:LOGIN_FAILURE
});
case EXIT_LOGIN:
return Object.assign({}, state,{
token: null,
loginState:LOGIN_NO,
userInfo:{},
// password: ''
});
case AUTO_LOGIN_SUCCESS:
return Object.assign({}, state, {
loginState: LOGIN_SUCCESS,
userInfo: action.rawData,
token: action.rawData.access_token
});
case AUTO_LOGIN_FAILURE:
return Object.assign({}, state, {
loginState: LOGIN_FAILURE
});
case SET_DOMAIN_CONFIGURATE:
return Object.assign({}, state, {
global_domain_config: action.global_domain_config
})
case SET_DOMAIN_FROM_ORIGIN:
return Object.assign({}, state, {
hasSetDomainFromOrigin: action.data
})
case SET_VERSION_APK:
return Object.assign({}, state, {
local_version_apk: action.local_version_apk
})
case SET_SYSPROFILE:
return Object.assign({}, state, {
sysProfiles: {
...state.sysProfiles,
[action.code]: action.value
}
})
case SET_SYSVALUESET:
return Object.assign({}, state, {
sysValueSets: {
...state.sysValueSets,
[action.code]: action.value
}
})
case SET_NAVIGATION:
return Object.assign({}, state, {
navigation: action.navigation
})
case SET_ORGANIZATION:
return Object.assign({}, state, {
organizations: action.organizations
})
default: // need this for default case
return state
}
switch (action.type) {
case LOGIN_DOING:
return Object.assign({}, state, {
loginState: LOGIN_DOING,
})
case LOGIN_SUCCESS:
return Object.assign({}, state, {
loginState: LOGIN_SUCCESS,
userInfo: action.rawData,
token: action.rawData.access_token,
username: action.username,
password: action.password,
})
case LOGIN_FAILURE:
return Object.assign({}, state, {
loginState: LOGIN_FAILURE,
})
case EXIT_LOGIN:
return Object.assign({}, state, {
token: null,
loginState: LOGIN_NO,
userInfo: {},
// password: ''
})
case AUTO_LOGIN_SUCCESS:
return Object.assign({}, state, {
loginState: LOGIN_SUCCESS,
userInfo: action.rawData,
token: action.rawData.access_token,
})
case AUTO_LOGIN_FAILURE:
return Object.assign({}, state, {
loginState: LOGIN_FAILURE,
})
case SET_DOMAIN_CONFIGURATE:
return Object.assign({}, state, {
global_domain_config: action.global_domain_config,
})
case SET_DOMAIN_FROM_ORIGIN:
return Object.assign({}, state, {
hasSetDomainFromOrigin: action.data,
})
case SET_VERSION_APK:
return Object.assign({}, state, {
local_version_apk: action.local_version_apk,
})
case SET_SYSPROFILE:
return Object.assign({}, state, {
sysProfiles: {
...state.sysProfiles,
[action.code]: action.value,
},
})
case SET_SYSVALUESET:
return Object.assign({}, state, {
sysValueSets: {
...state.sysValueSets,
[action.code]: action.value,
},
})
case SET_NAVIGATION:
return Object.assign({}, state, {
navigation: action.navigation,
})
case SET_ORGANIZATION:
return Object.assign({}, state, {
organizations: action.organizations,
})
default:
// need this for default case
return state
}
}
/*
* @FilePath: /BoneHouse_Business_APP/src/actions/action-types.ts
* @Author: PEII
* @Date: 2022-11-02 16:41:21
* @LastEditTime: 2022-11-02 16:52:16
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
*/
export const GET_ORGANIZATIONS = 'GET_ORGANIZATIONS'
export const GET_CUSTOMERS = 'GET_CUSTOMERS'
\ No newline at end of file
/*
* @FilePath: /BoneHouse_Business_APP/src/actions/userAction.ts
* @Author: PEII
* @Date: 2022-11-02 16:09:29
* @LastEditTime: 2022-11-02 16:56:49
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
*/
import { createApiAction } from './utils'
import { GET_ORGANIZATIONS, GET_CUSTOMERS } from './action-types'
import api from '../services/api'
export const getOrganizations = createApiAction(GET_ORGANIZATIONS, api.getOrganizations)
export const getCustomers = createApiAction(GET_CUSTOMERS, (params: any) => api.getCustomers(params))
import { curry, compose, reject, isNil, applySpec, always, __, Dictionary, identity, type } from 'ramda'
import { request } from '../services/baseApi'
/**
* 创建action
* @param type {string}
* @param getPayload {Func}
* @param getMeta {Func}
*/
export const createAction = curry((type: string, getPayload: Function, getMeta: Function) =>
compose(
reject(isNil),
applySpec({
type: always(type),
payload: getPayload,
meta: getMeta,
}),
),
)
/**
* 创建简单action
* @param type {string} 类型
* @param payload {any}
* @return
*/
export const createSimpleAction: (string, any?) => Dictionary<any> = createAction(__, identity, always(null))
/**
* 创建常量action
* @param type {string} 类型
* @return
*/
export const createConstantAction: (string) => Dictionary<any> = createAction(__, always(null), always(null))
export const createApiAction = curry((actionType: string, fn: Function) => {
return (params = {}, callback = { success: <U>(p: U) => {}, fail: <R>(p: R) => {} }, customActionType = actionType) =>
async (dispatch: Function) => {
try {
dispatch({ type: `${customActionType}_REQUEST`, params })
if (type(fn) !== 'Function') {
throw new Error(`参数【${fn.toString()}】不是可调用函数`)
}
let data = await fn(params)
if (data && data.error_code === 0) {
dispatch({ type: `${customActionType}`, payload: data.data })
callback.success && callback.success({ payload: data.data })
return data.data
} else {
throw new Error('请求数据失败')
}
} catch (error) {
console.log({ type: `${customActionType}_FAILURE`, payload: error })
dispatch({ type: `${customActionType}_FAILURE`, payload: error })
callback.fail && callback.fail(error)
}
}
})
export const createSimpleApiAction = createApiAction(__, request)
......@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/pages/mix_consume/index.tsx
* @Author: PEII
* @Date: 2022-08-02 16:40:21
* @LastEditTime: 2022-10-13 17:52:12
* @LastEditTime: 2022-10-28 17:58:04
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 混单报消耗
......@@ -20,7 +20,6 @@ import Header from '../../components/header/header'
import Resolution from '../../components/common/Resolution'
import Search from './components/search'
import { isBlank, g, show } from '../../utils/utils'
import api from '../../services/api'
import { setOrders } from '../../../app/action/MixConsumeAction'
import styles from './index.styl'
......
{
"$schema": "../../../types/formitem.schema.json",
"formItems": [
{
"label": "临床科室",
"type": "SELECT",
"disabled": true,
"rules": [{ "required": true }],
"options": [
{
"value": "-1",
"label": "骨科关节"
}
]
},
{
"field": ""
}
]
}
/*
* @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
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 自助下单formItem数据
*/
// @ts-nocheck
import * as R from 'ramda'
import { FieldType, SelectMode } from '../../enums'
import { IFormField } from 'bonehouse'
export function getSelfFormItems(): IFormField[] {
return [
{
field: 'sellerCode',
label: '销售员',
type: FieldType.SELECT,
options: [
{
label: this.props.userInfo.person_name,
value: this.props.userInfo.user_name,
},
],
placeholder: '请选择',
rules: [{ required: true, message: '请选择销售员' }],
disabled: true,
},
{
field: 'orgCode',
label: '组织',
type: FieldType.SELECT,
options: (() => {
return R.compose(
R.map(
R.applySpec({
label: R.prop('org_name'),
value: R.prop('org_code'),
}),
),
R.uniqBy(R.prop('org_code'))
)(this.props.organizations || [])
})(),
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: '还有什么要安排的,可录音备注哟!',
},
]
}
......@@ -2,7 +2,7 @@
* @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
* @LastEditTime: 2022-11-02 19:41:00
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 自助下单
......@@ -11,63 +11,25 @@
// @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 { INavigation } from 'navigation'
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 { g, getFormItem, isBlank, isNotBlank, show, getOrderSysProfile } from '../../utils/utils'
import { getSelfFormItems } from './self.formItem'
import { getCustomers } from '../../actions/userAction'
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
}
navigation: INavigation
userInfo: any
organizations: IOrganization[]
allCustomers: {}
getCustomers: Function
}
type IState = {
......@@ -84,179 +46,30 @@ class SelfOrder extends Component<IProps, IState> {
state = {
data: {
sellerCode: this.props.userStore.userName,
sellerCode: this.props.userInfo.user_name,
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: '还有什么要安排的,可录音备注哟!',
},
],
formItems: [],
}
componentDidMount() {
this.setOptionsFormItems()
const formItems = getSelfFormItems.call(this)
this.setState({ formItems }, () => {
this.setOptionsFormItems()
})
}
componentWillUnmount() {
this.props.productionStore.resetSupplier()
this.props.productionStore.resetCategory()
}
componentWillUnmount() {}
/**
* @description: 设置配置性的表单字段(部门,业务经理,跟台员,送货员)
*/
setOptionsFormItems() {
const { sysProfiles } = this.props.sysStore
let { formItems } = this.state
// 部门(00)第一位显示、第二位必需
let dep = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
let dep = getOrderSysProfile('OBS_MOBILE_DEPARTMENT_DISPLAY')
if (dep.show) {
formItems = R.insert(
2,
......@@ -264,7 +77,7 @@ class SelfOrder extends Component<IProps, IState> {
field: 'departmentCode',
label: '部门',
type: FieldType.SELECT,
placeholder: '请选择',
placeholder: '请选择',
options: [],
rules: [{ required: dep.required, message: '请选择客户' }],
refrence: ['orgCode'],
......@@ -275,7 +88,7 @@ class SelfOrder extends Component<IProps, IState> {
}
// 业务经理(00)第一位显示、第二位必需
let businessManager = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
let businessManager = getOrderSysProfile('OBS_MOBILE_DEPARTMENT_DISPLAY')
if (businessManager.show) {
formItems = R.insert(
3,
......@@ -293,7 +106,7 @@ class SelfOrder extends Component<IProps, IState> {
}
// 跟台员(00)第一位显示、第二位必需
let follower = translateSysprofile(sysProfiles.OBS_MOBILE_SUR_FOLLOWER_DISPLAY)
let follower = getOrderSysProfile('OBS_MOBILE_SUR_FOLLOWER_DISPLAY')
if (follower.show) {
formItems = R.insert(
4,
......@@ -311,7 +124,7 @@ class SelfOrder extends Component<IProps, IState> {
}
// 送货员(00)第一位显示、第二位必需
let deliver = translateSysprofile(sysProfiles.OBS_MOBILE_DELIVERYMAN_DISPLAY)
let deliver = getOrderSysProfile('OBS_MOBILE_DELIVERYMAN_DISPLAY')
if (deliver.show) {
formItems = R.insert(
5,
......@@ -355,8 +168,7 @@ class SelfOrder extends Component<IProps, IState> {
* @return {*}
*/
async setOrgCallback() {
const sysProfiles = this.props.sysStore.sysProfiles
const { show } = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
const { show } = getOrderSysProfile('OBS_MOBILE_DEPARTMENT_DISPLAY')
// 设置完组织获取部门和客户
if (show) {
this.getDepartments.call(this)
......@@ -372,16 +184,16 @@ class SelfOrder extends Component<IProps, IState> {
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 })
// 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 })
}
/**
......@@ -394,22 +206,22 @@ class SelfOrder extends Component<IProps, IState> {
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)
}
// 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 })
}
......@@ -422,15 +234,23 @@ class SelfOrder extends Component<IProps, IState> {
async getCustomers() {
const { data, formItems } = this.state
const { orgCode, sellerCode } = data
let customers = this.props.orgStore.customers(sellerCode, orgCode)
let customers = R.propOr([], orgCode)(this.props.allCustomers)
const item = getFormItem(formItems, 'customerCode')
if (isBlank(customers)) {
item.loading = true
await this.props.orgStore.getCustomers(sellerCode, orgCode)
await this.props.getCustomers(sellerCode, orgCode)
item.loading = false
customers = this.props.orgStore.customers(sellerCode, orgCode)
customers = R.propOr([], orgCode)(this.props.allCustomers)
}
item.options = customers
console.log(customers)
item.options = R.map(
R.applySpec({
label: R.prop('customer_name'),
value: R.prop('customer_code'),
}),
)(customers)
this.setState({ formItems })
}
......@@ -442,11 +262,17 @@ class SelfOrder extends Component<IProps, IState> {
*/
setCustomerCallback() {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode } = data
const billToSites = this.props.orgStore.billToSites(sellerCode, orgCode, customerCode)
const { orgCode, customerCode } = data
const customer = R.find(R.propEq('customer_code', customerCode))(this.props.allCustomers[orgCode] || [])
const item = getFormItem(formItems, 'billToSiteCode')
item.options = billToSites
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 })
}
......@@ -457,11 +283,22 @@ class SelfOrder extends Component<IProps, IState> {
*/
setBillToSitesCallback() {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode, billToSiteCode } = data
const shipToSites = this.props.orgStore.shipToSites(sellerCode, orgCode, customerCode, billToSiteCode)
const { billToSiteCode } = data
const item = getFormItem(formItems, 'shipToSiteCode')
item.options = shipToSites
const billItem = getFormItem(formItems, 'billToSiteCode')
const billToSiteItem = R.find(R.propEq('value', billToSiteCode))(billItem.options || [])
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 })
}
......@@ -474,16 +311,33 @@ class SelfOrder extends Component<IProps, IState> {
const { formItems, data } = this.state
const { sellerCode, orgCode, customerCode, billToSiteCode, shipToSiteCode } = data
const doctors = this.props.orgStore.doctors(sellerCode, orgCode, customerCode, billToSiteCode)
const { formItems, data } = this.state
const { billToSiteCode } = data
const item = getFormItem(formItems, 'doctorName')
item.options = doctors
const shipItem = getFormItem(formItems, 'shipToSiteCode')
const billToSiteItem = R.find(R.propEq('value', billToSiteCode))(billItem.options || [])
item.options = 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 })
// 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()
}
// if (isNotBlank(shipToSiteCode)) {
// this.getInventories()
// }
}
/**
......@@ -495,22 +349,22 @@ class SelfOrder extends Component<IProps, IState> {
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 })
// 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 })
}
/**
......@@ -519,14 +373,13 @@ class SelfOrder extends Component<IProps, IState> {
* @return {*}
*/
selectProductsBeforeHandler() {
const { data } = this.state
this.props.navigation.navigate('Productions', {
orgCode: data.orgCode,
callback: productions => {
console.log(productions)
},
})
// const { data } = this.state
// this.props.navigation.navigate('Productions', {
// orgCode: data.orgCode,
// callback: productions => {
// console.log(productions)
// },
// })
}
/**
......@@ -565,8 +418,18 @@ class SelfOrder extends Component<IProps, IState> {
}
}
const mapStateToProps = state => ({})
const mapStateToProps = state => ({
userInfo: state.login.userInfo,
organizations: state.user.organizations,
allCustomers: state.user.customers,
})
const mapDispatchToProps = dispatch => ({})
const mapDispatchToProps = dispatch => ({
getCustomers(seller_code, org_code) {
return new Promise(resolve => {
dispatch(getCustomers({ seller_code, org_code }, { success: () => resolve(), fail: () => resolve() }))
})
},
})
export default connect(mapStateToProps, mapDispatchToProps)(SelfOrder)
File mode changed
/*
* @FilePath: /BoneHouse_Business_APP/src/reducers/user.ts
* @Author: PEII
* @Date: 2022-11-02 16:02:14
* @LastEditTime: 2022-11-02 17:19:01
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
*/
import * as R from 'ramda'
import { createReducer } from './utils'
import { GET_ORGANIZATIONS, GET_CUSTOMERS } from '../actions/action-types'
const initState = {
organizations: [],
inventories: [],
customers: {},
}
type IAction = {
type: string
payload: any
}
export const user = createReducer(initState, {
[GET_ORGANIZATIONS]: (state: any, action: IAction) => {
const organizations = R.compose(R.uniqBy(R.prop('org_code')), R.propOr([], 'organizations'))(action.payload)
const inventories = R.compose(R.uniqBy(R.prop('inv_code')), R.propOr([], 'inventories'))(action.payload)
return { ...state, organizations, inventories }
},
[GET_CUSTOMERS]: (state: any, action: IAction) => {
const data = action.payload
let customers = {...state.customers }
customers[data.org_code] = data.customers
return { ...state, customers }
},
})
/*
* @FilePath: /BoneHouse_Business_APP/src/reducers/utils.ts
* @Author: PEII
* @Date: 2022-10-28 19:49:08
* @LastEditTime: 2022-10-28 19:49:21
* @LastEditors: PEII
* @Vision: 1.0
* @Description: reducers
*/
// @ts-nocheck
import { identity, propOr } from 'ramda'
export interface IAction {
type: string
}
export function createReducer<U, T extends Object>(initialState: U, handlers: T) {
return <R extends IAction>(state = initialState, action: R) => propOr(identity, action.type, handlers)(state, action)
}
export default createReducer
......@@ -17,6 +17,7 @@ declare module 'bonehouse' {
export type IDepartment = {
departmentCode: string
departmentName: string
[key: string]: any
}
export type IFunction = {
......@@ -24,16 +25,19 @@ declare module 'bonehouse' {
functionCode: string
functionName: string
functionOrder: number
[key: string]: any
}
export type IInventory = {
invCode: string
invName: string
[key: string]: any
}
export type IOption = {
label: string
value: string
[key: string]: any
}
export type IRule = {
......@@ -41,6 +45,7 @@ declare module 'bonehouse' {
message?: string
pattern?: RegExp
func?: Function
[key: string]: any
}
export type IFormField = {
......@@ -62,28 +67,33 @@ declare module 'bonehouse' {
order?: number
minuteInterval?: number
symmetric?: string
[key: string]: any
}
export type IOrganization = {
orgName: string
orgCode: string
[key: string]: string
}
export type IShipToSite = {
shipToSiteCode: string
shipToSiteName: string
[key: string]: any
}
export type IBillToSite = {
billToSiteCode: string
billToSiteName: string
shipToSites: IShipToSite[]
[key: string]: any
}
export type ICustomer = {
customerCode: string
customerName: string
billToSites: IBillToSite[]
[key: string]: any
}
export type ISurgeryCollectHeader = {
......@@ -153,6 +163,7 @@ declare module 'bonehouse' {
surgeryName: string
updateBy: string
updateTime: string
[key: string]: any
}
export type ISurgeryCollectLine = {
......@@ -190,6 +201,7 @@ declare module 'bonehouse' {
feeType: string
feeAmount: number
remark: string
[key: string]: any
}
export type IPlan = {
......@@ -216,6 +228,7 @@ declare module 'bonehouse' {
zysx: string
ssDate: string
ssTime: string
[key: string]: any
}
}
......@@ -226,12 +239,14 @@ declare module 'navigation' {
push: Function
replace: Function
reset: Function
[key: string]: any
}
type IRouteState = {
params: any
routeName: string
key: string
[key: string]: any
}
export type INavigation = {
......
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