Commit 9119cad9 by 前端

Merge branch 'SAAS+V5.8.7.5' into 'master'

上线合并

See merge request !34
2 parents d2410622 ee3383dc
...@@ -259,6 +259,7 @@ Page({ ...@@ -259,6 +259,7 @@ Page({
packageList: [], packageList: [],
baseConfigData: {}, baseConfigData: {},
showSource: false, showSource: false,
sourceDefaultIndex: 0,
Sourcecolumns: [ Sourcecolumns: [
{ {
type: SALES_TYPE.PRE_SALES, type: SALES_TYPE.PRE_SALES,
...@@ -3228,8 +3229,18 @@ Page({ ...@@ -3228,8 +3229,18 @@ Page({
// return latestDate.formattedDate(); // 或返回时间戳 latestTimestamp // return latestDate.formattedDate(); // 或返回时间戳 latestTimestamp
}, },
toSelectCustomerSource() { toSelectCustomerSource() {
const { Sourcecolumns = [], orderObj = {} } = this.data
const salesType = orderObj.customer?.salesType
const sourceDefaultIndex = Sourcecolumns.findIndex(
item => String(item.type) === String(salesType)
)
const selectedIndex = sourceDefaultIndex >= 0 ? sourceDefaultIndex : 0
this.setData({ this.setData({
showSource: true showSource: true,
sourceDefaultIndex: selectedIndex
}, () => {
const picker = this.selectComponent?.('#customerSourcePicker')
picker?.setColumnIndex?.(0, selectedIndex)?.catch?.(() => {})
}) })
}, },
onChangeSource(e) { onChangeSource(e) {
......
...@@ -124,8 +124,11 @@ value="{{ orderObj.remark }}" ...@@ -124,8 +124,11 @@ value="{{ orderObj.remark }}"
<gl-cell <gl-cell
border border
label="客户来源" label="客户来源"
value="{{ filter.getSalesTypeName(Sourcecolumns, orderObj.customer.salesType) }}"
valueAlign="right" valueAlign="right"
value="{{ filter.getSalesTypeName(Sourcecolumns, orderObj.customer.salesType) }}"
haveArrow
placeholder="点击选择"
bindclick="toSelectCustomerSource"
/> />
<gl-cell border label="性别" value="{{ orderObj.customer.customerSex == 1 ? '男' : (orderObj.customer.customerSex == 2 ? '女' : '') }}" valueAlign="right" labelWidth="var(--fontSize140)" /> <gl-cell border label="性别" value="{{ orderObj.customer.customerSex == 1 ? '男' : (orderObj.customer.customerSex == 2 ? '女' : '') }}" valueAlign="right" labelWidth="var(--fontSize140)" />
<gl-cell border valueAlign="right" label="手机号" required="{{ filter.isIncludesItem(requiredList ,'customerPhone') }}" value="{{ orderObj.customer.customerPhone }}" labelWidth="var(--fontSize140)" /> <gl-cell border valueAlign="right" label="手机号" required="{{ filter.isIncludesItem(requiredList ,'customerPhone') }}" value="{{ orderObj.customer.customerPhone }}" labelWidth="var(--fontSize140)" />
...@@ -816,11 +819,13 @@ value="{{ orderObj.remark }}" ...@@ -816,11 +819,13 @@ value="{{ orderObj.remark }}"
/> />
<van-popup show="{{ showSource }}" position="bottom" bind:close="onCloseSource"> <van-popup show="{{ showSource }}" position="bottom" bind:close="onCloseSource">
<van-picker <van-picker
id="customerSourcePicker"
show-toolbar show-toolbar
title="客户来源" title="客户来源"
bind:cancel="onCloseSource" bind:cancel="onCloseSource"
columns="{{ Sourcecolumns }}" columns="{{ Sourcecolumns }}"
value-key="name" value-key="name"
default-index="{{ sourceDefaultIndex }}"
bind:confirm="onChangeSource" bind:confirm="onChangeSource"
/> />
</van-popup> </van-popup>
......
...@@ -34,6 +34,7 @@ function createPage(pageConfig, lowPriceFlag) { ...@@ -34,6 +34,7 @@ function createPage(pageConfig, lowPriceFlag) {
const currentGoods = [{ goodsCode: 'CURRENT' }] const currentGoods = [{ goodsCode: 'CURRENT' }]
let profileEchoCustomerId let profileEchoCustomerId
let routeCount = 0 let routeCount = 0
const sourcePickerCalls = []
const page = { const page = {
_isLowPriceCreateOrder: Number(lowPriceFlag) === 1, _isLowPriceCreateOrder: Number(lowPriceFlag) === 1,
isLowPriceOrder: pageConfig.isLowPriceOrder, isLowPriceOrder: pageConfig.isLowPriceOrder,
...@@ -66,6 +67,15 @@ function createPage(pageConfig, lowPriceFlag) { ...@@ -66,6 +67,15 @@ function createPage(pageConfig, lowPriceFlag) {
Object.assign(this.data, patch) Object.assign(this.data, patch)
callback?.() callback?.()
}, },
selectComponent(selector) {
if (selector !== '#customerSourcePicker') return null
return {
setColumnIndex(columnIndex, optionIndex) {
sourcePickerCalls.push([columnIndex, optionIndex])
return Promise.resolve()
}
}
},
async echoCustomerProfileIfNeeded(detail) { async echoCustomerProfileIfNeeded(detail) {
profileEchoCustomerId = detail?.customer?.customerId profileEchoCustomerId = detail?.customer?.customerId
}, },
...@@ -80,7 +90,8 @@ function createPage(pageConfig, lowPriceFlag) { ...@@ -80,7 +90,8 @@ function createPage(pageConfig, lowPriceFlag) {
currentGoods, currentGoods,
page, page,
getProfileEchoCustomerId: () => profileEchoCustomerId, getProfileEchoCustomerId: () => profileEchoCustomerId,
getRouteCount: () => routeCount getRouteCount: () => routeCount,
getSourcePickerCalls: () => sourcePickerCalls
} }
} }
...@@ -113,16 +124,24 @@ describe('createOrder customer profile import', () => { ...@@ -113,16 +124,24 @@ describe('createOrder customer profile import', () => {
it('low-price profile selection keeps current goods and payment fields', async () => { it('low-price profile selection keeps current goods and payment fields', async () => {
const pageConfig = await loadPageConfig() const pageConfig = await loadPageConfig()
const context = createPage(pageConfig, 1) const context = createPage(pageConfig, 1)
const selectedProfile = structuredClone(selectedRecord)
selectedProfile.customer.salesType = context.page.data.Sourcecolumns[2].type
await pageConfig.chooseCustomerInfo.call(context.page, { await pageConfig.chooseCustomerInfo.call(context.page, {
detail: structuredClone(selectedRecord) detail: selectedProfile
}) })
assert.equal(context.page.data.orderObj.customer.customerId, 2) assert.equal(context.page.data.orderObj.customer.customerId, 2)
assert.equal(context.page.data.orderObj.customer.customerName, '新客户') assert.equal(context.page.data.orderObj.customer.customerName, '新客户')
assert.equal(context.page.data.orderObj.customer.customerSex, 1) assert.equal(context.page.data.orderObj.customer.customerSex, 1)
assert.equal(context.page.data.orderObj.customer.experienceFlag, 'N') assert.equal(context.page.data.orderObj.customer.experienceFlag, 'N')
assert.equal(context.page.data.orderObj.customer.salesType, 0) assert.equal(
context.page.data.orderObj.customer.salesType,
selectedProfile.customer.salesType
)
pageConfig.toSelectCustomerSource.call(context.page)
assert.equal(context.page.data.sourceDefaultIndex, 2)
assert.deepEqual(context.getSourcePickerCalls(), [[0, 2]])
assert.equal(context.page.data.orderObj.remark, '新客户备注') assert.equal(context.page.data.orderObj.remark, '新客户备注')
assert.equal(context.page.data.currentWordNumber, 5) assert.equal(context.page.data.currentWordNumber, 5)
assert.equal(context.page.data.orderObj.orderCode, 'ARCHIVE-ORDER-001') assert.equal(context.page.data.orderObj.orderCode, 'ARCHIVE-ORDER-001')
......
...@@ -34,6 +34,11 @@ describe('createOrder customer information template', () => { ...@@ -34,6 +34,11 @@ describe('createOrder customer information template', () => {
assert.doesNotMatch(customerSection, /请通过客户档案选择/) assert.doesNotMatch(customerSection, /请通过客户档案选择/)
assert.match(customerSection, /label="客户来源"/) assert.match(customerSection, /label="客户来源"/)
assert.match(customerSection, /value="\{\{ filter\.getSalesTypeName\(Sourcecolumns, orderObj\.customer\.salesType\) \}\}"/) assert.match(customerSection, /value="\{\{ filter\.getSalesTypeName\(Sourcecolumns, orderObj\.customer\.salesType\) \}\}"/)
assert.match(
customerSection,
/label="客户来源"[\s\S]*bindclick="toSelectCustomerSource"/
)
assert.match(template, /default-index="\{\{ sourceDefaultIndex \}\}"/)
assert.match(customerSection, /label="性别"/) assert.match(customerSection, /label="性别"/)
assert.match(customerSection, /orderObj\.customer\.customerSex == 1 \? '男' : \(orderObj\.customer\.customerSex == 2 \? '女' : ''\)/) assert.match(customerSection, /orderObj\.customer\.customerSex == 1 \? '男' : \(orderObj\.customer\.customerSex == 2 \? '女' : ''\)/)
assert.match(customerSection, /label="手机号"/) assert.match(customerSection, /label="手机号"/)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!