Commit c736aa27 by 张立顺

fix: keep boutique list helper in main package

1 parent 80cd57dc
...@@ -13,7 +13,7 @@ import { openOrderPromptWithRestrictState } from '~/tabIndex/services/newOrderAb ...@@ -13,7 +13,7 @@ import { openOrderPromptWithRestrictState } from '~/tabIndex/services/newOrderAb
import { confirmOrderPrompt } from '~/tabIndex/services/orderPromptConfirm.service.js' import { confirmOrderPrompt } from '~/tabIndex/services/orderPromptConfirm.service.js'
import commonApi from '~/api/api' import commonApi from '~/api/api'
import { normalizeMarketingFlagOnItem } from '~/utils/marketingFlag' import { normalizeMarketingFlagOnItem } from '~/utils/marketingFlag'
import { buildBoutiqueCustomerDailyListDisplay } from '~/tabWorkOrder/pages/createOrder/services/customerDailyFields.helpers.js' import { buildBoutiqueCustomerDailyListDisplay } from '~/utils/boutiqueCustomerDailyDisplay.helpers.js'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
......
import { formatActualDeliveryDateForDisplay } from '../../../../utils/actualDeliveryDate.helpers.js' import { formatActualDeliveryDateForDisplay } from '../../../../utils/actualDeliveryDate.helpers.js'
import {
BOUTIQUE_CUSTOMER_TAGS,
buildBoutiqueCustomerDailyDisplay,
buildBoutiqueCustomerDailyListDisplay,
formatCustomerTags,
getCustomerTagLabels,
parseCustomerTags,
serializeCustomerTags
} from '../../../../utils/boutiqueCustomerDailyDisplay.helpers.js'
export {
BOUTIQUE_CUSTOMER_TAGS,
buildBoutiqueCustomerDailyDisplay,
buildBoutiqueCustomerDailyListDisplay,
formatCustomerTags,
getCustomerTagLabels,
parseCustomerTags,
serializeCustomerTags
}
export const BOUTIQUE_CUSTOMER_TAGS = [
{ value: '1', label: '已触客' },
{ value: '2', label: '已拉群' },
{ value: '3', label: '已交付引荐' },
{ value: '4', label: '首保维保客户' },
{ value: '5', label: '事故车客户' }
]
const CUSTOMER_TAG_ORDER = BOUTIQUE_CUSTOMER_TAGS.map(item => item.value)
const BOUTIQUE_DELIVERY_SCENE_FRAGMENTS = ['1.1', '1.2', '1.3'] const BOUTIQUE_DELIVERY_SCENE_FRAGMENTS = ['1.1', '1.2', '1.3']
const BOUTIQUE_DELIVERY_SCENE_CODES = new Set([ const BOUTIQUE_DELIVERY_SCENE_CODES = new Set([
'100101', '100101',
...@@ -36,37 +46,6 @@ const FIVE_BOUNDARY_BRAND_IDS = new Set([ ...@@ -36,37 +46,6 @@ const FIVE_BOUNDARY_BRAND_IDS = new Set([
'2740' '2740'
]) ])
function toTagValues(value) {
if (Array.isArray(value)) return value
if (value === undefined || value === null || value === '') return []
return String(value).split(',')
}
export function parseCustomerTags(value, allowedValues = CUSTOMER_TAG_ORDER) {
const allowed = new Set((allowedValues || []).map(String))
const selected = new Set(
toTagValues(value)
.map(item => String(item).trim())
.filter(item => allowed.has(item))
)
return CUSTOMER_TAG_ORDER.filter(item => selected.has(item))
}
export function serializeCustomerTags(value, allowedValues = CUSTOMER_TAG_ORDER) {
return parseCustomerTags(value, allowedValues).join(',')
}
export function formatCustomerTags(value) {
return getCustomerTagLabels(value).join('/')
}
export function getCustomerTagLabels(value) {
const selected = new Set(parseCustomerTags(value))
return BOUTIQUE_CUSTOMER_TAGS.filter(item => selected.has(item.value)).map(
item => item.label
)
}
function getBrandName(brand) { function getBrandName(brand) {
if (typeof brand === 'string') return brand if (typeof brand === 'string') return brand
return ( return (
...@@ -187,32 +166,6 @@ export function isBoutiqueActualDeliveryDateMissing(visible, value) { ...@@ -187,32 +166,6 @@ export function isBoutiqueActualDeliveryDateMissing(visible, value) {
return !!visible && !formatDeliveryDateForDisplay(value) return !!visible && !formatDeliveryDateForDisplay(value)
} }
export function buildBoutiqueCustomerDailyDisplay(customer = {}) {
const source = customer || {}
const customerTagLabels = getCustomerTagLabels(source.customerTags)
const actualDeliveryDate = formatDeliveryDateForDisplay(
source.actualDeliveryDate
)
return {
showCustomerTags: customerTagLabels.length > 0,
showActualDeliveryDate: !!actualDeliveryDate,
customerTagLabels,
customerTagsText: customerTagLabels.join('/'),
actualDeliveryDate
}
}
export function buildBoutiqueCustomerDailyListDisplay(orderItem = {}) {
const source = orderItem || {}
const nestedCustomer = source.customer || {}
return buildBoutiqueCustomerDailyDisplay({
...nestedCustomer,
customerTags: nestedCustomer.customerTags || source.customerTags || '',
actualDeliveryDate:
nestedCustomer.actualDeliveryDate || source.actualDeliveryDate || ''
})
}
export function resolveBoutiqueDetailCustomerPhone(detail = {}) { export function resolveBoutiqueDetailCustomerPhone(detail = {}) {
return detail?.customer?.customerPhone || '' return detail?.customer?.customerPhone || ''
} }
......
...@@ -187,6 +187,11 @@ describe('boutique customer daily field UI contract', () => { ...@@ -187,6 +187,11 @@ describe('boutique customer daily field UI contract', () => {
assert.match(mainListJs, /buildBoutiqueCustomerDailyListDisplay/) assert.match(mainListJs, /buildBoutiqueCustomerDailyListDisplay/)
assert.match( assert.match(
mainListJs, mainListJs,
/from '~\/utils\/boutiqueCustomerDailyDisplay\.helpers\.js'/
)
assert.doesNotMatch(mainListJs, /from '~\/tabWorkOrder\//)
assert.match(
mainListJs,
/e\.customerDailyDisplay\s*=\s*buildBoutiqueCustomerDailyListDisplay\(e\)/ /e\.customerDailyDisplay\s*=\s*buildBoutiqueCustomerDailyListDisplay\(e\)/
) )
assert.match(mainListWxml, /li\.customerDailyDisplay\.showCustomerTags/) assert.match(mainListWxml, /li\.customerDailyDisplay\.showCustomerTags/)
......
import { formatActualDeliveryDateForDisplay } from './actualDeliveryDate.helpers.js'
export const BOUTIQUE_CUSTOMER_TAGS = [
{ value: '1', label: '已触客' },
{ value: '2', label: '已拉群' },
{ value: '3', label: '已交付引荐' },
{ value: '4', label: '首保维保客户' },
{ value: '5', label: '事故车客户' }
]
const CUSTOMER_TAG_ORDER = BOUTIQUE_CUSTOMER_TAGS.map(item => item.value)
function toTagValues(value) {
if (Array.isArray(value)) return value
if (value === undefined || value === null || value === '') return []
return String(value).split(',')
}
export function parseCustomerTags(value, allowedValues = CUSTOMER_TAG_ORDER) {
const allowed = new Set((allowedValues || []).map(String))
const selected = new Set(
toTagValues(value)
.map(item => String(item).trim())
.filter(item => allowed.has(item))
)
return CUSTOMER_TAG_ORDER.filter(item => selected.has(item))
}
export function serializeCustomerTags(value, allowedValues = CUSTOMER_TAG_ORDER) {
return parseCustomerTags(value, allowedValues).join(',')
}
export function getCustomerTagLabels(value) {
const selected = new Set(parseCustomerTags(value))
return BOUTIQUE_CUSTOMER_TAGS.filter(item => selected.has(item.value)).map(
item => item.label
)
}
export function formatCustomerTags(value) {
return getCustomerTagLabels(value).join('/')
}
export function buildBoutiqueCustomerDailyDisplay(customer = {}) {
const source = customer || {}
const customerTagLabels = getCustomerTagLabels(source.customerTags)
const actualDeliveryDate = formatActualDeliveryDateForDisplay(
source.actualDeliveryDate
)
return {
showCustomerTags: customerTagLabels.length > 0,
showActualDeliveryDate: !!actualDeliveryDate,
customerTagLabels,
customerTagsText: customerTagLabels.join('/'),
actualDeliveryDate
}
}
export function buildBoutiqueCustomerDailyListDisplay(orderItem = {}) {
const source = orderItem || {}
const nestedCustomer = source.customer || {}
return buildBoutiqueCustomerDailyDisplay({
...nestedCustomer,
customerTags: nestedCustomer.customerTags || source.customerTags || '',
actualDeliveryDate:
nestedCustomer.actualDeliveryDate || source.actualDeliveryDate || ''
})
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!