Commit 0c643e22 by peii

fix: 修复

parent eba09817
Showing with 73 additions and 46 deletions
...@@ -665,7 +665,8 @@ class SelfOrderPage extends Component { ...@@ -665,7 +665,8 @@ class SelfOrderPage extends Component {
that.customerGetShip() that.customerGetShip()
} }
if (item.title == '主治医生') { if (item.title == '主治医生') {
;(item.showInput = false), (item.inputValue = '') item.showInput = false
item.inputValue = ''
} }
} }
return item return item
...@@ -776,9 +777,10 @@ class SelfOrderPage extends Component { ...@@ -776,9 +777,10 @@ class SelfOrderPage extends Component {
} }
if (itemTitle === '客户名称') { if (itemTitle === '客户名称') {
that.clearInitNameAndValue(2) that.clearInitNameAndValue(2)
// that.setDefaultByCustomer()
} else if (R.includes(itemTitle, ['收货地点'])) {
// TODO:
that.setDefaultByCustomer() that.setDefaultByCustomer()
} else if (R.includes(itemTitle, ['收单地点', '收货地点']) && isBlank(listOptionData[18].value)) {
that.setDefaultByCustomer(true)
} }
if (itemTitle === '主治医生') { if (itemTitle === '主治医生') {
...@@ -1183,11 +1185,14 @@ class SelfOrderPage extends Component { ...@@ -1183,11 +1185,14 @@ class SelfOrderPage extends Component {
callback: customer => { callback: customer => {
if (isBlank(customer)) return if (isBlank(customer)) return
this.setState({localCustomersOption: [customer]}, () => { this.setState({ localCustomersOption: [customer] }, () => {
this.handleCallBack({ this.handleCallBack(
name: customer.customer_name, {
value: customer.customer_code, name: customer.customer_name,
}, listOptionData[2].title) value: customer.customer_code,
},
listOptionData[2].title,
)
}) })
}, },
}) })
...@@ -1261,7 +1266,7 @@ class SelfOrderPage extends Component { ...@@ -1261,7 +1266,7 @@ class SelfOrderPage extends Component {
that.customerGetBill() that.customerGetBill()
that.customerGetShip() that.customerGetShip()
that.getPayBankAccounts() that.getPayBankAccounts()
that.setDefaultByCustomer() // that.setDefaultByCustomer()
}, },
) )
} }
...@@ -1274,47 +1279,64 @@ class SelfOrderPage extends Component { ...@@ -1274,47 +1279,64 @@ class SelfOrderPage extends Component {
} }
} }
async setDefaultByCustomer(onlyInv = false) { /**
* @description 设置默认值
* @param {*}
* @return {*}
*/
async setDefaultByCustomer(defaultValue) {
const { listOptionData, localCustomersOption } = this.state const { listOptionData, localCustomersOption } = this.state
const { sysValueSets, global_domain_config, token } = this.props 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 (isBlank(defaultValue)) {
const customer = R.find(R.propEq('customer_code', listOptionData[2].value), localCustomersOption)
if (isBlank(customer)) return
if (!onlyInv) { const billSite = R.find(R.propEq('bill_to_site_code', listOptionData[3].value), customer.bill_to_sites || [])
const templateList = R.compose( if (isBlank(billSite)) return
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) const shipSite = R.find(
if (isNotBlank(template)) { R.allPass([
listOptionData[24].value = template.value R.propEq('ship_to_site_code', listOptionData[4].value),
listOptionData[24].name = template.name R.propSatisfies(isNotBlank, 'default')
} ]),
)(billSite.ship_to_sites || [])
if (isBlank(shipSite)) return
let params = { defaultValue = shipSite.default
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) 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
}
if (isNotBlank(orderTypes)) { let params = {
const orderType = R.find(R.propEq('value_code', defaultValue.order_type_code))(orderTypes) access_token: token,
if (isNotBlank(orderType)) { value_set_code: 'SUR_ORDER_TYPE',
listOptionData[7].value = defaultValue.order_type_code org_code: listOptionData[1].value,
listOptionData[7].name = orderType.value_name 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
} }
} }
...@@ -1322,7 +1344,7 @@ class SelfOrderPage extends Component { ...@@ -1322,7 +1344,7 @@ class SelfOrderPage extends Component {
return this.setState({ listOptionData }) return this.setState({ listOptionData })
} }
let params = { params = {
access_token: token, access_token: token,
org_code: listOptionData[1].value, org_code: listOptionData[1].value,
customer_code: listOptionData[2].value, customer_code: listOptionData[2].value,
...@@ -1477,9 +1499,14 @@ class SelfOrderPage extends Component { ...@@ -1477,9 +1499,14 @@ class SelfOrderPage extends Component {
if (shipSites.length === 1) { if (shipSites.length === 1) {
listOptionData[4].name = shipSites[0].ship_to_site_name listOptionData[4].name = shipSites[0].ship_to_site_name
listOptionData[4].value = shipSites[0].ship_to_site_code listOptionData[4].value = shipSites[0].ship_to_site_code
that.setState({ that.setState(
listOptionData, {
}) listOptionData,
},
() => {
that.setDefaultByCustomer(shipSites[0].default)
},
)
} }
} }
} }
......
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