Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1432781e
authored
Jun 15, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat 日报功能开发
1 parent
ff20e7c2
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
713 additions
and
117 deletions
packageDynamicForm/api/dailyReportCarBrand.js
packageDynamicForm/api/dynamicDailyReport.js
packageDynamicForm/api/negotiationDailyReport.js
packageDynamicForm/api/negotiationDailyReportAdapters.js
packageDynamicForm/api/negotiationDailyReportCache.js
packageDynamicForm/api/staffDailyReport.js
packageDynamicForm/api/staffDailyReportAdapters.js
packageDynamicForm/api/staffDailyReportCache.js
packageDynamicForm/api/storeDailyReport.js
packageDynamicForm/api/storeDailyReportAdapters.js
packageDynamicForm/api/storeDailyReportCache.js
packageDynamicForm/components/negotiation-summary/negotiation-summary.js
packageDynamicForm/docs/ARCHITECTURE.md
packageDynamicForm/docs/DEVLOG.md
packageDynamicForm/docs/daily-report-save-and-json.md
packageDynamicForm/fixtures/mock-meta.js
packageDynamicForm/form-engine/save-request.js
packageDynamicForm/pages/negotiationDetail/negotiationDetail.js
packageDynamicForm/pages/staffDailyReport/staffDailyReport.js
packageDynamicForm/pages/storeDailyReport/storeDailyReport.js
packageDynamicForm/pages/storeDailyReport/storeDailyReport.wxml
packageDynamicForm/services/dailyReportBootstrap.js
packageDynamicForm/tests/dailyReportCarBrand.test.mjs
packageDynamicForm/tests/dailyReportSaveRequest.test.mjs
packageDynamicForm/tests/dailyReportWeeklyList.test.mjs
packageDynamicForm/tests/negotiation-discussion-staff.test.mjs
packageDynamicForm/tests/negotiationDailyFormLoader.test.mjs
packageDynamicForm/tests/staffDailyFormLoader.test.mjs
packageDynamicForm/tests/staffDailyReportAdapters.test.mjs
packageDynamicForm/tests/storeDailyFormLoader.test.mjs
packageDynamicForm/tests/storeDailyReportAdapters.test.mjs
packageDynamicForm/tests/storeMonthlyPendingCount.test.mjs
packageDynamicForm/utils/user-merchant.js
packageDynamicForm/api/dailyReportCarBrand.js
0 → 100644
View file @
1432781
/**
* 日报保存用 carBrandList — staff.daily.report.car.brand
* 与 schema 显隐用的 merchant.info 分离
*/
const
{
resolveSceneType
}
=
require
(
'../utils/user-merchant.js'
)
const
carBrandCache
=
new
Map
()
const
MOCK_DAILY_REPORT_CAR_BRAND_LIST
=
[
{
firstBrandId
:
3454
,
firstBrandName
:
'问界'
,
brandId
:
3454
,
brandName
:
'AITO'
},
{
firstBrandId
:
3067
,
firstBrandName
:
'岚图'
,
brandId
:
3067
,
brandName
:
'岚图汽车'
}
]
function
getCarBrandCacheKey
(
merchantId
,
sceneType
)
{
return
`
${
merchantId
||
''
}
:
${
sceneType
??
0
}
`
}
function normalizeCarBrandListForSave(data = []) {
if (!Array.isArray(data)) {
return []
}
return data.map(item => {
const firstBrandId = item.firstBrandId
const firstBrandName = item.firstBrandName || ''
let brandId = item.brandId
let brandName = item.brandName || ''
if (brandId == -1) {
brandName = firstBrandName
}
return {
firstBrandId,
firstBrandName,
brandId,
brandName
}
})
}
function normalizeSceneCodeListToSceneList(data) {
if (!Array.isArray(data)) {
return []
}
return data
.filter(code => code != null && code !== '')
.map(code => ({ baseSceneCode: Number(code) }))
}
let staffDailyReportCarBrandOverride = null
function __setStaffDailyReportCarBrand(impl) {
staffDailyReportCarBrandOverride = impl
}
function clearDailyReportCarBrandCache() {
carBrandCache.clear()
}
/**
* 拉取保存用 carBrandList(merchantId + sceneType)
* @param {Object} [params={}]
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async function fetchDailyReportCarBrandList(params = {}) {
const { merchantId, sceneType = 0, useMock = false } = params
if (!merchantId) {
return { code: 0, message: 'ok', data: [] }
}
if (useMock) {
return { code: 0, message: 'ok', data: [...MOCK_DAILY_REPORT_CAR_BRAND_LIST] }
}
const cacheKey = getCarBrandCacheKey(merchantId, sceneType)
const cached = carBrandCache.get(cacheKey)
if (cached) {
return cached
}
const fetcher =
staffDailyReportCarBrandOverride ||
((data) => require('./dynamicDailyReport.js').staffDailyReportCarBrand(data))
const result = await fetcher({
merchantId,
sceneType: resolveSceneType({ sceneType })
})
const code = result?.code
if (code != null && code != 0) {
return {
code: code ?? -1,
message: result?.message || '获取车型失败',
data: []
}
}
const normalized = {
code: 0,
message: 'ok',
data: normalizeCarBrandListForSave(result?.data)
}
carBrandCache.set(cacheKey, normalized)
return normalized
}
module.exports = {
normalizeCarBrandListForSave,
normalizeSceneCodeListToSceneList,
fetchDailyReportCarBrandList,
getCarBrandCacheKey,
clearDailyReportCarBrandCache,
__setStaffDailyReportCarBrand,
MOCK_DAILY_REPORT_CAR_BRAND_LIST
}
packageDynamicForm/api/dynamicDailyReport.js
View file @
1432781
...
...
@@ -32,6 +32,21 @@ function findAllSceneByMerchantId(data) {
return
api
.
post
(
'dj.api.scenemerchantref.findAllSceneByMerchantId'
,
data
)
}
function
merchantBaseSceneCodeList
(
data
)
{
return
api
.
post
(
'dj.api.smartcarlife.staffBaseInfo.merchant.baseSceneCode.list'
,
data
,
[],
undefined
,
'dj'
,
false
)
}
function
staffDailyReportCarBrand
(
data
)
{
return
api
.
post
(
'dj.api.smartcarlife.staff.daily.report.car.brand'
,
data
)
}
function
dailyReportDiscussionStaffList
(
data
)
{
return
api
.
post
(
'dj.api.smartcarlife.dailyReport.discussion.staff.list'
,
...
...
@@ -50,5 +65,7 @@ module.exports = {
dailyReportDetailGet
,
dailyReportMonthlyPendingCountGet
,
findAllSceneByMerchantId
,
merchantBaseSceneCodeList
,
staffDailyReportCarBrand
,
dailyReportDiscussionStaffList
}
packageDynamicForm/api/negotiationDailyReport.js
View file @
1432781
...
...
@@ -35,6 +35,7 @@ const {
saveEchoAdapter
}
=
require
(
'./negotiationDailyReportAdapters.js'
)
const
{
isNegotiationMockMode
}
=
require
(
'../config/apiSwitch.js'
)
const
{
fetchDailyReportCarBrandList
:
fetchCarBrandListImpl
}
=
require
(
'./dailyReportCarBrand.js'
)
const
{
normalizeDailyReportUserInfo
}
=
require
(
'../utils/user-merchant.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
,
...
...
@@ -67,11 +68,18 @@ function buildPageContextFromSources({
brandIds
=
[],
detail
=
{},
baseSceneCode
,
sceneList
sceneList
,
carBrandList
=
[]
}
=
{})
{
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
pageContext
=
buildPageContext
({
baseSceneCode
},
brandIds
,
normalized
,
sceneList
||
[])
return
enrichPageContextWithDetailEcho
(
pageContext
,
detail
)
const
enriched
=
enrichPageContextWithDetailEcho
(
pageContext
,
detail
)
return
{
...
enriched
,
sceneType
:
normalized
.
sceneType
,
yqMerchantName
:
normalized
.
yqMerchantName
,
carBrandList
:
Array
.
isArray
(
carBrandList
)
?
carBrandList
:
[]
}
}
/** 统一 API 响应结构 { code, message, data } */
...
...
@@ -91,7 +99,13 @@ function unwrapResponse(result = {}) {
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @returns {Promise<{code: number, message: string, baseSceneCode: string|null, sceneList: Array}>}
*/
async
function
fetchMerchantScene
({
merchantId
,
detailBaseSceneCode
,
hasRecord
}
=
{})
{
async
function
fetchMerchantScene
({
merchantId
,
staffUuid
,
sceneType
,
detailBaseSceneCode
,
hasRecord
}
=
{})
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
...
...
@@ -100,7 +114,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
sceneList
:
[]
}
}
const
result
=
await
fetchSceneAdapter
({
merchantId
})
const
result
=
await
fetchSceneAdapter
({
merchantId
,
staffUuid
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
return
{
...
...
@@ -142,6 +156,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
}
}
async
function
fetchDailyReportCarBrandList
({
merchantId
,
sceneType
}
=
{})
{
return
fetchCarBrandListImpl
({
merchantId
,
sceneType
,
useMock
:
isNegotiationMockMode
(
'brand'
)
})
}
/**
* 组装表单 pageContext(品牌、场景、用户信息)
* @param {Object} [options={}]
...
...
@@ -149,10 +171,17 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Array} [options.carBrandList] 保存用车型列表
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async
function
fetchPageContext
(
options
=
{})
{
const
{
userInfo
=
{},
brandIds
=
[],
detail
=
{},
merchantScene
=
{}
}
=
options
const
{
userInfo
=
{},
brandIds
=
[],
detail
=
{},
merchantScene
=
{},
carBrandList
=
[]
}
=
options
const
hasRecord
=
!!
detail
.
dailyReportRecordId
let
baseSceneCode
=
resolveBaseSceneCode
(
merchantScene
.
sceneList
||
[],
...
...
@@ -179,7 +208,8 @@ async function fetchPageContext(options = {}) {
brandIds
,
detail
,
baseSceneCode
,
sceneList
:
merchantScene
.
sceneList
||
[]
sceneList
:
merchantScene
.
sceneList
||
[],
carBrandList
})
}
}
...
...
@@ -202,7 +232,13 @@ function buildEmptyDetail(reportTemplateId) {
* @param {number|string} [options.reportTemplateId] 模板 ID
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async
function
fetchReportDetail
({
merchantId
,
staffUuid
,
reportDate
,
reportTemplateId
}
=
{})
{
async
function
fetchReportDetail
({
merchantId
,
staffUuid
,
reportDate
,
reportTemplateId
,
sceneType
}
=
{})
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
return
{
code
:
0
,
...
...
@@ -215,7 +251,8 @@ async function fetchReportDetail({ merchantId, staffUuid, reportDate, reportTemp
merchantId
,
staffUuid
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
...
...
@@ -313,11 +350,11 @@ function resolveSchemaDetailValues(detail, schemaList = [], fallbackValues = {})
* @param {string} [options.reportDate] 报表日期 YYYY-MM-DD
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async
function
fetchDiscussionStaffList
({
merchantId
,
reportDate
}
=
{})
{
async
function
fetchDiscussionStaffList
({
merchantId
,
reportDate
,
sceneType
}
=
{})
{
if
(
!
merchantId
||
!
reportDate
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
}
const
result
=
await
fetchDiscussionStaffListAdapter
({
merchantId
,
reportDate
})
const
result
=
await
fetchDiscussionStaffListAdapter
({
merchantId
,
reportDate
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
return
{
code
:
code
??
-
1
,
message
,
data
:
[]
}
...
...
@@ -342,7 +379,8 @@ async function fetchWeeklyList({
merchantId
,
staffUuid
,
reportStartDate
,
reportEndDate
reportEndDate
,
sceneType
}
=
{})
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
...
...
@@ -350,6 +388,7 @@ async function fetchWeeklyList({
const
result
=
await
fetchWeeklyAdapter
({
merchantId
,
staffUuid
,
sceneType
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
,
reportStartDate
,
reportEndDate
...
...
@@ -433,6 +472,7 @@ async function submitForm(payload = {}) {
module
.
exports
=
{
fetchMerchantBrandIds
,
fetchMerchantScene
,
fetchDailyReportCarBrandList
,
fetchPageContext
,
fetchReportDetail
,
fetchDiscussionStaffList
,
...
...
packageDynamicForm/api/negotiationDailyReportAdapters.js
View file @
1432781
...
...
@@ -33,6 +33,8 @@ const {
DYNAMIC_FORM_TEMPLATE_MODULE
}
=
require
(
'../config/configCenter.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
}
=
require
(
'../config/dailyReportConstants.js'
)
const
{
resolveSceneType
}
=
require
(
'../utils/user-merchant.js'
)
const
{
normalizeSceneCodeListToSceneList
}
=
require
(
'./dailyReportCarBrand.js'
)
const
MOCK_DISCUSSION_STAFF_LIST
=
[
{
staffName
:
'张三'
,
staffUuid
:
'uuid-staff-001'
},
...
...
@@ -93,11 +95,12 @@ async function fetchDetailAdapter(params = {}) {
return
requireMockNegotiationDynamicDetail
().
fetchMockNegotiationDynamicDetail
(
params
)
}
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
staffUuid
,
reportDate
}
=
params
const
{
merchantId
,
staffUuid
,
reportDate
,
sceneType
}
=
params
return
dailyReportDetailGet
({
merchantId
,
staffUuid
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
})
}
...
...
@@ -132,7 +135,8 @@ async function fetchSchemaRootAdapter(params = {}) {
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async
function
fetchSceneAdapter
(
params
=
{})
{
const
{
merchantId
}
=
params
const
{
merchantId
,
staffUuid
,
sceneType
}
=
params
const
resolvedSceneType
=
resolveSceneType
({
sceneType
})
if
(
isNegotiationMockMode
(
'scene'
))
{
return
{
...
...
@@ -142,15 +146,23 @@ async function fetchSceneAdapter(params = {}) {
}
}
const
cached
=
getCachedScene
(
merchantId
)
const
cached
=
getCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
)
if
(
cached
)
{
return
cached
}
const
{
findAllSceneByMerchantId
}
=
getDynamicDailyReportApi
()
const
result
=
await
findAllSceneByMerchantId
({
merchantId
})
setCachedScene
(
merchantId
,
result
)
return
result
const
{
merchantBaseSceneCodeList
}
=
getDynamicDailyReportApi
()
const
result
=
await
merchantBaseSceneCodeList
({
staffUuid
,
merchantId
,
sceneType
:
resolvedSceneType
})
const
normalized
=
{
...
result
,
data
:
normalizeSceneCodeListToSceneList
(
result
?.
data
)
}
setCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
,
normalized
)
return
normalized
}
/**
...
...
@@ -198,11 +210,13 @@ async function fetchWeeklyAdapter(params = {}) {
staffUuid
,
reportStartDate
,
reportEndDate
,
sceneType
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
}
=
params
const
result
=
await
dailyReportWeeklyList
({
merchantId
,
staffUuid
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
,
reportStartDate
,
reportEndDate
...
...
@@ -230,8 +244,12 @@ async function fetchDiscussionStaffListAdapter(params = {}) {
}
}
const
{
dailyReportDiscussionStaffList
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
reportDate
}
=
params
const
result
=
await
dailyReportDiscussionStaffList
({
merchantId
,
reportDate
})
const
{
merchantId
,
reportDate
,
sceneType
}
=
params
const
result
=
await
dailyReportDiscussionStaffList
({
merchantId
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
})
})
if
(
result
?.
code
!=
0
)
{
return
result
}
...
...
packageDynamicForm/api/negotiationDailyReportCache.js
View file @
1432781
/**
* 洽谈明细进程内缓存 — scene / schema / brand
* key:scene
/
brand=merchantId;schema=reportTemplateId:baseSceneCode
* key:scene
=staffUuid:merchantId:sceneType;
brand=merchantId;schema=reportTemplateId:baseSceneCode
*/
const
sceneCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
brandCache
=
new
Map
()
function
getSceneCacheKey
(
staffUuid
,
merchantId
,
sceneType
)
{
return
`
${
staffUuid
||
''
}
:
${
merchantId
||
''
}
:
${
sceneType
??
0
}
`
}
/**
* 生成 schema 缓存键
* @param {number|string} reportTemplateId 模板 ID
...
...
@@ -21,20 +25,16 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
* @param {string|number} merchantId 门店 ID
* @returns {Object|null} 缓存的 API 响应
*/
function
getCachedScene
(
merchantId
)
{
if
(
!
merchantId
)
return
null
return
sceneCache
.
get
(
merchantId
)
||
null
function getCachedScene(staffUuid, merchantId, sceneType) {
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
if (!key || key === '::0') return null
return sceneCache.get(key) || null
}
/**
* 写入门店场景缓存
* @param {string|number} merchantId 门店 ID
* @param {Object} value API 响应
* @returns {void}
*/
function
setCachedScene
(
merchantId
,
value
)
{
if
(
!
merchantId
)
return
sceneCache
.
set
(
merchantId
,
value
)
function setCachedScene(staffUuid, merchantId, sceneType, value) {
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
if (!key || key === '::0') return
sceneCache.set(key, value)
}
/**
...
...
@@ -90,6 +90,7 @@ function clearNegotiationDailyReportCache() {
}
module.exports = {
getSceneCacheKey,
getSchemaCacheKey,
getCachedScene,
setCachedScene,
...
...
packageDynamicForm/api/staffDailyReport.js
View file @
1432781
...
...
@@ -37,6 +37,7 @@ const {
saveEchoAdapter
}
=
require
(
'./staffDailyReportAdapters.js'
)
const
{
isStaffMockMode
}
=
require
(
'../config/apiSwitch.js'
)
const
{
fetchDailyReportCarBrandList
:
fetchCarBrandListImpl
}
=
require
(
'./dailyReportCarBrand.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_SOURCE
...
...
@@ -72,7 +73,8 @@ function buildPageContextFromSources({
brandIds
=
[],
detail
=
{},
baseSceneCode
,
sceneList
sceneList
,
carBrandList
=
[]
}
=
{})
{
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
pageContext
=
buildPageContext
(
...
...
@@ -81,7 +83,13 @@ function buildPageContextFromSources({
normalized
,
sceneList
||
[]
)
return
enrichPageContextWithDetailEcho
(
pageContext
,
detail
)
const
enriched
=
enrichPageContextWithDetailEcho
(
pageContext
,
detail
)
return
{
...
enriched
,
sceneType
:
normalized
.
sceneType
,
yqMerchantName
:
normalized
.
yqMerchantName
,
carBrandList
:
Array
.
isArray
(
carBrandList
)
?
carBrandList
:
[]
}
}
/** 统一 API 响应结构 { code, message, data } */
...
...
@@ -111,7 +119,13 @@ function unwrapDetailPayload(result = {}) {
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @returns {Promise<{code: number, message: string, baseSceneCode: string|null, sceneList: Array}>}
*/
async
function
fetchMerchantScene
({
merchantId
,
detailBaseSceneCode
,
hasRecord
}
=
{})
{
async
function
fetchMerchantScene
({
merchantId
,
staffUuid
,
sceneType
,
detailBaseSceneCode
,
hasRecord
}
=
{})
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
...
...
@@ -120,7 +134,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
sceneList
:
[]
}
}
const
result
=
await
fetchSceneAdapter
({
merchantId
})
const
result
=
await
fetchSceneAdapter
({
merchantId
,
staffUuid
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
return
{
...
...
@@ -162,6 +176,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
}
}
async
function
fetchDailyReportCarBrandList
({
merchantId
,
sceneType
}
=
{})
{
return
fetchCarBrandListImpl
({
merchantId
,
sceneType
,
useMock
:
isStaffMockMode
(
'brand'
)
})
}
/**
* 组装表单 pageContext(品牌、场景、用户信息)
* @param {Object} [options={}]
...
...
@@ -169,6 +191,7 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Array} [options.carBrandList] 保存用车型列表
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async
function
fetchPageContext
(
options
=
{})
{
...
...
@@ -176,7 +199,8 @@ async function fetchPageContext(options = {}) {
userInfo
=
{},
brandIds
=
[],
detail
=
{},
merchantScene
=
{}
merchantScene
=
{},
carBrandList
=
[]
}
=
options
const
normalizedUser
=
normalizeUserInfo
(
userInfo
)
const
hasRecord
=
!!
detail
.
dailyReportRecordId
...
...
@@ -205,7 +229,8 @@ async function fetchPageContext(options = {}) {
brandIds
,
detail
,
baseSceneCode
,
sceneList
:
merchantScene
.
sceneList
||
[]
sceneList
:
merchantScene
.
sceneList
||
[],
carBrandList
})
}
}
...
...
@@ -232,7 +257,8 @@ async function fetchReportDetail({
merchantId
,
staffUuid
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
}
=
{})
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
return
{
...
...
@@ -246,7 +272,8 @@ async function fetchReportDetail({
merchantId
,
staffUuid
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapDetailPayload
(
result
)
if
(
code
!=
0
)
{
...
...
@@ -345,7 +372,8 @@ async function fetchWeeklyList({
merchantId
,
staffUuid
,
reportStartDate
,
reportEndDate
reportEndDate
,
sceneType
}
=
{})
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
...
...
@@ -353,6 +381,7 @@ async function fetchWeeklyList({
const
result
=
await
fetchWeeklyAdapter
({
merchantId
,
staffUuid
,
sceneType
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
staff
,
reportStartDate
,
reportEndDate
...
...
@@ -436,6 +465,7 @@ async function submitForm(payload = {}) {
module
.
exports
=
{
fetchMerchantBrandIds
,
fetchMerchantScene
,
fetchDailyReportCarBrandList
,
fetchPageContext
,
fetchReportDetail
,
fetchSchema
,
...
...
packageDynamicForm/api/staffDailyReportAdapters.js
View file @
1432781
...
...
@@ -22,6 +22,8 @@ const {
DYNAMIC_FORM_TEMPLATE_MODULE
}
=
require
(
'../config/configCenter.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
}
=
require
(
'../config/dailyReportConstants.js'
)
const
{
resolveSceneType
}
=
require
(
'../utils/user-merchant.js'
)
const
{
normalizeSceneCodeListToSceneList
}
=
require
(
'./dailyReportCarBrand.js'
)
let
fetchMerchantOperatingBrandListOverride
=
null
...
...
@@ -85,11 +87,12 @@ async function fetchDetailAdapter(params = {}) {
return
requireMockDynamicDetail
().
fetchMockDynamicDetail
(
params
)
}
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
staffUuid
,
reportDate
}
=
params
const
{
merchantId
,
staffUuid
,
reportDate
,
sceneType
}
=
params
return
dailyReportDetailGet
({
merchantId
,
staffUuid
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
staff
})
}
...
...
@@ -124,7 +127,8 @@ async function fetchSchemaRootAdapter(params = {}) {
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async
function
fetchSceneAdapter
(
params
=
{})
{
const
{
merchantId
}
=
params
const
{
merchantId
,
staffUuid
,
sceneType
}
=
params
const
resolvedSceneType
=
resolveSceneType
({
sceneType
})
if
(
isStaffMockMode
(
'scene'
))
{
return
{
...
...
@@ -134,15 +138,23 @@ async function fetchSceneAdapter(params = {}) {
}
}
const
cached
=
getCachedScene
(
merchantId
)
const
cached
=
getCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
)
if
(
cached
)
{
return
cached
}
const
{
findAllSceneByMerchantId
}
=
getDynamicDailyReportApi
()
const
result
=
await
findAllSceneByMerchantId
({
merchantId
})
setCachedScene
(
merchantId
,
result
)
return
result
const
{
merchantBaseSceneCodeList
}
=
getDynamicDailyReportApi
()
const
result
=
await
merchantBaseSceneCodeList
({
staffUuid
,
merchantId
,
sceneType
:
resolvedSceneType
})
const
normalized
=
{
...
result
,
data
:
normalizeSceneCodeListToSceneList
(
result
?.
data
)
}
setCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
,
normalized
)
return
normalized
}
/**
...
...
@@ -198,11 +210,13 @@ async function fetchWeeklyAdapter(params = {}) {
staffUuid
,
reportStartDate
,
reportEndDate
,
sceneType
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
staff
}
=
params
const
result
=
await
dailyReportWeeklyList
({
merchantId
,
staffUuid
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
,
reportStartDate
,
reportEndDate
...
...
packageDynamicForm/api/staffDailyReportCache.js
View file @
1432781
/**
* 驻店日报进程内缓存 — scene / schema / brand
* key:scene
/
brand=merchantId;schema=reportTemplateId:baseSceneCode
* key:scene
=staffUuid:merchantId:sceneType;
brand=merchantId;schema=reportTemplateId:baseSceneCode
*/
const
sceneCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
brandCache
=
new
Map
()
function
getSceneCacheKey
(
staffUuid
,
merchantId
,
sceneType
)
{
return
`
${
staffUuid
||
''
}
:
${
merchantId
||
''
}
:
${
sceneType
??
0
}
`
}
/**
* 生成 schema 缓存键
* @param {number|string} reportTemplateId 模板 ID
...
...
@@ -18,23 +22,29 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
/**
* 读取门店场景缓存
* @param {string} staffUuid 员工 UUID
* @param {string|number} merchantId 门店 ID
* @param {number|string} sceneType 业务场景
* @returns {Object|null} 缓存的 API 响应
*/
function
getCachedScene
(
merchantId
)
{
if
(
!
merchantId
)
return
null
return
sceneCache
.
get
(
merchantId
)
||
null
function getCachedScene(staffUuid, merchantId, sceneType) {
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
if (!key || key === '::0') return null
return sceneCache.get(key) || null
}
/**
* 写入门店场景缓存
* @param {string} staffUuid 员工 UUID
* @param {string|number} merchantId 门店 ID
* @param {number|string} sceneType 业务场景
* @param {Object} value API 响应
* @returns {void}
*/
function
setCachedScene
(
merchantId
,
value
)
{
if
(
!
merchantId
)
return
sceneCache
.
set
(
merchantId
,
value
)
function setCachedScene(staffUuid, merchantId, sceneType, value) {
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
if (!key || key === '::0') return
sceneCache.set(key, value)
}
/**
...
...
@@ -90,6 +100,7 @@ function clearStaffDailyReportCache() {
}
module.exports = {
getSceneCacheKey,
getSchemaCacheKey,
getCachedScene,
setCachedScene,
...
...
packageDynamicForm/api/storeDailyReport.js
View file @
1432781
...
...
@@ -43,6 +43,7 @@ const {
}
=
require
(
'./storeDailyReportAdapters.js'
)
const
{
normalizeReportStatus
}
=
require
(
'../utils/report-status.js'
)
const
{
isStoreMockMode
}
=
require
(
'../config/apiSwitch.js'
)
const
{
fetchDailyReportCarBrandList
:
fetchCarBrandListImpl
}
=
require
(
'./dailyReportCarBrand.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_SOURCE
}
=
require
(
'../config/dailyReportConstants.js'
)
const
{
...
...
@@ -126,7 +127,8 @@ function buildPageContextFromSources({
brandIds
=
[],
detail
=
{},
baseSceneCode
,
sceneList
sceneList
,
carBrandList
=
[]
}
=
{})
{
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
pageContext
=
buildPageContext
(
...
...
@@ -135,7 +137,13 @@ function buildPageContextFromSources({
normalized
,
sceneList
||
[]
)
return
enrichPageContextWithDetailEcho
(
pageContext
,
detail
)
const
enriched
=
enrichPageContextWithDetailEcho
(
pageContext
,
detail
)
return
{
...
enriched
,
sceneType
:
normalized
.
sceneType
,
yqMerchantName
:
normalized
.
yqMerchantName
,
carBrandList
:
Array
.
isArray
(
carBrandList
)
?
carBrandList
:
[]
}
}
/** 统一 API 响应结构 { code, message, data } */
...
...
@@ -155,7 +163,13 @@ function unwrapResponse(result = {}) {
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @returns {Promise<{code: number, message: string, baseSceneCode: string|null, sceneList: Array}>}
*/
async
function
fetchMerchantScene
({
merchantId
,
detailBaseSceneCode
,
hasRecord
}
=
{})
{
async
function
fetchMerchantScene
({
merchantId
,
staffUuid
,
sceneType
,
detailBaseSceneCode
,
hasRecord
}
=
{})
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
...
...
@@ -164,7 +178,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
sceneList
:
[]
}
}
const
result
=
await
fetchSceneAdapter
({
merchantId
})
const
result
=
await
fetchSceneAdapter
({
merchantId
,
staffUuid
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
return
{
...
...
@@ -206,6 +220,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
}
}
async
function
fetchDailyReportCarBrandList
({
merchantId
,
sceneType
}
=
{})
{
return
fetchCarBrandListImpl
({
merchantId
,
sceneType
,
useMock
:
isStoreMockMode
(
'brand'
)
})
}
/**
* 组装表单 pageContext(品牌、场景、用户信息)
* @param {Object} [options={}]
...
...
@@ -213,6 +235,7 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Array} [options.carBrandList] 保存用车型列表
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
async
function
fetchPageContext
(
options
=
{})
{
...
...
@@ -220,7 +243,8 @@ async function fetchPageContext(options = {}) {
userInfo
=
{},
brandIds
=
[],
detail
=
{},
merchantScene
=
{}
merchantScene
=
{},
carBrandList
=
[]
}
=
options
const
hasRecord
=
!!
detail
.
dailyReportRecordId
let
baseSceneCode
=
resolveBaseSceneCode
(
...
...
@@ -248,7 +272,8 @@ async function fetchPageContext(options = {}) {
brandIds
,
detail
,
baseSceneCode
,
sceneList
:
merchantScene
.
sceneList
||
[]
sceneList
:
merchantScene
.
sceneList
||
[],
carBrandList
})
}
}
...
...
@@ -276,7 +301,8 @@ async function fetchReportDetail({
merchantId
,
staffUuid
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
}
=
{})
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
return
{
...
...
@@ -290,7 +316,8 @@ async function fetchReportDetail({
merchantId
,
staffUuid
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
...
...
@@ -402,7 +429,8 @@ async function fetchWeeklyList({
merchantId
,
staffUuid
,
reportStartDate
,
reportEndDate
reportEndDate
,
sceneType
}
=
{})
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
...
...
@@ -410,6 +438,7 @@ async function fetchWeeklyList({
const
result
=
await
fetchWeeklyAdapter
({
merchantId
,
staffUuid
,
sceneType
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
,
reportStartDate
,
reportEndDate
...
...
@@ -527,7 +556,8 @@ async function saveDraftForm(payload = {}) {
reportTemplateId
,
dailyReportRecordId
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
,
dailyReportSource
:
DAILY_REPORT_SOURCE
.
miniapp
dailyReportSource
:
DAILY_REPORT_SOURCE
.
miniapp
,
forDraft
:
true
})
logStoreSaveRequestDebug
(
'[storeDailyReport] dynamic.draft.save 草稿数据结构'
,
saveRequest
)
const
result
=
await
saveDraftAdapter
(
saveRequest
)
...
...
@@ -556,17 +586,18 @@ async function saveDraftForm(payload = {}) {
* @param {string} [options.reportDate] YYYY-MM-DD
* @returns {Promise<{code: number, message: string, data: { pendingCount: number }|null}>}
*/
async
function
fetchMonthlyPendingCount
({
merchantId
,
reportDate
}
=
{})
{
async
function
fetchMonthlyPendingCount
({
merchantId
,
reportDate
,
sceneType
}
=
{})
{
if
(
!
merchantId
||
!
reportDate
)
{
return
{
code
:
10002
,
message
:
'merchantId 或 reportDate 不能为空'
,
data
:
null
}
}
const
result
=
await
fetchMonthlyPendingCountAdapter
({
merchantId
,
reportDate
})
const
result
=
await
fetchMonthlyPendingCountAdapter
({
merchantId
,
reportDate
,
sceneType
})
return
normalizeMonthlyPendingCountResponse
(
result
)
}
module
.
exports
=
{
fetchMerchantBrandIds
,
fetchMerchantScene
,
fetchDailyReportCarBrandList
,
fetchPageContext
,
fetchReportDetail
,
fetchSchema
,
...
...
packageDynamicForm/api/storeDailyReportAdapters.js
View file @
1432781
...
...
@@ -38,6 +38,8 @@ const {
DYNAMIC_FORM_TEMPLATE_MODULE
}
=
require
(
'../config/configCenter.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
}
=
require
(
'../config/dailyReportConstants.js'
)
const
{
resolveSceneType
}
=
require
(
'../utils/user-merchant.js'
)
const
{
normalizeSceneCodeListToSceneList
}
=
require
(
'./dailyReportCarBrand.js'
)
let
fetchMerchantOperatingBrandListOverride
=
null
...
...
@@ -85,11 +87,12 @@ async function fetchDetailAdapter(params = {}) {
return
requireMockStoreDynamicDetail
().
fetchMockStoreDynamicDetail
(
params
)
}
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
staffUuid
,
reportDate
}
=
params
const
{
merchantId
,
staffUuid
,
reportDate
,
sceneType
}
=
params
return
dailyReportDetailGet
({
merchantId
,
staffUuid
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
})
}
...
...
@@ -124,7 +127,8 @@ async function fetchSchemaRootAdapter(params = {}) {
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
async
function
fetchSceneAdapter
(
params
=
{})
{
const
{
merchantId
}
=
params
const
{
merchantId
,
staffUuid
,
sceneType
}
=
params
const
resolvedSceneType
=
resolveSceneType
({
sceneType
})
if
(
isStoreMockMode
(
'scene'
))
{
return
{
...
...
@@ -134,15 +138,23 @@ async function fetchSceneAdapter(params = {}) {
}
}
const
cached
=
getCachedScene
(
merchantId
)
const
cached
=
getCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
)
if
(
cached
)
{
return
cached
}
const
{
findAllSceneByMerchantId
}
=
getDynamicDailyReportApi
()
const
result
=
await
findAllSceneByMerchantId
({
merchantId
})
setCachedScene
(
merchantId
,
result
)
return
result
const
{
merchantBaseSceneCodeList
}
=
getDynamicDailyReportApi
()
const
result
=
await
merchantBaseSceneCodeList
({
staffUuid
,
merchantId
,
sceneType
:
resolvedSceneType
})
const
normalized
=
{
...
result
,
data
:
normalizeSceneCodeListToSceneList
(
result
?.
data
)
}
setCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
,
normalized
)
return
normalized
}
/**
...
...
@@ -198,11 +210,13 @@ async function fetchWeeklyAdapter(params = {}) {
staffUuid
,
reportStartDate
,
reportEndDate
,
sceneType
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
store
}
=
params
const
result
=
await
dailyReportWeeklyList
({
merchantId
,
staffUuid
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
,
reportStartDate
,
reportEndDate
...
...
@@ -270,7 +284,10 @@ async function fetchMonthlyPendingCountAdapter(params = {}) {
}
}
const
{
dailyReportMonthlyPendingCountGet
}
=
getDynamicDailyReportApi
()
return
dailyReportMonthlyPendingCountGet
(
params
)
return
dailyReportMonthlyPendingCountGet
({
...
params
,
sceneType
:
resolveSceneType
({
sceneType
:
params
.
sceneType
})
})
}
/**
...
...
packageDynamicForm/api/storeDailyReportCache.js
View file @
1432781
/**
* 门店日报进程内缓存 — scene / schema / brand
* key:scene
/
brand=merchantId;schema=reportTemplateId:baseSceneCode
* key:scene
=staffUuid:merchantId:sceneType;
brand=merchantId;schema=reportTemplateId:baseSceneCode
*/
const
sceneCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
brandCache
=
new
Map
()
function
getSceneCacheKey
(
staffUuid
,
merchantId
,
sceneType
)
{
return
`
${
staffUuid
||
''
}
:
${
merchantId
||
''
}
:
${
sceneType
??
0
}
`
}
/**
* 生成 schema 缓存键
* @param {number|string} reportTemplateId 模板 ID
...
...
@@ -21,20 +25,16 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
* @param {string|number} merchantId 门店 ID
* @returns {Object|null} 缓存的 API 响应
*/
function
getCachedScene
(
merchantId
)
{
if
(
!
merchantId
)
return
null
return
sceneCache
.
get
(
merchantId
)
||
null
function getCachedScene(staffUuid, merchantId, sceneType) {
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
if (!key || key === '::0') return null
return sceneCache.get(key) || null
}
/**
* 写入门店场景缓存
* @param {string|number} merchantId 门店 ID
* @param {Object} value API 响应
* @returns {void}
*/
function
setCachedScene
(
merchantId
,
value
)
{
if
(
!
merchantId
)
return
sceneCache
.
set
(
merchantId
,
value
)
function setCachedScene(staffUuid, merchantId, sceneType, value) {
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
if (!key || key === '::0') return
sceneCache.set(key, value)
}
/**
...
...
@@ -90,6 +90,7 @@ function clearStoreDailyReportCache() {
}
module.exports = {
getSceneCacheKey,
getSchemaCacheKey,
getCachedScene,
setCachedScene,
...
...
packageDynamicForm/components/negotiation-summary/negotiation-summary.js
View file @
1432781
...
...
@@ -10,6 +10,10 @@ Component({
merchantId
:
{
type
:
String
,
value
:
''
},
sceneType
:
{
type
:
null
,
value
:
0
}
},
...
...
@@ -88,7 +92,7 @@ Component({
},
async
loadStaffList
()
{
const
{
reportDate
,
merchantId
}
=
this
.
properties
const
{
reportDate
,
merchantId
,
sceneType
}
=
this
.
properties
if
(
!
reportDate
||
!
merchantId
)
return
this
.
setData
({
loading
:
true
,
...
...
@@ -102,7 +106,8 @@ Component({
try
{
const
res
=
await
negotiationApi
.
fetchDiscussionStaffList
({
merchantId
,
reportDate
reportDate
,
sceneType
})
if
(
res
.
code
!==
0
)
{
this
.
setData
({
...
...
@@ -131,7 +136,7 @@ Component({
},
async
loadStaffDetail
(
staff
=
{})
{
const
{
reportDate
,
merchantId
}
=
this
.
properties
const
{
reportDate
,
merchantId
,
sceneType
}
=
this
.
properties
if
(
!
staff
.
staffUuid
||
!
reportDate
||
!
merchantId
)
{
this
.
setData
({
sections
:
[],
sectionNavIndex
:
[]
})
return
...
...
@@ -141,7 +146,8 @@ Component({
const
res
=
await
negotiationApi
.
fetchReportDetail
({
merchantId
,
staffUuid
:
staff
.
staffUuid
,
reportDate
reportDate
,
sceneType
})
if
(
res
.
code
!==
0
||
!
res
.
data
)
{
this
.
setData
({
sections
:
[],
sectionNavIndex
:
[]
})
...
...
packageDynamicForm/docs/ARCHITECTURE.md
View file @
1432781
...
...
@@ -73,7 +73,7 @@ sequenceDiagram
| Schema | 配置中心数字键
`{ "0": field, ... }`
→
`{ list }`
|
`configCenter.normalizeConfigToSchemaRoot`
|
| 主营品牌 |
`merchants.api.open.merchant.info`
|
`carBrandApi`
→
`fetchBrandAdapter`
(按 merchantId 缓存) |
| 详情 |
`detail.get`
+
`jsonContent`
+
`subformDataList`
|
`fetchDetailAdapter`
→
`parseJsonContentDetailValues`
|
| 场景 |
`
findAllSceneByMerchantId`
|
`fetchSceneAdapter`
(按 merchantId
缓存) |
| 场景 |
`
staffBaseInfo.merchant.baseSceneCode.list`
(
`staffUuid`
+
`merchantId`
+
`sceneType`
) |
`fetchSceneAdapter`
(按
`staffUuid:merchantId:sceneType`
缓存) |
| 周历 |
`dailyReport.weekly.list`
|
`fetchWeeklyAdapter`
(页面独立刷新,不在 Loader 内) |
| 字段选项 |
`getEmployeeList`
等 |
`fieldOptionsAdapters`
+
`fieldOptionProviders`
|
...
...
packageDynamicForm/docs/DEVLOG.md
View file @
1432781
# DEVLOG — packageDynamicForm
## 2026-06-15 — 三份日报 sceneType 与 carBrandList
-
**接口**
:
`detail.get`
/
`weekly.list`
/
`discussion.staff.list`
/
`monthly.pending.get`
/
`dynamic.save`
/
`dynamic.draft.save`
增加
`sceneType`
;保存增加
`yqMerchantId`
、
`yqMerchantName`
;
`dynamic.save`
的
`requestJson`
增加
`carBrandList`
(来源
`staff.daily.report.car.brand`
)。
-
**场景**
:
`findAllSceneByMerchantId`
替换为
`staffBaseInfo.merchant.baseSceneCode.list`
(返参
`list<String>`
归一化为
`sceneList`
)。
-
**实现**
:
[
`dailyReportCarBrand.js`
](
../api/dailyReportCarBrand.js
)
、
[
`save-request.js`
](
../form-engine/save-request.js
)
、
[
`dailyReportBootstrap.js`
](
../services/dailyReportBootstrap.js
)
加载时并行拉取
`carBrandList`
写入
`pageContext`
。
## 2026-06-10 — F2-1 fieldDataList 从 jsonContent 还原 name(库内共用)
-
**现象**
:App 保存的 F2-1 jsonContent 为双 key(
`value`
展示串 +
`F2-1`
id 数组),
`buildAppNormalizedListsFromJsonContent`
产出的
`fieldDataList`
中
`name === id`
。
...
...
packageDynamicForm/docs/daily-report-save-and-json.md
View file @
1432781
...
...
@@ -36,7 +36,9 @@ sequenceDiagram
**显隐与持久化**
:模版级隐藏(调休、品牌/场景过滤等)
**仅隐藏 UI**
,不清
`values`
;
`jsonContent`
写入仍有值的隐藏块供再次编辑回显。
`fieldDataList`
/
`subformDataList`
/ 校验仍仅
**当前可见**
字段。subform 行内
`childrenShowRules`
联动切换仍清 hidden cell(如洽谈「是否成交」否)。
**HTTP 传输**
:
`fieldDataList`
/
`subformDataList`
不再作为顶层字段;由
[
`save-request.js`
](
../form-engine/save-request.js
)
组装
**`requestJson`**
(
`JSON.stringify({ fieldDataList, subformDataList? })`
,与
`jsonContent`
同级字符串)。空
`subformDataList`
在
`requestJson`
对象内
**不传**
;
`buildDailyReportSaveRequest`
返回值中的 lists 仍为数组,供 mock 回显。
**HTTP 传输**
:
`fieldDataList`
/
`subformDataList`
不再作为顶层字段;由
[
`save-request.js`
](
../form-engine/save-request.js
)
组装
**`requestJson`**
(
`JSON.stringify({ fieldDataList, subformDataList?, carBrandList? })`
,与
`jsonContent`
同级字符串)。空
`subformDataList`
在
`requestJson`
对象内
**不传**
;
`carBrandList`
仅在
**`dynamic.save` 正式提交**
时写入(草稿
`dynamic.draft.save`
不传)。
`buildDailyReportSaveRequest`
返回值中的 lists 仍为数组,供 mock 回显。
**顶层保存字段**
(三页共用):除原有
`merchantId`
/
`merchantName`
/
`staffUuid`
等外,增加
`yqMerchantId`
、
`yqMerchantName`
、
`sceneType`
(0 会员权益/升级,1 精品升级)。
`carBrandList`
来源:加载时
[
`staff.daily.report.car.brand`
](
../api/dailyReportCarBrand.js
)
写入
`pageContext.carBrandList`
。
**统一提交入口**
:
[
`buildAppDailyReportSubmitPayload`
](
../form-engine/app-subform-json.js
)
...
...
packageDynamicForm/fixtures/mock-meta.js
View file @
1432781
...
...
@@ -95,6 +95,8 @@ function buildPageContext(preset = {}, brandIds = [], userInfo = {}, sceneList =
shopMerchantId
:
userInfo
.
shopMerchantId
||
merchantId
||
''
,
shopMerchantName
,
yqMerchantId
:
resolveYqMerchantId
(
userInfo
,
merchantId
),
yqMerchantName
:
userInfo
.
yqMerchantName
||
userInfo
.
merchantName
||
''
,
sceneType
:
userInfo
.
sceneType
??
0
,
merchantName
:
shopMerchantName
,
staffName
:
userInfo
.
staffName
||
userInfo
.
name
||
''
}
...
...
packageDynamicForm/form-engine/save-request.js
View file @
1432781
...
...
@@ -4,23 +4,33 @@ const {
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_SOURCE
}
=
require
(
'../config/dailyReportConstants.js'
)
const
{
resolveSaveMerchantId
,
resolveShopMerchantName
}
=
require
(
'../utils/user-merchant.js'
)
const
{
resolveSaveMerchantId
,
resolveShopMerchantName
,
resolveYqMerchantId
,
resolveYqMerchantName
,
resolveSceneType
}
=
require
(
'../utils/user-merchant.js'
)
/** 组装 requestJson 对象并 JSON.stringify(与 jsonContent 同级字符串传输) */
function
buildRequestJsonForApi
(
fieldDataList
=
[],
subformDataList
=
[])
{
function
buildRequestJsonForApi
(
fieldDataList
=
[],
subformDataList
=
[]
,
options
=
{}
)
{
const
payload
=
{
fieldDataList
:
Array
.
isArray
(
fieldDataList
)
?
fieldDataList
:
[]
}
if
(
Array
.
isArray
(
subformDataList
)
&&
subformDataList
.
length
>
0
)
{
payload
.
subformDataList
=
subformDataList
}
const
carBrandList
=
options
.
carBrandList
if
(
Array
.
isArray
(
carBrandList
)
&&
carBrandList
.
length
>
0
)
{
payload
.
carBrandList
=
carBrandList
}
return
JSON
.
stringify
(
payload
)
}
/** 解析 save 请求体中的 requestJson(供 mock / 测试回显) */
function
parseRequestJsonLists
(
requestJson
)
{
if
(
requestJson
==
null
||
requestJson
===
''
)
{
return
{
fieldDataList
:
[],
subformDataList
:
[]
}
return
{
fieldDataList
:
[],
subformDataList
:
[]
,
carBrandList
:
[]
}
}
const
parsed
=
typeof
requestJson
===
'string'
?
JSON
.
parse
(
requestJson
)
:
requestJson
...
...
@@ -28,7 +38,8 @@ function parseRequestJsonLists(requestJson) {
fieldDataList
:
Array
.
isArray
(
parsed
.
fieldDataList
)
?
parsed
.
fieldDataList
:
[],
subformDataList
:
Array
.
isArray
(
parsed
.
subformDataList
)
?
parsed
.
subformDataList
:
[]
:
[],
carBrandList
:
Array
.
isArray
(
parsed
.
carBrandList
)
?
parsed
.
carBrandList
:
[]
}
}
...
...
@@ -44,7 +55,8 @@ function buildDailyReportSaveRequest({
reportTemplateId
,
dailyReportRecordId
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
staff
,
dailyReportSource
=
DAILY_REPORT_SOURCE
.
miniapp
dailyReportSource
=
DAILY_REPORT_SOURCE
.
miniapp
,
forDraft
=
false
}
=
{})
{
const
formPayload
=
buildSavePayloadByTemplateType
(
templateType
,
{
reportTemplateId
,
...
...
@@ -54,6 +66,12 @@ function buildDailyReportSaveRequest({
normalizedFieldDataList
:
templateType
===
DAILY_REPORT_TEMPLATE_TYPE
.
staff
})
const
carBrandList
=
pageContext
.
carBrandList
const
requestJsonOptions
=
!
forDraft
&&
Array
.
isArray
(
carBrandList
)
&&
carBrandList
.
length
>
0
?
{
carBrandList
}
:
{}
const
request
=
{
reportDate
,
merchantId
:
resolveSaveMerchantId
(
userContext
,
pageContext
),
...
...
@@ -65,6 +83,12 @@ function buildDailyReportSaveRequest({
userContext
.
merchantName
||
pageContext
.
merchantName
||
''
,
yqMerchantId
:
resolveYqMerchantId
(
userContext
,
pageContext
.
merchantId
),
yqMerchantName
:
resolveYqMerchantName
(
userContext
)
||
pageContext
.
yqMerchantName
||
''
,
sceneType
:
resolveSceneType
(
userContext
,
pageContext
.
sceneType
),
staffUuid
:
userContext
.
staffUuid
,
staffName
:
userContext
.
staffName
||
''
,
dailyReportSource
,
...
...
@@ -73,7 +97,8 @@ function buildDailyReportSaveRequest({
jsonContent
:
formPayload
.
jsonContent
,
requestJson
:
buildRequestJsonForApi
(
formPayload
.
fieldDataList
,
formPayload
.
subformDataList
formPayload
.
subformDataList
,
requestJsonOptions
)
}
...
...
packageDynamicForm/pages/negotiationDetail/negotiationDetail.js
View file @
1432781
...
...
@@ -397,6 +397,7 @@ Page({
const
res
=
await
negotiationApi
.
fetchWeeklyList
({
merchantId
:
ctx
.
merchantId
,
staffUuid
:
ctx
.
staffUuid
,
sceneType
:
ctx
.
sceneType
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportEndDate
:
timeBean
.
reportEndDate
})
...
...
packageDynamicForm/pages/staffDailyReport/staffDailyReport.js
View file @
1432781
...
...
@@ -254,6 +254,7 @@ Page({
const
res
=
await
staffDailyApi
.
fetchWeeklyList
({
merchantId
:
ctx
.
merchantId
,
staffUuid
:
ctx
.
staffUuid
,
sceneType
:
ctx
.
sceneType
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportEndDate
:
timeBean
.
reportEndDate
})
...
...
@@ -279,7 +280,8 @@ Page({
yqMerchantId
:
ctx
.
yqMerchantId
||
''
,
staffUuid
:
ctx
.
staffUuid
||
''
,
reportDate
:
this
.
data
.
reportDate
||
''
,
reportType
:
'staff'
reportType
:
'staff'
,
sceneType
:
ctx
.
sceneType
??
0
}
},
...
...
packageDynamicForm/pages/storeDailyReport/storeDailyReport.js
View file @
1432781
...
...
@@ -319,6 +319,7 @@ Page({
const
res
=
await
storeDailyApi
.
fetchWeeklyList
({
merchantId
:
ctx
.
merchantId
,
staffUuid
:
ctx
.
staffUuid
,
sceneType
:
ctx
.
sceneType
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportEndDate
:
timeBean
.
reportEndDate
})
...
...
@@ -465,7 +466,8 @@ Page({
try
{
const
res
=
await
storeDailyApi
.
fetchMonthlyPendingCount
({
merchantId
,
reportDate
reportDate
,
sceneType
:
(
this
.
userContext
||
this
.
getRequestContext
()).
sceneType
})
if
(
this
.
isStaleLoad
(
seq
))
{
return
...
...
packageDynamicForm/pages/storeDailyReport/storeDailyReport.wxml
View file @
1432781
...
...
@@ -35,6 +35,7 @@
class="summary-panel__inner"
reportDate="{{ reportDate }}"
merchantId="{{ requestContext.merchantId }}"
sceneType="{{ requestContext.sceneType }}"
bind:close="closeNegotiationSummary"
></negotiation-summary>
</view>
...
...
packageDynamicForm/services/dailyReportBootstrap.js
View file @
1432781
...
...
@@ -14,14 +14,23 @@ async function loadDailyForm(options = {}, api) {
}
const
{
userContext
,
reportDate
,
reportTemplateId
}
=
options
const
[
brandRes
,
sceneRes
,
detailRes
]
=
await
Promise
.
all
([
const
[
brandRes
,
sceneRes
,
detailRes
,
carBrandRes
]
=
await
Promise
.
all
([
api
.
fetchMerchantBrandIds
({
merchantId
:
userContext
.
merchantId
}),
api
.
fetchMerchantScene
({
merchantId
:
userContext
.
merchantId
}),
api
.
fetchMerchantScene
({
merchantId
:
userContext
.
merchantId
,
staffUuid
:
userContext
.
staffUuid
,
sceneType
:
userContext
.
sceneType
}),
api
.
fetchReportDetail
({
merchantId
:
userContext
.
merchantId
,
staffUuid
:
userContext
.
staffUuid
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
:
userContext
.
sceneType
}),
api
.
fetchDailyReportCarBrandList
({
merchantId
:
userContext
.
merchantId
,
sceneType
:
userContext
.
sceneType
})
])
...
...
@@ -37,13 +46,17 @@ async function loadDailyForm(options = {}, api) {
if
(
detailRes
.
code
!==
0
)
{
return
{
code
:
detailRes
.
code
,
message
:
detailRes
.
message
||
'获取日报详情失败'
,
data
:
null
}
}
if
(
carBrandRes
.
code
!==
0
)
{
return
{
code
:
carBrandRes
.
code
,
message
:
carBrandRes
.
message
||
'获取车型失败'
,
data
:
null
}
}
const
detail
=
detailRes
.
data
||
{}
const
pageContextRes
=
await
api
.
fetchPageContext
({
userInfo
:
userContext
,
brandIds
:
brandRes
.
data
||
[],
detail
,
merchantScene
:
sceneRes
merchantScene
:
sceneRes
,
carBrandList
:
carBrandRes
.
data
||
[]
})
if
(
pageContextRes
.
code
!==
0
||
!
pageContextRes
.
data
)
{
return
{
...
...
packageDynamicForm/tests/dailyReportCarBrand.test.mjs
0 → 100644
View file @
1432781
import { describe, it, beforeEach } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
normalizeCarBrandListForSave,
normalizeSceneCodeListToSceneList,
fetchDailyReportCarBrandList,
clearDailyReportCarBrandCache,
__setStaffDailyReportCarBrand
} = require('../api/dailyReportCarBrand.js')
describe('dailyReportCarBrand', () => {
beforeEach(() => {
clearDailyReportCarBrandCache()
__setStaffDailyReportCarBrand(null)
})
it('normalizeCarBrandListForSave maps four fields', () => {
const list = normalizeCarBrandListForSave([
{
firstBrandId: 3454,
firstBrandName: '问界',
brandId: 3454,
brandName: 'AITO',
brandType: 0
}
])
assert.deepEqual(list, [
{
firstBrandId: 3454,
firstBrandName: '问界',
brandId: 3454,
brandName: 'AITO'
}
])
})
it('normalizeCarBrandListForSave uses firstBrandName when brandId is -1', () => {
const list = normalizeCarBrandListForSave([
{
firstBrandId: 999,
firstBrandName: '自定义品牌',
brandId: -1,
brandName: ''
}
])
assert.equal(list[0].brandName, '自定义品牌')
})
it('normalizeSceneCodeListToSceneList converts string codes', () => {
assert.deepEqual(normalizeSceneCodeListToSceneList(['110201', '100101']), [
{ baseSceneCode: 110201 },
{ baseSceneCode: 100101 }
])
})
it('fetchDailyReportCarBrandList uses mock fixture when useMock', async () => {
const res = await fetchDailyReportCarBrandList({
merchantId: 'm1',
sceneType: 1,
useMock: true
})
assert.equal(res.code, 0)
assert.equal(res.data.length, 2)
})
it('fetchDailyReportCarBrandList caches by merchantId and sceneType', async () => {
let calls = 0
__setStaffDailyReportCarBrand(async () => {
calls += 1
return {
code: 0,
data: [{ firstBrandId: 1, firstBrandName: 'A', brandId: 1, brandName: 'A' }]
}
})
await fetchDailyReportCarBrandList({ merchantId: 'm1', sceneType: 0 })
await fetchDailyReportCarBrandList({ merchantId: 'm1', sceneType: 0 })
assert.equal(calls, 1)
})
})
packageDynamicForm/tests/dailyReportSaveRequest.test.mjs
View file @
1432781
...
...
@@ -329,6 +329,88 @@ describe('dailyReportSaveRequest', async () => {
(unified.fieldDataList || []).every(item => !item.groupKey && item.fieldType !== 'subform')
)
})
it('includes yqMerchantId, yqMerchantName, sceneType and requestJson.carBrandList on submit', () => {
const engine = createFormEngine(schema)
const carBrandList = [
{
firstBrandId: 3454,
firstBrandName: '问界',
brandId: 3454,
brandName: 'AITO'
}
]
engine.setPageContext({
baseSceneCode: 100101,
brandIds: [3454],
merchantId: 1001,
yqMerchantId: 3003,
yqMerchantName: '园区店A',
sceneType: 1,
carBrandList,
sceneList: [{ baseSceneCode: 100101 }]
})
engine.setFieldValue('F1-1', '在岗')
const { request } = buildDailyReportSaveRequest({
reportDate: '2026-05-27',
userContext: {
merchantId: 1001,
yqMerchantId: 3003,
yqMerchantName: '园区店A',
sceneType: 1,
staffUuid: 's1',
staffName: '李四'
},
pageContext: engine.getPageContext(),
engine,
reportTemplateId: 10001
})
assert.equal(request.yqMerchantId, 3003)
assert.equal(request.yqMerchantName, '园区店A')
assert.equal(request.sceneType, 1)
const lists = parseRequestJsonLists(request.requestJson)
assert.deepEqual(lists.carBrandList, carBrandList)
})
it('draft save omits requestJson.carBrandList but keeps top-level scene fields', () => {
const engine = createFormEngine(schema)
engine.setPageContext({
baseSceneCode: 100101,
brandIds: [3454],
merchantId: 1001,
yqMerchantId: 3003,
yqMerchantName: '园区店A',
sceneType: 0,
carBrandList: [{ firstBrandId: 1, firstBrandName: 'A', brandId: 1, brandName: 'A' }],
sceneList: [{ baseSceneCode: 100101 }]
})
engine.setFieldValue('F1-1', '在岗')
const { request } = buildDailyReportSaveRequest({
reportDate: '2026-05-27',
userContext: {
merchantId: 1001,
yqMerchantId: 3003,
yqMerchantName: '园区店A',
sceneType: 0,
staffUuid: 's1',
staffName: '李四'
},
pageContext: engine.getPageContext(),
engine,
reportTemplateId: 10002,
templateType: DAILY_REPORT_TEMPLATE_TYPE.store,
forDraft: true
})
assert.equal(request.yqMerchantId, 3003)
assert.equal(request.sceneType, 0)
const lists = parseRequestJsonLists(request.requestJson)
assert.deepEqual(lists.carBrandList, [])
assert.equal(lists.fieldDataList.length > 0, true)
})
})
describe('mockDynamicDetail staff sample', () => {
...
...
packageDynamicForm/tests/dailyReportWeeklyList.test.mjs
View file @
1432781
...
...
@@ -34,11 +34,13 @@ describe('dailyReportWeeklyList adapters', () => {
const res = await staffAdapters.fetchWeeklyAdapter({
merchantId: 1001,
staffUuid: 'uuid-1',
sceneType: 1,
reportStartDate: '2026-05-20',
reportEndDate: '2026-05-26'
})
assert.equal(captured.merchantId, 1001)
assert.equal(captured.staffUuid, 'uuid-1')
assert.equal(captured.sceneType, 1)
assert.equal(captured.templateType, DAILY_REPORT_TEMPLATE_TYPE.staff)
assert.equal(captured.reportStartDate, '2026-05-20')
assert.equal(captured.reportEndDate, '2026-05-26')
...
...
packageDynamicForm/tests/negotiation-discussion-staff.test.mjs
View file @
1432781
...
...
@@ -37,12 +37,14 @@ describe('negotiation discussion staff list', () => {
try {
const res = await adapters.fetchDiscussionStaffListAdapter({
merchantId: 'shop-001',
reportDate: '2026-06-02'
reportDate: '2026-06-02',
sceneType: 0
})
assert.equal(res.code, 0)
assert.equal(res.data.length, 1)
assert.equal(captured.merchantId, 'shop-001')
assert.equal(captured.reportDate, '2026-06-02')
assert.equal(captured.sceneType, 0)
} finally {
adapters.__setDynamicDailyReportApi(null)
NEGOTIATION_DAILY_API_SWITCH.discussionStaffList = original
...
...
packageDynamicForm/tests/negotiationDailyFormLoader.test.mjs
View file @
1432781
...
...
@@ -30,6 +30,7 @@ function createDeps(overrides = {}) {
values: {}
}
}),
fetchDailyReportCarBrandList: async () => ({ code: 0, data: [] }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchSchema: async () => ({
code: 0,
...
...
packageDynamicForm/tests/staffDailyFormLoader.test.mjs
View file @
1432781
...
...
@@ -31,6 +31,7 @@ function createDeps(overrides = {}) {
values: {}
}
}),
fetchDailyReportCarBrandList: async () => ({ code: 0, data: [] }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchSchema: async () => ({
code: 0,
...
...
packageDynamicForm/tests/staffDailyReportAdapters.test.mjs
View file @
1432781
...
...
@@ -92,11 +92,13 @@ describe('staffDailyReportAdapters', () => {
merchantId: 'm1',
staffUuid: 's1',
reportDate: '2026-05-26',
sceneType: 1,
reportTemplateId: 10001
})
assert.equal(captured.merchantId, 'm1')
assert.equal(captured.staffUuid, 's1')
assert.equal(captured.reportDate, '2026-05-26')
assert.equal(captured.sceneType, 1)
assert.equal(captured.templateType, DAILY_REPORT_TEMPLATE_TYPE.staff)
assert.equal(captured.reportTemplateId, undefined)
} finally {
...
...
@@ -167,20 +169,52 @@ describe('staffDailyReportAdapters', () => {
it('fetchSceneAdapter caches scene list for merchant', async () => {
let calls = 0
adapters.__setDynamicDailyReportApi({
findAllSceneByMerchantId
: async () => {
merchantBaseSceneCodeList
: async () => {
calls += 1
return { code: 0, message: 'ok', data: [
{ baseSceneCode: 100101, sceneType: 1 }
] }
return { code: 0, message: 'ok', data: [
'100101'
] }
}
})
try {
await adapters.fetchSceneAdapter({ merchantId: 'm-cache' })
await adapters.fetchSceneAdapter({ merchantId: 'm-cache' })
await adapters.fetchSceneAdapter({
merchantId: 'm-cache',
staffUuid: 's1',
sceneType: 1
})
await adapters.fetchSceneAdapter({
merchantId: 'm-cache',
staffUuid: 's1',
sceneType: 1
})
assert.equal(calls, 1)
} finally {
adapters.__setDynamicDailyReportApi(null)
}
})
it('fetchSceneAdapter normalizes baseSceneCode list strings', async () => {
adapters.__setDynamicDailyReportApi({
merchantBaseSceneCodeList: async () => ({
code: 0,
message: 'ok',
data: ['110201', '100101']
})
})
try {
const res = await adapters.fetchSceneAdapter({
merchantId: 'm1',
staffUuid: 's1',
sceneType: 0
})
assert.equal(res.code, 0)
assert.deepEqual(res.data, [
{ baseSceneCode: 110201 },
{ baseSceneCode: 100101 }
])
} finally {
adapters.__setDynamicDailyReportApi(null)
}
})
it('fetchBrandAdapter mock mode returns fixture brand list', async () => {
const original = STAFF_DAILY_API_SWITCH.brand
STAFF_DAILY_API_SWITCH.brand = 'mock'
...
...
packageDynamicForm/tests/storeDailyFormLoader.test.mjs
View file @
1432781
...
...
@@ -30,6 +30,7 @@ function createDeps(overrides = {}) {
values: {}
}
}),
fetchDailyReportCarBrandList: async () => ({ code: 0, data: [] }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchSchema: async () => ({
code: 0,
...
...
packageDynamicForm/tests/storeDailyReportAdapters.test.mjs
View file @
1432781
...
...
@@ -501,14 +501,22 @@ describe('storeDailyReportAdapters', () => {
it('fetchSceneAdapter caches scene list for merchant', async () => {
let calls = 0
adapters.__setDynamicDailyReportApi({
findAllSceneByMerchantId
: async () => {
merchantBaseSceneCodeList
: async () => {
calls += 1
return { code: 0, message: 'ok', data: [
{ baseSceneCode: 110201, sceneType: 0 }
] }
return { code: 0, message: 'ok', data: [
'110201'
] }
}
})
try {
await adapters.fetchSceneAdapter({ merchantId: 'm-store-cache' })
await adapters.fetchSceneAdapter({ merchantId: 'm-store-cache' })
await adapters.fetchSceneAdapter({
merchantId: 'm-store-cache',
staffUuid: 's1',
sceneType: 0
})
await adapters.fetchSceneAdapter({
merchantId: 'm-store-cache',
staffUuid: 's1',
sceneType: 0
})
assert.equal(calls, 1)
} finally {
adapters.__setDynamicDailyReportApi(null)
...
...
packageDynamicForm/tests/storeMonthlyPendingCount.test.mjs
View file @
1432781
...
...
@@ -111,10 +111,12 @@ describe('fetchMonthlyPendingCount', () => {
try {
const res = await adapters.fetchMonthlyPendingCountAdapter({
merchantId: '4s-2',
reportDate: '2026-06-03'
reportDate: '2026-06-03',
sceneType: 1
})
assert.equal(captured.merchantId, '4s-2')
assert.equal(captured.reportDate, '2026-06-03')
assert.equal(captured.sceneType, 1)
assert.equal(res.data.pendingCount, 7)
} finally {
adapters.__setDynamicDailyReportApi(null)
...
...
packageDynamicForm/utils/user-merchant.js
View file @
1432781
...
...
@@ -29,6 +29,25 @@ function resolveYqMerchantId(userInfo = {}, shopMerchantId = '') {
return
userInfo
.
yqMerchantId
||
userInfo
.
merchantId
||
shopMerchantId
||
''
}
/** 园区店名称:保存 yqMerchantName */
function
resolveYqMerchantName
(
userInfo
=
{},
hint
)
{
if
(
hint
!=
null
&&
hint
!==
''
)
{
return
hint
}
return
userInfo
.
yqMerchantName
||
userInfo
.
merchantName
||
''
}
/** 业务场景:0 会员权益/升级,1 精品升级 */
function
resolveSceneType
(
userInfo
=
{},
hint
)
{
if
(
hint
!=
null
&&
hint
!==
''
)
{
return
hint
}
if
(
userInfo
.
sceneType
!=
null
&&
userInfo
.
sceneType
!==
''
)
{
return
userInfo
.
sceneType
}
return
0
}
/**
* 从单份上下文解析 4S merchantId(已 normalize 的 merchantId 可作为兜底)
* @param {Object} [ctx={}]
...
...
@@ -75,6 +94,8 @@ function normalizeDailyReportUserInfo(userInfo = {}) {
shopMerchantId
,
shopMerchantName
,
yqMerchantId
:
resolveYqMerchantId
(
userInfo
,
merchantId
),
yqMerchantName
:
resolveYqMerchantName
(
userInfo
),
sceneType
:
resolveSceneType
(
userInfo
),
staffUuid
:
userInfo
.
uuid
||
userInfo
.
staffUuid
||
''
,
baseSceneCode
:
userInfo
.
baseSceneCode
,
merchantName
:
shopMerchantName
,
...
...
@@ -86,6 +107,8 @@ module.exports = {
resolveShopMerchantId
,
resolveShopMerchantName
,
resolveYqMerchantId
,
resolveYqMerchantName
,
resolveSceneType
,
resolveSaveMerchantId
,
normalizeDailyReportUserInfo
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment