Commit a0c930d3 by peii

feat: 下单设置默认值

parent 3cf1f0a4
...@@ -84,6 +84,10 @@ export function requestQuickSurColSetting(params) { ...@@ -84,6 +84,10 @@ export function requestQuickSurColSetting(params) {
} }
} }
export function reqCollectSetting(baseUrl, params) {
return GetRequest(baseUrl, getUrlParams('/surgery/collect_setting/search', params))
}
export const reqSelfOrganizations = async (global_domain_config, params) => { export const reqSelfOrganizations = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/authorized_inventory/search', params)) return await GetRequest(global_domain_config, getUrlParams('/authorized_inventory/search', params))
} }
...@@ -174,6 +178,38 @@ export function requestSelfOrderType(params, url, cb = () => {}) { ...@@ -174,6 +178,38 @@ export function requestSelfOrderType(params, url, cb = () => {}) {
} }
} }
export async function reqSelfOrderType(params, url, host) {
if (!url) {
url = '/system/order_type/search'
}
return await GetRequest(host, getUrlParams(url, params))
.then(res => {
// 兼容老的接口,有的环境没有实现获取订单类型接口
if (res.status === 404) {
return reqSelfOrderType(params, '/system/value_set/search', host)
}
if (res.error_code == 0) {
let data = []
if (R.includes('order_type', url)) {
data = R.map(
R.applySpec({
value_name: R.prop('order_type_name'),
value_code: R.prop('order_type_code'),
}),
)(res.data)
} else {
data = res.data.sys_values
}
return data
}
})
.catch(err => {
if (!url) {
return reqSelfOrderType(params, '/system/value_set/search', host)
}
})
}
// 获取配台模板 params={access_token:'', org_code:'', seller_code: 'shi.ming', customer_code: '', surgery_type: '', doctor_name: ''} // 获取配台模板 params={access_token:'', org_code:'', seller_code: 'shi.ming', customer_code: '', surgery_type: '', doctor_name: ''}
export function requestSelfTemplateCollect(params) { export function requestSelfTemplateCollect(params) {
return (dispatch, getState) => { return (dispatch, getState) => {
...@@ -460,4 +496,4 @@ export function setLendOrderCodeValues(values) { ...@@ -460,4 +496,4 @@ export function setLendOrderCodeValues(values) {
export function getPayBankAccounts(host, params) { export function getPayBankAccounts(host, params) {
return GetRequest(host, getUrlParams('/surgery/app/salCustomerBank', params)) return GetRequest(host, getUrlParams('/surgery/app/salCustomerBank', params))
} }
\ No newline at end of file
...@@ -57,6 +57,8 @@ import { ...@@ -57,6 +57,8 @@ import {
requestQuickSurColSetting, requestQuickSurColSetting,
requestSurgeryType, requestSurgeryType,
getPayBankAccounts, getPayBankAccounts,
reqCollectSetting,
reqSelfOrderType,
} from '../../action/SelfAction' } from '../../action/SelfAction'
import { exitLoginStatus, requestSysProfile } from '../../action/LoginAction' import { exitLoginStatus, requestSysProfile } from '../../action/LoginAction'
import { import {
...@@ -723,7 +725,7 @@ class SelfOrderPage extends Component { ...@@ -723,7 +725,7 @@ class SelfOrderPage extends Component {
(chIndex == 21 && patientBedProfile.required) || (chIndex == 21 && patientBedProfile.required) ||
(chIndex == 22 && surgeryNameProfile.required) || (chIndex == 22 && surgeryNameProfile.required) ||
(chIndex == 23 && hospitalizationNumberProfile.required) || (chIndex == 23 && hospitalizationNumberProfile.required) ||
(chIndex == 24 && printProfile.required) || (chIndex == 24 && printProfile.required) ||
(chIndex == 28 && payBankProfile.required)) && (chIndex == 28 && payBankProfile.required)) &&
!listOptionData[chIndex].value !listOptionData[chIndex].value
) { ) {
...@@ -774,7 +776,11 @@ class SelfOrderPage extends Component { ...@@ -774,7 +776,11 @@ class SelfOrderPage extends Component {
} }
if (itemTitle === '客户名称') { if (itemTitle === '客户名称') {
that.clearInitNameAndValue(2) that.clearInitNameAndValue(2)
that.setDefaultByCustomer()
} else if (R.includes(itemTitle, ['收单地点', '收货地点']) && isBlank(listOptionData[18].value)) {
that.setDefaultByCustomer(true)
} }
if (itemTitle === '主治医生') { if (itemTitle === '主治医生') {
if (item.name === '其他') { if (item.name === '其他') {
chItem.showInput = true chItem.showInput = true
...@@ -836,6 +842,7 @@ class SelfOrderPage extends Component { ...@@ -836,6 +842,7 @@ class SelfOrderPage extends Component {
], ],
customer_code: cus.customer_code, customer_code: cus.customer_code,
customer_name: cus.customer_name, customer_name: cus.customer_name,
default: R.propOr({}, 'default', cus),
}))(customers) }))(customers)
} }
...@@ -1213,6 +1220,7 @@ class SelfOrderPage extends Component { ...@@ -1213,6 +1220,7 @@ class SelfOrderPage extends Component {
], ],
customer_code: cus.customer_code, customer_code: cus.customer_code,
customer_name: cus.customer_name, customer_name: cus.customer_name,
default: R.propOr({}, 'default', cus),
}))(customers) }))(customers)
} }
...@@ -1226,6 +1234,7 @@ class SelfOrderPage extends Component { ...@@ -1226,6 +1234,7 @@ class SelfOrderPage extends Component {
if (filterOpt.length === 1) { if (filterOpt.length === 1) {
listOptionData[2].name = filterOpt[0].customer_name listOptionData[2].name = filterOpt[0].customer_name
listOptionData[2].value = filterOpt[0].customer_code listOptionData[2].value = filterOpt[0].customer_code
that.setState( that.setState(
{ {
listOptionData, listOptionData,
...@@ -1235,6 +1244,7 @@ class SelfOrderPage extends Component { ...@@ -1235,6 +1244,7 @@ class SelfOrderPage extends Component {
that.customerGetBill() that.customerGetBill()
that.customerGetShip() that.customerGetShip()
that.getPayBankAccounts() that.getPayBankAccounts()
that.setDefaultByCustomer()
}, },
) )
} }
...@@ -1247,6 +1257,75 @@ class SelfOrderPage extends Component { ...@@ -1247,6 +1257,75 @@ class SelfOrderPage extends Component {
} }
} }
async setDefaultByCustomer(onlyInv = false) {
const { listOptionData, localCustomersOption } = this.state
const { sysValueSets, global_domain_config, token } = this.props
const customer = R.find(R.propEq('customer_code', listOptionData[2].value), localCustomersOption)
if (isBlank(customer) || isBlank(customer.default)) return
const defaultValue = customer.default
if (!onlyInv) {
const templateList = R.compose(
R.map(
R.applySpec({
value: R.prop('value_code'),
name: R.prop('value_name'),
}),
),
R.uniqBy(R.prop('value_code')),
R.propOr([], 'SUR_COLLECT_PRINT_TEMPLATE'),
)(sysValueSets)
const template = R.find(R.propEq('value', defaultValue.collect_print_template))(templateList)
if (isNotBlank(template)) {
listOptionData[24].value = template.value
listOptionData[24].name = template.name
}
let params = {
access_token: token,
value_set_code: 'SUR_ORDER_TYPE',
org_code: listOptionData[1].value,
order_type: 'SUR_ORDER_TYPE',
}
const orderTypes = await reqSelfOrderType(params, null, global_domain_config)
if (isNotBlank(orderTypes)) {
const orderType = R.find(R.propEq('value_code', defaultValue.order_type_code))(orderTypes)
if (isNotBlank(orderType)) {
listOptionData[7].value = defaultValue.order_type_code
listOptionData[7].name = orderType.value_name
}
}
}
if (R.any(isBlank, [listOptionData[2].value, listOptionData[3].value, listOptionData[4].value])) {
return this.setState({ listOptionData })
}
let params = {
access_token: token,
org_code: listOptionData[1].value,
customer_code: listOptionData[2].value,
bill_to_site_code: listOptionData[3].value,
ship_to_site_code: listOptionData[4].value,
process_code: 'COLLECT',
}
const invRes = await reqCollectSetting(global_domain_config, params).catch(() => ({}))
if (invRes.code === 0 && isNotBlank(invRes.data)) {
const inv = R.find(R.propEq('source_inv_code', defaultValue.inv_code))(invRes.data)
if (isNotBlank(inv)) {
listOptionData[18].value = defaultValue.inv_code
listOptionData[18].name = inv.source_inv_name
}
}
this.setState({ listOptionData })
}
/** /**
* 收单地点 点击 * 收单地点 点击
* */ * */
...@@ -1629,7 +1708,6 @@ class SelfOrderPage extends Component { ...@@ -1629,7 +1708,6 @@ class SelfOrderPage extends Component {
// 选择产品 点击跳转 // 选择产品 点击跳转
handleProductCheck() { handleProductCheck() {
const { localCustomersOption, listOptionData } = this.state const { localCustomersOption, listOptionData } = this.state
console.log(localCustomersOption)
if (isBlank(listOptionData[2].value) || isBlank(listOptionData[3].value) || isBlank(listOptionData[4].value)) { if (isBlank(listOptionData[2].value) || isBlank(listOptionData[3].value) || isBlank(listOptionData[4].value)) {
return show('请先选择客户相关信息') return show('请先选择客户相关信息')
......
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