Commit 04f673b6 by Denglingling

优化【快速下单】,新增多仓模块

parent d9584521
......@@ -50,9 +50,12 @@ import {
setQuickInitData,
reqQuickSurgeryHospital,
requestListDataSuccess,
requestQuickSurgeryType
requestQuickSurgeryType,
reqQuickOrganizations,
requestQuickSurColSetting,
reqQuickTemplateCollect
} from '../../action/QuickAction';
import { exitLoginStatus } from '../../action/LoginAction';
import { exitLoginStatus, requestSysProfile } from '../../action/LoginAction';
import {
QUICK_ORDER_LIST_DOING,
QUICK_ORDER_LIST_SUCCESS,
......@@ -62,6 +65,7 @@ import {
QUICK_SUBMIT_SUCCESS,
QUICK_SUBMIT_FAILURE
} from '../../base/ActionTypes';
import moment from 'moment';
class EquipConsuPage extends Component {
constructor(props) {
......@@ -122,8 +126,8 @@ class EquipConsuPage extends Component {
{
"id": "8",
title: '手术时间',
name: '请选择',
value: '',
name: moment(new Date()).format("YYYY-MM-DD HH:mm"),
value: moment(new Date()).format("YYYY-MM-DD HH:mm"),
dateValue: new Date(),
showDatePicker: true
},
......@@ -135,12 +139,18 @@ class EquipConsuPage extends Component {
},
{
"id": "10",
title: '借货仓库',
name: '请选择',
value: ''
},
{
"id": "11",
title: '备注',
value: '',
isRemark: true // 备注
},
{
"id": "11",
"id": "12",
title: '还有什么要安排的,可录音备注哟!',
value: '',
isRecode: true // 录音
......@@ -178,10 +188,6 @@ class EquipConsuPage extends Component {
isSubLoding: false, // 加载中弹窗
lodingTitle: '加载中',
listCurrentOption: [ // 当前选择器数据
// {
// name: '男',
// value: 'boy'
// }
],
dateModelPop: false, // 日期选择器
hasPermission: undefined, //录音 授权状态
......@@ -208,12 +214,15 @@ class EquipConsuPage extends Component {
// ],
showNotEnogPop: false, // 库存不足弹窗
not_enough_items_list:[], // 库存不足数据
bor_ware_required: '', // APP借货仓库必填权限
}
}
componentDidMount() {
this.getSellerName()
this.getAudioAuthorize()
this.getOrganizationData()
this.getSysConfigValue()
}
// 赋值销售员 初始化数据
......@@ -411,14 +420,14 @@ class EquipConsuPage extends Component {
// 播放录音
_play = async () => {
let self = this
let that = this
show('正在播放')
self.whoosh = new Sound(this.state.audioPath, '', (err) => {
that.whoosh = new Sound(this.state.audioPath, '', (err) => {
if(err) {
show('加载音频失败')
return console.log('加载音频失败-->',err)
}
self.whoosh.play(success => {
that.whoosh.play(success => {
if(success) {
show('播放完毕')
}else {
......@@ -434,7 +443,7 @@ class EquipConsuPage extends Component {
// 初始化录音
this.prepareRecordingPath(this.state.audioPath)
let {listOptionData} = this.state
listOptionData[11].value = ''
listOptionData[12].value = ''
this.setState({
currentTime: 0,
stop: false,
......@@ -444,18 +453,18 @@ class EquipConsuPage extends Component {
componentWillReceiveProps(nextProps) {
let { quick_list_status, loginState, navigation, submit_quick_order_status} = this.props
let self = this
let that = this
if(quick_list_status != nextProps.quick_list_status) {
switch (nextProps.quick_list_status) {
case QUICK_ORDER_LIST_DOING:
this.changeSubLoding(true)
break;
case QUICK_ORDER_LIST_SUCCESS:
self.setState({
that.setState({
isSubLoding: false,
lodingTitle: '加载中'
},() => {
self.changeCurrentOption()
that.changeCurrentOption()
})
break;
case QUICK_ORDER_LIST_FAILURE:
......@@ -480,12 +489,20 @@ class EquipConsuPage extends Component {
this.changeSubLoding(true, '提交中')
break;
case QUICK_SUBMIT_SUCCESS:
self.setState({
isSubLoding: false,
lodingTitle: '提交中'
},() => {
self.processReturnData()
})
// that.setState({
// isSubLoding: false,
// lodingTitle: '提交中'
// },() => {
// that.processReturnData()
// })
setTimeout(() => {
that.setState({
isSubLoding: false,
lodingTitle: '提交中'
}, () => {
that.processReturnData()
})
}, 500)
break;
case QUICK_SUBMIT_FAILURE:
this.changeSubLoding(false, '提交中')
......@@ -510,7 +527,7 @@ class EquipConsuPage extends Component {
let that = this
this.setState({
listOptionData: listOptionData.map((item, index) => {
if(index > curIndex && index < 11 ) {
if(index > curIndex && index < 12 ) {
item.name = localOtherObj.name
item.value = localOtherObj.value
if(listOptionData[1].value && item.title == '客户名称') {
......@@ -523,9 +540,12 @@ class EquipConsuPage extends Component {
that.customerGetShip()
}
if(item.title == '主治医生') {
item.showInput = false,
item.showInput = false
item.inputValue = ''
}
if((listOptionData[5].value || listOptionData[5].inputValue) && item.title === '手术模板'){
that.getMatchTempData()
}
}
return item
})
......@@ -534,11 +554,15 @@ class EquipConsuPage extends Component {
// 判断是否都有值,修改提交按钮的颜色
changeCanSub(isSubCheck) {
let { listOptionData } = this.state
let { listOptionData, bor_ware_required } = this.state
let tempStatus = false
let tempTit = ''
let maxIndex = 10
if(bor_ware_required === 'Y'){
maxIndex = 11
}
for(let chIndex in listOptionData) {
if(chIndex > 0 && chIndex < 10
if(chIndex > 0 && chIndex < maxIndex
&& chIndex != 6 && chIndex != 8
&& !listOptionData[chIndex].value
&& listOptionData[chIndex].name !== '其他') {
......@@ -559,32 +583,32 @@ class EquipConsuPage extends Component {
// 选择器弹窗回调函数
handleCallBack(item, itemTitle) {
let { listOptionData} = this.state
let self = this
let that = this
listOptionData.map(function(chItem, index){
if(chItem.title === itemTitle) {
chItem.name = item.name
chItem.value = item.value
if(itemTitle === '组织') {
self.clearInitNameAndValue(1)
that.clearInitNameAndValue(1)
}
if(itemTitle === '客户名称') {
self.clearInitNameAndValue(2)
that.clearInitNameAndValue(2)
}
if (itemTitle === '主治医生') {
if(itemTitle === '主治医生') {
if(item.name === '其他') {
chItem.showInput = true
} else {
chItem.showInput = false
chItem.inputValue = ''
}
self.clearInitNameAndValue(5)
that.clearInitNameAndValue(5)
}
if(itemTitle === '手术类型') {
self.clearInitNameAndValue(6)
that.clearInitNameAndValue(6)
}
if(itemTitle === '手术模板') {
listOptionData[11].value = item.desc
}
if (itemTitle === '手术模板') {
listOptionData[10].value = item.desc
}
}
})
......@@ -592,7 +616,7 @@ class EquipConsuPage extends Component {
currentItem: item,
listOptionData: listOptionData
},() => {
self.changeCanSub()
that.changeCanSub()
})
}
......@@ -657,6 +681,9 @@ class EquipConsuPage extends Component {
tempOption = [...resultArr]
} else if (currentTitle === '订单类型') {
tempOption = this.changeNameAndValue(quickOrderOption, 'value_name', 'value_code')
} else if (currentTitle === '借货仓库') {
let filterOpt = dedupQuoteArray(quickOrderOption, 'source_inv_code')
tempOption = this.changeNameAndValue(filterOpt, 'source_inv_name', 'source_inv_code')
}
this.setState({
listCurrentOption: [...tempOption]
......@@ -697,12 +724,49 @@ class EquipConsuPage extends Component {
props.requestQuickOrganizations(params)
})
}
async getOrganizationData() {
let { state, props } = this
let params = {
access_token: props.token
}
let that = this
let { global_domain_config } = props
let orgResult = await reqQuickOrganizations(global_domain_config, params);
if (orgResult.error_code == 0) {
let { data: { organizations } } = orgResult
let { listOptionData } = state
// props.requestListDataSuccess(organizations)
let filterOpt = dedupQuoteArray(organizations, 'org_code')
if (filterOpt.length === 0) {
show(`当前${listOptionData[1].title}为空`)
return
}
if (filterOpt.length === 1) {
listOptionData[1].name = filterOpt[0].org_name
listOptionData[1].value = filterOpt[0].org_code
that.setState({
listOptionData
}, () => {
that.organizationGetCustomerData()
})
}
}else {
this.showWarnError(orgResult)
}
// else if (orgResult.error_code == 41006) {
// show('登录过期,请重新登录');
// props.exitLoginStatus();
// } else {
// let error_msg = orgResult.error_msg || orgResult.message
// show(error_msg);
// }
}
// 客户名称 点击
handleCustomerCheck() {
let { state } = this
let self = this
let that = this
if(this.judgeOrgIsNull()) {
self.setState({
that.setState({
currentTitle: '客户名称',
currentItem: {
name: state.listOptionData[2].name,
......@@ -710,7 +774,7 @@ class EquipConsuPage extends Component {
}
}, () => {
// 在此修改接口
self.getCustomerData()
that.getCustomerData()
})
}
}
......@@ -737,14 +801,14 @@ class EquipConsuPage extends Component {
let cusResult = await reqQuickSurgeryHospital(global_domain_config, params);
if(cusResult.error_code == 0) {
let { data: { customers } } = cusResult
props.requestListDataSuccess(customers)
let { listOptionData } = state
// props.requestListDataSuccess(customers)
let filterOpt = dedupQuoteArray(customers, 'customer_code')
if(filterOpt.length === 0) {
show(`当前客户名称为空`)
show(`当前${listOptionData[2].title}为空`)
return
}
if(filterOpt.length === 1) {
let { listOptionData } = state
listOptionData[2].name = filterOpt[0].customer_name
listOptionData[2].value = filterOpt[0].customer_code
that.setState({
......@@ -755,20 +819,23 @@ class EquipConsuPage extends Component {
that.customerGetShip()
})
}
} else if(cusResult.error_code == 41006) {
show('登录过期,请重新登录');
props.exitLoginStatus();
} else {
let error_msg = cusResult.error_msg || cusResult.message
show(error_msg);
}else {
this.showWarnError(cusResult)
}
// else if(cusResult.error_code == 41006) {
// show('登录过期,请重新登录');
// props.exitLoginStatus();
// } else {
// let error_msg = cusResult.error_msg || cusResult.message
// show(error_msg);
// }
}
// 收单地点 点击
handleBillCheck() {
let { localCustomersOption, listOptionData } = this.state
let self = this
let that = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
self.setState({
that.setState({
currentTitle: '收单地点',
currentItem: {
name: listOptionData[3].name,
......@@ -788,7 +855,7 @@ class EquipConsuPage extends Component {
})
}
tempOption = dedupQuoteArray(tempOption, 'name')
self.setState({
that.setState({
showTypePop: true,
listCurrentOption: [...tempOption]
})
......@@ -801,7 +868,7 @@ class EquipConsuPage extends Component {
let tempLocalOption = localCustomersOption.filter(item => item.customer_code === listOptionData[2].value)
tempLocalOption = dedupQuoteArray(tempLocalOption, 'bill_to_site_code')
if(tempLocalOption.length === 0) {
show(`当前收单地点为空`)
show(`当前${listOptionData[3].title}为空`)
return
}
if(tempLocalOption.length === 1) {
......@@ -815,9 +882,9 @@ class EquipConsuPage extends Component {
// 收货地点 点击
handleShipCheck() {
let { localCustomersOption, listOptionData } = this.state
let self = this
let that = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
self.setState({
that.setState({
currentTitle: '收货地点',
currentItem: {
name: listOptionData[4].name,
......@@ -837,7 +904,7 @@ class EquipConsuPage extends Component {
})
}
tempOption = dedupQuoteArray(tempOption, 'name')
self.setState({
that.setState({
showTypePop: true,
listCurrentOption: [...tempOption]
})
......@@ -850,7 +917,7 @@ class EquipConsuPage extends Component {
let tempLocalOption = localCustomersOption.filter(item => item.customer_code === listOptionData[2].value)
tempLocalOption = dedupQuoteArray(tempLocalOption, 'ship_to_site_code')
if(tempLocalOption.length === 0) {
show(`当前收货地点为空`)
show(`当前${listOptionData[4].title}为空`)
return
}
if(tempLocalOption.length === 1) {
......@@ -864,10 +931,10 @@ class EquipConsuPage extends Component {
// 主治医生 点击
handleDoctorCheck() {
let { localCustomersOption, listOptionData } = this.state
let self = this
let that = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
// 点击
self.setState({
that.setState({
currentTitle: '主治医生',
currentItem: {
name: listOptionData[5].name,
......@@ -892,7 +959,7 @@ class EquipConsuPage extends Component {
}
tempOption.push(othObj)
tempOption = dedupQuoteArray(tempOption, 'name')
self.setState({
that.setState({
showTypePop: true,
listCurrentOption: [...tempOption]
})
......@@ -915,9 +982,9 @@ class EquipConsuPage extends Component {
handleSurTypeCheck() {
let { listOptionData } = this.state
let { props } = this
let self = this
let that = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
self.setState({
that.setState({
currentTitle: '手术类型',
currentItem: {
name: listOptionData[6].name,
......@@ -948,18 +1015,59 @@ class EquipConsuPage extends Component {
if(state.listOptionData[5].name !== '其他') {
tempDoctorName = state.listOptionData[5].value
}
let cur_surgery_type = state.listOptionData[6].name === '请选择' ? '' : state.listOptionData[6].name
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,
surgery_type: cur_surgery_type,
doctor_name: tempDoctorName
}
props.requestQuickTemplateCollect(params)
})
}
}
async getMatchTempData() {
let { state, props } = this
let tempDoctorName = ''
if(state.listOptionData[5].name !== '其他') {
tempDoctorName = state.listOptionData[5].value
}
let cur_surgery_type = state.listOptionData[6].name === '请选择' ? '' : state.listOptionData[6].name
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: cur_surgery_type,
doctor_name: tempDoctorName
}
console.log('params=====', params)
let that = this
let { global_domain_config } = props
let tempResult = await reqQuickTemplateCollect(global_domain_config, params);
if (tempResult.error_code == 0) {
let { data: { surgery_template_headers } } = tempResult
let { listOptionData } = state
props.requestListDataSuccess(surgery_template_headers)
let filterOpt = dedupQuoteArray(surgery_template_headers, 'template_number')
if (filterOpt.length === 0) {
show(`当前${listOptionData[7].title}为空`)
return
}
if (filterOpt.length === 1) {
listOptionData[7].name = filterOpt[0].template_name
listOptionData[7].value = filterOpt[0].template_number
listOptionData[11].value = filterOpt[0].template_desc
that.setState({
listOptionData
})
}
}else {
this.showWarnError(tempResult)
}
}
// 手术时间 点击 2020-04-23 17:41
handleSurDateCheck() {
let { listOptionData } = this.state
......@@ -1016,6 +1124,30 @@ class EquipConsuPage extends Component {
})
}
}
// 借货仓库 点击
handleWareCheck(){
let { state, props } = this
if(this.judgeOrgIsNull() && this.judgeCustomerIsNull()) {
this.setState({
currentTitle: state.listOptionData[10].title,
currentItem: {
name: state.listOptionData[10].name,
value: state.listOptionData[10].value
}
}, () => {
// 在此修改接口
let params = {
access_token: props.token,
org_code: state.listOptionData[1].value,
customer_code: state.listOptionData[2].value,
bill_to_site_code: state.listOptionData[3].value,
ship_to_site_code: state.listOptionData[4].value,
process_code: 'COLLECT'
}
props.requestQuickSurColSetting(params)
})
}
}
// 备注 输入
handleRemarkInput(text) {
let { listOptionData } = this.state
......@@ -1048,7 +1180,7 @@ class EquipConsuPage extends Component {
// 提交订单
that.setState({
listOptionData: state.listOptionData.map((item, index) => {
if(index == 11) {
if(index == 12) {
item.value = audioResult.data.url
}
return item
......@@ -1060,12 +1192,14 @@ class EquipConsuPage extends Component {
} else if(audioResult.error_code == 41006) {
that.changeSubLoding(false)
show('登录过期,请重新登录');
props.exitLoginStatus();
this.showWarnError(audioResult)
// show('登录过期,请重新登录');
// props.exitLoginStatus();
} else {
// that.changeSubLoding(false)
let error_msg = audioResult.error_msg || audioResult.message
show(error_msg);
that.changeSubLoding(false)
this.showWarnError(audioResult)
// let error_msg = audioResult.error_msg || audioResult.message
// show(error_msg);
that.submitQuickOrder()
}
} else {
......@@ -1090,12 +1224,14 @@ class EquipConsuPage extends Component {
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
tempSubOption.collect_src_inv_code = state.listOptionData[10].value
tempSubOption.surgery_desc = state.listOptionData[11].value
tempSubOption.voice_url = state.listOptionData[12].value
let params = {
access_token: props.token,
data: { ...tempSubOption }
}
console.log('params----', params)
props.requestQuickSumbit(params)
}
// 判断组织是否为空
......@@ -1163,14 +1299,14 @@ class EquipConsuPage extends Component {
// 库存不足弹窗回调 -- 确定
handleNotEnoughCallBack() {
let { submitOption } = this.state
let self = this
let that = this
this.setState({
submitOption: {
...submitOption,
force_balance_check_flag: 'N'
}
}, () => {
self.handleSubmit()
that.handleSubmit()
})
}
// 库存不足弹窗关闭
......@@ -1178,10 +1314,44 @@ class EquipConsuPage extends Component {
this.setState({
showNotEnogPop: show
})
}
}
// 获取配置值
async getSysConfigValue() {
let { global_domain_config, token } = this.props
const params = {
access_token: token,
profile_code: 'OBS_MOBILE_BOR_WARE_REQUIRED'
}
let sysRes = await requestSysProfile(global_domain_config, params)
console.log('sysRes:==', sysRes)
if(sysRes.error_code === 0){
this.setState({
bor_ware_required: sysRes.data.profile_value
})
}else {
this.showWarnError(sysRes)
}
// else if(sysRes.error_code == 41006) {
// show('登录过期,请重新登录');
// this.props.exitLoginStatus();
// } else {
// let error_msg = sysRes.error_msg || sysRes.message
// show(error_msg);
// }
}
showWarnError(res){
if(res.error_code == 41006) {
show('登录过期,请重新登录');
this.props.exitLoginStatus();
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
}
}
// 返回备注以上的元素
renderListItem() {
let { listOptionData, dateModelPop } = this.state
let { listOptionData, dateModelPop, bor_ware_required } = this.state
return(
<View style={styles.list_cont}>
<View style={styles.item_container}>
......@@ -1325,7 +1495,20 @@ class EquipConsuPage extends Component {
{ this.renderRightArrowItem() }
</CellTextStyle>
</TouchableOpacity>
</View>
</View>
<View style={styles.item_container}>
<TouchableOpacity
activeOpacity={.8}
onPress={() => this.handleWareCheck()}
>
<CellTextStyle>
{ bor_ware_required === 'Y' ? <AsteriskTextStyle>*</AsteriskTextStyle> : null}
<TitleTextStyle>{listOptionData[10].title}</TitleTextStyle>
<ContTextStyle>{listOptionData[10].name}</ContTextStyle>
{ this.renderRightArrowItem() }
</CellTextStyle>
</TouchableOpacity>
</View>
{ this.renderPickerModel() }
</View>
)
......@@ -1379,7 +1562,7 @@ class EquipConsuPage extends Component {
style={list_common_item.rema_Input}
maxLength={140}
onChangeText={(text) => this.handleRemarkInput(text)}
defaultValue={state.listOptionData[10].value}
defaultValue={state.listOptionData[11].value}
/>
</TouchableOpacity>
</View>
......@@ -1563,6 +1746,9 @@ const mapDispatchToProps = (dispatch) => {
},
requestQuickSurgeryType: (params) => {
dispatch(requestQuickSurgeryType(params))
},
requestQuickSurColSetting: (params) => {
dispatch(requestQuickSurColSetting(params))
}
}
}
......
......@@ -523,13 +523,14 @@ class surgeryTemplatePage extends Component {
}else {
tempDoctorName = state.listOptionData[2].inputValue
}
let cur_surgery_type = state.listOptionData[3].name === '请选择' ? '' : state.listOptionData[3].name
let params = {
access_token: props.token,
org_code: state.listOptionData[0].value,
seller_code: props.userInfo.user_name,
customer_code: state.listOptionData[1].value,
doctor_name: tempDoctorName,
surgery_type: state.listOptionData[3].value,
surgery_type: cur_surgery_type,
}
props.requestQuickTemplateCollect(params)
}
......
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