feat(mobile-oa-h5): add market status-tag registry mirror
Mirror Web status-tag-registry for market modules with resolveStatusTag and parity tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a7a5a914f1
commit
87f1e9a4eb
2 files changed
+183
No files matched your search
@@ -0,0 +1,122 @@
|
||||
// Mirror of web-admin/src/utils/status-tag-registry.ts (market scope). Keep in sync manually.
|
||||
|
||||
function createRegistry(entries) {
|
||||
return Object.freeze(
|
||||
Object.fromEntries(
|
||||
Object.entries(entries).map(([code, item]) => [code, Object.freeze({ ...item })])
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, { label: string, tagType: string }>} registry
|
||||
* @param {string | null | undefined} code
|
||||
* @param {Record<string, string>} [aliases]
|
||||
* @returns {{ label: string, tagType: string }}
|
||||
*/
|
||||
export function resolveStatusTag(registry, code, aliases = {}) {
|
||||
const raw = String(code ?? '').trim()
|
||||
if (!raw) return { label: '—', tagType: 'info' }
|
||||
const mapped = aliases[raw] || raw
|
||||
const hit = registry[mapped]
|
||||
if (hit) return { label: hit.label, tagType: hit.tagType }
|
||||
if (/[\u4e00-\u9fff]/.test(raw)) return { label: raw, tagType: 'info' }
|
||||
return { label: '未知', tagType: 'info' }
|
||||
}
|
||||
|
||||
/** 样本缴费进度(勿与转账笔 payStatus / 期次 paymentScheduleStatus 混用) */
|
||||
export const samplePaymentProgress = createRegistry({
|
||||
dfj: { label: '待缴费', tagType: 'info' },
|
||||
bfyj: { label: '部分已缴', tagType: 'primary' },
|
||||
yjq: { label: '已缴清', tagType: 'success' },
|
||||
待缴费: { label: '待缴费', tagType: 'info' },
|
||||
待缴清: { label: '待缴费', tagType: 'info' }, // progress-only alias
|
||||
部分已缴: { label: '部分已缴', tagType: 'primary' },
|
||||
部分缴费: { label: '部分已缴', tagType: 'primary' },
|
||||
已缴清: { label: '已缴清', tagType: 'success' }
|
||||
})
|
||||
|
||||
/** 应缴批次 scheduleStatus(open=待缴清;勿与 samplePaymentProgress.dfj=待缴费 混用) */
|
||||
export const paymentScheduleStatus = createRegistry({
|
||||
open: { label: '待缴清', tagType: 'warning' },
|
||||
cleared: { label: '已缴清', tagType: 'success' },
|
||||
void: { label: '已作废', tagType: 'info' },
|
||||
pending: { label: '待缴清', tagType: 'warning' }, // mobile-only alias → open
|
||||
paid: { label: '已缴清', tagType: 'success' },
|
||||
partial: { label: '部分到账', tagType: 'primary' },
|
||||
closed: { label: '已关闭', tagType: 'info' }
|
||||
})
|
||||
|
||||
export const protocolStatus = createRegistry({
|
||||
dsx: { label: '待生效', tagType: 'info' },
|
||||
sxz: { label: '生效中', tagType: 'primary' },
|
||||
ygq: { label: '已过期', tagType: 'warning' },
|
||||
yzf: { label: '已作废', tagType: 'danger' },
|
||||
sdfq: { label: '属地废弃', tagType: 'danger' },
|
||||
zky: { label: '转科研', tagType: 'primary' }
|
||||
})
|
||||
|
||||
export const donationStatus = createRegistry({
|
||||
dsx: { label: '待生效', tagType: 'info' },
|
||||
sxz: { label: '生效中', tagType: 'primary' },
|
||||
ygq: { label: '已过期', tagType: 'warning' },
|
||||
yzf: { label: '已作废', tagType: 'danger' },
|
||||
sdfq: { label: '属地废弃', tagType: 'danger' },
|
||||
zckc: { label: '转细胞存储', tagType: 'primary' }
|
||||
})
|
||||
|
||||
export const payMode = createRegistry({
|
||||
dj: { label: '趸交', tagType: 'primary' },
|
||||
fq: { label: '分期', tagType: 'warning' },
|
||||
djfq: { label: '趸交+分期', tagType: 'warning' },
|
||||
fgd: { label: '分改趸', tagType: 'warning' }
|
||||
})
|
||||
|
||||
/** 转账笔 payStatus(dfj=已付款;勿与样本进度 dfj=待缴费 混用) */
|
||||
export const payStatus = createRegistry({
|
||||
dfj: { label: '已付款', tagType: 'primary' },
|
||||
jfqrz: { label: '付款确认中', tagType: 'warning' },
|
||||
yjf: { label: '付款完成', tagType: 'success' },
|
||||
tfqrz: { label: '退费确认中', tagType: 'warning' },
|
||||
ytf: { label: '已退费', tagType: 'danger' }
|
||||
})
|
||||
|
||||
export const paymentChaseStatus = createRegistry({
|
||||
overdue: { label: '已逾期', tagType: 'danger' },
|
||||
upcoming: { label: '即将到期', tagType: 'warning' }
|
||||
})
|
||||
|
||||
export const auditStatus = createRegistry({
|
||||
shtg: { label: '审核通过', tagType: 'success' },
|
||||
shth: { label: '审核退回', tagType: 'danger' }
|
||||
})
|
||||
|
||||
export const transportType = createRegistry({
|
||||
kdys: { label: '快递运输', tagType: 'info' },
|
||||
ryxd: { label: '人员携带', tagType: 'success' }
|
||||
})
|
||||
|
||||
/** 本范围至少覆盖 cell_storage / research_donation;其余与 Web 一致 */
|
||||
export const receptionSource = createRegistry({
|
||||
cell_storage: { label: '细胞存储', tagType: 'primary' },
|
||||
research_donation: { label: '科研捐赠', tagType: 'warning' },
|
||||
outbound: { label: '出库', tagType: 'primary' },
|
||||
pilot_service: { label: '中试服务', tagType: 'primary' },
|
||||
clinical_application: { label: '临床应用', tagType: 'warning' },
|
||||
basic_experiment: { label: '基础实验', tagType: 'primary' }
|
||||
})
|
||||
|
||||
export const presignOrderStatus = createRegistry({
|
||||
draft: { label: '草稿', tagType: 'info' },
|
||||
active: { label: '进行中', tagType: 'warning' },
|
||||
converted: { label: '已转正式', tagType: 'success' },
|
||||
void: { label: '已作废', tagType: 'danger' }
|
||||
})
|
||||
|
||||
export const transferType = createRegistry({
|
||||
wxzz: { label: '微信转账', tagType: 'success' },
|
||||
zzbzz: { label: '支付宝转账', tagType: 'primary' },
|
||||
yhkzz: { label: '银行卡转账', tagType: 'info' },
|
||||
xj: { label: '现金', tagType: 'warning' },
|
||||
lszz: { label: '乐刷', tagType: 'primary' }
|
||||
})
|
||||
@@ -0,0 +1,61 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
resolveStatusTag,
|
||||
samplePaymentProgress,
|
||||
paymentScheduleStatus,
|
||||
payStatus,
|
||||
payMode,
|
||||
presignOrderStatus,
|
||||
receptionSource,
|
||||
transportType,
|
||||
auditStatus
|
||||
} from './status-tag-registry.js'
|
||||
|
||||
test('sample progress dfj is 待缴费/info not 待缴清', () => {
|
||||
assert.deepEqual(resolveStatusTag(samplePaymentProgress, 'dfj'), {
|
||||
label: '待缴费',
|
||||
tagType: 'info'
|
||||
})
|
||||
})
|
||||
|
||||
test('schedule open is 待缴清/warning', () => {
|
||||
assert.deepEqual(resolveStatusTag(paymentScheduleStatus, 'open'), {
|
||||
label: '待缴清',
|
||||
tagType: 'warning'
|
||||
})
|
||||
})
|
||||
|
||||
test('payStatus dfj is 已付款/primary', () => {
|
||||
assert.deepEqual(resolveStatusTag(payStatus, 'dfj'), {
|
||||
label: '已付款',
|
||||
tagType: 'primary'
|
||||
})
|
||||
})
|
||||
|
||||
test('payMode covers djfq and fgd as warning', () => {
|
||||
assert.equal(resolveStatusTag(payMode, 'dj').tagType, 'primary')
|
||||
assert.equal(resolveStatusTag(payMode, 'djfq').tagType, 'warning')
|
||||
assert.equal(resolveStatusTag(payMode, 'fgd').label, '分改趸')
|
||||
})
|
||||
|
||||
test('presign draft uses info not default', () => {
|
||||
assert.deepEqual(resolveStatusTag(presignOrderStatus, 'draft'), {
|
||||
label: '草稿',
|
||||
tagType: 'info'
|
||||
})
|
||||
})
|
||||
|
||||
test('freight source cell_storage is primary', () => {
|
||||
assert.equal(resolveStatusTag(receptionSource, 'cell_storage').tagType, 'primary')
|
||||
assert.equal(resolveStatusTag(transportType, 'kdys').tagType, 'info')
|
||||
assert.equal(resolveStatusTag(transportType, 'ryxd').tagType, 'success')
|
||||
})
|
||||
|
||||
test('audit shth is danger', () => {
|
||||
assert.equal(resolveStatusTag(auditStatus, 'shth').tagType, 'danger')
|
||||
})
|
||||
|
||||
test('progress alias 待缴清 normalizes to 待缴费', () => {
|
||||
assert.equal(resolveStatusTag(samplePaymentProgress, '待缴清').label, '待缴费')
|
||||
})
|
||||
Reference in new issue
Block a user