Commit 2fbe173f by 张立顺

feat 客户接待功能

1 parent 41a0c12c
Showing 27 changed files with 1757 additions and 16 deletions
...@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd"; ...@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 3; let index = 1;
const accountInfo = wx.getAccountInfoSync(); const accountInfo = wx.getAccountInfoSync();
const systemInfo = wx.getSystemInfoSync(); const systemInfo = wx.getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion; const envName = accountInfo.miniProgram.envVersion;
......
...@@ -65,6 +65,24 @@ function dailyReportDiscussionStaffList(data) { ...@@ -65,6 +65,24 @@ function dailyReportDiscussionStaffList(data) {
) )
} }
/**
* 统计客户今日计划到店数
* @param {Object} data merchantId、advanceUserId、inviteDate(可空,默认当日)
* @returns {Promise} dj.api.smartcarlife.customer.todayPlanStore.count
*/
function customerTodayPlanStoreCount(data) {
return api.post('dj.api.smartcarlife.customer.todayPlanStore.count', data)
}
/**
* 查询客户今日计划到店列表
* @param {Object} data merchantId、advanceUserId、inviteDate
* @returns {Promise} dj.api.smartcarlife.customer.todayPlanStore.list
*/
function customerTodayPlanStoreList(data) {
return api.post('dj.api.smartcarlife.customer.todayPlanStore.list', data)
}
module.exports = { module.exports = {
dailyReportWeeklyList, dailyReportWeeklyList,
dynamicDailyReportSave, dynamicDailyReportSave,
...@@ -74,5 +92,7 @@ module.exports = { ...@@ -74,5 +92,7 @@ module.exports = {
getUserScene, getUserScene,
findSceneByMerchantIdAndSceneType, findSceneByMerchantIdAndSceneType,
staffDailyReportCarBrand, staffDailyReportCarBrand,
dailyReportDiscussionStaffList dailyReportDiscussionStaffList,
customerTodayPlanStoreCount,
customerTodayPlanStoreList
} }
...@@ -34,6 +34,12 @@ const { ...@@ -34,6 +34,12 @@ const {
fetchDiscussionStaffListAdapter, fetchDiscussionStaffListAdapter,
saveEchoAdapter saveEchoAdapter
} = require('./negotiationDailyReportAdapters.js') } = require('./negotiationDailyReportAdapters.js')
const {
fetchTodayPlanStoreCountAdapter,
fetchTodayPlanStoreListAdapter,
normalizeTodayPlanStoreCountResponse,
normalizeTodayPlanStoreListResponse
} = require('./negotiationTodayPlanStoreAdapters.js')
const { isNegotiationMockMode } = require('../config/apiSwitch.js') const { isNegotiationMockMode } = require('../config/apiSwitch.js')
const { fetchDailyReportCarBrandList: fetchCarBrandListImpl } = require('./dailyReportCarBrand.js') const { fetchDailyReportCarBrandList: fetchCarBrandListImpl } = require('./dailyReportCarBrand.js')
const { normalizeDailyReportUserInfo } = require('../utils/user-merchant.js') const { normalizeDailyReportUserInfo } = require('../utils/user-merchant.js')
...@@ -414,6 +420,54 @@ async function fetchWeeklyList({ ...@@ -414,6 +420,54 @@ async function fetchWeeklyList({
} }
/** /**
* 统计今日计划到店客户数(洽谈明细入口条)
* @param {Object} [options={}]
* @param {string|number} [options.merchantId] 4S 店商户号
* @param {string} [options.advanceUserId] 驻店零售员工 id(staffUuid)
* @param {string} [options.inviteDate] 邀约日期 YYYY-MM-DD,可空默认当日
* @returns {Promise<{code: number, message: string, data: number|null}>}
*/
async function fetchTodayPlanStoreCount({
merchantId,
advanceUserId,
inviteDate
} = {}) {
if (!merchantId || !advanceUserId) {
return { code: 0, message: 'ok', data: 0 }
}
const params = { merchantId, advanceUserId }
if (inviteDate) {
params.inviteDate = inviteDate
}
const result = await fetchTodayPlanStoreCountAdapter(params)
return normalizeTodayPlanStoreCountResponse(unwrapResponse(result))
}
/**
* 查询计划到店客户列表(洽谈明细弹层)
* @param {Object} [options={}]
* @param {string|number} [options.merchantId] 4S 店商户号
* @param {string} [options.advanceUserId] 驻店零售员工 id
* @param {string} [options.inviteDate] 邀约日期 YYYY-MM-DD
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchTodayPlanStoreList({
merchantId,
advanceUserId,
inviteDate
} = {}) {
if (!merchantId || !advanceUserId || !inviteDate) {
return { code: 0, message: 'ok', data: [] }
}
const result = await fetchTodayPlanStoreListAdapter({
merchantId,
advanceUserId,
inviteDate
})
return normalizeTodayPlanStoreListResponse(unwrapResponse(result))
}
/**
* 校验并提交洽谈明细(dynamic.save + 可选 mock 回显) * 校验并提交洽谈明细(dynamic.save + 可选 mock 回显)
* @param {Object} [payload={}] * @param {Object} [payload={}]
* @param {Object} payload.engine formEngine 实例 * @param {Object} payload.engine formEngine 实例
...@@ -487,6 +541,8 @@ module.exports = { ...@@ -487,6 +541,8 @@ module.exports = {
fetchDiscussionStaffList, fetchDiscussionStaffList,
fetchSchema, fetchSchema,
fetchWeeklyList, fetchWeeklyList,
fetchTodayPlanStoreCount,
fetchTodayPlanStoreList,
submitForm, submitForm,
buildPageContextFromSources, buildPageContextFromSources,
normalizeUserInfo normalizeUserInfo
......
/**
* 洽谈明细 — 今日计划到店客户 count/list adapter
* @file 仅 mock/real 切换与响应归一,不调 setData
*/
const { isNegotiationMockMode } = require('../config/apiSwitch.js')
var timeUtil = require('../../utils/timeFormat/time-utils.js')
function getDynamicDailyReportApi() {
return require('./dynamicDailyReport.js')
}
/** mock 客户模板(inviteDate 由 buildMockTodayPlanStoreList 注入) */
const MOCK_TODAY_PLAN_ITEMS = [
{
advanceUserId: 'uuid-staff-001',
advanceUserName: '李璐',
customerName: '姓名',
customerPhone: '157****2929',
carBrandId: 3454,
carBrand: '问界',
carChildsBrandId: 1,
carChildsBrandName: '问界',
carSeriesId: 101,
carSeriesName: 'M7 Plus'
},
{
advanceUserId: 'uuid-staff-001',
advanceUserName: '李璐',
customerName: '迪丽热巴',
customerPhone: '158****8888',
carBrandId: 2161,
carBrand: '奥迪',
carChildsBrandId: 2,
carChildsBrandName: '奥迪A4L',
carSeriesId: 102,
carSeriesName: '奥迪A4L'
},
{
advanceUserId: 'uuid-staff-001',
advanceUserName: '李璐',
customerName: '王先生',
customerPhone: '139****1234',
carBrandId: 3454,
carBrand: '问界',
carChildsBrandId: 1,
carChildsBrandName: '问界',
carSeriesId: 103,
carSeriesName: 'M9'
},
{
advanceUserId: 'uuid-staff-001',
advanceUserName: '李璐',
customerName: '赵女士',
customerPhone: '136****5678',
carBrandId: 3067,
carBrand: '岚图',
carChildsBrandId: 3,
carChildsBrandName: '岚图',
carSeriesId: 104,
carSeriesName: 'FREE'
},
{
advanceUserId: 'uuid-staff-001',
advanceUserName: '李璐',
customerName: '陈先生',
customerPhone: '188****9999',
carBrandId: 3454,
carBrand: '问界',
carChildsBrandId: 1,
carChildsBrandName: '问界',
carSeriesId: 105,
carSeriesName: 'M5'
}
]
/**
* 构建 mock 计划到店列表(仅当天有数据,模拟后端按 inviteDate 筛选)
* @param {string} [inviteDate] YYYY-MM-DD,空则按今天
* @returns {Array}
*/
function buildMockTodayPlanStoreList(inviteDate) {
const today = timeUtil.getTodayDateStr()
const targetDate = inviteDate || today
if (targetDate !== today) {
return []
}
return MOCK_TODAY_PLAN_ITEMS.map(item => ({
...item,
inviteDate: today
}))
}
/**
* 从 count 接口 data 提取整数
* @param {*} data
* @returns {number|undefined}
*/
function extractTodayPlanCount(data) {
if (data == null || data === '') {
return undefined
}
if (typeof data === 'number' && Number.isFinite(data)) {
return data
}
if (typeof data === 'string' && data.trim() !== '') {
const parsed = Number(data)
return Number.isFinite(parsed) ? parsed : undefined
}
if (typeof data === 'object') {
const raw = data.count ?? data.total ?? data.data
if (raw == null || raw === '') {
return undefined
}
const parsed = typeof raw === 'number' ? raw : Number(raw)
return Number.isFinite(parsed) ? parsed : undefined
}
return undefined
}
/**
* 归一 count 响应
* @param {Object} [result={}]
* @returns {{code: number, message: string, data: number|null}}
*/
function normalizeTodayPlanStoreCountResponse(result = {}) {
if (result.code != 0) {
return {
code: result.code ?? -1,
message: result.message || '请求失败',
data: null
}
}
const count = extractTodayPlanCount(result.data)
if (!Number.isFinite(count)) {
return { code: -1, message: '今日待接待客户数无效', data: null }
}
return { code: 0, message: 'ok', data: count }
}
/**
* 归一 list 响应
* @param {Object} [result={}]
* @returns {{code: number, message: string, data: Array}}
*/
function normalizeTodayPlanStoreListResponse(result = {}) {
if (result.code != 0) {
return {
code: result.code ?? -1,
message: result.message || '请求失败',
data: []
}
}
const list = Array.isArray(result.data)
? result.data
: Array.isArray(result.data?.list)
? result.data.list
: []
return { code: 0, message: 'ok', data: list }
}
/**
* 拉取今日计划到店数
* @param {Object} [params={}] merchantId、advanceUserId、inviteDate(可空)
* @returns {Promise<{code: number, message: string, data: number|Array}>} mock 时 data 为列表长度
*/
async function fetchTodayPlanStoreCountAdapter(params = {}) {
if (isNegotiationMockMode('todayPlanStore')) {
const list = buildMockTodayPlanStoreList(params.inviteDate)
return { code: 0, message: 'ok', data: list.length }
}
const { customerTodayPlanStoreCount } = getDynamicDailyReportApi()
return customerTodayPlanStoreCount(params)
}
/**
* 拉取计划到店客户列表
* @param {Object} [params={}] merchantId、advanceUserId、inviteDate
* @returns {Promise<{code: number, message: string, data: Array}>} mock 时仅 inviteDate 为当天返回数据
*/
async function fetchTodayPlanStoreListAdapter(params = {}) {
if (isNegotiationMockMode('todayPlanStore')) {
return {
code: 0,
message: 'ok',
data: buildMockTodayPlanStoreList(params.inviteDate)
}
}
const { customerTodayPlanStoreList } = getDynamicDailyReportApi()
return customerTodayPlanStoreList(params)
}
module.exports = {
buildMockTodayPlanStoreList,
fetchTodayPlanStoreCountAdapter,
fetchTodayPlanStoreListAdapter,
normalizeTodayPlanStoreCountResponse,
normalizeTodayPlanStoreListResponse,
extractTodayPlanCount
}
/**
* 洽谈明细 — 今日计划到店客户多选弹层
* @file 底部弹层:日期切换、多选列表、确认导入
*/
const negotiationApi = require('../../api/negotiationDailyReport.js')
const {
formatPlanStoreDateLabel,
shiftPlanStoreDate,
canShiftPlanStoreDate,
formatCustomerCarSeriesLabel,
maskCustomerPhone
} = require('../../services/today-plan-date.js')
var timeUtil = require('~/utils/timeFormat/time-utils.js')
const {
buildWeappIconUrl,
TODAY_PLAN_CHECK_ICON
} = require('../../utils/upgrade-icon-url.js')
Component({
properties: {
/** 父页控制显隐;true 时打开弹层并重置为今天 */
show: {
type: Boolean,
value: false,
observer(n) {
if (n) {
this.openPopup()
}
}
},
/** 4S 店商户号 */
merchantId: {
type: String,
value: ''
},
/** 驻店零售员工 id(staffUuid) */
advanceUserId: {
type: String,
value: ''
},
staffName: {
type: String,
value: ''
}
},
data: {
visible: false,
currentDate: '',
dateLabel: '',
canPrev: false,
canNext: false,
customerList: [],
selectedCount: 0,
isAllSelected: false,
loading: false,
loadComplete: false,
isFullSucreen: false,
checkIconUrl: ''
},
methods: {
noScroll() {},
/** 打开弹层并重置为今天 */
openPopup() {
const today = timeUtil.getTodayDateStr()
this.setData({
visible: true,
currentDate: today,
customerList: [],
selectedCount: 0,
isAllSelected: false,
loadComplete: false
})
this.syncDateNavState(today)
this.loadCustomerList(today)
},
/** 同步日期导航按钮与文案 */
syncDateNavState(dateStr) {
this.setData({
dateLabel: formatPlanStoreDateLabel(dateStr),
canPrev: canShiftPlanStoreDate(dateStr, -1),
canNext: canShiftPlanStoreDate(dateStr, 1)
})
},
/** 拉取当前日期客户列表 */
async loadCustomerList(inviteDate) {
const { merchantId, advanceUserId } = this.properties
if (!merchantId || !advanceUserId || !inviteDate) {
this.setData({ customerList: [], loadComplete: true, loading: false })
return
}
this.setData({ loading: true, loadComplete: false })
try {
const res = await negotiationApi.fetchTodayPlanStoreList({
merchantId,
advanceUserId,
inviteDate
})
const list = (res.code === 0 ? res.data : []) || []
const customerList = list.map((item, index) => ({
...item,
_rowKey: `${inviteDate}_${index}`,
selected: false,
carSeriesLabel: formatCustomerCarSeriesLabel(item),
phoneMasked: maskCustomerPhone(item.customerPhone)
}))
this.setData({
customerList,
selectedCount: 0,
isAllSelected: false,
loadComplete: true
})
} catch (error) {
console.error(error)
wx.$util?.showToast?.('加载客户列表失败')
this.setData({ customerList: [], loadComplete: true })
} finally {
this.setData({ loading: false })
}
},
onMaskTap() {
this.closePopup()
},
onCancel() {
this.closePopup()
},
/** 关闭弹层并通知父页 */
closePopup() {
this.setData({ visible: false })
this.triggerEvent('cancel')
},
onPrevDay() {
const next = shiftPlanStoreDate(this.data.currentDate, -1)
if (!next) return
this.changeDate(next)
},
onNextDay() {
const next = shiftPlanStoreDate(this.data.currentDate, 1)
if (!next) return
this.changeDate(next)
},
/** 切换日期:清空勾选并重新拉列表 */
changeDate(dateStr) {
this.setData({
currentDate: dateStr,
customerList: [],
selectedCount: 0,
isAllSelected: false
})
this.syncDateNavState(dateStr)
this.loadCustomerList(dateStr)
},
/** 切换单条客户勾选 */
onToggleItem(e) {
const index = e.currentTarget.dataset.index
const list = [...this.data.customerList]
if (!list[index]) return
list[index] = { ...list[index], selected: !list[index].selected }
this.updateSelectionState(list)
},
/** 全选 / 取消全选 */
onToggleAll() {
const { customerList, isAllSelected } = this.data
if (!customerList.length) return
const nextAll = !isAllSelected
const list = customerList.map(item => ({ ...item, selected: nextAll }))
this.updateSelectionState(list)
},
/** 同步 selectedCount、isAllSelected 到 data */
updateSelectionState(customerList) {
const selectedCount = customerList.filter(item => item.selected).length
const isAllSelected =
customerList.length > 0 && selectedCount === customerList.length
this.setData({ customerList, selectedCount, isAllSelected })
},
/**
* 确认导入:向父页派发 confirm,剥离 UI 衍生字段
* @fires confirm detail.customers 原始客户对象数组
*/
onConfirm() {
const selected = this.data.customerList.filter(item => item.selected)
if (!selected.length) return
const payload = selected.map(({ selected: _s, _rowKey, carSeriesLabel, phoneMasked, ...rest }) => rest)
this.setData({ visible: false })
this.triggerEvent('confirm', { customers: payload })
}
},
/** 生命周期:安全区与勾选 CDN 图标(根目录 check.png) */
attached() {
this.setData({
isFullSucreen: wx.$util?.isFullSucreen?.(true) || false,
checkIconUrl: buildWeappIconUrl(TODAY_PLAN_CHECK_ICON)
})
}
})
<root-portal enable="{{ visible }}">
<view class="plan-popup" hidden="{{ !visible }}" catchtouchmove="noScroll">
<view class="plan-popup__mask" bindtap="onMaskTap"></view>
<view class="plan-popup__panel" style="height: 85%">
<view class="plan-popup__header">
<view class="plan-popup__header-btn plan-popup__header-btn--left" bindtap="onCancel">取消</view>
<view class="plan-popup__header-title text-hide">{{ staffName }}的待接待客户</view>
<view class="plan-popup__header-btn plan-popup__header-btn--right" bindtap="onToggleAll">全选</view>
</view>
<view class="plan-popup__date">
<view
class="plan-popup__date-arrow {{ canPrev ? '' : 'is-disabled' }}"
bindtap="onPrevDay"
>
<text class="plan-popup__date-arrow-icon">‹</text>
</view>
<view class="plan-popup__date-label">{{ dateLabel }}</view>
<view
class="plan-popup__date-arrow {{ canNext ? '' : 'is-disabled' }}"
bindtap="onNextDay"
>
<text class="plan-popup__date-arrow-icon">›</text>
</view>
</view>
<scroll-view scroll-y class="plan-popup__list" enhanced show-scrollbar="{{ false }}">
<view wx:if="{{ loading }}" class="plan-popup__empty">加载中...</view>
<block wx:elif="{{ loadComplete && customerList.length }}">
<view
class="plan-popup__card {{ item.selected ? 'is-selected' : '' }}"
wx:for="{{ customerList }}"
wx:key="_rowKey"
data-index="{{ index }}"
bindtap="onToggleItem"
>
<view class="plan-popup__card-main">
<view class="plan-popup__card-name text-hide">
{{ item.customerName }} {{ item.phoneMasked }}
</view>
<view class="plan-popup__card-series text-hide">{{ item.carSeriesLabel }}</view>
</view>
<view class="plan-popup__checkbox {{ item.selected ? 'is-checked' : '' }}">
<image
wx:if="{{ item.selected }}"
class="plan-popup__checkbox-icon"
src="{{ checkIconUrl }}"
mode="aspectFit"
/>
</view>
</view>
</block>
<view wx:elif="{{ loadComplete }}" class="plan-popup__empty">暂无待接待客户</view>
</scroll-view>
<view class="plan-popup__footer {{ isFullSucreen ? 'is-full' : '' }}">
<view class="plan-popup__summary">
共选 <text class="plan-popup__summary-num">{{ selectedCount }}</text> 位
</view>
<view class="plan-popup__actions">
<view class="plan-popup__btn plan-popup__btn--cancel" bindtap="onCancel">取消</view>
<view
class="plan-popup__btn plan-popup__btn--confirm {{ selectedCount > 0 ? '' : 'is-disabled' }}"
bindtap="onConfirm"
>
添加到洽谈明细
</view>
</view>
</view>
</view>
</view>
</root-portal>
.plan-popup {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 99999;
}
.plan-popup__mask {
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0.7);
}
.plan-popup__panel {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
display: flex;
flex-direction: column;
background: #fff;
border-radius: 20rpx 20rpx 0 0;
box-sizing: border-box;
overflow: hidden;
}
.plan-popup__header {
flex-shrink: 0;
display: flex;
align-items: center;
height: 98rpx;
padding: 0 24rpx;
border-bottom: 2rpx solid #ebedf0;
}
.plan-popup__header-btn {
flex-shrink: 0;
font-size: 28rpx;
color: #2c66f7;
padding: 8rpx 8rpx;
}
.plan-popup__header-btn--left {
margin-right: 16rpx;
}
.plan-popup__header-btn--right {
margin-left: 16rpx;
}
.plan-popup__header-title {
flex: 1;
min-width: 0;
text-align: center;
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.plan-popup__date {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
height: 88rpx;
padding: 0 32rpx;
}
.plan-popup__date-arrow {
width: 64rpx;
height: 64rpx;
display: flex;
align-items: center;
justify-content: center;
color: #37393d;
}
.plan-popup__date-arrow.is-disabled {
opacity: 0.3;
}
.plan-popup__date-arrow-icon {
font-size: 40rpx;
line-height: 1;
}
.plan-popup__date-label {
flex: 1;
text-align: center;
font-size: 30rpx;
font-weight: 700;
color: #37393d;
}
.plan-popup__list {
flex: 1;
min-height: 0;
padding: 16rpx 24rpx;
box-sizing: border-box;
}
.plan-popup__card {
display: flex;
align-items: center;
padding: 24rpx;
margin-bottom: 16rpx;
background: #f5f6f7;
border-radius: 16rpx;
border: 2rpx solid transparent;
box-sizing: border-box;
}
.plan-popup__card.is-selected {
background: #eef3ff;
border-color: #347bff;
}
.plan-popup__card-main {
flex: 1;
min-width: 0;
margin-right: 16rpx;
}
.plan-popup__card-name {
font-size: 28rpx;
font-weight: 500;
color: #e67e22;
line-height: 40rpx;
}
.plan-popup__card-series {
margin-top: 8rpx;
font-size: 24rpx;
color: #8a8f99;
line-height: 34rpx;
}
.plan-popup__checkbox {
flex-shrink: 0;
width: 40rpx;
height: 40rpx;
border-radius: 8rpx;
border: 2rpx solid #c8cdd4;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.plan-popup__checkbox.is-checked {
border: none;
background: transparent;
}
.plan-popup__checkbox-icon {
width: 40rpx;
height: 40rpx;
}
.plan-popup__empty {
padding: 80rpx 0;
text-align: center;
font-size: 28rpx;
color: #8a8f99;
}
.plan-popup__footer {
flex-shrink: 0;
padding: 16rpx 24rpx;
padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
border-top: 2rpx solid #ebedf0;
}
.plan-popup__footer.is-full {
padding-bottom: calc(16rpx + 34px);
}
.plan-popup__summary {
text-align: center;
font-size: 26rpx;
color: #666;
margin-bottom: 16rpx;
}
.plan-popup__summary-num {
color: #2c66f7;
font-weight: 600;
}
.plan-popup__actions {
display: flex;
gap: 24rpx;
}
.plan-popup__btn {
flex: 1;
height: 88rpx;
line-height: 88rpx;
text-align: center;
border-radius: 44rpx;
font-size: 30rpx;
}
.plan-popup__btn--cancel {
background: #f2f3f5;
color: #333;
}
.plan-popup__btn--confirm {
background: #2c66f7;
color: #fff;
}
.plan-popup__btn--confirm.is-disabled {
opacity: 0.45;
}
...@@ -43,7 +43,8 @@ const NEGOTIATION_DAILY_API_SWITCH = { ...@@ -43,7 +43,8 @@ const NEGOTIATION_DAILY_API_SWITCH = {
brand: 'real', brand: 'real',
weekly: 'real', weekly: 'real',
fieldOptions: 'real', fieldOptions: 'real',
discussionStaffList: 'real' discussionStaffList: 'real',
todayPlanStore: 'real'
} }
/** 表单四级车型 L3/L4(getCarSeriesList / getCarTypeList),与 Loader brand 初始化分离 */ /** 表单四级车型 L3/L4(getCarSeriesList / getCarTypeList),与 Loader brand 初始化分离 */
...@@ -85,7 +86,7 @@ function isStoreSaveEchoEnabled() { ...@@ -85,7 +86,7 @@ function isStoreSaveEchoEnabled() {
/** /**
* 判断洽谈明细指定接口是否走 mock * 判断洽谈明细指定接口是否走 mock
* @param {string} key detail | schema | save | scene | brand | weekly | fieldOptions | discussionStaffList * @param {string} key detail | schema | save | scene | brand | weekly | fieldOptions | discussionStaffList | todayPlanStore
* @returns {boolean} * @returns {boolean}
*/ */
function isNegotiationMockMode(key) { function isNegotiationMockMode(key) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
| Loader | `services/*FormLoader.js` | 并行 bootstrap(brand/scene/detail)→ pageContext → schema | | Loader | `services/*FormLoader.js` | 并行 bootstrap(brand/scene/detail)→ pageContext → schema |
| API 门面 | `api/*DailyReport.js` | 页面/Loader 调用的稳定方法;组装 pageContext、save payload | | API 门面 | `api/*DailyReport.js` | 页面/Loader 调用的稳定方法;组装 pageContext、save payload |
| Adapter | `api/*DailyReportAdapters.js` | mock/real 分支;`sceneCache` / `schemaCache` / `brandCache` | | Adapter | `api/*DailyReportAdapters.js` | mock/real 分支;`sceneCache` / `schemaCache` / `brandCache` |
| Adapter | `api/negotiationTodayPlanStoreAdapters.js` | 洽谈今日计划到店 count/list(`todayPlanStore` 开关) |
| Engine | `form-engine/` | 显隐、values、校验、normalized save payload | | Engine | `form-engine/` | 显隐、values、校验、normalized save payload |
| Field UI | `components/form-field-*` | 按 schema `type` 渲染;`optionsKey` → `fieldOptionsService` | | Field UI | `components/form-field-*` | 按 schema `type` 渲染;`optionsKey` → `fieldOptionsService` |
| Config | `config/apiSwitch.js` `configCenter.js` | 联调开关、配置中心 schema 拉取与 indexed → list 转换 | | Config | `config/apiSwitch.js` `configCenter.js` | 联调开关、配置中心 schema 拉取与 indexed → list 转换 |
...@@ -66,6 +67,26 @@ sequenceDiagram ...@@ -66,6 +67,26 @@ sequenceDiagram
详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md)。 详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md)。
## 洽谈今日计划客户导入
```mermaid
sequenceDiagram
participant Page as negotiationDetail
participant Popup as todayPlanCustomerPopup
participant API as negotiationDailyReport
participant Import as negotiationCustomerImport
participant Engine as formEngine
Page->>API: fetchTodayPlanStoreCount
Page->>Popup: show merchantId advanceUserId
Popup->>API: fetchTodayPlanStoreList inviteDate
Popup->>Page: confirm customers
Page->>Import: applyCustomersToEngine
Import->>Engine: appendGroupRows per visible F3
```
业务规则与 UI 见 [PAGES.md](./PAGES.md) 洽谈节「今日计划到店客户」。
## 真接口约定(摘要) ## 真接口约定(摘要)
| 能力 | 形态 | 入口 | | 能力 | 形态 | 入口 |
......
# DEVLOG — packageDynamicForm # DEVLOG — packageDynamicForm
## 2026-06-24 — 洽谈明细今日计划到店客户
- **能力**:当天入口条展示待接待客户数;「查看客户」打开多选弹层;批量导入到可见 F3 subform(`applyCustomersToEngine` + `engine.appendGroupRows`)
- **接口**:`dj.api.smartcarlife.customer.todayPlanStore.count` / `.list`;`NEGOTIATION_DAILY_API_SWITCH.todayPlanStore: real`
- **UI**:入口条 CDN 切图(`class.png`、`arrow_right.png`);弹层勾选 `check.png`(CDN 根目录);入口条随 `scroll-view` 滚动;导入成功无 toast
- **单测**:`today-plan-date.test.mjs`、`negotiationTodayPlanStoreAdapters.test.mjs`、`negotiationCustomerImport.test.mjs`、`upgrade-icon-url.test.mjs`(`IT-PLAN-*`)
- **文档**:PAGES.md 洽谈节「今日计划到店客户」、SESSION-HANDOFF `todayPlanStore`
## 2026-06-15 — 新驻店页严格 7 天(移除工资申诉) ## 2026-06-15 — 新驻店页严格 7 天(移除工资申诉)
- **问题**:从旧 `staffDaily` 照搬的 `salaryapplyFillCheck` / `editableDay` 使 `isDateWithin7Days` 在申诉命中后超过 7 天仍显示提交/编辑按钮;本会话叠加的 `staffDailyReportPageMethods`、申诉拆分与单测偏离范围 - **问题**:从旧 `staffDaily` 照搬的 `salaryapplyFillCheck` / `editableDay` 使 `isDateWithin7Days` 在申诉命中后超过 7 天仍显示提交/编辑按钮;本会话叠加的 `staffDailyReportPageMethods`、申诉拆分与单测偏离范围
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
| 门店 schema / 配置中心模版(F2、completeFun、divider) | [store-template-features.md](./store-template-features.md) + `fixtures/schema-store-daily-full.js` +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 门店节 | | 门店 schema / 配置中心模版(F2、completeFun、divider) | [store-template-features.md](./store-template-features.md) + `fixtures/schema-store-daily-full.js` +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 门店节 |
| 驻店 schema / 配置中心模版(F1、出勤 gate、group) | [staff-template-features.md](./staff-template-features.md) + `fixtures/schema-staff-daily-full.js` +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 驻店节 | | 驻店 schema / 配置中心模版(F1、出勤 gate、group) | [staff-template-features.md](./staff-template-features.md) + `fixtures/schema-staff-daily-full.js` +(若新增/改动 `numberInput`)跑 [patch 脚本](#schema-fixture-维护mock) + PAGES.md 驻店节 |
| apiSwitch 默认或联调策略 | [SESSION-HANDOFF.md](./SESSION-HANDOFF.md)(apiSwitch 速查)+ DEVLOG.md | | apiSwitch 默认或联调策略 | [SESSION-HANDOFF.md](./SESSION-HANDOFF.md)(apiSwitch 速查)+ DEVLOG.md |
| 今日计划客户 / 洽谈导入 / todayPlanStore | PAGES.md 洽谈节 + SESSION-HANDOFF + DEVLOG + integration-test-plan |
| 新单测或 TEST-ID | [integration-test-plan.md](./integration-test-plan.md) + PAGES.md「相关单测」 | | 新单测或 TEST-ID | [integration-test-plan.md](./integration-test-plan.md) + PAGES.md「相关单测」 |
| 任意可交付能力 | [DEVLOG.md](./DEVLOG.md) 追加条目(日期 + 要点) | | 任意可交付能力 | [DEVLOG.md](./DEVLOG.md) 追加条目(日期 + 要点) |
......
...@@ -173,6 +173,20 @@ ...@@ -173,6 +173,20 @@
**新建日** `filterBrandId`(三页共用):`filterBrandId` 为已有专属区块的品牌 ID 列表;门店 `brandIds` 中**至少有一个不在该列表**(如除岚图外还有宝马)时展示「其他品牌」类区块(洽谈 F3-3、门店 F2-11/F2-14、驻店 F1-11 等);经营品牌**全部**落在列表内时隐藏。 **新建日** `filterBrandId`(三页共用):`filterBrandId` 为已有专属区块的品牌 ID 列表;门店 `brandIds` 中**至少有一个不在该列表**(如除岚图外还有宝马)时展示「其他品牌」类区块(洽谈 F3-3、门店 F2-11/F2-14、驻店 F1-11 等);经营品牌**全部**落在列表内时隐藏。
### 今日计划到店客户(入口条 + 弹层导入)
- **展示条件**:周历选中当天(`isTodayReport`)且表单加载成功;入口条在 `scroll-view` 内随表单滚动
- **入口条**:展示 `todayPlanStore.count`;只读态(`formDisabled`)隐藏「查看客户」按钮
- **弹层**:组件 [`today-plan-customer-popup`](../components/today-plan-customer-popup/);日期 ±7 天切换;多选后「添加到洽谈明细」
- **导入规则**([`negotiationCustomerImport.js`](../services/negotiationCustomerImport.js)):
- 仅写入**当前可见** F3 subform(F3-1~F3-4)
- 全有或全无;任一可见 subform 超 20 行 → `wx.showModal`「添加失败」
- 允许 partial carInfo(三级车系);导入成功**无 toast**
- **接口**:`dj.api.smartcarlife.customer.todayPlanStore.count` / `.list`;参数 `merchantId`、`advanceUserId`(= `staffUuid`)、`inviteDate`
- **apiSwitch**:`NEGOTIATION_DAILY_API_SWITCH.todayPlanStore`(当前 `real`)
- **CDN 资源**:`packageDynamicForm/class.png`、`arrow_right.png`(入口条);`check.png`(CDN 根目录,弹层勾选)
- **相关单测**:`IT-PLAN-DATE-*`、`IT-PLAN-ADAPTER-*`、`IT-PLAN-IMPORT-*`、`upgrade-icon-url.test.mjs`
### 页面状态 ### 页面状态
| 状态 | TEST-ID | | 状态 | TEST-ID |
...@@ -185,7 +199,7 @@ ...@@ -185,7 +199,7 @@
- **提交**:`dynamic.save`(保持与门店相同接口;payload 以 **App jsonContent** 为主) - **提交**:`dynamic.save`(保持与门店相同接口;payload 以 **App jsonContent** 为主)
- **jsonContent 形态**:subform 入库 **`childrenValue` + `origin_children`**;远程 select 行内 `{ text, value }`;与 gl_tape 互显。详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md) - **jsonContent 形态**:subform 入库 **`childrenValue` + `origin_children`**;远程 select 行内 `{ text, value }`;与 gl_tape 互显。详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md)
- **apiSwitch**:三页 `detail`/`schema`/`fieldOptions`/`weekly`/`scene`/`brand`/`save` 默认 `real`;洽谈另 `discussionStaffList: real`;门店另 `monthlyPendingCount: real`;`saveEcho: off` - **apiSwitch**:三页 `detail`/`schema`/`fieldOptions`/`weekly`/`scene`/`brand`/`save` 默认 `real`;洽谈另 `discussionStaffList: real`、`todayPlanStore: real`;门店另 `monthlyPendingCount: real`;`saveEcho: off`
### 字段选项 ### 字段选项
...@@ -200,6 +214,10 @@ ...@@ -200,6 +214,10 @@
- `IT-DISC-STAFF-*` / `IT-SUMMARY-*` — 汇总员工列表与 jsonContent 表格转换 - `IT-DISC-STAFF-*` / `IT-SUMMARY-*` — 汇总员工列表与 jsonContent 表格转换
- `IT-NEG-DETAIL-GET-001` — detail.get templateType=3 - `IT-NEG-DETAIL-GET-001` — detail.get templateType=3
- `IT-NEG-BRAND-CACHE-001` - `IT-NEG-BRAND-CACHE-001`
- `IT-PLAN-DATE-001` ~ `IT-PLAN-DATE-005` — 弹层日期文案、±7 边界、手机号脱敏(`today-plan-date.test.mjs`)
- `IT-PLAN-ADAPTER-001` ~ `IT-PLAN-ADAPTER-004` — todayPlanStore mock/real 归一(`negotiationTodayPlanStoreAdapters.test.mjs`)
- `IT-PLAN-IMPORT-001` ~ `IT-PLAN-IMPORT-003` — F3 字段映射、20 行上限、engine 写入(`negotiationCustomerImport.test.mjs`)
- `upgrade-icon-url.test.mjs` — CDN 图标 URL 拼接
- `dailyReportWeeklyList.test.mjs` — weekly templateType=3 - `dailyReportWeeklyList.test.mjs` — weekly templateType=3
--- ---
...@@ -228,8 +246,8 @@ ...@@ -228,8 +246,8 @@
| storeDailyReport | 当天已提交 | 当天且已提交 | 只读 + 洽谈汇总(**无编辑**) | IT-STORE-PAGE-009 | | storeDailyReport | 当天已提交 | 当天且已提交 | 只读 + 洽谈汇总(**无编辑**) | IT-STORE-PAGE-009 |
| storeDailyReport | 非当天只读 | 选中非当天 | 只读;无底部按钮(含洽谈汇总) | IT-STORE-PAGE-005 | | storeDailyReport | 非当天只读 | 选中非当天 | 只读;无底部按钮(含洽谈汇总) | IT-STORE-PAGE-005 |
| storeDailyReport | 加载失败 / 场景为空 | 同驻店 | 空态 +「重新加载」 | IT-STORE-PAGE-008 / IT-STORE-LOADER-003 | | storeDailyReport | 加载失败 / 场景为空 | 同驻店 | 空态 +「重新加载」 | IT-STORE-PAGE-008 / IT-STORE-LOADER-003 |
| negotiationDetail | 当天未提交 | 周历选中当天 | 可编辑 + F3 subform + 底部「提交」 | IT-PAGE-001 | | negotiationDetail | 当天未提交 | 周历选中当天 | 可编辑 + F3 subform + 入口条「查看客户」+ 底部「提交」 | IT-PAGE-001 |
| negotiationDetail | 当天已提交 | 当天且已提交 | 只读 +「编辑」;编辑态「保存」「取消」 | IT-PAGE-001 | | negotiationDetail | 当天已提交 | 当天且已提交 | 只读 + 入口条(无「查看客户」)+「编辑」;编辑态「保存」「取消」 | IT-PAGE-001 |
| negotiationDetail | 非当天只读 | 周历选中非当天 | 只读变灰 + 无底部按钮 | IT-PAGE-001 | | negotiationDetail | 非当天只读 | 周历选中非当天 | 只读变灰 + 无底部按钮 | IT-PAGE-001 |
| negotiationDetail | 场景为空 | scene 空 | 「暂无数据」+「重新加载」 | IT-LOADER-003 | | negotiationDetail | 场景为空 | scene 空 | 「暂无数据」+「重新加载」 | IT-LOADER-003 |
...@@ -251,7 +269,7 @@ ...@@ -251,7 +269,7 @@
| 模板联调 | real | real | off | | 模板联调 | real | real | off |
| 上线 | real | real | off | | 上线 | real | real | off |
门店另:`monthlyPendingCount`(F2-24);洽谈另:`discussionStaffList`。 门店另:`monthlyPendingCount`(F2-24);洽谈另:`discussionStaffList`、`todayPlanStore`(今日计划到店 count/list)。
## PageContext 显隐 ## PageContext 显隐
......
...@@ -18,7 +18,8 @@ STORE_DAILY_API_SWITCH = { ...@@ -18,7 +18,8 @@ STORE_DAILY_API_SWITCH = {
NEGOTIATION_DAILY_API_SWITCH = { NEGOTIATION_DAILY_API_SWITCH = {
...同上, ...同上,
discussionStaffList: 'real' // 门店页洽谈汇总员工列表 discussionStaffList: 'real', // 门店页洽谈汇总员工列表
todayPlanStore: 'real' // 洽谈明细今日计划到店 count/list
} }
CAR_MODEL_QUERY_SWITCH = 'real' // 表单 L3/L4 车型,与 Loader brand 无关 CAR_MODEL_QUERY_SWITCH = 'real' // 表单 L3/L4 车型,与 Loader brand 无关
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
| IT-APP-LISTS-* | app-save-lists-from-json.test.mjs | `npm test` | buildAppNormalizedListsFromJsonContent | | IT-APP-LISTS-* | app-save-lists-from-json.test.mjs | `npm test` | buildAppNormalizedListsFromJsonContent |
| IT-SUBFORM-MAX-001 ~ 004 | subform-max-rows.test.mjs | `npm test` | subform 最多 20 行 | | IT-SUBFORM-MAX-001 ~ 004 | subform-max-rows.test.mjs | `npm test` | subform 最多 20 行 |
| IT-STORE-APP-* / IT-STORE-ECHO-* | store-app-json-*.test.mjs | `npm test` | 门店保存/回显 jsonContent | | IT-STORE-APP-* / IT-STORE-ECHO-* | store-app-json-*.test.mjs | `npm test` | 门店保存/回显 jsonContent |
| IT-PLAN-DATE-001 ~ 005 | today-plan-date.test.mjs | `npm test` | 弹层日期文案、±7 边界、手机号脱敏 |
| IT-PLAN-ADAPTER-001 ~ 004 | negotiationTodayPlanStoreAdapters.test.mjs | `npm test` | todayPlanStore mock/real 与响应归一 |
| IT-PLAN-IMPORT-001 ~ 003 | negotiationCustomerImport.test.mjs | `npm test` | F3 字段映射、20 行上限、engine 写入 |
| upgrade-icon-url.test.mjs | upgrade-icon-url | `npm test` | CDN 图标 URL 三类路径拼接 |
## form-engine / 页面集成 ## form-engine / 页面集成
......
...@@ -42,7 +42,7 @@ import { ...@@ -42,7 +42,7 @@ import {
getGroupRowFieldsList, getGroupRowFieldsList,
stripHiddenSubformCellsFromCache stripHiddenSubformCellsFromCache
} from './group-rows-cache.js' } from './group-rows-cache.js'
import { cloneRowFieldsList, cloneRowTemplateForAdd } from './group-row-adapter.js' import { cloneRowFieldsList, cloneRowTemplateForAdd, valueMapToRowFieldsFromOrigin } from './group-row-adapter.js'
import { flattenFields } from './visibility.js' import { flattenFields } from './visibility.js'
import { normalizeFieldValueByType } from './field-types/registry.js' import { normalizeFieldValueByType } from './field-types/registry.js'
import { resolveSelectOptionValue } from './select-value.js' import { resolveSelectOptionValue } from './select-value.js'
...@@ -310,6 +310,50 @@ export function createFormEngine(schemaRoot = {}) { ...@@ -310,6 +310,50 @@ export function createFormEngine(schemaRoot = {}) {
added: nextLen > prevLen added: nextLen > prevLen
} }
}, },
/**
* 批量追加带初始值的 subform 行(洽谈明细导入客户)
* @param {string|Object} groupInput subform key 或 group 节点
* @param {Array<Object>} valueMaps 行 valueMap 数组
* @returns {object} 视图状态 + addedCount
*/
appendGroupRows(groupInput, valueMaps = []) {
const groupKey = groupInput?.key ?? groupInput
const group =
list.find(item => item.key === groupKey && item.type === 'subform') ||
groupInput
if (!group?.key || !Array.isArray(valueMaps) || !valueMaps.length) {
return { ...getViewState(), added: false, addedCount: 0 }
}
const columnTemplate = cloneRowTemplateForAdd(group)
let addedCount = 0
for (const valueMap of valueMaps) {
const prevLen = (groupRowsCache[group.key] || []).length
const cacheResult = addRowToCache(groupRowsCache, group)
const nextLen = (cacheResult.cache[group.key] || []).length
if (nextLen <= prevLen) {
break
}
const rowFields = valueMapToRowFieldsFromOrigin(columnTemplate, valueMap || {})
groupRowsCache = replaceRowInCache(
cacheResult.cache,
group.key,
cacheResult.rowIndex,
rowFields,
columnTemplate
)
addedCount += 1
}
if (addedCount > 0) {
values = syncValuesFromGroupCache(values, group.key, groupRowsCache[group.key])
applyVisibilityClearing()
finishSubformMutation()
}
return {
...getViewState(),
added: addedCount > 0,
addedCount
}
},
/** 删除 subform 指定行,返回最新视图状态 */ /** 删除 subform 指定行,返回最新视图状态 */
removeGroupRow(groupKey, rowIndex) { removeGroupRow(groupKey, rowIndex) {
groupRowsCache = removeRowFromCache(groupRowsCache, groupKey, rowIndex) groupRowsCache = removeRowFromCache(groupRowsCache, groupKey, rowIndex)
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* @see packageDynamicForm/docs/PAGES.md#洽谈明细negotiationdetail * @see packageDynamicForm/docs/PAGES.md#洽谈明细negotiationdetail
* @see packageDynamicForm/docs/ARCHITECTURE.md * @see packageDynamicForm/docs/ARCHITECTURE.md
* *
* 职责:周历选日、F3 subform、VIN OCR / 品牌选择桥接 * 职责:周历选日、F3 subform、VIN OCR / 品牌选择桥接、今日计划到店客户入口条与弹层导入
* 加载:loadNegotiationDailyForm(结构同门店,templateType=3) * 加载:loadNegotiationDailyForm(结构同门店,templateType=3)
* 写入:onFieldChange → engine;vinOcrBridge / carBrandPickerBridge 回填字段 * 写入:onFieldChange → engine;vinOcrBridge / carBrandPickerBridge 回填字段;applyCustomersToEngine 批量导入 F3
* 联调:NEGOTIATION_DAILY_API_SWITCH(../config/apiSwitch.js) * 联调:NEGOTIATION_DAILY_API_SWITCH(../config/apiSwitch.js)
* 维护:改动 Page 方法 / 加载链 / VIN·品牌桥接时,同步 PAGES.md、DEVLOG.md 并补方法 JSDoc(见 MAINTENANCE.md § 三页 Page 后续开发) * 维护:改动 Page 方法 / 加载链 / VIN·品牌桥接时,同步 PAGES.md、DEVLOG.md 并补方法 JSDoc(见 MAINTENANCE.md § 三页 Page 后续开发)
*/ */
...@@ -46,6 +46,12 @@ const { ...@@ -46,6 +46,12 @@ const {
buildVinApiValidMapFromEntries buildVinApiValidMapFromEntries
} = require('../../form-engine/vin-api-valid-tracker.js') } = require('../../form-engine/vin-api-valid-tracker.js')
const dailyReportPage = require('../behaviors/dailyReportPage.js') const dailyReportPage = require('../behaviors/dailyReportPage.js')
const { applyCustomersToEngine } = require('../../services/negotiationCustomerImport.js')
const {
buildPackageDynamicFormIconUrl,
TODAY_PLAN_BANNER_CLASS_ICON,
TODAY_PLAN_BANNER_ARROW_RIGHT_ICON
} = require('../../utils/upgrade-icon-url.js')
Page({ Page({
behaviors: [dailyReportPage], behaviors: [dailyReportPage],
...@@ -74,7 +80,14 @@ Page({ ...@@ -74,7 +80,14 @@ Page({
groupRowVisibleMap: {}, groupRowVisibleMap: {},
groupRowTotalMap: {}, groupRowTotalMap: {},
loading: true, loading: true,
loadError: '' loadError: '',
todayPlanCustomerCount: 0,
showTodayPlanPopup: false,
todayPlanMerchantId: '',
todayPlanAdvanceUserId: '',
todayPlanStaffName: '',
todayPlanClassIconUrl: '',
todayPlanArrowRightIconUrl: ''
}, },
engine: null, engine: null,
...@@ -96,6 +109,7 @@ Page({ ...@@ -96,6 +109,7 @@ Page({
if (ctx.shopMerchantName) { if (ctx.shopMerchantName) {
this.setData({ merchantName: ctx.shopMerchantName }) this.setData({ merchantName: ctx.shopMerchantName })
} }
this.initTodayPlanBannerIcons()
this.applyCalendarState(this.data.selectWeek) this.applyCalendarState(this.data.selectWeek)
this.refreshWeeklyList() this.refreshWeeklyList()
this.loadFormData() this.loadFormData()
...@@ -488,6 +502,11 @@ Page({ ...@@ -488,6 +502,11 @@ Page({
loadError: '' loadError: ''
}) })
this.applyEngineView(finalViewState, { structureChanged: true }) this.applyEngineView(finalViewState, { structureChanged: true })
if (this.data.isTodayReport) {
this.refreshTodayPlanCustomerCount()
} else {
this.setData({ todayPlanCustomerCount: 0 })
}
} catch (error) { } catch (error) {
if (this.isStaleLoad(seq)) return if (this.isStaleLoad(seq)) return
console.error(error) console.error(error)
...@@ -867,6 +886,106 @@ Page({ ...@@ -867,6 +886,106 @@ Page({
this.runVinValidate(vin, resolved) this.runVinValidate(vin, resolved)
}, },
/** 初始化今日计划入口条 CDN 切图(class.png、arrow_right.png) */
initTodayPlanBannerIcons() {
this.setData({
todayPlanClassIconUrl: buildPackageDynamicFormIconUrl(
TODAY_PLAN_BANNER_CLASS_ICON
),
todayPlanArrowRightIconUrl: buildPackageDynamicFormIconUrl(
TODAY_PLAN_BANNER_ARROW_RIGHT_ICON
)
})
},
/**
* 拉取今日待接待客户数(入口条展示)
* 由 loadFormData 在 isTodayReport 为 true 时调用
*/
async refreshTodayPlanCustomerCount() {
const ctx = this.userContext || this.getRequestContext()
if (!ctx.merchantId || !ctx.staffUuid) {
this.setData({ todayPlanCustomerCount: 0 })
return
}
try {
const res = await negotiationApi.fetchTodayPlanStoreCount({
merchantId: ctx.merchantId,
advanceUserId: ctx.staffUuid,
inviteDate: timeUtil.getTodayDateStr()
})
if (res.code === 0 && Number.isFinite(res.data)) {
this.setData({ todayPlanCustomerCount: res.data })
}
} catch (error) {
console.error(error)
}
},
/** 打开今日计划到店客户弹层 */
openTodayPlanCustomerPopup() {
if (this.data.formDisabled || !this.data.isTodayReport) return
const ctx = this.userContext || this.getRequestContext()
this.setData({
showTodayPlanPopup: true,
todayPlanMerchantId: ctx.merchantId || '',
todayPlanAdvanceUserId: ctx.staffUuid || '',
todayPlanStaffName: ctx.staffName || ''
})
},
/** 关闭今日计划客户弹层 */
closeTodayPlanCustomerPopup() {
this.setData({ showTodayPlanPopup: false })
},
/** 添加失败:任一可见 subform 超 20 行 */
showCustomerImportMaxLengthError(groupLabel) {
wx.showModal({
title: '添加失败',
content: `${groupLabel || '洽谈明细'}一次最多添加20个客户`,
showCancel: false,
confirmText: '知道了'
})
},
/**
* 弹层确认:批量导入客户到可见 F3 subform
* @param {WechatMiniprogram.CustomEvent} e detail.customers 选中客户列表
* 成功无 toast;超 20 行时 showCustomerImportMaxLengthError
*/
onTodayPlanCustomersConfirm(e) {
const customers = e?.detail?.customers || []
if (!customers.length || !this.engine) {
this.closeTodayPlanCustomerPopup()
return
}
const result = applyCustomersToEngine(this.engine, customers)
if (!result.ok) {
this.showCustomerImportMaxLengthError(result.groupLabel)
return
}
const groupActiveIndex = { ...(this.data.groupActiveIndex || {}) }
const rowTotalMap = {}
;(result.changedGroupKeys || []).forEach(groupKey => {
const cacheRows = result.viewState?.groupRowsCache?.[groupKey] || []
const total = cacheRows.length
rowTotalMap[groupKey] = total
if (total > 0) {
groupActiveIndex[groupKey] = this.clampGroupActiveIndex(
groupKey,
total - 1,
total
)
}
})
this.applyEngineView(result.viewState, {
structureChanged: false,
groupActiveIndex
})
this.closeTodayPlanCustomerPopup()
},
/** 页面卸载:清理 VIN OCR / 车型选择 bridge pending */ /** 页面卸载:清理 VIN OCR / 车型选择 bridge pending */
onUnload() { onUnload() {
this._vinOcrCtx = null this._vinOcrCtx = null
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"navigationStyle": "custom", "navigationStyle": "custom",
"usingComponents": { "usingComponents": {
"weekCalendar": "../../components/weekCalendar/weekCalendar", "weekCalendar": "../../components/weekCalendar/weekCalendar",
"dynamic-form": "../../components/dynamic-form/dynamic-form" "dynamic-form": "../../components/dynamic-form/dynamic-form",
"today-plan-customer-popup": "../../components/today-plan-customer-popup/today-plan-customer-popup"
} }
} }
...@@ -146,3 +146,69 @@ page { ...@@ -146,3 +146,69 @@ page {
color: #347bff; color: #347bff;
font-size: 28rpx; font-size: 28rpx;
} }
.today-plan-banner {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 0 20rpx;
padding: 0;
box-sizing: border-box;
}
.today-plan-banner__left {
display: flex;
align-items: center;
min-width: 0;
flex: 1;
}
.today-plan-banner__icon {
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
flex-shrink: 0;
}
.today-plan-banner__text {
font-size: 28rpx;
color: #292d33;
white-space: nowrap;
}
.today-plan-banner__count {
margin-left: 12rpx;
font-size: 32rpx;
font-weight: 700;
color: #2c66f7;
}
.today-plan-banner__btn {
flex-shrink: 0;
margin-left: 16rpx;
display: flex;
align-items: center;
justify-content: center;
height: 64rpx;
padding: 0 32rpx;
border-radius: 16rpx;
border: 1rpx solid #2c66f71a;
background: rgba(44, 102, 247, 0.1);
font-size: 30rpx;
font-weight: 500;
color: #347bff;
text-align: center;
white-space: nowrap;
box-sizing: border-box;
}
.today-plan-banner__btn-text {
line-height: 1;
}
.today-plan-banner__btn-arrow {
width: 36rpx;
height: 36rpx;
margin-left: 4rpx;
flex-shrink: 0;
}
...@@ -33,6 +33,25 @@ ...@@ -33,6 +33,25 @@
enhanced enhanced
show-scrollbar="{{ false }}" show-scrollbar="{{ false }}"
> >
<view wx:if="{{ isTodayReport }}" class="today-plan-banner">
<view class="today-plan-banner__left">
<image class="today-plan-banner__icon" src="{{ todayPlanClassIconUrl }}" mode="aspectFit" />
<text class="today-plan-banner__text">今日待接待客户数</text>
<text class="today-plan-banner__count">{{ todayPlanCustomerCount }}</text>
</view>
<view
wx:if="{{ !formDisabled }}"
class="today-plan-banner__btn"
bindtap="openTodayPlanCustomerPopup"
>
<text class="today-plan-banner__btn-text">查看客户</text>
<image
class="today-plan-banner__btn-arrow"
src="{{ todayPlanArrowRightIconUrl }}"
mode="aspectFit"
/>
</view>
</view>
<dynamic-form <dynamic-form
fixedFields="{{ fixedFields }}" fixedFields="{{ fixedFields }}"
section-groups="{{ sectionGroups }}" section-groups="{{ sectionGroups }}"
...@@ -67,4 +86,13 @@ ...@@ -67,4 +86,13 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<today-plan-customer-popup
show="{{ showTodayPlanPopup }}"
merchant-id="{{ todayPlanMerchantId }}"
advance-user-id="{{ todayPlanAdvanceUserId }}"
staff-name="{{ todayPlanStaffName }}"
bind:cancel="closeTodayPlanCustomerPopup"
bind:confirm="onTodayPlanCustomersConfirm"
/>
</view> </view>
/**
* 洽谈明细 — 从计划到店客户批量导入 subform 行
* @file 纯业务映射与容量校验,通过 engine.appendGroupRows 写入
*/
const { resolveSubformMaxRows } = require('../form-engine/subform-limits.js')
const { formatCustomerCarSeriesLabel } = require('./today-plan-date.js')
/** 各 F3 子表单字段后缀(与 PRD / gl_tape 一致) */
const GROUP_FIELD_SUFFIX = {
'F3-1': {
inviteDate: '1',
customerName: '4',
customerPhone: '5',
staff: '8',
carBrand: '6'
},
'F3-2': {
inviteDate: '1',
customerName: '4',
customerPhone: '5',
staff: '8',
carBrand: '6'
},
'F3-3': {
inviteDate: '1',
customerName: '4',
customerPhone: '5',
staff: '8',
carBrand: '6'
},
'F3-4': {
inviteDate: '1',
customerName: '5',
customerPhone: '6',
staff: '2',
carBrand: '7'
}
}
/**
* 从引擎视图状态取 subform 当前行数
* @param {Object} viewState
* @param {string} groupKey
* @returns {number}
*/
function getSubformRowCount(viewState = {}, groupKey) {
const cacheRows = viewState.groupRowsCache?.[groupKey]
if (Array.isArray(cacheRows)) {
return cacheRows.length
}
const valueRows = viewState.values?.[groupKey]
if (Array.isArray(valueRows)) {
return valueRows.length
}
return 0
}
/**
* 从引擎取当前可见 subform 分组
* @param {Object} engine
* @returns {Array}
*/
function getVisibleSubformGroups(engine) {
if (!engine || typeof engine.getVisibleList !== 'function') {
return []
}
return engine.getVisibleList().filter(item => item.type === 'subform' && item.key)
}
/**
* 构建 partial carInfo(三级车系,导入可提交;手动改仍需四级)
* @param {Object} customer
* @returns {Object|null}
*/
function buildCustomerCarInfo(customer = {}) {
const { carBrandId, carBrand, carChildsBrandId, carChildsBrandName, carSeriesId, carSeriesName } =
customer
if (!carBrand && !carSeriesName) {
return null
}
const displayText = formatCustomerCarSeriesLabel(customer)
return {
vehicleBrandId: carBrandId,
vehicleBrandName: carBrand,
vehicleSubBrandId: carChildsBrandId,
vehicleSubBrandName: carChildsBrandName,
vehicleSeriesId: carSeriesId,
vehicleSeriesName: carSeriesName,
displayText
}
}
/**
* 单客户 + 子表单 → valueMap(供 origin_children 还原行)
* @param {Object} customer API 列表项
* @param {string} groupKey F3-1 ~ F3-4
* @returns {Object}
*/
function buildCustomerRowValueMap(customer = {}, groupKey) {
const suffixMap = GROUP_FIELD_SUFFIX[groupKey]
if (!suffixMap) {
return {}
}
const valueMap = {}
const prefix = groupKey
if (customer.inviteDate) {
valueMap[`${prefix}-${suffixMap.inviteDate}`] = customer.inviteDate
}
if (customer.customerName) {
valueMap[`${prefix}-${suffixMap.customerName}`] = customer.customerName
}
if (customer.customerPhone) {
valueMap[`${prefix}-${suffixMap.customerPhone}`] = customer.customerPhone
}
if (customer.advanceUserId && customer.advanceUserName) {
valueMap[`${prefix}-${suffixMap.staff}`] = {
id: customer.advanceUserId,
name: customer.advanceUserName
}
}
const carInfo = buildCustomerCarInfo(customer)
if (carInfo) {
valueMap[`${prefix}-${suffixMap.carBrand}`] = carInfo
}
return valueMap
}
/**
* 校验可见 subform 是否还能容纳 N 条新客户
* @param {Array} visibleSubforms
* @param {Object} rowCounts groupKey → 当前行数
* @param {number} selectedCount
* @returns {{ok: boolean, groupLabel?: string}}
*/
function validateCustomerImportCapacity(visibleSubforms = [], rowCounts = {}, selectedCount = 0) {
if (!selectedCount) {
return { ok: false, groupLabel: '' }
}
for (const group of visibleSubforms) {
const maxLength = resolveSubformMaxRows(group)
const current = Number(rowCounts[group.key]) || 0
if (current + selectedCount > maxLength) {
return { ok: false, groupLabel: group.label || group.key }
}
}
return { ok: true }
}
/**
* 批量将选中客户写入所有可见 F3 subform(全有或全无)
* @param {Object} engine formEngine 实例
* @param {Array} customers 选中客户列表
* @returns {{ok: boolean, groupLabel?: string, viewState?: Object, changedGroupKeys?: string[]}}
*/
function applyCustomersToEngine(engine, customers = []) {
const visibleSubforms = getVisibleSubformGroups(engine)
if (!visibleSubforms.length) {
return { ok: false, groupLabel: '洽谈明细' }
}
const selectedCount = customers.length
const viewState = engine.getViewState()
const rowCounts = {}
visibleSubforms.forEach(group => {
rowCounts[group.key] = getSubformRowCount(viewState, group.key)
})
const validation = validateCustomerImportCapacity(
visibleSubforms,
rowCounts,
selectedCount
)
if (!validation.ok) {
return validation
}
let lastViewState = viewState
const changedGroupKeys = []
for (const group of visibleSubforms) {
const valueMaps = customers.map(customer =>
buildCustomerRowValueMap(customer, group.key)
)
const result = engine.appendGroupRows(group.key, valueMaps)
const addedCount = result.addedCount ?? 0
if (addedCount < selectedCount) {
return { ok: false, groupLabel: group.label || group.key }
}
lastViewState = result
changedGroupKeys.push(group.key)
}
return {
ok: true,
viewState: lastViewState,
changedGroupKeys
}
}
module.exports = {
GROUP_FIELD_SUFFIX,
getVisibleSubformGroups,
getSubformRowCount,
buildCustomerCarInfo,
buildCustomerRowValueMap,
validateCustomerImportCapacity,
applyCustomersToEngine
}
/**
* 洽谈明细 — 计划到店日期导航与展示文案
* @file 纯函数,供弹层日期切换与 label 渲染
*/
var timeUtil = require('../../utils/timeFormat/time-utils.js')
const WEEK_CN = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
const PLAN_STORE_DATE_RANGE_DAYS = 7
/**
* 解析 YYYY-MM-DD 为本地零点 Date
* @param {string} dateStr
* @returns {Date|null}
*/
function parsePlanStoreDate(dateStr) {
if (!dateStr || typeof dateStr !== 'string') {
return null
}
const parts = dateStr.split('-').map(Number)
if (parts.length !== 3 || parts.some(n => !Number.isFinite(n))) {
return null
}
return new Date(parts[0], parts[1] - 1, parts[2])
}
/**
* 日期与今天相差天数(按本地日历)
* @param {string} dateStr YYYY-MM-DD
* @returns {number}
*/
function diffPlanStoreDaysFromToday(dateStr) {
const target = parsePlanStoreDate(dateStr)
if (!target) {
return 0
}
const today = parsePlanStoreDate(timeUtil.getTodayDateStr())
const oneDay = 24 * 60 * 60 * 1000
return Math.round((target.getTime() - today.getTime()) / oneDay)
}
/**
* 相对今天文案:今天/明天/昨天/N天前/N天后
* @param {string} dateStr
* @returns {string}
*/
function getPlanStoreDateTips(dateStr) {
const diff = diffPlanStoreDaysFromToday(dateStr)
if (diff === 0) return '今天'
if (diff === 1) return '明天'
if (diff === -1) return '昨天'
if (diff === 2) return '后天'
if (diff === -2) return '前天'
if (diff > 2) return `${diff}天后`
if (diff < -2) return `${Math.abs(diff)}天前`
return ''
}
/**
* 弹层日期展示:6月10日 周三 (今天)
* @param {string} dateStr YYYY-MM-DD
* @returns {string}
*/
function formatPlanStoreDateLabel(dateStr) {
const date = parsePlanStoreDate(dateStr)
if (!date) {
return dateStr || ''
}
const month = date.getMonth() + 1
const day = date.getDate()
const week = WEEK_CN[date.getDay()] || ''
const tips = getPlanStoreDateTips(dateStr)
return `${month}月${day}日 ${week} (${tips})`
}
/**
* 是否可切换日期(今日 ±7 天)
* @param {string} currentDateStr
* @param {number} offset -1 前一天 / +1 后一天
* @returns {boolean}
*/
function canShiftPlanStoreDate(currentDateStr, offset) {
const current = parsePlanStoreDate(currentDateStr)
if (!current || !offset) {
return false
}
const next = new Date(current)
next.setDate(next.getDate() + offset)
return isPlanStoreDateInRange(timeUtil.formatDateStr(next))
}
/**
* 判断日期是否在可选范围内
* @param {string} dateStr
* @returns {boolean}
*/
function isPlanStoreDateInRange(dateStr) {
const diff = diffPlanStoreDaysFromToday(dateStr)
return diff >= -PLAN_STORE_DATE_RANGE_DAYS && diff <= PLAN_STORE_DATE_RANGE_DAYS
}
/**
* 切换日期
* @param {string} currentDateStr
* @param {number} offset
* @returns {string|null}
*/
function shiftPlanStoreDate(currentDateStr, offset) {
if (!canShiftPlanStoreDate(currentDateStr, offset)) {
return null
}
const current = parsePlanStoreDate(currentDateStr)
const next = new Date(current)
next.setDate(next.getDate() + offset)
return timeUtil.formatDateStr(next)
}
/**
* 列表展示用车系文案
* @param {Object} [customer={}]
* @returns {string}
*/
function formatCustomerCarSeriesLabel(customer = {}) {
return [customer.carBrand, customer.carChildsBrandName, customer.carSeriesName]
.filter(part => part != null && part !== '')
.join('-')
}
/**
* 手机号脱敏(中间四位 ****),已脱敏则原样
* @param {string} [phone='']
* @returns {string}
*/
function maskCustomerPhone(phone = '') {
if (!phone || typeof phone !== 'string') {
return ''
}
if (phone.includes('*')) {
return phone
}
if (phone.length === 11) {
return `${phone.slice(0, 3)}****${phone.slice(7)}`
}
return phone
}
module.exports = {
PLAN_STORE_DATE_RANGE_DAYS,
parsePlanStoreDate,
diffPlanStoreDaysFromToday,
getPlanStoreDateTips,
formatPlanStoreDateLabel,
canShiftPlanStoreDate,
isPlanStoreDateInRange,
shiftPlanStoreDate,
formatCustomerCarSeriesLabel,
maskCustomerPhone
}
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const { createFormEngine } = require('../form-engine/core.js')
const {
buildCustomerRowValueMap,
validateCustomerImportCapacity,
applyCustomersToEngine
} = require('../services/negotiationCustomerImport.js')
const sampleCustomer = {
inviteDate: '2026-06-10',
customerName: '张三',
customerPhone: '13800138000',
advanceUserId: 'staff-1',
advanceUserName: '李璐',
carBrandId: 3454,
carBrand: '问界',
carChildsBrandId: 1,
carChildsBrandName: '问界',
carSeriesId: 101,
carSeriesName: 'M7 Plus'
}
const subformGroup = {
key: 'F3-2',
type: 'subform',
label: '问界鸿蒙洽谈明细 (延保)',
rules: { maxLength: 20 },
origin_children: [
{ key: 'F3-2-1', type: 'date', label: '交车日期' },
{ key: 'F3-2-4', type: 'input', label: '客户名称' },
{ key: 'F3-2-5', type: 'phoneInput', label: '客户手机号' },
{ key: 'F3-2-6', type: 'carBrandSelect', label: '车型配置' },
{
key: 'F3-2-8',
type: 'select',
label: '驻店人员',
optionsKey: 'storeStaffList'
}
],
children: [[]]
}
describe('negotiationCustomerImport', () => {
it('IT-PLAN-IMPORT-001: buildCustomerRowValueMap maps F3-2 fields', () => {
const map = buildCustomerRowValueMap(sampleCustomer, 'F3-2')
assert.equal(map['F3-2-4'], '张三')
assert.equal(map['F3-2-5'], '13800138000')
assert.equal(map['F3-2-1'], '2026-06-10')
assert.equal(map['F3-2-8'].id, 'staff-1')
assert.equal(map['F3-2-6'].vehicleSeriesName, 'M7 Plus')
})
it('IT-PLAN-IMPORT-002: validateCustomerImportCapacity blocks over 20', () => {
const fail = validateCustomerImportCapacity([subformGroup], { 'F3-2': 18 }, 3)
assert.equal(fail.ok, false)
assert.match(fail.groupLabel, /问界/)
const ok = validateCustomerImportCapacity([subformGroup], { 'F3-2': 18 }, 2)
assert.equal(ok.ok, true)
})
it('IT-PLAN-IMPORT-003: applyCustomersToEngine appends rows', () => {
const engine = createFormEngine({
list: [subformGroup],
version: 1
})
engine.init({ list: [subformGroup] }, { initialValues: {} })
const result = applyCustomersToEngine(engine, [sampleCustomer, sampleCustomer])
assert.equal(result.ok, true)
const state = engine.getViewState()
assert.equal((state.groupRowsCache['F3-2'] || []).length, 2)
})
})
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const timeUtil = require('../../utils/timeFormat/time-utils.js')
const { NEGOTIATION_DAILY_API_SWITCH } = require('../config/apiSwitch.js')
const {
buildMockTodayPlanStoreList,
fetchTodayPlanStoreCountAdapter,
fetchTodayPlanStoreListAdapter,
normalizeTodayPlanStoreCountResponse,
normalizeTodayPlanStoreListResponse,
extractTodayPlanCount
} = require('../api/negotiationTodayPlanStoreAdapters.js')
describe('negotiationTodayPlanStoreAdapters', () => {
it('IT-PLAN-ADAPTER-001: mock count matches today list length', async () => {
const original = NEGOTIATION_DAILY_API_SWITCH.todayPlanStore
NEGOTIATION_DAILY_API_SWITCH.todayPlanStore = 'mock'
try {
const today = timeUtil.getTodayDateStr()
const expectedLen = buildMockTodayPlanStoreList(today).length
const res = await fetchTodayPlanStoreCountAdapter({
merchantId: '1',
advanceUserId: 'u1',
inviteDate: today
})
const normalized = normalizeTodayPlanStoreCountResponse(res)
assert.equal(normalized.code, 0)
assert.equal(normalized.data, expectedLen)
assert.ok(expectedLen > 0)
} finally {
NEGOTIATION_DAILY_API_SWITCH.todayPlanStore = original
}
})
it('IT-PLAN-ADAPTER-002: mock list empty for non-today inviteDate', async () => {
const original = NEGOTIATION_DAILY_API_SWITCH.todayPlanStore
NEGOTIATION_DAILY_API_SWITCH.todayPlanStore = 'mock'
try {
const res = await fetchTodayPlanStoreListAdapter({
merchantId: '1',
advanceUserId: 'u1',
inviteDate: '2000-01-01'
})
const normalized = normalizeTodayPlanStoreListResponse(res)
assert.equal(normalized.code, 0)
assert.equal(normalized.data.length, 0)
} finally {
NEGOTIATION_DAILY_API_SWITCH.todayPlanStore = original
}
})
it('IT-PLAN-ADAPTER-003: normalize count from scalar data', () => {
assert.equal(extractTodayPlanCount(3), 3)
const ok = normalizeTodayPlanStoreCountResponse({ code: 0, message: 'ok', data: 8 })
assert.equal(ok.data, 8)
})
it('IT-PLAN-ADAPTER-004: normalize list response', () => {
const res = normalizeTodayPlanStoreListResponse({
code: 0,
message: 'ok',
data: [{ customerName: 'A' }]
})
assert.equal(res.data.length, 1)
assert.equal(res.data[0].customerName, 'A')
})
})
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
formatPlanStoreDateLabel,
canShiftPlanStoreDate,
shiftPlanStoreDate,
maskCustomerPhone,
isPlanStoreDateInRange,
diffPlanStoreDaysFromToday
} = require('../services/today-plan-date.js')
const timeUtil = require('../../utils/timeFormat/time-utils.js')
describe('today-plan-date', () => {
const today = timeUtil.getTodayDateStr()
it('IT-PLAN-DATE-001: formatPlanStoreDateLabel includes weekday and tips', () => {
const label = formatPlanStoreDateLabel(today)
assert.match(label, /今天/)
assert.match(label, /月/)
})
it('IT-PLAN-DATE-002: isPlanStoreDateInRange allows ±7 days', () => {
const dPlus = new Date()
dPlus.setDate(dPlus.getDate() + 7)
const plus7 = timeUtil.formatDateStr(dPlus)
assert.equal(isPlanStoreDateInRange(plus7), true)
const dMinus = new Date()
dMinus.setDate(dMinus.getDate() - 8)
const minus8 = timeUtil.formatDateStr(dMinus)
assert.equal(isPlanStoreDateInRange(minus8), false)
})
it('IT-PLAN-DATE-003: shiftPlanStoreDate respects boundary', () => {
const next = shiftPlanStoreDate(today, 1)
assert.ok(next)
assert.equal(canShiftPlanStoreDate(today, 1), true)
})
it('IT-PLAN-DATE-004: maskCustomerPhone masks 11-digit phone', () => {
assert.equal(maskCustomerPhone('15712342929'), '157****2929')
assert.equal(maskCustomerPhone('157****2929'), '157****2929')
})
it('IT-PLAN-DATE-005: diffPlanStoreDaysFromToday is 0 for today', () => {
assert.equal(diffPlanStoreDaysFromToday(today), 0)
})
})
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
buildPackageDynamicFormIconUrl,
buildUpgradeIconUrl,
buildWeappIconUrl,
DEFAULT_IMG_BASE,
TODAY_PLAN_BANNER_CLASS_ICON,
TODAY_PLAN_BANNER_ARROW_RIGHT_ICON,
TODAY_PLAN_CHECK_ICON
} = require('../utils/upgrade-icon-url.js')
test('buildPackageDynamicFormIconUrl 拼接 packageDynamicForm 子目录', () => {
const url = buildPackageDynamicFormIconUrl('class.png')
assert.ok(url.includes('packageDynamicForm/class.png'))
assert.ok(url.startsWith(DEFAULT_IMG_BASE))
})
test('洽谈入口条常量对应切图文件名', () => {
assert.equal(TODAY_PLAN_BANNER_CLASS_ICON, 'class.png')
assert.equal(TODAY_PLAN_BANNER_ARROW_RIGHT_ICON, 'arrow_right.png')
assert.ok(
buildPackageDynamicFormIconUrl(TODAY_PLAN_BANNER_CLASS_ICON).endsWith(
'packageDynamicForm/class.png'
)
)
assert.ok(
buildPackageDynamicFormIconUrl(TODAY_PLAN_BANNER_ARROW_RIGHT_ICON).endsWith(
'packageDynamicForm/arrow_right.png'
)
)
})
test('buildUpgradeIconUrl 仍指向 upgrade 子目录', () => {
const url = buildUpgradeIconUrl('arrow-left.png')
assert.ok(url.endsWith('upgrade/arrow-left.png'))
})
test('今日计划弹层勾选图标指向 CDN 根目录 check.png', () => {
assert.equal(TODAY_PLAN_CHECK_ICON, 'check.png')
const url = buildWeappIconUrl(TODAY_PLAN_CHECK_ICON)
assert.ok(url.endsWith('check.png'))
assert.ok(!url.includes('packageDynamicForm/'))
})
/**
* packageDynamicForm CDN 图标 URL 拼接
* @file 解析 IMG 基址并拼接 upgrade / packageDynamicForm / 根目录路径;不调 setData、不依赖 Page
*/
/** 日报子表单翻页箭头 CDN 基地址(与 tabIndex IMG_URL 一致) */ /** 日报子表单翻页箭头 CDN 基地址(与 tabIndex IMG_URL 一致) */
const DEFAULT_IMG_BASE = const DEFAULT_IMG_BASE =
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/' 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
...@@ -8,7 +12,10 @@ function normalizeImgBase(base = '') { ...@@ -8,7 +12,10 @@ function normalizeImgBase(base = '') {
return trimmed.endsWith('/') ? trimmed : `${trimmed}/` return trimmed.endsWith('/') ? trimmed : `${trimmed}/`
} }
/** 解析图片基地址:运行时 > config.ImgUrl > 默认 CDN */ /**
* 解析图片基地址:运行时 globalData / wx.$util > config.ImgUrl > 默认 CDN
* @returns {string} 以 / 结尾的完整基址
*/
function resolveImgBase() { function resolveImgBase() {
const app = typeof getApp === 'function' ? getApp() : null const app = typeof getApp === 'function' ? getApp() : null
const wxUtil = const wxUtil =
...@@ -28,15 +35,50 @@ function resolveImgBase() { ...@@ -28,15 +35,50 @@ function resolveImgBase() {
return DEFAULT_IMG_BASE return DEFAULT_IMG_BASE
} }
/**
* upgrade 子目录切图(表单翻页箭头等)
* @param {string} fileName 文件名,如 formLift.png
* @returns {string} 完整 URL
*/
function buildUpgradeIconUrl(fileName) { function buildUpgradeIconUrl(fileName) {
return `${resolveImgBase()}upgrade/${fileName}` return `${resolveImgBase()}upgrade/${fileName}`
} }
/**
* packageDynamicForm 分包切图(洽谈入口条图标等)
* @param {string} fileName 文件名,如 class.png
* @returns {string} 完整 URL
*/
function buildPackageDynamicFormIconUrl(fileName) {
return `${resolveImgBase()}packageDynamicForm/${fileName}`
}
/**
* CDN 根目录切图(与 IMG_URL + fileName 一致,如 check.png)
* @param {string} fileName 文件名
* @returns {string} 完整 URL
*/
function buildWeappIconUrl(fileName) {
return `${resolveImgBase()}${fileName}`
}
/** 洽谈入口条左侧记事本图标 */
const TODAY_PLAN_BANNER_CLASS_ICON = 'class.png'
/** 洽谈入口条「查看客户」右侧箭头 */
const TODAY_PLAN_BANNER_ARROW_RIGHT_ICON = 'arrow_right.png'
/** 今日计划弹层勾选态图标(CDN 根目录) */
const TODAY_PLAN_CHECK_ICON = 'check.png'
module.exports = { module.exports = {
DEFAULT_IMG_BASE, DEFAULT_IMG_BASE,
resolveImgBase, resolveImgBase,
buildUpgradeIconUrl, buildUpgradeIconUrl,
buildPackageDynamicFormIconUrl,
buildWeappIconUrl,
FORM_NAV_ICON_LEFT: 'formLift.png', FORM_NAV_ICON_LEFT: 'formLift.png',
FORM_NAV_ICON_RIGHT: 'formRight.png', FORM_NAV_ICON_RIGHT: 'formRight.png',
FORM_FIELD_ARROW_ICON: 'arrow-left.png' FORM_FIELD_ARROW_ICON: 'arrow-left.png',
TODAY_PLAN_BANNER_CLASS_ICON,
TODAY_PLAN_BANNER_ARROW_RIGHT_ICON,
TODAY_PLAN_CHECK_ICON
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!