diff --git a/src/api/stock.check/stock.check.ts b/src/api/stock.check/stock.check.ts index 2b840feb..13b36036 100644 --- a/src/api/stock.check/stock.check.ts +++ b/src/api/stock.check/stock.check.ts @@ -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 } diff --git a/src/views/storage/stockcheck/components/OperationCellRenderer.vue b/src/views/storage/stockcheck/components/OperationCellRenderer.vue index 8c3c39e0..56f84fc1 100644 --- a/src/views/storage/stockcheck/components/OperationCellRenderer.vue +++ b/src/views/storage/stockcheck/components/OperationCellRenderer.vue @@ -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>({}) // ============================================================ 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 按钮:打开表单弹窗 // ============================================================ diff --git a/src/views/storage/stockcheck/config/template-config.ts b/src/views/storage/stockcheck/config/template-config.ts index 1e146cd6..09fbf4a3 100644 --- a/src/views/storage/stockcheck/config/template-config.ts +++ b/src/views/storage/stockcheck/config/template-config.ts @@ -225,6 +225,18 @@ export const VALUE_MAPS: Record> = { 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 | 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 = { 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 confirmMessage?: string + /** + * 按行数据动态覆盖确认文案(返回空串/undefined 时回退 confirmMessage) + * 例:审核通过时,开启静态盘点的任务需额外提示移库/分配储位锁定 + */ + confirmMessageWhen?: (row: Record) => 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) + ? '
该盘点单已开启静态盘点,审核通过后:
' + + '
    ' + + '
  • 锁定移库、分配储位操作
  • ' + + '
  • 拣货不受影响
  • ' + + '
  • 需等盘点完成后自动解锁
  • ' + + '
' + + '
确定通过?
' + : '', + confirmUseHtml: true, confirmTitle: '审核通过', confirmType: 'info', confirmButtonText: '确定通过', diff --git a/src/views/storage/stockcheck/index.vue b/src/views/storage/stockcheck/index.vue index e9acde95..78405a6f 100644 --- a/src/views/storage/stockcheck/index.vue +++ b/src/views/storage/stockcheck/index.vue @@ -361,6 +361,7 @@ import { getTabToolbarButtons, isCheckApiSuccess, isLocationScopeType, + isStaticCheckRow, loadStoreOptions, storeOptions, buildWhereConditions, @@ -566,9 +567,16 @@ async function handleOperationAction(key: string, row: Record) { 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 diff --git a/src/views/storage/stockcheck/pages/CheckFormDialog.vue b/src/views/storage/stockcheck/pages/CheckFormDialog.vue index 3951c995..dfc2b0dd 100644 --- a/src/views/storage/stockcheck/pages/CheckFormDialog.vue +++ b/src/views/storage/stockcheck/pages/CheckFormDialog.vue @@ -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 @@ 盲盘:盘点作业时前端不显示账面数量 + + + 关闭 + 开启 + + + 开启后:审核通过将锁定移库、分配储位操作(拣货不受影响),盘点完成后自动解锁 + + + @@ -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;