Commit e7557312 by peii

actions

parent 7a156482
......@@ -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-02 16:52:16
* @LastEditTime: 2022-11-04 18:00:41
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
......@@ -10,3 +10,5 @@
export const GET_ORGANIZATIONS = 'GET_ORGANIZATIONS'
export const GET_CUSTOMERS = 'GET_CUSTOMERS'
export const GET_COLLECT_SETTING = 'GET_COLLECT_SETTING'
\ No newline at end of file
......@@ -2,15 +2,17 @@
* @FilePath: /BoneHouse_Business_APP/src/actions/userAction.ts
* @Author: PEII
* @Date: 2022-11-02 16:09:29
* @LastEditTime: 2022-11-02 16:56:49
* @LastEditTime: 2022-11-04 18:51:56
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
*/
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'
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 { request } from '../services/baseApi'
......@@ -31,9 +32,9 @@ export const createSimpleAction: (string, any?) => Dictionary<any> = createActio
* @param type {string} 类型
* @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) =>
async (dispatch: Function) => {
try {
......@@ -56,6 +57,6 @@ export const createApiAction = curry((actionType: string, fn: Function) => {
callback.fail && callback.fail(error)
}
}
})
}
export const createSimpleApiAction = createApiAction(__, request)
// export const createSimpleApiAction = createApiAction(__, request)
......@@ -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-04 15:16:13
* @LastEditTime: 2022-11-04 18:56:41
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 自助下单
......@@ -21,7 +21,7 @@ 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 } from '../../actions/userAction'
import { getCustomers, getCollectSetting } from '../../actions/userAction'
import styles from './self.styl'
type IProps = {
......@@ -29,7 +29,8 @@ type IProps = {
userInfo: any
organizations: IOrganization[]
allCustomers: {}
getCustomers: Function
getCustomers: (sellerCode: string, orgCode: string) => Promise<any>
getCollectSetting: (orgCode, customerCode, billToSiteCode, shipToSiteCode) => Promise<any>
}
type IState = {
......@@ -330,8 +331,11 @@ 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)
const item = getFormItem(formItems, 'collectSrcInvCode')
let invRes = await this.props.getCollectSetting(orgCode, customerCode, billToSiteCode, shipToSiteCode)
console.log(invRes)
// if (isBlank(invs)) {
// item.loading = true
// await this.props.orderStore.getInventories(orgCode, customerCode, billToSiteCode, shipToSiteCode)
......@@ -411,6 +415,21 @@ const mapDispatchToProps = dispatch => ({
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)
......@@ -2,19 +2,20 @@
* @FilePath: /BoneHouse_Business_APP/src/reducers/user.ts
* @Author: PEII
* @Date: 2022-11-02 16:02:14
* @LastEditTime: 2022-11-02 17:19:01
* @LastEditTime: 2022-11-04 18:39:31
* @LastEditors: PEII
* @Vision: 1.0
* @Description:
*/
import * as R from 'ramda'
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 = {
organizations: [],
inventories: [],
customers: {},
srcInvs: {},
}
type IAction = {
......@@ -23,16 +24,21 @@ type IAction = {
}
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 inventories = R.compose(R.uniqBy(R.prop('inv_code')), R.propOr([], 'inventories'))(action.payload)
return { ...state, organizations, inventories }
},
[GET_CUSTOMERS]: (state: any, action: IAction) => {
[GET_CUSTOMERS](state: any, action: IAction) {
const data = action.payload
let customers = {...state.customers }
let customers = { ...state.customers }
customers[data.org_code] = data.customers
return { ...state, customers }
},
[GET_COLLECT_SETTING](state: any, action: IAction) {
console.log(action)
return state
},
})
......@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/services/api.ts
* @Author: peii
* @Date: 2021-12-19 16:06:26
* @LastEditTime: 2022-10-27 11:20:09
* @LastEditTime: 2022-11-04 18:11:25
* @LastEditors: PEII
* @Vision: 1.0
* @Description: 未重构完全暂用的所有请求
......@@ -189,4 +189,18 @@ export default {
createGroupComsumeOrder(data: any) {
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 @@
/// <reference types="react" />
/// <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' {
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