Commit f02dea34 by Denglingling

完善【快速下单】提交成功后,清空当前页面数据、以及store缓存

parent cf69922c
......@@ -140,7 +140,6 @@ function requestListDataFail() {
}
// 上传语音 params={ access_token:'', path='录音地址' } -- 待修改
export function requestQuickAudio_222(params) {
return dispatch => {
......@@ -251,3 +250,10 @@ function requestSubmitFail() {
type: QUICK_SUBMIT_FAILURE
}
}
// 初始化数据
export function setQuickInitData() {
return {
type: QUICK_INIT_DATA
}
}
\ No newline at end of file
......@@ -88,7 +88,7 @@ export const list_common_item = {
rema_Input_inner: {
paddingTop: 10,
height: 105,
width: Width() - 38,
width: Width() - 58,
// borderWidth: 1,
// borderColor: '#eeeeee'
},
......@@ -405,7 +405,7 @@ export const list_common_item = {
ser_text_input: {
backgroundColor: '#F5F5F5',
height: 38,
lineHeight: 36,
lineHeight: 16,
paddingLeft: 34,
borderRadius: 10,
fontSize: 14,
......
......@@ -30,7 +30,7 @@ export function TitleTextStyle({style, ...props}) {
// 列表内容
export function ContTextStyle({style, ...props}) {
return <Text style={[styles.cont_text, style]} {...props} />
return <Text style={[styles.cont_text,styles.text_select, style]} {...props} />
}
// 列表输入框内容
......@@ -71,7 +71,6 @@ const styles = StyleSheet.create({
fontSize: second_text_size,
color: first_text_color,
fontFamily: font_family_semibold
// fontWeight: 'bold'
},
cont_text: {
fontSize: second_text_size,
......@@ -81,8 +80,10 @@ const styles = StyleSheet.create({
fontFamily: font_family_regular,
paddingLeft: 20
},
text_select: {
paddingLeft: 6
},
text_input: {
// height: 38,
paddingRight: 20
},
image_box: {
......@@ -96,7 +97,6 @@ const styles = StyleSheet.create({
height: 58,
backgroundColor: foundation_color,
paddingHorizontal: 20,
// paddingVertical: 20,
marginBottom: 18
},
btn_cont: {
......
......@@ -16,6 +16,7 @@ import {
safe_view
} from '../../base/BaseStyle';
// 选择器弹窗
class DialogModel extends Component {
constructor(props) {
super(props);
......@@ -23,18 +24,15 @@ class DialogModel extends Component {
isVisible: this.props.show,
entityList: this.props.entityList
}
// this.entityList = this.props.entityList
}
componentWillReceiveProps(nextProps) {
// console.warn('------show--------------',nextProps.show, this.state.isVisible )
if (this.state.isVisible != nextProps.show) {
this.setState({
isVisible: nextProps.show
});
}
if (this.state.entityList != nextProps.entityList) {
// this.entityList = nextProps.entityList
this.setState({
entityList: nextProps.entityList
})
......@@ -49,13 +47,14 @@ class DialogModel extends Component {
}
renderItem(item, index) {
// console.warn(this.props.itemIndex)
let { itemIndex, itemValue } = this.props
let { itemValue } = this.props
return (
<TouchableOpacity key={index} onPress={this.choose.bind(this, item, index)} style={[styles.item]}>
{/* <TouchableOpacity key={i} onPress={this.choose.bind(this, index)} style={[styles.item]}> */}
{/* <Text style={[styles.itemText, itemIndex == index ? styles.curr_item : '']}>{item.name}</Text> */}
<Text style={[styles.itemText, itemValue == item.value ? styles.curr_item : '']}>{item.name}</Text>
<TouchableOpacity
activeOpacity={.8}
key={index}
onPress={this.choose.bind(this, item, index)}
style={styles.list_item_box}>
<Text numberOfLines={1} style={[styles.list_item_text, itemValue == item.value ? styles.curr_item : '']}>{item.name}</Text>
</TouchableOpacity>
);
}
......@@ -63,7 +62,6 @@ class DialogModel extends Component {
choose(item, index) {
let { itemTitle } = this.props
if (this.state.isVisible) {
// this.props.callback(i);
this.props.callback(item, itemTitle);
this.closeModal();
}
......@@ -91,9 +89,6 @@ class DialogModel extends Component {
render() {
return (
// <View style={styles.dia_container}>
// <Text style={styles.dis_cont}>遮照层</Text>
// </View>
<View style={styles.dia_container}>
<Modal
transparent={true}
......@@ -114,14 +109,7 @@ class DialogModel extends Component {
const styles = StyleSheet.create({
dia_container: {
flex: 1,
// position: 'absolute',
// top: 0,
// left: 0,
// right: 0,
// backgroundColor: '#ccc',
// width: Width(),
// height: Height()
flex: 1
},
dis_cont: {
width: '80%',
......@@ -137,10 +125,7 @@ const styles = StyleSheet.create({
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
position: 'relative',
// marginTop: 12,
// marginBottom: 12,
// height: pxHeight(420)
position: 'relative'
},
modal_style: {
position: "absolute",
......@@ -154,16 +139,16 @@ const styles = StyleSheet.create({
borderTopRightRadius: 12,
maxHeight: pxHeight(480),
minHeight: pxHeight(180)
// maxHeight: '100%'
},
item: {
list_item_box: {
width: Width(),
height: 40,
paddingLeft: 20,
paddingRight: 20,
alignItems: 'center'
alignItems: 'center',
},
itemText: {
list_item_text: {
fontSize: 16,
color: third_text_color
},
......@@ -175,18 +160,7 @@ const styles = StyleSheet.create({
paddingVertical: 40,
paddingTop: 46
},
item_scroll: {
// height: '80%',
// marginTop: 30,
// paddingBottom: 30
},
// cancel: {
// width: Width(),
// height: 30,
// marginTop: 12,
// alignItems: 'center',
// backgroundColor: '#ffffff'
// },
item_scroll: {},
})
export default DialogModel;
\ No newline at end of file
......@@ -99,10 +99,18 @@ class NotEnoughModel extends Component {
style={styles.cont_list}
key={index}>
<Text style={[styles.co_li, styles.co_str]}>{item.item_name}({item.item_code})</Text>
<Text style={styles.co_li}>{item.general_name}</Text>
<Text style={styles.co_li}>{item.specification}</Text>
<Text style={styles.co_li}>{item.reg_number}</Text>
<Text style={styles.co_li}>{item.item_name}</Text>
<Text style={styles.co_li}>
{'通用名称:' + (item.general_name ? item.general_name : '无') }
</Text>
<Text style={styles.co_li}>
{'规格型号:' + (item.specification ? item.specification : '无') }
</Text>
<Text style={styles.co_li}>
{'注册证编号:' + (item.reg_number ? item.reg_number : '无') }
</Text>
<Text style={styles.co_li}>
{'物料名称:' + (item.item_name ? item.item_name : '无')}
</Text>
<Text style={styles.co_li}>
计划数量:
<Text style={styles.plan_num}>{item.plan_quantity}</Text>
......
......@@ -27,7 +27,7 @@ class SubSuccPage extends Component {
constructor(props) {
super(props);
this.state = {
orderVal: '20200318121230'
orderVal: ''
}
}
......@@ -41,6 +41,9 @@ class SubSuccPage extends Component {
}
async handleSubmit() {
let {orderVal} = this.state
if(orderVal) {
// 有订单号
console.warn('复制订单号并返回主页')
let { orderVal } = this.state
console.log('---orderNumber---', orderVal, typeof orderVal)
......@@ -49,6 +52,7 @@ class SubSuccPage extends Component {
let str = await Clipboard.getString()
console.warn(str)
show('复制成功')
}
// 返回首页
let { navigation } = this.props
setTimeout(() => {
......@@ -57,8 +61,8 @@ class SubSuccPage extends Component {
}
render() {
let {navigation} = this.props
let {title } = navigation.state.params
let { navigation } = this.props
let { title } = navigation.state.params
let { state } = this
return (
<View style={styles.succ_container}>
......@@ -74,13 +78,19 @@ class SubSuccPage extends Component {
<Image source={require('../../images/cor_green.png')} style={styles.img_icon}/>
</View>
<Text style={styles.succ_title}>{'提交成功'}</Text>
{
state.orderVal ?
<Text style={styles.succ_text}>{'订单号:'} { state.orderVal }</Text>
: null
}
<TouchableOpacity
activeOpacity={.9}
style={styles.succ_btn}
onPress={() => this.handleSubmit()}
>
<Text style={styles.btn_text}>{'复制订单号并返回主页'}</Text>
<Text style={styles.btn_text}>
{ state.orderVal ? '复制订单号并返回主页' : '返回主页'}
</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
......
......@@ -7,7 +7,9 @@ import {
ScrollView,
TouchableOpacity,
Image,
TextInput
TextInput,
Alert,
Platform
} from 'react-native';
import {
home_background_color,
......@@ -29,7 +31,7 @@ import {
FooterBtnStyle
} from '../common/CellTextStyle';
import { connect } from 'react-redux';
import { show, isEmpty, dedupQuoteArray, formatStrForDate } from '../../utils/Utils';
import { show, isEmpty, dedupQuoteArray, formatStrForDate, cloneObject } from '../../utils/Utils';
import { AudioRecorder, AudioUtils } from 'react-native-audio';
import Sound from 'react-native-sound';
import DateModel from '../common/DateModel';
......@@ -43,7 +45,8 @@ import {
requestQuickTemplateCollect,
requestQuickAudio,
requestQuickSumbit,
uploadAttachment
uploadAttachment,
setQuickInitData
} from '../../action/QuickAction';
import { exitLoginStatus } from '../../action/LoginAction';
import {
......@@ -63,7 +66,7 @@ class EquipConsuPage extends Component {
super(props);
this.state = {
canSubFlag: false, // 生成订单按钮样式改变
listOptionData: [ // 备注以上的元素
listOptionData: [ // 页面元素
{
"id": "0",
title: '销售员',
......@@ -166,6 +169,7 @@ class EquipConsuPage extends Component {
isRecode: true // 录音
}
],
subInitListOption: [], // 提交成功后,初始化当前数据
submitOption: { // 提交的信息
seller_code: '', // 用户名username
org_code: '', // 组织
......@@ -351,20 +355,30 @@ class EquipConsuPage extends Component {
})
}
// 赋值销售员
// 赋值销售员 初始化数据
getSellerName() {
let {state, props} = this
// console.log('---userInfo',props.userInfo)
if(state.listOptionData[0].name !== props.userInfo.person_name) {
let {listOptionData} = this.state
this.setState({
listOptionData: state.listOptionData.map((item) => {
if(item.title === '销售员') {
item.name = props.userInfo.person_name
item.value = props.userInfo.user_name
}
return item
subInitListOption: cloneObject(listOptionData) // 存储初始化数据,提交成功后赋此值
})
if(state.listOptionData[0].name !== props.userInfo.person_name) {
listOptionData[0].name = props.userInfo.person_name
listOptionData[0].value = props.userInfo.user_name
this.setState({
listOptionData,
subInitListOption: cloneObject(listOptionData)
})
// this.setState({
// listOptionData: state.listOptionData.map((item) => {
// if(item.title === '销售员') {
// item.name = props.userInfo.person_name
// item.value = props.userInfo.user_name
// }
// return item
// })
// })
}
}
......@@ -598,6 +612,10 @@ class EquipConsuPage extends Component {
if(index > curIndex && index < 11 ) {
item.name = localOtherObj.name
item.value = localOtherObj.value
if(item.title == '主治医生') {
item.showInput = false,
item.inputValue = ''
}
}
return item
})
......@@ -634,7 +652,7 @@ class EquipConsuPage extends Component {
handleCallBack(item, itemTitle) {
// console.warn(item, 'item------')
// console.warn('item-itemTitle-----',itemTitle)
let { listOptionData, localOtherObj} = this.state
let { listOptionData} = this.state
let self = this
this.setState({
currentItem: item,
......@@ -685,7 +703,7 @@ class EquipConsuPage extends Component {
// 修改当前选择器数据
changeCurrentOption() {
let { listOptionData, currentTitle, localCustomersOption } = this.state
let { currentTitle } = this.state
let { quickOrderOption } = this.props
console.log('当前:--quickOrderOption---', quickOrderOption)
let tempOption = []
......@@ -1087,51 +1105,19 @@ class EquipConsuPage extends Component {
let { state, props } = this
let that = this
// // 测试 -- 录音
// let params = {
// access_token: props.token,
// path: state.audioPath
// }
// console.log('---handleSubmit--',params)
// // props.requestQuickAudio(params)
// // requestQuickAudio(params).then((response) => {
// // console.log('返回---', response)
// // })
// let audioResult = await requestQuickAudio(params);
// console.log('返回---audioResult======',audioResult)
// this.changeSubLoding(true, '上传中')
// if(audioResult.error_code == 0) {
// // 提交订单
// that.setState({
// listOptionData: state.listOptionData.map((item, index) => {
// if(index == 11) {
// item.value = audioResult.data.url
// }
// return item
// })
// }, () => {
// this.changeSubLoding(false)
// that.submitQuickOrder()
// })
// } else if(audioResult.error_code == 41006) {
// this.changeSubLoding(false)
// show('登录过期,请重新登录');
// props.exitLoginStatus();
// } else {
// this.changeSubLoding(false)
// let error_msg = audioResult.error_msg || audioResult.message
// show(error_msg);
// }
console.log('提交======》', state.canSubFlag, state.stop, state.isSubLoding)
// // // 测试 -- 图片上传
// // this.addPhotoAction()
// 测试
// this.clearAllData()
// let { state: { params: { title } } } = this.props.navigation
// this.props.navigation.navigate('SubSuccPage', {
// title: `${title} - 下单成功`,
// orderNumber: quickOrderOption.survey_collect_number
// })
// console.log('提交======》', state.canSubFlag, state.stop, state.isSubLoding)
// 可提交 并且 不处于正在提交中
if(state.canSubFlag && !state.isSubLoding) {
// console.warn('进入提交内容----------')
console.warn('进入提交内容----------')
// console.warn(state.listOptionData)
// 先提交录音,再提交接口
......@@ -1141,9 +1127,9 @@ class EquipConsuPage extends Component {
access_token: props.token,
path: state.audioPath
}
// console.log('---handleSubmit--',params)
console.log('---handleSubmit--',params)
let audioResult = await requestQuickAudio(params);
// console.log('返回---audioResult======',audioResult)
console.log('返回---audioResult======',audioResult)
that.changeSubLoding(true, '上传中')
if(audioResult.error_code == 0) {
// 提交订单
......@@ -1194,7 +1180,7 @@ class EquipConsuPage extends Component {
tempSubOption.surgery_desc = state.listOptionData[10].value
tempSubOption.voice_url = state.listOptionData[11].value
// console.log('tempSubOption-----', tempSubOption)
console.log('tempSubOption-----', tempSubOption)
let params = {
access_token: props.token,
data: { ...tempSubOption }
......@@ -1228,7 +1214,7 @@ class EquipConsuPage extends Component {
// 处理提交后返回的数据
processReturnData() {
let { quickOrderOption } = this.props
let { quickOrderOption, setQuickInitData } = this.props
console.log('submit --- !!!! --- 当前:--quickOrderOption---', quickOrderOption)
if(quickOrderOption.create_success) {
if(quickOrderOption.create_success == 'N') {
......@@ -1240,6 +1226,7 @@ class EquipConsuPage extends Component {
} else if(quickOrderOption.create_success == 'Y') {
// 打开下单成功页面
this.clearAllData()
let { state: { params: { title } } } = this.props.navigation
this.props.navigation.navigate('SubSuccPage', {
title: `${title} - 下单成功`,
......@@ -1251,6 +1238,17 @@ class EquipConsuPage extends Component {
}
// 清空数据
clearAllData() {
let {props} = this
let {listOptionData, subInitListOption} = this.state
props.setQuickInitData() // 清空缓存数据
listOptionData = cloneObject(subInitListOption) // 清空本地数据
this.setState({
listOptionData
})
}
// 库存不足弹窗回调 -- 确定
handleNotEnoughCallBack() {
// console.log('callback----heihei: 点击确定!!!')
......@@ -1673,6 +1671,9 @@ const mapDispatchToProps = (dispatch) => {
},
exitLoginStatus: () => {
dispatch(exitLoginStatus())
},
setQuickInitData: () => {
dispatch(setQuickInitData())
}
}
}
......
import Toast from 'react-native-root-toast';
import {Dimensions, Platform,PixelRatio} from "react-native";
import {Dimensions, Platform,PixelRatio, Text} from "react-native";
export const show = (data) => {
export const show = (data, type) => {
// default
let text_color = '#fafafa'
let back_color = '#222'
let tip_data = data
if(type == 'error') {
text_color = '#f5222d'
back_color ='#fff1f0'
tip_data = ${data}`
} else if(type == 'warn') {
text_color = '#fa8c16'
back_color ='#fff7e6'
tip_data = `! ${data}`
} else if(type == 'success') {
text_color = '#52c41a'
back_color ='#f6ffed'
tip_data = `√ ${data}`
}
if(data != null) {
Toast.show(data, {
Toast.show(tip_data, {
duration: Toast.durations.LONG,
position: Toast.positions.CENTER,
shadow: true,
shadow: false,
hideOnPress: true,
delay: 0,
visible: true,
backgroundColor: '#222',
textColor: '#fff'
backgroundColor: back_color,
textColor: text_color,
shadowColor: text_color
})
}
}
......@@ -127,6 +145,15 @@ export const dedupQuoteArray = (arr, typeName) => {
return result;
}
/**
* 深度克隆对象、数组
* @param obj 被克隆的对象
* @return 克隆后的对象
*/
export function cloneObject(obj) {
return JSON.parse(JSON.stringify(obj))
}
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