Commit 9bd5f920 by 张立顺

fix bug

1 parent 099eebaf
...@@ -32,6 +32,12 @@ export { ...@@ -32,6 +32,12 @@ export {
export const ABNORMAL_FLOW_API_USE_MOCK = false export const ABNORMAL_FLOW_API_USE_MOCK = false
/** /**
* 仅 checkShopLock 走 Mock(其它接口仍按 ABNORMAL_FLOW_API_USE_MOCK)
* @type {boolean}
*/
export const ABNORMAL_FLOW_CHECK_SHOP_LOCK_USE_MOCK = false
/**
* @typedef {1|2|3|4|5|6|7} AbnormalFlowTypeValue * @typedef {1|2|3|4|5|6|7} AbnormalFlowTypeValue
*/ */
...@@ -73,7 +79,7 @@ export function waitInputOrderUnionCount(data = {}) { ...@@ -73,7 +79,7 @@ export function waitInputOrderUnionCount(data = {}) {
* @returns {Promise<RopResponse>} * @returns {Promise<RopResponse>}
*/ */
export function checkAbnormalFlowShopLock(data) { export function checkAbnormalFlowShopLock(data) {
if (ABNORMAL_FLOW_API_USE_MOCK) { if (ABNORMAL_FLOW_API_USE_MOCK || ABNORMAL_FLOW_CHECK_SHOP_LOCK_USE_MOCK) {
return mockOk(getMockShopLock()) return mockOk(getMockShopLock())
} }
return api.post( return api.post(
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/** 改为 true 可 Mock 锁单拦截(测新建工单) */ /** 改为 true 可 Mock 锁单拦截(测新建工单) */
export const MOCK_SHOP_LOCK = false export const MOCK_SHOP_LOCK = true
const SEED_PENDING = [ const SEED_PENDING = [
{ {
...@@ -160,11 +160,11 @@ export function getMockCount() { ...@@ -160,11 +160,11 @@ export function getMockCount() {
} }
/** /**
* Mock:checkShopLock(默认 false 不锁单) * Mock:checkShopLock(true = 锁单生效)
* @returns {boolean} * @returns {boolean}
*/ */
export function getMockShopLock() { export function getMockShopLock() {
return MOCK_SHOP_LOCK return true
} }
/** /**
...@@ -323,7 +323,7 @@ function buildApprovalLogs(approvalStatus, reportTime) { ...@@ -323,7 +323,7 @@ function buildApprovalLogs(approvalStatus, reportTime) {
} }
if (status === 3) { if (status === 3) {
logs.push({ logs.push({
approvalStatus: 5, approvalStatus: 3,
operatorName: '何穗', operatorName: '何穗',
createdDate: reportTime, createdDate: reportTime,
remark: '客户情况属实,建议尽快处理', remark: '客户情况属实,建议尽快处理',
...@@ -340,7 +340,7 @@ function buildApprovalLogs(approvalStatus, reportTime) { ...@@ -340,7 +340,7 @@ function buildApprovalLogs(approvalStatus, reportTime) {
} }
if (status === 4) { if (status === 4) {
logs.push({ logs.push({
approvalStatus: 5, approvalStatus: 3,
operatorName: '何穗', operatorName: '何穗',
createdDate: reportTime, createdDate: reportTime,
remark: '同意', remark: '同意',
...@@ -357,7 +357,7 @@ function buildApprovalLogs(approvalStatus, reportTime) { ...@@ -357,7 +357,7 @@ function buildApprovalLogs(approvalStatus, reportTime) {
} }
// 5 通过 // 5 通过
logs.push({ logs.push({
approvalStatus: 5, approvalStatus: 3,
operatorName: '何穗', operatorName: '何穗',
createdDate: reportTime, createdDate: reportTime,
remark: '同意', remark: '同意',
......
...@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false ...@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 1; let index = 2;
const accountInfo = wx.getAccountInfoSync(); const accountInfo = wx.getAccountInfoSync();
const systemInfo = getSystemInfoSync(); const systemInfo = getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion; const envName = accountInfo.miniProgram.envVersion;
......
...@@ -13,7 +13,7 @@ import commonApi from '../../api/api.js' ...@@ -13,7 +13,7 @@ import commonApi from '../../api/api.js'
import { import {
checkDailyReport, checkDailyReport,
checkStudyTask, checkStudyTask,
checkOrderLockGate checkAbnormalOrder
} from '../../store/ModalToQueueControl.js' } from '../../store/ModalToQueueControl.js'
import { trackDynamicFormMenuEntry } from '../../utils/dynamicFormMenus.js' import { trackDynamicFormMenuEntry } from '../../utils/dynamicFormMenus.js'
import { SCENE_TYPE } from './constants.js' import { SCENE_TYPE } from './constants.js'
...@@ -32,8 +32,8 @@ async function runStaffOrderChecks() { ...@@ -32,8 +32,8 @@ async function runStaffOrderChecks() {
if (staffCheck) return true if (staffCheck) return true
let staffStudyTask = await checkStudyTask() let staffStudyTask = await checkStudyTask()
if (staffStudyTask) return true if (staffStudyTask) return true
let lockCheck = await checkOrderLockGate() let abnormalOrderCheck = await checkAbnormalOrder('pages.index')
if (lockCheck) return true if (abnormalOrderCheck) return true
return false return false
} }
......
...@@ -482,14 +482,17 @@ Page({ ...@@ -482,14 +482,17 @@ Page({
let dayBoolean = abnormalOrderPop?.date && nowDate == abnormalOrderPop?.date let dayBoolean = abnormalOrderPop?.date && nowDate == abnormalOrderPop?.date
let flag = abnormalOrderPop?.[sceneType]?.[merchantId] let flag = abnormalOrderPop?.[sceneType]?.[merchantId]
if (dayBoolean && flag) {
resolve(false)
return
}
api api
.abnormalOrderLock() .abnormalOrderLock()
.then(res => { .then(res => {
if (res.data.abnormalOrderNum) { if (!res.data?.abnormalOrderNum) {
resolve(false)
return
}
if (dayBoolean && flag) {
resolve(true)
return
}
this.addModalToQueue( this.addModalToQueue(
'异常订单提醒', '异常订单提醒',
`存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`, `存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`,
...@@ -508,9 +511,6 @@ Page({ ...@@ -508,9 +511,6 @@ Page({
} }
}) })
resolve(true) resolve(true)
} else {
resolve(false)
}
}) })
.catch(() => { .catch(() => {
resolve(false) resolve(false)
...@@ -607,6 +607,7 @@ Page({ ...@@ -607,6 +607,7 @@ Page({
const tab = this.selectComponent(`#page-${tabIndex}`) const tab = this.selectComponent(`#page-${tabIndex}`)
tab?.refreshOnShow?.() tab?.refreshOnShow?.()
} }
loadAbnormalFlowTipState(this)
}, },
back() { back() {
if (this.data.staffUuid) { if (this.data.staffUuid) {
......
...@@ -13,7 +13,7 @@ import { ...@@ -13,7 +13,7 @@ import {
getMoreBtnAPI, getMoreBtnAPI,
checkOrderCalimStatus, checkOrderCalimStatus,
} from "../../../api"; } from "../../../api";
import { checkDailyReport, checkStudyTask, checkOrderLockGate } from "~/store/ModalToQueueControl"; import { checkDailyReport, checkStudyTask, checkAbnormalOrder, checkOrderLockGate } from "~/store/ModalToQueueControl";
import data from "../constant/data"; import data from "../constant/data";
import constantData from "../constant/data"; import constantData from "../constant/data";
import api from "~/api/api"; import api from "~/api/api";
...@@ -331,8 +331,8 @@ Component({ ...@@ -331,8 +331,8 @@ Component({
// 校验学习中心开单限制 // 校验学习中心开单限制
let staffStudyTask = await checkStudyTask(); let staffStudyTask = await checkStudyTask();
if (staffStudyTask) return false; if (staffStudyTask) return false;
let lockCheck = await checkOrderLockGate(); let abnormalOrderCheck = await checkAbnormalOrder('pages.index');
if (lockCheck) return false; if (abnormalOrderCheck) return false;
/**禁止提单 */ /**禁止提单 */
if (await wx.$globalDataFunction.inspectionOfProhibitionBill()) return; if (await wx.$globalDataFunction.inspectionOfProhibitionBill()) return;
// console.log(e) // console.log(e)
......
...@@ -3,8 +3,7 @@ import api from '~/api/api.js' ...@@ -3,8 +3,7 @@ import api from '~/api/api.js'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js' import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
import { import {
isAbnormalFlowLockActive, isAbnormalFlowLockActive,
shouldBypassAbnormalFlowLock, shouldBypassAbnormalFlowLock
shouldCallAbnormalFlowShopLockApi
} from '~/utils/abnormalFlowLock.helpers.js' } from '~/utils/abnormalFlowLock.helpers.js'
// import { // import {
// checkUsedCarStaffIsNew, // checkUsedCarStaffIsNew,
...@@ -295,10 +294,6 @@ const checkAbnormalFlowLock = (context = {}, priority = 3) => { ...@@ -295,10 +294,6 @@ const checkAbnormalFlowLock = (context = {}, priority = 3) => {
resolve(false) resolve(false)
return return
} }
if (!shouldCallAbnormalFlowShopLockApi()) {
resolve(false)
return
}
api api
.checkAbnormalFlowShopLock({ merchantId }) .checkAbnormalFlowShopLock({ merchantId })
.then(res => { .then(res => {
......
...@@ -870,6 +870,11 @@ Page({ ...@@ -870,6 +870,11 @@ Page({
async initData(userInfo, options = {}) { async initData(userInfo, options = {}) {
const { storeSwitched = false } = options const { storeSwitched = false } = options
userInfo = userInfo ? userInfo : wx.$util.getUserInfo() userInfo = userInfo ? userInfo : wx.$util.getUserInfo()
const merchantId =
userInfo?.shopMerchantId ||
userInfo?.default4SStoreInfo?.merchantId ||
''
const prevMerchantId = this._abnormalFlowTipMerchantId
if (storeSwitched) { if (storeSwitched) {
this.invalidateMenuCache() this.invalidateMenuCache()
} }
...@@ -904,6 +909,17 @@ Page({ ...@@ -904,6 +909,17 @@ Page({
// 产品需求:强制填写(04-17版本) // 产品需求:强制填写(04-17版本)
this.checkDailyRecport() this.checkDailyRecport()
if (
merchantId &&
prevMerchantId !== undefined &&
String(merchantId) !== String(prevMerchantId)
) {
loadAbnormalFlowTipState(this)
}
if (merchantId) {
this._abnormalFlowTipMerchantId = merchantId
}
}, },
async checkDailyRecport() { async checkDailyRecport() {
return runDailyChecks(this, { isStaff: app.globalData.isStaff }) return runDailyChecks(this, { isStaff: app.globalData.isStaff })
......
...@@ -68,22 +68,25 @@ export function checkStaffOrderStatus(page) { ...@@ -68,22 +68,25 @@ export function checkStaffOrderStatus(page) {
}) })
} }
/** 异常订单锁单提醒 */ /** 异常订单锁单提醒(始终请求 lock.select;弹窗仍按当日去重) */
export function checkAbnormalOrderLocal(page) { export function checkAbnormalOrderLocal(page) {
return new Promise(resolve => { return new Promise(resolve => {
const abnormalOrderPop = wx.$storage.get('abnormalOrderPop') || {} const abnormalOrderPop = wx.$storage.get('abnormalOrderPop') || {}
const userInfo = wx.$util.getUserInfo() const userInfo = wx.$util.getUserInfo()
if (shouldSkipAbnormalOrderPop(abnormalOrderPop, userInfo)) {
resolve(false)
return
}
const nowDate = todayDateString() const nowDate = todayDateString()
const { sceneType, shopMerchantId: merchantId } = userInfo const { sceneType, shopMerchantId: merchantId } = userInfo
commonApi commonApi
.abnormalOrderLock() .abnormalOrderLock()
.then(res => { .then(res => {
if (res.data?.abnormalOrderNum) { if (!res.data?.abnormalOrderNum) {
resolve(false)
return
}
if (shouldSkipAbnormalOrderPop(abnormalOrderPop, userInfo)) {
resolve(true)
return
}
page.addModalToQueue( page.addModalToQueue(
'异常订单提醒', '异常订单提醒',
`存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`, `存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`,
...@@ -100,9 +103,6 @@ export function checkAbnormalOrderLocal(page) { ...@@ -100,9 +103,6 @@ export function checkAbnormalOrderLocal(page) {
} }
}) })
resolve(true) resolve(true)
} else {
resolve(false)
}
}) })
.catch(() => resolve(false)) .catch(() => resolve(false))
}) })
......
/** /**
* @file 新建工单异常流水限制态拉取(调 API,不调 setData) * @file 新建工单异常流水限制态拉取(调 API,不调 setData)
*/ */
import { import { checkAbnormalFlowShopLock } from '~/api/abnormalFlowDeclaration.js'
checkAbnormalFlowShopLock, import { shouldRestrictNewOrderToDjQrOnly } from '~/utils/abnormalFlowLock.helpers.js'
waitInputOrderUnionCount
} from '~/api/abnormalFlowDeclaration.js'
import {
shouldCallAbnormalFlowShopLockApi,
shouldRestrictNewOrderToDjQrOnly
} from '~/utils/abnormalFlowLock.helpers.js'
/** /**
* 解析门店 id(精品 / 权益字段略有差异) * 解析门店 id(精品 / 权益字段略有差异)
...@@ -24,7 +18,7 @@ function resolveMerchantId(userInfo = {}) { ...@@ -24,7 +18,7 @@ function resolveMerchantId(userInfo = {}) {
} }
/** /**
* 拉取新建工单是否仅允许嘀加二维码收款 * 拉取新建工单是否仅允许嘀加二维码收款(仅 checkShopLock)
* @returns {Promise<{ djQrOnlyMode: boolean }>} * @returns {Promise<{ djQrOnlyMode: boolean }>}
*/ */
export async function loadNewOrderRestrictState() { export async function loadNewOrderRestrictState() {
...@@ -34,26 +28,11 @@ export async function loadNewOrderRestrictState() { ...@@ -34,26 +28,11 @@ export async function loadNewOrderRestrictState() {
return { djQrOnlyMode: false } return { djQrOnlyMode: false }
} }
const now = new Date() const lockRes = await checkAbnormalFlowShopLock({ merchantId }).catch(
const needShopLockApi = shouldCallAbnormalFlowShopLockApi(now) () => ({ data: null })
try {
const countRes = await waitInputOrderUnionCount()
const countData = countRes?.data
let shopLockData = null
if (needShopLockApi) {
const lockRes = await checkAbnormalFlowShopLock({ merchantId })
shopLockData = lockRes?.data
}
const djQrOnlyMode = shouldRestrictNewOrderToDjQrOnly(
shopLockData,
countData,
now
) )
const djQrOnlyMode = shouldRestrictNewOrderToDjQrOnly(lockRes?.data)
return { djQrOnlyMode } return { djQrOnlyMode }
} catch {
return { djQrOnlyMode: false }
}
} }
/** /**
...@@ -64,10 +43,13 @@ export async function loadNewOrderRestrictState() { ...@@ -64,10 +43,13 @@ export async function loadNewOrderRestrictState() {
*/ */
export async function openOrderPromptWithRestrictState(page, patch = {}) { export async function openOrderPromptWithRestrictState(page, patch = {}) {
const { djQrOnlyMode } = await loadNewOrderRestrictState() const { djQrOnlyMode } = await loadNewOrderRestrictState()
// 先写入限制态,再 show,避免 wx:if 重建组件时 djQrOnlyMode 未就绪
page.setData({ page.setData({
showPromptDialog: true,
orderPromptDjQrOnlyMode: djQrOnlyMode, orderPromptDjQrOnlyMode: djQrOnlyMode,
...patch ...patch
}) })
page.setData({
showPromptDialog: true
})
return { djQrOnlyMode } return { djQrOnlyMode }
} }
...@@ -54,7 +54,7 @@ export function shouldSkipOrderStaffPop(storage = {}, userInfo = {}) { ...@@ -54,7 +54,7 @@ export function shouldSkipOrderStaffPop(storage = {}, userInfo = {}) {
} }
/** /**
* 是否应跳过异常订单弹窗(当日已弹过) * 是否应跳过异常订单弹窗展示(当日已弹过;不跳过 lock.select 请求)
*/ */
export function shouldSkipAbnormalOrderPop(storage = {}, userInfo = {}) { export function shouldSkipAbnormalOrderPop(storage = {}, userInfo = {}) {
const nowDate = todayDateString() const nowDate = todayDateString()
......
...@@ -72,12 +72,6 @@ page { ...@@ -72,12 +72,6 @@ page {
} }
.voucher-cell { .voucher-cell {
flex-direction: column;
.label {
margin-bottom: var(--fontSize16);
}
.voucher-list { .voucher-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
......
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
<view class="label">报备时间</view> <view class="label">报备时间</view>
<view class="value">{{ detail.reportTime }}</view> <view class="value">{{ detail.reportTime }}</view>
</view> </view>
<view class="cell voucher-cell" wx:if="{{ detail.vouchers.length }}"> <view class="cell voucher-cell">
<view class="label">上传凭证</view> <view class="label">上传凭证</view>
<view class="voucher-list"> <view class="value">
<view class="voucher-list" wx:if="{{ detail.vouchers.length }}">
<image <image
class="voucher-thumb" class="voucher-thumb"
wx:for="{{ detail.vouchers }}" wx:for="{{ detail.vouchers }}"
...@@ -41,6 +42,8 @@ ...@@ -41,6 +42,8 @@
data-index="{{ index }}" data-index="{{ index }}"
/> />
</view> </view>
<text wx:else>-</text>
</view>
</view> </view>
</view> </view>
...@@ -53,7 +56,7 @@ ...@@ -53,7 +56,7 @@
<view class="label">审批状态</view> <view class="label">审批状态</view>
<view <view
class="status-tag" class="status-tag"
style="color:{{ detail.rmStatusStyle.color }};background:{{ detail.rmStatusStyle.background }};" style="color:{{ detail.rmStatusStyle.color }};background-color:{{ detail.rmStatusStyle.background }};"
> >
{{ detail.rmStatusStyle.text }} {{ detail.rmStatusStyle.text }}
</view> </view>
...@@ -73,9 +76,9 @@ ...@@ -73,9 +76,9 @@
<view class="label">审批状态</view> <view class="label">审批状态</view>
<view <view
class="status-tag" class="status-tag"
style="color:{{ detail.bgStatusStyle.color }};background:{{ detail.bgStatusStyle.background }};" style="color:{{ detail.bgStatusStyle.color }};background-color:{{ detail.bgStatusStyle.background }};"
> >
{{ detail.bgStatusText }} {{ detail.bgStatusStyle.text }}
</view> </view>
</view> </view>
<view class="cell" wx:for="{{ bgFields }}" wx:key="key"> <view class="cell" wx:for="{{ bgFields }}" wx:key="key">
......
...@@ -65,9 +65,41 @@ const APPROVAL_STATUS_STYLE_MAP = { ...@@ -65,9 +65,41 @@ const APPROVAL_STATUS_STYLE_MAP = {
} }
} }
/** 详情页空状态 / 未开始 */
const EMPTY_STATUS_STYLE = {
text: '-',
color: '#292D33',
background: '#F4F5F7'
}
/** 区域经理已通过(与列表绿色一致,区别于终审「审批通过」) */
const RM_APPROVED_STYLE = {
text: '区域经理已通过',
color: '#35C376',
background: '#EAF9F1'
}
/**
* approvalLogs 中区域经理轮(approvalSource=0)状态:1 待审 / 2 驳回 / 3 通过
* 与 declarationInfo.approvalStatus(整体流转 1–5)语义不同,勿混用。
*/
export const RM_LOG_APPROVAL_STATUS = {
PENDING: 1,
REJECTED: 2,
APPROVED: 3
}
/**
* @param {number|string} [rmStatus] approvalLogs RM 轮 approvalStatus
* @returns {boolean}
*/
export function isRmLogApproved(rmStatus) {
return Number(rmStatus) === RM_LOG_APPROVAL_STATUS.APPROVED
}
/** /**
* 审批状态码取标签样式 * 审批状态码取标签样式
* @param {number|string} approvalStatus - 1–5 * @param {number|string} approvalStatus - declaration 整体流转 1–5
* @returns {{ text: string, color: string, background: string }} * @returns {{ text: string, color: string, background: string }}
*/ */
export function getApprovalStatusStyle(approvalStatus) { export function getApprovalStatusStyle(approvalStatus) {
...@@ -101,19 +133,61 @@ export function getReportStatusStyle(status) { ...@@ -101,19 +133,61 @@ export function getReportStatusStyle(status) {
} }
/** /**
* @param {number|string} [approvalStatus] * 详情页-区域经理审批状态(读 approvalLogs RM 轮:3=通过)
* @returns {string} * @param {number|string} [rmStatus]
* @param {number|string} [bgStatus] 预留扩展
* @returns {{ text: string, color: string, background: string }}
*/
export function getRmApprovalStatusStyle(rmStatus, bgStatus) {
if (rmStatus === undefined || rmStatus === null || rmStatus === '') {
return EMPTY_STATUS_STYLE
}
const rm = Number(rmStatus)
if (rm === RM_LOG_APPROVAL_STATUS.PENDING) {
return getApprovalStatusStyle(ABNORMAL_FLOW_APPROVAL_STATUS.RM_PENDING)
}
if (rm === RM_LOG_APPROVAL_STATUS.REJECTED) {
return getApprovalStatusStyle(ABNORMAL_FLOW_APPROVAL_STATUS.RM_REJECTED)
}
if (rm === RM_LOG_APPROVAL_STATUS.APPROVED) {
return RM_APPROVED_STYLE
}
return EMPTY_STATUS_STYLE
}
/**
* 详情页-后台审批状态(RM log 通过后才展示;BG log 3/4/5 对齐 declaration 待审/驳回/通过)
* @param {number|string} [rmStatus]
* @param {number|string} [bgStatus]
* @returns {{ text: string, color: string, background: string }}
*/ */
export function getBgApprovalStatusText(approvalStatus) { export function getBgApprovalStatusStyle(rmStatus, bgStatus) {
if ( if (!isRmLogApproved(rmStatus)) {
approvalStatus === undefined || return EMPTY_STATUS_STYLE
approvalStatus === null ||
approvalStatus === '' ||
Number(approvalStatus) === ABNORMAL_FLOW_APPROVAL_STATUS.BG_PENDING
) {
return '待后台审批'
} }
return getApprovalStatusStyle(approvalStatus).text if (bgStatus === undefined || bgStatus === null || bgStatus === '') {
return getApprovalStatusStyle(ABNORMAL_FLOW_APPROVAL_STATUS.BG_PENDING)
}
const bg = Number(bgStatus)
if (bg === ABNORMAL_FLOW_APPROVAL_STATUS.BG_PENDING) {
return getApprovalStatusStyle(ABNORMAL_FLOW_APPROVAL_STATUS.BG_PENDING)
}
if (bg === ABNORMAL_FLOW_APPROVAL_STATUS.BG_REJECTED) {
return getApprovalStatusStyle(ABNORMAL_FLOW_APPROVAL_STATUS.BG_REJECTED)
}
if (bg === ABNORMAL_FLOW_APPROVAL_STATUS.APPROVED) {
return getApprovalStatusStyle(ABNORMAL_FLOW_APPROVAL_STATUS.APPROVED)
}
return EMPTY_STATUS_STYLE
}
/**
* @param {number|string} [rmStatus]
* @param {number|string} [bgStatus]
* @returns {string}
*/
export function getBgApprovalStatusText(rmStatus, bgStatus) {
return getBgApprovalStatusStyle(rmStatus, bgStatus).text
} }
/** /**
...@@ -247,6 +321,48 @@ function findApprovalLogBySource(logs, source) { ...@@ -247,6 +321,48 @@ function findApprovalLogBySource(logs, source) {
} }
/** /**
* 从对象项中取凭证 URL(兼容常见字段名)
* @param {Object} item
* @returns {string}
*/
function pickVoucherUrlFromObject(item) {
if (!item || typeof item !== 'object') return ''
return (
item.url ||
item.imageUrl ||
item.voucherImageUrl ||
item.voucherUrl ||
''
)
}
/**
* 归一化凭证 URL 列表(兼容字符串数组、对象数组、逗号分隔字符串)
* @param {string|string[]|Object[]|*} raw
* @returns {string[]}
*/
export function normalizeVoucherUrls(raw) {
if (raw === undefined || raw === null || raw === '') return []
if (typeof raw === 'string') {
return raw
.split(',')
.map(s => s.trim())
.filter(Boolean)
}
if (!Array.isArray(raw)) {
const single =
typeof raw === 'object' ? pickVoucherUrlFromObject(raw) : String(raw)
return single ? [single] : []
}
return raw
.map(item => {
if (typeof item === 'string') return item.trim()
return pickVoucherUrlFromObject(item)
})
.filter(Boolean)
}
/**
* 映射 declaration.detail → 详情页 VM * 映射 declaration.detail → 详情页 VM
* @param {Object} data * @param {Object} data
* @returns {Object} * @returns {Object}
...@@ -273,22 +389,23 @@ export function mapDetailFromApi(data = {}) { ...@@ -273,22 +389,23 @@ export function mapDetailFromApi(data = {}) {
abnormalTypeText: getAbnormalTypeLabel(decl.abnormalType), abnormalTypeText: getAbnormalTypeLabel(decl.abnormalType),
remark: decl.remark || '', remark: decl.remark || '',
reporterName: decl.createdBy || '', reporterName: decl.createdBy || '',
reportTime: decl.createdDate || '', reportTime: formatTradeTime(decl.createdDate),
vouchers: Array.isArray(decl.voucherImageUrls) vouchers: normalizeVoucherUrls(decl.voucherImageUrls),
? decl.voucherImageUrls
: [],
rmStatus, rmStatus,
rmStatusStyle: getApprovalStatusStyle(rmStatus), rmStatusStyle: getRmApprovalStatusStyle(rmStatus, bgStatus),
rmApprover: rmLog?.operatorName || '', rmApprover: rmLog?.operatorName || '',
rmApproveTime: rmLog?.createdDate || '', rmApproveTime: formatTradeTime(rmLog?.createdDate),
rmOpinion: rmLog?.remark || '', rmOpinion: rmLog?.remark || '',
bgStatus, bgStatus,
bgStatusStyle: getApprovalStatusStyle(bgStatus), bgStatusStyle: getBgApprovalStatusStyle(rmStatus, bgStatus),
bgStatusText: getBgApprovalStatusText(bgStatus),
bgApprover: bgLog?.operatorName || '', bgApprover: bgLog?.operatorName || '',
bgApproveTime: bgLog?.createdDate || '', bgApproveTime: formatTradeTime(bgLog?.createdDate),
bgOpinion: bgLog?.remark || '', bgOpinion: bgLog?.remark || '',
estimatedDeadline: '' estimatedDeadline: formatTradeTime(
bgLog?.estimatedDeadline ||
decl?.estimatedDeadline ||
data.estimatedDeadline
)
} }
} }
......
...@@ -4,8 +4,6 @@ import assert from 'node:assert/strict' ...@@ -4,8 +4,6 @@ import assert from 'node:assert/strict'
describe('abnormalFlowLock.helpers', async () => { describe('abnormalFlowLock.helpers', async () => {
const { const {
ABNORMAL_FLOW_LOCK_BYPASS, ABNORMAL_FLOW_LOCK_BYPASS,
isAbnormalFlowReminderDay,
shouldCallAbnormalFlowShopLockApi,
shouldRestrictNewOrderToDjQrOnly, shouldRestrictNewOrderToDjQrOnly,
shouldShowAbnormalFlowTip, shouldShowAbnormalFlowTip,
markAbnormalFlowTipDismissed, markAbnormalFlowTipDismissed,
...@@ -17,18 +15,6 @@ describe('abnormalFlowLock.helpers', async () => { ...@@ -17,18 +15,6 @@ describe('abnormalFlowLock.helpers', async () => {
buildAbnormalFlowTipText buildAbnormalFlowTipText
} = await import('../utils/abnormalFlowLock.helpers.js') } = await import('../utils/abnormalFlowLock.helpers.js')
it('reminder day Mon-Wed only', () => {
assert.equal(isAbnormalFlowReminderDay(new Date('2026-07-06')), true)
assert.equal(isAbnormalFlowReminderDay(new Date('2026-07-09')), false)
assert.equal(isAbnormalFlowReminderDay(new Date('2026-07-05')), false)
})
it('shouldCallAbnormalFlowShopLockApi Thu-Sun only', () => {
assert.equal(shouldCallAbnormalFlowShopLockApi(new Date('2026-07-06')), false)
assert.equal(shouldCallAbnormalFlowShopLockApi(new Date('2026-07-09')), true)
assert.equal(shouldCallAbnormalFlowShopLockApi(new Date('2026-07-05')), true)
})
it('tip dismiss for entire login session', () => { it('tip dismiss for entire login session', () => {
assert.equal(shouldShowAbnormalFlowTip(null, 's1'), true) assert.equal(shouldShowAbnormalFlowTip(null, 's1'), true)
const storage = markAbnormalFlowTipDismissed(null, 's1') const storage = markAbnormalFlowTipDismissed(null, 's1')
...@@ -93,40 +79,18 @@ describe('abnormalFlowLock.helpers', async () => { ...@@ -93,40 +79,18 @@ describe('abnormalFlowLock.helpers', async () => {
assert.match(buildAbnormalFlowTipText(3), /3笔异常流水/) assert.match(buildAbnormalFlowTipText(3), /3笔异常流水/)
}) })
it('shouldRestrictNewOrderToDjQrOnly by weekday', () => { it('shouldRestrictNewOrderToDjQrOnly uses checkShopLock only', () => {
const lockOn = { lockControlEnabled: 'Y', lockFlowFlag: 'Y' } const lockOn = { lockControlEnabled: 'Y', lockFlowFlag: 'Y' }
const countPending = { totalCount: 2 }
const countEmpty = { totalCount: 0 }
const mon = new Date('2026-07-06')
assert.equal(shouldRestrictNewOrderToDjQrOnly(true), true)
assert.equal(shouldRestrictNewOrderToDjQrOnly(lockOn), true)
assert.equal(shouldRestrictNewOrderToDjQrOnly(false), false)
assert.equal(shouldRestrictNewOrderToDjQrOnly(null), false)
assert.equal( assert.equal(
shouldRestrictNewOrderToDjQrOnly(null, countPending, mon), shouldRestrictNewOrderToDjQrOnly({
true lockControlEnabled: 'N',
) lockFlowFlag: 'Y'
assert.equal( }),
shouldRestrictNewOrderToDjQrOnly(lockOn, countPending, mon),
true
)
assert.equal(
shouldRestrictNewOrderToDjQrOnly(lockOn, countEmpty, mon),
false
)
const thu = new Date('2026-07-09')
assert.equal(
shouldRestrictNewOrderToDjQrOnly(null, countPending, thu),
false
)
assert.equal(
shouldRestrictNewOrderToDjQrOnly(lockOn, countPending, thu),
true
)
assert.equal(
shouldRestrictNewOrderToDjQrOnly(
{ lockControlEnabled: 'N', lockFlowFlag: 'Y' },
countPending,
thu
),
false false
) )
}) })
......
...@@ -6,9 +6,12 @@ describe('abnormalFlowReport.helpers', async () => { ...@@ -6,9 +6,12 @@ describe('abnormalFlowReport.helpers', async () => {
ABNORMAL_TYPE_OPTIONS, ABNORMAL_TYPE_OPTIONS,
SUCCESS_MODAL, SUCCESS_MODAL,
getApprovalStatusStyle, getApprovalStatusStyle,
getRmApprovalStatusStyle,
getBgApprovalStatusStyle,
getBgApprovalStatusText, getBgApprovalStatusText,
getAbnormalTypeLabel, getAbnormalTypeLabel,
formatTradeTime, formatTradeTime,
normalizeVoucherUrls,
validateReportForm, validateReportForm,
fenToYuan, fenToYuan,
mapUnionCount, mapUnionCount,
...@@ -36,9 +39,41 @@ describe('abnormalFlowReport.helpers', async () => { ...@@ -36,9 +39,41 @@ describe('abnormalFlowReport.helpers', async () => {
assert.equal(getApprovalStatusStyle(5).text, '审批通过') assert.equal(getApprovalStatusStyle(5).text, '审批通过')
}) })
it('bg pending text for status 3 or empty', () => { it('bg approval status links with rm round', () => {
assert.equal(getBgApprovalStatusText(3), '待后台审批') assert.equal(getBgApprovalStatusText(3, 3), '待后台审批')
assert.equal(getBgApprovalStatusText(''), '待后台审批') assert.equal(getBgApprovalStatusText(3, ''), '待后台审批')
assert.equal(getBgApprovalStatusText(1, 3), '-')
assert.equal(getBgApprovalStatusText(2, 3), '-')
})
it('rm log status 3 means approved; bg log status 5 means approved', () => {
const rmPending = getRmApprovalStatusStyle(1, 3)
const bgWhileRmPending = getBgApprovalStatusStyle(1, 3)
assert.equal(rmPending.text, '待区域经理审批')
assert.equal(rmPending.color, '#F7A431')
assert.equal(bgWhileRmPending.text, '-')
assert.equal(bgWhileRmPending.background, '#F4F5F7')
const rmApproved = getRmApprovalStatusStyle(3, 3)
const bgPending = getBgApprovalStatusStyle(3, 3)
assert.equal(rmApproved.text, '区域经理已通过')
assert.equal(rmApproved.color, '#35C376')
assert.equal(bgPending.text, '待后台审批')
assert.equal(bgPending.color, '#F7A431')
const bgApproved = getBgApprovalStatusStyle(3, 5)
assert.equal(bgApproved.text, '审批通过')
assert.equal(bgApproved.color, '#35C376')
const rmRejected = getRmApprovalStatusStyle(2, 3)
const bgWhileRmRejected = getBgApprovalStatusStyle(2, 3)
assert.equal(rmRejected.text, '区域经理审批驳回')
assert.equal(rmRejected.color, '#F24724')
assert.equal(bgWhileRmRejected.text, '-')
const bgRejected = getBgApprovalStatusStyle(3, 4)
assert.equal(bgRejected.text, '后台审批驳回')
assert.equal(bgRejected.color, '#F24724')
}) })
it('validateReportForm requires type and remark', () => { it('validateReportForm requires type and remark', () => {
...@@ -65,6 +100,27 @@ describe('abnormalFlowReport.helpers', async () => { ...@@ -65,6 +100,27 @@ describe('abnormalFlowReport.helpers', async () => {
assert.equal(formatTradeTime(null), '') assert.equal(formatTradeTime(null), '')
}) })
it('normalizeVoucherUrls handles array object and comma string', () => {
assert.deepEqual(normalizeVoucherUrls(null), [])
assert.deepEqual(normalizeVoucherUrls(''), [])
assert.deepEqual(normalizeVoucherUrls(['https://a.png', '', 'https://b.png']), [
'https://a.png',
'https://b.png'
])
assert.deepEqual(
normalizeVoucherUrls([
{ url: 'https://c.png' },
{ imageUrl: 'https://d.png' },
{ voucherImageUrl: 'https://e.png' }
]),
['https://c.png', 'https://d.png', 'https://e.png']
)
assert.deepEqual(
normalizeVoucherUrls('https://f.png, https://g.png'),
['https://f.png', 'https://g.png']
)
})
it('mapUnionCount reads tab totals', () => { it('mapUnionCount reads tab totals', () => {
assert.deepEqual( assert.deepEqual(
mapUnionCount({ mapUnionCount({
...@@ -147,8 +203,53 @@ describe('abnormalFlowReport.helpers', async () => { ...@@ -147,8 +203,53 @@ describe('abnormalFlowReport.helpers', async () => {
}) })
assert.equal(detail.tradeRefNo, 'TN3') assert.equal(detail.tradeRefNo, 'TN3')
assert.equal(detail.abnormalTypeText, '已付款未录单') assert.equal(detail.abnormalTypeText, '已付款未录单')
assert.equal(detail.tradeTime, '2020-02-02 08:00:00')
assert.equal(detail.reportTime, '2020-02-03 08:00:00')
assert.equal(detail.rmApprover, '经理') assert.equal(detail.rmApprover, '经理')
assert.equal(detail.bgStatusText, '待后台审批') assert.equal(detail.rmApproveTime, '2020-02-04 08:00:00')
assert.equal(detail.rmStatusStyle.text, '待区域经理审批')
assert.equal(detail.bgApproveTime, '')
assert.equal(detail.bgStatusStyle.text, '-')
assert.equal(detail.vouchers.length, 1) assert.equal(detail.vouchers.length, 1)
}) })
it('mapDetailFromApi maps voucherImageUrls and empty list', () => {
const withUrls = mapDetailFromApi({
declarationInfo: {
abnormalType: 1,
remark: '备注',
voucherImageUrls: [{ url: 'https://a.png' }, 'https://b.png']
}
})
assert.deepEqual(withUrls.vouchers, ['https://a.png', 'https://b.png'])
const empty = mapDetailFromApi({
declarationInfo: { abnormalType: 1, remark: '无凭证' }
})
assert.deepEqual(empty.vouchers, [])
})
it('mapDetailFromApi treats rm log status 3 as rm approved', () => {
const detail = mapDetailFromApi({
declarationInfo: { abnormalType: 1, remark: 'x', approvalStatus: 5 },
approvalLogs: [
{
approvalSource: 0,
approvalStatus: 3,
operatorName: '何穗',
createdDate: '2020-02-04',
remark: '同意'
},
{
approvalSource: 1,
approvalStatus: 5,
operatorName: '总部',
createdDate: '2020-02-05',
remark: '通过'
}
]
})
assert.equal(detail.rmStatusStyle.text, '区域经理已通过')
assert.equal(detail.bgStatusStyle.text, '审批通过')
})
}) })
...@@ -32,25 +32,6 @@ export function isAbnormalFlowWhitelistRoute(routeName) { ...@@ -32,25 +32,6 @@ export function isAbnormalFlowWhitelistRoute(routeName) {
} }
/** /**
* 是否处于提醒周期(周一~周三,PRD 4.3.3)
* @param {Date} [date]
* @returns {boolean}
*/
export function isAbnormalFlowReminderDay(date = new Date()) {
const day = date.getDay()
return day >= 1 && day <= 3
}
/**
* 是否应调用 checkShopLock 接口(周四~周日确认锁单;周一~周三不调)
* @param {Date} [date]
* @returns {boolean}
*/
export function shouldCallAbnormalFlowShopLockApi(date = new Date()) {
return !isAbnormalFlowReminderDay(date)
}
/**
* 登录周期内是否应展示吸底提醒(未手动关闭) * 登录周期内是否应展示吸底提醒(未手动关闭)
* @param {Object|null} storage - abnormalFlowPop * @param {Object|null} storage - abnormalFlowPop
* @param {string} [sessionId] - 当前登录会话标识 * @param {string} [sessionId] - 当前登录会话标识
...@@ -159,20 +140,11 @@ export function shouldBypassAbnormalFlowLock(context = {}) { ...@@ -159,20 +140,11 @@ export function shouldBypassAbnormalFlowLock(context = {}) {
} }
/** /**
* 新建工单收款弹窗是否仅允许嘀加二维码 * 新建工单收款弹窗是否仅允许嘀加二维码(仅 checkShopLock 返回值)
* 周一~周三:仅 union.count 有待报备即限制;周四~周日:需 checkShopLock 确认 + 有待报备
* @param {boolean|Object|null|undefined} shopLockData - checkShopLock 返回值 * @param {boolean|Object|null|undefined} shopLockData - checkShopLock 返回值
* @param {Object} [countData] - union.count 返回值
* @param {Date} [date]
* @returns {boolean} * @returns {boolean}
*/ */
export function shouldRestrictNewOrderToDjQrOnly( export function shouldRestrictNewOrderToDjQrOnly(shopLockData) {
shopLockData,
countData,
date = new Date()
) {
if (!hasUnprocessedAbnormalFlow(countData)) return false
if (isAbnormalFlowReminderDay(date)) return true
return isAbnormalFlowLockActive(shopLockData) return isAbnormalFlowLockActive(shopLockData)
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!