Commit 065d70ae by 张立顺

feat 日报功能开发

1 parent aede5d91
Showing 61 changed files with 1054 additions and 240 deletions
...@@ -18,12 +18,12 @@ export const appId = "wx570d9331f9ace0bd"; ...@@ -18,12 +18,12 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 3; let index = 0;
const accountInfo = wx.getAccountInfoSync(); const accountInfo = wx.getAccountInfoSync();
const systemInfo = wx.getSystemInfoSync(); const systemInfo = wx.getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion; const envName = accountInfo.miniProgram.envVersion;
//手动控制体验版环境的请求 true就依据下面index false就默认2 //手动控制体验版环境的请求 true就依据下面index false就默认2
const manual = true; const manual = false;
const release = false; const release = false;
// 判断小程序环境 // 判断小程序环境
......
...@@ -28,10 +28,6 @@ function dailyReportMonthlyPendingCountGet(data) { ...@@ -28,10 +28,6 @@ function dailyReportMonthlyPendingCountGet(data) {
) )
} }
function findAllSceneByMerchantId(data) {
return api.post('dj.api.scenemerchantref.findAllSceneByMerchantId', data)
}
function merchantBaseSceneCodeList(data) { function merchantBaseSceneCodeList(data) {
return api.post( return api.post(
'dj.api.smartcarlife.staffBaseInfo.merchant.baseSceneCode.list', 'dj.api.smartcarlife.staffBaseInfo.merchant.baseSceneCode.list',
...@@ -64,7 +60,6 @@ module.exports = { ...@@ -64,7 +60,6 @@ module.exports = {
dynamicDailyReportDraftSave, dynamicDailyReportDraftSave,
dailyReportDetailGet, dailyReportDetailGet,
dailyReportMonthlyPendingCountGet, dailyReportMonthlyPendingCountGet,
findAllSceneByMerchantId,
merchantBaseSceneCodeList, merchantBaseSceneCodeList,
staffDailyReportCarBrand, staffDailyReportCarBrand,
dailyReportDiscussionStaffList dailyReportDiscussionStaffList
......
...@@ -194,6 +194,7 @@ function saveMockDynamicDetail(params = {}) { ...@@ -194,6 +194,7 @@ function saveMockDynamicDetail(params = {}) {
id: dailyReportRecordId || prev.id || prev.dailyReportRecordId || Date.now(), id: dailyReportRecordId || prev.id || prev.dailyReportRecordId || Date.now(),
dailyReportRecordId: dailyReportRecordId || prev.dailyReportRecordId || Date.now(), dailyReportRecordId: dailyReportRecordId || prev.dailyReportRecordId || Date.now(),
baseSceneCode: prev.baseSceneCode ?? BOUTIQUE_PAGE_CONTEXT.baseSceneCode, baseSceneCode: prev.baseSceneCode ?? BOUTIQUE_PAGE_CONTEXT.baseSceneCode,
reportStatus: '1',
fieldDataList: fieldDataList ?? prev.fieldDataList ?? [], fieldDataList: fieldDataList ?? prev.fieldDataList ?? [],
jsonContent: jsonContent ?? prev.jsonContent ?? '', jsonContent: jsonContent ?? prev.jsonContent ?? '',
subformDataList: subformDataList ?? prev.subformDataList ?? [] subformDataList: subformDataList ?? prev.subformDataList ?? []
......
...@@ -74,6 +74,7 @@ function saveMockNegotiationDynamicDetail(params = {}) { ...@@ -74,6 +74,7 @@ function saveMockNegotiationDynamicDetail(params = {}) {
reportTemplateId: reportTemplateId || prev.reportTemplateId || DEFAULT_REPORT_TEMPLATE_ID, reportTemplateId: reportTemplateId || prev.reportTemplateId || DEFAULT_REPORT_TEMPLATE_ID,
dailyReportRecordId: dailyReportRecordId || prev.dailyReportRecordId || Date.now(), dailyReportRecordId: dailyReportRecordId || prev.dailyReportRecordId || Date.now(),
baseSceneCode: prev.baseSceneCode ?? null, baseSceneCode: prev.baseSceneCode ?? null,
reportStatus: '1',
fieldDataList: fieldDataList ?? prev.fieldDataList ?? [], fieldDataList: fieldDataList ?? prev.fieldDataList ?? [],
subformDataList: subformDataList ?? prev.subformDataList ?? [], subformDataList: subformDataList ?? prev.subformDataList ?? [],
jsonContent: jsonContent ?? prev.jsonContent ?? '' jsonContent: jsonContent ?? prev.jsonContent ?? ''
......
...@@ -38,6 +38,13 @@ const { isNegotiationMockMode } = require('../config/apiSwitch.js') ...@@ -38,6 +38,13 @@ const { isNegotiationMockMode } = require('../config/apiSwitch.js')
const { fetchDailyReportCarBrandList: fetchCarBrandListImpl } = require('./dailyReportCarBrand.js') const { fetchDailyReportCarBrandList: fetchCarBrandListImpl } = require('./dailyReportCarBrand.js')
const { normalizeDailyReportUserInfo } = require('../utils/user-merchant.js') const { normalizeDailyReportUserInfo } = require('../utils/user-merchant.js')
const { const {
unwrapApiResponse,
resolveDetailGetResponse,
isApiSuccess,
isEmptyDetailPayload
} = require('../utils/api-response.js')
const { normalizeReportStatus } = require('../utils/report-status.js')
const {
DAILY_REPORT_TEMPLATE_TYPE, DAILY_REPORT_TEMPLATE_TYPE,
DAILY_REPORT_SOURCE DAILY_REPORT_SOURCE
} = require('../config/dailyReportConstants.js') } = require('../config/dailyReportConstants.js')
...@@ -84,11 +91,7 @@ function buildPageContextFromSources({ ...@@ -84,11 +91,7 @@ function buildPageContextFromSources({
/** 统一 API 响应结构 { code, message, data } */ /** 统一 API 响应结构 { code, message, data } */
function unwrapResponse(result = {}) { function unwrapResponse(result = {}) {
return { return unwrapApiResponse(result)
code: result.code,
message: result.message || '请求失败',
data: result.data
}
} }
/** /**
...@@ -219,6 +222,7 @@ function buildEmptyDetail(reportTemplateId) { ...@@ -219,6 +222,7 @@ function buildEmptyDetail(reportTemplateId) {
return { return {
reportTemplateId: reportTemplateId || NEGOTIATION_DEFAULT_REPORT_TEMPLATE_ID, reportTemplateId: reportTemplateId || NEGOTIATION_DEFAULT_REPORT_TEMPLATE_ID,
dailyReportRecordId: null, dailyReportRecordId: null,
reportStatus: '0',
values: {} values: {}
} }
} }
...@@ -254,18 +258,14 @@ async function fetchReportDetail({ ...@@ -254,18 +258,14 @@ async function fetchReportDetail({
reportTemplateId, reportTemplateId,
sceneType sceneType
}) })
const { code, message, data } = unwrapResponse(result) const resolved = resolveDetailGetResponse(result, buildEmptyDetail, reportTemplateId)
if (code != 0) { if (!isApiSuccess(resolved.code)) {
return { code: code ?? -1, message, data: null } return resolved
} }
if (!data) { if (isEmptyDetailPayload(result?.data)) {
return { return resolved
code: 0,
message: 'ok',
data: buildEmptyDetail(reportTemplateId)
}
} }
return normalizeDetailResponse(data, reportTemplateId) return normalizeDetailResponse(resolved.data, reportTemplateId)
} }
/** 将 adapter 返回的 detail 规范化为 { reportTemplateId, dailyReportRecordId, baseSceneCode, values } */ /** 将 adapter 返回的 detail 规范化为 { reportTemplateId, dailyReportRecordId, baseSceneCode, values } */
...@@ -278,6 +278,7 @@ function normalizeDetailResponse(detail = {}, reportTemplateId) { ...@@ -278,6 +278,7 @@ function normalizeDetailResponse(detail = {}, reportTemplateId) {
reportTemplateId: detail.reportTemplateId || reportTemplateId || NEGOTIATION_DEFAULT_REPORT_TEMPLATE_ID, reportTemplateId: detail.reportTemplateId || reportTemplateId || NEGOTIATION_DEFAULT_REPORT_TEMPLATE_ID,
dailyReportRecordId: recordId, dailyReportRecordId: recordId,
baseSceneCode: detail.baseSceneCode, baseSceneCode: detail.baseSceneCode,
reportStatus: normalizeReportStatus(detail.reportStatus),
values: parseJsonContentDetailValues(detail.jsonContent, []), values: parseJsonContentDetailValues(detail.jsonContent, []),
jsonContent: detail.jsonContent, jsonContent: detail.jsonContent,
fieldDataList: detail.fieldDataList || [], fieldDataList: detail.fieldDataList || [],
......
...@@ -130,7 +130,7 @@ async function fetchSchemaRootAdapter(params = {}) { ...@@ -130,7 +130,7 @@ async function fetchSchemaRootAdapter(params = {}) {
} }
/** /**
* 拉取门店场景列表(mock 或 findAllSceneByMerchantId + sceneCache) * 拉取门店场景列表(mock 或 merchantBaseSceneCodeList + sceneCache)
* @param {Object} [params={}] merchantId * @param {Object} [params={}] merchantId
* @returns {Promise<{code: number, message: string, data: Array}>} * @returns {Promise<{code: number, message: string, data: Array}>}
*/ */
......
...@@ -46,6 +46,13 @@ const { ...@@ -46,6 +46,13 @@ const {
const { const {
normalizeDailyReportUserInfo normalizeDailyReportUserInfo
} = require('../utils/user-merchant.js') } = require('../utils/user-merchant.js')
const {
unwrapApiResponse,
resolveDetailGetResponse,
isApiSuccess,
isEmptyDetailPayload
} = require('../utils/api-response.js')
const { normalizeReportStatus } = require('../utils/report-status.js')
const IS_PRODUCTION = envIndex === 3 const IS_PRODUCTION = envIndex === 3
...@@ -94,11 +101,7 @@ function buildPageContextFromSources({ ...@@ -94,11 +101,7 @@ function buildPageContextFromSources({
/** 统一 API 响应结构 { code, message, data } */ /** 统一 API 响应结构 { code, message, data } */
function unwrapResponse(result = {}) { function unwrapResponse(result = {}) {
return { return unwrapApiResponse(result)
code: result.code,
message: result.message || '请求失败',
data: result.data
}
} }
/** 场景列表兜底为数组 */ /** 场景列表兜底为数组 */
...@@ -106,11 +109,6 @@ function normalizeSceneListData(data) { ...@@ -106,11 +109,6 @@ function normalizeSceneListData(data) {
return Array.isArray(data) ? data : [] return Array.isArray(data) ? data : []
} }
/** detail 响应解包,同 unwrapResponse */
function unwrapDetailPayload(result = {}) {
return unwrapResponse(result)
}
/** /**
* 获取门店可选场景列表并解析 baseSceneCode * 获取门店可选场景列表并解析 baseSceneCode
* @param {Object} [options={}] * @param {Object} [options={}]
...@@ -240,6 +238,7 @@ function buildEmptyDetail(reportTemplateId) { ...@@ -240,6 +238,7 @@ function buildEmptyDetail(reportTemplateId) {
return { return {
reportTemplateId: reportTemplateId || STAFF_DEFAULT_REPORT_TEMPLATE_ID, reportTemplateId: reportTemplateId || STAFF_DEFAULT_REPORT_TEMPLATE_ID,
dailyReportRecordId: null, dailyReportRecordId: null,
reportStatus: '0',
values: {} values: {}
} }
} }
...@@ -275,18 +274,14 @@ async function fetchReportDetail({ ...@@ -275,18 +274,14 @@ async function fetchReportDetail({
reportTemplateId, reportTemplateId,
sceneType sceneType
}) })
const { code, message, data } = unwrapDetailPayload(result) const resolved = resolveDetailGetResponse(result, buildEmptyDetail, reportTemplateId)
if (code != 0) { if (!isApiSuccess(resolved.code)) {
return { code: code ?? -1, message, data: null } return resolved
} }
if (!data) { if (isEmptyDetailPayload(result?.data)) {
return { return resolved
code: 0,
message: 'ok',
data: buildEmptyDetail(reportTemplateId)
}
} }
return normalizeDetailResponse(data, reportTemplateId) return normalizeDetailResponse(resolved.data, reportTemplateId)
} }
/** 将 adapter 返回的 detail 规范化为 { reportTemplateId, dailyReportRecordId, baseSceneCode, values } */ /** 将 adapter 返回的 detail 规范化为 { reportTemplateId, dailyReportRecordId, baseSceneCode, values } */
...@@ -299,6 +294,7 @@ function normalizeDetailResponse(detail = {}, reportTemplateId) { ...@@ -299,6 +294,7 @@ function normalizeDetailResponse(detail = {}, reportTemplateId) {
reportTemplateId: detail.reportTemplateId || reportTemplateId || STAFF_DEFAULT_REPORT_TEMPLATE_ID, reportTemplateId: detail.reportTemplateId || reportTemplateId || STAFF_DEFAULT_REPORT_TEMPLATE_ID,
dailyReportRecordId: recordId, dailyReportRecordId: recordId,
baseSceneCode: detail.baseSceneCode, baseSceneCode: detail.baseSceneCode,
reportStatus: normalizeReportStatus(detail.reportStatus),
values: parseJsonContentDetailValues(detail.jsonContent, []), values: parseJsonContentDetailValues(detail.jsonContent, []),
jsonContent: detail.jsonContent, jsonContent: detail.jsonContent,
fieldDataList: detail.fieldDataList || [], fieldDataList: detail.fieldDataList || [],
......
...@@ -122,7 +122,7 @@ async function fetchSchemaRootAdapter(params = {}) { ...@@ -122,7 +122,7 @@ async function fetchSchemaRootAdapter(params = {}) {
} }
/** /**
* 拉取门店场景列表(mock 或 findAllSceneByMerchantId + sceneCache) * 拉取门店场景列表(mock 或 merchantBaseSceneCodeList + sceneCache)
* @param {Object} [params={}] merchantId * @param {Object} [params={}] merchantId
* @returns {Promise<{code: number, message: string, data: Array}>} * @returns {Promise<{code: number, message: string, data: Array}>}
*/ */
......
...@@ -49,6 +49,12 @@ const { DAILY_REPORT_TEMPLATE_TYPE, DAILY_REPORT_SOURCE } = require('../config/d ...@@ -49,6 +49,12 @@ const { DAILY_REPORT_TEMPLATE_TYPE, DAILY_REPORT_SOURCE } = require('../config/d
const { const {
normalizeDailyReportUserInfo normalizeDailyReportUserInfo
} = require('../utils/user-merchant.js') } = require('../utils/user-merchant.js')
const {
unwrapApiResponse,
resolveDetailGetResponse,
isApiSuccess,
isEmptyDetailPayload
} = require('../utils/api-response.js')
const IS_PRODUCTION = envIndex === 3 const IS_PRODUCTION = envIndex === 3
...@@ -148,11 +154,7 @@ function buildPageContextFromSources({ ...@@ -148,11 +154,7 @@ function buildPageContextFromSources({
/** 统一 API 响应结构 { code, message, data } */ /** 统一 API 响应结构 { code, message, data } */
function unwrapResponse(result = {}) { function unwrapResponse(result = {}) {
return { return unwrapApiResponse(result)
code: result.code,
message: result.message || '请求失败',
data: result.data
}
} }
/** /**
...@@ -319,18 +321,14 @@ async function fetchReportDetail({ ...@@ -319,18 +321,14 @@ async function fetchReportDetail({
reportTemplateId, reportTemplateId,
sceneType sceneType
}) })
const { code, message, data } = unwrapResponse(result) const resolved = resolveDetailGetResponse(result, buildEmptyDetail, reportTemplateId)
if (code != 0) { if (!isApiSuccess(resolved.code)) {
return { code: code ?? -1, message, data: null } return resolved
} }
if (!data) { if (isEmptyDetailPayload(result?.data)) {
return { return resolved
code: 0,
message: 'ok',
data: buildEmptyDetail(reportTemplateId)
}
} }
return normalizeDetailResponse(data, reportTemplateId) return normalizeDetailResponse(resolved.data, reportTemplateId)
} }
/** /**
......
...@@ -122,7 +122,7 @@ async function fetchSchemaRootAdapter(params = {}) { ...@@ -122,7 +122,7 @@ async function fetchSchemaRootAdapter(params = {}) {
} }
/** /**
* 拉取门店场景列表(mock 或 findAllSceneByMerchantId + sceneCache) * 拉取门店场景列表(mock 或 merchantBaseSceneCodeList + sceneCache)
* @param {Object} [params={}] merchantId * @param {Object} [params={}] merchantId
* @returns {Promise<{code: number, message: string, data: Array}>} * @returns {Promise<{code: number, message: string, data: Array}>}
*/ */
......
const negotiationApi = require('../../api/negotiationDailyReport.js') const negotiationApi = require('../../api/negotiationDailyReport.js')
const { isApiSuccess } = require('../../utils/api-response.js')
import { buildNegotiationSummaryTables } from '../../form-engine/negotiation-summary-transform.js' import { buildNegotiationSummaryTables } from '../../form-engine/negotiation-summary-transform.js'
Component({ Component({
...@@ -109,7 +110,7 @@ Component({ ...@@ -109,7 +110,7 @@ Component({
reportDate, reportDate,
sceneType sceneType
}) })
if (res.code !== 0) { if (!isApiSuccess(res.code)) {
this.setData({ this.setData({
loadError: res.message || '加载失败', loadError: res.message || '加载失败',
loadComplete: true loadComplete: true
...@@ -149,7 +150,7 @@ Component({ ...@@ -149,7 +150,7 @@ Component({
reportDate, reportDate,
sceneType sceneType
}) })
if (res.code !== 0 || !res.data) { if (!isApiSuccess(res.code) || !res.data) {
this.setData({ sections: [], sectionNavIndex: [] }) this.setData({ sections: [], sectionNavIndex: [] })
return return
} }
......
# DEVLOG — packageDynamicForm # DEVLOG — packageDynamicForm
## 2026-06-15 — 详情回显按 sceneList 过滤 baseSceneCode
- **问题**:`detailEchoSpec` 白名单内 bypass `baseSceneSpec`,跨精品/权益 jsonContent 整块回显。
- **修复**:echo 仍跳过 brand/filterBrandId,但继续用 `pageContext.sceneList`(来自 `merchantBaseSceneCode.list`)校验 `field.baseSceneCode`。
- **单测**:`IT-VIS-SPEC-006` / `IT-VIS-SPEC-007`。
## 2026-06-15 — 驻店日报 7 天可填 + 新老互斥跳转
- **7 天窗口**:`staffDailyReport` 对齐旧 `staffDaily`(`isDateWithin7Days` / 可选 `editableDay`);支持 `reportDate` 入参定位周历。
- **首页互斥**:`isNeed=true` 时展示「驻店日报-新」并隐藏旧 `staff_daily_report`;`false` 仅旧入口。
- **下单跳转**:[`staffDailyReportNavigation.js`](../../utils/staffDailyReportNavigation.js) 统一按白名单跳转新/老驻店页。
## 2026-06-15 — 三份日报提交后只读 + 编辑解锁
- **交互**:对齐旧版 `tabWorkOrder/pages/staffDaily`:当天已提交 → 表单只读 +「编辑」;编辑态「保存」「取消」;换日重置 `isEditReport`。
- **已提交判定**:`reportStatus=1` 或 `weeklyList` 含当日([`daily-report-edit-state.js`](../utils/daily-report-edit-state.js))。
- **实现**:三页共用 `dailyReportPageMethods`(`syncReportSubmittedState` / `editReport` / `cancelReport`);驻店/洽谈 `detail` 透传 `reportStatus`。
## 2026-06-15 — 三份日报 sceneType 与 carBrandList ## 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`)。 - **接口**:`detail.get` / `weekly.list` / `discussion.staff.list` / `monthly.pending.get` / `dynamic.save` / `dynamic.draft.save` 增加 `sceneType`;保存增加 `yqMerchantId`、`yqMerchantName`;`dynamic.save` 与 `dynamic.draft.save` 的 `requestJson` 均增加 `carBrandList`(来源 `staff.daily.report.car.brand`)。
- **场景**:`findAllSceneByMerchantId` 替换为 `staffBaseInfo.merchant.baseSceneCode.list`(返参 `list<String>` 归一化为 `sceneList`)。 - **场景**:`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`。 - **实现**:[`dailyReportCarBrand.js`](../api/dailyReportCarBrand.js)、[`save-request.js`](../form-engine/save-request.js)、[`dailyReportBootstrap.js`](../services/dailyReportBootstrap.js) 加载时并行拉取 `carBrandList` 写入 `pageContext`。
......
# 动态表单综合指南 # 动态表单综合指南
> 约 3 分钟快速了解 `packageDynamicForm`。团队技术分享请阅 [TECH-SHARE.md](./TECH-SHARE.md);更细专题见文末「更多资料」。 > 约 3 分钟快速了解 `packageDynamicForm`(偏**日报业务**速查)。公共组件架构与接入方式见 [TECH-SHARE.md](./TECH-SHARE.md);更细专题见文末「更多资料」。
--- ---
......
...@@ -32,11 +32,16 @@ ...@@ -32,11 +32,16 @@
| 状态 | TEST-ID | | 状态 | TEST-ID |
|------|---------| |------|---------|
| 当天可编辑 + 提交 | IT-PAGE-002 | | 7 天内可编辑 + 提交 | IT-PAGE-002 |
| 非当天只读 | IT-PAGE-005 | | 7 天外只读 | IT-PAGE-005 |
| 当天已提交只读 + 编辑解锁 | IT-PAGE-002 |
| 调休仅出勤可见 | IT-PAGE-006 | | 调休仅出勤可见 | IT-PAGE-006 |
| 加载失败空态 | IT-PAGE-008 | | 加载失败空态 | IT-PAGE-008 |
**可编辑窗口**:与旧 `tabWorkOrder/staffDaily` 一致,近 **7 天**(`isDateWithin7Days`);工资申诉回填时可能扩大至 `editableDay`(上月 1 日起)。底部按钮在 7 天内显示。
**路由**:支持 `?reportDate=yyyy-MM-dd`(下单/待办跳转昨日)。
### 保存 ### 保存
- **提交**:`dynamic.save` → `buildDailyReportSaveRequest` → `buildDynamicSavePayload`(`normalizedFieldDataList: true`);经 `buildAppDailyReportSubmitPayload` 先 lists、后 jsonContent(详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md)) - **提交**:`dynamic.save` → `buildDailyReportSaveRequest` → `buildDynamicSavePayload`(`normalizedFieldDataList: true`);经 `buildAppDailyReportSubmitPayload` 先 lists、后 jsonContent(详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md))
...@@ -107,7 +112,7 @@ ...@@ -107,7 +112,7 @@
- **保存并提交**:点击后 `wx.showModal`(标题「重要提示」,文案「确认提交后将不可再编辑,确认继续?」);确定后 `dynamic.save`(先校验);成功/失败 Toast「提交成功」「提交失败」 - **保存并提交**:点击后 `wx.showModal`(标题「重要提示」,文案「确认提交后将不可再编辑,确认继续?」);确定后 `dynamic.save`(先校验);成功/失败 Toast「提交成功」「提交失败」
- **保存**:直接 `dynamic.draft.save`(跳过必填校验);成功/失败 Toast「操作成功」「操作失败」 - **保存**:直接 `dynamic.draft.save`(跳过必填校验);成功/失败 Toast「操作成功」「操作失败」
- **jsonContent 形态**:顶层 `value`(如 F2-1);subform 入库 **`childrenValue` + `origin_children`**(无 `children`);远程 select 在 `childrenValue` 行内为 `{ text, value }`;提交前 lists 仍由含 `children` 的 formList 生成。详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md) - **jsonContent 形态**:顶层 `value`(如 F2-1);subform 入库 **`childrenValue` + `origin_children`**(无 `children`);远程 select 在 `childrenValue` 行内为 `{ text, value }`;提交前 lists 仍由含 `children` 的 formList 生成。详见 [daily-report-save-and-json.md](./daily-report-save-and-json.md)
- **reportStatus**:`0` 草稿 / `1` 已提交;当天 `reportStatus=1` 只读并隐藏保存/提交按钮 - **reportStatus**:`0` 草稿 / `1` 已提交;当天已提交(`reportStatus=1` 或 `weeklyList` 含当日)表单只读,底部显示「编辑」;点编辑后「保存」「取消」;草稿态仍「提交」「保存」
### 洽谈明细表汇总 ### 洽谈明细表汇总
...@@ -213,15 +218,17 @@ ...@@ -213,15 +218,17 @@
| 页面 | 状态 | 触发 | UI 预期 | TEST-ID | | 页面 | 状态 | 触发 | UI 预期 | TEST-ID |
|------|------|------|---------|---------| |------|------|------|---------|---------|
| staffDailyReport | 当天可编辑 | 选中当天(含已提交) | 可编辑 + 底部「提交」 | IT-PAGE-002 | | staffDailyReport | 7 天内未提交 | 选中日在 7 天内且无记录 | 可编辑 +「提交」 | IT-PAGE-002 |
| staffDailyReport | 非当天只读 | 选中非当天 | 灰色 disabled,无底部按钮 | IT-PAGE-005 | | staffDailyReport | 7 天内已提交 | 已提交且未点编辑 | 只读 +「编辑」 | IT-PAGE-002 |
| staffDailyReport | 7 天外只读 | 选中日超出 7 天 | 灰色 disabled,无底部按钮 | IT-PAGE-005 |
| staffDailyReport | 调休 | F1-1 选「调休」 | 仅出勤可见,其余隐藏并清值 | IT-PAGE-006 | | staffDailyReport | 调休 | F1-1 选「调休」 | 仅出勤可见,其余隐藏并清值 | IT-PAGE-006 |
| staffDailyReport | 加载失败 / 场景为空 | 接口失败或 scene 空 | 「暂无数据」或空态 +「重新加载」 | IT-PAGE-008 / IT-LOADER-003 | | staffDailyReport | 加载失败 / 场景为空 | 接口失败或 scene 空 | 「暂无数据」或空态 +「重新加载」 | IT-PAGE-008 / IT-LOADER-003 |
| storeDailyReport | 当天未提交 | 当天且 reportStatus=0 | 可编辑 +「保存并提交」「保存」「洽谈汇总」 | IT-STORE-PAGE-002 | | storeDailyReport | 当天未提交 | 当天且 reportStatus=0 | 可编辑 +「保存并提交」「保存」「洽谈汇总」 | IT-STORE-PAGE-002 |
| storeDailyReport | 当天已提交 | 当天且 reportStatus=1 | 只读;无提交/保存;**仍保留**洽谈汇总 | IT-STORE-PAGE-009 | | storeDailyReport | 当天已提交 | 当天且已提交 | 只读 +「编辑」;编辑态「保存」「取消」;**仍保留**洽谈汇总 | IT-STORE-PAGE-009 |
| storeDailyReport | 非当天只读 | 选中非当天 | 只读;无底部按钮(含洽谈汇总) | IT-STORE-PAGE-005 | | storeDailyReport | 非当天只读 | 选中非当天 | 只读;无底部按钮(含洽谈汇总) | IT-STORE-PAGE-005 |
| storeDailyReport | 加载失败 / 场景为空 | 同驻店 | 空态 +「重新加载」 | IT-STORE-PAGE-008 / IT-STORE-LOADER-003 | | storeDailyReport | 加载失败 / 场景为空 | 同驻店 | 空态 +「重新加载」 | IT-STORE-PAGE-008 / IT-STORE-LOADER-003 |
| negotiationDetail | 当天可编辑 | 周历选中当天 | 可编辑 + F3 subform + 底部「提交」 | IT-PAGE-001 | | negotiationDetail | 当天未提交 | 周历选中当天 | 可编辑 + F3 subform + 底部「提交」 | IT-PAGE-001 |
| negotiationDetail | 当天已提交 | 当天且已提交 | 只读 +「编辑」;编辑态「保存」「取消」 | IT-PAGE-001 |
| negotiationDetail | 非当天只读 | 周历选中非当天 | 只读变灰 + 无底部按钮 | IT-PAGE-001 | | negotiationDetail | 非当天只读 | 周历选中非当天 | 只读变灰 + 无底部按钮 | IT-PAGE-001 |
| negotiationDetail | 场景为空 | scene 空 | 「暂无数据」+「重新加载」 | IT-LOADER-003 | | negotiationDetail | 场景为空 | scene 空 | 「暂无数据」+「重新加载」 | IT-LOADER-003 |
...@@ -249,7 +256,7 @@ ...@@ -249,7 +256,7 @@
| 维度 | 来源 | | 维度 | 来源 |
|------|------| |------|------|
| `sceneList` | `findAllSceneByMerchantId` | | `sceneList` | `staffBaseInfo.merchant.baseSceneCode.list`(返参归一化为 `[{ baseSceneCode }]`) |
| `brandIds` | `merchants.api.open.merchant.info`(`getMerchantCarBrandList`) | | `brandIds` | `merchants.api.open.merchant.info`(`getMerchantCarBrandList`) |
运行时显隐用 `ctx.brandIds` 与 `ctx.sceneList`;`brandIdMap` 仅 mock 字典。 运行时显隐用 `ctx.brandIds` 与 `ctx.sceneList`;`brandIdMap` 仅 mock 字典。
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
| 文档 | 用途 | | 文档 | 用途 |
|------|------| |------|------|
| [**动态表单综合指南**](./DYNAMIC-FORM-GUIDE.md) | **快速入门**:已有功能、配置方式、后期拓展 | | [**动态表单综合指南**](./DYNAMIC-FORM-GUIDE.md) | **快速入门**:已有功能、配置方式、后期拓展 |
| [**TECH-SHARE.md**](./TECH-SHARE.md) | **技术分享**:能力边界、架构概览、**拓展展望** | | [**TECH-SHARE.md**](./TECH-SHARE.md) | **公共组件技术分享(口述稿)**:背景、预研问题、方案选型、待验证与扩展 |
| [ARCHITECTURE.md](./ARCHITECTURE.md) | 分层职责与数据流 | | [ARCHITECTURE.md](./ARCHITECTURE.md) | 分层职责与数据流 |
| [PAGES.md](./PAGES.md) | 三页对照、加载/保存、页面状态、单测映射 | | [PAGES.md](./PAGES.md) | 三页对照、加载/保存、页面状态、单测映射 |
| [MAINTENANCE.md](./MAINTENANCE.md) | 后续开发 checklist 与注释模板 | | [MAINTENANCE.md](./MAINTENANCE.md) | 后续开发 checklist 与注释模板 |
......
...@@ -36,7 +36,7 @@ sequenceDiagram ...@@ -36,7 +36,7 @@ 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?, carBrandList? })`,与 `jsonContent` 同级字符串)。空 `subformDataList` 在 `requestJson` 对象内**不传**;`carBrandList` 仅在 **`dynamic.save` 正式提交**时写入(草稿 `dynamic.draft.save` 不传)。`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`** 的 `requestJson` 中均写入(`pageContext.carBrandList` 非空时)。`buildDailyReportSaveRequest` 返回值中的 lists 仍为数组,供 mock 回显。
**顶层保存字段**(三页共用):除原有 `merchantId` / `merchantName` / `staffUuid` 等外,增加 `yqMerchantId`、`yqMerchantName`、`sceneType`(0 会员权益/升级,1 精品升级)。`carBrandList` 来源:加载时 [`staff.daily.report.car.brand`](../api/dailyReportCarBrand.js) 写入 `pageContext.carBrandList`。 **顶层保存字段**(三页共用):除原有 `merchantId` / `merchantName` / `staffUuid` 等外,增加 `yqMerchantId`、`yqMerchantName`、`sceneType`(0 会员权益/升级,1 精品升级)。`carBrandList` 来源:加载时 [`staff.daily.report.car.brand`](../api/dailyReportCarBrand.js) 写入 `pageContext.carBrandList`。
...@@ -94,6 +94,8 @@ App 草稿 `saveReport` 仅做 childrenValue 序列化、**不产** fieldDataLis ...@@ -94,6 +94,8 @@ App 草稿 `saveReport` 仅做 childrenValue 序列化、**不产** fieldDataLis
## 3. 回显(detail.get) ## 3. 回显(detail.get)
**无记录成功**:接口 `code` 为 `0` / `"0"` 且 `data: null`(或空)视为成功,与 App 一致;[`fetchReportDetail`](../api/staffDailyReport.js) 经 [`resolveDetailGetResponse`](../utils/api-response.js) 映射为 `buildEmptyDetail`(`dailyReportRecordId: null`、`values: {}`),正常加载空白表单。
| 步骤 | 函数 | 说明 | | 步骤 | 函数 | 说明 |
|------|------|------| |------|------|------|
| 解析 jsonContent | [`normalizeJsonContentList`](../form-engine/app-subform-json.js) | 兼容 string / array / `{ list: [] }` | | 解析 jsonContent | [`normalizeJsonContentList`](../form-engine/app-subform-json.js) | 兼容 string / array / `{ list: [] }` |
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
| F3-3 | 其他品牌洽谈明细 (延保/权益) | `filterBrandId` 排除已知品牌,`brandId:[]` | 3 | 4(F3-3-14~17) | | F3-3 | 其他品牌洽谈明细 (延保/权益) | `filterBrandId` 排除已知品牌,`brandId:[]` | 3 | 4(F3-3-14~17) |
| F3-4 | 洽谈明细 (轻改) | `sceneType:[1]`,`baseSceneCode:[100101,100102,100103]` | —(无 orderList) | — | | F3-4 | 洽谈明细 (轻改) | `sceneType:[1]`,`baseSceneCode:[100101,100102,100103]` | —(无 orderList) | — |
新建日显隐:[`visibility.js`](../form-engine/visibility.js)。详情回显白名单:`hasDetailEcho` + `echoSubformKeys`(见 PAGES.md)。 新建日显隐:[`visibility.js`](../form-engine/visibility.js)。详情回显:`hasDetailEcho` + `echoSubformKeys` 跳过 brand 限制,**仍按** `sceneList` ↔ `baseSceneCode` 过滤(见 PAGES.md)。
--- ---
......
...@@ -20,7 +20,12 @@ ...@@ -20,7 +20,12 @@
| `store_daily_report` | 门店日报 | 同上 | | `store_daily_report` | 门店日报 | 同上 |
| `negotiation_detail` | 洽谈明细 | 同上 | | `negotiation_detail` | 洽谈明细 | 同上 |
旧「驻店日报」(`tabWorkOrder.staffDaily`) 与「驻店日报-新」并存。 旧「驻店日报」与「驻店日报-新」**互斥**(`isNeed` 白名单):
- `isNeed=true`:展示动态三入口(含 `staff_daily_report_new`),**隐藏** registry 中 `staff_daily_report`(精品→`upgradeStaffDaily` / 权益→`staffDaily`)
- `isNeed=false`:仅保留旧「驻店日报」,不注入动态三入口
**下单/待办跳转**:[`staffDailyReportNavigation.js`](../../utils/staffDailyReportNavigation.js) 按同一 `isNeed` 规则跳转新页或旧页(`ModalToQueueControl`、待办、部分内联下单校验已接入)。
**网关显隐**:[`dailyReportNewVersionGate.js`](../../utils/dailyReportNewVersionGate.js) → `dailyReport.new.version.isNeed`(`merchantId`=4S 店);角色通过且 `data===true` 才展示三入口。详见原全站 Menu 契约(`IT-MENU-001` / `IT-MENU-002`)。 **网关显隐**:[`dailyReportNewVersionGate.js`](../../utils/dailyReportNewVersionGate.js) → `dailyReport.new.version.isNeed`(`merchantId`=4S 店);角色通过且 `data===true` 才展示三入口。详见原全站 Menu 契约(`IT-MENU-001` / `IT-MENU-002`)。
......
...@@ -68,7 +68,7 @@ function buildDailyReportSaveRequest({ ...@@ -68,7 +68,7 @@ function buildDailyReportSaveRequest({
const carBrandList = pageContext.carBrandList const carBrandList = pageContext.carBrandList
const requestJsonOptions = const requestJsonOptions =
!forDraft && Array.isArray(carBrandList) && carBrandList.length > 0 Array.isArray(carBrandList) && carBrandList.length > 0
? { carBrandList } ? { carBrandList }
: {} : {}
......
...@@ -101,7 +101,7 @@ function resolveEchoTopLevelKeys(ctx = {}) { ...@@ -101,7 +101,7 @@ function resolveEchoTopLevelKeys(ctx = {}) {
return new Set(Array.isArray(fromCtx) ? fromCtx : []) return new Set(Array.isArray(fromCtx) ? fromCtx : [])
} }
/** 详情 jsonContent 回显范围内:跳过 brandId / filterBrandId / baseSceneCode 模板过滤 */ /** 详情 jsonContent 回显范围内:跳过 brandId / filterBrandId;baseSceneCode 仍由 baseSceneSpec 校验 */
function isInDetailEchoScope(field = {}, ctx = {}, options = {}) { function isInDetailEchoScope(field = {}, ctx = {}, options = {}) {
if (!ctx.hasDetailEcho) { if (!ctx.hasDetailEcho) {
return false return false
......
/** 详情 jsonContent 回显范围:跳过模版 brand/scene 过滤 */ /** 详情 jsonContent 回显范围:跳过模版 brand/filterBrandId;baseSceneCode 由 specs/index 层校验 */
import { isSubform, isStaticGroup } from '../../field-types.js' import { isSubform, isStaticGroup } from '../../field-types.js'
import { ATTENDANCE_KEY, isDividerVisible } from '../../visibility.js' import { ATTENDANCE_KEY, isDividerVisible } from '../../visibility.js'
......
...@@ -14,8 +14,12 @@ export const visibilitySpecs = [ ...@@ -14,8 +14,12 @@ export const visibilitySpecs = [
/** 与 visibility.isFieldVisible 等价 */ /** 与 visibility.isFieldVisible 等价 */
export function isFieldVisibleBySpecs(field, ctx, values, options = {}) { export function isFieldVisibleBySpecs(field, ctx, values, options = {}) {
const echoResult = detailEchoSpec(field, ctx, values, options) const echoResult = detailEchoSpec(field, ctx, values, options)
if (echoResult !== null) { if (echoResult === false) {
return echoResult === true return false
}
if (echoResult === true) {
// 详情回显:跳过 brand/filterBrandId,仍按 sceneList 校验 baseSceneCode
return baseSceneSpec(field, ctx, values, options)
} }
if (!fieldShowRuleSpec(field, ctx, values, options)) { if (!fieldShowRuleSpec(field, ctx, values, options)) {
return false return false
......
...@@ -9,6 +9,9 @@ const { ...@@ -9,6 +9,9 @@ const {
patchGroupRowMapForKey patchGroupRowMapForKey
} = require('../../utils/merge-form-group-view.js') } = require('../../utils/merge-form-group-view.js')
const { resolveApiFailureMessage } = require('../../utils/api-failure-message.js') const { resolveApiFailureMessage } = require('../../utils/api-failure-message.js')
const {
resolveReportSubmittedPatch
} = require('../../utils/daily-report-edit-state.js')
const dailyReportPageMethods = { const dailyReportPageMethods = {
getEngineKey(reportDate) { getEngineKey(reportDate) {
...@@ -101,6 +104,52 @@ const dailyReportPageMethods = { ...@@ -101,6 +104,52 @@ const dailyReportPageMethods = {
/** 提交/保存失败 Toast:优先后端 message,其次异常 message */ /** 提交/保存失败 Toast:优先后端 message,其次异常 message */
showSubmitFailureToast(res, error, fallback = '提交失败') { showSubmitFailureToast(res, error, fallback = '提交失败') {
wx.$util.showToast(resolveApiFailureMessage(res, error, fallback)) wx.$util.showToast(resolveApiFailureMessage(res, error, fallback))
},
/** 从 detail + weeklyList 同步 reportStatus / isReportSubmitted */
syncReportSubmittedState(detail = {}) {
const patch = resolveReportSubmittedPatch({
detail,
reportDate: this.data.reportDate,
weeklyList: this.data.weeklyList || []
})
Object.assign(this.data, patch)
this.setData(patch)
return patch.isReportSubmitted
},
/** 进入编辑态(已提交日报解锁) */
editReport() {
this.data.isEditReport = true
this.setData({
isEditReport: true,
formDisabled: false
})
},
/** 退出编辑态,不重载详情 */
cancelReport() {
this.data.isEditReport = false
this.setData({
isEditReport: false,
formDisabled:
typeof this.getFormDisabled === 'function'
? this.getFormDisabled()
: !!this.data.formDisabled
})
},
/** 换周/换日时重置编辑态 */
resetEditReport() {
if (!this.data.isEditReport) return
this.data.isEditReport = false
this.setData({
isEditReport: false,
formDisabled:
typeof this.getFormDisabled === 'function'
? this.getFormDisabled()
: !!this.data.formDisabled
})
} }
} }
......
...@@ -13,6 +13,8 @@ var timeUtil = require('~/utils/timeFormat/time-utils.js') ...@@ -13,6 +13,8 @@ var timeUtil = require('~/utils/timeFormat/time-utils.js')
const { parseGroupErrorKey } = require('../../form-engine/group-values.js') const { parseGroupErrorKey } = require('../../form-engine/group-values.js')
const negotiationApi = require('../../api/negotiationDailyReport.js') const negotiationApi = require('../../api/negotiationDailyReport.js')
const { loadNegotiationDailyForm } = require('../../services/negotiationDailyFormLoader.js') const { loadNegotiationDailyForm } = require('../../services/negotiationDailyFormLoader.js')
const { isApiSuccess } = require('../../utils/api-response.js')
const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-state.js')
const vinOcrBridge = require('../../services/vinOcrBridge.js') const vinOcrBridge = require('../../services/vinOcrBridge.js')
const { resolveVinFieldContext } = require('../../services/vin-ocr-context.js') const { resolveVinFieldContext } = require('../../services/vin-ocr-context.js')
const carBrandPickerBridge = require('../../services/carBrandPickerBridge.js') const carBrandPickerBridge = require('../../services/carBrandPickerBridge.js')
...@@ -55,6 +57,9 @@ Page({ ...@@ -55,6 +57,9 @@ Page({
reportDate: '', reportDate: '',
weeklyList: [], weeklyList: [],
isTodayReport: true, isTodayReport: true,
reportStatus: '0',
isReportSubmitted: false,
isEditReport: false,
merchantName: '', merchantName: '',
fixedFields: [], fixedFields: [],
sectionGroups: [], sectionGroups: [],
...@@ -131,24 +136,32 @@ Page({ ...@@ -131,24 +136,32 @@ Page({
/** 切换周历周偏移并同步 data */ /** 切换周历周偏移并同步 data */
applyCalendarState(selectWeek, timeBeanInput) { applyCalendarState(selectWeek, timeBeanInput) {
this.resetEditReport()
const state = this.buildCalendarState(selectWeek, timeBeanInput) const state = this.buildCalendarState(selectWeek, timeBeanInput)
Object.assign(this.data, state) Object.assign(this.data, state)
state.formDisabled = this.getFormDisabled()
this.setData(state) this.setData(state)
return state return state
}, },
/** 周历点击选日:更新 timeBean.selectDay */ /** 周历点击选日:更新 timeBean.selectDay */
applyDaySelect(selectDay) { applyDaySelect(selectDay) {
this.resetEditReport()
const timeBean = { ...this.data.timeBean, selectDay } const timeBean = { ...this.data.timeBean, selectDay }
const state = this.buildCalendarState(this.data.selectWeek, timeBean) const state = this.buildCalendarState(this.data.selectWeek, timeBean)
Object.assign(this.data, state) Object.assign(this.data, state)
state.formDisabled = this.getFormDisabled()
this.setData(state) this.setData(state)
return state return state
}, },
/** 非当天时为只读 */ /** 非当天只读;当天已提交且未点编辑时只读 */
getFormDisabled() { getFormDisabled() {
return !this.data.isTodayReport return isDailyReportFormDisabled({
isTodayReport: this.data.isTodayReport,
isReportSubmitted: this.data.isReportSubmitted,
isEditReport: this.data.isEditReport
})
}, },
/** 复制当前 subform 各 group 的活跃行索引 */ /** 复制当前 subform 各 group 的活跃行索引 */
...@@ -382,10 +395,12 @@ Page({ ...@@ -382,10 +395,12 @@ Page({
...item, ...item,
hasDailyValue: weeklyList.includes(item.date) hasDailyValue: weeklyList.includes(item.date)
})) }))
Object.assign(this.data, { timeBean, weeklyList })
this.setData({ this.setData({
timeBean, timeBean,
weeklyList weeklyList
}) })
this.syncReportSubmittedState({ reportStatus: this.data.reportStatus })
}, },
/** 拉取 weekly.list 更新周历标记 */ /** 拉取 weekly.list 更新周历标记 */
...@@ -448,7 +463,7 @@ Page({ ...@@ -448,7 +463,7 @@ Page({
reportTemplateId: this.reportTemplateId reportTemplateId: this.reportTemplateId
}) })
if (this.isStaleLoad(seq)) return if (this.isStaleLoad(seq)) return
if (loadRes.code !== 0 || !loadRes.data) { if (!isApiSuccess(loadRes.code) || !loadRes.data) {
const message = loadRes.message || '加载失败' const message = loadRes.message || '加载失败'
this.setData({ loadError: message }) this.setData({ loadError: message })
return wx.$util.showToast(message) return wx.$util.showToast(message)
...@@ -458,6 +473,7 @@ Page({ ...@@ -458,6 +473,7 @@ Page({
this.pageContext = pageContext || null this.pageContext = pageContext || null
this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId
this.dailyReportRecordId = detail.dailyReportRecordId || null this.dailyReportRecordId = detail.dailyReportRecordId || null
this.syncReportSubmittedState(detail)
const engine = this.ensureEngine(this.getEngineKey(reportDate)) const engine = this.ensureEngine(this.getEngineKey(reportDate))
const finalViewState = engine.init(schema, { const finalViewState = engine.init(schema, {
...@@ -503,6 +519,9 @@ Page({ ...@@ -503,6 +519,9 @@ Page({
if (!this.data.isTodayReport) { if (!this.data.isTodayReport) {
return wx.$util.showToast('仅支持填写当天日报') return wx.$util.showToast('仅支持填写当天日报')
} }
if (this.data.isReportSubmitted && !this.data.isEditReport) {
return wx.$util.showToast('日报已提交,不可再编辑')
}
wx.$util.showLoading() wx.$util.showLoading()
try { try {
cancelPendingVinDebounce() cancelPendingVinDebounce()
...@@ -538,7 +557,7 @@ Page({ ...@@ -538,7 +557,7 @@ Page({
dailyReportRecordId: this.dailyReportRecordId, dailyReportRecordId: this.dailyReportRecordId,
reportDate: this.data.reportDate reportDate: this.data.reportDate
}) })
if (res.code !== 0) { if (!isApiSuccess(res.code)) {
return this.showSubmitFailureToast(res, null) return this.showSubmitFailureToast(res, null)
} }
if (res.data?.dailyReportRecordId) { if (res.data?.dailyReportRecordId) {
...@@ -566,10 +585,12 @@ Page({ ...@@ -566,10 +585,12 @@ Page({
reportTemplateId: this.reportTemplateId reportTemplateId: this.reportTemplateId
}) })
if (this.isStaleRefresh(seq)) return if (this.isStaleRefresh(seq)) return
if (loadRes.code !== 0 || !loadRes.data) return if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues } = loadRes.data const { schema, detail, initialValues } = loadRes.data
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.syncReportSubmittedState(detail)
this.resetEditReport()
if (!this.engine) return if (!this.engine) return
const ctx = this.engine.getPageContext() const ctx = this.engine.getPageContext()
const viewState = this.engine.init(schema, { const viewState = this.engine.init(schema, {
......
...@@ -51,6 +51,12 @@ page { ...@@ -51,6 +51,12 @@ page {
flex-direction: column; flex-direction: column;
} }
.btns-con--stack .confirm,
.btns-con--stack .save {
width: 100%;
flex: none;
}
.btns .confirm, .btns .confirm,
.btns .save, .btns .save,
.btns .summary-btn { .btns .summary-btn {
......
...@@ -53,8 +53,17 @@ ...@@ -53,8 +53,17 @@
bind:groupchange="onGroupChange" bind:groupchange="onGroupChange"
></dynamic-form> ></dynamic-form>
<view class="btns"> <view class="btns">
<view class="btns-con btns-con--stack"> <view class="btns-con btns-con--stack" wx:if="{{ isTodayReport }}">
<view wx:if="{{ isTodayReport }}" class="confirm text-center" bindtap="submit">保存</view> <block wx:if="{{ !isReportSubmitted }}">
<view class="confirm text-center" bindtap="submit">提交</view>
</block>
<block wx:else>
<view wx:if="{{ !isEditReport }}" class="confirm text-center" bindtap="editReport">编辑</view>
<block wx:else>
<view class="confirm text-center" bindtap="submit">保存</view>
<view class="save text-center" bindtap="cancelReport">取消</view>
</block>
</block>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
......
...@@ -14,18 +14,26 @@ var timeUtil = require('~/utils/timeFormat/time-utils.js') ...@@ -14,18 +14,26 @@ var timeUtil = require('~/utils/timeFormat/time-utils.js')
const { parseGroupErrorKey } = require('../../form-engine/group-values.js') const { parseGroupErrorKey } = require('../../form-engine/group-values.js')
const staffDailyApi = require('../../api/staffDailyReport.js') const staffDailyApi = require('../../api/staffDailyReport.js')
const { loadStaffDailyForm } = require('../../services/staffDailyFormLoader.js') const { loadStaffDailyForm } = require('../../services/staffDailyFormLoader.js')
const { isApiSuccess } = require('../../utils/api-response.js')
const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-state.js')
const { resolveWeekStateForReportDate } = require('../../utils/daily-report-calendar.js')
const dailyReportPage = require('../behaviors/dailyReportPage.js') const dailyReportPage = require('../behaviors/dailyReportPage.js')
Page({ Page({
behaviors: [dailyReportPage], behaviors: [dailyReportPage],
data: { data: {
navBarHeight: 0, navBarHeight: 0,
pageTitle: '驻店日报-新', pageTitle: '驻店日报',
selectWeek: 0, selectWeek: 0,
timeBean: {}, timeBean: {},
reportDate: '', reportDate: '',
weeklyList: [], weeklyList: [],
isTodayReport: true, isTodayReport: true,
isDateWithin7Days: true,
editableDay: '',
reportStatus: '0',
isReportSubmitted: false,
isEditReport: false,
merchantName: '', merchantName: '',
fixedFields: [], fixedFields: [],
sectionGroups: [], sectionGroups: [],
...@@ -51,7 +59,7 @@ Page({ ...@@ -51,7 +59,7 @@ Page({
engineKey: '', engineKey: '',
_submitting: false, _submitting: false,
/** 页面加载:初始化周历、拉 weekly 标记、加载当日表单 */ /** 页面加载:初始化周历、拉 weekly 标记、加载表单 */
onLoad(options = {}) { onLoad(options = {}) {
if (options.reportTemplateId) { if (options.reportTemplateId) {
this.reportTemplateId = Number(options.reportTemplateId) || options.reportTemplateId this.reportTemplateId = Number(options.reportTemplateId) || options.reportTemplateId
...@@ -60,11 +68,35 @@ Page({ ...@@ -60,11 +68,35 @@ Page({
if (ctx.shopMerchantName) { if (ctx.shopMerchantName) {
this.setData({ merchantName: ctx.shopMerchantName }) this.setData({ merchantName: ctx.shopMerchantName })
} }
this.applyCalendarState(this.data.selectWeek) if (options.reportDate) {
const { selectWeek, timeBean } = resolveWeekStateForReportDate(options.reportDate)
this.applyCalendarState(selectWeek, timeBean)
} else {
this.applyCalendarState(this.data.selectWeek)
}
this.salaryapplyFillCheck()
this.refreshWeeklyList() this.refreshWeeklyList()
this.loadFormData() this.loadFormData()
}, },
/** 工资申诉回填场景:扩大可编辑起始日(对齐旧 staffDaily) */
salaryapplyFillCheck() {
const comApi = require('~/api/api.js')
const dayjs = require('dayjs')
comApi
.salaryapplyFillCheck({})
.then(res => {
if (!res?.data) return
const editableDay = dayjs().subtract(1, 'M').startOf('M').format('YYYY-MM-DD')
this.data.editableDay = editableDay
const state = this.buildCalendarState(this.data.selectWeek, this.data.timeBean)
state.formDisabled = this.getFormDisabled()
Object.assign(this.data, state)
this.setData(state)
})
.catch(() => {})
},
/** 自定义导航栏高度回调 */ /** 自定义导航栏高度回调 */
navbarReady(e) { navbarReady(e) {
const height = e?.detail?.height const height = e?.detail?.height
...@@ -74,7 +106,7 @@ Page({ ...@@ -74,7 +106,7 @@ Page({
}) })
}, },
/** 根据 selectWeek 计算 reportDate、isTodayReport、formDisabled */ /** 根据 selectWeek 计算 reportDate、可编辑窗口、formDisabled */
buildCalendarState(selectWeek, timeBeanInput) { buildCalendarState(selectWeek, timeBeanInput) {
const timeBean = timeBeanInput || timeUtil.getWeekDayList(selectWeek) const timeBean = timeBeanInput || timeUtil.getWeekDayList(selectWeek)
const selectDay = timeBean.selectDay ?? 0 const selectDay = timeBean.selectDay ?? 0
...@@ -83,36 +115,49 @@ Page({ ...@@ -83,36 +115,49 @@ Page({
const time = new Date(date) const time = new Date(date)
timeBean.yearMonth = `${time.getFullYear()}-${time.getMonth() + 1}` timeBean.yearMonth = `${time.getFullYear()}-${time.getMonth() + 1}`
} }
const limitDate = this.data.editableDay || undefined
const isTodayReport = date ? timeUtil.isTodayReport(date) : true const isTodayReport = date ? timeUtil.isTodayReport(date) : true
const isDateWithin7Days = date
? timeUtil.isDateWithin7Days(date, limitDate)
: true
return { return {
timeBean, timeBean,
selectWeek, selectWeek,
reportDate: date, reportDate: date,
isTodayReport, isTodayReport,
formDisabled: !isTodayReport isDateWithin7Days,
formDisabled: !isDateWithin7Days
} }
}, },
/** 切换周历周偏移并同步 data */ /** 切换周历周偏移并同步 data */
applyCalendarState(selectWeek, timeBeanInput) { applyCalendarState(selectWeek, timeBeanInput) {
this.resetEditReport()
const state = this.buildCalendarState(selectWeek, timeBeanInput) const state = this.buildCalendarState(selectWeek, timeBeanInput)
Object.assign(this.data, state) Object.assign(this.data, state)
state.formDisabled = this.getFormDisabled()
this.setData(state) this.setData(state)
return state return state
}, },
/** 周历点击选日:更新 timeBean.selectDay */ /** 周历点击选日:更新 timeBean.selectDay */
applyDaySelect(selectDay) { applyDaySelect(selectDay) {
this.resetEditReport()
const timeBean = { ...this.data.timeBean, selectDay } const timeBean = { ...this.data.timeBean, selectDay }
const state = this.buildCalendarState(this.data.selectWeek, timeBean) const state = this.buildCalendarState(this.data.selectWeek, timeBean)
Object.assign(this.data, state) Object.assign(this.data, state)
state.formDisabled = this.getFormDisabled()
this.setData(state) this.setData(state)
return state return state
}, },
/** 非当天时为只读(驻店无 reportStatus 锁定) */ /** 7 天外只读;已提交且未点编辑时只读 */
getFormDisabled() { getFormDisabled() {
return !this.data.isTodayReport return isDailyReportFormDisabled({
isDateWithinEditableWindow: this.data.isDateWithin7Days,
isReportSubmitted: this.data.isReportSubmitted,
isEditReport: this.data.isEditReport
})
}, },
/** 复制当前 subform 各 group 的活跃行索引 */ /** 复制当前 subform 各 group 的活跃行索引 */
...@@ -239,10 +284,12 @@ Page({ ...@@ -239,10 +284,12 @@ Page({
...item, ...item,
hasDailyValue: weeklyList.includes(item.date) hasDailyValue: weeklyList.includes(item.date)
})) }))
Object.assign(this.data, { timeBean, weeklyList })
this.setData({ this.setData({
timeBean, timeBean,
weeklyList weeklyList
}) })
this.syncReportSubmittedState({ reportStatus: this.data.reportStatus })
}, },
/** 拉取 weekly.list 更新周历标记 */ /** 拉取 weekly.list 更新周历标记 */
...@@ -301,7 +348,7 @@ Page({ ...@@ -301,7 +348,7 @@ Page({
reportTemplateId: this.reportTemplateId reportTemplateId: this.reportTemplateId
}) })
if (this.isStaleLoad(seq)) return if (this.isStaleLoad(seq)) return
if (loadRes.code !== 0 || !loadRes.data) { if (!isApiSuccess(loadRes.code) || !loadRes.data) {
this.setData({ loadError: loadRes.message || '加载失败' }) this.setData({ loadError: loadRes.message || '加载失败' })
console.error('[staffDailyReport] loadFormData failed', loadRes) console.error('[staffDailyReport] loadFormData failed', loadRes)
return return
...@@ -310,6 +357,7 @@ Page({ ...@@ -310,6 +357,7 @@ Page({
const { pageContext, schema, detail, initialValues } = loadRes.data const { pageContext, schema, detail, initialValues } = loadRes.data
this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId this.reportTemplateId = detail.reportTemplateId || this.reportTemplateId
this.dailyReportRecordId = detail.dailyReportRecordId || null this.dailyReportRecordId = detail.dailyReportRecordId || null
this.syncReportSubmittedState(detail)
const engine = this.ensureEngine(this.getEngineKey(reportDate)) const engine = this.ensureEngine(this.getEngineKey(reportDate))
const finalViewState = engine.init(schema, { const finalViewState = engine.init(schema, {
...@@ -352,8 +400,11 @@ Page({ ...@@ -352,8 +400,11 @@ Page({
return wx.$util.showToast('正在提交中,请稍候') return wx.$util.showToast('正在提交中,请稍候')
} }
if (!this.engine) return if (!this.engine) return
if (!this.data.isTodayReport) { if (!this.data.isDateWithin7Days) {
return wx.$util.showToast('仅支持填写当天日报') return wx.$util.showToast('已超过提交时效')
}
if (this.data.isReportSubmitted && !this.data.isEditReport) {
return wx.$util.showToast('日报已提交,不可再编辑')
} }
const validation = this.engine.validate() const validation = this.engine.validate()
if (!validation.ok) { if (!validation.ok) {
...@@ -377,7 +428,7 @@ Page({ ...@@ -377,7 +428,7 @@ Page({
dailyReportRecordId: this.dailyReportRecordId, dailyReportRecordId: this.dailyReportRecordId,
reportDate: this.data.reportDate reportDate: this.data.reportDate
}) })
if (res.code !== 0) { if (!isApiSuccess(res.code)) {
return this.showSubmitFailureToast(res, null) return this.showSubmitFailureToast(res, null)
} }
if (res.data?.dailyReportRecordId) { if (res.data?.dailyReportRecordId) {
...@@ -406,10 +457,12 @@ Page({ ...@@ -406,10 +457,12 @@ Page({
reportTemplateId: this.reportTemplateId reportTemplateId: this.reportTemplateId
}) })
if (this.isStaleRefresh(seq)) return if (this.isStaleRefresh(seq)) return
if (loadRes.code !== 0 || !loadRes.data) return if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues } = loadRes.data const { schema, detail, initialValues } = loadRes.data
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.syncReportSubmittedState(detail)
this.resetEditReport()
if (!this.engine) return if (!this.engine) return
const ctx = this.engine.getPageContext() const ctx = this.engine.getPageContext()
const viewState = this.engine.init(schema, { const viewState = this.engine.init(schema, {
......
...@@ -43,6 +43,16 @@ page { ...@@ -43,6 +43,16 @@ page {
box-sizing: border-box; box-sizing: border-box;
} }
.btns-con--stack {
flex-direction: column;
}
.btns-con--stack .confirm,
.btns-con--stack .save {
width: 100%;
flex: none;
}
.btns .confirm, .btns .confirm,
.btns .save { .btns .save {
flex: 1; flex: 1;
......
...@@ -50,9 +50,18 @@ ...@@ -50,9 +50,18 @@
bind:groupnav="onGroupNav" bind:groupnav="onGroupNav"
bind:groupchange="onGroupChange" bind:groupchange="onGroupChange"
></dynamic-form> ></dynamic-form>
<view class="btns" wx:if="{{ isTodayReport }}"> <view class="btns" wx:if="{{ isDateWithin7Days }}">
<view class="btns-con"> <view class="btns-con btns-con--stack">
<view class="confirm text-center" bindtap="submit">保存</view> <block wx:if="{{ !isReportSubmitted }}">
<view class="confirm text-center" bindtap="submit">提交</view>
</block>
<block wx:else>
<view wx:if="{{ !isEditReport }}" class="confirm text-center" bindtap="editReport">编辑</view>
<block wx:else>
<view class="confirm text-center" bindtap="submit">保存</view>
<view class="save text-center" bindtap="cancelReport">取消</view>
</block>
</block>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
......
...@@ -14,12 +14,13 @@ var timeUtil = require('~/utils/timeFormat/time-utils.js') ...@@ -14,12 +14,13 @@ var timeUtil = require('~/utils/timeFormat/time-utils.js')
const { parseGroupErrorKey } = require('../../form-engine/group-values.js') const { parseGroupErrorKey } = require('../../form-engine/group-values.js')
const storeDailyApi = require('../../api/storeDailyReport.js') const storeDailyApi = require('../../api/storeDailyReport.js')
const { loadStoreDailyForm } = require('../../services/storeDailyFormLoader.js') const { loadStoreDailyForm } = require('../../services/storeDailyFormLoader.js')
const { isReportSubmitted } = require('../../utils/report-status.js') const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-state.js')
const { resolveSaveMerchantId } = require('../../utils/user-merchant.js') const { resolveSaveMerchantId } = require('../../utils/user-merchant.js')
const { const {
STORE_MONTHLY_PENDING_FIELD_KEY, STORE_MONTHLY_PENDING_FIELD_KEY,
shouldFetchMonthlyPendingCount shouldFetchMonthlyPendingCount
} = require('../../utils/store-monthly-pending.js') } = require('../../utils/store-monthly-pending.js')
const { isApiSuccess } = require('../../utils/api-response.js')
const { const {
STORE_STAFF_LIST_FIELD_KEY, STORE_STAFF_LIST_FIELD_KEY,
STORE_STAFF_COUNT_FIELD_KEY, STORE_STAFF_COUNT_FIELD_KEY,
...@@ -43,6 +44,7 @@ Page({ ...@@ -43,6 +44,7 @@ Page({
isTodayReport: true, isTodayReport: true,
reportStatus: '0', reportStatus: '0',
isReportSubmitted: false, isReportSubmitted: false,
isEditReport: false,
merchantName: '', merchantName: '',
fixedFields: [], fixedFields: [],
sectionGroups: [], sectionGroups: [],
...@@ -115,34 +117,37 @@ Page({ ...@@ -115,34 +117,37 @@ Page({
/** 切换周历周偏移并同步 data */ /** 切换周历周偏移并同步 data */
applyCalendarState(selectWeek, timeBeanInput) { applyCalendarState(selectWeek, timeBeanInput) {
this.resetEditReport()
const state = this.buildCalendarState(selectWeek, timeBeanInput) const state = this.buildCalendarState(selectWeek, timeBeanInput)
Object.assign(this.data, state) Object.assign(this.data, state)
state.formDisabled = this.getFormDisabled()
this.setData(state) this.setData(state)
return state return state
}, },
/** 周历点击选日:更新 timeBean.selectDay */ /** 周历点击选日:更新 timeBean.selectDay */
applyDaySelect(selectDay) { applyDaySelect(selectDay) {
this.resetEditReport()
const timeBean = { ...this.data.timeBean, selectDay } const timeBean = { ...this.data.timeBean, selectDay }
const state = this.buildCalendarState(this.data.selectWeek, timeBean) const state = this.buildCalendarState(this.data.selectWeek, timeBean)
Object.assign(this.data, state) Object.assign(this.data, state)
state.formDisabled = this.getFormDisabled()
this.setData(state) this.setData(state)
return state return state
}, },
/** 从详情同步 reportStatus,已提交则当天只读 */ /** 从详情同步 reportStatus / isReportSubmitted(含 weeklyList 兜底) */
applyReportStatusFromDetail(detail = {}) { applyReportStatusFromDetail(detail = {}) {
const reportStatus = detail.reportStatus != null ? String(detail.reportStatus) : '0' return this.syncReportSubmittedState(detail)
const submitted = isReportSubmitted(reportStatus)
Object.assign(this.data, { reportStatus, isReportSubmitted: submitted })
this.setData({ reportStatus, isReportSubmitted: submitted })
return submitted
}, },
/** 非当天只读;当天已提交只读 */ /** 非当天只读;当天已提交且未点编辑时只读 */
getFormDisabled() { getFormDisabled() {
if (!this.data.isTodayReport) return true return isDailyReportFormDisabled({
return this.data.isReportSubmitted isTodayReport: this.data.isTodayReport,
isReportSubmitted: this.data.isReportSubmitted,
isEditReport: this.data.isEditReport
})
}, },
/** F2-1 有选人时给 F2-2 打 disabled,供 dynamic-form 字段级只读 */ /** F2-1 有选人时给 F2-2 打 disabled,供 dynamic-form 字段级只读 */
...@@ -304,10 +309,12 @@ Page({ ...@@ -304,10 +309,12 @@ Page({
...item, ...item,
hasDailyValue: weeklyList.includes(item.date) hasDailyValue: weeklyList.includes(item.date)
})) }))
Object.assign(this.data, { timeBean, weeklyList })
this.setData({ this.setData({
timeBean, timeBean,
weeklyList weeklyList
}) })
this.syncReportSubmittedState({ reportStatus: this.data.reportStatus })
}, },
/** 拉取 weekly.list(templateType=2)更新周历标记 */ /** 拉取 weekly.list(templateType=2)更新周历标记 */
...@@ -400,7 +407,7 @@ Page({ ...@@ -400,7 +407,7 @@ Page({
reportTemplateId: this.reportTemplateId reportTemplateId: this.reportTemplateId
}) })
if (this.isStaleLoad(seq)) return if (this.isStaleLoad(seq)) return
if (loadRes.code !== 0 || !loadRes.data) { if (!isApiSuccess(loadRes.code) || !loadRes.data) {
const message = loadRes.message || '加载失败' const message = loadRes.message || '加载失败'
this.setData({ loadError: message }) this.setData({ loadError: message })
return wx.$util.showToast(message) return wx.$util.showToast(message)
...@@ -472,7 +479,7 @@ Page({ ...@@ -472,7 +479,7 @@ Page({
if (this.isStaleLoad(seq)) { if (this.isStaleLoad(seq)) {
return return
} }
if (res.code !== 0 || res.data == null) { if (!isApiSuccess(res.code) || res.data == null) {
console.warn( console.warn(
'[storeDailyReport] fetchMonthlyPendingCount failed:', '[storeDailyReport] fetchMonthlyPendingCount failed:',
res.message res.message
...@@ -572,7 +579,7 @@ Page({ ...@@ -572,7 +579,7 @@ Page({
wx.$util.showToast('仅支持填写当天日报') wx.$util.showToast('仅支持填写当天日报')
return true return true
} }
if (this.data.isReportSubmitted) { if (this.data.isReportSubmitted && !this.data.isEditReport) {
wx.$util.showToast('日报已提交,不可再编辑') wx.$util.showToast('日报已提交,不可再编辑')
return true return true
} }
...@@ -595,7 +602,7 @@ Page({ ...@@ -595,7 +602,7 @@ Page({
dailyReportRecordId: this.dailyReportRecordId, dailyReportRecordId: this.dailyReportRecordId,
reportDate: this.data.reportDate reportDate: this.data.reportDate
}) })
if (res.code !== 0) { if (!isApiSuccess(res.code)) {
wx.$util.showToast('操作失败') wx.$util.showToast('操作失败')
return return
} }
...@@ -629,9 +636,32 @@ Page({ ...@@ -629,9 +636,32 @@ Page({
}) })
}, },
/** 提交:校验通过后 dynamic.save */ /** 提交:校验通过后 dynamic.save(编辑态重提不再二次确认) */
async submit() { async submit() {
if (this.guardStoreDailyWriteInProgress()) return if (this._savingDraft || this._submitting) {
wx.$util.showToast('正在处理中,请稍候')
return
}
if (!this.engine) {
wx.$util.showToast('表单未加载完成')
return
}
if (this.data.loading || this.data.loadError || !this.data.reportDate) {
wx.$util.showToast('表单未就绪')
return
}
if (!this.data.isTodayReport) {
wx.$util.showToast('仅支持填写当天日报')
return
}
if (this.data.isReportSubmitted && !this.data.isEditReport) {
wx.$util.showToast('日报已提交,不可再编辑')
return
}
if (!this.reportTemplateId) {
wx.$util.showToast('缺少报表模板,请联系运营配置')
return
}
const validation = this.engine.validate() const validation = this.engine.validate()
if (!validation.ok) { if (!validation.ok) {
this.applyEngineView(this.engine.getViewState(), { this.applyEngineView(this.engine.getViewState(), {
...@@ -652,7 +682,7 @@ Page({ ...@@ -652,7 +682,7 @@ Page({
dailyReportRecordId: this.dailyReportRecordId, dailyReportRecordId: this.dailyReportRecordId,
reportDate: this.data.reportDate reportDate: this.data.reportDate
}) })
if (res.code !== 0) { if (!isApiSuccess(res.code)) {
this.showSubmitFailureToast(res, null) this.showSubmitFailureToast(res, null)
return return
} }
...@@ -682,11 +712,12 @@ Page({ ...@@ -682,11 +712,12 @@ Page({
reportTemplateId: this.reportTemplateId reportTemplateId: this.reportTemplateId
}) })
if (this.isStaleRefresh(seq)) return if (this.isStaleRefresh(seq)) return
if (loadRes.code !== 0 || !loadRes.data) return if (!isApiSuccess(loadRes.code) || !loadRes.data) return
const { schema, detail, initialValues } = loadRes.data const { schema, detail, initialValues } = loadRes.data
this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId this.dailyReportRecordId = detail.dailyReportRecordId || this.dailyReportRecordId
this.applyReportStatusFromDetail(detail) this.syncReportSubmittedState(detail)
this.resetEditReport()
if (!this.engine) return if (!this.engine) return
const ctx = this.engine.getPageContext() const ctx = this.engine.getPageContext()
const viewState = this.engine.init(schema, { const viewState = this.engine.init(schema, {
......
...@@ -70,6 +70,13 @@ page { ...@@ -70,6 +70,13 @@ page {
flex-direction: column; flex-direction: column;
} }
.btns-con--stack .confirm,
.btns-con--stack .save,
.btns-con--stack .summary-btn {
width: 100%;
flex: none;
}
.btns .confirm, .btns .confirm,
.btns .save, .btns .save,
.btns .summary-btn { .btns .summary-btn {
......
...@@ -66,16 +66,17 @@ ...@@ -66,16 +66,17 @@
></dynamic-form> ></dynamic-form>
<view class="btns"> <view class="btns">
<view class="btns-con btns-con--stack"> <view class="btns-con btns-con--stack">
<view <block wx:if="{{ isTodayReport && !isReportSubmitted }}">
wx:if="{{ isTodayReport && !isReportSubmitted }}" <view class="confirm text-center" bindtap="onSubmitTap">提交</view>
class="confirm text-center" <view class="save text-center" bindtap="onSaveDraft">保存</view>
bindtap="onSubmitTap" </block>
>提交</view> <block wx:elif="{{ isTodayReport && isReportSubmitted }}">
<view <view wx:if="{{ !isEditReport }}" class="confirm text-center" bindtap="editReport">编辑</view>
wx:if="{{ isTodayReport && !isReportSubmitted }}" <block wx:else>
class="save text-center" <view class="confirm text-center" bindtap="submit">保存</view>
bindtap="onSaveDraft" <view class="save text-center" bindtap="cancelReport">取消</view>
>保存</view> </block>
</block>
<view <view
wx:if="{{ isTodayReport }}" wx:if="{{ isTodayReport }}"
class="summary-btn text-center" class="summary-btn text-center"
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
* @param {number|string} [options.reportTemplateId] * @param {number|string} [options.reportTemplateId]
* @param {Object} api - staffDailyReport | storeDailyReport | negotiationDailyReport 门面 * @param {Object} api - staffDailyReport | storeDailyReport | negotiationDailyReport 门面
*/ */
const { isApiSuccess } = require('../utils/api-response.js')
async function loadDailyForm(options = {}, api) { async function loadDailyForm(options = {}, api) {
if (!api) { if (!api) {
return { code: -1, message: '缺少日报 API 依赖', data: null } return { code: -1, message: '缺少日报 API 依赖', data: null }
...@@ -34,19 +36,19 @@ async function loadDailyForm(options = {}, api) { ...@@ -34,19 +36,19 @@ async function loadDailyForm(options = {}, api) {
}) })
]) ])
if (brandRes.code !== 0) { if (!isApiSuccess(brandRes.code)) {
return { code: brandRes.code, message: brandRes.message || '获取经营品牌失败', data: null } return { code: brandRes.code, message: brandRes.message || '获取经营品牌失败', data: null }
} }
if (sceneRes.code !== 0) { if (!isApiSuccess(sceneRes.code)) {
return { code: sceneRes.code, message: sceneRes.message || '获取门店场景失败', data: null } return { code: sceneRes.code, message: sceneRes.message || '获取门店场景失败', data: null }
} }
if (!Array.isArray(sceneRes.sceneList) || sceneRes.sceneList.length === 0) { if (!Array.isArray(sceneRes.sceneList) || sceneRes.sceneList.length === 0) {
return { code: -1, message: '暂无数据', data: null } return { code: -1, message: '暂无数据', data: null }
} }
if (detailRes.code !== 0) { if (!isApiSuccess(detailRes.code)) {
return { code: detailRes.code, message: detailRes.message || '获取日报详情失败', data: null } return { code: detailRes.code, message: detailRes.message || '获取日报详情失败', data: null }
} }
if (carBrandRes.code !== 0) { if (!isApiSuccess(carBrandRes.code)) {
return { code: carBrandRes.code, message: carBrandRes.message || '获取车型失败', data: null } return { code: carBrandRes.code, message: carBrandRes.message || '获取车型失败', data: null }
} }
...@@ -58,7 +60,7 @@ async function loadDailyForm(options = {}, api) { ...@@ -58,7 +60,7 @@ async function loadDailyForm(options = {}, api) {
merchantScene: sceneRes, merchantScene: sceneRes,
carBrandList: carBrandRes.data || [] carBrandList: carBrandRes.data || []
}) })
if (pageContextRes.code !== 0 || !pageContextRes.data) { if (!isApiSuccess(pageContextRes.code) || !pageContextRes.data) {
return { return {
code: pageContextRes.code ?? -1, code: pageContextRes.code ?? -1,
message: pageContextRes.message || '获取门店场景失败', message: pageContextRes.message || '获取门店场景失败',
...@@ -73,7 +75,7 @@ async function loadDailyForm(options = {}, api) { ...@@ -73,7 +75,7 @@ async function loadDailyForm(options = {}, api) {
merchantId: userContext.merchantId, merchantId: userContext.merchantId,
detail detail
}) })
if (schemaRes.code !== 0) { if (!isApiSuccess(schemaRes.code)) {
return { code: schemaRes.code, message: schemaRes.message || '加载失败', data: null } return { code: schemaRes.code, message: schemaRes.message || '加载失败', data: null }
} }
......
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const { resolveWeekStateForReportDate } = require('../utils/daily-report-calendar.js')
describe('daily-report-calendar', () => {
it('resolveWeekStateForReportDate selects target day in weekDayList', () => {
const { selectWeek, timeBean } = resolveWeekStateForReportDate(
'2026-06-10',
new Date('2026-06-15T12:00:00')
)
assert.equal(typeof selectWeek, 'number')
assert.equal(timeBean.selectDay >= 0, true)
const date = timeBean.weekDayList?.[timeBean.selectDay]?.date
assert.equal(date, '2026-06-10')
})
})
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
isDailyReportSubmitted,
isDailyReportFormDisabled,
resolveReportSubmittedPatch
} = require('../utils/daily-report-edit-state.js')
describe('daily-report-edit-state', () => {
it('isDailyReportSubmitted: reportStatus=1', () => {
assert.equal(
isDailyReportSubmitted({
reportStatus: '1',
reportDate: '2026-06-15',
weeklyList: []
}),
true
)
})
it('isDailyReportSubmitted: weeklyList includes reportDate', () => {
assert.equal(
isDailyReportSubmitted({
reportStatus: '0',
reportDate: '2026-06-15',
weeklyList: ['2026-06-14', '2026-06-15']
}),
true
)
})
it('isDailyReportSubmitted: draft not in weeklyList', () => {
assert.equal(
isDailyReportSubmitted({
reportStatus: '0',
reportDate: '2026-06-15',
weeklyList: []
}),
false
)
})
it('isDailyReportFormDisabled: unlock when isEditReport', () => {
assert.equal(
isDailyReportFormDisabled({
isDateWithinEditableWindow: true,
isReportSubmitted: true,
isEditReport: true
}),
false
)
})
it('isDailyReportFormDisabled: locked when submitted and not editing', () => {
assert.equal(
isDailyReportFormDisabled({
isDateWithinEditableWindow: true,
isReportSubmitted: true,
isEditReport: false
}),
true
)
})
it('isDailyReportFormDisabled: locked outside editable window', () => {
assert.equal(
isDailyReportFormDisabled({
isDateWithinEditableWindow: false,
isReportSubmitted: false,
isEditReport: false
}),
true
)
})
it('isDailyReportFormDisabled: editable within 7-day window', () => {
assert.equal(
isDailyReportFormDisabled({
isDateWithinEditableWindow: true,
isReportSubmitted: false,
isEditReport: false
}),
false
)
})
it('resolveReportSubmittedPatch merges reportStatus and weeklyList', () => {
const patch = resolveReportSubmittedPatch({
detail: { reportStatus: 0 },
reportDate: '2026-06-15',
weeklyList: ['2026-06-15']
})
assert.equal(patch.reportStatus, '0')
assert.equal(patch.isReportSubmitted, true)
})
})
...@@ -374,8 +374,9 @@ describe('dailyReportSaveRequest', async () => { ...@@ -374,8 +374,9 @@ describe('dailyReportSaveRequest', async () => {
assert.deepEqual(lists.carBrandList, carBrandList) assert.deepEqual(lists.carBrandList, carBrandList)
}) })
it('draft save omits requestJson.carBrandList but keeps top-level scene fields', () => { it('draft save includes requestJson.carBrandList and keeps top-level scene fields', () => {
const engine = createFormEngine(schema) const engine = createFormEngine(schema)
const carBrandList = [{ firstBrandId: 1, firstBrandName: 'A', brandId: 1, brandName: 'A' }]
engine.setPageContext({ engine.setPageContext({
baseSceneCode: 100101, baseSceneCode: 100101,
brandIds: [3454], brandIds: [3454],
...@@ -383,7 +384,7 @@ describe('dailyReportSaveRequest', async () => { ...@@ -383,7 +384,7 @@ describe('dailyReportSaveRequest', async () => {
yqMerchantId: 3003, yqMerchantId: 3003,
yqMerchantName: '园区店A', yqMerchantName: '园区店A',
sceneType: 0, sceneType: 0,
carBrandList: [{ firstBrandId: 1, firstBrandName: 'A', brandId: 1, brandName: 'A' }], carBrandList,
sceneList: [{ baseSceneCode: 100101 }] sceneList: [{ baseSceneCode: 100101 }]
}) })
engine.setFieldValue('F1-1', '在岗') engine.setFieldValue('F1-1', '在岗')
...@@ -408,7 +409,7 @@ describe('dailyReportSaveRequest', async () => { ...@@ -408,7 +409,7 @@ describe('dailyReportSaveRequest', async () => {
assert.equal(request.yqMerchantId, 3003) assert.equal(request.yqMerchantId, 3003)
assert.equal(request.sceneType, 0) assert.equal(request.sceneType, 0)
const lists = parseRequestJsonLists(request.requestJson) const lists = parseRequestJsonLists(request.requestJson)
assert.deepEqual(lists.carBrandList, []) assert.deepEqual(lists.carBrandList, carBrandList)
assert.equal(lists.fieldDataList.length > 0, true) assert.equal(lists.fieldDataList.length > 0, true)
}) })
}) })
......
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
isApiSuccess,
resolveDetailGetResponse
} = require('../utils/api-response.js')
const { STAFF_DAILY_API_SWITCH } = require('../config/apiSwitch.js')
const { DAILY_REPORT_TEMPLATE_TYPE } = require('../config/dailyReportConstants.js')
const adapters = require('../api/staffDailyReportAdapters.js')
const { loadStaffDailyForm } = require('../services/staffDailyFormLoader.js')
const schemaIndexed = require('../fixtures/schema-staff-daily-full.js')
const { normalizeConfigToSchemaRoot } = require('../config/configCenter.js')
const schemaTemplate = normalizeConfigToSchemaRoot(schemaIndexed)
function buildStaffEmptyDetail(reportTemplateId) {
return {
reportTemplateId: reportTemplateId || 10001,
dailyReportRecordId: null,
values: {}
}
}
describe('detail.get null response', () => {
it('IT-API-SUCCESS-001: isApiSuccess accepts 0 and "0"', () => {
assert.equal(isApiSuccess(0), true)
assert.equal(isApiSuccess('0'), true)
assert.equal(isApiSuccess(1), false)
assert.equal(isApiSuccess('1'), false)
})
it('IT-DETAIL-NULL-001: detail.get code "0" data null normalizes to empty detail', async () => {
const original = STAFF_DAILY_API_SWITCH.detail
STAFF_DAILY_API_SWITCH.detail = 'real'
adapters.__setDynamicDailyReportApi({
dailyReportDetailGet: async () => ({
code: '0',
data: null,
message: '调用服务成功!',
errId: null
})
})
try {
const raw = await adapters.fetchDetailAdapter({
merchantId: 'shop-1',
staffUuid: 'staff-1',
reportDate: '2026-06-15',
sceneType: 0
})
const resolved = resolveDetailGetResponse(
raw,
buildStaffEmptyDetail,
10001
)
assert.equal(resolved.code, 0)
assert.equal(resolved.data.dailyReportRecordId, null)
assert.deepEqual(resolved.data.values, {})
assert.equal(raw.code, '0')
assert.equal(raw.data, null)
} finally {
adapters.__setDynamicDailyReportApi(null)
STAFF_DAILY_API_SWITCH.detail = original
}
})
it('IT-DETAIL-NULL-001b: resolveDetailGetResponse maps null to buildEmptyDetail', () => {
const empty = { reportTemplateId: 99, dailyReportRecordId: null, values: {} }
const res = resolveDetailGetResponse(
{ code: '0', data: null, message: '调用服务成功!' },
() => empty,
99
)
assert.equal(res.code, 0)
assert.equal(res.data, empty)
})
it('IT-DETAIL-NULL-001c: fetchDetailAdapter real mode passes templateType=1', async () => {
const original = STAFF_DAILY_API_SWITCH.detail
STAFF_DAILY_API_SWITCH.detail = 'real'
let captured = null
adapters.__setDynamicDailyReportApi({
dailyReportDetailGet: async data => {
captured = data
return { code: '0', data: null, message: '调用服务成功!' }
}
})
try {
await adapters.fetchDetailAdapter({
merchantId: 'shop-1',
staffUuid: 'staff-1',
reportDate: '2026-06-15',
sceneType: 0
})
assert.equal(captured.templateType, DAILY_REPORT_TEMPLATE_TYPE.staff)
} finally {
adapters.__setDynamicDailyReportApi(null)
STAFF_DAILY_API_SWITCH.detail = original
}
})
it('IT-DETAIL-NULL-002: loadStaffDailyForm succeeds when detail is empty record', async () => {
const pageContext = {
baseSceneCode: 100101,
brandIds: [3454],
sceneList: [{ baseSceneCode: 100101 }],
merchantId: 'm1'
}
const deps = {
fetchMerchantBrandIds: async () => ({ code: 0, data: [3454] }),
fetchMerchantScene: async () => ({
code: 0,
sceneList: [{ baseSceneCode: 100101 }],
baseSceneCode: 100101
}),
fetchReportDetail: async () => ({
code: 0,
data: {
reportTemplateId: 10001,
dailyReportRecordId: null,
values: {}
}
}),
fetchDailyReportCarBrandList: async () => ({ code: 0, data: [] }),
fetchPageContext: async () => ({ code: 0, data: pageContext }),
fetchSchema: async () => ({ code: 0, data: schemaTemplate })
}
const res = await loadStaffDailyForm(
{
userContext: { merchantId: 'm1', staffUuid: 's1' },
reportDate: '2026-06-15',
reportTemplateId: 10001
},
deps
)
assert.equal(res.code, 0)
assert.ok(res.data.pageContext)
assert.ok(res.data.schema)
assert.equal(res.data.detail.dailyReportRecordId, null)
})
})
...@@ -145,7 +145,7 @@ describe('dynamicFormMenus', async () => { ...@@ -145,7 +145,7 @@ describe('dynamicFormMenus', async () => {
const menu = [] const menu = []
appendDynamicFormTabIndexMenus(menu, [], { sceneType: 1 }) appendDynamicFormTabIndexMenus(menu, [], { sceneType: 1 })
assert.equal(menu.length, 3) assert.equal(menu.length, 3)
assert.ok(menu.some(item => item.name === '驻店日报-新')) assert.ok(menu.some(item => item.name === '驻店日报'))
assert.ok(menu.some(item => item.name === '门店日报')) assert.ok(menu.some(item => item.name === '门店日报'))
assert.ok(menu.some(item => item.name === '洽谈明细')) assert.ok(menu.some(item => item.name === '洽谈明细'))
}) })
...@@ -299,7 +299,7 @@ describe('dynamicFormMenus', async () => { ...@@ -299,7 +299,7 @@ describe('dynamicFormMenus', async () => {
assert.ok(menu.some(item => item.name === '其它')) assert.ok(menu.some(item => item.name === '其它'))
assert.equal( assert.equal(
menu.filter(item => menu.filter(item =>
['洽谈明细', '门店日报', '驻店日报-新'].includes(item.name) ['洽谈明细', '门店日报', '驻店日报'].includes(item.name)
).length, ).length,
3 3
) )
...@@ -378,7 +378,7 @@ describe('dynamicFormMenus', async () => { ...@@ -378,7 +378,7 @@ describe('dynamicFormMenus', async () => {
const menu = [ const menu = [
{ name: '洽谈明细' }, { name: '洽谈明细' },
{ name: '其它' }, { name: '其它' },
{ name: '驻店日报-新' } { name: '驻店日报' }
] ]
const newMenu = [{ name: '门店日报' }] const newMenu = [{ name: '门店日报' }]
stripDynamicFormTabIndexMenus(menu, newMenu) stripDynamicFormTabIndexMenus(menu, newMenu)
...@@ -396,7 +396,7 @@ describe('dynamicFormMenus', async () => { ...@@ -396,7 +396,7 @@ describe('dynamicFormMenus', async () => {
appendDynamicFormTabIndexMenus(menu, newMenu, { sceneType: 1 }) appendDynamicFormTabIndexMenus(menu, newMenu, { sceneType: 1 })
const negotiation = menu.find(item => item.name === '洽谈明细') const negotiation = menu.find(item => item.name === '洽谈明细')
const store = menu.find(item => item.name === '门店日报') const store = menu.find(item => item.name === '门店日报')
const staff = menu.find(item => item.name === '驻店日报-新') const staff = menu.find(item => item.name === '驻店日报')
assert.equal(negotiation.icon, 'negotiationDetail') assert.equal(negotiation.icon, 'negotiationDetail')
assert.equal(store.icon, 'storeDailyReport') assert.equal(store.icon, 'storeDailyReport')
assert.equal(staff.icon, 'staffDailyReport') assert.equal(staff.icon, 'staffDailyReport')
...@@ -404,7 +404,7 @@ describe('dynamicFormMenus', async () => { ...@@ -404,7 +404,7 @@ describe('dynamicFormMenus', async () => {
const menuList = [] const menuList = []
appendDynamicFormEquityMenus(menuList, { sceneType: 0 }) appendDynamicFormEquityMenus(menuList, { sceneType: 0 })
assert.equal(menuList.length, 3) assert.equal(menuList.length, 3)
const equityStaff = menuList.find(item => item.menuText === '驻店日报-新') const equityStaff = menuList.find(item => item.menuText === '驻店日报')
assert.equal(equityStaff.icon, 'staffDailyReport') assert.equal(equityStaff.icon, 'staffDailyReport')
}) })
}) })
...@@ -1796,9 +1796,14 @@ describe('negotiation schema (F3)', async () => { ...@@ -1796,9 +1796,14 @@ describe('negotiation schema (F3)', async () => {
assert.equal(isFieldVisible(f33, echoCtx, {}), true) assert.equal(isFieldVisible(f33, echoCtx, {}), true)
}) })
it('IT-NEG-012: echoSubformKeys includes empty F3-4 in visible list', () => { it('IT-NEG-012: echoSubformKeys includes empty F3-4 in visible list when sceneList matches', () => {
const boutiqueCtx = {
baseSceneCode: 100101,
brandIds: [3454],
sceneList: [{ baseSceneCode: 100101 }]
}
const echoCtx = { const echoCtx = {
...warrantyCtx, ...boutiqueCtx,
hasDetailEcho: true, hasDetailEcho: true,
echoSubformKeys: ['F3-4'] echoSubformKeys: ['F3-4']
} }
...@@ -1863,9 +1868,7 @@ describe('negotiation schema (F3)', async () => { ...@@ -1863,9 +1868,7 @@ describe('negotiation schema (F3)', async () => {
it('IT-ECHO-SCOPE-005: detail echo whitelist shows only jsonContent keys not extra blocks', () => { it('IT-ECHO-SCOPE-005: detail echo whitelist shows only jsonContent keys not extra blocks', () => {
const echoCtx = { const echoCtx = {
baseSceneCode: 100101, ...warrantyCtx,
brandIds: [3454],
sceneList: [{ baseSceneCode: 100101 }],
hasDetailEcho: true, hasDetailEcho: true,
echoSubformKeys: ['F3-1', 'F3-3'], echoSubformKeys: ['F3-1', 'F3-3'],
echoTopLevelKeys: ['F3-1', 'F3-3'] echoTopLevelKeys: ['F3-1', 'F3-3']
......
import { describe, it, mock } from 'node:test'
import assert from 'node:assert/strict'
const wxMock = {
navigateTo: mock.fn(),
$router: { go: mock.fn() },
$util: { getUserInfo: () => ({ sceneType: 1, shopMerchantId: '100' }) },
$hasPermission: {
canSelectMultiStore: () => false,
canSelectMultiStoreForStaffDaily: () => false
}
}
global.wx = wxMock
global.getApp = () => ({ globalData: { isStaff: true } })
const gate = await import('../../utils/dailyReportNewVersionGate.js')
const nav = await import('../../utils/staffDailyReportNavigation.js')
describe('staffDailyReportNavigation', () => {
it('navigateToStaffDailyReport uses new page when isNeed=true', async () => {
gate.clearDailyReportNewVersionCache()
gate.__setApiClientForTest({
dailyReportNewVersionIsNeed: async () => ({ code: 0, data: true })
})
wxMock.navigateTo.mock.resetCalls()
wxMock.$router.go.mock.resetCalls()
await nav.navigateToStaffDailyReport({
userInfo: { sceneType: 1, shopMerchantId: '100' },
reportDate: '2026-06-14'
})
assert.equal(wxMock.navigateTo.mock.calls.length, 1)
assert.match(wxMock.navigateTo.mock.calls[0].arguments[0].url, /staffDailyReport/)
assert.match(wxMock.navigateTo.mock.calls[0].arguments[0].url, /reportDate=2026-06-14/)
assert.equal(wxMock.$router.go.mock.calls.length, 0)
gate.__setApiClientForTest(null)
})
it('navigateToStaffDailyReport uses legacy route when isNeed=false', async () => {
gate.clearDailyReportNewVersionCache()
gate.__setApiClientForTest({
dailyReportNewVersionIsNeed: async () => ({ code: 0, data: false })
})
wxMock.navigateTo.mock.resetCalls()
wxMock.$router.go.mock.resetCalls()
await nav.navigateToStaffDailyReport({
userInfo: { sceneType: 0, shopMerchantId: '100' },
reportDate: '2026-06-14'
})
assert.equal(wxMock.$router.go.mock.calls.length, 1)
assert.equal(wxMock.$router.go.mock.calls[0].arguments[0], 'tabWorkOrder.staffDaily')
assert.equal(wxMock.navigateTo.mock.calls.length, 0)
gate.__setApiClientForTest(null)
})
it('resolveLegacyStaffDailyRoute branches by sceneType', () => {
assert.equal(
nav.resolveLegacyStaffDailyRoute({ sceneType: 0 }).route,
'tabWorkOrder.staffDaily'
)
assert.equal(
nav.resolveLegacyStaffDailyRoute({ sceneType: 1 }).route,
'tabWorkOrder.upgradeStaffDaily'
)
})
})
...@@ -77,6 +77,39 @@ describe('visibility specs', () => { ...@@ -77,6 +77,39 @@ describe('visibility specs', () => {
assert.equal(isFieldVisibleBySpecs(field, ctx, values, options), false) assert.equal(isFieldVisibleBySpecs(field, ctx, values, options), false)
}) })
it('IT-VIS-SPEC-006: detail echo still hides when baseSceneCode mismatches sceneList', () => {
const field = {
key: 'F3-1',
type: 'subform',
baseSceneCode: [110201, 110202],
brandId: [3067]
}
const ctx = {
hasDetailEcho: true,
echoSubformKeys: ['F3-1'],
brandIds: [3067],
sceneList: [{ baseSceneCode: 100101 }]
}
assert.equal(detailEchoSpec(field, ctx, {}, {}), true)
assert.equal(isFieldVisibleBySpecs(field, ctx, {}, {}), false)
})
it('IT-VIS-SPEC-007: detail echo shows when baseSceneCode matches sceneList', () => {
const field = {
key: 'F3-1',
type: 'subform',
baseSceneCode: [110201, 110202],
brandId: [999]
}
const ctx = {
hasDetailEcho: true,
echoSubformKeys: ['F3-1'],
brandIds: [],
sceneList: [{ baseSceneCode: 110201 }]
}
assert.equal(isFieldVisibleBySpecs(field, ctx, {}, {}), true)
})
it('IT-STAFF-OFF-001: on-duty passes detail echo when key not in echoTopLevelKeys', () => { it('IT-STAFF-OFF-001: on-duty passes detail echo when key not in echoTopLevelKeys', () => {
const field = { key: 'F1-5', type: 'group', brandId: [3454], rules: { keys: ['F1-1'], result: 'val1 == "在岗"' } } const field = { key: 'F1-5', type: 'group', brandId: [3454], rules: { keys: ['F1-1'], result: 'val1 == "在岗"' } }
const ctx = { const ctx = {
......
/**
* 日报 API 响应归一 — code 0 / "0" 成功;detail.get data:null 视为无记录
*/
/** @param {*} code */
function isApiSuccess(code) {
return code == 0
}
/**
* @param {Object} [result={}]
* @returns {{ code: number|string, message: string, data: * }}
*/
function unwrapApiResponse(result = {}) {
const code = result.code
return {
code: isApiSuccess(code) ? 0 : code ?? -1,
message: result.message || '请求失败',
data: result.data
}
}
function isEmptyDetailPayload(data) {
return data == null || data === ''
}
/**
* detail.get 响应:成功且 data 为空 → buildEmptyDetail(与 App 无记录语义一致)
* @param {Object} [result={}]
* @param {Function} buildEmptyDetail
* @param {number|string} [reportTemplateId]
* @returns {{ code: number, message: string, data: Object|null }}
*/
function resolveDetailGetResponse(result = {}, buildEmptyDetail, reportTemplateId) {
const { code, message, data } = unwrapApiResponse(result)
if (!isApiSuccess(code)) {
return { code: code ?? -1, message, data: null }
}
if (isEmptyDetailPayload(data)) {
return {
code: 0,
message: 'ok',
data: buildEmptyDetail(reportTemplateId)
}
}
return { code: 0, message, data }
}
module.exports = {
isApiSuccess,
unwrapApiResponse,
resolveDetailGetResponse,
isEmptyDetailPayload
}
var timeUtil = require('../../utils/timeFormat/time-utils.js')
function formatYmd(date) {
const d = date instanceof Date ? date : new Date(date)
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
return `${y}-${m}-${day}`
}
function countSundaysBetween(startDate, endDate) {
const start = new Date(startDate)
const end = new Date(endDate)
let sundays = 0
for (let current = new Date(start); current <= end; current.setDate(current.getDate() + 1)) {
if (current.getDay() === 0) {
sundays++
}
}
return sundays
}
/**
* 根据 reportDate 计算周历 selectWeek / timeBean(对齐旧 staffDaily.initData)
* @param {string} reportDate yyyy-MM-dd
* @param {Date} [now]
*/
function resolveWeekStateForReportDate(reportDate, now = new Date()) {
const target = new Date(reportDate)
const todayStr = formatYmd(now)
let countSundays = countSundaysBetween(reportDate, todayStr)
if (now.getDay() === 0) {
countSundays -= 1
}
const selectWeek = 0 - countSundays
const timeBean = timeUtil.getWeekDayList(selectWeek)
timeBean.selectDay = target.getDay() === 0 ? 6 : target.getDay() - 1
return { selectWeek, timeBean }
}
module.exports = {
formatYmd,
countSundaysBetween,
resolveWeekStateForReportDate
}
const { isReportSubmitted, normalizeReportStatus } = require('./report-status.js')
function isDailyReportSubmitted({ reportStatus, reportDate, weeklyList = [] }) {
if (isReportSubmitted(reportStatus)) return true
if (reportDate && weeklyList.includes(reportDate)) return true
return false
}
function isDailyReportFormDisabled({
isDateWithinEditableWindow,
isTodayReport,
isReportSubmitted: submitted,
isEditReport
}) {
const editable =
isDateWithinEditableWindow !== undefined
? isDateWithinEditableWindow
: isTodayReport
if (!editable) return true
return submitted && !isEditReport
}
function resolveReportSubmittedPatch({ detail = {}, reportDate, weeklyList = [] }) {
const reportStatus = normalizeReportStatus(detail.reportStatus)
const submitted = isDailyReportSubmitted({ reportStatus, reportDate, weeklyList })
return {
reportStatus,
isReportSubmitted: submitted
}
}
module.exports = {
isDailyReportSubmitted,
isDailyReportFormDisabled,
resolveReportSubmittedPatch
}
...@@ -323,5 +323,11 @@ async function resolveDynamicForm(ctx) { ...@@ -323,5 +323,11 @@ async function resolveDynamicForm(ctx) {
} }
) )
}) })
return { dynamicForm: { visible: items.length > 0, items } } return {
dynamicForm: {
visible: items.length > 0,
items,
hideLegacyStaffDaily: items.some(i => i.id === 'staff_daily_report_new')
}
}
} }
...@@ -67,10 +67,14 @@ export async function buildEquityMenusAsync(options = {}) { ...@@ -67,10 +67,14 @@ export async function buildEquityMenusAsync(options = {}) {
const dynamicItems = apiResults.dynamicForm?.items || [] const dynamicItems = apiResults.dynamicForm?.items || []
const menuList = sortBySortVal( let menuList = sortBySortVal(
dedupeById([...syncItems, ...asyncViewModels, ...dynamicItems]) dedupeById([...syncItems, ...asyncViewModels, ...dynamicItems])
) )
if (apiResults.dynamicForm?.hideLegacyStaffDaily) {
menuList = menuList.filter(i => i.id !== 'staff_daily_report')
}
const sideEffects = {} const sideEffects = {}
if (apiResults.sideEffects) { if (apiResults.sideEffects) {
Object.assign(sideEffects, apiResults.sideEffects) Object.assign(sideEffects, apiResults.sideEffects)
......
...@@ -88,7 +88,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -88,7 +88,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '工作日报', label: '工作日报',
icon: 'supervisorDailyNew', icon: 'supervisorDailyNew',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 0, sortVal: 8,
recordId: 15, recordId: 15,
noCheckdailyReport: true, noCheckdailyReport: true,
reportTypeAttr: 'daily', reportTypeAttr: 'daily',
...@@ -101,7 +101,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -101,7 +101,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '工作周报', label: '工作周报',
icon: 'weeklyReport', icon: 'weeklyReport',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 0, sortVal: 9,
recordId: 18, recordId: 18,
noCheckdailyReport: true, noCheckdailyReport: true,
reportTypeAttr: 'weekly', reportTypeAttr: 'weekly',
...@@ -114,7 +114,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -114,7 +114,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '工作月报', label: '工作月报',
icon: 'monthlyReport', icon: 'monthlyReport',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 0, sortVal: 10,
recordId: 19, recordId: 19,
noCheckdailyReport: true, noCheckdailyReport: true,
reportTypeAttr: 'monthly', reportTypeAttr: 'monthly',
...@@ -128,7 +128,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -128,7 +128,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '驻店日报', label: '驻店日报',
icon: 'supplementary_order', icon: 'supplementary_order',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 1, sortVal: 11,
recordId: 13, recordId: 13,
action: { type: 'router', target: 'tabWorkOrder.staffDaily' }, action: { type: 'router', target: 'tabWorkOrder.staffDaily' },
visible: ({ policies }) => policies.staffOrMultiStoreDaily() visible: ({ policies }) => policies.staffOrMultiStoreDaily()
...@@ -138,7 +138,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -138,7 +138,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '新建工单', label: '新建工单',
icon: 'create_order', icon: 'create_order',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 2, sortVal: 1,
beforeClick: 'inspectionOfProhibitionBill', beforeClick: 'inspectionOfProhibitionBill',
action: { type: 'createOrderPrompt', target: '' }, action: { type: 'createOrderPrompt', target: '' },
visible: ({ isStaff }) => isStaff visible: ({ isStaff }) => isStaff
...@@ -148,7 +148,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -148,7 +148,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '战败下单', label: '战败下单',
icon: 'deafeat_order', icon: 'deafeat_order',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 3, sortVal: 2,
action: { action: {
type: 'defeatOrder', type: 'defeatOrder',
target: 'packageEquity.createDeafeatOrderBefore' target: 'packageEquity.createDeafeatOrderBefore'
...@@ -161,7 +161,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -161,7 +161,7 @@ export const EQUITY_MENU_REGISTRY = [
label: 'BI报表', label: 'BI报表',
icon: 'business_data', icon: 'business_data',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 11, sortVal: 21,
recordId: 11, recordId: 11,
action: { type: 'router', target: 'tabOperating.index' }, action: { type: 'router', target: 'tabOperating.index' },
visible: ({ policies }) => policies.canSelectMultiStore() visible: ({ policies }) => policies.canSelectMultiStore()
...@@ -172,7 +172,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -172,7 +172,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '交车目标', label: '交车目标',
icon: 'delivery_target', icon: 'delivery_target',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 9, sortVal: 18,
action: { type: 'router', target: 'packageEquity.deliveryTarget' }, action: { type: 'router', target: 'packageEquity.deliveryTarget' },
visible: ({ policies }) => policies.isDeliveryTargetRole() visible: ({ policies }) => policies.isDeliveryTargetRole()
}, },
...@@ -181,7 +181,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -181,7 +181,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '培训资料', label: '培训资料',
icon: 'peixun_icon', icon: 'peixun_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 7, sortVal: 15,
action: { type: 'router', target: 'packageEquity.trainingMaterials' }, action: { type: 'router', target: 'packageEquity.trainingMaterials' },
visible: ({ policies }) => !policies.canSelectMultiStore() visible: ({ policies }) => !policies.canSelectMultiStore()
}, },
...@@ -190,7 +190,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -190,7 +190,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '场景集市', label: '场景集市',
icon: 'sceneMarket', icon: 'sceneMarket',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 7, sortVal: 16,
action: { action: {
type: 'navigate', type: 'navigate',
target: '/packageEquity/pages/sceneMarket/index/index', target: '/packageEquity/pages/sceneMarket/index/index',
...@@ -205,7 +205,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -205,7 +205,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '招聘管理', label: '招聘管理',
icon: 'recruit-manage', icon: 'recruit-manage',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 12, sortVal: 22,
tipsNum: 0, tipsNum: 0,
action: { type: 'router', target: 'packageEquity.recruitManage' }, action: { type: 'router', target: 'packageEquity.recruitManage' },
visible: ({ policies }) => policies.canViewRecruit() visible: ({ policies }) => policies.canViewRecruit()
...@@ -215,7 +215,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -215,7 +215,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '待审批', label: '待审批',
icon: 'refund_review_icon', icon: 'refund_review_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 13, sortVal: 23,
tipsNum: 0, tipsNum: 0,
action: { action: {
type: 'router', type: 'router',
...@@ -229,7 +229,7 @@ export const EQUITY_MENU_REGISTRY = [ ...@@ -229,7 +229,7 @@ export const EQUITY_MENU_REGISTRY = [
label: '学习中心', label: '学习中心',
icon: 'study-center', icon: 'study-center',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 14, sortVal: 24,
action: { type: 'router', target: 'packageStudyCenter.studyCenter' }, action: { type: 'router', target: 'packageStudyCenter.studyCenter' },
visible: ({ isStaff, policies }) => visible: ({ isStaff, policies }) =>
isStaff && policies.notJiLianChannel() isStaff && policies.notJiLianChannel()
...@@ -253,7 +253,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -253,7 +253,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '工资申诉', label: '工资申诉',
icon: 'salary_appeal_icon', icon: 'salary_appeal_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 15, sortVal: 25,
action: { type: 'router', target: 'packageEquity.salaryAppeal' }, action: { type: 'router', target: 'packageEquity.salaryAppeal' },
provider: 'salaryAppeal' provider: 'salaryAppeal'
}, },
...@@ -262,7 +262,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -262,7 +262,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '接待缺失报备', label: '接待缺失报备',
icon: 'missing-reception', icon: 'missing-reception',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 16, sortVal: 26,
action: { type: 'router', target: 'packageEquity.missingReception' }, action: { type: 'router', target: 'packageEquity.missingReception' },
provider: 'missingReception' provider: 'missingReception'
}, },
...@@ -271,7 +271,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -271,7 +271,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '话术萃取', label: '话术萃取',
icon: 'extract_icon', icon: 'extract_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 5, sortVal: 12,
default: true, default: true,
action: { action: {
type: 'router', type: 'router',
...@@ -285,7 +285,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -285,7 +285,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '话术核验', label: '话术核验',
icon: 'verification_icon', icon: 'verification_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 5, sortVal: 13,
default: true, default: true,
action: { action: {
type: 'router', type: 'router',
...@@ -299,7 +299,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -299,7 +299,7 @@ export const ASYNC_MENU_REGISTRY = [
label: 'AI趣练', label: 'AI趣练',
icon: 'ai_chat', icon: 'ai_chat',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 5, sortVal: 14,
default: true, default: true,
action: { type: 'router', target: 'packageEquity.start' }, action: { type: 'router', target: 'packageEquity.start' },
provider: 'aiFunPractice' provider: 'aiFunPractice'
...@@ -309,7 +309,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -309,7 +309,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '客户线索', label: '客户线索',
icon: 'customer_clue', icon: 'customer_clue',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 6, sortVal: 4,
default: true, default: true,
tipsNum: 0, tipsNum: 0,
action: { type: 'router', target: 'packageEquity.clueList' }, action: { type: 'router', target: 'packageEquity.clueList' },
...@@ -320,7 +320,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -320,7 +320,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '工资绩效', label: '工资绩效',
icon: 'businessschoo', icon: 'businessschoo',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 8, sortVal: 17,
action: { type: 'salaryPerformance' }, action: { type: 'salaryPerformance' },
provider: 'salaryPerformance' provider: 'salaryPerformance'
}, },
...@@ -329,7 +329,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -329,7 +329,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '驻店目标', label: '驻店目标',
icon: 'resident_target', icon: 'resident_target',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 10, sortVal: 19,
action: { type: 'residentTarget', target: 'packageEquity.residentTarget' }, action: { type: 'residentTarget', target: 'packageEquity.residentTarget' },
provider: 'residentTarget' provider: 'residentTarget'
}, },
...@@ -338,7 +338,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -338,7 +338,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '接待记录', label: '接待记录',
icon: 'reception-record-icon', icon: 'reception-record-icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 4, sortVal: 3,
default: true, default: true,
action: { type: 'router', target: 'packageEquity.receptionRecords' }, action: { type: 'router', target: 'packageEquity.receptionRecords' },
provider: 'receptionRecords' provider: 'receptionRecords'
...@@ -348,7 +348,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -348,7 +348,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '违规录音处理', label: '违规录音处理',
icon: 'illegal-recording', icon: 'illegal-recording',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 10, sortVal: 20,
default: true, default: true,
action: { action: {
type: 'navigate', type: 'navigate',
......
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
checkStudyTask, checkStudyTask,
checkAbnormalOrder, checkAbnormalOrder,
} from "~/store/ModalToQueueControl"; } from "~/store/ModalToQueueControl";
import { navigateToStaffDailyReport } from "~/utils/staffDailyReportNavigation.js";
import dataForm from "../components/constant/stepData"; import dataForm from "../components/constant/stepData";
import constantList from "../components/constant/constantList"; import constantList from "../components/constant/constantList";
import NP from "number-precision"; import NP from "number-precision";
...@@ -500,10 +501,7 @@ Page({ ...@@ -500,10 +501,7 @@ Page({
confirmColor: "#347BFF", confirmColor: "#347BFF",
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
wx.$router.go("tabWorkOrder.staffDaily", { navigateToStaffDailyReport({ reportDate: formattedDate });
// reportDate: hasNeedReport.date
reportDate: formattedDate,
});
} }
}, },
complete: () => { complete: () => {
......
// packageEquity/pages/index/index.js — 权益首页 Component(菜单见 menu/,非菜单见 services/) // packageEquity/pages/index/index.js — 权益首页 Component(菜单见 menu/,非菜单见 services/)
import { checkDailyReport } from '~/store/ModalToQueueControl' import { checkDailyReport } from '~/store/ModalToQueueControl'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
import { import {
getReceptionRecordList, getReceptionRecordList,
getRecordDetailList, getRecordDetailList,
...@@ -436,6 +437,10 @@ Component({ ...@@ -436,6 +437,10 @@ Component({
merchantBrand: this.data.merchantBrand merchantBrand: this.data.merchantBrand
}) })
if (action.type === 'navigate') { if (action.type === 'navigate') {
if (Number(e.detail.id) === 1) {
navigateToStaffDailyReport({ reportDate: action.params?.reportDate })
return
}
wx.$router.go(action.route, action.params) wx.$router.go(action.route, action.params)
} else if (action.type === 'showPromptDialog') { } else if (action.type === 'showPromptDialog') {
this.setData({ showPromptDialog: true }) this.setData({ showPromptDialog: true })
......
let modalQueue = [] let modalQueue = []
import api from '~/api/api.js' import api from '~/api/api.js'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
// import { // import {
// checkUsedCarStaffIsNew, // checkUsedCarStaffIsNew,
// checkUsedCarStaffDailyReportValid // checkUsedCarStaffDailyReportValid
...@@ -94,7 +95,8 @@ const staffDailyReport = userInfo => { ...@@ -94,7 +95,8 @@ const staffDailyReport = userInfo => {
5, 5,
res => { res => {
if (res.confirm) { if (res.confirm) {
wx.$router.go('tabWorkOrder.upgradeStaffDaily', { navigateToStaffDailyReport({
userInfo,
reportDate: formattedDate reportDate: formattedDate
}) })
} }
...@@ -146,7 +148,8 @@ const equityStaffDailyReport = userInfo => { ...@@ -146,7 +148,8 @@ const equityStaffDailyReport = userInfo => {
4, 4,
res => { res => {
if (res.confirm) { if (res.confirm) {
wx.$router.go('tabWorkOrder.staffDaily', { navigateToStaffDailyReport({
userInfo,
reportDate: formattedDate reportDate: formattedDate
}) })
} }
......
...@@ -210,7 +210,7 @@ async function resolveDynamicForm(ctx) { ...@@ -210,7 +210,7 @@ async function resolveDynamicForm(ctx) {
} }
) )
}) })
return { dynamicForm: { visible: items.length > 0, items } } return { dynamicForm: { visible: items.length > 0, items, hideLegacyStaffDaily: items.some(i => i.id === 'staff_daily_report_new') } }
} }
/** /**
......
...@@ -114,7 +114,7 @@ export async function buildTabIndexMenusAsync(options = {}) { ...@@ -114,7 +114,7 @@ export async function buildTabIndexMenusAsync(options = {}) {
const dynamicItems = apiResults.dynamicForm?.items || [] const dynamicItems = apiResults.dynamicForm?.items || []
const allItems = sortBySortVal( let allItems = sortBySortVal(
dedupeById([ dedupeById([
...syncResult.menu.map(i => ({ ...i, section: MENU_SECTION.MAIN })), ...syncResult.menu.map(i => ({ ...i, section: MENU_SECTION.MAIN })),
...syncResult.newMenu.map(i => ({ ...i, section: MENU_SECTION.SECONDARY })), ...syncResult.newMenu.map(i => ({ ...i, section: MENU_SECTION.SECONDARY })),
...@@ -123,6 +123,10 @@ export async function buildTabIndexMenusAsync(options = {}) { ...@@ -123,6 +123,10 @@ export async function buildTabIndexMenusAsync(options = {}) {
]) ])
) )
if (apiResults.dynamicForm?.hideLegacyStaffDaily) {
allItems = allItems.filter(i => i.id !== 'staff_daily_report')
}
const { menu, newMenu } = splitBySection(allItems) const { menu, newMenu } = splitBySection(allItems)
const sideEffects = {} const sideEffects = {}
......
...@@ -98,7 +98,7 @@ export const MENU_REGISTRY = [ ...@@ -98,7 +98,7 @@ export const MENU_REGISTRY = [
label: '新建工单', label: '新建工单',
icon: 'create_newworkorder', icon: 'create_newworkorder',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 10, sortVal: 1,
hot: true, hot: true,
recordId: 6, recordId: 6,
beforeClick: 'inspectionOfProhibitionBill', beforeClick: 'inspectionOfProhibitionBill',
...@@ -113,7 +113,7 @@ export const MENU_REGISTRY = [ ...@@ -113,7 +113,7 @@ export const MENU_REGISTRY = [
label: '战败下单', label: '战败下单',
icon: 'defeat_order', icon: 'defeat_order',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 11, sortVal: 2,
hot: true, hot: true,
recordId: 8, recordId: 8,
action: { type: 'router', target: 'tabWorkOrder.defeatOrder' }, action: { type: 'router', target: 'tabWorkOrder.defeatOrder' },
...@@ -184,7 +184,7 @@ export const MENU_REGISTRY = [ ...@@ -184,7 +184,7 @@ export const MENU_REGISTRY = [
label: '工作日报', label: '工作日报',
icon: 'supervisorDailyNew', icon: 'supervisorDailyNew',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 20, sortVal: 8,
recordId: 15, recordId: 15,
noCheckdailyReport: true, noCheckdailyReport: true,
reportTypeAttr: 'daily', reportTypeAttr: 'daily',
...@@ -198,7 +198,7 @@ export const MENU_REGISTRY = [ ...@@ -198,7 +198,7 @@ export const MENU_REGISTRY = [
label: '工作周报', label: '工作周报',
icon: 'weeklyReport', icon: 'weeklyReport',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 21, sortVal: 9,
recordId: 18, recordId: 18,
noCheckdailyReport: true, noCheckdailyReport: true,
reportTypeAttr: 'weekly', reportTypeAttr: 'weekly',
...@@ -212,7 +212,7 @@ export const MENU_REGISTRY = [ ...@@ -212,7 +212,7 @@ export const MENU_REGISTRY = [
label: '工作月报', label: '工作月报',
icon: 'monthlyReport', icon: 'monthlyReport',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 22, sortVal: 10,
recordId: 19, recordId: 19,
noCheckdailyReport: true, noCheckdailyReport: true,
reportTypeAttr: 'monthly', reportTypeAttr: 'monthly',
...@@ -228,7 +228,7 @@ export const MENU_REGISTRY = [ ...@@ -228,7 +228,7 @@ export const MENU_REGISTRY = [
label: '预约管理', label: '预约管理',
icon: 'booking_management', icon: 'booking_management',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 5, sortVal: 11,
recordId: 8, recordId: 8,
action: { type: 'router', target: 'pages.tabDateIndex' }, action: { type: 'router', target: 'pages.tabDateIndex' },
visible: ({ policies }) => visible: ({ policies }) =>
...@@ -244,7 +244,7 @@ export const MENU_REGISTRY = [ ...@@ -244,7 +244,7 @@ export const MENU_REGISTRY = [
label: '驻店日报', label: '驻店日报',
icon: 'staffreport', icon: 'staffreport',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 30, sortVal: 16,
recordId: 13, recordId: 13,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { type: 'router', target: 'tabWorkOrder.upgradeStaffDaily' }, action: { type: 'router', target: 'tabWorkOrder.upgradeStaffDaily' },
...@@ -256,7 +256,7 @@ export const MENU_REGISTRY = [ ...@@ -256,7 +256,7 @@ export const MENU_REGISTRY = [
label: 'BI报表', label: 'BI报表',
icon: 'business_data', icon: 'business_data',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 40, sortVal: 17,
recordId: 11, recordId: 11,
action: { type: 'router', target: 'tabOperating.index' }, action: { type: 'router', target: 'tabOperating.index' },
visible: ({ policies }) => visible: ({ policies }) =>
...@@ -267,7 +267,7 @@ export const MENU_REGISTRY = [ ...@@ -267,7 +267,7 @@ export const MENU_REGISTRY = [
label: '生意助手', label: '生意助手',
icon: 'boutique-syzs', icon: 'boutique-syzs',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 41, sortVal: 18,
recordId: 12, recordId: 12,
action: { action: {
type: 'miniProgram', type: 'miniProgram',
...@@ -285,7 +285,7 @@ export const MENU_REGISTRY = [ ...@@ -285,7 +285,7 @@ export const MENU_REGISTRY = [
label: '培训资料', label: '培训资料',
icon: 'peixun_icon', icon: 'peixun_icon',
section: MENU_SECTION.SECONDARY, section: MENU_SECTION.SECONDARY,
sortVal: 50, sortVal: 100,
recordId: 14, recordId: 14,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { type: 'router', target: 'packageEquity.trainingMaterials' }, action: { type: 'router', target: 'packageEquity.trainingMaterials' },
...@@ -296,7 +296,7 @@ export const MENU_REGISTRY = [ ...@@ -296,7 +296,7 @@ export const MENU_REGISTRY = [
label: '工资绩效', label: '工资绩效',
icon: 'businessschoo', icon: 'businessschoo',
section: MENU_SECTION.SECONDARY, section: MENU_SECTION.SECONDARY,
sortVal: 51, sortVal: 101,
action: { type: 'salaryPerformance' }, action: { type: 'salaryPerformance' },
visible: ({ policies }) => visible: ({ policies }) =>
policies.notTechnician() && policies.isSuper() policies.notTechnician() && policies.isSuper()
...@@ -306,7 +306,7 @@ export const MENU_REGISTRY = [ ...@@ -306,7 +306,7 @@ export const MENU_REGISTRY = [
label: '带教管理', label: '带教管理',
icon: 'mentorship-manage', icon: 'mentorship-manage',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 52, sortVal: 19,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { type: 'router', target: 'tabWorkOrder.mentorshipManage' }, action: { type: 'router', target: 'tabWorkOrder.mentorshipManage' },
visible: ({ policies }) => visible: ({ policies }) =>
...@@ -317,7 +317,7 @@ export const MENU_REGISTRY = [ ...@@ -317,7 +317,7 @@ export const MENU_REGISTRY = [
label: '场景集市', label: '场景集市',
icon: 'sceneMarket', icon: 'sceneMarket',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 53, sortVal: 20,
action: { action: {
type: 'navigate', type: 'navigate',
target: '/packageEquity/pages/sceneMarket/index/index', target: '/packageEquity/pages/sceneMarket/index/index',
...@@ -332,7 +332,7 @@ export const MENU_REGISTRY = [ ...@@ -332,7 +332,7 @@ export const MENU_REGISTRY = [
label: '话术萃取', label: '话术萃取',
icon: 'extract_icon', icon: 'extract_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 54, sortVal: 21,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { action: {
type: 'router', type: 'router',
...@@ -347,7 +347,7 @@ export const MENU_REGISTRY = [ ...@@ -347,7 +347,7 @@ export const MENU_REGISTRY = [
label: '待审批', label: '待审批',
icon: 'refund_review_icon', icon: 'refund_review_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 60, sortVal: 26,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { action: {
type: 'router', type: 'router',
...@@ -363,7 +363,7 @@ export const MENU_REGISTRY = [ ...@@ -363,7 +363,7 @@ export const MENU_REGISTRY = [
icon: 'recruit-manage', icon: 'recruit-manage',
iconPrefix: 'crowdFunding', iconPrefix: 'crowdFunding',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 61, sortVal: 27,
recordId: 16, recordId: 16,
tipsNum: 0, tipsNum: 0,
action: { type: 'router', target: 'packageEquity.recruitManage' }, action: { type: 'router', target: 'packageEquity.recruitManage' },
...@@ -375,7 +375,7 @@ export const MENU_REGISTRY = [ ...@@ -375,7 +375,7 @@ export const MENU_REGISTRY = [
label: '施工单', label: '施工单',
icon: 'tabRepairOrder', icon: 'tabRepairOrder',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 70, sortVal: 29,
recordId: 20, recordId: 20,
noCheckdailyReport: true, noCheckdailyReport: true,
isRepairOrderTabFromMenu: true, isRepairOrderTabFromMenu: true,
...@@ -391,7 +391,7 @@ export const MENU_REGISTRY = [ ...@@ -391,7 +391,7 @@ export const MENU_REGISTRY = [
label: '学习中心', label: '学习中心',
icon: 'study-center', icon: 'study-center',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 71, sortVal: 30,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { type: 'router', target: 'packageStudyCenter.studyCenter' }, action: { type: 'router', target: 'packageStudyCenter.studyCenter' },
visible: ({ policies, isStaff }) => visible: ({ policies, isStaff }) =>
...@@ -420,7 +420,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -420,7 +420,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '话术核验', label: '话术核验',
icon: 'verification_icon', icon: 'verification_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 55, sortVal: 22,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { action: {
type: 'router', type: 'router',
...@@ -434,7 +434,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -434,7 +434,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '工资申诉', label: '工资申诉',
icon: 'salary_appeal_icon', icon: 'salary_appeal_icon',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 56, sortVal: 23,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { type: 'router', target: 'packageEquity.salaryAppeal' }, action: { type: 'router', target: 'packageEquity.salaryAppeal' },
provider: 'salaryAppeal' provider: 'salaryAppeal'
...@@ -444,7 +444,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -444,7 +444,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '接待缺失报备', label: '接待缺失报备',
icon: 'missing-reception', icon: 'missing-reception',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 57, sortVal: 24,
noCheckdailyReport: true, noCheckdailyReport: true,
action: { type: 'router', target: 'packageEquity.missingReception' }, action: { type: 'router', target: 'packageEquity.missingReception' },
provider: 'missingReception' provider: 'missingReception'
...@@ -454,7 +454,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -454,7 +454,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '客户线索', label: '客户线索',
icon: 'customer_clue', icon: 'customer_clue',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 58, sortVal: 4,
recordId: 11, recordId: 11,
tipsNum: 0, tipsNum: 0,
noCheckdailyReport: true, noCheckdailyReport: true,
...@@ -466,7 +466,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -466,7 +466,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '工资绩效', label: '工资绩效',
icon: 'businessschoo', icon: 'businessschoo',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 59, sortVal: 25,
action: { type: 'salaryPerformance' }, action: { type: 'salaryPerformance' },
provider: 'salaryPerformance' provider: 'salaryPerformance'
}, },
...@@ -475,7 +475,7 @@ export const ASYNC_MENU_REGISTRY = [ ...@@ -475,7 +475,7 @@ export const ASYNC_MENU_REGISTRY = [
label: '驻店目标', label: '驻店目标',
icon: 'resident_target', icon: 'resident_target',
section: MENU_SECTION.MAIN, section: MENU_SECTION.MAIN,
sortVal: 62, sortVal: 28,
action: { type: 'residentTarget', target: 'packageEquity.residentTarget' }, action: { type: 'residentTarget', target: 'packageEquity.residentTarget' },
provider: 'residentTarget' provider: 'residentTarget'
} }
......
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
checkStudyTask, checkStudyTask,
checkAbnormalOrder checkAbnormalOrder
} from '~/store/ModalToQueueControl' } from '~/store/ModalToQueueControl'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
import { import {
buildTabIndexMenusAsync, buildTabIndexMenusAsync,
...@@ -144,10 +145,7 @@ Page({ ...@@ -144,10 +145,7 @@ Page({
previousDate.setHours(hour) previousDate.setHours(hour)
// 格式化日期为"yyyy-mm-dd" // 格式化日期为"yyyy-mm-dd"
let formattedDate = previousDate.toISOString().split('T')[0] let formattedDate = previousDate.toISOString().split('T')[0]
wx.$router.go('tabWorkOrder.upgradeStaffDaily', { navigateToStaffDailyReport({ reportDate: formattedDate })
// reportDate: hasNeedReport.date
reportDate: formattedDate
})
break break
case 2: case 2:
// 校验是否填写昨日日报 // 校验是否填写昨日日报
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import api from '../../api' import api from '../../api'
import { getYQorderInfo, getPositionList, setConfigInfo } from '~/store/index' import { getYQorderInfo, getPositionList, setConfigInfo } from '~/store/index'
import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl' import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
import NP from 'number-precision' import NP from 'number-precision'
const app = getApp() const app = getApp()
let toastList = { let toastList = {
...@@ -462,10 +463,7 @@ Page({ ...@@ -462,10 +463,7 @@ Page({
confirmColor: '#347BFF', confirmColor: '#347BFF',
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
wx.$router.go('tabWorkOrder.upgradeStaffDaily', { navigateToStaffDailyReport({ reportDate: formattedDate })
// reportDate: hasNeedReport.date
reportDate: formattedDate
})
} }
}, },
complete: () => { complete: () => {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import api from '../../api' import api from '../../api'
import { getYQorderInfo } from '~/store/index' import { getYQorderInfo } from '~/store/index'
import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl' import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
const app = getApp() const app = getApp()
let toastList = { let toastList = {
employeeName: '销售顾问不能为空', employeeName: '销售顾问不能为空',
...@@ -526,10 +527,7 @@ Page({ ...@@ -526,10 +527,7 @@ Page({
confirmColor: '#347BFF', confirmColor: '#347BFF',
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
wx.$router.go('tabWorkOrder.upgradeStaffDaily', { navigateToStaffDailyReport({ reportDate: formattedDate })
// reportDate: hasNeedReport.date
reportDate: formattedDate
})
} }
}, },
complete: () => { complete: () => {
......
...@@ -4,6 +4,7 @@ import api2 from '~/api/api.js' ...@@ -4,6 +4,7 @@ import api2 from '~/api/api.js'
import { getYQorderInfo, getPositionList, setConfigInfo } from '~/store/index' import { getYQorderInfo, getPositionList, setConfigInfo } from '~/store/index'
import { validateVin, formatVinInput } from '~/utils/vinVaildate' import { validateVin, formatVinInput } from '~/utils/vinVaildate'
import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl' import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
const phoneRex = /^[1]([3-9])[0-9]{9}$/ const phoneRex = /^[1]([3-9])[0-9]{9}$/
const app = getApp() const app = getApp()
let toastList = { let toastList = {
...@@ -904,10 +905,7 @@ Page({ ...@@ -904,10 +905,7 @@ Page({
confirmColor: '#347BFF', confirmColor: '#347BFF',
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
wx.$router.go('tabWorkOrder.upgradeStaffDaily', { navigateToStaffDailyReport({ reportDate: formattedDate })
// reportDate: hasNeedReport.date
reportDate: formattedDate
})
} }
}, },
complete: () => { complete: () => {
......
// tabWorkOrder/pages/carFilmUpgrade/carFilmUpgrade.js // tabWorkOrder/pages/carFilmUpgrade/carFilmUpgrade.js
import api from "../../api"; import api from "../../api";
import { getYQorderInfo, setConfigInfo } from "~/store/index"; import { getYQorderInfo, setConfigInfo } from "~/store/index";
import { navigateToStaffDailyReport } from "~/utils/staffDailyReportNavigation.js";
const app = getApp(); const app = getApp();
let toastList = { let toastList = {
userId: "销售顾问不能为空", userId: "销售顾问不能为空",
...@@ -322,10 +323,7 @@ Page({ ...@@ -322,10 +323,7 @@ Page({
confirmColor: "#347BFF", confirmColor: "#347BFF",
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
wx.$router.go("tabWorkOrder.upgradeStaffDaily", { navigateToStaffDailyReport({ reportDate: formattedDate });
// reportDate: hasNeedReport.date
reportDate: formattedDate,
});
} }
}, },
complete: () => { complete: () => {
......
...@@ -4,10 +4,10 @@ import { ...@@ -4,10 +4,10 @@ import {
} from './dailyReportNewVersionGate.js' } from './dailyReportNewVersionGate.js'
/** 精品首页三入口 name(用于 strip / 接口显隐) */ /** 精品首页三入口 name(用于 strip / 接口显隐) */
export const DYNAMIC_FORM_TAB_INDEX_MENU_NAMES = ['洽谈明细', '门店日报', '驻店日报-新'] export const DYNAMIC_FORM_TAB_INDEX_MENU_NAMES = ['洽谈明细', '门店日报', '驻店日报']
/** 权益首页三入口 menuText */ /** 权益首页三入口 menuText */
export const DYNAMIC_FORM_EQUITY_MENU_TEXTS = ['洽谈明细', '门店日报', '驻店日报-新'] export const DYNAMIC_FORM_EQUITY_MENU_TEXTS = ['洽谈明细', '门店日报', '驻店日报']
/** 动态表单分包页面路径(与 app.json subpackage 一致,使用 navigateToUrl 跳转) */ /** 动态表单分包页面路径(与 app.json subpackage 一致,使用 navigateToUrl 跳转) */
export const DYNAMIC_FORM_NAVIGATE_URLS = { export const DYNAMIC_FORM_NAVIGATE_URLS = {
...@@ -70,7 +70,7 @@ export function canShowStaffDailyNew(userInfo = {}) { ...@@ -70,7 +70,7 @@ export function canShowStaffDailyNew(userInfo = {}) {
} }
function withDynamicFormSceneUrl(item) { function withDynamicFormSceneUrl(item) {
if (item.name === '驻店日报-新' || item.menuText === '驻店日报-新') { if (item.name === '驻店日报' || item.menuText === '驻店日报') {
return { return {
...item, ...item,
navigateToUrl: buildStaffDailyReportNavigateUrl() navigateToUrl: buildStaffDailyReportNavigateUrl()
...@@ -102,7 +102,7 @@ export const DYNAMIC_FORM_TAB_INDEX_MENUS = [ ...@@ -102,7 +102,7 @@ export const DYNAMIC_FORM_TAB_INDEX_MENUS = [
trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.negotiationDetail], trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.negotiationDetail],
recordId: 0, recordId: 0,
noCheckdailyReport: true, noCheckdailyReport: true,
sortVal: 91 sortVal: 7
}, },
{ {
name: '门店日报', name: '门店日报',
...@@ -111,16 +111,16 @@ export const DYNAMIC_FORM_TAB_INDEX_MENUS = [ ...@@ -111,16 +111,16 @@ export const DYNAMIC_FORM_TAB_INDEX_MENUS = [
trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.storeDailyReport], trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.storeDailyReport],
recordId: 0, recordId: 0,
noCheckdailyReport: true, noCheckdailyReport: true,
sortVal: 92 sortVal: 6
}, },
{ {
name: '驻店日报-新', name: '驻店日报',
// TEST-ID: IT-ROUTE-002 与旧 tabWorkOrder 驻店日报并存 // TEST-ID: IT-ROUTE-002 动态驻店日报(与旧 tabWorkOrder 入口互斥)
navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport, navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport,
trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport], trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport],
recordId: 0, recordId: 0,
noCheckdailyReport: true, noCheckdailyReport: true,
sortVal: 93 sortVal: 5
} }
] ]
...@@ -129,21 +129,21 @@ export const DYNAMIC_FORM_EQUITY_MENUS = [ ...@@ -129,21 +129,21 @@ export const DYNAMIC_FORM_EQUITY_MENUS = [
menuText: '洽谈明细', menuText: '洽谈明细',
navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.negotiationDetail, navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.negotiationDetail,
trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.negotiationDetail], trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.negotiationDetail],
sortVal: 2, sortVal: 7,
noCheckdailyReport: true noCheckdailyReport: true
}, },
{ {
menuText: '门店日报', menuText: '门店日报',
navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.storeDailyReport, navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.storeDailyReport,
trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.storeDailyReport], trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.storeDailyReport],
sortVal: 3, sortVal: 6,
noCheckdailyReport: true noCheckdailyReport: true
}, },
{ {
menuText: '驻店日报-新', menuText: '驻店日报',
navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport, navigateToUrl: DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport,
trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport], trackEventCode: DYNAMIC_FORM_TRACK_EVENT_BY_URL[DYNAMIC_FORM_NAVIGATE_URLS.staffDailyReport],
sortVal: 1, sortVal: 5,
noCheckdailyReport: true noCheckdailyReport: true
} }
] ]
......
import {
fetchDailyReportNewVersionMenuVisible,
resolveShopMerchantId
} from './dailyReportNewVersionGate.js'
import {
buildStaffDailyReportNavigateUrl,
canShowStaffDailyNew
} from './dynamicFormMenus.js'
export function resolveLegacyStaffDailyRoute(userInfo = {}) {
if (userInfo.sceneType === 0) {
return {
type: 'router',
route: 'tabWorkOrder.staffDaily',
params: { scene: 0 }
}
}
return {
type: 'router',
route: 'tabWorkOrder.upgradeStaffDaily',
params: {}
}
}
export function buildStaffDailyReportUrlWithDate(reportDate) {
const base = buildStaffDailyReportNavigateUrl()
if (!reportDate) {
return base
}
const sep = base.includes('?') ? '&' : '?'
return `${base}${sep}reportDate=${encodeURIComponent(reportDate)}`
}
/**
* 是否跳转新版驻店日报(白名单 + 角色门禁)
* @param {Object} [userInfo]
* @returns {Promise<boolean>}
*/
export async function shouldUseNewStaffDailyReport(userInfo = {}) {
if (!canShowStaffDailyNew(userInfo)) {
return false
}
if (wx?.$hasPermission?.canSelectMultiStore?.(userInfo)) {
return false
}
const merchantId = resolveShopMerchantId(userInfo)
if (!merchantId) {
return false
}
return fetchDailyReportNewVersionMenuVisible(merchantId)
}
/**
* 按白名单跳转新/老驻店日报
* @param {Object} [options]
* @param {Object} [options.userInfo]
* @param {string} [options.reportDate] yyyy-MM-dd
*/
export async function navigateToStaffDailyReport({ userInfo, reportDate } = {}) {
const info = userInfo || wx.$util?.getUserInfo?.() || {}
const useNew = await shouldUseNewStaffDailyReport(info)
if (useNew) {
const url = buildStaffDailyReportUrlWithDate(reportDate)
wx.navigateTo({ url })
return { type: 'navigate', url }
}
const legacy = resolveLegacyStaffDailyRoute(info)
const params = { ...(legacy.params || {}) }
if (reportDate) {
params.reportDate = reportDate
}
wx.$router.go(legacy.route, params)
return { type: 'router', route: legacy.route, params }
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!