Commit 702a633e by 李伟康

重构(精品店订单创建组件): 提取销售类型处理逻辑为复用方法

将原watch监听器的内联业务逻辑抽离为独立方法,在updateSceneGate中新增调用以复用逻辑,同时修复部分代码格式问题
1 parent f7f9a6ad
...@@ -174,24 +174,7 @@ export default { ...@@ -174,24 +174,7 @@ export default {
}, },
'orderObj.salesType': { 'orderObj.salesType': {
handler(newVal) { handler(newVal) {
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode)) this.customerTagsAndActualDeliveryDateHidden()
let formList = this.formList
let { isHarmony } = this
formList.map(item => {
item.map(child => {
if (child.value == 'customerTags') {
let hidden = !selected || newVal == 2
child.hidden = hidden
if (hidden) this.$set(this.orderObj, 'customerTags', [])
}
if (child.value == 'actualDeliveryDate') {
let hidden = (isHarmony ? ![3].includes(+newVal) : ![0, 3].includes(+newVal)) || !selected
child.hidden = hidden
if (hidden) this.$set(this.orderObj, 'actualDeliveryDate', '')
}
})
})
this.formList = formList
}, },
immediate: true, immediate: true,
deep: true deep: true
...@@ -304,6 +287,28 @@ export default { ...@@ -304,6 +287,28 @@ export default {
this.initData() this.initData()
}, },
methods: { methods: {
customerTagsAndActualDeliveryDateHidden() {
let { salesType } = this.orderObj,
{ isHarmony } = this
console.log(salesType)
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
let formList = this.formList
formList.map(item => {
item.map(child => {
if (child.value == 'customerTags') {
let hidden = !selected || salesType == 2
child.hidden = hidden
if (hidden) this.$set(this.orderObj, 'customerTags', [])
}
if (child.value == 'actualDeliveryDate') {
let hidden = (isHarmony ? ![3].includes(+salesType) : ![0, 3].includes(+salesType)) || !selected
child.hidden = hidden
if (hidden) this.$set(this.orderObj, 'actualDeliveryDate', '')
}
})
})
this.formList = formList
},
updateSceneGate() { updateSceneGate() {
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode)) const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
const list = this.formList || [] const list = this.formList || []
...@@ -322,6 +327,9 @@ export default { ...@@ -322,6 +327,9 @@ export default {
}) })
}) })
this.formList = list this.formList = list
this.$nextTick(() => {
this.customerTagsAndActualDeliveryDateHidden()
})
return selected return selected
}, },
async initRecentSceneEcho() { async initRecentSceneEcho() {
...@@ -1981,11 +1989,11 @@ export default { ...@@ -1981,11 +1989,11 @@ export default {
this.orderObj.orderTypeCode = '1' this.orderObj.orderTypeCode = '1'
this.orderObj.djOrderType = orderTypeMap['1'] || '正常订单' this.orderObj.djOrderType = orderTypeMap['1'] || '正常订单'
} }
let actualDeliveryDate = rest.actualDeliveryDate || customer.actualDeliveryDate, let actualDeliveryDate = rest.actualDeliveryDate || customer.actualDeliveryDate,
customerTags = rest.customerTags || customer.customerTags customerTags = rest.customerTags || customer.customerTags
if (actualDeliveryDate) this.orderObj.actualDeliveryDate = dayjs(actualDeliveryDate).format('YYYY-MM-DD') if (actualDeliveryDate) this.orderObj.actualDeliveryDate = dayjs(actualDeliveryDate).format('YYYY-MM-DD')
if (customerTags && typeof customerTags === 'string') this.orderObj.customerTags = customerTags.split(',') if (customerTags && typeof customerTags === 'string') this.orderObj.customerTags = customerTags.split(',')
this.orderObj.payeeType = rest.selectPayType == '2' ? '1' : '0' this.orderObj.payeeType = rest.selectPayType == '2' ? '1' : '0'
const customerFields = ['customerName', 'customerSex', 'customerPhone', 'salesType', 'standNo', 'plateNumber', 'experienceFlag'] const customerFields = ['customerName', 'customerSex', 'customerPhone', 'salesType', 'standNo', 'plateNumber', 'experienceFlag']
Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]]))) Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]])))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!