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
......@@ -12,16 +12,16 @@ import {
SET_SYSPROFILE,
SET_SYSVALUESET,
SET_NAVIGATION,
SET_ORGANIZATION
} from '../../base/ActionTypes';
SET_ORGANIZATION,
} from '../../base/ActionTypes'
// 登录状态
const defaultState = {
loginState:LOGIN_NO, // 登录状态
userInfo:{}, // 保存用户信息
token:null,
username:'',
password:'',
loginState: LOGIN_NO, // 登录状态
userInfo: {}, // 保存用户信息
token: null,
username: '',
password: '',
global_domain_config: 'https://obs.uat.guke.tech',
hasSetDomainFromOrigin: false,
local_version_apk: '',
......@@ -29,102 +29,116 @@ const defaultState = {
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_FEE_TYPE: [],
SUR_ORDER_TYPE: [],
},
organizations: []
organizations: [],
}
// 默认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: 0,
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_FEE_TYPE: [],
SUR_ORDER_TYPE: [],
}
export default login = (state = defaultState, action) => {
switch (action.type) {
case LOGIN_DOING:
return Object.assign({}, state, {
loginState: LOGIN_DOING
});
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
});
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
});
loginState: LOGIN_FAILURE,
})
case EXIT_LOGIN:
return Object.assign({}, state,{
return Object.assign({}, state, {
token: null,
loginState:LOGIN_NO,
userInfo:{},
loginState: LOGIN_NO,
userInfo: {},
// password: ''
});
})
case AUTO_LOGIN_SUCCESS:
return Object.assign({}, state, {
loginState: LOGIN_SUCCESS,
userInfo: action.rawData,
token: action.rawData.access_token
});
token: action.rawData.access_token,
})
case AUTO_LOGIN_FAILURE:
return Object.assign({}, state, {
loginState: LOGIN_FAILURE
});
loginState: LOGIN_FAILURE,
})
case SET_DOMAIN_CONFIGURATE:
return Object.assign({}, state, {
global_domain_config: action.global_domain_config
global_domain_config: action.global_domain_config,
})
case SET_DOMAIN_FROM_ORIGIN:
return Object.assign({}, state, {
hasSetDomainFromOrigin: action.data
hasSetDomainFromOrigin: action.data,
})
case SET_VERSION_APK:
return Object.assign({}, state, {
local_version_apk: action.local_version_apk
local_version_apk: action.local_version_apk,
})
case SET_SYSPROFILE:
return Object.assign({}, state, {
sysProfiles: {
...state.sysProfiles,
[action.code]: action.value
}
[action.code]: action.value,
},
})
case SET_SYSVALUESET:
return Object.assign({}, state, {
sysValueSets: {
...state.sysValueSets,
[action.code]: action.value
}
[action.code]: action.value,
},
})
case SET_NAVIGATION:
return Object.assign({}, state, {
navigation: action.navigation
navigation: action.navigation,
})
case SET_ORGANIZATION:
return Object.assign({}, state, {
organizations: action.organizations
organizations: action.organizations,
})
default: // need this for default case
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: '还有什么要安排的,可录音备注哟!',
},
]
}
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