feat(stock-check): 新建盘点支持静态盘点并在审核时提示锁定

- 新建盘点新增 isStatic 参数(0 关闭 / 1 开启),仅商品盘点显示并传递,库位盘点不传
- 盘点任务回包新增 is_static,列表与详情展示静态盘点标记
- 审核通过确认框对静态盘点任务额外提示:锁定移库、分配储位(拣货不受影响),盘点完成后自动解锁
- 操作列按钮配置支持 confirmMessageWhen 动态确认文案与 HTML 渲染

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-10-28 07:37:07 +08:00
parent 41a3563bce
commit d76d3c6746
5 changed files with 140 additions and 6 deletions

View File

@ -150,6 +150,12 @@ export type StockCheckTask = {
checked_items: number
/** 差异行数 */
diff_items: number
/**
* 是否静态盘点:0=关闭 / 1=开启(库位盘点恒为 0)
*
* 部分回包可能写成驼峰 `isStatic` 或布尔值,前端判定统一走 `isStaticCheckRow()`。
*/
is_static?: number | boolean | null
remark: string
created_at?: string
updated_at?: string
@ -357,6 +363,11 @@ export type StockCheckResultRow = StockCheckDetailRow & {
*
* mode 口径:按库位盘点(type=location)一律盲盘 blind(前端传值被忽略);
* 按商品盘点(type=store/goods)按传入值(默认明盘 open)。
*
* isStatic 口径:**仅商品盘点(type=store/goods)有效**,0=关闭(缺省)/1=开启;
* 按库位盘点(type=location)不显示该选项、**不传该字段**。
* 开启静态盘点的任务审核通过后会锁定移库 / 分配储位操作(拣货不受影响),
* 待盘点完成(finish)后由后端自动解锁。
*/
export type StockCheckCreateParams = {
/** 盘点名称/主题 */
@ -372,6 +383,13 @@ export type StockCheckCreateParams = {
mode?: StockCheckMode
/** 货主ID(type=store 时必填;添加商品明细时商品货主必须与该货主一致) */
store_id?: number
/**
* 是否静态盘点:0=关闭(缺省)/ 1=开启
*
* 仅商品盘点(type=store / goods)有效;库位盘点(type=location)不显示选项、不传。
* 开启后审核通过会锁定移库 / 分配储位操作(拣货不受影响),盘点完成后自动解锁。
*/
isStatic?: 0 | 1
remark?: string
}

View File

@ -4,7 +4,8 @@
根据 operationButtons 配置渲染按钮列表。
支持的行为类型:
- actionType='action' → 触发 @operation-action 事件(可选配置 confirmMessage 弹确认框)
- actionType='action' → 触发 @operation-action 事件(可选配置 confirmMessage 弹确认框;
confirmMessageWhen(row) 可按行数据覆盖确认文案,confirmUseHtml 允许 HTML 渲染)
- actionType='form' → 打开 COMPONENT_REGISTRY 中注册的表单组件
显隐与禁用:
@ -90,15 +91,17 @@ const actionLoadingMap = reactive<Record<string, boolean>>({})
// ============================================================
async function handleActionClick(btn: OperationButtonConfig) {
if (btn.confirmMessage) {
const confirmMessage = resolveConfirmMessage(btn)
if (confirmMessage) {
try {
await ElMessageBox.confirm(
btn.confirmMessage,
confirmMessage,
btn.confirmTitle || '确认操作',
{
confirmButtonText: btn.confirmButtonText || '确定',
cancelButtonText: '取消',
type: (btn.confirmType || 'warning') as any,
dangerouslyUseHTMLString: Boolean(btn.confirmUseHtml),
buttonSize: 'small'
}
)
@ -115,6 +118,19 @@ async function handleActionClick(btn: OperationButtonConfig) {
}
}
/** 确认文案:confirmMessageWhen(row) 优先,返回空则回退静态 confirmMessage */
function resolveConfirmMessage(btn: OperationButtonConfig): string {
if (typeof btn.confirmMessageWhen === 'function') {
try {
const dynamic = btn.confirmMessageWhen(props.row)
if (dynamic) return dynamic
} catch {
/* 忽略,回退静态 confirmMessage */
}
}
return btn.confirmMessage || ''
}
// ============================================================
// form 按钮:打开表单弹窗
// ============================================================

View File

@ -225,6 +225,18 @@ export const VALUE_MAPS: Record<string, Record<string, string>> = {
open: '明盘',
blind: '盲盘'
},
/**
* 是否静态盘点 is_static(0=关闭 / 1=开启;回包兼容布尔 true/false)
*
* 仅商品盘点可用;开启的任务审核通过后会锁定移库 / 分配储位(拣货不受影响),
* 盘点完成后由后端自动解锁。
*/
is_static: {
'1': '开启',
'0': '关闭',
true: '开启',
false: '关闭'
},
/** 明细行形态 scope_type(明细行的类型:商品行 / 库位行) */
scope_type: {
goods: '商品',
@ -278,6 +290,20 @@ export function isLegacyAllCheckType(type: unknown): boolean {
return String(type ?? '').trim().toLowerCase() === 'all'
}
/**
* 任务是否开启「静态盘点」
*
* 仅商品盘点(type=store/goods)有效,库位盘点恒为关闭。
* 回包字段可能是 `is_static`(下划线)或 `isStatic`(驼峰),值可能是 0/1 或布尔,
* 这里统一归一,供列表标记 / 审核提示 / 操作成功文案复用。
*/
export function isStaticCheckRow(row: Record<string, any> | null | undefined): boolean {
if (!row) return false
if (isLocationScopeType(row.type)) return false
const raw = row.is_static ?? row.isStatic
return raw === true || Number(raw) === 1 || String(raw ?? '').trim() === '1'
}
/** 翻译 value → label */
export function translate(field: string, value: any): string {
const map = VALUE_MAPS[field]
@ -453,6 +479,22 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagType: 'info', translateField: 'mode' }
},
/**
* 静态盘点标记(is_static,仅商品盘点可开启)
*
* 开启后:审核通过会锁定移库 / 分配储位操作(拣货不受影响),盘点完成后自动解锁。
*/
is_static: {
key: 'is_static',
label: '静态盘点',
scanBox: null,
table: { minWidth: 90, align: 'center' },
slot: {
type: 'tag',
tagType: { '1': 'warning', '0': 'info', true: 'warning', false: 'info' },
translateField: 'is_static'
}
},
status: {
key: 'status',
label: '盘点状态',
@ -599,6 +641,13 @@ export interface OperationButtonConfig {
*/
labelWhen?: (row: Record<string, any>) => string
confirmMessage?: string
/**
* 按行数据动态覆盖确认文案(返回空串/undefined 时回退 confirmMessage)
* 例:审核通过时,开启静态盘点的任务需额外提示移库/分配储位锁定
*/
confirmMessageWhen?: (row: Record<string, any>) => string
/** 确认文案是否按 HTML 渲染(confirmMessageWhen 需换行/高亮时开启) */
confirmUseHtml?: boolean
confirmTitle?: string
confirmType?: 'warning' | 'danger' | 'info'
confirmButtonText?: string
@ -1121,6 +1170,7 @@ const TABLE_COLUMN_KEYS = [
'title',
'type',
'mode',
'is_static',
'store_name',
'status',
'detail_status',
@ -1139,7 +1189,7 @@ const DETAIL_SECTIONS = [
{
title: '基本信息',
columnCount: 3,
fieldKeys: ['check_no', 'title', 'type', 'mode', 'status', 'detail_status', 'store_id', 'store_name']
fieldKeys: ['check_no', 'title', 'type', 'mode', 'is_static', 'status', 'detail_status', 'store_id', 'store_name']
},
{
title: '进度信息',
@ -1200,6 +1250,18 @@ const OPERATION_BUTTONS: OperationButtonConfig[] = [
actionType: 'action',
type: 'primary',
confirmMessage: '审核通过后即可开始盘点作业。确定通过?',
// 开启静态盘点:审核通过后锁定移库 / 分配储位(拣货不受影响),盘点完成后自动解锁
confirmMessageWhen: (row) =>
isStaticCheckRow(row)
? '<div>该盘点单已开启<b>静态盘点</b>,审核通过后:</div>' +
'<ul style="margin: 6px 0 8px; padding-left: 18px; line-height: 1.7;">' +
'<li>锁定<b>移库</b>、<b>分配储位</b>操作</li>' +
'<li><b>拣货不受影响</b></li>' +
'<li>需等盘点完成后自动解锁</li>' +
'</ul>' +
'<div>确定通过?</div>'
: '',
confirmUseHtml: true,
confirmTitle: '审核通过',
confirmType: 'info',
confirmButtonText: '确定通过',

View File

@ -361,6 +361,7 @@ import {
getTabToolbarButtons,
isCheckApiSuccess,
isLocationScopeType,
isStaticCheckRow,
loadStoreOptions,
storeOptions,
buildWhereConditions,
@ -566,9 +567,16 @@ async function handleOperationAction(key: string, row: Record<string, any>) {
case 'submitCheck':
await runCheckAction(() => stockCheckSubmit({ id }), '已提交审核')
break
case 'auditPass':
await runCheckAction(() => stockCheckAudit({ id, action: 'approve' }), '审核已通过')
case 'auditPass': {
const staticTip = isStaticCheckRow(row)
? ',已锁定移库/分配储位,盘点完成后自动解锁'
: ''
await runCheckAction(
() => stockCheckAudit({ id, action: 'approve' }),
`审核已通过${staticTip}`
)
break
}
case 'auditReject':
await handleAuditReject(row)
break

View File

@ -10,6 +10,9 @@
- mode 盘点方式:open 明盘 / blind 盲盘
—— 库位类(location)固定为 blind 盲盘且不可更改;商品类(store / goods)默认明盘
- store_id 货主ID(type=store 时必填)
- isStatic 是否静态盘点:0 关闭(缺省)/ 1 开启
—— **仅商品盘点(store / goods)有效**,库位盘点不显示选项且不传;
开启后审核通过会锁定移库 / 分配储位操作(拣货不受影响),盘点完成后自动解锁
- remark 备注
盘点时间不在本表单维护:主表已无 check_date,start_time(首个盘点明细写入时间)/
end_time(完成盘点时间)由盘点作业流程自动回填,前端不传。
@ -78,6 +81,16 @@
<span v-else-if="form.mode === 'blind'" class="form-tip">盲盘:盘点作业时前端不显示账面数量</span>
</el-form-item>
<el-form-item v-if="!isLocationType" label="静态盘点" prop="isStatic">
<el-radio-group v-model="form.isStatic">
<el-radio :value="0">关闭</el-radio>
<el-radio :value="1">开启</el-radio>
</el-radio-group>
<span v-if="form.isStatic === 1" class="form-tip form-tip--block">
开启后:审核通过将锁定移库、分配储位操作(拣货不受影响),盘点完成后自动解锁
</span>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="3" maxlength="200" show-word-limit placeholder="可留空" />
</el-form-item>
@ -147,12 +160,15 @@ const form = reactive<{
type: StockCheckType
store_id: number | undefined
mode: StockCheckMode
/** 是否静态盘点:0=关闭 / 1=开启(仅商品盘点可传,库位盘点不传) */
isStatic: 0 | 1
remark: string
}>({
title: '',
type: 'location',
store_id: undefined,
mode: 'blind',
isStatic: 0,
remark: ''
})
@ -175,6 +191,8 @@ watch(
() => form.type,
(type) => {
form.mode = isLocationScopeType(type) ? 'blind' : 'open'
// 静态盘点仅商品盘点有效,库位盘点重置为关闭
if (isLocationScopeType(type)) form.isStatic = 0
}
)
@ -201,6 +219,7 @@ function resetForm() {
form.type = 'location'
form.store_id = undefined
form.mode = 'blind'
form.isStatic = 0
form.remark = ''
}
@ -230,6 +249,8 @@ async function handleSubmit() {
type: form.type,
mode: form.mode,
store_id: form.type === 'store' ? form.store_id : undefined,
// 静态盘点仅商品盘点(store/goods)有效:库位盘点不显示选项、不传该字段
...(isLocationType.value ? {} : { isStatic: form.isStatic }),
remark: form.remark.trim() || undefined
})
if (!isCheckApiSuccess(res)) {
@ -280,6 +301,15 @@ async function handleSubmit() {
color: #909399;
}
/* 独立成行的提示(宽占满、无左间距),沿用 warning 色 */
.form-tip--block {
display: block;
margin-left: 0;
margin-top: 2px;
width: 100%;
line-height: 1.5;
}
.type-tip {
width: 100%;
margin-top: 2px;