Commit ce8571b3 by Denglingling

完善【自助下单】模块的 配台模版、订单类型、录音、提交接口,录音上传还需要修改

parent 1798ebee
......@@ -3,10 +3,21 @@
<uses-permission android:name="android.permission.INTERNET" />
<!-- add -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> -->
<!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
......
import { PostRequest, GetRequest } from '../network/RequestUtils';
import { PostRequest, GetRequest, UploadRequest } from '../network/RequestUtils';
import { show, getUrlParams } from '../utils/Utils';
import { exitLoginStatus } from './LoginAction';
import { QUICK_ORDER_LIST_DOING, QUICK_ORDER_LIST_SUCCESS, QUICK_ORDER_LIST_FAILURE } from '../base/ActionTypes';
import {
QUICK_ORDER_LIST_DOING,
QUICK_ORDER_LIST_SUCCESS,
QUICK_ORDER_LIST_FAILURE,
QUICK_SUBMIT_DOING,
QUICK_SUBMIT_SUCCESS,
QUICK_SUBMIT_FAILURE
} from '../base/ActionTypes';
import RNFetchBlob from 'react-native-fetch-blob'
// 获取组织 params={access_token:''}
// export const requestQuickOrganizations = async (params) => {
......@@ -9,14 +17,14 @@ import { QUICK_ORDER_LIST_DOING, QUICK_ORDER_LIST_SUCCESS, QUICK_ORDER_LIST_FAIL
// }
export function requestQuickOrganizations(params) {
return dispatch => {
console.warn('----requestQuickOrganizations====================')
// console.warn('----requestQuickOrganizations====================')
dispatch(requestOrganizationsing());
// GetRequest(`/authorized_inventory/search?access_token=${access_token}`)
GetRequest(getUrlParams('/authorized_inventory/search', params))
.then(res => {
console.warn('res=====', Object.keys(res), res.error, res.message);
// console.warn('res=====', Object.keys(res), res.error, res.message);
if(res.error_code == 0) {
console.warn('res====organizations==========', res.data.organizations);
// console.warn('res====organizations==========', res.data.organizations);
let { data: { organizations } } = res
dispatch(requestOrganizationsSuccess(organizations));
} else if(res.error_code === 41006) {
......@@ -29,7 +37,7 @@ export function requestQuickOrganizations(params) {
}
})
.catch(err => {
console.log('------err--====organizations----', Object.keys(err), err.error, err.message)
// console.log('------err--====organizations----', Object.keys(err), err.error, err.message)
show(err.error);
})
}
......@@ -42,11 +50,9 @@ export function requestQuickSurgeryHospital(params) {
dispatch(requestOrganizationsing());
GetRequest(getUrlParams('/sale/seller_customer/search', params))
// GetRequest('/sale/seller_customer/search?access_token=20200512140017932dcdff2129a5f4201900f116c819e74865T473Ma2PGh16ek&org_code=A02&seller_code=shi.ming')
.then(res => {
console.warn('res===!!==', Object.keys(res), res.error, res.message);
// console.warn('res===!!==', Object.keys(res));
if(res.error_code == 0) {
console.warn('res====requestQuickSurgeryHospital==========', res.data.organizations);
let { data: { customers } } = res
dispatch(requestOrganizationsSuccess(customers));
} else if(res.error_code === 41006) {
......@@ -59,12 +65,65 @@ export function requestQuickSurgeryHospital(params) {
}
})
.catch(err => {
console.log('------err--====requestQuickSurgeryHospital----', Object.keys(err))
// console.log('------err--====requestQuickSurgeryHospital----', Object.keys(err))
show(err.error);
})
}
}
// 获取订单类型 params={access_token:'', value_set_code:'SUR_ORDER_TYPE'}
export function requestQuickOrderType(params) {
return dispatch => {
console.warn('----requestQuickOrderType====================', params)
dispatch(requestOrganizationsing());
GetRequest(getUrlParams('/system/value_set/search', params))
.then(res => {
console.warn('res===!!==', Object.keys(res));
if(res.error_code == 0) {
let { data: { sys_values } } = res
dispatch(requestOrganizationsSuccess(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());
}
})
.catch(err => {
// console.log('------err--====requestQuickSurgeryHospital----', Object.keys(err))
show(err.error);
})
}
}
// 获取配台模版 params={access_token:'', org_code:'', seller_code: 'shi.ming', customer_code: '', surgery_type: '', doctor_name: ''}
export function requestQuickTemplateCollect(params) {
return dispatch => {
console.warn('----requestQuickTemplateCollect====================', params)
dispatch(requestOrganizationsing());
GetRequest(getUrlParams('/surgery/template_header/search', params))
.then(res => {
console.warn('res===!!==', Object.keys(res));
if(res.error_code == 0) {
let { data: { surgery_template_headers } } = res
dispatch(requestOrganizationsSuccess(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());
}
})
.catch(err => {
// console.log('------err--====requestQuickTemplateCollect----', Object.keys(err))
show(err.error);
})
}
}
function requestOrganizationsing() {
return {
......@@ -84,3 +143,99 @@ function requestOrganizationsFail() {
type: QUICK_ORDER_LIST_FAILURE
}
}
// 上传语音 params={ access_token:'', path='录音地址' }
export function requestQuickAudio(params) {
return dispatch => {
let { access_token, path } = params
// 临时
// access_token = "201904091445193616b5e3d3a777848dda1de1a8123d0fdf9xw7t566c1S92U88"
let formData = new FormData()
let soundPath = `file://${path}`
let fileName = path.substring(path.lastIndexOf('/') + 1, path.length)
// let file = { uri: soundPath, type: 'ogg', name: fileName } // 类型和名字固定???
let file = { uri: soundPath, type: 'multipart/form-data', name: fileName } // 类型和名字固定???
formData.append('file', file)
console.log('----file====================', file, soundPath, formData)
// /system/attachment/create
// /dingding/upload_media
dispatch(requestSubmitOrganizationsing());
UploadRequest(getUrlParams('/dingding/upload_media', { access_token }), formData)
.then(res => {
console.log('res===!!==', Object.keys(res), res);
if(res.error_code == 0) {
let { data: { url } } = res
dispatch(requestSubmitOrganizationsSuccess(url));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSubmitOrganizationsFail());
}
})
.catch(err => {
// console.log('------err--====requestQuickAudio----', Object.keys(err))
show(err.error);
})
}
}
//上传头像
export const uploadAttachment = async (token,datas) => {
return await UploadRequest('/system/attachment/create' + '?access_token=' + token,datas)
};
// 提交数据
export function requestQuickSumbit({access_token, ...params}) {
return dispatch => {
console.warn('----requestQuickSumbit====================', access_token, params)
dispatch(requestSubmitOrganizationsing());
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====requestQuickSumbit==========', res.data);
let { data: { data } } = res
dispatch(requestSubmitOrganizationsSuccess(data));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSubmitOrganizationsFail());
}
})
.catch(err => {
// console.log('------err--====requestQuickSumbit----', Object.keys(err), err.error, err.message)
show(err.error);
})
}
}
function requestSubmitOrganizationsing() {
return {
type: QUICK_SUBMIT_DOING
}
}
function requestSubmitOrganizationsSuccess(data) {
return {
type: QUICK_SUBMIT_SUCCESS,
rawData: data
}
}
function requestSubmitOrganizationsFail() {
return {
type: QUICK_SUBMIT_FAILURE
}
}
\ No newline at end of file
export const BaseUrl = "https://obs.uat.sfrx.guke.tech";
export const BaseUrlOther = "https://sob-os.uat.sfrx.guke.tech";
export const VERSION = '/api/latest';
export const BaseUrl = "http://192.168.10.188:8200"; // https://obs.uat.sfrx.guke.tech https://sob-os.uat.sfrx.guke.tech
export const BaseUrlOther = "http://192.168.10.188:8200"; //http://192.168.10.188:8200/v1/dingding/upload_media
export const VERSION = '/v1'; // /api/latest
export const ACCESS_TOKEN = '201904091445193616b5e3d3a777848dda1de1a8123d0fdf9xw7t566c1S92U88';//未获取到access_token时使用
......@@ -78,7 +78,7 @@ const styles = StyleSheet.create({
paddingLeft: 20
},
text_input: {
height: 38,
// height: 38,
paddingRight: 20
},
image_box: {
......
......@@ -33,13 +33,24 @@ import {
FooterBtnStyle
} from '../common/CellTextStyle';
import { connect } from 'react-redux';
import { show, isEmpty, dedupQuoteArray } from '../../utils/Utils';
import { show, isEmpty, dedupQuoteArray, formatStrForDate } from '../../utils/Utils';
import { AudioRecorder, AudioUtils } from 'react-native-audio';
import Sound from 'react-native-sound';
import DateModel from '../common/DateModel';
import DialogModel from '../common/DialogModel';
import LodingModel from '../common/LodingModel';
import { requestQuickOrganizations, requestQuickSurgeryHospital} from '../../action/QuickAction';
import { QUICK_ORDER_LIST_DOING, QUICK_ORDER_LIST_SUCCESS, QUICK_ORDER_LIST_FAILURE } from '../../base/ActionTypes';
import {
requestQuickOrganizations,
requestQuickSurgeryHospital,
requestQuickOrderType,
requestQuickTemplateCollect,
requestQuickAudio,
requestQuickSumbit,
uploadAttachment
} from '../../action/QuickAction';
import { QUICK_ORDER_LIST_DOING, QUICK_ORDER_LIST_SUCCESS, QUICK_ORDER_LIST_FAILURE, LOGIN_NO } from '../../base/ActionTypes';
import ImagePicker from 'react-native-image-picker';
class EquipConsuPage extends Component {
constructor(props) {
......@@ -51,7 +62,7 @@ class EquipConsuPage extends Component {
"id": "0",
title: '销售员',
name: '蔡妍',
value: '蔡妍',
value: 'caiyan',
isPicker: false,
select: false,
isEditable: false // 不可编辑
......@@ -156,16 +167,24 @@ class EquipConsuPage extends Component {
bill_to_site_code: '', // 收单地点
ship_to_site_code: '', // 收货地点
doctor_name: '', // 主治医生
surgery_name: '', // 手术名称
// surgery_name: '', // 手术名称
surgery_date: '', // 手术时间
surgery_type_code: '', // 手术类型
// surgery_type_code: '', // 手术类型
template_collect_number: '', // 配台模版
order_type_code: '', // 订单类型
surgery_desc: '', // 备注信息
file_path: '', // 录音地址
voice_url: '', // 录音地址
order_currency: 'CNY',
Caller: 'dingding',
force_balance_check_flag: 'Y', // 检查缺失物料
},
currentItem: {
name: '请选择',
value: '-1'
value: ''
},
localOtherObj: {
name: '请选择',
value: ''
},
currentTitle: '组织', // 当前点击项
showTypePop: false, // 选择器弹窗
......@@ -187,21 +206,310 @@ class EquipConsuPage extends Component {
],
dateModelPop: false, // 日期选择器
hasPermission: undefined, //录音 授权状态
audioPath: AudioUtils.DocumentDirectoryPath + '/quickAudio.aac', // 文件路径
// audioPath: AudioUtils.DocumentDirectoryPath + `/quickAudio${Math.floor(Math.random() * (1000))+1}.aac`, // 文件路径
audioPath: AudioUtils.DocumentDirectoryPath + `/quickAudio${Math.floor(Math.random() * (1000))+1}.ogg`, // 文件路径
recording: false, //是否录音
pause: false, //录音是否暂停
stop: false, //录音是否停止
currentTime: 0, //录音时长
localCustomersOption: [], // 当前医院信息:手术医院、收单地点、收货地点、主治医生
surgeryTypeOption: [
{
name:'创伤',
value:'创伤'
},{
name:'关节',
value:'关节'
},
{
name:'脊柱',
value:'脊柱'
},
{
name:'运动医学',
value:'运动医学'
}
],
localTemplateOption: [], // 当前配台模版需要的信息(需要同步到备注)
}
}
componentDidMount() {
this.getSellerName()
this.getAudioAuthorize()
}
//拍照上传
addPhotoAction(){
// const {headerData,itemData} = this.props.navigation.state.params;
// const {photos} = this.state;
const options = {
title: '选择图片',
cancelButtonTitle: '取消',
takePhotoButtonTitle: '拍照',
chooseFromLibraryButtonTitle: '相册',
cameraType: 'back',
mediaType: 'photo',
videoQuality: 'high',
durationLimit: 10,
maxWidth: 720,
maxHeight: 1280,
aspectX: 2,
aspectY: 1,
quality: 1,
angle: 0,
allowsEditing: false,
noData: false,
storageOptions: {
skipBackup: true,
path: 'images'
}
};
ImagePicker.showImagePicker(options,(res) => {
if (res.didCancel) {
console.log('User cancelled photo picker');
}
else if (res.error) {
console.log('ImagePicker Error: ', res.error);
if(res.error.indexOf('Camera permissions not granted') > -1){
Alert.alert(('提示信息', 'APP需要使用相机,请打开相机权限允许APP使用'), [{
text: '设置',
onPress: () => {
Linking.openURL('app-settings:')
.catch(err => console.log('error', err))
}
},{
text: '取消'
}])
}
if(res.error.indexOf('Photo library permissions not granted') > -1){
Alert.alert('提示信息', 'APP需要使用相册,请打开相册权限允许APP使用', [{
text: '设置',
onPress: () => {
Linking.openURL('app-settings:')
.catch(err => console.log('error', err))
}
},{
text: '取消'
}]);
}
}
else if (res.customButton) {
console.log('User tapped custom button: ', res.customButton);
} else {
show('上传中...')
let source; //保存选中的图片
if (Platform.OS === 'android') {
source = res.uri;
} else {
source = res.uri.replace('file://','');
}
// let date = itemData.receipt_date;
// if(date && date.length > 0){
// date = date.replace('T',' ')
// }
// let watermark = itemData.receipt_number + ' ' + date + ' ' + this.props.userInfo.person_name + ' ' + itemData.inv_name + ' ' + itemData.party_name
const formData = new FormData();
let file = {uri: source, type: 'multipart/form-data', name: res.fileName};
formData.append('file',file);
formData.append('destination','ALL');
formData.append('attachment_name',res.fileName);
formData.append('source_header_table','rcv_receipt_header');
// formData.append('source_header_number',headerData.receipt_number);
formData.append('source_line_table','rcv_receipt_line');
console.log('formData112===',formData)
// formData.append('source_line_number',itemData.source_line_number);
// formData.append('watermark',watermark);
//上传附近接口 destination: 'ALL',attachment_name:res.fileName, 'source_header_table':'rcv_receipt_header'
//uploadAttachment(this.props.token,{file: file,destination: 'ALL',attachment_name:res.fileName, 'source_header_table':'rcv_receipt_header' })
uploadAttachment(this.props.token, formData)
.then((response)=>{
if (response.error_code === 0) {
show('上传成功');
// photos.push(source);
// this.setState({photos});
}else if(response.error_code === 41006){
show('登录过期,请重新登录');
// this.props.exitLoginStatus()
} else {
show(response.error_msg)
}
})
}
})
}
// 赋值销售员
getSellerName() {
let {state, props} = this
console.log('---userInfo',props.userInfo)
if(state.listOptionData[0].name !== props.userInfo.person_name) {
this.setState({
listOptionData: state.listOptionData.map((item) => {
if(item.title === '销售员') {
item.name = props.userInfo.person_name
item.value = props.userInfo.user_name
}
return item
})
})
}
}
// 请求授权
getAudioAuthorize() {
AudioRecorder.requestAuthorization()
.then(isAuthor => {
console.warn('是否授权: ' + isAuthor)
if(!isAuthor) {
return alert('请前往设置开启录音权限')
}
this.setState({hasPermission: isAuthor})
this.prepareRecordingPath(this.state.audioPath);
// 录音进展
AudioRecorder.onProgress = (data) => {
this.setState({currentTime: Math.floor(data.currentTime)});
};
// 完成录音
AudioRecorder.onFinished = (data) => {
// data 返回需要上传到后台的录音数据
console.warn(this.state.currentTime)
console.warn(data)
};
})
}
/**
* AudioRecorder.prepareRecordingAtPath(path,option)
* 录制路径
* path 路径
* option 参数
*/
prepareRecordingPath = (path) => {
const option = {
SampleRate: 44100.0, //采样率
Channels: 2, //通道
AudioQuality: 'High', //音质
AudioEncoding: 'aac', //音频编码
OutputFormat: 'mpeg_4', //输出格式
MeteringEnabled: false, //是否计量
MeasurementMode: false, //测量模式
AudioEncodingBitRate: 32000, //音频编码比特率
IncludeBase64: true, //是否是base64格式
AudioSource: 0, //音频源
}
AudioRecorder.prepareRecordingAtPath(path,option)
}
// 开始录音
_record = async () => {
console.warn('changan')
show('录音开始')
if(!this.state.hasPermission) {
return alert('没有授权')
}
if(this.state.recording) {
return alert('正在录音中...')
}
if(this.state.stop) {
// 初始化录音
this.prepareRecordingPath(this.state.audioPath)
}
this.setState({recording: true,pause: false})
try {
await AudioRecorder.startRecording()
} catch (err) {
console.log(err)
}
}
// 暂停录音
_pause = async () => {
if(!this.state.recording) {
return alert('当前未录音')
}
try {
await AudioRecorder.pauseRecording()
this.setState({pause: true, recording: false})
} catch (err) {
console.log(err)
}
}
// 恢复录音
_resume = async () => {
if(!this.state.pause) {
return alert('录音未暂停')
}
try {
await AudioRecorder.resumeRecording();
this.setState({pause: false, recording: true})
} catch (err) {
console.log(err)
}
}
// 停止录音
_stop = async () => {
console.warn('tanqi')
show('录音结束')
console.warn('停止录音',this.state.currentTime)
try {
await AudioRecorder.stopRecording();
this.setState({stop: true, recording: false, paused: false});
} catch (error) {
console.error(error);
}
}
// 播放录音
_play = async () => {
let self = this
self.whoosh = new Sound(this.state.audioPath, '', (err) => {
if(err) {
show('加载音频失败')
return console.warn(err)
}
self.whoosh.play(success => {
if(success) {
console.warn('success - 播放成功')
}else {
console.warn('fail - 播放失败')
show('播放失败')
}
})
})
}
// 停止播放录音 -- 安卓不能停止、ios可以
_stopPlay = async () => {
console.warn('tingzhi bofang')
let self = this
self.whoosh.stop(() => {
console.warn('success - 停止成功')
})
}
// 删除录音
_del = async () => {
// 初始化录音
this.prepareRecordingPath(this.state.audioPath)
this.setState({
currentTime: 0,
stop: false
})
}
componentWillReceiveProps(nextProps) {
let { quick_list_status} = this.props
let { quick_list_status, loginState, navigation, submit_quick_order_status} = this.props
let self = this
if(quick_list_status != nextProps.quick_list_status) {
console.warn('-222------', nextProps.quick_list_status)
......@@ -211,23 +519,70 @@ class EquipConsuPage extends Component {
this.changeSubLoding(true)
break;
case QUICK_ORDER_LIST_SUCCESS:
self.changeSubLoding()
self.changeSubLoding(false)
setTimeout(() => {
self.changeCurrentOption()
}, 500)
break;
case QUICK_ORDER_LIST_FAILURE:
this.changeSubLoding()
this.changeSubLoding(false)
break;
default:
break;
}
}
console.log('-----nextProps.loginState----', nextProps.loginState, loginState)
if(loginState != nextProps.loginState) {
switch(nextProps.loginState) {
case LOGIN_NO:
navigation.navigate('LoginPage')
break;
default:
break;
}
}
if(submit_quick_order_status != nextProps.submit_quick_order_status) {
console.warn('-submit_quick_order_status------', nextProps.submit_quick_order_status)
console.warn('--222---submit_quick_order_status--', submit_quick_order_status)
switch (nextProps.submit_quick_order_status) {
case QUICK_ORDER_LIST_DOING:
this.changeSubLoding(true, '提交中')
break;
case QUICK_ORDER_LIST_SUCCESS:
self.changeSubLoding(false, '提交中')
setTimeout(() => {
self.processReturnData()
}, 500)
break;
case QUICK_ORDER_LIST_FAILURE:
this.changeSubLoding(false, '提交中')
break;
default:
break;
}
}
}
// 修改正在加载
changeSubLoding(loading) {
changeSubLoding(loading, loadTit) {
this.setState({
isSubLoding: loading || false
isSubLoding: loading || false,
lodingTitle: loadTit || '加载中'
})
}
// 清空当前项以下的值
clearInitNameAndValue(curIndex) {
// let tempIndex = curIndex+1
let { listOptionData, localOtherObj } = this.state
this.setState({
listOptionData: listOptionData.map((item, index) => {
if(index > curIndex && index < 11 ) {
item.name = localOtherObj.name
item.value = localOtherObj.value
}
return item
})
})
}
......@@ -235,7 +590,8 @@ class EquipConsuPage extends Component {
handleCallBack(item, itemTitle) {
// console.warn(item, 'item------')
// console.warn('item-itemTitle-----',itemTitle)
let { listOptionData } = this.state
let { listOptionData, localOtherObj} = this.state
let self = this
this.setState({
currentItem: item,
})
......@@ -246,8 +602,35 @@ class EquipConsuPage extends Component {
console.warn('---hhh-----', item)
chItem.name = item.name
chItem.value = item.value
if (itemTitle === '主治医生' && item.name === '其他') {
if(itemTitle === '组织') {
self.clearInitNameAndValue(1)
// self.getCustomerData()
// listOptionData[2].name = localOtherObj.name
// listOptionData[2].value = localOtherObj.value
// listOptionData[3].name = localOtherObj.name
// listOptionData[3].value = localOtherObj.value
// listOptionData[4].name = localOtherObj.name
// listOptionData[4].value = localOtherObj.value
// listOptionData[5].name = localOtherObj.name
// listOptionData[5].value = localOtherObj.value
// listOptionData[6].name = localOtherObj.name
// listOptionData[6].value = localOtherObj.value
// listOptionData[7].name = localOtherObj.name
// listOptionData[7].value = localOtherObj.value
// listOptionData[9].name = localOtherObj.name
// listOptionData[9].value = localOtherObj.value
}
if (itemTitle === '主治医生') {
if(item.name === '其他') {
chItem.showInput = true
} else {
chItem.showInput = false
chItem.inputValue = ''
}
}
if (itemTitle === '配台模版') {
// localTemplateOption
listOptionData[10].value = item.desc
}
}
return chItem
......@@ -271,6 +654,10 @@ class EquipConsuPage extends Component {
let { quickOrderOption } = this.props
console.warn('当前:--quickOrderOption---', quickOrderOption)
let tempOption = []
if(quickOrderOption.length === 0) {
show(`当前${currentTitle}为空`)
return
}
if (currentTitle === '组织') {
tempOption = this.changeNameAndValue(quickOrderOption, 'org_name', 'org_code')
} else if (currentTitle === '手术医院') {
......@@ -288,6 +675,7 @@ class EquipConsuPage extends Component {
// customer_code: 'customer_6'
// }
// ]
this.setState({
localCustomersOption: quickOrderOption
})
......@@ -312,89 +700,128 @@ class EquipConsuPage extends Component {
tempOption = this.changeNameAndValue(currentArr, 'customer_name', 'customer_code')
} else if (currentTitle === '收单地点') {
tempOption =[
{
bill_to_site_name: '收单地点-4',
bill_to_site_code: 'bill_4'
},
{
bill_to_site_name: '收单地点-5',
bill_to_site_code: 'bill_5'
},
{
bill_to_site_name: '收单地点-6',
bill_to_site_code: 'bill_6'
}
]
tempOption = this.changeNameAndValue(tempOption, 'bill_to_site_name', 'bill_to_site_code')
// tempOption =[
// {
// bill_to_site_name: '收单地点-4',
// bill_to_site_code: 'bill_4'
// },
// {
// bill_to_site_name: '收单地点-5',
// bill_to_site_code: 'bill_5'
// },
// {
// bill_to_site_name: '收单地点-6',
// bill_to_site_code: 'bill_6'
// }
// ]
// tempOption = this.changeNameAndValue(tempOption, 'bill_to_site_name', 'bill_to_site_code')
} else if (currentTitle === '收货地点') {
tempOption =[
{
ship_to_site_name: '收货地点-4',
ship_to_site_code: 'ship_4'
},
{
ship_to_site_name: '收货地点-5',
ship_to_site_code: 'ship_5'
},
{
ship_to_site_name: '收货地点-6',
ship_to_site_code: 'ship_6'
}
]
tempOption = this.changeNameAndValue(tempOption, 'ship_to_site_name', 'ship_to_site_code')
// tempOption =[
// {
// ship_to_site_name: '收货地点-4',
// ship_to_site_code: 'ship_4'
// },
// {
// ship_to_site_name: '收货地点-5',
// ship_to_site_code: 'ship_5'
// },
// {
// ship_to_site_name: '收货地点-6',
// ship_to_site_code: 'ship_6'
// }
// ]
// tempOption = this.changeNameAndValue(tempOption, 'ship_to_site_name', 'ship_to_site_code')
} else if (currentTitle === '主治医生') {
tempOption =[
{
doctor_name: '主治医生-4',
doctor_code: 'doctor_4'
},
{
doctor_name: '主治医生-5',
doctor_code: 'doctor_5'
},
{
doctor_name: '主治医生-6',
doctor_code: 'doctor_6'
}
]
tempOption.push({
doctor_name: '其他',
doctor_code: '-1'
})
tempOption = this.changeNameAndValue(tempOption, 'doctor_name', 'doctor_code')
// tempOption =[
// {
// doctor_name: '主治医生-4',
// doctor_code: 'doctor_4'
// },
// {
// doctor_name: '主治医生-5',
// doctor_code: 'doctor_5'
// },
// {
// doctor_name: '主治医生-6',
// doctor_code: 'doctor_6'
// }
// ]
// tempOption.push({
// doctor_name: '其他',
// doctor_code: '-1'
// })
// tempOption = this.changeNameAndValue(tempOption, 'doctor_name', 'doctor_code')
} else if (currentTitle === '手术类型') {
tempOption =[
{
surgery_type_name: '手术类型-4',
surgery_type_code: 'surgery_4'
},
{
surgery_type_name: '手术类型-5',
surgery_type_code: 'surgery_5'
},
{
surgery_type_name: '手术类型-6',
surgery_type_code: 'surgery_6'
}
]
tempOption = this.changeNameAndValue(tempOption, 'surgery_type_name', 'surgery_type_code')
// tempOption =[
// {
// surgery_type_name: '手术类型-4',
// surgery_type_code: 'surgery_4'
// },
// {
// surgery_type_name: '手术类型-5',
// surgery_type_code: 'surgery_5'
// },
// {
// surgery_type_name: '手术类型-6',
// surgery_type_code: 'surgery_6'
// }
// ]
// tempOption = this.changeNameAndValue(tempOption, 'surgery_type_name', 'surgery_type_code')
} else if (currentTitle === '配台模版') {
// tempOption =[
// {
// template_name: '配台模版-4',
// template_number: 'order_4'
// },
// {
// template_name: '配台模版-5',
// template_number: 'order_5'
// },
// {
// template_name: '配台模版-6',
// template_number: 'order_6'
// }
// ]
// ===== doctor_name 、 template_desc
this.setState({
localTemplateOption: quickOrderOption
})
let resultArr = []
quickOrderOption.forEach(item => {
let obj = {}
let tempName = item.template_name
if(item.doctor_name) {
tempName += `——${item.doctor_name}`
}
obj.name = tempName,
obj.value = item.template_number,
obj.desc = item.template_desc
resultArr.push(obj)
})
tempOption = [...resultArr]
// tempOption = this.changeNameAndValue(quickOrderOption, 'template_name', 'template_number')
} else if (currentTitle === '订单类型') {
tempOption =[
{
order_type_name: '订单类型-4',
order_type_code: 'order_4'
},
{
order_type_name: '订单类型-5',
order_type_code: 'order_5'
},
{
order_type_name: '订单类型-6',
order_type_code: 'order_6'
}
]
tempOption = this.changeNameAndValue(tempOption, 'order_type_name', 'order_type_code')
// tempOption =[
// {
// order_type_name: '订单类型-4',
// order_type_code: 'order_4'
// },
// {
// order_type_name: '订单类型-5',
// order_type_code: 'order_5'
// },
// {
// order_type_name: '订单类型-6',
// order_type_code: 'order_6'
// }
// ]
tempOption = this.changeNameAndValue(quickOrderOption, 'value_name', 'value_code')
}
this.setState({
showTypePop: true,
......@@ -436,7 +863,9 @@ class EquipConsuPage extends Component {
handleCustomerCheck() {
console.warn('手术医院------check')
let { state, props } = this
this.setState({
let self = this
if(this.judgeOrgIsNull()) {
self.setState({
currentTitle: '手术医院',
currentItem: {
name: state.listOptionData[2].name,
......@@ -444,6 +873,21 @@ class EquipConsuPage extends Component {
}
}, () => {
// 在此修改接口
// let params = {
// access_token: props.token,
// org_code: state.listOptionData[1].value,
// seller_code: props.userInfo.user_name
// }
// console.log('-----params---', params)
// props.requestQuickSurgeryHospital(params)
self.getCustomerData()
})
}
}
// 获取手术医院
getCustomerData() {
let { state, props } = this
let params = {
access_token: props.token,
org_code: state.listOptionData[1].value,
......@@ -451,7 +895,6 @@ class EquipConsuPage extends Component {
}
console.log('-----params---', params)
props.requestQuickSurgeryHospital(params)
})
}
// 收单地点 点击
......@@ -459,7 +902,8 @@ class EquipConsuPage extends Component {
console.warn('收单地点------check')
let { localCustomersOption, listOptionData } = this.state
let self = this
this.setState({
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
self.setState({
currentTitle: '收单地点',
currentItem: {
name: listOptionData[3].name,
......@@ -487,13 +931,15 @@ class EquipConsuPage extends Component {
})
})
}
}
// 收货地点 点击
handleShipCheck() {
console.warn('收货地点------check')
let { localCustomersOption, listOptionData } = this.state
let self = this
this.setState({
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
self.setState({
currentTitle: '收货地点',
currentItem: {
name: listOptionData[4].name,
......@@ -521,13 +967,26 @@ class EquipConsuPage extends Component {
})
})
}
}
// 主治医生 点击/输入
handleDoctorCheck(text) {
console.warn('主治医生------check', text)
let { localCustomersOption, listOptionData } = this.state
let self = this
this.setState({
if(text) {
// 输入
self.setState({
listOptionData: listOptionData.map(item => {
if(item.title === '主治医生') {
item.inputValue = text
}
return item
})
})
} else if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
// 点击
self.setState({
currentTitle: '主治医生',
currentItem: {
name: listOptionData[5].name,
......@@ -547,6 +1006,11 @@ class EquipConsuPage extends Component {
}
})
}
let othObj = {
name: '其他',
value: ''
}
tempOption.push(othObj)
tempOption = dedupQuoteArray(tempOption, 'name')
console.log('---tempOption========?????-', tempOption)
self.setState({
......@@ -555,46 +1019,201 @@ class EquipConsuPage extends Component {
})
})
}
}
// 手术类型 点击
handleSurTypeCheck() {
console.warn('手术类型------check')
let { listOptionData, surgeryTypeOption } = this.state
let self = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
self.setState({
currentTitle: '手术类型',
currentItem: {
name: listOptionData[6].name,
value: listOptionData[6].value
}
}, () => {
self.setState({
showTypePop: true,
listCurrentOption: [...surgeryTypeOption]
})
})
}
}
// 配台模版 点击
handleMatchTempCheck() {
console.warn('配台模版------check')
let { state, props } = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
this.setState({
currentTitle: '配台模版',
currentItem: {
name: state.listOptionData[7].name,
value: state.listOptionData[7].value
}
}, () => {
// 在此修改接口
let params = {
access_token: props.token,
org_code: state.listOptionData[1].value,
seller_code: props.userInfo.user_name,
customer_code: state.listOptionData[2].value,
surgery_type: state.listOptionData[6].value,
doctor_name: state.listOptionData[5].value
}
console.log('-----params---', params)
props.requestQuickTemplateCollect(params)
})
}
}
// 手术类时间 点击 2020-04-23 17:41
handleSurDateCheck() {
console.warn('手术类时间 点击 ===')
let { listOptionData } = this.state
let date = listOptionData[8].value
if(date) {
this.setState({
listOptionData: listOptionData.map((item, index) => {
if(item.title === '手术类时间') {
item.dateValue = formatStrForDate(date)
}
return item
})
})
console.warn('!date----', listOptionData[8])
}
this.closeDateModal(true)
}
// 关闭日期选择器
closeDateModal(show) {
this.setState({
dateModelPop: show
})
}
// 修改当前日期数据
dateModalCallback(date) {
console.warn('callback',date)
let { listOptionData } = this.state
this.setState({
listOptionData: listOptionData.map((item, index) => {
if(item.title === '手术类时间') {
item.name = date
item.value = date
item.dateValue = formatStrForDate(date)
}
return item
})
})
console.warn('--手术类时间---', listOptionData[8])
}
// 订单类型 点击
handleOrderCheck() {
console.warn('订单类型------check')
let { state, props } = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
this.setState({
currentTitle: '订单类型',
currentItem: {
name: state.listOptionData[9].name,
value: state.listOptionData[9].value
}
}, () => {
// 在此修改接口
let params = {
access_token: props.token,
value_set_code:'SUR_ORDER_TYPE'
}
console.log('-----params---', params)
props.requestQuickOrderType(params)
})
}
}
// 备注 输入
handleRemarkInput(text) {
console.warn('备注---',text)
let { listOptionData } = this.state
this.setState({
listOptionData: listOptionData.map((item, index) => {
if(item.title === '备注') {
item.value = text
}
return item
})
})
}
// 生成订单 点击
handleSubmit() {
let { state, props } = this
let params = {
access_token: props.token,
path: state.audioPath
}
console.log('---handleSubmit--',params)
props.requestQuickAudio(params)
// this.addPhotoAction()
// console.warn(state.listOptionData)
// let tempSubOption = {...state.submitOption}
// tempSubOption.seller_code = state.listOptionData[0].value
// tempSubOption.org_code = state.listOptionData[1].value
// tempSubOption.customer_code = state.listOptionData[2].value
// tempSubOption.bill_to_site_code = state.listOptionData[3].value
// tempSubOption.ship_to_site_code = state.listOptionData[4].value
// tempSubOption.doctor_name = state.listOptionData[5].value
// tempSubOption.template_collect_number = state.listOptionData[7].value
// tempSubOption.surgery_date = state.listOptionData[8].value
// tempSubOption.order_type_code = state.listOptionData[9].value
// tempSubOption.surgery_desc = state.listOptionData[10].value
// tempSubOption.voice_url = state.listOptionData[11].value
// console.warn('tempSubOption-----', tempSubOption)
// let params = { access_token: props.token, ...tempSubOption}
// // Object.assign({},{ access_token: props.token }, tempSubOption)
// // this.setState({
// // })
// props.requestQuickSumbit(params)
}
// 判断组织是否为空
judgeOrgIsNull() {
let { listOptionData } = this.state
let orgVal = listOptionData[1].value
if(!orgVal) {
show('请先选择组织')
return false
} else {
return true
}
}
// 判断手术医院是否为空
judgeCustomerIsNull() {
let { listOptionData } = this.state
let orgVal = listOptionData[2].value
if(!orgVal) {
show('请先选择手术医院')
return false
} else {
return true
}
}
// 处理提交后返回的数据
processReturnData() {
let { listOptionData, currentTitle, localCustomersOption } = this.state
let { quickOrderOption } = this.props
console.warn('submit --- --- 当前:--quickOrderOption---', quickOrderOption)
}
// 返回备注以上的元素
......@@ -622,7 +1241,7 @@ class EquipConsuPage extends Component {
<CellTextStyle>
<AsteriskTextStyle>*</AsteriskTextStyle>
<TitleTextStyle>{'销售员'}</TitleTextStyle>
<ContInputTextStyle editable={false} defaultValue={listOptionData[0].value}></ContInputTextStyle>
<ContInputTextStyle editable={false} defaultValue={listOptionData[0].name}></ContInputTextStyle>
</CellTextStyle>
</TouchableOpacity>
</View>
......@@ -812,6 +1431,7 @@ class EquipConsuPage extends Component {
// 返回备注元素
renderRemarksItem() {
let { state } = this
return (
<CellTextStyle style={styles.remark_item}>
<View style={styles.rema_box}>
......@@ -828,6 +1448,7 @@ class EquipConsuPage extends Component {
style={styles.rema_Input}
maxLength={140}
onChangeText={(text) => this.handleRemarkInput(text)}
defaultValue={state.listOptionData[10].value}
/>
</TouchableOpacity>
</View>
......@@ -1114,6 +1735,7 @@ const mapStateToProps = (state) => {
return {
userInfo: state.login.userInfo,
token: state.login.token,
loginState: state.login.loginState,
quick_list_status: state.quick.quick_list_status,
submit_quick_order_status: state.quick.submit_quick_order_status,
quickOrderOption: state.quick.quickOrderOption
......@@ -1127,6 +1749,18 @@ const mapDispatchToProps = (dispatch) => {
},
requestQuickSurgeryHospital: (params) => {
dispatch(requestQuickSurgeryHospital(params))
},
requestQuickOrderType: (params) => {
dispatch(requestQuickOrderType(params))
},
requestQuickTemplateCollect: (params) => {
dispatch(requestQuickTemplateCollect(params))
},
requestQuickAudio: (params) => {
dispatch(requestQuickAudio(params))
},
requestQuickSumbit: (params) => {
dispatch(requestQuickSumbit(params))
}
}
}
......
......@@ -772,6 +772,7 @@ class SelfOrderPage extends Component {
this.setState({
listOptionData: listOptionData.map((item, index) => {
if(item.title === '手术类时间') {
item.name = date
item.value = date
item.dateValue = formatStrForDate(date)
}
......
......@@ -55,13 +55,21 @@ export const UploadRequest = (url,datas) => {
const opts = {
method: 'POST',
body: datas,
// headers: {
// // 'Accept': 'application/json',
// // 'Content-Type': 'application/json'
// 'Content-Type': 'multipart/form-data'
// // 'Content-Type': 'multipart/form-data;charset=utf-8'
// },
timeout: 20000 //20s超时
};
return fetch(`${BaseUrl}${VERSION}${url}`, opts)
// return fetch(`${BaseUrl}${VERSION}${url}`, opts)
return fetch(`${BaseUrlOther}${VERSION}${url}`, opts)
.then(response => response.json())
.then(data => data)
.catch(error => {
return {flag: -3, error_msg:'请求异常,请重试'}
console.log('error--------------------',error, Object.keys(error))
return {error_code: -3, error_msg:'请求异常,请重试'}
})
};
\ No newline at end of file
......@@ -39,7 +39,8 @@ export default self = (state = defaultState, action) => {
case QUICK_SUBMIT_SUCCESS:
return Object.assign({}, state, {
submit_quick_order_status: QUICK_SUBMIT_SUCCESS,
quickOrderOption: {} // 清空当前临时数据
quickOrderOption: action.rawData
// quickOrderOption: {} // 清空当前临时数据
})
case QUICK_SUBMIT_FAILURE:
return Object.assign({}, state, {
......
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