Commit ae5d0722 by Denglingling

完善【器械消耗】需要存储的store 数据,以及对接接口函数的封装

parent 3f74230a
import { PostRequest, GetRequest } from '../network/RequestUtils';
import { show } from '../utils/Utils';
import { show, getUrlParams } from '../utils/Utils';
import { exitLoginStatus } from './LoginAction';
// import { SELF_ORDER_LIST_DOING, SELF_ORDER_LIST_SUCCESS, SELF_ORDER_LIST_FAILURE } from '../base/ActionTypes';
import {
EQUIP_CONSU_LIST_DOING,
EQUIP_CONSU_LIST_SUCCESS,
EQUIP_CONSU_LIST_FAILURE,
EQUIP_SUBMIT_DOING,
EQUIP_SUBMIT_SUCCESS,
EQUIP_SUBMIT_FAILURE
} from '../base/ActionTypes';
// 获取组织 params={access_token:''}
export function requestEquipOrganizations(params) {
return dispatch => {
console.log('----requestEquipOrganizations====================')
dispatch(requestListDataing());
GetRequest(getUrlParams('/authorized_inventory/search', params))
.then(res => {
console.log('res=====', Object.keys(res), res);
if(res.error_code == 0) {
let { data: { organizations } } = res
dispatch(requestListDataSuccess(organizations));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
}
})
.catch(err => {
console.log('------err--====requestEquipOrganizations----', Object.keys(err), err)
show(err.error);
})
}
}
// 获取手术医院 params={access_token:'', org_code:'', seller_code:''}
export function requestEquipSurgeryHospital(params) {
return dispatch => {
console.log('----requestEquipSurgeryHospital====================', params)
dispatch(requestListDataing());
GetRequest(getUrlParams('/sale/seller_customer/search', params))
.then(res => {
console.log('res===!!==', Object.keys(res));
if(res.error_code == 0) {
let { data: { customers } } = res
dispatch(requestListDataSuccess(customers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
}
})
.catch(err => {
console.log('------err--====requestEquipSurgeryHospital----', Object.keys(err), err)
show(err.error);
})
}
}
// api/latest/surgery/collect_order/search?access_token=${access_token}&org_code=A02&seller_code=shi.ming&customer_code=CU00000017&collect_header_status=RETURNED,COLLECTED
// 获取手术医院 params={access_token:'', org_code:'', seller_code:'', customer_code:'', collect_header_status: ''}
export function requestEquipOrderInfo(params) {
return dispatch => {
console.log('----requestEquipOrderInfo====================', params)
dispatch(requestListDataing());
GetRequest(getUrlParams('/surgery/collect_order/search', params))
.then(res => {
console.log('res===!!==', Object.keys(res));
if(res.error_code == 0) {
let { data: { surgery_collect_headers } } = res
dispatch(requestListDataSuccess(surgery_collect_headers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
}
})
.catch(err => {
console.log('------err--====requestEquipOrderInfo----', Object.keys(err), err)
show(err.error);
})
}
}
function requestListDataing() {
return {
type: EQUIP_CONSU_LIST_DOING
}
}
function requestListDataSuccess(data) {
return {
type: EQUIP_CONSU_LIST_SUCCESS,
rawData: data
}
}
function requestListDataFail() {
return {
type: EQUIP_CONSU_LIST_FAILURE
}
}
// 获取消耗明细 params={access_token:'', surgery_collect_number:''}
export const requestEquipDetails = async (params) => {
console.log('----requestEquipDetails----', params)
return await GetRequest(getUrlParams('/surgery/collected_order_line/search', params))
}
// 图片上传 -- 具体需要修改!!!!!
export const requestQuickAudio = async (params) => {
let { access_token, path } = params
let formData = new FormData()
let soundPath = `file://${path}`
let fileName = path.substring(path.lastIndexOf('/') + 1, path.length)
let file = { uri: soundPath, type: "multipart/form-data", name: fileName}
formData.append('file', file)
console.log('--------', file, formData)
return await UploadRequest(getUrlParams('/dingding/upload_media', { access_token }), formData)
}
// 提交数据
export function requestEquipSumbit({access_token, ...params}) {
return dispatch => {
console.warn('----requestEquipSumbit====================', access_token, params)
dispatch(requestSubmiting());
PostRequest(getUrlParams('/surgery/consume_order/create', {access_token: access_token}), params)
.then(res => {
console.warn('res=====', Object.keys(res));
if(res.error_code == 0) {
console.warn('res====requestEquipSumbit==========', res.data);
let { data } = res
dispatch(requestSubmitSuccess(data));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSubmitFail());
}
})
.catch(err => {
console.log('------err--====requestEquipSumbit----', Object.keys(err), err)
show(err.error);
})
}
}
function requestSubmiting() {
return {
type: EQUIP_SUBMIT_DOING
}
}
function requestSubmitSuccess(data) {
return {
type: EQUIP_SUBMIT_SUCCESS,
rawData: data
}
}
function requestSubmitFail() {
return {
type: EQUIP_SUBMIT_FAILURE
}
}
\ No newline at end of file
......@@ -14,21 +14,21 @@ import {
export function requestQuickOrganizations(params) {
return dispatch => {
console.log('----requestQuickOrganizations====================')
dispatch(requestOrganizationsing());
dispatch(requestListDataing());
// GetRequest(`/authorized_inventory/search?access_token=${access_token}`)
GetRequest(getUrlParams('/authorized_inventory/search', params))
.then(res => {
console.log('res=====', Object.keys(res), res);
if(res.error_code == 0) {
let { data: { organizations } } = res
dispatch(requestOrganizationsSuccess(organizations));
dispatch(requestListDataSuccess(organizations));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestOrganizationsFail());
dispatch(requestListDataFail());
}
})
.catch(err => {
......@@ -42,20 +42,20 @@ export function requestQuickOrganizations(params) {
export function requestQuickSurgeryHospital(params) {
return dispatch => {
console.log('----requestQuickSurgeryHospital====================', params)
dispatch(requestOrganizationsing());
dispatch(requestListDataing());
GetRequest(getUrlParams('/sale/seller_customer/search', params))
.then(res => {
console.log('res===!!==', Object.keys(res));
if(res.error_code == 0) {
let { data: { customers } } = res
dispatch(requestOrganizationsSuccess(customers));
dispatch(requestListDataSuccess(customers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestOrganizationsFail());
dispatch(requestListDataFail());
}
})
.catch(err => {
......@@ -69,20 +69,20 @@ export function requestQuickSurgeryHospital(params) {
export function requestQuickOrderType(params) {
return dispatch => {
console.log('----requestQuickOrderType====================', params)
dispatch(requestOrganizationsing());
dispatch(requestListDataing());
GetRequest(getUrlParams('/system/value_set/search', params))
.then(res => {
console.log('res===!!==', Object.keys(res));
if(res.error_code == 0) {
let { data: { sys_values } } = res
dispatch(requestOrganizationsSuccess(sys_values));
dispatch(requestListDataSuccess(sys_values));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestOrganizationsFail());
dispatch(requestListDataFail());
}
})
.catch(err => {
......@@ -96,20 +96,20 @@ export function requestQuickOrderType(params) {
export function requestQuickTemplateCollect(params) {
return dispatch => {
console.log('----requestQuickTemplateCollect====================', params)
dispatch(requestOrganizationsing());
dispatch(requestListDataing());
GetRequest(getUrlParams('/surgery/template_header/search', params))
.then(res => {
console.log('res===!!==', Object.keys(res));
if(res.error_code == 0) {
let { data: { surgery_template_headers } } = res
dispatch(requestOrganizationsSuccess(surgery_template_headers));
dispatch(requestListDataSuccess(surgery_template_headers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestOrganizationsFail());
dispatch(requestListDataFail());
}
})
.catch(err => {
......@@ -119,20 +119,20 @@ export function requestQuickTemplateCollect(params) {
}
}
function requestOrganizationsing() {
function requestListDataing() {
return {
type: QUICK_ORDER_LIST_DOING
}
}
function requestOrganizationsSuccess(data) {
function requestListDataSuccess(data) {
return {
type: QUICK_ORDER_LIST_SUCCESS,
rawData: data
}
}
function requestOrganizationsFail() {
function requestListDataFail() {
return {
type: QUICK_ORDER_LIST_FAILURE
}
......@@ -162,7 +162,7 @@ export function requestQuickAudio_222(params) {
console.log('----file====================', file, soundPath, formData)
dispatch(requestSubmitOrganizationsing());
dispatch(requestSubmiting());
// /system/attachment/create
// /dingding/upload_media
UploadRequest(getUrlParams('/dingding/upload_media', { access_token }), formData)
......@@ -170,14 +170,14 @@ export function requestQuickAudio_222(params) {
console.log('res===!!==', Object.keys(res), res);
if(res.error_code == 0) {
let { data: { url } } = res
dispatch(requestSubmitOrganizationsSuccess(url));
dispatch(requestSubmitSuccess(url));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSubmitOrganizationsFail());
dispatch(requestSubmitFail());
}
})
.catch(err => {
......@@ -208,21 +208,21 @@ export const requestQuickAudio = async (params) => {
export function requestQuickSumbit({access_token, ...params}) {
return dispatch => {
console.warn('----requestQuickSumbit====================', access_token, params)
dispatch(requestSubmitOrganizationsing());
dispatch(requestSubmiting());
PostRequest(getUrlParams('/surgery/collect_order/via_data/create', {access_token: access_token}), params)
.then(res => {
console.warn('res=====', Object.keys(res));
if(res.error_code == 0) {
console.warn('res====requestQuickSumbit==========', res.data);
let { data } = res
dispatch(requestSubmitOrganizationsSuccess(data));
dispatch(requestSubmitSuccess(data));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSubmitOrganizationsFail());
dispatch(requestSubmitFail());
}
})
.catch(err => {
......@@ -232,20 +232,20 @@ export function requestQuickSumbit({access_token, ...params}) {
}
}
function requestSubmitOrganizationsing() {
function requestSubmiting() {
return {
type: QUICK_SUBMIT_DOING
}
}
function requestSubmitOrganizationsSuccess(data) {
function requestSubmitSuccess(data) {
return {
type: QUICK_SUBMIT_SUCCESS,
rawData: data
}
}
function requestSubmitOrganizationsFail() {
function requestSubmitFail() {
return {
type: QUICK_SUBMIT_FAILURE
}
......
......@@ -24,3 +24,12 @@ export const QUICK_SUBMIT_NO = "QUICK_SUBMIT_NO"
export const QUICK_SUBMIT_DOING = "QUICK_SUBMIT_DOING"
export const QUICK_SUBMIT_SUCCESS = "QUICK_SUBMIT_SUCCESS"
export const QUICK_SUBMIT_FAILURE = "QUICK_SUBMIT_FAILURE"
//-----------equipment consumption---------------------
export const EQUIP_CONSU_LIST_NO = "EQUIP_CONSU_LIST_NO"
export const EQUIP_CONSU_LIST_DOING = "EQUIP_CONSU_LIST_DOING"
export const EQUIP_CONSU_LIST_SUCCESS = "EQUIP_CONSU_LIST_SUCCESS"
export const EQUIP_CONSU_LIST_FAILURE = "EQUIP_CONSU_LIST_FAILURE"
export const EQUIP_SUBMIT_NO = "EQUIP_SUBMIT_NO"
export const EQUIP_SUBMIT_DOING = "EQUIP_SUBMIT_DOING"
export const EQUIP_SUBMIT_SUCCESS = "EQUIP_SUBMIT_SUCCESS"
export const EQUIP_SUBMIT_FAILURE = "EQUIP_SUBMIT_FAILURE"
\ No newline at end of file
......@@ -675,7 +675,7 @@ class EquipConsuPage extends Component {
// 返回耗材明细子项
renderConDeSubItem(item, index) {
return(
<View style={list_common_item.con_de_sub}>
<View style={list_common_item.con_de_sub} key={index}>
<Text style={list_common_item.de_sub_tit}>
{index+1}{ item.title }
</Text>
......
......@@ -3,6 +3,7 @@ import {persistReducer} from 'redux-persist';
import login from './module/login';
import quick from './module/quick';
import selfOrder from './module/selfOrder';
import equip from './module/equip';
const loginConfig = {
key: 'login',
......@@ -25,10 +26,18 @@ const quickConfig = {
blackList: []
}
const equipConfig = {
key: 'equip',
storage,
debug: false,
blackList: []
}
const rootReducer = {
login: persistReducer(loginConfig,login),
selfOrder: persistReducer(selfConfig,selfOrder),
quick: persistReducer(quickConfig,quick),
equip: persistReducer(equipConfig,equip),
}
export default rootReducer;
\ No newline at end of file
import {
EQUIP_CONSU_LIST_NO,
EQUIP_CONSU_LIST_DOING,
EQUIP_CONSU_LIST_SUCCESS,
EQUIP_CONSU_LIST_FAILURE,
EQUIP_SUBMIT_NO,
EQUIP_SUBMIT_DOING,
EQUIP_SUBMIT_SUCCESS,
EQUIP_SUBMIT_FAILURE
} from '../../base/ActionTypes';
// 器械消耗状态
const defaultState = {
equip_list_status: EQUIP_CONSU_LIST_NO, // 获取数据状态
submit_equip_order_status: EQUIP_SUBMIT_NO, // 提交订单状态
equipOrderOption: {} // 当前临时存储数据
}
export default equip = (state = defaultState, action) => {
switch (action.type) {
case EQUIP_CONSU_LIST_DOING:
return Object.assign({}, state, {
equip_list_status: EQUIP_CONSU_LIST_DOING
});
case EQUIP_CONSU_LIST_SUCCESS:
return Object.assign({}, state, {
equip_list_status: EQUIP_CONSU_LIST_SUCCESS,
equipOrderOption: action.rawData
})
case EQUIP_CONSU_LIST_FAILURE:
return Object.assign({}, state, {
equip_list_status: EQUIP_CONSU_LIST_FAILURE
})
case EQUIP_SUBMIT_DOING:
return Object.assign({}, state, {
submit_equip_order_status: EQUIP_SUBMIT_DOING
});
case EQUIP_SUBMIT_SUCCESS:
return Object.assign({}, state, {
submit_equip_order_status: EQUIP_SUBMIT_SUCCESS,
equipOrderOption: action.rawData
// equipOrderOption: {} // 清空当前临时数据
})
case EQUIP_SUBMIT_FAILURE:
return Object.assign({}, state, {
submit_equip_order_status: EQUIP_SUBMIT_FAILURE
})
default:
return state;
}
}
\ No newline at end of file
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