Commit 0c643e22 by peii

fix: 修复

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