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
Show 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) {
...
@@ -32,6 +32,21 @@ function findAllSceneByMerchantId(data) {
return
api
.
post
(
'dj.api.scenemerchantref.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
)
{
function
dailyReportDiscussionStaffList
(
data
)
{
return
api
.
post
(
return
api
.
post
(
'dj.api.smartcarlife.dailyReport.discussion.staff.list'
,
'dj.api.smartcarlife.dailyReport.discussion.staff.list'
,
...
@@ -50,5 +65,7 @@ module.exports = {
...
@@ -50,5 +65,7 @@ module.exports = {
dailyReportDetailGet
,
dailyReportDetailGet
,
dailyReportMonthlyPendingCountGet
,
dailyReportMonthlyPendingCountGet
,
findAllSceneByMerchantId
,
findAllSceneByMerchantId
,
merchantBaseSceneCodeList
,
staffDailyReportCarBrand
,
dailyReportDiscussionStaffList
dailyReportDiscussionStaffList
}
}
packageDynamicForm/api/negotiationDailyReport.js
View file @
1432781
...
@@ -35,6 +35,7 @@ const {
...
@@ -35,6 +35,7 @@ const {
saveEchoAdapter
saveEchoAdapter
}
=
require
(
'./negotiationDailyReportAdapters.js'
)
}
=
require
(
'./negotiationDailyReportAdapters.js'
)
const
{
isNegotiationMockMode
}
=
require
(
'../config/apiSwitch.js'
)
const
{
isNegotiationMockMode
}
=
require
(
'../config/apiSwitch.js'
)
const
{
fetchDailyReportCarBrandList
:
fetchCarBrandListImpl
}
=
require
(
'./dailyReportCarBrand.js'
)
const
{
normalizeDailyReportUserInfo
}
=
require
(
'../utils/user-merchant.js'
)
const
{
normalizeDailyReportUserInfo
}
=
require
(
'../utils/user-merchant.js'
)
const
{
const
{
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_TEMPLATE_TYPE
,
...
@@ -67,11 +68,18 @@ function buildPageContextFromSources({
...
@@ -67,11 +68,18 @@ function buildPageContextFromSources({
brandIds
=
[],
brandIds
=
[],
detail
=
{},
detail
=
{},
baseSceneCode
,
baseSceneCode
,
sceneList
sceneList
,
carBrandList
=
[]
}
=
{})
{
}
=
{})
{
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
pageContext
=
buildPageContext
({
baseSceneCode
},
brandIds
,
normalized
,
sceneList
||
[])
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 } */
/** 统一 API 响应结构 { code, message, data } */
...
@@ -91,7 +99,13 @@ function unwrapResponse(result = {}) {
...
@@ -91,7 +99,13 @@ function unwrapResponse(result = {}) {
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @returns {Promise<{code: number, message: string, baseSceneCode: string|null, sceneList: Array}>}
* @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
)
{
if
(
!
merchantId
)
{
return
{
return
{
code
:
0
,
code
:
0
,
...
@@ -100,7 +114,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
...
@@ -100,7 +114,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
sceneList
:
[]
sceneList
:
[]
}
}
}
}
const
result
=
await
fetchSceneAdapter
({
merchantId
})
const
result
=
await
fetchSceneAdapter
({
merchantId
,
staffUuid
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
{
return
{
...
@@ -142,6 +156,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
...
@@ -142,6 +156,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
}
}
}
}
async
function
fetchDailyReportCarBrandList
({
merchantId
,
sceneType
}
=
{})
{
return
fetchCarBrandListImpl
({
merchantId
,
sceneType
,
useMock
:
isNegotiationMockMode
(
'brand'
)
})
}
/**
/**
* 组装表单 pageContext(品牌、场景、用户信息)
* 组装表单 pageContext(品牌、场景、用户信息)
* @param {Object} [options={}]
* @param {Object} [options={}]
...
@@ -149,10 +171,17 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
...
@@ -149,10 +171,17 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Array} [options.carBrandList] 保存用车型列表
* @returns {Promise<{code: number, message: string, data: Object|null}>}
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
*/
async
function
fetchPageContext
(
options
=
{})
{
async
function
fetchPageContext
(
options
=
{})
{
const
{
userInfo
=
{},
brandIds
=
[],
detail
=
{},
merchantScene
=
{}
}
=
options
const
{
userInfo
=
{},
brandIds
=
[],
detail
=
{},
merchantScene
=
{},
carBrandList
=
[]
}
=
options
const
hasRecord
=
!!
detail
.
dailyReportRecordId
const
hasRecord
=
!!
detail
.
dailyReportRecordId
let
baseSceneCode
=
resolveBaseSceneCode
(
let
baseSceneCode
=
resolveBaseSceneCode
(
merchantScene
.
sceneList
||
[],
merchantScene
.
sceneList
||
[],
...
@@ -179,7 +208,8 @@ async function fetchPageContext(options = {}) {
...
@@ -179,7 +208,8 @@ async function fetchPageContext(options = {}) {
brandIds
,
brandIds
,
detail
,
detail
,
baseSceneCode
,
baseSceneCode
,
sceneList
:
merchantScene
.
sceneList
||
[]
sceneList
:
merchantScene
.
sceneList
||
[],
carBrandList
})
})
}
}
}
}
...
@@ -202,7 +232,13 @@ function buildEmptyDetail(reportTemplateId) {
...
@@ -202,7 +232,13 @@ function buildEmptyDetail(reportTemplateId) {
* @param {number|string} [options.reportTemplateId] 模板 ID
* @param {number|string} [options.reportTemplateId] 模板 ID
* @returns {Promise<{code: number, message: string, data: Object|null}>}
* @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
)
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
return
{
return
{
code
:
0
,
code
:
0
,
...
@@ -215,7 +251,8 @@ async function fetchReportDetail({ merchantId, staffUuid, reportDate, reportTemp
...
@@ -215,7 +251,8 @@ async function fetchReportDetail({ merchantId, staffUuid, reportDate, reportTemp
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
})
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -313,11 +350,11 @@ function resolveSchemaDetailValues(detail, schemaList = [], fallbackValues = {})
...
@@ -313,11 +350,11 @@ function resolveSchemaDetailValues(detail, schemaList = [], fallbackValues = {})
* @param {string} [options.reportDate] 报表日期 YYYY-MM-DD
* @param {string} [options.reportDate] 报表日期 YYYY-MM-DD
* @returns {Promise<{code: number, message: string, data: Array}>}
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
*/
async
function
fetchDiscussionStaffList
({
merchantId
,
reportDate
}
=
{})
{
async
function
fetchDiscussionStaffList
({
merchantId
,
reportDate
,
sceneType
}
=
{})
{
if
(
!
merchantId
||
!
reportDate
)
{
if
(
!
merchantId
||
!
reportDate
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
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
)
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
{
code
:
code
??
-
1
,
message
,
data
:
[]
}
return
{
code
:
code
??
-
1
,
message
,
data
:
[]
}
...
@@ -342,7 +379,8 @@ async function fetchWeeklyList({
...
@@ -342,7 +379,8 @@ async function fetchWeeklyList({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
,
sceneType
}
=
{})
{
}
=
{})
{
if
(
!
merchantId
)
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
...
@@ -350,6 +388,7 @@ async function fetchWeeklyList({
...
@@ -350,6 +388,7 @@ async function fetchWeeklyList({
const
result
=
await
fetchWeeklyAdapter
({
const
result
=
await
fetchWeeklyAdapter
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
sceneType
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
...
@@ -433,6 +472,7 @@ async function submitForm(payload = {}) {
...
@@ -433,6 +472,7 @@ async function submitForm(payload = {}) {
module
.
exports
=
{
module
.
exports
=
{
fetchMerchantBrandIds
,
fetchMerchantBrandIds
,
fetchMerchantScene
,
fetchMerchantScene
,
fetchDailyReportCarBrandList
,
fetchPageContext
,
fetchPageContext
,
fetchReportDetail
,
fetchReportDetail
,
fetchDiscussionStaffList
,
fetchDiscussionStaffList
,
...
...
packageDynamicForm/api/negotiationDailyReportAdapters.js
View file @
1432781
...
@@ -33,6 +33,8 @@ const {
...
@@ -33,6 +33,8 @@ const {
DYNAMIC_FORM_TEMPLATE_MODULE
DYNAMIC_FORM_TEMPLATE_MODULE
}
=
require
(
'../config/configCenter.js'
)
}
=
require
(
'../config/configCenter.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
}
=
require
(
'../config/dailyReportConstants.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
=
[
const
MOCK_DISCUSSION_STAFF_LIST
=
[
{
staffName
:
'张三'
,
staffUuid
:
'uuid-staff-001'
},
{
staffName
:
'张三'
,
staffUuid
:
'uuid-staff-001'
},
...
@@ -93,11 +95,12 @@ async function fetchDetailAdapter(params = {}) {
...
@@ -93,11 +95,12 @@ async function fetchDetailAdapter(params = {}) {
return
requireMockNegotiationDynamicDetail
().
fetchMockNegotiationDynamicDetail
(
params
)
return
requireMockNegotiationDynamicDetail
().
fetchMockNegotiationDynamicDetail
(
params
)
}
}
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
staffUuid
,
reportDate
}
=
params
const
{
merchantId
,
staffUuid
,
reportDate
,
sceneType
}
=
params
return
dailyReportDetailGet
({
return
dailyReportDetailGet
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
})
})
}
}
...
@@ -132,7 +135,8 @@ async function fetchSchemaRootAdapter(params = {}) {
...
@@ -132,7 +135,8 @@ async function fetchSchemaRootAdapter(params = {}) {
* @returns {Promise<{code: number, message: string, data: Array}>}
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
*/
async
function
fetchSceneAdapter
(
params
=
{})
{
async
function
fetchSceneAdapter
(
params
=
{})
{
const
{
merchantId
}
=
params
const
{
merchantId
,
staffUuid
,
sceneType
}
=
params
const
resolvedSceneType
=
resolveSceneType
({
sceneType
})
if
(
isNegotiationMockMode
(
'scene'
))
{
if
(
isNegotiationMockMode
(
'scene'
))
{
return
{
return
{
...
@@ -142,15 +146,23 @@ async function fetchSceneAdapter(params = {}) {
...
@@ -142,15 +146,23 @@ async function fetchSceneAdapter(params = {}) {
}
}
}
}
const
cached
=
getCachedScene
(
merchantId
)
const
cached
=
getCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
)
if
(
cached
)
{
if
(
cached
)
{
return
cached
return
cached
}
}
const
{
findAllSceneByMerchantId
}
=
getDynamicDailyReportApi
()
const
{
merchantBaseSceneCodeList
}
=
getDynamicDailyReportApi
()
const
result
=
await
findAllSceneByMerchantId
({
merchantId
})
const
result
=
await
merchantBaseSceneCodeList
({
setCachedScene
(
merchantId
,
result
)
staffUuid
,
return
result
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 = {}) {
...
@@ -198,11 +210,13 @@ async function fetchWeeklyAdapter(params = {}) {
staffUuid
,
staffUuid
,
reportStartDate
,
reportStartDate
,
reportEndDate
,
reportEndDate
,
sceneType
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
negotiation
}
=
params
}
=
params
const
result
=
await
dailyReportWeeklyList
({
const
result
=
await
dailyReportWeeklyList
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
,
templateType
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
...
@@ -230,8 +244,12 @@ async function fetchDiscussionStaffListAdapter(params = {}) {
...
@@ -230,8 +244,12 @@ async function fetchDiscussionStaffListAdapter(params = {}) {
}
}
}
}
const
{
dailyReportDiscussionStaffList
}
=
getDynamicDailyReportApi
()
const
{
dailyReportDiscussionStaffList
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
reportDate
}
=
params
const
{
merchantId
,
reportDate
,
sceneType
}
=
params
const
result
=
await
dailyReportDiscussionStaffList
({
merchantId
,
reportDate
})
const
result
=
await
dailyReportDiscussionStaffList
({
merchantId
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
})
})
if
(
result
?.
code
!=
0
)
{
if
(
result
?.
code
!=
0
)
{
return
result
return
result
}
}
...
...
packageDynamicForm/api/negotiationDailyReportCache.js
View file @
1432781
/**
/**
* 洽谈明细进程内缓存 — scene / schema / brand
* 洽谈明细进程内缓存 — 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
sceneCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
brandCache
=
new
Map
()
const
brandCache
=
new
Map
()
function
getSceneCacheKey
(
staffUuid
,
merchantId
,
sceneType
)
{
return
`
${
staffUuid
||
''
}
:
${
merchantId
||
''
}
:
${
sceneType
??
0
}
`
}
/**
/**
* 生成 schema 缓存键
* 生成 schema 缓存键
* @param {number|string} reportTemplateId 模板 ID
* @param {number|string} reportTemplateId 模板 ID
...
@@ -21,20 +25,16 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
...
@@ -21,20 +25,16 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
* @param {string|number} merchantId 门店 ID
* @param {string|number} merchantId 门店 ID
* @returns {Object|null} 缓存的 API 响应
* @returns {Object|null} 缓存的 API 响应
*/
*/
function
getCachedScene
(
merchantId
)
{
function getCachedScene(staffUuid, merchantId, sceneType) {
if
(
!
merchantId
)
return
null
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
return
sceneCache
.
get
(
merchantId
)
||
null
if (!key || key === '::0') return null
return sceneCache.get(key) || null
}
}
/**
function setCachedScene(staffUuid, merchantId, sceneType, value) {
* 写入门店场景缓存
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
* @param {string|number} merchantId 门店 ID
if (!key || key === '::0') return
* @param {Object} value API 响应
sceneCache.set(key, value)
* @returns {void}
*/
function
setCachedScene
(
merchantId
,
value
)
{
if
(
!
merchantId
)
return
sceneCache
.
set
(
merchantId
,
value
)
}
}
/**
/**
...
@@ -90,6 +90,7 @@ function clearNegotiationDailyReportCache() {
...
@@ -90,6 +90,7 @@ function clearNegotiationDailyReportCache() {
}
}
module.exports = {
module.exports = {
getSceneCacheKey,
getSchemaCacheKey,
getSchemaCacheKey,
getCachedScene,
getCachedScene,
setCachedScene,
setCachedScene,
...
...
packageDynamicForm/api/staffDailyReport.js
View file @
1432781
...
@@ -37,6 +37,7 @@ const {
...
@@ -37,6 +37,7 @@ const {
saveEchoAdapter
saveEchoAdapter
}
=
require
(
'./staffDailyReportAdapters.js'
)
}
=
require
(
'./staffDailyReportAdapters.js'
)
const
{
isStaffMockMode
}
=
require
(
'../config/apiSwitch.js'
)
const
{
isStaffMockMode
}
=
require
(
'../config/apiSwitch.js'
)
const
{
fetchDailyReportCarBrandList
:
fetchCarBrandListImpl
}
=
require
(
'./dailyReportCarBrand.js'
)
const
{
const
{
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_SOURCE
DAILY_REPORT_SOURCE
...
@@ -72,7 +73,8 @@ function buildPageContextFromSources({
...
@@ -72,7 +73,8 @@ function buildPageContextFromSources({
brandIds
=
[],
brandIds
=
[],
detail
=
{},
detail
=
{},
baseSceneCode
,
baseSceneCode
,
sceneList
sceneList
,
carBrandList
=
[]
}
=
{})
{
}
=
{})
{
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
pageContext
=
buildPageContext
(
const
pageContext
=
buildPageContext
(
...
@@ -81,7 +83,13 @@ function buildPageContextFromSources({
...
@@ -81,7 +83,13 @@ function buildPageContextFromSources({
normalized
,
normalized
,
sceneList
||
[]
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 } */
/** 统一 API 响应结构 { code, message, data } */
...
@@ -111,7 +119,13 @@ function unwrapDetailPayload(result = {}) {
...
@@ -111,7 +119,13 @@ function unwrapDetailPayload(result = {}) {
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @returns {Promise<{code: number, message: string, baseSceneCode: string|null, sceneList: Array}>}
* @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
)
{
if
(
!
merchantId
)
{
return
{
return
{
code
:
0
,
code
:
0
,
...
@@ -120,7 +134,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
...
@@ -120,7 +134,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
sceneList
:
[]
sceneList
:
[]
}
}
}
}
const
result
=
await
fetchSceneAdapter
({
merchantId
})
const
result
=
await
fetchSceneAdapter
({
merchantId
,
staffUuid
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
{
return
{
...
@@ -162,6 +176,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
...
@@ -162,6 +176,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
}
}
}
}
async
function
fetchDailyReportCarBrandList
({
merchantId
,
sceneType
}
=
{})
{
return
fetchCarBrandListImpl
({
merchantId
,
sceneType
,
useMock
:
isStaffMockMode
(
'brand'
)
})
}
/**
/**
* 组装表单 pageContext(品牌、场景、用户信息)
* 组装表单 pageContext(品牌、场景、用户信息)
* @param {Object} [options={}]
* @param {Object} [options={}]
...
@@ -169,6 +191,7 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
...
@@ -169,6 +191,7 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Array} [options.carBrandList] 保存用车型列表
* @returns {Promise<{code: number, message: string, data: Object|null}>}
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
*/
async
function
fetchPageContext
(
options
=
{})
{
async
function
fetchPageContext
(
options
=
{})
{
...
@@ -176,7 +199,8 @@ async function fetchPageContext(options = {}) {
...
@@ -176,7 +199,8 @@ async function fetchPageContext(options = {}) {
userInfo
=
{},
userInfo
=
{},
brandIds
=
[],
brandIds
=
[],
detail
=
{},
detail
=
{},
merchantScene
=
{}
merchantScene
=
{},
carBrandList
=
[]
}
=
options
}
=
options
const
normalizedUser
=
normalizeUserInfo
(
userInfo
)
const
normalizedUser
=
normalizeUserInfo
(
userInfo
)
const
hasRecord
=
!!
detail
.
dailyReportRecordId
const
hasRecord
=
!!
detail
.
dailyReportRecordId
...
@@ -205,7 +229,8 @@ async function fetchPageContext(options = {}) {
...
@@ -205,7 +229,8 @@ async function fetchPageContext(options = {}) {
brandIds
,
brandIds
,
detail
,
detail
,
baseSceneCode
,
baseSceneCode
,
sceneList
:
merchantScene
.
sceneList
||
[]
sceneList
:
merchantScene
.
sceneList
||
[],
carBrandList
})
})
}
}
}
}
...
@@ -232,7 +257,8 @@ async function fetchReportDetail({
...
@@ -232,7 +257,8 @@ async function fetchReportDetail({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
}
=
{})
{
}
=
{})
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
return
{
return
{
...
@@ -246,7 +272,8 @@ async function fetchReportDetail({
...
@@ -246,7 +272,8 @@ async function fetchReportDetail({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
})
})
const
{
code
,
message
,
data
}
=
unwrapDetailPayload
(
result
)
const
{
code
,
message
,
data
}
=
unwrapDetailPayload
(
result
)
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -345,7 +372,8 @@ async function fetchWeeklyList({
...
@@ -345,7 +372,8 @@ async function fetchWeeklyList({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
,
sceneType
}
=
{})
{
}
=
{})
{
if
(
!
merchantId
)
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
...
@@ -353,6 +381,7 @@ async function fetchWeeklyList({
...
@@ -353,6 +381,7 @@ async function fetchWeeklyList({
const
result
=
await
fetchWeeklyAdapter
({
const
result
=
await
fetchWeeklyAdapter
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
sceneType
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
staff
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
staff
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
...
@@ -436,6 +465,7 @@ async function submitForm(payload = {}) {
...
@@ -436,6 +465,7 @@ async function submitForm(payload = {}) {
module
.
exports
=
{
module
.
exports
=
{
fetchMerchantBrandIds
,
fetchMerchantBrandIds
,
fetchMerchantScene
,
fetchMerchantScene
,
fetchDailyReportCarBrandList
,
fetchPageContext
,
fetchPageContext
,
fetchReportDetail
,
fetchReportDetail
,
fetchSchema
,
fetchSchema
,
...
...
packageDynamicForm/api/staffDailyReportAdapters.js
View file @
1432781
...
@@ -22,6 +22,8 @@ const {
...
@@ -22,6 +22,8 @@ const {
DYNAMIC_FORM_TEMPLATE_MODULE
DYNAMIC_FORM_TEMPLATE_MODULE
}
=
require
(
'../config/configCenter.js'
)
}
=
require
(
'../config/configCenter.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
}
=
require
(
'../config/dailyReportConstants.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
let
fetchMerchantOperatingBrandListOverride
=
null
...
@@ -85,11 +87,12 @@ async function fetchDetailAdapter(params = {}) {
...
@@ -85,11 +87,12 @@ async function fetchDetailAdapter(params = {}) {
return
requireMockDynamicDetail
().
fetchMockDynamicDetail
(
params
)
return
requireMockDynamicDetail
().
fetchMockDynamicDetail
(
params
)
}
}
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
staffUuid
,
reportDate
}
=
params
const
{
merchantId
,
staffUuid
,
reportDate
,
sceneType
}
=
params
return
dailyReportDetailGet
({
return
dailyReportDetailGet
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
staff
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
staff
})
})
}
}
...
@@ -124,7 +127,8 @@ async function fetchSchemaRootAdapter(params = {}) {
...
@@ -124,7 +127,8 @@ async function fetchSchemaRootAdapter(params = {}) {
* @returns {Promise<{code: number, message: string, data: Array}>}
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
*/
async
function
fetchSceneAdapter
(
params
=
{})
{
async
function
fetchSceneAdapter
(
params
=
{})
{
const
{
merchantId
}
=
params
const
{
merchantId
,
staffUuid
,
sceneType
}
=
params
const
resolvedSceneType
=
resolveSceneType
({
sceneType
})
if
(
isStaffMockMode
(
'scene'
))
{
if
(
isStaffMockMode
(
'scene'
))
{
return
{
return
{
...
@@ -134,15 +138,23 @@ async function fetchSceneAdapter(params = {}) {
...
@@ -134,15 +138,23 @@ async function fetchSceneAdapter(params = {}) {
}
}
}
}
const
cached
=
getCachedScene
(
merchantId
)
const
cached
=
getCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
)
if
(
cached
)
{
if
(
cached
)
{
return
cached
return
cached
}
}
const
{
findAllSceneByMerchantId
}
=
getDynamicDailyReportApi
()
const
{
merchantBaseSceneCodeList
}
=
getDynamicDailyReportApi
()
const
result
=
await
findAllSceneByMerchantId
({
merchantId
})
const
result
=
await
merchantBaseSceneCodeList
({
setCachedScene
(
merchantId
,
result
)
staffUuid
,
return
result
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 = {}) {
...
@@ -198,11 +210,13 @@ async function fetchWeeklyAdapter(params = {}) {
staffUuid
,
staffUuid
,
reportStartDate
,
reportStartDate
,
reportEndDate
,
reportEndDate
,
sceneType
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
staff
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
staff
}
=
params
}
=
params
const
result
=
await
dailyReportWeeklyList
({
const
result
=
await
dailyReportWeeklyList
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
,
templateType
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
...
...
packageDynamicForm/api/staffDailyReportCache.js
View file @
1432781
/**
/**
* 驻店日报进程内缓存 — scene / schema / brand
* 驻店日报进程内缓存 — 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
sceneCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
brandCache
=
new
Map
()
const
brandCache
=
new
Map
()
function
getSceneCacheKey
(
staffUuid
,
merchantId
,
sceneType
)
{
return
`
${
staffUuid
||
''
}
:
${
merchantId
||
''
}
:
${
sceneType
??
0
}
`
}
/**
/**
* 生成 schema 缓存键
* 生成 schema 缓存键
* @param {number|string} reportTemplateId 模板 ID
* @param {number|string} reportTemplateId 模板 ID
...
@@ -18,23 +22,29 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
...
@@ -18,23 +22,29 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
/**
/**
* 读取门店场景缓存
* 读取门店场景缓存
* @param {string} staffUuid 员工 UUID
* @param {string|number} merchantId 门店 ID
* @param {string|number} merchantId 门店 ID
* @param {number|string} sceneType 业务场景
* @returns {Object|null} 缓存的 API 响应
* @returns {Object|null} 缓存的 API 响应
*/
*/
function
getCachedScene
(
merchantId
)
{
function getCachedScene(staffUuid, merchantId, sceneType) {
if
(
!
merchantId
)
return
null
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
return
sceneCache
.
get
(
merchantId
)
||
null
if (!key || key === '::0') return null
return sceneCache.get(key) || null
}
}
/**
/**
* 写入门店场景缓存
* 写入门店场景缓存
* @param {string} staffUuid 员工 UUID
* @param {string|number} merchantId 门店 ID
* @param {string|number} merchantId 门店 ID
* @param {number|string} sceneType 业务场景
* @param {Object} value API 响应
* @param {Object} value API 响应
* @returns {void}
* @returns {void}
*/
*/
function
setCachedScene
(
merchantId
,
value
)
{
function setCachedScene(staffUuid, merchantId, sceneType, value) {
if
(
!
merchantId
)
return
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
sceneCache
.
set
(
merchantId
,
value
)
if (!key || key === '::0') return
sceneCache.set(key, value)
}
}
/**
/**
...
@@ -90,6 +100,7 @@ function clearStaffDailyReportCache() {
...
@@ -90,6 +100,7 @@ function clearStaffDailyReportCache() {
}
}
module.exports = {
module.exports = {
getSceneCacheKey,
getSchemaCacheKey,
getSchemaCacheKey,
getCachedScene,
getCachedScene,
setCachedScene,
setCachedScene,
...
...
packageDynamicForm/api/storeDailyReport.js
View file @
1432781
...
@@ -43,6 +43,7 @@ const {
...
@@ -43,6 +43,7 @@ const {
}
=
require
(
'./storeDailyReportAdapters.js'
)
}
=
require
(
'./storeDailyReportAdapters.js'
)
const
{
normalizeReportStatus
}
=
require
(
'../utils/report-status.js'
)
const
{
normalizeReportStatus
}
=
require
(
'../utils/report-status.js'
)
const
{
isStoreMockMode
}
=
require
(
'../config/apiSwitch.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
{
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_SOURCE
}
=
require
(
'../config/dailyReportConstants.js'
)
const
{
const
{
...
@@ -126,7 +127,8 @@ function buildPageContextFromSources({
...
@@ -126,7 +127,8 @@ function buildPageContextFromSources({
brandIds
=
[],
brandIds
=
[],
detail
=
{},
detail
=
{},
baseSceneCode
,
baseSceneCode
,
sceneList
sceneList
,
carBrandList
=
[]
}
=
{})
{
}
=
{})
{
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
normalized
=
normalizeUserInfo
(
userInfo
)
const
pageContext
=
buildPageContext
(
const
pageContext
=
buildPageContext
(
...
@@ -135,7 +137,13 @@ function buildPageContextFromSources({
...
@@ -135,7 +137,13 @@ function buildPageContextFromSources({
normalized
,
normalized
,
sceneList
||
[]
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 } */
/** 统一 API 响应结构 { code, message, data } */
...
@@ -155,7 +163,13 @@ function unwrapResponse(result = {}) {
...
@@ -155,7 +163,13 @@ function unwrapResponse(result = {}) {
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @param {boolean} [options.hasRecord] 是否已有日报记录
* @returns {Promise<{code: number, message: string, baseSceneCode: string|null, sceneList: Array}>}
* @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
)
{
if
(
!
merchantId
)
{
return
{
return
{
code
:
0
,
code
:
0
,
...
@@ -164,7 +178,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
...
@@ -164,7 +178,7 @@ async function fetchMerchantScene({ merchantId, detailBaseSceneCode, hasRecord }
sceneList
:
[]
sceneList
:
[]
}
}
}
}
const
result
=
await
fetchSceneAdapter
({
merchantId
})
const
result
=
await
fetchSceneAdapter
({
merchantId
,
staffUuid
,
sceneType
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
{
return
{
...
@@ -206,6 +220,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
...
@@ -206,6 +220,14 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
}
}
}
}
async
function
fetchDailyReportCarBrandList
({
merchantId
,
sceneType
}
=
{})
{
return
fetchCarBrandListImpl
({
merchantId
,
sceneType
,
useMock
:
isStoreMockMode
(
'brand'
)
})
}
/**
/**
* 组装表单 pageContext(品牌、场景、用户信息)
* 组装表单 pageContext(品牌、场景、用户信息)
* @param {Object} [options={}]
* @param {Object} [options={}]
...
@@ -213,6 +235,7 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
...
@@ -213,6 +235,7 @@ async function fetchMerchantBrandIds({ merchantId } = {}) {
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Array} [options.brandIds] 经营品牌 ID 列表
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.detail] 日报详情
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Object} [options.merchantScene] fetchMerchantScene 返回值
* @param {Array} [options.carBrandList] 保存用车型列表
* @returns {Promise<{code: number, message: string, data: Object|null}>}
* @returns {Promise<{code: number, message: string, data: Object|null}>}
*/
*/
async
function
fetchPageContext
(
options
=
{})
{
async
function
fetchPageContext
(
options
=
{})
{
...
@@ -220,7 +243,8 @@ async function fetchPageContext(options = {}) {
...
@@ -220,7 +243,8 @@ async function fetchPageContext(options = {}) {
userInfo
=
{},
userInfo
=
{},
brandIds
=
[],
brandIds
=
[],
detail
=
{},
detail
=
{},
merchantScene
=
{}
merchantScene
=
{},
carBrandList
=
[]
}
=
options
}
=
options
const
hasRecord
=
!!
detail
.
dailyReportRecordId
const
hasRecord
=
!!
detail
.
dailyReportRecordId
let
baseSceneCode
=
resolveBaseSceneCode
(
let
baseSceneCode
=
resolveBaseSceneCode
(
...
@@ -248,7 +272,8 @@ async function fetchPageContext(options = {}) {
...
@@ -248,7 +272,8 @@ async function fetchPageContext(options = {}) {
brandIds
,
brandIds
,
detail
,
detail
,
baseSceneCode
,
baseSceneCode
,
sceneList
:
merchantScene
.
sceneList
||
[]
sceneList
:
merchantScene
.
sceneList
||
[],
carBrandList
})
})
}
}
}
}
...
@@ -276,7 +301,8 @@ async function fetchReportDetail({
...
@@ -276,7 +301,8 @@ async function fetchReportDetail({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
}
=
{})
{
}
=
{})
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
if
(
!
merchantId
||
!
staffUuid
||
!
reportDate
)
{
return
{
return
{
...
@@ -290,7 +316,8 @@ async function fetchReportDetail({
...
@@ -290,7 +316,8 @@ async function fetchReportDetail({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
})
})
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
const
{
code
,
message
,
data
}
=
unwrapResponse
(
result
)
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -402,7 +429,8 @@ async function fetchWeeklyList({
...
@@ -402,7 +429,8 @@ async function fetchWeeklyList({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
,
sceneType
}
=
{})
{
}
=
{})
{
if
(
!
merchantId
)
{
if
(
!
merchantId
)
{
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
return
{
code
:
0
,
message
:
'ok'
,
data
:
[]
}
...
@@ -410,6 +438,7 @@ async function fetchWeeklyList({
...
@@ -410,6 +438,7 @@ async function fetchWeeklyList({
const
result
=
await
fetchWeeklyAdapter
({
const
result
=
await
fetchWeeklyAdapter
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
sceneType
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
...
@@ -527,7 +556,8 @@ async function saveDraftForm(payload = {}) {
...
@@ -527,7 +556,8 @@ async function saveDraftForm(payload = {}) {
reportTemplateId
,
reportTemplateId
,
dailyReportRecordId
,
dailyReportRecordId
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
,
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
,
dailyReportSource
:
DAILY_REPORT_SOURCE
.
miniapp
dailyReportSource
:
DAILY_REPORT_SOURCE
.
miniapp
,
forDraft
:
true
})
})
logStoreSaveRequestDebug
(
'[storeDailyReport] dynamic.draft.save 草稿数据结构'
,
saveRequest
)
logStoreSaveRequestDebug
(
'[storeDailyReport] dynamic.draft.save 草稿数据结构'
,
saveRequest
)
const
result
=
await
saveDraftAdapter
(
saveRequest
)
const
result
=
await
saveDraftAdapter
(
saveRequest
)
...
@@ -556,17 +586,18 @@ async function saveDraftForm(payload = {}) {
...
@@ -556,17 +586,18 @@ async function saveDraftForm(payload = {}) {
* @param {string} [options.reportDate] YYYY-MM-DD
* @param {string} [options.reportDate] YYYY-MM-DD
* @returns {Promise<{code: number, message: string, data: { pendingCount: number }|null}>}
* @returns {Promise<{code: number, message: string, data: { pendingCount: number }|null}>}
*/
*/
async
function
fetchMonthlyPendingCount
({
merchantId
,
reportDate
}
=
{})
{
async
function
fetchMonthlyPendingCount
({
merchantId
,
reportDate
,
sceneType
}
=
{})
{
if
(
!
merchantId
||
!
reportDate
)
{
if
(
!
merchantId
||
!
reportDate
)
{
return
{
code
:
10002
,
message
:
'merchantId 或 reportDate 不能为空'
,
data
:
null
}
return
{
code
:
10002
,
message
:
'merchantId 或 reportDate 不能为空'
,
data
:
null
}
}
}
const
result
=
await
fetchMonthlyPendingCountAdapter
({
merchantId
,
reportDate
})
const
result
=
await
fetchMonthlyPendingCountAdapter
({
merchantId
,
reportDate
,
sceneType
})
return
normalizeMonthlyPendingCountResponse
(
result
)
return
normalizeMonthlyPendingCountResponse
(
result
)
}
}
module
.
exports
=
{
module
.
exports
=
{
fetchMerchantBrandIds
,
fetchMerchantBrandIds
,
fetchMerchantScene
,
fetchMerchantScene
,
fetchDailyReportCarBrandList
,
fetchPageContext
,
fetchPageContext
,
fetchReportDetail
,
fetchReportDetail
,
fetchSchema
,
fetchSchema
,
...
...
packageDynamicForm/api/storeDailyReportAdapters.js
View file @
1432781
...
@@ -38,6 +38,8 @@ const {
...
@@ -38,6 +38,8 @@ const {
DYNAMIC_FORM_TEMPLATE_MODULE
DYNAMIC_FORM_TEMPLATE_MODULE
}
=
require
(
'../config/configCenter.js'
)
}
=
require
(
'../config/configCenter.js'
)
const
{
DAILY_REPORT_TEMPLATE_TYPE
}
=
require
(
'../config/dailyReportConstants.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
let
fetchMerchantOperatingBrandListOverride
=
null
...
@@ -85,11 +87,12 @@ async function fetchDetailAdapter(params = {}) {
...
@@ -85,11 +87,12 @@ async function fetchDetailAdapter(params = {}) {
return
requireMockStoreDynamicDetail
().
fetchMockStoreDynamicDetail
(
params
)
return
requireMockStoreDynamicDetail
().
fetchMockStoreDynamicDetail
(
params
)
}
}
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
dailyReportDetailGet
}
=
getDynamicDailyReportApi
()
const
{
merchantId
,
staffUuid
,
reportDate
}
=
params
const
{
merchantId
,
staffUuid
,
reportDate
,
sceneType
}
=
params
return
dailyReportDetailGet
({
return
dailyReportDetailGet
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
reportDate
,
reportDate
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
templateType
:
DAILY_REPORT_TEMPLATE_TYPE
.
store
})
})
}
}
...
@@ -124,7 +127,8 @@ async function fetchSchemaRootAdapter(params = {}) {
...
@@ -124,7 +127,8 @@ async function fetchSchemaRootAdapter(params = {}) {
* @returns {Promise<{code: number, message: string, data: Array}>}
* @returns {Promise<{code: number, message: string, data: Array}>}
*/
*/
async
function
fetchSceneAdapter
(
params
=
{})
{
async
function
fetchSceneAdapter
(
params
=
{})
{
const
{
merchantId
}
=
params
const
{
merchantId
,
staffUuid
,
sceneType
}
=
params
const
resolvedSceneType
=
resolveSceneType
({
sceneType
})
if
(
isStoreMockMode
(
'scene'
))
{
if
(
isStoreMockMode
(
'scene'
))
{
return
{
return
{
...
@@ -134,15 +138,23 @@ async function fetchSceneAdapter(params = {}) {
...
@@ -134,15 +138,23 @@ async function fetchSceneAdapter(params = {}) {
}
}
}
}
const
cached
=
getCachedScene
(
merchantId
)
const
cached
=
getCachedScene
(
staffUuid
,
merchantId
,
resolvedSceneType
)
if
(
cached
)
{
if
(
cached
)
{
return
cached
return
cached
}
}
const
{
findAllSceneByMerchantId
}
=
getDynamicDailyReportApi
()
const
{
merchantBaseSceneCodeList
}
=
getDynamicDailyReportApi
()
const
result
=
await
findAllSceneByMerchantId
({
merchantId
})
const
result
=
await
merchantBaseSceneCodeList
({
setCachedScene
(
merchantId
,
result
)
staffUuid
,
return
result
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 = {}) {
...
@@ -198,11 +210,13 @@ async function fetchWeeklyAdapter(params = {}) {
staffUuid
,
staffUuid
,
reportStartDate
,
reportStartDate
,
reportEndDate
,
reportEndDate
,
sceneType
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
store
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
store
}
=
params
}
=
params
const
result
=
await
dailyReportWeeklyList
({
const
result
=
await
dailyReportWeeklyList
({
merchantId
,
merchantId
,
staffUuid
,
staffUuid
,
sceneType
:
resolveSceneType
({
sceneType
}),
templateType
,
templateType
,
reportStartDate
,
reportStartDate
,
reportEndDate
reportEndDate
...
@@ -270,7 +284,10 @@ async function fetchMonthlyPendingCountAdapter(params = {}) {
...
@@ -270,7 +284,10 @@ async function fetchMonthlyPendingCountAdapter(params = {}) {
}
}
}
}
const
{
dailyReportMonthlyPendingCountGet
}
=
getDynamicDailyReportApi
()
const
{
dailyReportMonthlyPendingCountGet
}
=
getDynamicDailyReportApi
()
return
dailyReportMonthlyPendingCountGet
(
params
)
return
dailyReportMonthlyPendingCountGet
({
...
params
,
sceneType
:
resolveSceneType
({
sceneType
:
params
.
sceneType
})
})
}
}
/**
/**
...
...
packageDynamicForm/api/storeDailyReportCache.js
View file @
1432781
/**
/**
* 门店日报进程内缓存 — scene / schema / brand
* 门店日报进程内缓存 — 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
sceneCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
schemaCache
=
new
Map
()
const
brandCache
=
new
Map
()
const
brandCache
=
new
Map
()
function
getSceneCacheKey
(
staffUuid
,
merchantId
,
sceneType
)
{
return
`
${
staffUuid
||
''
}
:
${
merchantId
||
''
}
:
${
sceneType
??
0
}
`
}
/**
/**
* 生成 schema 缓存键
* 生成 schema 缓存键
* @param {number|string} reportTemplateId 模板 ID
* @param {number|string} reportTemplateId 模板 ID
...
@@ -21,20 +25,16 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
...
@@ -21,20 +25,16 @@ function getSchemaCacheKey(reportTemplateId, baseSceneCode) {
* @param {string|number} merchantId 门店 ID
* @param {string|number} merchantId 门店 ID
* @returns {Object|null} 缓存的 API 响应
* @returns {Object|null} 缓存的 API 响应
*/
*/
function
getCachedScene
(
merchantId
)
{
function getCachedScene(staffUuid, merchantId, sceneType) {
if
(
!
merchantId
)
return
null
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
return
sceneCache
.
get
(
merchantId
)
||
null
if (!key || key === '::0') return null
return sceneCache.get(key) || null
}
}
/**
function setCachedScene(staffUuid, merchantId, sceneType, value) {
* 写入门店场景缓存
const key = getSceneCacheKey(staffUuid, merchantId, sceneType)
* @param {string|number} merchantId 门店 ID
if (!key || key === '::0') return
* @param {Object} value API 响应
sceneCache.set(key, value)
* @returns {void}
*/
function
setCachedScene
(
merchantId
,
value
)
{
if
(
!
merchantId
)
return
sceneCache
.
set
(
merchantId
,
value
)
}
}
/**
/**
...
@@ -90,6 +90,7 @@ function clearStoreDailyReportCache() {
...
@@ -90,6 +90,7 @@ function clearStoreDailyReportCache() {
}
}
module.exports = {
module.exports = {
getSceneCacheKey,
getSchemaCacheKey,
getSchemaCacheKey,
getCachedScene,
getCachedScene,
setCachedScene,
setCachedScene,
...
...
packageDynamicForm/components/negotiation-summary/negotiation-summary.js
View file @
1432781
...
@@ -10,6 +10,10 @@ Component({
...
@@ -10,6 +10,10 @@ Component({
merchantId
:
{
merchantId
:
{
type
:
String
,
type
:
String
,
value
:
''
value
:
''
},
sceneType
:
{
type
:
null
,
value
:
0
}
}
},
},
...
@@ -88,7 +92,7 @@ Component({
...
@@ -88,7 +92,7 @@ Component({
},
},
async
loadStaffList
()
{
async
loadStaffList
()
{
const
{
reportDate
,
merchantId
}
=
this
.
properties
const
{
reportDate
,
merchantId
,
sceneType
}
=
this
.
properties
if
(
!
reportDate
||
!
merchantId
)
return
if
(
!
reportDate
||
!
merchantId
)
return
this
.
setData
({
this
.
setData
({
loading
:
true
,
loading
:
true
,
...
@@ -102,7 +106,8 @@ Component({
...
@@ -102,7 +106,8 @@ Component({
try
{
try
{
const
res
=
await
negotiationApi
.
fetchDiscussionStaffList
({
const
res
=
await
negotiationApi
.
fetchDiscussionStaffList
({
merchantId
,
merchantId
,
reportDate
reportDate
,
sceneType
})
})
if
(
res
.
code
!==
0
)
{
if
(
res
.
code
!==
0
)
{
this
.
setData
({
this
.
setData
({
...
@@ -131,7 +136,7 @@ Component({
...
@@ -131,7 +136,7 @@ Component({
},
},
async
loadStaffDetail
(
staff
=
{})
{
async
loadStaffDetail
(
staff
=
{})
{
const
{
reportDate
,
merchantId
}
=
this
.
properties
const
{
reportDate
,
merchantId
,
sceneType
}
=
this
.
properties
if
(
!
staff
.
staffUuid
||
!
reportDate
||
!
merchantId
)
{
if
(
!
staff
.
staffUuid
||
!
reportDate
||
!
merchantId
)
{
this
.
setData
({
sections
:
[],
sectionNavIndex
:
[]
})
this
.
setData
({
sections
:
[],
sectionNavIndex
:
[]
})
return
return
...
@@ -141,7 +146,8 @@ Component({
...
@@ -141,7 +146,8 @@ Component({
const
res
=
await
negotiationApi
.
fetchReportDetail
({
const
res
=
await
negotiationApi
.
fetchReportDetail
({
merchantId
,
merchantId
,
staffUuid
:
staff
.
staffUuid
,
staffUuid
:
staff
.
staffUuid
,
reportDate
reportDate
,
sceneType
})
})
if
(
res
.
code
!==
0
||
!
res
.
data
)
{
if
(
res
.
code
!==
0
||
!
res
.
data
)
{
this
.
setData
({
sections
:
[],
sectionNavIndex
:
[]
})
this
.
setData
({
sections
:
[],
sectionNavIndex
:
[]
})
...
...
packageDynamicForm/docs/ARCHITECTURE.md
View file @
1432781
...
@@ -73,7 +73,7 @@ sequenceDiagram
...
@@ -73,7 +73,7 @@ sequenceDiagram
| Schema | 配置中心数字键
`{ "0": field, ... }`
→
`{ list }`
|
`configCenter.normalizeConfigToSchemaRoot`
|
| Schema | 配置中心数字键
`{ "0": field, ... }`
→
`{ list }`
|
`configCenter.normalizeConfigToSchemaRoot`
|
| 主营品牌 |
`merchants.api.open.merchant.info`
|
`carBrandApi`
→
`fetchBrandAdapter`
(按 merchantId 缓存) |
| 主营品牌 |
`merchants.api.open.merchant.info`
|
`carBrandApi`
→
`fetchBrandAdapter`
(按 merchantId 缓存) |
| 详情 |
`detail.get`
+
`jsonContent`
+
`subformDataList`
|
`fetchDetailAdapter`
→
`parseJsonContentDetailValues`
|
| 详情 |
`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 内) |
| 周历 |
`dailyReport.weekly.list`
|
`fetchWeeklyAdapter`
(页面独立刷新,不在 Loader 内) |
| 字段选项 |
`getEmployeeList`
等 |
`fieldOptionsAdapters`
+
`fieldOptionProviders`
|
| 字段选项 |
`getEmployeeList`
等 |
`fieldOptionsAdapters`
+
`fieldOptionProviders`
|
...
...
packageDynamicForm/docs/DEVLOG.md
View file @
1432781
# DEVLOG — packageDynamicForm
# 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(库内共用)
## 2026-06-10 — F2-1 fieldDataList 从 jsonContent 还原 name(库内共用)
-
**现象**
:App 保存的 F2-1 jsonContent 为双 key(
`value`
展示串 +
`F2-1`
id 数组),
`buildAppNormalizedListsFromJsonContent`
产出的
`fieldDataList`
中
`name === id`
。
-
**现象**
: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
...
@@ -36,7 +36,9 @@ sequenceDiagram
**显隐与持久化**
:模版级隐藏(调休、品牌/场景过滤等)
**仅隐藏 UI**
,不清
`values`
;
`jsonContent`
写入仍有值的隐藏块供再次编辑回显。
`fieldDataList`
/
`subformDataList`
/ 校验仍仅
**当前可见**
字段。subform 行内
`childrenShowRules`
联动切换仍清 hidden cell(如洽谈「是否成交」否)。
**显隐与持久化**
:模版级隐藏(调休、品牌/场景过滤等)
**仅隐藏 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
)
**统一提交入口**
:
[
`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 =
...
@@ -95,6 +95,8 @@ function buildPageContext(preset = {}, brandIds = [], userInfo = {}, sceneList =
shopMerchantId
:
userInfo
.
shopMerchantId
||
merchantId
||
''
,
shopMerchantId
:
userInfo
.
shopMerchantId
||
merchantId
||
''
,
shopMerchantName
,
shopMerchantName
,
yqMerchantId
:
resolveYqMerchantId
(
userInfo
,
merchantId
),
yqMerchantId
:
resolveYqMerchantId
(
userInfo
,
merchantId
),
yqMerchantName
:
userInfo
.
yqMerchantName
||
userInfo
.
merchantName
||
''
,
sceneType
:
userInfo
.
sceneType
??
0
,
merchantName
:
shopMerchantName
,
merchantName
:
shopMerchantName
,
staffName
:
userInfo
.
staffName
||
userInfo
.
name
||
''
staffName
:
userInfo
.
staffName
||
userInfo
.
name
||
''
}
}
...
...
packageDynamicForm/form-engine/save-request.js
View file @
1432781
...
@@ -4,23 +4,33 @@ const {
...
@@ -4,23 +4,33 @@ const {
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_TEMPLATE_TYPE
,
DAILY_REPORT_SOURCE
DAILY_REPORT_SOURCE
}
=
require
(
'../config/dailyReportConstants.js'
)
}
=
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 同级字符串传输) */
/** 组装 requestJson 对象并 JSON.stringify(与 jsonContent 同级字符串传输) */
function
buildRequestJsonForApi
(
fieldDataList
=
[],
subformDataList
=
[])
{
function
buildRequestJsonForApi
(
fieldDataList
=
[],
subformDataList
=
[]
,
options
=
{}
)
{
const
payload
=
{
const
payload
=
{
fieldDataList
:
Array
.
isArray
(
fieldDataList
)
?
fieldDataList
:
[]
fieldDataList
:
Array
.
isArray
(
fieldDataList
)
?
fieldDataList
:
[]
}
}
if
(
Array
.
isArray
(
subformDataList
)
&&
subformDataList
.
length
>
0
)
{
if
(
Array
.
isArray
(
subformDataList
)
&&
subformDataList
.
length
>
0
)
{
payload
.
subformDataList
=
subformDataList
payload
.
subformDataList
=
subformDataList
}
}
const
carBrandList
=
options
.
carBrandList
if
(
Array
.
isArray
(
carBrandList
)
&&
carBrandList
.
length
>
0
)
{
payload
.
carBrandList
=
carBrandList
}
return
JSON
.
stringify
(
payload
)
return
JSON
.
stringify
(
payload
)
}
}
/** 解析 save 请求体中的 requestJson(供 mock / 测试回显) */
/** 解析 save 请求体中的 requestJson(供 mock / 测试回显) */
function
parseRequestJsonLists
(
requestJson
)
{
function
parseRequestJsonLists
(
requestJson
)
{
if
(
requestJson
==
null
||
requestJson
===
''
)
{
if
(
requestJson
==
null
||
requestJson
===
''
)
{
return
{
fieldDataList
:
[],
subformDataList
:
[]
}
return
{
fieldDataList
:
[],
subformDataList
:
[]
,
carBrandList
:
[]
}
}
}
const
parsed
=
const
parsed
=
typeof
requestJson
===
'string'
?
JSON
.
parse
(
requestJson
)
:
requestJson
typeof
requestJson
===
'string'
?
JSON
.
parse
(
requestJson
)
:
requestJson
...
@@ -28,7 +38,8 @@ function parseRequestJsonLists(requestJson) {
...
@@ -28,7 +38,8 @@ function parseRequestJsonLists(requestJson) {
fieldDataList
:
Array
.
isArray
(
parsed
.
fieldDataList
)
?
parsed
.
fieldDataList
:
[],
fieldDataList
:
Array
.
isArray
(
parsed
.
fieldDataList
)
?
parsed
.
fieldDataList
:
[],
subformDataList
:
Array
.
isArray
(
parsed
.
subformDataList
)
subformDataList
:
Array
.
isArray
(
parsed
.
subformDataList
)
?
parsed
.
subformDataList
?
parsed
.
subformDataList
:
[]
:
[],
carBrandList
:
Array
.
isArray
(
parsed
.
carBrandList
)
?
parsed
.
carBrandList
:
[]
}
}
}
}
...
@@ -44,7 +55,8 @@ function buildDailyReportSaveRequest({
...
@@ -44,7 +55,8 @@ function buildDailyReportSaveRequest({
reportTemplateId
,
reportTemplateId
,
dailyReportRecordId
,
dailyReportRecordId
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
staff
,
templateType
=
DAILY_REPORT_TEMPLATE_TYPE
.
staff
,
dailyReportSource
=
DAILY_REPORT_SOURCE
.
miniapp
dailyReportSource
=
DAILY_REPORT_SOURCE
.
miniapp
,
forDraft
=
false
}
=
{})
{
}
=
{})
{
const
formPayload
=
buildSavePayloadByTemplateType
(
templateType
,
{
const
formPayload
=
buildSavePayloadByTemplateType
(
templateType
,
{
reportTemplateId
,
reportTemplateId
,
...
@@ -54,6 +66,12 @@ function buildDailyReportSaveRequest({
...
@@ -54,6 +66,12 @@ function buildDailyReportSaveRequest({
normalizedFieldDataList
:
templateType
===
DAILY_REPORT_TEMPLATE_TYPE
.
staff
normalizedFieldDataList
:
templateType
===
DAILY_REPORT_TEMPLATE_TYPE
.
staff
})
})
const
carBrandList
=
pageContext
.
carBrandList
const
requestJsonOptions
=
!
forDraft
&&
Array
.
isArray
(
carBrandList
)
&&
carBrandList
.
length
>
0
?
{
carBrandList
}
:
{}
const
request
=
{
const
request
=
{
reportDate
,
reportDate
,
merchantId
:
resolveSaveMerchantId
(
userContext
,
pageContext
),
merchantId
:
resolveSaveMerchantId
(
userContext
,
pageContext
),
...
@@ -65,6 +83,12 @@ function buildDailyReportSaveRequest({
...
@@ -65,6 +83,12 @@ function buildDailyReportSaveRequest({
userContext
.
merchantName
||
userContext
.
merchantName
||
pageContext
.
merchantName
||
pageContext
.
merchantName
||
''
,
''
,
yqMerchantId
:
resolveYqMerchantId
(
userContext
,
pageContext
.
merchantId
),
yqMerchantName
:
resolveYqMerchantName
(
userContext
)
||
pageContext
.
yqMerchantName
||
''
,
sceneType
:
resolveSceneType
(
userContext
,
pageContext
.
sceneType
),
staffUuid
:
userContext
.
staffUuid
,
staffUuid
:
userContext
.
staffUuid
,
staffName
:
userContext
.
staffName
||
''
,
staffName
:
userContext
.
staffName
||
''
,
dailyReportSource
,
dailyReportSource
,
...
@@ -73,7 +97,8 @@ function buildDailyReportSaveRequest({
...
@@ -73,7 +97,8 @@ function buildDailyReportSaveRequest({
jsonContent
:
formPayload
.
jsonContent
,
jsonContent
:
formPayload
.
jsonContent
,
requestJson
:
buildRequestJsonForApi
(
requestJson
:
buildRequestJsonForApi
(
formPayload
.
fieldDataList
,
formPayload
.
fieldDataList
,
formPayload
.
subformDataList
formPayload
.
subformDataList
,
requestJsonOptions
)
)
}
}
...
...
packageDynamicForm/pages/negotiationDetail/negotiationDetail.js
View file @
1432781
...
@@ -397,6 +397,7 @@ Page({
...
@@ -397,6 +397,7 @@ Page({
const
res
=
await
negotiationApi
.
fetchWeeklyList
({
const
res
=
await
negotiationApi
.
fetchWeeklyList
({
merchantId
:
ctx
.
merchantId
,
merchantId
:
ctx
.
merchantId
,
staffUuid
:
ctx
.
staffUuid
,
staffUuid
:
ctx
.
staffUuid
,
sceneType
:
ctx
.
sceneType
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportEndDate
:
timeBean
.
reportEndDate
reportEndDate
:
timeBean
.
reportEndDate
})
})
...
...
packageDynamicForm/pages/staffDailyReport/staffDailyReport.js
View file @
1432781
...
@@ -254,6 +254,7 @@ Page({
...
@@ -254,6 +254,7 @@ Page({
const
res
=
await
staffDailyApi
.
fetchWeeklyList
({
const
res
=
await
staffDailyApi
.
fetchWeeklyList
({
merchantId
:
ctx
.
merchantId
,
merchantId
:
ctx
.
merchantId
,
staffUuid
:
ctx
.
staffUuid
,
staffUuid
:
ctx
.
staffUuid
,
sceneType
:
ctx
.
sceneType
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportEndDate
:
timeBean
.
reportEndDate
reportEndDate
:
timeBean
.
reportEndDate
})
})
...
@@ -279,7 +280,8 @@ Page({
...
@@ -279,7 +280,8 @@ Page({
yqMerchantId
:
ctx
.
yqMerchantId
||
''
,
yqMerchantId
:
ctx
.
yqMerchantId
||
''
,
staffUuid
:
ctx
.
staffUuid
||
''
,
staffUuid
:
ctx
.
staffUuid
||
''
,
reportDate
:
this
.
data
.
reportDate
||
''
,
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({
...
@@ -319,6 +319,7 @@ Page({
const
res
=
await
storeDailyApi
.
fetchWeeklyList
({
const
res
=
await
storeDailyApi
.
fetchWeeklyList
({
merchantId
:
ctx
.
merchantId
,
merchantId
:
ctx
.
merchantId
,
staffUuid
:
ctx
.
staffUuid
,
staffUuid
:
ctx
.
staffUuid
,
sceneType
:
ctx
.
sceneType
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportStartDate
:
timeBean
.
reportStartDate
,
reportEndDate
:
timeBean
.
reportEndDate
reportEndDate
:
timeBean
.
reportEndDate
})
})
...
@@ -465,7 +466,8 @@ Page({
...
@@ -465,7 +466,8 @@ Page({
try
{
try
{
const
res
=
await
storeDailyApi
.
fetchMonthlyPendingCount
({
const
res
=
await
storeDailyApi
.
fetchMonthlyPendingCount
({
merchantId
,
merchantId
,
reportDate
reportDate
,
sceneType
:
(
this
.
userContext
||
this
.
getRequestContext
()).
sceneType
})
})
if
(
this
.
isStaleLoad
(
seq
))
{
if
(
this
.
isStaleLoad
(
seq
))
{
return
return
...
...
packageDynamicForm/pages/storeDailyReport/storeDailyReport.wxml
View file @
1432781
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
class="summary-panel__inner"
class="summary-panel__inner"
reportDate="{{ reportDate }}"
reportDate="{{ reportDate }}"
merchantId="{{ requestContext.merchantId }}"
merchantId="{{ requestContext.merchantId }}"
sceneType="{{ requestContext.sceneType }}"
bind:close="closeNegotiationSummary"
bind:close="closeNegotiationSummary"
></negotiation-summary>
></negotiation-summary>
</view>
</view>
...
...
packageDynamicForm/services/dailyReportBootstrap.js
View file @
1432781
...
@@ -14,14 +14,23 @@ async function loadDailyForm(options = {}, api) {
...
@@ -14,14 +14,23 @@ async function loadDailyForm(options = {}, api) {
}
}
const
{
userContext
,
reportDate
,
reportTemplateId
}
=
options
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
.
fetchMerchantBrandIds
({
merchantId
:
userContext
.
merchantId
}),
api
.
fetchMerchantScene
({
merchantId
:
userContext
.
merchantId
}),
api
.
fetchMerchantScene
({
merchantId
:
userContext
.
merchantId
,
staffUuid
:
userContext
.
staffUuid
,
sceneType
:
userContext
.
sceneType
}),
api
.
fetchReportDetail
({
api
.
fetchReportDetail
({
merchantId
:
userContext
.
merchantId
,
merchantId
:
userContext
.
merchantId
,
staffUuid
:
userContext
.
staffUuid
,
staffUuid
:
userContext
.
staffUuid
,
reportDate
,
reportDate
,
reportTemplateId
reportTemplateId
,
sceneType
:
userContext
.
sceneType
}),
api
.
fetchDailyReportCarBrandList
({
merchantId
:
userContext
.
merchantId
,
sceneType
:
userContext
.
sceneType
})
})
])
])
...
@@ -37,13 +46,17 @@ async function loadDailyForm(options = {}, api) {
...
@@ -37,13 +46,17 @@ async function loadDailyForm(options = {}, api) {
if
(
detailRes
.
code
!==
0
)
{
if
(
detailRes
.
code
!==
0
)
{
return
{
code
:
detailRes
.
code
,
message
:
detailRes
.
message
||
'获取日报详情失败'
,
data
:
null
}
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
detail
=
detailRes
.
data
||
{}
const
pageContextRes
=
await
api
.
fetchPageContext
({
const
pageContextRes
=
await
api
.
fetchPageContext
({
userInfo
:
userContext
,
userInfo
:
userContext
,
brandIds
:
brandRes
.
data
||
[],
brandIds
:
brandRes
.
data
||
[],
detail
,
detail
,
merchantScene
:
sceneRes
merchantScene
:
sceneRes
,
carBrandList
:
carBrandRes
.
data
||
[]
})
})
if
(
pageContextRes
.
code
!==
0
||
!
pageContextRes
.
data
)
{
if
(
pageContextRes
.
code
!==
0
||
!
pageContextRes
.
data
)
{
return
{
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 () => {
...
@@ -329,6 +329,88 @@ describe('dailyReportSaveRequest', async () => {
(unified.fieldDataList || []).every(item => !item.groupKey && item.fieldType !== 'subform')
(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', () => {
describe('mockDynamicDetail staff sample', () => {
...
...
packageDynamicForm/tests/dailyReportWeeklyList.test.mjs
View file @
1432781
...
@@ -34,11 +34,13 @@ describe('dailyReportWeeklyList adapters', () => {
...
@@ -34,11 +34,13 @@ describe('dailyReportWeeklyList adapters', () => {
const res = await staffAdapters.fetchWeeklyAdapter({
const res = await staffAdapters.fetchWeeklyAdapter({
merchantId: 1001,
merchantId: 1001,
staffUuid: 'uuid-1',
staffUuid: 'uuid-1',
sceneType: 1,
reportStartDate: '2026-05-20',
reportStartDate: '2026-05-20',
reportEndDate: '2026-05-26'
reportEndDate: '2026-05-26'
})
})
assert.equal(captured.merchantId, 1001)
assert.equal(captured.merchantId, 1001)
assert.equal(captured.staffUuid, 'uuid-1')
assert.equal(captured.staffUuid, 'uuid-1')
assert.equal(captured.sceneType, 1)
assert.equal(captured.templateType, DAILY_REPORT_TEMPLATE_TYPE.staff)
assert.equal(captured.templateType, DAILY_REPORT_TEMPLATE_TYPE.staff)
assert.equal(captured.reportStartDate, '2026-05-20')
assert.equal(captured.reportStartDate, '2026-05-20')
assert.equal(captured.reportEndDate, '2026-05-26')
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', () => {
...
@@ -37,12 +37,14 @@ describe('negotiation discussion staff list', () => {
try {
try {
const res = await adapters.fetchDiscussionStaffListAdapter({
const res = await adapters.fetchDiscussionStaffListAdapter({
merchantId: 'shop-001',
merchantId: 'shop-001',
reportDate: '2026-06-02'
reportDate: '2026-06-02',
sceneType: 0
})
})
assert.equal(res.code, 0)
assert.equal(res.code, 0)
assert.equal(res.data.length, 1)
assert.equal(res.data.length, 1)
assert.equal(captured.merchantId, 'shop-001')
assert.equal(captured.merchantId, 'shop-001')
assert.equal(captured.reportDate, '2026-06-02')
assert.equal(captured.reportDate, '2026-06-02')
assert.equal(captured.sceneType, 0)
} finally {
} finally {
adapters.__setDynamicDailyReportApi(null)
adapters.__setDynamicDailyReportApi(null)
NEGOTIATION_DAILY_API_SWITCH.discussionStaffList = original
NEGOTIATION_DAILY_API_SWITCH.discussionStaffList = original
...
...
packageDynamicForm/tests/negotiationDailyFormLoader.test.mjs
View file @
1432781
...
@@ -30,6 +30,7 @@ function createDeps(overrides = {}) {
...
@@ -30,6 +30,7 @@ function createDeps(overrides = {}) {
values: {}
values: {}
}
}
}),
}),
fetchDailyReportCarBrandList: async () => ({ code: 0, data: [] }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchSchema: async () => ({
fetchSchema: async () => ({
code: 0,
code: 0,
...
...
packageDynamicForm/tests/staffDailyFormLoader.test.mjs
View file @
1432781
...
@@ -31,6 +31,7 @@ function createDeps(overrides = {}) {
...
@@ -31,6 +31,7 @@ function createDeps(overrides = {}) {
values: {}
values: {}
}
}
}),
}),
fetchDailyReportCarBrandList: async () => ({ code: 0, data: [] }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchSchema: async () => ({
fetchSchema: async () => ({
code: 0,
code: 0,
...
...
packageDynamicForm/tests/staffDailyReportAdapters.test.mjs
View file @
1432781
...
@@ -92,11 +92,13 @@ describe('staffDailyReportAdapters', () => {
...
@@ -92,11 +92,13 @@ describe('staffDailyReportAdapters', () => {
merchantId: 'm1',
merchantId: 'm1',
staffUuid: 's1',
staffUuid: 's1',
reportDate: '2026-05-26',
reportDate: '2026-05-26',
sceneType: 1,
reportTemplateId: 10001
reportTemplateId: 10001
})
})
assert.equal(captured.merchantId, 'm1')
assert.equal(captured.merchantId, 'm1')
assert.equal(captured.staffUuid, 's1')
assert.equal(captured.staffUuid, 's1')
assert.equal(captured.reportDate, '2026-05-26')
assert.equal(captured.reportDate, '2026-05-26')
assert.equal(captured.sceneType, 1)
assert.equal(captured.templateType, DAILY_REPORT_TEMPLATE_TYPE.staff)
assert.equal(captured.templateType, DAILY_REPORT_TEMPLATE_TYPE.staff)
assert.equal(captured.reportTemplateId, undefined)
assert.equal(captured.reportTemplateId, undefined)
} finally {
} finally {
...
@@ -167,20 +169,52 @@ describe('staffDailyReportAdapters', () => {
...
@@ -167,20 +169,52 @@ describe('staffDailyReportAdapters', () => {
it('fetchSceneAdapter caches scene list for merchant', async () => {
it('fetchSceneAdapter caches scene list for merchant', async () => {
let calls = 0
let calls = 0
adapters.__setDynamicDailyReportApi({
adapters.__setDynamicDailyReportApi({
findAllSceneByMerchantId
: async () => {
merchantBaseSceneCodeList
: async () => {
calls += 1
calls += 1
return { code: 0, message: 'ok', data: [
{ baseSceneCode: 100101, sceneType: 1 }
] }
return { code: 0, message: 'ok', data: [
'100101'
] }
}
}
})
})
try {
try {
await adapters.fetchSceneAdapter({ merchantId: 'm-cache' })
await adapters.fetchSceneAdapter({
await adapters.fetchSceneAdapter({ merchantId: 'm-cache' })
merchantId: 'm-cache',
staffUuid: 's1',
sceneType: 1
})
await adapters.fetchSceneAdapter({
merchantId: 'm-cache',
staffUuid: 's1',
sceneType: 1
})
assert.equal(calls, 1)
assert.equal(calls, 1)
} finally {
} finally {
adapters.__setDynamicDailyReportApi(null)
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 () => {
it('fetchBrandAdapter mock mode returns fixture brand list', async () => {
const original = STAFF_DAILY_API_SWITCH.brand
const original = STAFF_DAILY_API_SWITCH.brand
STAFF_DAILY_API_SWITCH.brand = 'mock'
STAFF_DAILY_API_SWITCH.brand = 'mock'
...
...
packageDynamicForm/tests/storeDailyFormLoader.test.mjs
View file @
1432781
...
@@ -30,6 +30,7 @@ function createDeps(overrides = {}) {
...
@@ -30,6 +30,7 @@ function createDeps(overrides = {}) {
values: {}
values: {}
}
}
}),
}),
fetchDailyReportCarBrandList: async () => ({ code: 0, data: [] }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchSchema: async () => ({
fetchSchema: async () => ({
code: 0,
code: 0,
...
...
packageDynamicForm/tests/storeDailyReportAdapters.test.mjs
View file @
1432781
...
@@ -501,14 +501,22 @@ describe('storeDailyReportAdapters', () => {
...
@@ -501,14 +501,22 @@ describe('storeDailyReportAdapters', () => {
it('fetchSceneAdapter caches scene list for merchant', async () => {
it('fetchSceneAdapter caches scene list for merchant', async () => {
let calls = 0
let calls = 0
adapters.__setDynamicDailyReportApi({
adapters.__setDynamicDailyReportApi({
findAllSceneByMerchantId
: async () => {
merchantBaseSceneCodeList
: async () => {
calls += 1
calls += 1
return { code: 0, message: 'ok', data: [
{ baseSceneCode: 110201, sceneType: 0 }
] }
return { code: 0, message: 'ok', data: [
'110201'
] }
}
}
})
})
try {
try {
await adapters.fetchSceneAdapter({ merchantId: 'm-store-cache' })
await adapters.fetchSceneAdapter({
await adapters.fetchSceneAdapter({ merchantId: 'm-store-cache' })
merchantId: 'm-store-cache',
staffUuid: 's1',
sceneType: 0
})
await adapters.fetchSceneAdapter({
merchantId: 'm-store-cache',
staffUuid: 's1',
sceneType: 0
})
assert.equal(calls, 1)
assert.equal(calls, 1)
} finally {
} finally {
adapters.__setDynamicDailyReportApi(null)
adapters.__setDynamicDailyReportApi(null)
...
...
packageDynamicForm/tests/storeMonthlyPendingCount.test.mjs
View file @
1432781
...
@@ -111,10 +111,12 @@ describe('fetchMonthlyPendingCount', () => {
...
@@ -111,10 +111,12 @@ describe('fetchMonthlyPendingCount', () => {
try {
try {
const res = await adapters.fetchMonthlyPendingCountAdapter({
const res = await adapters.fetchMonthlyPendingCountAdapter({
merchantId: '4s-2',
merchantId: '4s-2',
reportDate: '2026-06-03'
reportDate: '2026-06-03',
sceneType: 1
})
})
assert.equal(captured.merchantId, '4s-2')
assert.equal(captured.merchantId, '4s-2')
assert.equal(captured.reportDate, '2026-06-03')
assert.equal(captured.reportDate, '2026-06-03')
assert.equal(captured.sceneType, 1)
assert.equal(res.data.pendingCount, 7)
assert.equal(res.data.pendingCount, 7)
} finally {
} finally {
adapters.__setDynamicDailyReportApi(null)
adapters.__setDynamicDailyReportApi(null)
...
...
packageDynamicForm/utils/user-merchant.js
View file @
1432781
...
@@ -29,6 +29,25 @@ function resolveYqMerchantId(userInfo = {}, shopMerchantId = '') {
...
@@ -29,6 +29,25 @@ function resolveYqMerchantId(userInfo = {}, shopMerchantId = '') {
return
userInfo
.
yqMerchantId
||
userInfo
.
merchantId
||
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 可作为兜底)
* 从单份上下文解析 4S merchantId(已 normalize 的 merchantId 可作为兜底)
* @param {Object} [ctx={}]
* @param {Object} [ctx={}]
...
@@ -75,6 +94,8 @@ function normalizeDailyReportUserInfo(userInfo = {}) {
...
@@ -75,6 +94,8 @@ function normalizeDailyReportUserInfo(userInfo = {}) {
shopMerchantId
,
shopMerchantId
,
shopMerchantName
,
shopMerchantName
,
yqMerchantId
:
resolveYqMerchantId
(
userInfo
,
merchantId
),
yqMerchantId
:
resolveYqMerchantId
(
userInfo
,
merchantId
),
yqMerchantName
:
resolveYqMerchantName
(
userInfo
),
sceneType
:
resolveSceneType
(
userInfo
),
staffUuid
:
userInfo
.
uuid
||
userInfo
.
staffUuid
||
''
,
staffUuid
:
userInfo
.
uuid
||
userInfo
.
staffUuid
||
''
,
baseSceneCode
:
userInfo
.
baseSceneCode
,
baseSceneCode
:
userInfo
.
baseSceneCode
,
merchantName
:
shopMerchantName
,
merchantName
:
shopMerchantName
,
...
@@ -86,6 +107,8 @@ module.exports = {
...
@@ -86,6 +107,8 @@ module.exports = {
resolveShopMerchantId
,
resolveShopMerchantId
,
resolveShopMerchantName
,
resolveShopMerchantName
,
resolveYqMerchantId
,
resolveYqMerchantId
,
resolveYqMerchantName
,
resolveSceneType
,
resolveSaveMerchantId
,
resolveSaveMerchantId
,
normalizeDailyReportUserInfo
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