Commit e7557312 by peii

actions

parent 7a156482
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/actions/action-types.ts * @FilePath: /BoneHouse_Business_APP/src/actions/action-types.ts
* @Author: PEII * @Author: PEII
* @Date: 2022-11-02 16:41:21 * @Date: 2022-11-02 16:41:21
* @LastEditTime: 2022-11-02 16:52:16 * @LastEditTime: 2022-11-04 18:00:41
* @LastEditors: PEII * @LastEditors: PEII
* @Vision: 1.0 * @Vision: 1.0
* @Description: * @Description:
...@@ -10,3 +10,5 @@ ...@@ -10,3 +10,5 @@
export const GET_ORGANIZATIONS = 'GET_ORGANIZATIONS' export const GET_ORGANIZATIONS = 'GET_ORGANIZATIONS'
export const GET_CUSTOMERS = 'GET_CUSTOMERS' export const GET_CUSTOMERS = 'GET_CUSTOMERS'
export const GET_COLLECT_SETTING = 'GET_COLLECT_SETTING'
\ No newline at end of file
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
* @FilePath: /BoneHouse_Business_APP/src/actions/userAction.ts * @FilePath: /BoneHouse_Business_APP/src/actions/userAction.ts
* @Author: PEII * @Author: PEII
* @Date: 2022-11-02 16:09:29 * @Date: 2022-11-02 16:09:29
* @LastEditTime: 2022-11-02 16:56:49 * @LastEditTime: 2022-11-04 18:51:56
* @LastEditors: PEII * @LastEditors: PEII
* @Vision: 1.0 * @Vision: 1.0
* @Description: * @Description:
*/ */
import { createApiAction } from './utils' import { createApiAction } from './utils'
import { GET_ORGANIZATIONS, GET_CUSTOMERS } from './action-types' import { GET_ORGANIZATIONS, GET_CUSTOMERS, GET_COLLECT_SETTING } from './action-types'
import api from '../services/api' import api from '../services/api'
export const getOrganizations = createApiAction(GET_ORGANIZATIONS, api.getOrganizations) export const getOrganizations = createApiAction(GET_ORGANIZATIONS, api.getOrganizations)
export const getCustomers = createApiAction(GET_CUSTOMERS, (params: any) => api.getCustomers(params)) export const getCustomers = createApiAction(GET_CUSTOMERS, api.getCustomers)
export const getCollectSetting = createApiAction(GET_COLLECT_SETTING, api.getCollectSetting)
import { IApiAction } from 'action'
import { curry, compose, reject, isNil, applySpec, always, __, Dictionary, identity, type } from 'ramda' import { curry, compose, reject, isNil, applySpec, always, __, Dictionary, identity, type } from 'ramda'
import { request } from '../services/baseApi' import { request } from '../services/baseApi'
...@@ -31,9 +32,9 @@ export const createSimpleAction: (string, any?) => Dictionary<any> = createActio ...@@ -31,9 +32,9 @@ export const createSimpleAction: (string, any?) => Dictionary<any> = createActio
* @param type {string} 类型 * @param type {string} 类型
* @return * @return
*/ */
export const createConstantAction: (string) => Dictionary<any> = createAction(__, always(null), always(null)) export const createConstantAction: (key: string) => Dictionary<any> = createAction(__, always(null), always(null))
export const createApiAction = curry((actionType: string, fn: Function) => { export const createApiAction: IApiAction = (actionType: string, fn: Function) => {
return (params = {}, callback = { success: <U>(p: U) => {}, fail: <R>(p: R) => {} }, customActionType = actionType) => return (params = {}, callback = { success: <U>(p: U) => {}, fail: <R>(p: R) => {} }, customActionType = actionType) =>
async (dispatch: Function) => { async (dispatch: Function) => {
try { try {
...@@ -56,6 +57,6 @@ export const createApiAction = curry((actionType: string, fn: Function) => { ...@@ -56,6 +57,6 @@ export const createApiAction = curry((actionType: string, fn: Function) => {
callback.fail && callback.fail(error) callback.fail && callback.fail(error)
} }
} }
}) }
export const createSimpleApiAction = createApiAction(__, request) // export const createSimpleApiAction = createApiAction(__, request)
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/pages/order/self.tsx * @FilePath: /BoneHouse_Business_APP/src/pages/order/self.tsx
* @Author: peii * @Author: peii
* @Date: 2021-07-13 22:40:12 * @Date: 2021-07-13 22:40:12
* @LastEditTime: 2022-11-04 15:16:13 * @LastEditTime: 2022-11-04 18:56:41
* @LastEditors: PEII * @LastEditors: PEII
* @Vision: 1.0 * @Vision: 1.0
* @Description: 自助下单 * @Description: 自助下单
...@@ -21,7 +21,7 @@ import { FieldType, SelectMode } from '../../enums' ...@@ -21,7 +21,7 @@ import { FieldType, SelectMode } from '../../enums'
import Header from '../../components/header/header' import Header from '../../components/header/header'
import { g, getFormItem, isBlank, isNotBlank, show, getOrderSysProfile } from '../../utils/utils' import { g, getFormItem, isBlank, isNotBlank, show, getOrderSysProfile } from '../../utils/utils'
import { getSelfFormItems } from './self.formItem' import { getSelfFormItems } from './self.formItem'
import { getCustomers } from '../../actions/userAction' import { getCustomers, getCollectSetting } from '../../actions/userAction'
import styles from './self.styl' import styles from './self.styl'
type IProps = { type IProps = {
...@@ -29,7 +29,8 @@ type IProps = { ...@@ -29,7 +29,8 @@ type IProps = {
userInfo: any userInfo: any
organizations: IOrganization[] organizations: IOrganization[]
allCustomers: {} allCustomers: {}
getCustomers: Function getCustomers: (sellerCode: string, orgCode: string) => Promise<any>
getCollectSetting: (orgCode, customerCode, billToSiteCode, shipToSiteCode) => Promise<any>
} }
type IState = { type IState = {
...@@ -330,8 +331,11 @@ class SelfOrder extends Component<IProps, IState> { ...@@ -330,8 +331,11 @@ class SelfOrder extends Component<IProps, IState> {
const { formItems, data } = this.state const { formItems, data } = this.state
const { orgCode, customerCode, billToSiteCode, shipToSiteCode } = data const { orgCode, customerCode, billToSiteCode, shipToSiteCode } = data
// const item = getFormItem(formItems, 'collectSrcInvCode') const item = getFormItem(formItems, 'collectSrcInvCode')
// let invs = this.props.orderStore.invs(orgCode, customerCode, billToSiteCode, shipToSiteCode)
let invRes = await this.props.getCollectSetting(orgCode, customerCode, billToSiteCode, shipToSiteCode)
console.log(invRes)
// if (isBlank(invs)) { // if (isBlank(invs)) {
// item.loading = true // item.loading = true
// await this.props.orderStore.getInventories(orgCode, customerCode, billToSiteCode, shipToSiteCode) // await this.props.orderStore.getInventories(orgCode, customerCode, billToSiteCode, shipToSiteCode)
...@@ -411,6 +415,21 @@ const mapDispatchToProps = dispatch => ({ ...@@ -411,6 +415,21 @@ const mapDispatchToProps = dispatch => ({
dispatch(getCustomers({ seller_code, org_code }, { success: () => resolve(), fail: () => resolve() })) dispatch(getCustomers({ seller_code, org_code }, { success: () => resolve(), fail: () => resolve() }))
}) })
}, },
getCollectSetting(orgCode, customerCode, billToSiteCode, shipToSiteCode) {
return new Promise(resolve => {
dispatch(
getCollectSetting(
{ orgCode, customerCode, billToSiteCode, shipToSiteCode, processCode: 'COLLECT' },
{
success: res => {
resolve(res)
},
},
),
)
})
},
}) })
export default connect(mapStateToProps, mapDispatchToProps)(SelfOrder) export default connect(mapStateToProps, mapDispatchToProps)(SelfOrder)
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
* @FilePath: /BoneHouse_Business_APP/src/reducers/user.ts * @FilePath: /BoneHouse_Business_APP/src/reducers/user.ts
* @Author: PEII * @Author: PEII
* @Date: 2022-11-02 16:02:14 * @Date: 2022-11-02 16:02:14
* @LastEditTime: 2022-11-02 17:19:01 * @LastEditTime: 2022-11-04 18:39:31
* @LastEditors: PEII * @LastEditors: PEII
* @Vision: 1.0 * @Vision: 1.0
* @Description: * @Description:
*/ */
import * as R from 'ramda' import * as R from 'ramda'
import { createReducer } from './utils' import { createReducer } from './utils'
import { GET_ORGANIZATIONS, GET_CUSTOMERS } from '../actions/action-types' import { GET_ORGANIZATIONS, GET_CUSTOMERS, GET_COLLECT_SETTING } from '../actions/action-types'
const initState = { const initState = {
organizations: [], organizations: [],
inventories: [], inventories: [],
customers: {}, customers: {},
srcInvs: {},
} }
type IAction = { type IAction = {
...@@ -23,16 +24,21 @@ type IAction = { ...@@ -23,16 +24,21 @@ type IAction = {
} }
export const user = createReducer(initState, { export const user = createReducer(initState, {
[GET_ORGANIZATIONS]: (state: any, action: IAction) => { [GET_ORGANIZATIONS](state: any, action: IAction) {
const organizations = R.compose(R.uniqBy(R.prop('org_code')), R.propOr([], 'organizations'))(action.payload) 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) const inventories = R.compose(R.uniqBy(R.prop('inv_code')), R.propOr([], 'inventories'))(action.payload)
return { ...state, organizations, inventories } return { ...state, organizations, inventories }
}, },
[GET_CUSTOMERS]: (state: any, action: IAction) => { [GET_CUSTOMERS](state: any, action: IAction) {
const data = action.payload const data = action.payload
let customers = {...state.customers } let customers = { ...state.customers }
customers[data.org_code] = data.customers customers[data.org_code] = data.customers
return { ...state, customers } return { ...state, customers }
}, },
[GET_COLLECT_SETTING](state: any, action: IAction) {
console.log(action)
return state
},
}) })
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/services/api.ts * @FilePath: /BoneHouse_Business_APP/src/services/api.ts
* @Author: peii * @Author: peii
* @Date: 2021-12-19 16:06:26 * @Date: 2021-12-19 16:06:26
* @LastEditTime: 2022-10-27 11:20:09 * @LastEditTime: 2022-11-04 18:11:25
* @LastEditors: PEII * @LastEditors: PEII
* @Vision: 1.0 * @Vision: 1.0
* @Description: 未重构完全暂用的所有请求 * @Description: 未重构完全暂用的所有请求
...@@ -189,4 +189,18 @@ export default { ...@@ -189,4 +189,18 @@ export default {
createGroupComsumeOrder(data: any) { createGroupComsumeOrder(data: any) {
return request({ url: `${v}/surgery/consume_group_order/create`, data, method: 'POST' }) return request({ url: `${v}/surgery/consume_group_order/create`, data, method: 'POST' })
}, },
/**
* @description: 获取客户对应的出库仓库
* @return {*}
*/
getCollectSetting(data: {
orgCode: string
customerCode: string
billToSiteCode: string
shipToSiteCode: string
processCode: 'COLLECT'
}) {
return request({ url: `${v}/surgery/collect_setting/search`, data })
},
} }
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
/// <reference types="react" /> /// <reference types="react" />
/// <reference types="react-native" /> /// <reference types="react-native" />
declare module 'action' {
export interface IApiAction {
<T extends (...args: any) => any>(actionType: string, fn: T): (...args: Parameters<T>) => (dispatch: Function) => Promise<any>
}
}
declare module 'bonehouse' { declare module 'bonehouse' {
export type EnumType = { [s: string]: any } export type EnumType = { [s: 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