Commit 9bd5f920 by 张立顺

fix bug

1 parent 099eebaf
......@@ -32,6 +32,12 @@ export {
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
*/
......@@ -73,7 +79,7 @@ export function waitInputOrderUnionCount(data = {}) {
* @returns {Promise<RopResponse>}
*/
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 api.post(
......
......@@ -4,7 +4,7 @@
*/
/** 改为 true 可 Mock 锁单拦截(测新建工单) */
export const MOCK_SHOP_LOCK = false
export const MOCK_SHOP_LOCK = true
const SEED_PENDING = [
{
......@@ -160,11 +160,11 @@ export function getMockCount() {
}
/**
* Mock:checkShopLock(默认 false 不锁单)
* Mock:checkShopLock(true = 锁单生效)
* @returns {boolean}
*/
export function getMockShopLock() {
return MOCK_SHOP_LOCK
return true
}
/**
......@@ -323,7 +323,7 @@ function buildApprovalLogs(approvalStatus, reportTime) {
}
if (status === 3) {
logs.push({
approvalStatus: 5,
approvalStatus: 3,
operatorName: '何穗',
createdDate: reportTime,
remark: '客户情况属实,建议尽快处理',
......@@ -340,7 +340,7 @@ function buildApprovalLogs(approvalStatus, reportTime) {
}
if (status === 4) {
logs.push({
approvalStatus: 5,
approvalStatus: 3,
operatorName: '何穗',
createdDate: reportTime,
remark: '同意',
......@@ -357,7 +357,7 @@ function buildApprovalLogs(approvalStatus, reportTime) {
}
// 5 通过
logs.push({
approvalStatus: 5,
approvalStatus: 3,
operatorName: '何穗',
createdDate: reportTime,
remark: '同意',
......
......@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false
* 4预发布
* 5cdptest
*/
let index = 1;
let index = 2;
const accountInfo = wx.getAccountInfoSync();
const systemInfo = getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion;
......
......@@ -13,7 +13,7 @@ import commonApi from '../../api/api.js'
import {
checkDailyReport,
checkStudyTask,
checkOrderLockGate
checkAbnormalOrder
} from '../../store/ModalToQueueControl.js'
import { trackDynamicFormMenuEntry } from '../../utils/dynamicFormMenus.js'
import { SCENE_TYPE } from './constants.js'
......@@ -32,8 +32,8 @@ async function runStaffOrderChecks() {
if (staffCheck) return true
let staffStudyTask = await checkStudyTask()
if (staffStudyTask) return true
let lockCheck = await checkOrderLockGate()
if (lockCheck) return true
let abnormalOrderCheck = await checkAbnormalOrder('pages.index')
if (abnormalOrderCheck) return true
return false
}
......
......@@ -482,35 +482,35 @@ Page({
let dayBoolean = abnormalOrderPop?.date && nowDate == abnormalOrderPop?.date
let flag = abnormalOrderPop?.[sceneType]?.[merchantId]
if (dayBoolean && flag) {
resolve(false)
return
}
api
.abnormalOrderLock()
.then(res => {
if (res.data.abnormalOrderNum) {
this.addModalToQueue(
'异常订单提醒',
`存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`,
'确认',
false,
0,
() => {
this.showNextModal()
}
)
wx.$storage.set('abnormalOrderPop', {
date: nowDate,
[sceneType]: {
...(abnormalOrderPop?.[sceneType] || {}),
[merchantId]: true
}
})
resolve(true)
} else {
if (!res.data?.abnormalOrderNum) {
resolve(false)
return
}
if (dayBoolean && flag) {
resolve(true)
return
}
this.addModalToQueue(
'异常订单提醒',
`存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`,
'确认',
false,
0,
() => {
this.showNextModal()
}
)
wx.$storage.set('abnormalOrderPop', {
date: nowDate,
[sceneType]: {
...(abnormalOrderPop?.[sceneType] || {}),
[merchantId]: true
}
})
resolve(true)
})
.catch(() => {
resolve(false)
......@@ -607,6 +607,7 @@ Page({
const tab = this.selectComponent(`#page-${tabIndex}`)
tab?.refreshOnShow?.()
}
loadAbnormalFlowTipState(this)
},
back() {
if (this.data.staffUuid) {
......
......@@ -13,7 +13,7 @@ import {
getMoreBtnAPI,
checkOrderCalimStatus,
} from "../../../api";
import { checkDailyReport, checkStudyTask, checkOrderLockGate } from "~/store/ModalToQueueControl";
import { checkDailyReport, checkStudyTask, checkAbnormalOrder, checkOrderLockGate } from "~/store/ModalToQueueControl";
import data from "../constant/data";
import constantData from "../constant/data";
import api from "~/api/api";
......@@ -331,8 +331,8 @@ Component({
// 校验学习中心开单限制
let staffStudyTask = await checkStudyTask();
if (staffStudyTask) return false;
let lockCheck = await checkOrderLockGate();
if (lockCheck) return false;
let abnormalOrderCheck = await checkAbnormalOrder('pages.index');
if (abnormalOrderCheck) return false;
/**禁止提单 */
if (await wx.$globalDataFunction.inspectionOfProhibitionBill()) return;
// console.log(e)
......
......@@ -3,8 +3,7 @@ import api from '~/api/api.js'
import { navigateToStaffDailyReport } from '~/utils/staffDailyReportNavigation.js'
import {
isAbnormalFlowLockActive,
shouldBypassAbnormalFlowLock,
shouldCallAbnormalFlowShopLockApi
shouldBypassAbnormalFlowLock
} from '~/utils/abnormalFlowLock.helpers.js'
// import {
// checkUsedCarStaffIsNew,
......@@ -295,10 +294,6 @@ const checkAbnormalFlowLock = (context = {}, priority = 3) => {
resolve(false)
return
}
if (!shouldCallAbnormalFlowShopLockApi()) {
resolve(false)
return
}
api
.checkAbnormalFlowShopLock({ merchantId })
.then(res => {
......
......@@ -870,6 +870,11 @@ Page({
async initData(userInfo, options = {}) {
const { storeSwitched = false } = options
userInfo = userInfo ? userInfo : wx.$util.getUserInfo()
const merchantId =
userInfo?.shopMerchantId ||
userInfo?.default4SStoreInfo?.merchantId ||
''
const prevMerchantId = this._abnormalFlowTipMerchantId
if (storeSwitched) {
this.invalidateMenuCache()
}
......@@ -904,6 +909,17 @@ Page({
// 产品需求:强制填写(04-17版本)
this.checkDailyRecport()
if (
merchantId &&
prevMerchantId !== undefined &&
String(merchantId) !== String(prevMerchantId)
) {
loadAbnormalFlowTipState(this)
}
if (merchantId) {
this._abnormalFlowTipMerchantId = merchantId
}
},
async checkDailyRecport() {
return runDailyChecks(this, { isStaff: app.globalData.isStaff })
......
......@@ -68,41 +68,41 @@ export function checkStaffOrderStatus(page) {
})
}
/** 异常订单锁单提醒 */
/** 异常订单锁单提醒(始终请求 lock.select;弹窗仍按当日去重) */
export function checkAbnormalOrderLocal(page) {
return new Promise(resolve => {
const abnormalOrderPop = wx.$storage.get('abnormalOrderPop') || {}
const userInfo = wx.$util.getUserInfo()
if (shouldSkipAbnormalOrderPop(abnormalOrderPop, userInfo)) {
resolve(false)
return
}
const nowDate = todayDateString()
const { sceneType, shopMerchantId: merchantId } = userInfo
commonApi
.abnormalOrderLock()
.then(res => {
if (res.data?.abnormalOrderNum) {
page.addModalToQueue(
'异常订单提醒',
`存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`,
'确认',
false,
0,
() => page.showNextModal()
)
wx.$storage.set('abnormalOrderPop', {
date: nowDate,
[sceneType]: {
...(abnormalOrderPop?.[sceneType] || {}),
[merchantId]: true
}
})
resolve(true)
} else {
if (!res.data?.abnormalOrderNum) {
resolve(false)
return
}
if (shouldSkipAbnormalOrderPop(abnormalOrderPop, userInfo)) {
resolve(true)
return
}
page.addModalToQueue(
'异常订单提醒',
`存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`,
'确认',
false,
0,
() => page.showNextModal()
)
wx.$storage.set('abnormalOrderPop', {
date: nowDate,
[sceneType]: {
...(abnormalOrderPop?.[sceneType] || {}),
[merchantId]: true
}
})
resolve(true)
})
.catch(() => resolve(false))
})
......
/**
* @file 新建工单异常流水限制态拉取(调 API,不调 setData)
*/
import {
checkAbnormalFlowShopLock,
waitInputOrderUnionCount
} from '~/api/abnormalFlowDeclaration.js'
import {
shouldCallAbnormalFlowShopLockApi,
shouldRestrictNewOrderToDjQrOnly
} from '~/utils/abnormalFlowLock.helpers.js'
import { checkAbnormalFlowShopLock } from '~/api/abnormalFlowDeclaration.js'
import { shouldRestrictNewOrderToDjQrOnly } from '~/utils/abnormalFlowLock.helpers.js'
/**
* 解析门店 id(精品 / 权益字段略有差异)
......@@ -24,7 +18,7 @@ function resolveMerchantId(userInfo = {}) {
}
/**
* 拉取新建工单是否仅允许嘀加二维码收款
* 拉取新建工单是否仅允许嘀加二维码收款(仅 checkShopLock)
* @returns {Promise<{ djQrOnlyMode: boolean }>}
*/
export async function loadNewOrderRestrictState() {
......@@ -34,26 +28,11 @@ export async function loadNewOrderRestrictState() {
return { djQrOnlyMode: false }
}
const now = new Date()
const needShopLockApi = shouldCallAbnormalFlowShopLockApi(now)
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
)
return { djQrOnlyMode }
} catch {
return { djQrOnlyMode: false }
}
const lockRes = await checkAbnormalFlowShopLock({ merchantId }).catch(
() => ({ data: null })
)
const djQrOnlyMode = shouldRestrictNewOrderToDjQrOnly(lockRes?.data)
return { djQrOnlyMode }
}
/**
......@@ -64,10 +43,13 @@ export async function loadNewOrderRestrictState() {
*/
export async function openOrderPromptWithRestrictState(page, patch = {}) {
const { djQrOnlyMode } = await loadNewOrderRestrictState()
// 先写入限制态,再 show,避免 wx:if 重建组件时 djQrOnlyMode 未就绪
page.setData({
showPromptDialog: true,
orderPromptDjQrOnlyMode: djQrOnlyMode,
...patch
})
page.setData({
showPromptDialog: true
})
return { djQrOnlyMode }
}
......@@ -54,7 +54,7 @@ export function shouldSkipOrderStaffPop(storage = {}, userInfo = {}) {
}
/**
* 是否应跳过异常订单弹窗(当日已弹过)
* 是否应跳过异常订单弹窗展示(当日已弹过;不跳过 lock.select 请求)
*/
export function shouldSkipAbnormalOrderPop(storage = {}, userInfo = {}) {
const nowDate = todayDateString()
......
......@@ -72,12 +72,6 @@ page {
}
.voucher-cell {
flex-direction: column;
.label {
margin-bottom: var(--fontSize16);
}
.voucher-list {
display: flex;
flex-wrap: wrap;
......
......@@ -28,18 +28,21 @@
<view class="label">报备时间</view>
<view class="value">{{ detail.reportTime }}</view>
</view>
<view class="cell voucher-cell" wx:if="{{ detail.vouchers.length }}">
<view class="cell voucher-cell">
<view class="label">上传凭证</view>
<view class="voucher-list">
<image
class="voucher-thumb"
wx:for="{{ detail.vouchers }}"
wx:key="index"
src="{{ item }}"
mode="aspectFill"
bindtap="previewVoucher"
data-index="{{ index }}"
/>
<view class="value">
<view class="voucher-list" wx:if="{{ detail.vouchers.length }}">
<image
class="voucher-thumb"
wx:for="{{ detail.vouchers }}"
wx:key="index"
src="{{ item }}"
mode="aspectFill"
bindtap="previewVoucher"
data-index="{{ index }}"
/>
</view>
<text wx:else>-</text>
</view>
</view>
</view>
......@@ -53,7 +56,7 @@
<view class="label">审批状态</view>
<view
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 }}
</view>
......@@ -73,9 +76,9 @@
<view class="label">审批状态</view>
<view
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 class="cell" wx:for="{{ bgFields }}" wx:key="key">
......
......@@ -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 }}
*/
export function getApprovalStatusStyle(approvalStatus) {
......@@ -101,19 +133,61 @@ export function getReportStatusStyle(status) {
}
/**
* @param {number|string} [approvalStatus]
* @returns {string}
* 详情页-区域经理审批状态(读 approvalLogs RM 轮:3=通过)
* @param {number|string} [rmStatus]
* @param {number|string} [bgStatus] 预留扩展
* @returns {{ text: string, color: string, background: string }}
*/
export function getBgApprovalStatusText(approvalStatus) {
if (
approvalStatus === undefined ||
approvalStatus === null ||
approvalStatus === '' ||
Number(approvalStatus) === ABNORMAL_FLOW_APPROVAL_STATUS.BG_PENDING
) {
return '待后台审批'
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)
}
return getApprovalStatusStyle(approvalStatus).text
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 getBgApprovalStatusStyle(rmStatus, bgStatus) {
if (!isRmLogApproved(rmStatus)) {
return EMPTY_STATUS_STYLE
}
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) {
}
/**
* 从对象项中取凭证 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
* @param {Object} data
* @returns {Object}
......@@ -273,22 +389,23 @@ export function mapDetailFromApi(data = {}) {
abnormalTypeText: getAbnormalTypeLabel(decl.abnormalType),
remark: decl.remark || '',
reporterName: decl.createdBy || '',
reportTime: decl.createdDate || '',
vouchers: Array.isArray(decl.voucherImageUrls)
? decl.voucherImageUrls
: [],
reportTime: formatTradeTime(decl.createdDate),
vouchers: normalizeVoucherUrls(decl.voucherImageUrls),
rmStatus,
rmStatusStyle: getApprovalStatusStyle(rmStatus),
rmStatusStyle: getRmApprovalStatusStyle(rmStatus, bgStatus),
rmApprover: rmLog?.operatorName || '',
rmApproveTime: rmLog?.createdDate || '',
rmApproveTime: formatTradeTime(rmLog?.createdDate),
rmOpinion: rmLog?.remark || '',
bgStatus,
bgStatusStyle: getApprovalStatusStyle(bgStatus),
bgStatusText: getBgApprovalStatusText(bgStatus),
bgStatusStyle: getBgApprovalStatusStyle(rmStatus, bgStatus),
bgApprover: bgLog?.operatorName || '',
bgApproveTime: bgLog?.createdDate || '',
bgApproveTime: formatTradeTime(bgLog?.createdDate),
bgOpinion: bgLog?.remark || '',
estimatedDeadline: ''
estimatedDeadline: formatTradeTime(
bgLog?.estimatedDeadline ||
decl?.estimatedDeadline ||
data.estimatedDeadline
)
}
}
......
......@@ -4,8 +4,6 @@ import assert from 'node:assert/strict'
describe('abnormalFlowLock.helpers', async () => {
const {
ABNORMAL_FLOW_LOCK_BYPASS,
isAbnormalFlowReminderDay,
shouldCallAbnormalFlowShopLockApi,
shouldRestrictNewOrderToDjQrOnly,
shouldShowAbnormalFlowTip,
markAbnormalFlowTipDismissed,
......@@ -17,18 +15,6 @@ describe('abnormalFlowLock.helpers', async () => {
buildAbnormalFlowTipText
} = 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', () => {
assert.equal(shouldShowAbnormalFlowTip(null, 's1'), true)
const storage = markAbnormalFlowTipDismissed(null, 's1')
......@@ -93,40 +79,18 @@ describe('abnormalFlowLock.helpers', async () => {
assert.match(buildAbnormalFlowTipText(3), /3笔异常流水/)
})
it('shouldRestrictNewOrderToDjQrOnly by weekday', () => {
it('shouldRestrictNewOrderToDjQrOnly uses checkShopLock only', () => {
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(
shouldRestrictNewOrderToDjQrOnly(null, countPending, mon),
true
)
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
),
shouldRestrictNewOrderToDjQrOnly({
lockControlEnabled: 'N',
lockFlowFlag: 'Y'
}),
false
)
})
......
......@@ -6,9 +6,12 @@ describe('abnormalFlowReport.helpers', async () => {
ABNORMAL_TYPE_OPTIONS,
SUCCESS_MODAL,
getApprovalStatusStyle,
getRmApprovalStatusStyle,
getBgApprovalStatusStyle,
getBgApprovalStatusText,
getAbnormalTypeLabel,
formatTradeTime,
normalizeVoucherUrls,
validateReportForm,
fenToYuan,
mapUnionCount,
......@@ -36,9 +39,41 @@ describe('abnormalFlowReport.helpers', async () => {
assert.equal(getApprovalStatusStyle(5).text, '审批通过')
})
it('bg pending text for status 3 or empty', () => {
assert.equal(getBgApprovalStatusText(3), '待后台审批')
assert.equal(getBgApprovalStatusText(''), '待后台审批')
it('bg approval status links with rm round', () => {
assert.equal(getBgApprovalStatusText(3, 3), '待后台审批')
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', () => {
......@@ -65,6 +100,27 @@ describe('abnormalFlowReport.helpers', async () => {
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', () => {
assert.deepEqual(
mapUnionCount({
......@@ -147,8 +203,53 @@ describe('abnormalFlowReport.helpers', async () => {
})
assert.equal(detail.tradeRefNo, 'TN3')
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.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)
})
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) {
}
/**
* 是否处于提醒周期(周一~周三,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 {string} [sessionId] - 当前登录会话标识
......@@ -159,20 +140,11 @@ export function shouldBypassAbnormalFlowLock(context = {}) {
}
/**
* 新建工单收款弹窗是否仅允许嘀加二维码
* 周一~周三:仅 union.count 有待报备即限制;周四~周日:需 checkShopLock 确认 + 有待报备
* 新建工单收款弹窗是否仅允许嘀加二维码(仅 checkShopLock 返回值)
* @param {boolean|Object|null|undefined} shopLockData - checkShopLock 返回值
* @param {Object} [countData] - union.count 返回值
* @param {Date} [date]
* @returns {boolean}
*/
export function shouldRestrictNewOrderToDjQrOnly(
shopLockData,
countData,
date = new Date()
) {
if (!hasUnprocessedAbnormalFlow(countData)) return false
if (isAbnormalFlowReminderDay(date)) return true
export function shouldRestrictNewOrderToDjQrOnly(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!