From 4dc90ac53977a0f3e470e3ac6e7ca48a7deebdf4 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Thu, 1 Oct 2026 09:07:35 +0800 Subject: [PATCH] 1 --- src/api/stock.check/stock.check.ts | 198 ++++++++++- .../components/ColumnCellRenderer.vue | 4 +- .../config/components/CheckItemsPanel.vue | 313 +++++++++--------- .../config/components/DetailPanel.vue | 5 +- .../stockcheck/config/template-config.ts | 269 ++++++++++++--- src/views/storage/stockcheck/index.vue | 28 +- .../stockcheck/pages/CheckFormDialog.vue | 52 ++- .../stockcheck/pages/CheckPatternDialog.vue | 275 +++++++++++++++ temp_stockcheck_tail.txt | 131 ++++++++ 9 files changed, 1036 insertions(+), 239 deletions(-) create mode 100644 src/views/storage/stockcheck/pages/CheckPatternDialog.vue create mode 100644 temp_stockcheck_tail.txt diff --git a/src/api/stock.check/stock.check.ts b/src/api/stock.check/stock.check.ts index c04ca95d..b5f8af97 100644 --- a/src/api/stock.check/stock.check.ts +++ b/src/api/stock.check/stock.check.ts @@ -64,6 +64,8 @@ export type StockCheckAuditAction = 'approve' | 'reject' /** 盘点主表行(create 响应 / list rows / detail.check 同构) */ export type StockCheckTask = { id: number + /** 所属仓库ID(服务端按登录上下文注入) */ + warehouse_id?: number /** 盘点单号(PD+YYYYMMDD+6 位序号,按仓库隔离) */ check_no: string /** 盘点名称/主题 */ @@ -72,9 +74,18 @@ export type StockCheckTask = { mode: StockCheckMode /** 货主ID(type=store 按货主盘点时有值) */ store_id?: number | null + /** 货主名称(list 回包附加字段,type=store 等场景有值,用于列表「货主名称」列) */ + store_name?: string | null + /** 盘点范围快照(后端可选字段,常为 null) */ + scope_snapshot?: unknown status: StockCheckStatus detail_status: StockCheckDetailStatus - /** 盘点日期 */ + /** + * 盘点日期 + * + * ⚠️ stock.check.list 最新回包**已不含该字段**(创建也不再传日期), + * 保留仅作兼容(detail 等回包或历史数据可能仍有值),前端列表/详情不再展示。 + */ check_date?: string | null /** 实际开始时间(开始盘点作业后回填) */ start_time?: string | null @@ -225,7 +236,12 @@ export type StockCheckResultRow = StockCheckDetailRow & { // ============ stock.check.create ============ -/** stock.check.create 请求参数(warehouse_id 服务端注入,禁止前端传;check_date 必填) */ +/** + * stock.check.create 请求参数(warehouse_id 服务端注入,禁止前端传) + * + * 注意:前端**统一不传** check_date,由服务端缺省为当天(接口文档标注其为必填, + * 若后续后端收紧校验,需在此恢复必填并在表单中补回日期选择)。 + */ export type StockCheckCreateParams = { /** 盘点名称/主题 */ title?: string @@ -235,8 +251,8 @@ export type StockCheckCreateParams = { mode?: StockCheckMode /** 货主ID(type=store 时必填) */ store_id?: number - /** 盘点日期(必填,须可被 Date 解析) */ - check_date: string + /** 盘点日期(前端不传,服务端缺省当天;传入时须可被 Date 解析) */ + check_date?: string remark?: string } @@ -257,16 +273,176 @@ export function stockCheckCreate( } as any) } +// ============ stock.check.patternList ============ + +/** + * 盘点定式(快速创建盘点任务时可选的内置模板) + * + * 定式由后端代码注册(app/service/systems/stock_check_patterns.js),**不建表**,共 5 个: + * empty_location=空库位盘点 / mis_shipment=错发盘点 / expiring=临期盘点 / + * static=静态盘点 / warning=预警盘点 + */ +export type StockCheckPattern = { + /** 定式ID(创建时作为 pattern_id 传入) */ + id: string + /** 定式名称 */ + name: string + /** 定式说明 */ + description?: string + /** + * 定式收集盘点对象后的明细形态: + * goods → 命中商品库存ID(stock_ids)→ 商品行明细 + * location → 命中库位列表 → 库位行明细 + */ + type?: 'goods' | 'location' | string + [key: string]: unknown +} + +/** stock.check.patternList 响应(无入参) */ +export type StockCheckPatternListResponse = { + /** 内置定式清单 */ + patterns?: StockCheckPattern[] + [key: string]: unknown +} + +/** + * stock.check.patternList:拉取盘点定式清单(供前端选择定式快速创建盘点任务) + * + * 返回代码注册的 5 个内置定式,每条含 id/name/description/type;无入参。 + */ +export function stockCheckPatternList(): Promise< + StockCheckPatternListResponse & { + code?: number + message?: string + data?: Partial | StockCheckPattern[] + } +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'stock.check.patternList', + v, + timestamp: new Date().getTime() + }, + data: {}, + isSystemApi: true + } as any) +} + +// ============ stock.check.patternCreate ============ + +/** + * stock.check.patternCreate 请求参数 + * + * warehouse_id 与创建人均由服务端从登录上下文注入(ctx.user.store_id / id / employees_name), + * 前端**禁止传入**;check_date 可不传(缺省今天),故前端无需选择盘点日期。 + */ +export type StockCheckPatternCreateParams = { + /** 定式ID:empty_location / mis_shipment / expiring / static / warning(patternId 为驼峰兼容别名) */ + pattern_id: string + /** 定式ID(驼峰别名,兼容写法;两者都传时 pattern_id 优先) */ + patternId?: string + /** 盘点名称/主题,缺省取定式 name */ + title?: string + /** 盘点方式,缺省 open:open=明盘 / blind=盲盘 */ + mode?: StockCheckMode + /** 盘点日期(可省略,缺省今天) */ + check_date?: string + /** 备注 */ + remark?: string +} + +/** stock.check.patternCreate 响应 */ +export type StockCheckPatternCreateResponse = { + /** 创建出的盘点任务(部分回包形态下与响应同级) */ + check?: StockCheckTask + /** 按定式收集到的盘点对象数量 */ + total_items?: number + /** static 定式:批量写入 wms_stock_static_check_task 的命中条数(写入失败不影响主流程) */ + static_written?: number + [key: string]: unknown +} + +/** + * stock.check.patternCreate:**按定式快速创建盘点任务** + * + * - 入参 `pattern_id`(兼容 `patternId` 驼峰写法,两者都传时 `pattern_id` 优先) + * - warehouse_id / 创建人由服务端注入;按定式收集盘点对象(goods 型 → stock_ids,location 型 → 库位列表) + * - 无符合条件对象时后端报 400;创建后主表 status 直接为 `submitted`(待审核)、detail_status=none_checked + * - static 定式创建成功后会把命中的 stock_id 批量写入 wms_stock_static_check_task(失败不影响主流程) + * - 写操作,记录操作日志 + */ +export function stockCheckPatternCreate( + data: StockCheckPatternCreateParams +): Promise< + StockCheckPatternCreateResponse & { + code?: number + message?: string + data?: Partial + } +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'stock.check.patternCreate', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + // ============ stock.check.list ============ -/** stock.check.list 的 where 条件 */ +/** + * where 条件项(后端查询协议):`{ operator, value, type? }` + * + * 规范见仓库根目录 stock-stockWarehouse-query-rules.md(与其他 storage 列表一致), + * 前端**不能**直接传裸标量/数组,必须包成该结构。 + */ +export type StockCheckWhereCondition = { + /** 操作符:eq / ne / like / notlike / in / notin / between / notbetween / isnull / isnotnull ... */ + operator: string + /** 查询值(between 时为 [start, end]) */ + value: unknown + /** 值类型:text / number / boolean / date / daterange / datetimerange */ + type?: 'text' | 'number' | 'boolean' | 'date' | 'daterange' | 'datetimerange' +} + +/** + * 时间范围条件(`operator=between` + `type=datetimerange`,值带时分秒) + * + * 实测(2026-10-01):时间范围必须精确到时分秒——只传 `YYYY-MM-DD`(type=daterange) + * 会把当天带时分秒的记录全部排除,导致「今天无结果」。 + */ +export type StockCheckRangeCondition = StockCheckWhereCondition & { + operator: 'between' | 'notbetween' + /** [开始, 结束],'YYYY-MM-DD HH:mm:ss'(仅日期时会补 00:00:00 / 23:59:59) */ + value: [string, string] + type: 'daterange' | 'datetimerange' +} + +/** stock.check.list 的 where 条件(每项均为 `{ operator, value, type? }` 结构) */ export type StockCheckListWhere = { - /** 状态筛选(单值或数组):created/submitted/rejected/approved/checking/completed/cancelled */ - status?: StockCheckStatus | StockCheckStatus[] - /** 货主筛选 */ - store_id?: number - /** 关键字:对盘点单号/标题模糊匹配 */ - keyword?: string + /** 关键字(盘点单号/标题模糊匹配):`{ operator: 'like', value: 'PD2026', type: 'text' }` */ + keyword?: StockCheckWhereCondition + /** 状态筛选:created/submitted/rejected/approved/checking/completed/cancelled */ + status?: StockCheckWhereCondition + /** 货主筛选:`{ operator: 'eq', value: 100000, type: 'number' }` */ + store_id?: StockCheckWhereCondition + /** 盘点范围筛选(all/location/store/goods):`{ operator: 'eq', value: 'goods', type: 'text' }` */ + type?: StockCheckWhereCondition + /** 盘点方式筛选(open/blind):`{ operator: 'eq', value: 'blind', type: 'text' }` */ + mode?: StockCheckWhereCondition + /** 创建时间范围(含时分秒):`{ operator: 'between', value: ['2026-10-01 00:00:00', '2026-10-01 23:59:59'], type: 'datetimerange' }` */ + created_at?: StockCheckRangeCondition + /** 盘点开始时间范围(对应列表「开始时间」列) */ + start_time?: StockCheckRangeCondition + /** 盘点结束时间范围(对应列表「结束时间」列) */ + end_time?: StockCheckRangeCondition } /** stock.check.list 请求参数 */ diff --git a/src/views/storage/stockcheck/components/ColumnCellRenderer.vue b/src/views/storage/stockcheck/components/ColumnCellRenderer.vue index ecb109b5..553d2824 100644 --- a/src/views/storage/stockcheck/components/ColumnCellRenderer.vue +++ b/src/views/storage/stockcheck/components/ColumnCellRenderer.vue @@ -36,7 +36,7 @@ const props = defineProps<{ value: any }>() -/** 显示文本:translateField 翻译 > format 格式化 > 原始值 */ +/** 显示文本:translateField 翻译 > format 格式化 > 原始值(空值统一显示 —) */ const displayValue = computed(() => { const v = props.value if (props.config?.translateField) { @@ -48,7 +48,7 @@ const displayValue = computed(() => { if (props.config?.format === 'date') { return formatDate(v) } - return v ?? '—' + return v === undefined || v === null || v === '' ? '—' : v }) const resolvedTagType = computed(() => { diff --git a/src/views/storage/stockcheck/config/components/CheckItemsPanel.vue b/src/views/storage/stockcheck/config/components/CheckItemsPanel.vue index 155e3420..c4c1db5b 100644 --- a/src/views/storage/stockcheck/config/components/CheckItemsPanel.vue +++ b/src/views/storage/stockcheck/config/components/CheckItemsPanel.vue @@ -7,10 +7,11 @@ (范围行 + 已盘/差异/状态/作业记录聚合) - 尚未开始作业的阶段(created/rejected/submitted,必然无作业记录)→ **stock.check.detail** (纯范围行,不含聚合;此时作业类列不渲染,无需多发一次聚合查询) - 行形态由任务 type 决定: + 明细行形态由任务 type 决定,表格统一「平铺」展示(不用展开行): - 商品行(scope_type=goods,type=store/goods):一行一个库存商品(商品快照 + 已盘聚合) - - 库位行(scope_type=location,type=all/location):一行一个库位,行内按商品聚合 stocks[], - 上报需带 stock_id → 展开行内按商品逐条上报 + - 库位行(scope_type=location,type=all/location):一行一个库位 + 行内商品各一行 + (result 的 stocks[] 平铺;无商品时保留库位行本身、商品列为 —) + 上报需带 stock_id → 商品行直接上报;同明细的「明细类型 / 库位」单元格合并显示 2. 盘点作业:行内或批量上报(stock.check.report,**覆盖式**: 商品行=同明细+同库位;库位行=同明细+同商品+同库位,均重复上报为更新) 3. 完成盘点(stock.check.finish,允许部分未盘完成: @@ -33,7 +34,7 @@ {{ isLocationTask ? '添加库位' : '添加商品' }} - - - + + + - - - - - - - - + + + + + + + + + + + + + - + @@ -221,25 +149,16 @@ - + +