12 Commits

77 changed files with 11725 additions and 663 deletions

View File

@@ -1,3 +1,6 @@
module.exports = { module.exports = {
extends: ['@commitlint/config-conventional'], extends: ['@commitlint/config-conventional'],
ignores: [
(message = '') => /^[^:\s]+[:]\s*V\d+(?:\.\d+)*\s+\S+/.test(message.trim()),
],
} }

4
.gitignore vendored
View File

@@ -30,8 +30,8 @@ docs/.vitepress/cache
src/types src/types
# 单独把这个文件排除掉,用以解决部分电脑生成的 auto-import.d.ts 的API不完整导致类型提示报错问题 # 单独把这个文件排除掉,用以解决部分电脑生成的 auto-import.d.ts 的API不完整导致类型提示报错问题
!src/types/auto-import.d.ts !src/types/auto-import.d.ts
src/manifest.json #src/manifest.json
src/pages.json #src/pages.json
# 2025-10-15 by 菲鸽: lock 文件还是需要加入版本管理,今天又遇到版本不一致导致无法运行的问题了。 # 2025-10-15 by 菲鸽: lock 文件还是需要加入版本管理,今天又遇到版本不一致导致无法运行的问题了。
# pnpm-lock.yaml # pnpm-lock.yaml

View File

@@ -1 +0,0 @@
npx lint-staged --allow-empty

View File

@@ -0,0 +1,367 @@
# 采购入库 PDA 扫码页重构设计
## 背景
当前“扫码采购入库”页面更接近通用表单页,而非工厂仓库现场的扫码作业页。页面在未锁定采购单前就暴露了商品扫码、批次号、库位码、提交等动作,导致流程噪音大、操作节奏不稳定、误操作风险高。
本次重构面向工厂仓库出入库场景,明确主使用设备与操作方式:
- 90% 使用 PDA / 手持终端物理扫码枪
- 10% 使用手机摄像头扫码
- 商品扫码主路径为“一枪一件”,每次扫码自动累计 `+1`
因此页面设计必须优先服务高频、连续、站立式作业,而不是低频表单录入。
## 目标
重构采购入库扫码页,使其满足以下目标:
- 先锁采购单,再进入连续扫码作业
- 商品扫码成功时不打断操作节奏
- 异常时给出明确、可恢复的处理反馈
- 始终让操作员看到当前单据、当前仓库、扫码进度、异常数量
- 降低危险操作误触概率,避免“清空全部”成为高频可见动作
- 保持与现有 ERP 扫码页代码风格一致,优先复用现有扫描输入、明细列表、提交逻辑能力
## 非目标
本次设计不包含以下范围:
- 不重做采购入库后端接口协议
- 不新增复杂的离线同步机制
- 不引入多步骤向导页或跨页长流程
- 不为手机摄像头场景单独做一套交互,只保留备用入口
## 设计方向
页面采用“作业台式”方案。锁单是进入作业态的前置动作,作业态才是页面主体。
相比“单页折叠式”或“全表单式”,作业台式更适合 PDA 连续扫码场景,原因是:
- 核心视线始终集中在当前单据、扫码输入、最近结果
- 可以让商品扫码输入框常驻焦点,适应物理扫码枪回车行为
- 订单上下文与作业进度持续可见,减少扫错单、扫过量、扫混仓的风险
## 页面状态
页面只允许存在两个一等状态:`锁单态``作业态`
### 锁单态
页面目标只有一件事:确定当前采购单。
展示内容:
- 页面标题:`扫码采购入库`
- 主动作:`扫描采购订单号`
- 次动作:`手动选单`
- 可选辅助文案:说明供应商、仓库、结算账户将在锁单后自动带出
锁单态不展示以下内容:
- 商品扫码输入框
- 批次号输入框
- 库位码输入框
- 入库明细列表
- 提交采购入库按钮
设计理由:未锁单前,商品扫码与提交都不可执行。提前展示只会制造误导。
### 作业态
选定采购单后进入作业态,页面主体切换为扫码作业台。
展示内容:
- 顶部固定订单信息条
- 商品扫码输入区
- 批次号、库位码辅助区
- 最近扫描记录区
- 底部主提交区
作业态的默认焦点必须回到商品扫码输入框,以适应 PDA 连续扫码。
## 页面结构
### 1. 顶部固定订单信息条
用于持续回答两个问题:当前在扫哪张单,以及还差多少。
固定展示字段:
- `采购单号`:最醒目的主字段,例如 `CG2025001`
- `供应商`
- `仓库`
- `进度`:格式为 `已扫 X / Y`
- `异常数`:格式为 `异常 N`
规则:
- 当异常数大于 0 时,使用警示色强调
- 顶部信息条在明细滚动时仍保持可见
- 标题可显示为 `采购入库 / CG2025001`,帮助快速确认当前上下文
### 2. 商品扫码输入区
这是作业态的主操作区。
字段与控件:
- 商品条码输入框:主输入,常驻焦点
- 批次号输入框:可选
- 库位码输入框:可选
- 相机按钮:仅手机摄像头备用
规则:
- 商品扫码成功后自动累计 `+1`
- 默认不依赖手动点击“确认”按钮完成正常扫码
- 若保留“确认”能力,也仅作为手机手输备用,不应成为 PDA 主路径
- 商品扫码完成后,焦点自动回到商品条码输入框
### 3. 最近扫描记录区
该区域不是传统表单明细,而是作业回显区。
默认展示:
- 最近 5 条扫描记录
- 最新一条置顶
- 最新成功记录高亮约 2 秒
每条记录显示:
- 商品名称
- 商品条码
- 批次号
- 库位码
- 当前明细累计数量
- 当前订单该商品剩余可入库数量
合并规则:
- 同商品、同批次、同库位的重复扫码:合并到同一条明细并数量 `+1`
- 同商品但批次不同:分成新行
- 同商品但库位不同:分成新行
操作规则:
- 每条记录提供 `撤销``删除本条` 能力
- 不提供高频可见的 `清空全部`
### 4. 底部主提交区
底部只保留一个强主动作:`提交采购入库`
规则:
- 仅当存在有效明细时可点击
- 点击后进入 loading防止重复提交
- 不将 `清空全部``提交` 并列摆放
## 扫码交互规则
### 正常路径
锁单后PDA 连续扫码主路径如下:
1. 扫描商品条码
2. 系统匹配当前采购单中的订单行
3. 若匹配成功,则新增或累计对应明细
4. 数量自动 `+1`
5. 顶部进度同步刷新
6. 页面显示成功反馈,例如:`西兰花 +1已扫 12 / 30`
7. 焦点返回商品扫码输入框,等待下一枪
正常路径要求:
- 不弹窗
- 不要求人工再次确认
- 不打断扫码节奏
### PDA 行为适配
考虑物理扫码枪通常自带输入结束与回车行为,页面需满足:
- 商品条码输入框支持快速连续触发提交
- 回车后自动执行匹配与累计
- 成功后无需额外点击
- 扫码完成后尽快恢复待扫状态
### 手机摄像头备用路径
手机端仍保留相机按钮,但定位是备用入口:
- 适用于无 PDA 或临时补录
- 交互与 PDA 一致,扫码成功后同样走自动累计逻辑
- 不单独扩展额外的手机专属页面流程
## 异常处理
异常处理分为三类。
### 1. 不中断型反馈
适用于成功扫码。
表现:
- 使用绿色反馈条或高可见状态条
- 文案直接描述结果,例如:`西兰花 +1已扫 12 / 30`
- 持续约 0.8 到 1.2 秒后消失
- 焦点自动回到商品扫码输入框
### 2. 中断型异常
适用于以下场景:
- 商品不在当前采购单内
- 商品剩余可入库数量为 0
- 扫码后将超出剩余可入库数量
- 条码命中多个待入库订单行
- 当前采购单未锁定
表现:
- 使用红色错误条或常驻错误提示
- 错误文案必须明确原因,不能只写“操作失败”
- 焦点不应伪装成成功回跳
- 必要时进入人工处理分支
推荐错误文案:
- `商品不在当前采购单内`
- `该商品剩余可入库 0 件`
- `该商品本次扫码后将超出剩余数量`
- `条码命中多个订单行,请人工选择`
- `请先扫描采购订单号`
### 3. 可恢复型提示
适用于非强拦截场景,例如:
- 批次号为空
- 库位码为空
处理原则:
- 若业务允许为空,则不拦截扫码
- 可在记录中标记为空,或在提交前统一提醒
- 不应影响正常扫码节奏
## 危险操作策略
仓库扫码场景下,危险操作必须降级。
优先提供:
- `撤销上一笔`
- `删除单条`
降级隐藏:
- `清空全部`
规则:
- `清空全部` 放入右上角更多菜单或二级操作区
- 执行前必须二次确认
- 不能与 `提交采购入库` 同层并列
原因:现场最常见修正动作是撤销刚才那一枪,而不是整单清空。
## 提交流程
### 提交前条件
`提交采购入库` 按钮仅在满足以下条件时启用:
- 已锁定采购单
- 至少存在 1 条有效明细
### 提交前校验
提交前统一执行轻校验,检查:
- 是否已锁单
- 是否存在有效明细
- 是否存在未处理异常
- 是否存在超量或冲突记录
- 若业务要求,可额外检查是否存在空库位记录
### 提交中行为
- 提交按钮进入 loading
- 页面避免重复触发提交
- 不清空当前上下文,直到接口明确成功
### 提交成功后
成功反馈不能只有“成功”提示,而应给用户明确后续动作:
- `继续当前单据扫码`
- `返回列表`
若业务允许同一采购单分批入库,则继续当前单据是高价值动作。
### 提交失败后
提交失败时必须保留现场:
- 当前采购单
- 已扫明细
- 当前批次号 / 库位码上下文
- 当前异常状态
不能因为接口失败而丢失现场数据,否则会造成重复作业和人工补录。
## 数据与组件边界
建议将页面逻辑拆分为以下职责单元:
- `锁单上下文`:负责采购单选择、锁定、切换、上下文字段映射
- `扫码作业上下文`:负责商品扫码、累计、异常判断、反馈文案
- `最近扫描记录列表`:负责最近记录展示、合并、撤销
- `提交控制器`:负责校验、提交、成功/失败收尾
实现时应优先复用现有能力:
- 扫码输入组件
- ERP 明细展示组件
- 采购入库现有数据结构与接口
避免将全部状态与条件判断继续堆在单个页面文件中。
## 错误处理与恢复策略
- 切换采购单前,如已有明细,需明确提示并确认
- 删除或撤销明细后,顶部进度立即回算
- 发生条码歧义时,进入人工选择而不是静默失败
- 明细为空时不得允许提交
- 页面刷新或重新进入时,若未设计暂存机制,则明确回到锁单态
## 测试关注点
测试应覆盖以下高风险路径:
- 未锁单时误扫商品
- 连续多枪同商品累计
- 同商品不同批次 / 库位分行
- 超量扫码拦截
- 条码命中多个订单行
- 撤销上一笔后进度与剩余数量回算
- 提交失败后现场状态保留
- PDA 回车触发下焦点能持续回到主扫码框
## 设计结论
采购入库扫码页应从“表单页”重构为“PDA 作业台页”:
- 先锁单,再作业
- 一枪一件,自动累计
- 正常路径绝不打断
- 异常路径明确、可恢复
- 明细区服务作业反馈,不服务传统录单表单
- 危险操作降级,提交操作集中
该方案优先满足工厂仓库高频扫码场景,同时保留手机摄像头作为备用输入方式。

6
env/.env vendored
View File

@@ -1,7 +1,7 @@
VITE_APP_TITLE = '亚为mom小程序' VITE_APP_TITLE = '亚为mom小程序'
VITE_APP_PORT = 9000 VITE_APP_PORT = 9000
VITE_UNI_APPID = '__UNI__D1E5001' VITE_UNI_APPID = '__UNI__2EB12DE'
VITE_WX_APPID = 'wx1a832d51073d3a35' VITE_WX_APPID = 'wx1a832d51073d3a35'
# h5部署网站的base配置到 manifest.config.ts 里的 h5.router.base # h5部署网站的base配置到 manifest.config.ts 里的 h5.router.base
@@ -10,8 +10,8 @@ VITE_WX_APPID = 'wx1a832d51073d3a35'
VITE_APP_PUBLIC_BASE=/ VITE_APP_PUBLIC_BASE=/
# 后台请求地址 # 后台请求地址
VITE_SERVER_BASEURL = 'http://localhost:48080/admin-api' VITE_SERVER_BASEURL = 'http://127.0.0.1:48080/admin-api'
VITE_UPLOAD_BASEURL = 'http://localhost:48080/upload' VITE_UPLOAD_BASEURL = 'http://127.0.0.1:48080/upload'
# 备注如果后台带统一前缀则也要加到后面eg: https://ukw0y1.laf.run/api # 备注如果后台带统一前缀则也要加到后面eg: https://ukw0y1.laf.run/api
# 注意,如果是微信小程序,还有一套请求地址的配置,根据 develop、trial、release 分别设置上传地址,见 `src/utils/index.ts`。 # 注意,如果是微信小程序,还有一套请求地址的配置,根据 develop、trial、release 分别设置上传地址,见 `src/utils/index.ts`。

View File

@@ -82,33 +82,33 @@ export default defineManifestConfig({
/* 图标配置 */ /* 图标配置 */
icons: { icons: {
android: { android: {
hdpi: 'static/app/icons/72x72.png', hdpi: 'src/static/app/icons/72x72.png',
xhdpi: 'static/app/icons/96x96.png', xhdpi: 'src/static/app/icons/96x96.png',
xxhdpi: 'static/app/icons/144x144.png', xxhdpi: 'src/static/app/icons/144x144.png',
xxxhdpi: 'static/app/icons/192x192.png', xxxhdpi: 'src/static/app/icons/192x192.png',
}, },
ios: { ios: {
appstore: 'static/app/icons/1024x1024.png', appstore: 'src/static/app/icons/1024x1024.png',
ipad: { ipad: {
'app': 'static/app/icons/76x76.png', 'app': 'src/static/app/icons/76x76.png',
'app@2x': 'static/app/icons/152x152.png', 'app@2x': 'src/static/app/icons/152x152.png',
'notification': 'static/app/icons/20x20.png', 'notification': 'src/static/app/icons/20x20.png',
'notification@2x': 'static/app/icons/40x40.png', 'notification@2x': 'src/static/app/icons/40x40.png',
'proapp@2x': 'static/app/icons/167x167.png', 'proapp@2x': 'src/static/app/icons/167x167.png',
'settings': 'static/app/icons/29x29.png', 'settings': 'src/static/app/icons/29x29.png',
'settings@2x': 'static/app/icons/58x58.png', 'settings@2x': 'src/static/app/icons/58x58.png',
'spotlight': 'static/app/icons/40x40.png', 'spotlight': 'src/static/app/icons/40x40.png',
'spotlight@2x': 'static/app/icons/80x80.png', 'spotlight@2x': 'src/static/app/icons/80x80.png',
}, },
iphone: { iphone: {
'app@2x': 'static/app/icons/120x120.png', 'app@2x': 'src/static/app/icons/120x120.png',
'app@3x': 'static/app/icons/180x180.png', 'app@3x': 'src/static/app/icons/180x180.png',
'notification@2x': 'static/app/icons/40x40.png', 'notification@2x': 'src/static/app/icons/40x40.png',
'notification@3x': 'static/app/icons/60x60.png', 'notification@3x': 'src/static/app/icons/60x60.png',
'settings@2x': 'static/app/icons/58x58.png', 'settings@2x': 'src/static/app/icons/58x58.png',
'settings@3x': 'static/app/icons/87x87.png', 'settings@3x': 'src/static/app/icons/87x87.png',
'spotlight@2x': 'static/app/icons/80x80.png', 'spotlight@2x': 'src/static/app/icons/80x80.png',
'spotlight@3x': 'static/app/icons/120x120.png', 'spotlight@3x': 'src/static/app/icons/120x120.png',
}, },
}, },
}, },

View File

@@ -88,11 +88,11 @@
"build:quickapp-webview": "uni build -p quickapp-webview", "build:quickapp-webview": "uni build -p quickapp-webview",
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
"build:quickapp-webview-union": "uni build -p quickapp-webview-union", "build:quickapp-webview-union": "uni build -p quickapp-webview-union",
"test": "vitest run --config vitest.config.ts",
"type-check": "vue-tsc --noEmit", "type-check": "vue-tsc --noEmit",
"init-husky": "git init && husky", "init-husky": "git init && husky",
"init-baseFiles": "node ./scripts/create-base-files.js", "init-baseFiles": "node ./scripts/create-base-files.js",
"init-json": "pnpm init-baseFiles", "init-json": "pnpm init-baseFiles",
"prepare": "pnpm init-husky & pnpm init-baseFiles",
"lint": "eslint", "lint": "eslint",
"lint:fix": "eslint --fix" "lint:fix": "eslint --fix"
}, },
@@ -173,6 +173,7 @@
"unplugin-auto-import": "^20.0.0", "unplugin-auto-import": "^20.0.0",
"vite": "5.2.8", "vite": "5.2.8",
"vite-plugin-restart": "^1.0.0", "vite-plugin-restart": "^1.0.0",
"vitest": "^3.2.4",
"vue-tsc": "^3.0.6" "vue-tsc": "^3.0.6"
}, },
"pnpm": { "pnpm": {
@@ -188,6 +189,6 @@
"unconfig": "7.3.2" "unconfig": "7.3.2"
}, },
"lint-staged": { "lint-staged": {
"*": "eslint --fix" "*.{js,jsx,ts,tsx,vue}": "eslint --fix --cache --cache-location .eslintcache"
} }
} }

View File

@@ -2,6 +2,7 @@ import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
import { tabBar } from './src/tabbar/config' import { tabBar } from './src/tabbar/config'
export default defineUniPages({ export default defineUniPages({
pages: [],
globalStyle: { globalStyle: {
navigationStyle: 'default', navigationStyle: 'default',
navigationBarTitleText: '芋道管理系统', navigationBarTitleText: '芋道管理系统',

279
pnpm-lock.yaml generated
View File

@@ -135,7 +135,7 @@ importers:
version: 20.19.11 version: 20.19.11
'@uni-helper/eslint-config': '@uni-helper/eslint-config':
specifier: 0.5.0 specifier: 0.5.0
version: 0.5.0(@antfu/eslint-config@5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.34.0(jiti@2.6.1)) version: 0.5.0(@antfu/eslint-config@5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1)))(eslint@9.34.0(jiti@2.6.1))
'@uni-helper/plugin-uni': '@uni-helper/plugin-uni':
specifier: 0.1.0 specifier: 0.1.0
version: 0.1.0(@dcloudio/vite-plugin-uni@3.0.0-4070620250821001(postcss@8.5.6)(rollup@4.50.0)(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1))(vue@3.4.21(typescript@5.8.3))) version: 0.1.0(@dcloudio/vite-plugin-uni@3.0.0-4070620250821001(postcss@8.5.6)(rollup@4.50.0)(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1))(vue@3.4.21(typescript@5.8.3)))
@@ -235,6 +235,9 @@ importers:
vite-plugin-restart: vite-plugin-restart:
specifier: ^1.0.0 specifier: ^1.0.0
version: 1.0.0(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)) version: 1.0.0(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1))
vitest:
specifier: ^3.2.4
version: 3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1)
vue-tsc: vue-tsc:
specifier: ^3.0.6 specifier: ^3.0.6
version: 3.0.6(typescript@5.8.3) version: 3.0.6(typescript@5.8.3)
@@ -1937,12 +1940,18 @@ packages:
'@types/babel__traverse@7.28.0': '@types/babel__traverse@7.28.0':
resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==}
'@types/chai@5.2.3':
resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}
'@types/conventional-commits-parser@5.0.1': '@types/conventional-commits-parser@5.0.1':
resolution: {integrity: sha512-7uz5EHdzz2TqoMfV7ee61Egf5y6NkcO4FB/1iCCQnbeiI1F3xzv3vK5dBCXUCLQgGYS+mUeigK1iKQzvED+QnQ==} resolution: {integrity: sha512-7uz5EHdzz2TqoMfV7ee61Egf5y6NkcO4FB/1iCCQnbeiI1F3xzv3vK5dBCXUCLQgGYS+mUeigK1iKQzvED+QnQ==}
'@types/debug@4.1.12': '@types/debug@4.1.12':
resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}
'@types/deep-eql@4.0.2':
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
'@types/estree@1.0.8': '@types/estree@1.0.8':
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
@@ -2345,6 +2354,35 @@ packages:
vitest: vitest:
optional: true optional: true
'@vitest/expect@3.2.4':
resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==}
'@vitest/mocker@3.2.4':
resolution: {integrity: sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==}
peerDependencies:
msw: ^2.4.9
vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0
peerDependenciesMeta:
msw:
optional: true
vite:
optional: true
'@vitest/pretty-format@3.2.4':
resolution: {integrity: sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==}
'@vitest/runner@3.2.4':
resolution: {integrity: sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==}
'@vitest/snapshot@3.2.4':
resolution: {integrity: sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==}
'@vitest/spy@3.2.4':
resolution: {integrity: sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==}
'@vitest/utils@3.2.4':
resolution: {integrity: sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==}
'@volar/language-core@2.4.23': '@volar/language-core@2.4.23':
resolution: {integrity: sha512-hEEd5ET/oSmBC6pi1j6NaNYRWoAiDhINbT8rmwtINugR39loROSlufGdYMF9TaKGfz+ViGs1Idi3mAhnuPcoGQ==} resolution: {integrity: sha512-hEEd5ET/oSmBC6pi1j6NaNYRWoAiDhINbT8rmwtINugR39loROSlufGdYMF9TaKGfz+ViGs1Idi3mAhnuPcoGQ==}
@@ -2565,6 +2603,10 @@ packages:
array-timsort@1.0.3: array-timsort@1.0.3:
resolution: {integrity: sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==} resolution: {integrity: sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==}
assertion-error@2.0.1:
resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
engines: {node: '>=12'}
ast-kit@0.11.3: ast-kit@0.11.3:
resolution: {integrity: sha512-qdwwKEhckRk0XE22/xDdmU3v/60E8Edu4qFhgTLIhGGDs/PAJwLw9pQn8Rj99PitlbBZbYpx0k/lbir4kg0SuA==} resolution: {integrity: sha512-qdwwKEhckRk0XE22/xDdmU3v/60E8Edu4qFhgTLIhGGDs/PAJwLw9pQn8Rj99PitlbBZbYpx0k/lbir4kg0SuA==}
engines: {node: '>=16.14.0'} engines: {node: '>=16.14.0'}
@@ -2758,6 +2800,10 @@ packages:
centra@2.7.0: centra@2.7.0:
resolution: {integrity: sha512-PbFMgMSrmgx6uxCdm57RUos9Tc3fclMvhLSATYN39XsDV29B89zZ3KA89jmY0vwSGazyU+uerqwa6t+KaodPcg==} resolution: {integrity: sha512-PbFMgMSrmgx6uxCdm57RUos9Tc3fclMvhLSATYN39XsDV29B89zZ3KA89jmY0vwSGazyU+uerqwa6t+KaodPcg==}
chai@5.3.3:
resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==}
engines: {node: '>=18'}
chalk@4.1.2: chalk@4.1.2:
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'} engines: {node: '>=10'}
@@ -2776,6 +2822,10 @@ packages:
character-entities@2.0.2: character-entities@2.0.2:
resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
check-error@2.1.3:
resolution: {integrity: sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==}
engines: {node: '>= 16'}
chokidar@3.6.0: chokidar@3.6.0:
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
engines: {node: '>= 8.10.0'} engines: {node: '>= 8.10.0'}
@@ -3045,6 +3095,10 @@ packages:
dedent@0.7.0: dedent@0.7.0:
resolution: {integrity: sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==} resolution: {integrity: sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==}
deep-eql@5.0.2:
resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
engines: {node: '>=6'}
deep-is@0.1.4: deep-is@0.1.4:
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
@@ -3478,6 +3532,10 @@ packages:
resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==}
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
expect-type@1.3.0:
resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
engines: {node: '>=12.0.0'}
expect@27.5.1: expect@27.5.1:
resolution: {integrity: sha512-E1q5hSUG2AmYQwQJ041nvgpkODHQvB+RKlB4IYdru6uJsyFTRyZAP463M+1lINorwbqAmUggi6+WwkD8lCS/Dw==} resolution: {integrity: sha512-E1q5hSUG2AmYQwQJ041nvgpkODHQvB+RKlB4IYdru6uJsyFTRyZAP463M+1lINorwbqAmUggi6+WwkD8lCS/Dw==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
@@ -4299,6 +4357,9 @@ packages:
longest-streak@3.1.0: longest-streak@3.1.0:
resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
loupe@3.2.1:
resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==}
lru-cache@5.1.1: lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
@@ -4782,6 +4843,10 @@ packages:
pathe@2.0.3: pathe@2.0.3:
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
pathval@2.0.1:
resolution: {integrity: sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==}
engines: {node: '>= 14.16'}
perfect-debounce@1.0.0: perfect-debounce@1.0.0:
resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==} resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==}
@@ -5210,6 +5275,9 @@ packages:
resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==} resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
siginfo@2.0.0:
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
signal-exit@3.0.7: signal-exit@3.0.7:
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
@@ -5271,6 +5339,9 @@ packages:
resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==}
engines: {node: '>=10'} engines: {node: '>=10'}
stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
statuses@2.0.1: statuses@2.0.1:
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
@@ -5399,6 +5470,9 @@ packages:
timm@1.7.1: timm@1.7.1:
resolution: {integrity: sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==} resolution: {integrity: sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==}
tinybench@2.9.0:
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
tinycolor2@1.6.0: tinycolor2@1.6.0:
resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==} resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
@@ -5416,6 +5490,18 @@ packages:
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
engines: {node: '>=12.0.0'} engines: {node: '>=12.0.0'}
tinypool@1.1.1:
resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==}
engines: {node: ^18.0.0 || >=20.0.0}
tinyrainbow@2.0.0:
resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==}
engines: {node: '>=14.0.0'}
tinyspy@4.0.4:
resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==}
engines: {node: '>=14.0.0'}
tmpl@1.0.5: tmpl@1.0.5:
resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
@@ -5652,6 +5738,11 @@ packages:
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
vite-node@3.2.4:
resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
hasBin: true
vite-plugin-restart@1.0.0: vite-plugin-restart@1.0.0:
resolution: {integrity: sha512-t2ktkTOa+DQX05TEZm/3FE0DyrYEyFXdhG5gLcta5p71zOpg9yG3DeRcHWJVLJgWNoaVtOr4fUlr1kKu+WfXyQ==} resolution: {integrity: sha512-t2ktkTOa+DQX05TEZm/3FE0DyrYEyFXdhG5gLcta5p71zOpg9yG3DeRcHWJVLJgWNoaVtOr4fUlr1kKu+WfXyQ==}
peerDependencies: peerDependencies:
@@ -5685,6 +5776,34 @@ packages:
terser: terser:
optional: true optional: true
vitest@3.2.4:
resolution: {integrity: sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@types/debug': ^4.1.12
'@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0
'@vitest/browser': 3.2.4
'@vitest/ui': 3.2.4
happy-dom: '*'
jsdom: '*'
peerDependenciesMeta:
'@edge-runtime/vm':
optional: true
'@types/debug':
optional: true
'@types/node':
optional: true
'@vitest/browser':
optional: true
'@vitest/ui':
optional: true
happy-dom:
optional: true
jsdom:
optional: true
vscode-uri@3.1.0: vscode-uri@3.1.0:
resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==} resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==}
@@ -5772,6 +5891,11 @@ packages:
engines: {node: '>= 8'} engines: {node: '>= 8'}
hasBin: true hasBin: true
why-is-node-running@2.3.0:
resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
engines: {node: '>=8'}
hasBin: true
word-wrap@1.2.5: word-wrap@1.2.5:
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@@ -5916,7 +6040,7 @@ snapshots:
'@jridgewell/gen-mapping': 0.3.13 '@jridgewell/gen-mapping': 0.3.13
'@jridgewell/trace-mapping': 0.3.30 '@jridgewell/trace-mapping': 0.3.30
'@antfu/eslint-config@5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)': '@antfu/eslint-config@5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1))':
dependencies: dependencies:
'@antfu/install-pkg': 1.1.0 '@antfu/install-pkg': 1.1.0
'@clack/prompts': 0.11.0 '@clack/prompts': 0.11.0
@@ -5925,7 +6049,7 @@ snapshots:
'@stylistic/eslint-plugin': 5.4.0(eslint@9.34.0(jiti@2.6.1)) '@stylistic/eslint-plugin': 5.4.0(eslint@9.34.0(jiti@2.6.1))
'@typescript-eslint/eslint-plugin': 8.46.0(@typescript-eslint/parser@8.46.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3) '@typescript-eslint/eslint-plugin': 8.46.0(@typescript-eslint/parser@8.46.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)
'@typescript-eslint/parser': 8.46.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3) '@typescript-eslint/parser': 8.46.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)
'@vitest/eslint-plugin': 1.3.16(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3) '@vitest/eslint-plugin': 1.3.16(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1))
ansis: 4.2.0 ansis: 4.2.0
cac: 6.7.14 cac: 6.7.14
eslint: 9.34.0(jiti@2.6.1) eslint: 9.34.0(jiti@2.6.1)
@@ -8508,6 +8632,11 @@ snapshots:
dependencies: dependencies:
'@babel/types': 7.28.4 '@babel/types': 7.28.4
'@types/chai@5.2.3':
dependencies:
'@types/deep-eql': 4.0.2
assertion-error: 2.0.1
'@types/conventional-commits-parser@5.0.1': '@types/conventional-commits-parser@5.0.1':
dependencies: dependencies:
'@types/node': 20.19.11 '@types/node': 20.19.11
@@ -8516,6 +8645,8 @@ snapshots:
dependencies: dependencies:
'@types/ms': 2.1.0 '@types/ms': 2.1.0
'@types/deep-eql@4.0.2': {}
'@types/estree@1.0.8': {} '@types/estree@1.0.8': {}
'@types/graceful-fs@4.1.9': '@types/graceful-fs@4.1.9':
@@ -8711,9 +8842,9 @@ snapshots:
'@typescript-eslint/types': 8.46.0 '@typescript-eslint/types': 8.46.0
eslint-visitor-keys: 4.2.1 eslint-visitor-keys: 4.2.1
'@uni-helper/eslint-config@0.5.0(@antfu/eslint-config@5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(eslint@9.34.0(jiti@2.6.1))': '@uni-helper/eslint-config@0.5.0(@antfu/eslint-config@5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1)))(eslint@9.34.0(jiti@2.6.1))':
dependencies: dependencies:
'@antfu/eslint-config': 5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3) '@antfu/eslint-config': 5.2.1(@unocss/eslint-plugin@66.5.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3))(@vue/compiler-sfc@3.5.22)(eslint-plugin-format@1.0.1(eslint@9.34.0(jiti@2.6.1)))(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1))
'@eslint/eslintrc': 3.3.1 '@eslint/eslintrc': 3.3.1
eslint: 9.34.0(jiti@2.6.1) eslint: 9.34.0(jiti@2.6.1)
eslint-flat-config-utils: 2.1.1 eslint-flat-config-utils: 2.1.1
@@ -9108,16 +9239,59 @@ snapshots:
vite: 5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1) vite: 5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)
vue: 3.4.21(typescript@5.8.3) vue: 3.4.21(typescript@5.8.3)
'@vitest/eslint-plugin@1.3.16(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)': '@vitest/eslint-plugin@1.3.16(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1))':
dependencies: dependencies:
'@typescript-eslint/scope-manager': 8.46.0 '@typescript-eslint/scope-manager': 8.46.0
'@typescript-eslint/utils': 8.46.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3) '@typescript-eslint/utils': 8.46.0(eslint@9.34.0(jiti@2.6.1))(typescript@5.8.3)
eslint: 9.34.0(jiti@2.6.1) eslint: 9.34.0(jiti@2.6.1)
optionalDependencies: optionalDependencies:
typescript: 5.8.3 typescript: 5.8.3
vitest: 3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
'@vitest/expect@3.2.4':
dependencies:
'@types/chai': 5.2.3
'@vitest/spy': 3.2.4
'@vitest/utils': 3.2.4
chai: 5.3.3
tinyrainbow: 2.0.0
'@vitest/mocker@3.2.4(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1))':
dependencies:
'@vitest/spy': 3.2.4
estree-walker: 3.0.3
magic-string: 0.30.19
optionalDependencies:
vite: 5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)
'@vitest/pretty-format@3.2.4':
dependencies:
tinyrainbow: 2.0.0
'@vitest/runner@3.2.4':
dependencies:
'@vitest/utils': 3.2.4
pathe: 2.0.3
strip-literal: 3.0.0
'@vitest/snapshot@3.2.4':
dependencies:
'@vitest/pretty-format': 3.2.4
magic-string: 0.30.19
pathe: 2.0.3
'@vitest/spy@3.2.4':
dependencies:
tinyspy: 4.0.4
'@vitest/utils@3.2.4':
dependencies:
'@vitest/pretty-format': 3.2.4
loupe: 3.2.1
tinyrainbow: 2.0.0
'@volar/language-core@2.4.23': '@volar/language-core@2.4.23':
dependencies: dependencies:
'@volar/source-map': 2.4.23 '@volar/source-map': 2.4.23
@@ -9383,6 +9557,8 @@ snapshots:
array-timsort@1.0.3: {} array-timsort@1.0.3: {}
assertion-error@2.0.1: {}
ast-kit@0.11.3(rollup@4.50.0): ast-kit@0.11.3(rollup@4.50.0):
dependencies: dependencies:
'@babel/parser': 7.28.3 '@babel/parser': 7.28.3
@@ -9633,6 +9809,14 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- debug - debug
chai@5.3.3:
dependencies:
assertion-error: 2.0.1
check-error: 2.1.3
deep-eql: 5.0.2
loupe: 3.2.1
pathval: 2.0.1
chalk@4.1.2: chalk@4.1.2:
dependencies: dependencies:
ansi-styles: 4.3.0 ansi-styles: 4.3.0
@@ -9646,6 +9830,8 @@ snapshots:
character-entities@2.0.2: {} character-entities@2.0.2: {}
check-error@2.1.3: {}
chokidar@3.6.0: chokidar@3.6.0:
dependencies: dependencies:
anymatch: 3.1.3 anymatch: 3.1.3
@@ -9877,6 +10063,8 @@ snapshots:
dedent@0.7.0: {} dedent@0.7.0: {}
deep-eql@5.0.2: {}
deep-is@0.1.4: {} deep-is@0.1.4: {}
deepmerge@4.3.1: {} deepmerge@4.3.1: {}
@@ -10381,6 +10569,8 @@ snapshots:
exit@0.1.2: {} exit@0.1.2: {}
expect-type@1.3.0: {}
expect@27.5.1: expect@27.5.1:
dependencies: dependencies:
'@jest/types': 27.5.1 '@jest/types': 27.5.1
@@ -11427,6 +11617,8 @@ snapshots:
longest-streak@3.1.0: {} longest-streak@3.1.0: {}
loupe@3.2.1: {}
lru-cache@5.1.1: lru-cache@5.1.1:
dependencies: dependencies:
yallist: 3.1.1 yallist: 3.1.1
@@ -12045,6 +12237,8 @@ snapshots:
pathe@2.0.3: {} pathe@2.0.3: {}
pathval@2.0.1: {}
perfect-debounce@1.0.0: {} perfect-debounce@1.0.0: {}
phin@2.9.3: {} phin@2.9.3: {}
@@ -12475,6 +12669,8 @@ snapshots:
side-channel-map: 1.0.1 side-channel-map: 1.0.1
side-channel-weakmap: 1.0.2 side-channel-weakmap: 1.0.2
siginfo@2.0.0: {}
signal-exit@3.0.7: {} signal-exit@3.0.7: {}
signal-exit@4.1.0: {} signal-exit@4.1.0: {}
@@ -12527,6 +12723,8 @@ snapshots:
dependencies: dependencies:
escape-string-regexp: 2.0.0 escape-string-regexp: 2.0.0
stackback@0.0.2: {}
statuses@2.0.1: {} statuses@2.0.1: {}
std-env@3.9.0: {} std-env@3.9.0: {}
@@ -12645,6 +12843,8 @@ snapshots:
timm@1.7.1: {} timm@1.7.1: {}
tinybench@2.9.0: {}
tinycolor2@1.6.0: {} tinycolor2@1.6.0: {}
tinyexec@0.3.2: {} tinyexec@0.3.2: {}
@@ -12661,6 +12861,12 @@ snapshots:
fdir: 6.5.0(picomatch@4.0.3) fdir: 6.5.0(picomatch@4.0.3)
picomatch: 4.0.3 picomatch: 4.0.3
tinypool@1.1.1: {}
tinyrainbow@2.0.0: {}
tinyspy@4.0.4: {}
tmpl@1.0.5: {} tmpl@1.0.5: {}
to-regex-range@5.0.1: to-regex-range@5.0.1:
@@ -12946,6 +13152,23 @@ snapshots:
vary@1.1.2: {} vary@1.1.2: {}
vite-node@3.2.4(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1):
dependencies:
cac: 6.7.14
debug: 4.4.3
es-module-lexer: 1.7.0
pathe: 2.0.3
vite: 5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)
transitivePeerDependencies:
- '@types/node'
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
vite-plugin-restart@1.0.0(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)): vite-plugin-restart@1.0.0(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)):
dependencies: dependencies:
micromatch: 4.0.8 micromatch: 4.0.8
@@ -12962,6 +13185,45 @@ snapshots:
sass: 1.77.8 sass: 1.77.8
terser: 5.43.1 terser: 5.43.1
vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.11)(jsdom@16.7.0)(sass@1.77.8)(terser@5.43.1):
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.4
'@vitest/mocker': 3.2.4(vite@5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1))
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
'@vitest/spy': 3.2.4
'@vitest/utils': 3.2.4
chai: 5.3.3
debug: 4.4.3
expect-type: 1.3.0
magic-string: 0.30.19
pathe: 2.0.3
picomatch: 4.0.3
std-env: 3.9.0
tinybench: 2.9.0
tinyexec: 0.3.2
tinyglobby: 0.2.15
tinypool: 1.1.1
tinyrainbow: 2.0.0
vite: 5.2.8(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)
vite-node: 3.2.4(@types/node@20.19.11)(sass@1.77.8)(terser@5.43.1)
why-is-node-running: 2.3.0
optionalDependencies:
'@types/debug': 4.1.12
'@types/node': 20.19.11
jsdom: 16.7.0
transitivePeerDependencies:
- less
- lightningcss
- msw
- sass
- stylus
- sugarss
- supports-color
- terser
vscode-uri@3.1.0: {} vscode-uri@3.1.0: {}
vue-demi@0.14.10(vue@3.4.21(typescript@5.8.3)): vue-demi@0.14.10(vue@3.4.21(typescript@5.8.3)):
@@ -13047,6 +13309,11 @@ snapshots:
dependencies: dependencies:
isexe: 2.0.0 isexe: 2.0.0
why-is-node-running@2.3.0:
dependencies:
siginfo: 2.0.0
stackback: 0.0.2
word-wrap@1.2.5: {} word-wrap@1.2.5: {}
wot-design-uni@1.13.0(vue@3.4.21(typescript@5.8.3)): wot-design-uni@1.13.0(vue@3.4.21(typescript@5.8.3)):

View File

@@ -0,0 +1,82 @@
import { http } from '@/http/http'
/** 审批记录 */
export interface ApprovalRecord {
id?: number
processInstanceId: string
bizId: string
bizTableName: string
applicant: string
applicantName?: string
approver: string
approverName?: string
assigner?: string
assignerName?: string
assignReason?: string
approvalTime?: string
comment?: string
approvalResult: number
flowType: number
parentApprovalId?: number
approvalLevel: number
processStatus: number
sort?: number
createTime?: string
updateTime?: string
}
/** 提交审批参数 */
export interface ApprovalSubmitVO {
bizId: string
bizTableName: string
nextApprover: string
remark?: string
}
/** 处理审批参数 */
export interface ApprovalProcessVO {
id: number
approvalResult: number
comment?: string
nextApprover?: string
assignReason?: string
}
/** 审批结果枚举 */
export const APPROVAL_RESULT = {
PENDING: 0, // 待审批
APPROVED: 1, // 通过
REJECTED: 2, // 拒绝
TRANSFERRED: 3, // 转办
}
/** 审批结果选项 */
export const APPROVAL_RESULT_OPTIONS = [
{ label: '通过', value: APPROVAL_RESULT.APPROVED },
{ label: '拒绝', value: APPROVAL_RESULT.REJECTED },
]
/** 提交审批 */
export function submitApproval(data: ApprovalSubmitVO) {
return http.post<number>('/erp/approval-record/submit', data)
}
/** 处理审批 */
export function processApproval(data: ApprovalProcessVO) {
return http.post<boolean>('/erp/approval-record/process', data)
}
/** 获取业务单据的审批记录列表 */
export function getApprovalRecordListByBiz(bizId: string, bizTableName: string) {
return http.get<ApprovalRecord[]>('/erp/approval-record/list-by-biz', { bizId, bizTableName })
}
/** 获取用户的待办审批列表 */
export function getPendingApprovalList(approver: string) {
return http.get<ApprovalRecord[]>('/erp/approval-record/pending-list', { approver })
}
/** 终止审批流程 */
export function terminateApproval(bizId: string, bizTableName: string) {
return http.post<boolean>('/erp/approval-record/terminate', { bizId, bizTableName })
}

View File

@@ -0,0 +1,12 @@
import { http } from '@/http/http'
/** 客户精简信息 */
export interface CustomerSimple {
id: number
name: string
}
/** 获取客户精简列表 */
export function getCustomerSimpleList() {
return http.get<CustomerSimple[]>('/erp/customer/simple-list')
}

View File

@@ -0,0 +1,14 @@
import { http } from '@/http/http'
/** 按库位码查询的结果 */
export interface LocationByCodeVO {
warehouseId: number
warehouseName: string
locationCode: string
enableLocation?: boolean
}
/** 按库位码查询库位信息 */
export function getLocationByCode(locationCode: string) {
return http.get<LocationByCodeVO>('/erp/location/get-by-code', { locationCode })
}

View File

@@ -16,7 +16,23 @@ export interface ProductSimple {
weight?: number weight?: number
} }
/** 按条码查询的产品信息 */
export interface ProductByBarCode {
id: number
name: string
barCode?: string
unitId?: number
unitName?: string
standard?: string
minPrice?: number
}
/** 获取产品精简列表 */ /** 获取产品精简列表 */
export function getProductSimpleList() { export function getProductSimpleList() {
return http.get<ProductSimple[]>('/erp/product/simple-list') return http.get<ProductSimple[]>('/erp/product/simple-list')
} }
/** 按条码查询启用中的产品 */
export function getProductByBarCode(barCode: string) {
return http.get<ProductByBarCode>('/erp/product/get-by-barcode', { barCode })
}

View File

@@ -0,0 +1,42 @@
import { http } from '@/http/http'
/** 采购入库扫码记录 */
export interface PurchaseInScanRecord {
id?: number
purchaseInId: number
productId?: number
productName?: string
productSpec?: string
productBarCode?: string
productUnit?: string
warehouseId?: number
warehouseName?: string
locationCode?: string
batchNo?: string
scanCount?: number
scanTime?: string
operatorId?: number
operatorName?: string
remark?: string
createTime?: string
}
/** 创建扫码记录 */
export function createPurchaseInScanRecord(data: PurchaseInScanRecord) {
return http.post<number>('/erp/purchase-in-scan-record/create', data)
}
/** 批量创建扫码记录 */
export function createPurchaseInScanRecordBatch(data: PurchaseInScanRecord[]) {
return http.post<number>('/erp/purchase-in-scan-record/create-batch', data)
}
/** 删除扫码记录 */
export function deletePurchaseInScanRecord(id: number) {
return http.delete<boolean>(`/erp/purchase-in-scan-record/delete?id=${id}`)
}
/** 获取入库单的所有扫码记录 */
export function getPurchaseInScanRecordList(purchaseInId: number) {
return http.get<PurchaseInScanRecord[]>(`/erp/purchase-in-scan-record/list?purchaseInId=${purchaseInId}`)
}

View File

@@ -13,6 +13,8 @@ export interface PurchaseInItem {
remark?: string remark?: string
warehouseId?: number warehouseId?: number
warehouseName?: string warehouseName?: string
batchNo?: string
locationCode?: string
productName?: string productName?: string
productBarCode?: string productBarCode?: string
productUnitName?: string productUnitName?: string
@@ -20,6 +22,7 @@ export interface PurchaseInItem {
productCategoryName?: string productCategoryName?: string
stockCount?: number stockCount?: number
totalCount?: number totalCount?: number
inCount?: number
totalPrice?: number totalPrice?: number
totalProductPrice?: number totalProductPrice?: number
orderItemId?: number orderItemId?: number
@@ -55,6 +58,7 @@ export interface PurchaseIn {
isQualified?: boolean isQualified?: boolean
returnType?: string | null returnType?: string | null
returnRemark?: string returnRemark?: string
hasApprovalRecords?: boolean
} }
/** 审核表单数据 */ /** 审核表单数据 */

View File

@@ -0,0 +1,42 @@
import { http } from '@/http/http'
/** 销售出库扫码记录 */
export interface SaleOutScanRecord {
id?: number
saleOutId: number
productId?: number
productName?: string
productSpec?: string
productBarCode?: string
productUnit?: string
warehouseId?: number
warehouseName?: string
locationCode?: string
batchNo?: string
scanCount?: number
scanTime?: string
operatorId?: number
operatorName?: string
remark?: string
createTime?: string
}
/** 创建扫码记录 */
export function createSaleOutScanRecord(data: SaleOutScanRecord) {
return http.post<number>('/erp/sale-out-scan-record/create', data)
}
/** 批量创建扫码记录 */
export function createSaleOutScanRecordBatch(data: SaleOutScanRecord[]) {
return http.post<number[]>('/erp/sale-out-scan-record/create-batch', data)
}
/** 删除扫码记录 */
export function deleteSaleOutScanRecord(id: number) {
return http.delete<boolean>(`/erp/sale-out-scan-record/delete?id=${id}`)
}
/** 获取出库单的所有扫码记录 */
export function getSaleOutScanRecordList(saleOutId: number) {
return http.get<SaleOutScanRecord[]>(`/erp/sale-out-scan-record/list?saleOutId=${saleOutId}`)
}

View File

@@ -0,0 +1,91 @@
import type { PageParam, PageResult } from '@/http/types'
import { http } from '@/http/http'
/** 销售出库项 */
export interface SaleOutItem {
id?: number
outId?: number
orderItemId?: number
productId?: number
productName?: string
productBarCode?: string
productSpec?: string
productUnitName?: string
warehouseId?: number
warehouseName?: string
locationCode?: string
batchNo?: string
count?: number
productPrice?: number
taxPercent?: number
taxPrice?: number
totalPrice?: number
remark?: string
productUnitId?: number
stockUnitPrice?: number
stockValue?: number
grossProfit?: number
}
/** 销售出库信息 */
export interface SaleOut {
id?: number
no?: string
status?: number
customerId?: number
customerName?: string
accountId?: number
accountName?: string
saleUserId?: number
saleUserName?: string
outTime?: string
orderId?: number
orderNo?: string
deliveryNoticeId?: number
deliveryNoticeNo?: string
totalCount?: number
totalPrice?: number
receiptPrice?: number
totalProductPrice?: number
totalTaxPrice?: number
discountPercent?: number
discountPrice?: number
otherPrice?: number
fileUrl?: string
remark?: string
creator?: string
creatorName?: string
createTime?: string
items?: SaleOutItem[]
productNames?: string
}
/** 获取销售出库分页列表 */
export function getSaleOutPage(params: PageParam) {
return http.get<PageResult<SaleOut>>('/erp/sale-out/page', params)
}
/** 获取销售出库详情 */
export function getSaleOut(id: number) {
return http.get<SaleOut>(`/erp/sale-out/get?id=${id}`)
}
/** 创建销售出库 */
export function createSaleOut(data: SaleOut) {
return http.post<number>('/erp/sale-out/create', data)
}
/** 更新销售出库 */
export function updateSaleOut(data: SaleOut) {
return http.put<boolean>('/erp/sale-out/update', data)
}
/** 更新销售出库状态 */
export function updateSaleOutStatus(id: number, status: number) {
return http.put<boolean>(`/erp/sale-out/update-status?id=${id}&status=${status}`)
}
/** 删除销售出库 */
export function deleteSaleOut(ids: number[]) {
return http.delete<boolean>(`/erp/sale-out/delete?ids=${ids.join(',')}`)
}

View File

@@ -7,9 +7,11 @@ export interface StockInItem {
stockInId?: number stockInId?: number
warehouseId?: number warehouseId?: number
warehouseName?: string warehouseName?: string
locationCode?: string
productId?: number productId?: number
productName?: string productName?: string
productUnitName?: string productUnitName?: string
batchNo?: string
count?: number count?: number
productPrice?: number productPrice?: number
totalPrice?: number totalPrice?: number

View File

@@ -7,9 +7,11 @@ export interface StockOutItem {
stockOutId?: number stockOutId?: number
warehouseId?: number warehouseId?: number
warehouseName?: string warehouseName?: string
locationCode?: string
productId?: number productId?: number
productName?: string productName?: string
productUnitName?: string productUnitName?: string
batchNo?: string
count?: number count?: number
productPrice?: number productPrice?: number
totalPrice?: number totalPrice?: number

View File

@@ -13,6 +13,9 @@ export interface Warehouse {
truckagePrice?: number truckagePrice?: number
status?: number status?: number
defaultStatus?: boolean defaultStatus?: boolean
enableLocation?: boolean
roomNoMax?: number
locationCapacity?: number
createTime?: number createTime?: number
} }

View File

@@ -0,0 +1,171 @@
<template>
<view class="item-list">
<view v-if="items.length === 0" class="item-list__empty">
暂无扫码明细
</view>
<view v-for="(item, index) in items" :key="`${item.warehouseId}-${item.productId}-${index}`" class="item-card">
<view class="item-card__header">
<text class="item-card__name">{{ item.productName }}</text>
<text class="item-card__remove" @tap="emit('remove', index)">{{ removeText }}</text>
</view>
<view class="item-card__meta">
<text>仓库{{ item.warehouseName || '-' }}</text>
<text>条码{{ item.productBarCode || '-' }}</text>
</view>
<view class="item-card__meta">
<text>规格{{ item.productSpec || '-' }}</text>
<text>单位{{ item.productUnitName || '-' }}</text>
</view>
<view class="item-card__meta">
<text>单价{{ formatNumber(item.productPrice) }}</text>
<text v-if="showStock">库存{{ formatNumber(item.stockCount) }}</text>
</view>
<view v-if="item.targetCount !== undefined" class="item-card__meta">
<text>目标{{ formatNumber(item.targetCount) }}</text>
</view>
<view v-if="item.remainCount !== undefined || item.batchNo || item.locationCode" class="item-card__meta">
<text v-if="item.remainCount !== undefined">剩余{{ formatNumber(item.remainCount) }}</text>
<text>批次{{ item.batchNo || '-' }}</text>
<text>库位{{ item.locationCode || '-' }}</text>
</view>
<view class="item-card__footer">
<view class="counter">
<text class="counter__button" @tap="emit('decrease', index)">-</text>
<text class="counter__value">{{ formatNumber(item.count) }}</text>
<text class="counter__button" @tap="emit('increase', index)">+</text>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
export interface ItemCardValue {
warehouseId: number
warehouseName?: string
productId: number
productName: string
productBarCode?: string
productSpec?: string
productUnitName?: string
productPrice?: number
stockCount?: number
batchNo?: string
locationCode?: string
remainCount?: number
targetCount?: number
count: number
}
withDefaults(
defineProps<{
items: ItemCardValue[]
showStock?: boolean
removeText?: string
}>(),
{
showStock: false,
removeText: '删除',
},
)
const emit = defineEmits<{
(event: 'increase', index: number): void
(event: 'decrease', index: number): void
(event: 'remove', index: number): void
}>()
/**
* 功能说明:格式化数值展示,避免 `undefined` 直接透出到页面。
* 适用场景:数量、库存、单价展示。
* @param value 原始数值
* @return 格式化后的字符串
* 注意事项:扫码页优先保证可读性,这里只保留最多 4 位小数,不做复杂金额格式化。
*/
function formatNumber(value?: number) {
if (value === undefined || value === null) {
return '-'
}
return Number(value).toFixed(Number.isInteger(Number(value)) ? 0 : 4)
}
</script>
<style lang="scss" scoped>
.item-list__empty {
padding: 28rpx;
border-radius: 16rpx;
background: #fff;
color: #86909c;
text-align: center;
}
.item-card {
margin-bottom: 20rpx;
padding: 24rpx;
border-radius: 16rpx;
background: #fff;
&__header,
&__meta,
&__footer {
display: flex;
align-items: center;
justify-content: space-between;
}
&__header {
margin-bottom: 12rpx;
}
&__name {
font-size: 30rpx;
font-weight: 600;
}
&__remove {
color: #f53f3f;
font-size: 24rpx;
}
&__meta {
margin-top: 8rpx;
color: #4e5969;
font-size: 24rpx;
gap: 16rpx;
flex-wrap: wrap;
}
&__footer {
margin-top: 20rpx;
}
}
.counter {
display: flex;
align-items: center;
gap: 24rpx;
&__button,
&__value {
display: inline-flex;
align-items: center;
justify-content: center;
width: 64rpx;
height: 64rpx;
border-radius: 12rpx;
background: #f2f3f5;
}
&__button {
font-size: 36rpx;
color: #1d2129;
}
&__value {
min-width: 88rpx;
background: #fff7e8;
color: #ad6800;
}
}
</style>

View File

@@ -0,0 +1,130 @@
<template>
<view class="scan-input">
<input
class="scan-input__field"
:value="modelValue"
:placeholder="placeholder"
:focus="autoFocus"
:disabled="disabled"
confirm-type="done"
@input="handleInput"
@confirm="handleSubmit"
>
<!-- 通过属性控制确认按钮是否渲染兼容不同交互模式下的输入提交流程 -->
<button
v-if="showConfirmButton"
class="scan-input__button scan-input__button--primary"
size="mini"
:disabled="disabled || loading"
@tap="handleSubmit"
>
{{ loading ? '处理中' : '确认' }}
</button>
<button class="scan-input__button scan-input__button--camera" size="mini" :disabled="disabled || loading" @tap="handleCameraScan">
{{ cameraText }}
</button>
</view>
</template>
<script setup lang="ts">
const props = withDefaults(
defineProps<{
modelValue: string
placeholder?: string
disabled?: boolean
loading?: boolean
autoFocus?: boolean
showConfirmButton?: boolean
cameraText?: string
}>(),
{
placeholder: '请扫描条码',
disabled: false,
loading: false,
autoFocus: true,
showConfirmButton: true,
cameraText: '相机',
},
)
const emit = defineEmits<{
(event: 'update:modelValue', value: string): void
(event: 'submit'): void
(event: 'camera-scan'): void
}>()
/**
* 功能说明:同步输入框内容到父组件。
* 适用场景:扫码枪键盘模拟输入、手工补录条码。
* @param event 输入事件
* @return 无
* 注意事项:扫码枪的原始值最终仍由父组件统一清洗,这里只做输入透传。
*/
function handleInput(event: Record<string, any>) {
emit('update:modelValue', event.detail.value || '')
}
/**
* 功能说明:把确认动作抛给父组件处理。
* 适用场景:扫码枪回车提交、用户手工点击确认按钮。
* @return 无
* 注意事项:父组件会负责防重入和业务校验,这里不重复做业务判断。
*/
function handleSubmit() {
if (props.disabled || props.loading) {
return
}
emit('submit')
}
/**
* 功能说明:触发父组件进入相机扫码流程。
* 适用场景:普通手机没有外接扫码枪时,通过摄像头扫描条码。
* @return 无
* 注意事项:组件层不直接执行业务逻辑,只负责抛出统一事件,保证扫码入口一致。
*/
function handleCameraScan() {
if (props.disabled || props.loading) {
return
}
emit('camera-scan')
}
</script>
<style lang="scss" scoped>
.scan-input {
display: flex;
align-items: center;
gap: 16rpx;
&__field {
flex: 1;
height: 84rpx;
padding: 0 24rpx;
border: 2rpx solid #d0d7de;
border-radius: 12rpx;
background: #fff;
}
&__button {
min-width: 128rpx;
height: 84rpx;
padding: 0 24rpx;
line-height: 84rpx;
border-radius: 12rpx;
box-sizing: border-box;
&--primary {
background: #1677ff;
color: #fff;
}
&--camera {
background: #e8f3ff;
color: #1677ff;
}
}
}
</style>

View File

@@ -0,0 +1,49 @@
<template>
<view class="submit-bar">
<button class="submit-bar__ghost" @tap="emit('secondary')">
{{ secondaryText }}
</button>
<button class="submit-bar__primary" :loading="loading" @tap="emit('submit')">
{{ submitText }}
</button>
</view>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
loading?: boolean
submitText?: string
secondaryText?: string
}>(),
{
loading: false,
submitText: '提交单据',
secondaryText: '清空明细',
},
)
const emit = defineEmits<{
(event: 'submit'): void
(event: 'secondary'): void
}>()
</script>
<style lang="scss" scoped>
.submit-bar {
position: sticky;
bottom: 0;
display: flex;
gap: 16rpx;
padding: 20rpx 0 calc(20rpx + env(safe-area-inset-bottom));
background: #f4f6f8;
&__ghost,
&__primary {
flex: 1;
height: 88rpx;
line-height: 88rpx;
border-radius: 16rpx;
}
}
</style>

136
src/manifest.json Normal file
View File

@@ -0,0 +1,136 @@
{
"name": "亚为mom小程序",
"appid": "__UNI__2EB12DE",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
"app-plus": {
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
"modules": {},
"distribute": {
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
],
"minSdkVersion": 21,
"targetSdkVersion": 30,
"abiFilters": [
"armeabi-v7a",
"arm64-v8a"
]
},
"ios": {},
"sdkConfigs": {},
"icons": {
"android": {
"hdpi": "src/static/app/icons/72x72.png",
"xhdpi": "src/static/app/icons/96x96.png",
"xxhdpi": "src/static/app/icons/144x144.png",
"xxxhdpi": "src/static/app/icons/192x192.png"
},
"ios": {
"appstore": "src/static/app/icons/1024x1024.png",
"ipad": {
"app": "src/static/app/icons/76x76.png",
"app@2x": "src/static/app/icons/152x152.png",
"notification": "src/static/app/icons/20x20.png",
"notification@2x": "src/static/app/icons/40x40.png",
"proapp@2x": "src/static/app/icons/167x167.png",
"settings": "src/static/app/icons/29x29.png",
"settings@2x": "src/static/app/icons/58x58.png",
"spotlight": "src/static/app/icons/40x40.png",
"spotlight@2x": "src/static/app/icons/80x80.png"
},
"iphone": {
"app@2x": "src/static/app/icons/120x120.png",
"app@3x": "src/static/app/icons/180x180.png",
"notification@2x": "src/static/app/icons/40x40.png",
"notification@3x": "src/static/app/icons/60x60.png",
"settings@2x": "src/static/app/icons/58x58.png",
"settings@3x": "src/static/app/icons/87x87.png",
"spotlight@2x": "src/static/app/icons/80x80.png",
"spotlight@3x": "src/static/app/icons/120x120.png"
}
}
}
},
"compatible": {
"ignoreVersion": true
}
},
"app-harmony": {
"distribute": {}
},
"mp-harmony": {
"distribute": {}
},
"quickapp": {},
"mp-weixin": {
"appid": "wx1a832d51073d3a35",
"setting": {
"urlCheck": false,
"es6": true,
"minified": true
},
"usingComponents": true,
"optimization": {
"subPackages": true
},
"mergeVirtualHostAttributes": true
},
"mp-alipay": {
"usingComponents": true,
"styleIsolation": "shared",
"optimization": {
"subPackages": true
},
"compileOptions": {
"globalObjectMode": "enable",
"transpile": {
"script": {
"ignore": [
"node_modules/**"
]
}
}
}
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"vueVersion": "3",
"h5": {
"router": {
"base": "/"
}
}
}

View File

@@ -74,9 +74,17 @@
<text class="text-28rpx text-[#333] font-semibold">{{ item.productName || '-' }}</text> <text class="text-28rpx text-[#333] font-semibold">{{ item.productName || '-' }}</text>
<text v-if="item.productBarCode" class="ml-12rpx text-22rpx text-[#999]">{{ item.productBarCode }}</text> <text v-if="item.productBarCode" class="ml-12rpx text-22rpx text-[#999]">{{ item.productBarCode }}</text>
</view> </view>
<view class="flex items-center">
<text v-if="item.warehouseName" class="text-24rpx text-[#1890ff]">{{ item.warehouseName }}</text> <text v-if="item.warehouseName" class="text-24rpx text-[#1890ff]">{{ item.warehouseName }}</text>
<text v-if="item.locationCode" class="ml-8rpx text-22rpx text-[#52c41a]">[{{ item.locationCode }}]</text>
</view>
</view> </view>
<view class="p-24rpx"> <view class="p-24rpx">
<!-- 批次号 -->
<view v-if="item.batchNo" class="mb-12rpx flex items-center text-26rpx text-[#666]">
<text class="mr-8rpx text-[#999]">批次号</text>
<text class="text-[#e6a23c]">{{ item.batchNo }}</text>
</view>
<!-- 产品规格 --> <!-- 产品规格 -->
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]"> <view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
<text class="mr-8rpx text-[#999]">规格</text> <text class="mr-8rpx text-[#999]">规格</text>
@@ -170,15 +178,19 @@
<!-- 审核弹窗 --> <!-- 审核弹窗 -->
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false"> <wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false">
<view class="p-32rpx"> <view class="p-32rpx">
<view class="text-32rpx text-[#333] font-semibold mb-32rpx text-center"> <view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
采购入库审核 采购入库审核
</view> </view>
<view class="mb-24rpx"> <view class="mb-24rpx">
<view class="text-26rpx text-[#666] mb-12rpx">是否合格</view> <view class="mb-12rpx text-26rpx text-[#666]">
是否合格
</view>
<wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" /> <wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <view v-if="!auditForm.isQualified" class="mb-24rpx">
<view class="text-26rpx text-[#666] mb-12rpx">返回方式</view> <view class="mb-12rpx text-26rpx text-[#666]">
返回方式
</view>
<wd-radio-group v-model="auditForm.returnType" shape="button"> <wd-radio-group v-model="auditForm.returnType" shape="button">
<wd-radio <wd-radio
v-for="opt in RETURN_TYPE_OPTIONS" v-for="opt in RETURN_TYPE_OPTIONS"
@@ -190,14 +202,16 @@
</wd-radio-group> </wd-radio-group>
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <view v-if="!auditForm.isQualified" class="mb-24rpx">
<view class="text-26rpx text-[#666] mb-12rpx">返回备注</view> <view class="mb-12rpx text-26rpx text-[#666]">
返回备注
</view>
<wd-textarea <wd-textarea
v-model="auditForm.returnRemark" v-model="auditForm.returnRemark"
placeholder="请输入返回方式备注" placeholder="请输入返回方式备注"
:maxlength="200" :maxlength="200"
/> />
</view> </view>
<view class="flex gap-24rpx mt-32rpx"> <view class="mt-32rpx flex gap-24rpx">
<wd-button class="flex-1" plain @click="auditVisible = false"> <wd-button class="flex-1" plain @click="auditVisible = false">
取消 取消
</wd-button> </wd-button>
@@ -246,23 +260,30 @@ const auditForm = reactive({
/** 获取状态文本 */ /** 获取状态文本 */
function getStatusText(status?: number, isQualified?: boolean) { function getStatusText(status?: number, isQualified?: boolean) {
if (status === 10) return '未审核' if (status === 10)
if (status === 20) return isQualified ? '审核' : '不合格' return '审核'
if (status === 30) return '不合格' if (status === 20)
return isQualified ? '已审核' : '不合格'
if (status === 30)
return '不合格'
return '未知' return '未知'
} }
/** 获取状态样式 */ /** 获取状态样式 */
function getStatusClass(status?: number, isQualified?: boolean) { function getStatusClass(status?: number, isQualified?: boolean) {
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]' if (status === 10)
if (status === 20) return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]' return 'bg-[#fff7e6] text-[#fa8c16]'
if (status === 30) return 'bg-[#fff1f0] text-[#f5222d]' if (status === 20)
return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'
if (status === 30)
return 'bg-[#fff1f0] text-[#f5222d]'
return 'bg-[#f5f5f5] text-[#999]' return 'bg-[#f5f5f5] text-[#999]'
} }
/** 获取返回方式标签 */ /** 获取返回方式标签 */
function getReturnTypeLabel(value?: string | null) { function getReturnTypeLabel(value?: string | null) {
if (!value) return '-' if (!value)
return '-'
const option = RETURN_TYPE_OPTIONS.find(opt => opt.value === value) const option = RETURN_TYPE_OPTIONS.find(opt => opt.value === value)
return option ? option.label : value return option ? option.label : value
} }
@@ -310,7 +331,8 @@ function handleQualifiedChange(val: boolean) {
/** 提交审核 */ /** 提交审核 */
async function submitAudit() { async function submitAudit() {
if (!props.id) return if (!props.id)
return
if (!auditForm.isQualified && !auditForm.returnType) { if (!auditForm.isQualified && !auditForm.returnType) {
toast.warning('请选择返回方式') toast.warning('请选择返回方式')
return return

View File

@@ -26,7 +26,7 @@
placeholder="请选择入库时间" placeholder="请选择入库时间"
/> />
</wd-cell> </wd-cell>
<wd-cell title="关联订单" title-width="180rpx" center is-link @click="openOrderSelect"> <wd-cell title="关联订单" title-width="180rpx" is-link center @click="openOrderSelect">
<text v-if="formData.orderNo" class="text-[#1890ff]">{{ formData.orderNo }}</text> <text v-if="formData.orderNo" class="text-[#1890ff]">{{ formData.orderNo }}</text>
<text v-else class="text-[#999]">点击选择采购订单</text> <text v-else class="text-[#999]">点击选择采购订单</text>
</wd-cell> </wd-cell>
@@ -97,6 +97,18 @@
> >
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-12rpx"> <view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-12rpx">
<text class="text-28rpx text-[#333] font-semibold">产品 #{{ index + 1 }} {{ item.productName || '' }}</text> <text class="text-28rpx text-[#333] font-semibold">产品 #{{ index + 1 }} {{ item.productName || '' }}</text>
<view class="flex gap-12rpx">
<wd-button
v-if="isLocationEnabled(item.warehouseId)"
size="small" type="primary" plain @click="handleRecommendLocation(item, index)"
>
推荐货位
</wd-button>
<wd-button
size="small" type="warning" plain @click="handleSplit(index)"
>
拆分
</wd-button>
<wd-button <wd-button
v-if="formData.items && formData.items.length > 1" v-if="formData.items && formData.items.length > 1"
size="small" type="error" plain @click="handleRemoveItem(index)" size="small" type="error" plain @click="handleRemoveItem(index)"
@@ -104,6 +116,7 @@
删除 删除
</wd-button> </wd-button>
</view> </view>
</view>
<view class="p-24rpx"> <view class="p-24rpx">
<!-- 仓库选择 --> <!-- 仓库选择 -->
<view class="mb-16rpx"> <view class="mb-16rpx">
@@ -115,6 +128,24 @@
@confirm="(e: any) => onWarehouseConfirm(e, index)" @confirm="(e: any) => onWarehouseConfirm(e, index)"
/> />
</view> </view>
<!-- 库位编码 -->
<view v-if="isLocationEnabled(item.warehouseId)" class="mb-16rpx">
<text class="mb-8rpx block text-24rpx text-[#999]">库位编码</text>
<wd-input
v-model="item.locationCode"
placeholder="库房号-区域-货位号,如 1-A-01"
clearable
/>
</view>
<!-- 批次号 -->
<view class="mb-16rpx">
<text class="mb-8rpx block text-24rpx text-[#999]">批次号</text>
<wd-input
v-model="item.batchNo"
placeholder="请输入批次号"
clearable
/>
</view>
<!-- 自动填充的产品信息只读 --> <!-- 自动填充的产品信息只读 -->
<view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx"> <view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
<view class="mb-8rpx flex justify-between text-24rpx"> <view class="mb-8rpx flex justify-between text-24rpx">
@@ -232,7 +263,9 @@
> >
<view class="p-24rpx"> <view class="p-24rpx">
<view class="mb-12rpx flex items-center justify-between"> <view class="mb-12rpx flex items-center justify-between">
<view class="text-30rpx text-[#333] font-semibold">{{ item.no }}</view> <view class="text-30rpx text-[#333] font-semibold">
{{ item.no }}
</view>
<wd-icon v-if="selectedOrderId === item.id" name="check" color="#1890ff" size="40rpx" /> <wd-icon v-if="selectedOrderId === item.id" name="check" color="#1890ff" size="40rpx" />
</view> </view>
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
@@ -241,20 +274,32 @@
</view> </view>
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">产品</text> <text class="text-[#999]">产品</text>
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text> <text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
</view> </view>
<view class="flex items-center justify-around mt-12rpx pt-12rpx border-t border-[#f0f0f0]"> <view class="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-12rpx">
<view class="text-center"> <view class="text-center">
<view class="text-28rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view> <view class="text-28rpx text-[#333] font-semibold">
<view class="text-22rpx text-[#999]">总数量</view> {{ item.totalCount || 0 }}
</view>
<view class="text-22rpx text-[#999]">
总数量
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-28rpx text-[#52c41a] font-semibold">{{ item.inCount || 0 }}</view> <view class="text-28rpx text-[#52c41a] font-semibold">
<view class="text-22rpx text-[#999]">已入库</view> {{ item.inCount || 0 }}
</view>
<view class="text-22rpx text-[#999]">
已入库
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-28rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view> <view class="text-28rpx text-[#e6a23c] font-semibold">
<view class="text-22rpx text-[#999]">含税金额</view> ¥{{ item.totalPrice || 0 }}
</view>
<view class="text-22rpx text-[#999]">
含税金额
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -301,6 +346,9 @@ interface WarehouseSimple {
id: number id: number
name: string name: string
defaultStatus?: boolean defaultStatus?: boolean
enableLocation?: boolean
roomNoMax?: number
locationCapacity?: number
} }
/** 供应商简单信息 */ /** 供应商简单信息 */
@@ -328,7 +376,7 @@ const formData = ref<PurchaseIn>({
no: undefined, no: undefined,
supplierId: undefined, supplierId: undefined,
accountId: undefined, accountId: undefined,
inTime: undefined, inTime: new Date().getTime(),
orderId: undefined, orderId: undefined,
orderNo: undefined, orderNo: undefined,
discountPercent: 0, discountPercent: 0,
@@ -370,9 +418,19 @@ const warehouseColumns = computed(() => [
warehouseList.value.map(w => ({ value: w.id, label: w.name })), warehouseList.value.map(w => ({ value: w.id, label: w.name })),
]) ])
/** 判断仓库是否启用库位管理 */
function isLocationEnabled(warehouseId?: number): boolean {
if (!warehouseId)
return false
const warehouse = warehouseList.value.find(w => w.id === warehouseId)
console.log('[库位推荐] warehouseId:', warehouseId, 'warehouse:', warehouse, 'enableLocation:', warehouse?.enableLocation)
return warehouse?.enableLocation === true
}
/** 获取供应商名称 */ /** 获取供应商名称 */
function getSupplierName() { function getSupplierName() {
if (!formData.value.supplierId) return '' if (!formData.value.supplierId)
return ''
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId) const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
return supplier?.name || formData.value.supplierName || '' return supplier?.name || formData.value.supplierName || ''
} }
@@ -383,12 +441,21 @@ function onAccountConfirm({ value }: any) {
} }
/** 仓库选择回调 */ /** 仓库选择回调 */
function onWarehouseConfirm({ value }: any, index: number) { function onWarehouseConfirm(e: any, index: number) {
console.log('[仓库选择] 完整事件:', e, 'index:', index)
if (formData.value.items && formData.value.items[index]) { if (formData.value.items && formData.value.items[index]) {
formData.value.items[index].warehouseId = value?.[0] // wd-picker 的 confirm 事件返回 { value, selectedItems }
const warehouse = warehouseList.value.find(w => w.id === value?.[0]) const warehouseId = e?.value?.[0] ?? e?.selectedItems?.[0]?.value ?? formData.value.items[index].warehouseId
console.log('[仓库选择] 解析后 warehouseId:', warehouseId)
formData.value.items[index].warehouseId = warehouseId
const warehouse = warehouseList.value.find(w => w.id === warehouseId)
console.log('[仓库选择] 找到仓库:', warehouse)
if (warehouse) { if (warehouse) {
formData.value.items[index].warehouseName = warehouse.name formData.value.items[index].warehouseName = warehouse.name
// 如果仓库未启用库位管理,清空库位编码
if (!warehouse.enableLocation) {
formData.value.items[index].locationCode = undefined
}
} }
} }
} }
@@ -407,7 +474,8 @@ function calcTotalPrice(item: PurchaseInItem) {
watch( watch(
() => formData.value, () => formData.value,
(val) => { (val) => {
if (!val || !val.items) return if (!val || !val.items)
return
// 计算每个明细的金额 // 计算每个明细的金额
val.items.forEach((item) => { val.items.forEach((item) => {
if (item.productPrice && item.count) { if (item.productPrice && item.count) {
@@ -437,6 +505,7 @@ async function loadDropdownData() {
supplierList.value = suppliers || [] supplierList.value = suppliers || []
accountList.value = accounts || [] accountList.value = accounts || []
warehouseList.value = warehouses || [] warehouseList.value = warehouses || []
console.log('[仓库数据] warehouseList:', warehouseList.value)
// 设置默认账户 // 设置默认账户
const defaultAccount = accountList.value.find(a => a.defaultStatus) const defaultAccount = accountList.value.find(a => a.defaultStatus)
if (defaultAccount && !formData.value.accountId) { if (defaultAccount && !formData.value.accountId) {
@@ -467,6 +536,135 @@ function handleRemoveItem(index: number) {
}) })
} }
/** 拆分明细行:复制当前产品行为一条新行,用于“同一产品分多个库位”录入 */
function handleSplit(index: number) {
const sourceItem = formData.value.items?.[index]
if (!sourceItem)
return
const newItem: PurchaseInItem = {
...sourceItem,
id: undefined,
locationCode: sourceItem.locationCode,
batchNo: sourceItem.batchNo,
count: sourceItem.count,
totalProductPrice: undefined,
taxPrice: undefined,
totalPrice: undefined,
remark: undefined,
}
formData.value.items?.splice(index + 1, 0, newItem)
toast.success('已拆分,请调整数量和库位')
}
/** 推荐货位 */
async function handleRecommendLocation(item: PurchaseInItem, index: number) {
console.log('[推荐货位] 开始, item:', item, 'index:', index)
if (!item.warehouseId) {
toast.warning('请先选择仓库')
return
}
if (!item.productId) {
toast.warning('请先选择产品')
return
}
if (!item.count || Number(item.count) <= 0) {
toast.warning('请先填写有效数量')
return
}
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
console.log('[推荐货位] 仓库:', warehouse, 'locationCapacity:', warehouse?.locationCapacity)
const locationCapacity = warehouse?.locationCapacity || 0
if (locationCapacity <= 0) {
toast.warning('当前仓库未配置单货位容量,无法推荐货位')
return
}
try {
toast.loading('正在推荐货位...')
const { http } = await import('@/http/http')
const totalCount = Number(item.count)
const requiredLocationCount = Math.ceil(totalCount / locationCapacity)
const recommendList = await http.get<string[]>('/erp/location/recommend-inbound', {
productId: item.productId,
warehouseId: item.warehouseId,
count: totalCount,
topN: requiredLocationCount,
})
if (!recommendList || recommendList.length === 0) {
toast.warning('当前没有可推荐的空货位,请手工选择')
return
}
// 单个货位直接回填
if (recommendList.length === 1) {
item.locationCode = recommendList[0]
toast.success(`已推荐货位: ${recommendList[0]}`)
return
}
// 多个货位,提示用户选择或自动拆分
uni.showModal({
title: '推荐货位',
content: `需要 ${requiredLocationCount} 个货位,推荐: ${recommendList.join(', ')}\n是否自动拆分并分配`,
confirmText: '自动拆分',
cancelText: '手动填写',
success: (res) => {
if (res.confirm) {
// 自动拆分
applyAutoSplit(index, recommendList, locationCapacity)
} else {
// 只填写第一个货位
item.locationCode = recommendList[0]
toast.info(`已填写第一个货位: ${recommendList[0]},请手动拆分其他`)
}
},
})
} catch (error) {
console.error('推荐货位失败', error)
} finally {
toast.close()
}
}
/** 自动拆分并分配货位 */
function applyAutoSplit(index: number, locationCodes: string[], locationCapacity: number) {
const sourceItem = formData.value.items?.[index]
if (!sourceItem)
return
const totalCount = Number(sourceItem.count)
let remaining = totalCount
// 更新第一行
const firstCount = Math.min(remaining, locationCapacity)
sourceItem.locationCode = locationCodes[0]
sourceItem.count = Number(firstCount.toFixed(4))
remaining = Number((remaining - firstCount).toFixed(4))
// 插入后续行
for (let i = 1; i < locationCodes.length && remaining > 0; i++) {
const currentCount = Math.min(remaining, locationCapacity)
const newItem: PurchaseInItem = {
...sourceItem,
id: undefined,
locationCode: locationCodes[i],
count: Number(currentCount.toFixed(4)),
totalProductPrice: undefined,
taxPrice: undefined,
totalPrice: undefined,
remark: undefined,
}
formData.value.items?.splice(index + i, 0, newItem)
remaining = Number((remaining - currentCount).toFixed(4))
}
toast.success(`已自动拆分为 ${locationCodes.length} 个货位`)
}
/** 打开订单选择弹窗 */ /** 打开订单选择弹窗 */
function openOrderSelect() { function openOrderSelect() {
orderSelectVisible.value = true orderSelectVisible.value = true
@@ -495,7 +693,8 @@ async function getOrderList() {
/** 加载更多订单 */ /** 加载更多订单 */
function loadMoreOrders() { function loadMoreOrders() {
if (orderLoadMoreState.value === 'finished') return if (orderLoadMoreState.value === 'finished')
return
orderQueryParams.value.pageNo++ orderQueryParams.value.pageNo++
getOrderList() getOrderList()
} }
@@ -507,7 +706,8 @@ function handleSelectOrder(item: PurchaseOrder) {
/** 确认选择订单 */ /** 确认选择订单 */
async function confirmSelectOrder() { async function confirmSelectOrder() {
if (!selectedOrderId.value) return if (!selectedOrderId.value)
return
try { try {
toast.loading('加载订单详情...') toast.loading('加载订单详情...')
const orderDetail = await getPurchaseOrder(selectedOrderId.value) const orderDetail = await getPurchaseOrder(selectedOrderId.value)

View File

@@ -11,18 +11,18 @@
<SearchForm @search="handleQuery" @reset="handleReset" /> <SearchForm @search="handleQuery" @reset="handleReset" />
<!-- 状态快速筛选 --> <!-- 状态快速筛选 -->
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm"> <view class="mx-24rpx mb-16rpx flex items-center overflow-hidden rounded-12rpx bg-white shadow-sm">
<view <view
v-for="tab in statusTabs" v-for="tab in statusTabs"
:key="tab.value" :key="tab.value"
class="flex-1 py-20rpx text-center text-26rpx relative" class="relative flex-1 py-20rpx text-center text-26rpx"
:class="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'" :class="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
@click="handleQuickFilter(tab.value)" @click="handleQuickFilter(tab.value)"
> >
{{ tab.label }} {{ tab.label }}
<view <view
v-if="activeStatus === tab.value" v-if="activeStatus === tab.value"
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]" class="absolute bottom-0 left-1/4 h-4rpx w-1/2 rounded-2rpx bg-[#1890ff]"
/> />
</view> </view>
</view> </view>
@@ -56,7 +56,7 @@
<!-- 产品 --> <!-- 产品 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">产品</text> <text class="text-[#999]">产品</text>
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text> <text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
</view> </view>
<!-- 入库时间 --> <!-- 入库时间 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
@@ -64,23 +64,40 @@
<text>{{ formatDate(item.inTime) }}</text> <text>{{ formatDate(item.inTime) }}</text>
</view> </view>
<!-- 创建人 --> <!-- 创建人 -->
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">创建人</text> <text class="text-[#999]">创建人</text>
<text>{{ item.creatorName || '-' }}</text> <text>{{ item.creatorName || '-' }}</text>
</view> </view>
<!-- 批次号 -->
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">批次号</text>
<text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ formatItemBatchNos(item) || '-' }}</text>
</view>
<!-- 数量金额区域 --> <!-- 数量金额区域 -->
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]"> <view class="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-16rpx">
<view class="text-center"> <view class="text-center">
<view class="text-30rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view> <view class="text-30rpx text-[#333] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view> {{ item.totalCount || 0 }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
总数量
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-30rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view> <view class="text-30rpx text-[#e6a23c] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">应付</view> ¥{{ item.totalPrice || 0 }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
应付
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-30rpx text-[#52c41a] font-semibold">¥{{ item.paymentPrice || 0 }}</view> <view class="text-30rpx text-[#52c41a] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">已付</view> ¥{{ item.paymentPrice || 0 }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
已付
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view <view
@@ -89,7 +106,9 @@
> >
¥{{ (item.totalPrice || 0) - (item.paymentPrice || 0) }} ¥{{ (item.totalPrice || 0) - (item.paymentPrice || 0) }}
</view> </view>
<view class="text-22rpx text-[#999] mt-4rpx">未付</view> <view class="mt-4rpx text-22rpx text-[#999]">
未付
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -107,6 +126,30 @@
> >
修改 修改
</wd-button> </wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:purchase-in:query'])"
size="small" type="warning" plain @click="handleScanIn(item)"
>
扫码入库
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:purchase-in:submit-approval']) && item.status === 10 && !item.hasApprovalRecords"
size="small" type="success" plain @click="handleSubmitApproval(item)"
>
提交审批
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:purchase-in:query-approval']) && item.hasApprovalRecords"
size="small" type="info" plain @click="handleViewApproval(item)"
>
审批记录
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:approval-record:process']) && item.hasApprovalRecords && item.status !== 20 && item.status !== 30"
size="small" type="primary" plain @click="handleProcessApproval(item)"
>
处理审批
</wd-button>
<wd-button <wd-button
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && item.status === 10" v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && item.status === 10"
size="small" type="success" plain @click="handleAudit(item)" size="small" type="success" plain @click="handleAudit(item)"
@@ -120,7 +163,7 @@
反审核 反审核
</wd-button> </wd-button>
<wd-button <wd-button
v-if="hasAccessByCodes(['erp:purchase-in:delete']) && item.status === 10" v-if="hasAccessByCodes(['erp:purchase-in:delete']) && item.status === 10 && !item.hasApprovalRecords"
size="small" type="error" plain @click="handleDelete(item.id!)" size="small" type="error" plain @click="handleDelete(item.id!)"
> >
删除 删除
@@ -151,15 +194,19 @@
<!-- 审核弹窗 --> <!-- 审核弹窗 -->
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false"> <wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = false">
<view class="p-32rpx"> <view class="p-32rpx">
<view class="text-32rpx text-[#333] font-semibold mb-32rpx text-center"> <view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
采购入库审核 采购入库审核
</view> </view>
<view class="mb-24rpx"> <view class="mb-24rpx">
<view class="text-26rpx text-[#666] mb-12rpx">是否合格</view> <view class="mb-12rpx text-26rpx text-[#666]">
是否合格
</view>
<wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" /> <wd-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <view v-if="!auditForm.isQualified" class="mb-24rpx">
<view class="text-26rpx text-[#666] mb-12rpx">返回方式</view> <view class="mb-12rpx text-26rpx text-[#666]">
返回方式
</view>
<wd-radio-group v-model="auditForm.returnType" shape="button"> <wd-radio-group v-model="auditForm.returnType" shape="button">
<wd-radio <wd-radio
v-for="opt in RETURN_TYPE_OPTIONS" v-for="opt in RETURN_TYPE_OPTIONS"
@@ -171,14 +218,16 @@
</wd-radio-group> </wd-radio-group>
</view> </view>
<view v-if="!auditForm.isQualified" class="mb-24rpx"> <view v-if="!auditForm.isQualified" class="mb-24rpx">
<view class="text-26rpx text-[#666] mb-12rpx">返回备注</view> <view class="mb-12rpx text-26rpx text-[#666]">
返回备注
</view>
<wd-textarea <wd-textarea
v-model="auditForm.returnRemark" v-model="auditForm.returnRemark"
placeholder="请输入返回方式备注" placeholder="请输入返回方式备注"
:maxlength="200" :maxlength="200"
/> />
</view> </view>
<view class="flex gap-24rpx mt-32rpx"> <view class="mt-32rpx flex gap-24rpx">
<wd-button class="flex-1" plain @click="auditVisible = false"> <wd-button class="flex-1" plain @click="auditVisible = false">
取消 取消
</wd-button> </wd-button>
@@ -188,6 +237,124 @@
</view> </view>
</view> </view>
</wd-popup> </wd-popup>
<!-- 提交审批弹窗 -->
<wd-popup v-model="submitApprovalVisible" position="bottom" closable @close="submitApprovalVisible = false">
<view class="p-32rpx">
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
提交审批
</view>
<view class="mb-24rpx">
<view class="mb-12rpx text-26rpx text-[#666]">
审批人
</view>
<wd-input
v-model="submitApprovalForm.nextApprover"
placeholder="请输入审批人用户名"
clearable
/>
</view>
<view class="mb-24rpx">
<view class="mb-12rpx text-26rpx text-[#666]">
备注
</view>
<wd-textarea
v-model="submitApprovalForm.remark"
placeholder="请输入备注"
:maxlength="200"
/>
</view>
<view class="mt-32rpx flex gap-24rpx">
<wd-button class="flex-1" plain @click="submitApprovalVisible = false">
取消
</wd-button>
<wd-button class="flex-1" type="primary" :loading="submitApprovalLoading" @click="confirmSubmitApproval">
提交
</wd-button>
</view>
</view>
</wd-popup>
<!-- 处理审批弹窗 -->
<wd-popup v-model="processApprovalVisible" position="bottom" closable @close="processApprovalVisible = false">
<view class="p-32rpx">
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
处理审批
</view>
<view class="mb-24rpx">
<view class="mb-12rpx text-26rpx text-[#666]">
审批结果
</view>
<wd-radio-group v-model="processApprovalForm.approvalResult" shape="button">
<wd-radio
v-for="opt in APPROVAL_RESULT_OPTIONS"
:key="opt.value"
:value="opt.value"
>
{{ opt.label }}
</wd-radio>
</wd-radio-group>
</view>
<view class="mb-24rpx">
<view class="mb-12rpx text-26rpx text-[#666]">
审批意见
</view>
<wd-textarea
v-model="processApprovalForm.comment"
placeholder="请输入审批意见"
:maxlength="200"
/>
</view>
<view class="mt-32rpx flex gap-24rpx">
<wd-button class="flex-1" plain @click="processApprovalVisible = false">
取消
</wd-button>
<wd-button class="flex-1" type="primary" :loading="processApprovalLoading" @click="confirmProcessApproval">
确定
</wd-button>
</view>
</view>
</wd-popup>
<!-- 审批记录弹窗 -->
<wd-popup v-model="approvalRecordsVisible" position="bottom" closable @close="approvalRecordsVisible = false">
<view class="p-32rpx">
<view class="mb-32rpx text-center text-32rpx text-[#333] font-semibold">
审批记录
</view>
<view v-if="approvalRecords.length === 0" class="py-60rpx text-center text-28rpx text-[#999]">
暂无审批记录
</view>
<view v-else class="max-h-600rpx overflow-y-auto">
<view
v-for="(record, index) in approvalRecords"
:key="record.id || index"
class="mb-16rpx rounded-12rpx bg-[#f8f8f8] p-20rpx"
>
<view class="mb-8rpx flex items-center justify-between">
<text class="text-28rpx text-[#333] font-semibold">{{ record.approverName || record.approver }}</text>
<view
class="rounded-8rpx px-12rpx py-4rpx text-22rpx"
:class="getApprovalResultClass(record.approvalResult)"
>
{{ getApprovalResultText(record.approvalResult) }}
</view>
</view>
<view v-if="record.comment" class="mb-8rpx text-26rpx text-[#666]">
意见{{ record.comment }}
</view>
<view class="text-24rpx text-[#999]">
{{ record.approvalTime ? new Date(record.approvalTime).toLocaleString('zh-CN') : '-' }}
</view>
</view>
</view>
<view class="mt-24rpx">
<wd-button type="primary" block @click="approvalRecordsVisible = false">
关闭
</wd-button>
</view>
</view>
</wd-popup>
</view> </view>
</template> </template>
@@ -197,6 +364,7 @@ import type { LoadMoreState } from '@/http/types'
import { onReachBottom } from '@dcloudio/uni-app' import { onReachBottom } from '@dcloudio/uni-app'
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { APPROVAL_RESULT, APPROVAL_RESULT_OPTIONS, getApprovalRecordListByBiz, processApproval, submitApproval } from '@/api/erp/approval'
import { deletePurchaseIn, getPurchaseInPage, RETURN_TYPE_OPTIONS, updatePurchaseInStatus } from '@/api/erp/purchase-in' import { deletePurchaseIn, getPurchaseInPage, RETURN_TYPE_OPTIONS, updatePurchaseInStatus } from '@/api/erp/purchase-in'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
@@ -237,25 +405,96 @@ const auditForm = reactive({
returnRemark: undefined as string | undefined, returnRemark: undefined as string | undefined,
}) })
// 提交审批相关
const submitApprovalVisible = ref(false)
const submitApprovalLoading = ref(false)
const submitApprovalForm = reactive({
bizId: '' as string,
nextApprover: '' as string,
remark: '' as string,
})
// 处理审批相关
const processApprovalVisible = ref(false)
const processApprovalLoading = ref(false)
const processApprovalForm = reactive({
id: undefined as number | undefined,
approvalResult: APPROVAL_RESULT.APPROVED,
comment: '' as string,
})
// 审批记录相关
const approvalRecordsVisible = ref(false)
const approvalRecords = ref<any[]>([])
/** 格式化日期 */ /** 格式化日期 */
function formatDate(date?: string) { function formatDate(date?: string) {
if (!date) return '-' if (!date)
return '-'
return new Date(date).toLocaleDateString('zh-CN') return new Date(date).toLocaleDateString('zh-CN')
} }
/** 格式化批次号列表 */
function formatItemBatchNos(row: PurchaseIn): string {
const items = row?.items || []
const batchCountMap = new Map<string, number>()
items.forEach((it: any) => {
const batchNo = (it?.batchNo || '').trim()
if (!batchNo)
return
const count = Number(it?.count || 0)
batchCountMap.set(batchNo, (batchCountMap.get(batchNo) || 0) + count)
})
if (!batchCountMap.size)
return ''
return Array.from(batchCountMap.entries())
.map(([batchNo, count]) => `${batchNo}[${count}]`)
.join('')
}
/** 获取状态文本 */ /** 获取状态文本 */
function getStatusText(status?: number, isQualified?: boolean) { function getStatusText(status?: number, isQualified?: boolean) {
if (status === 10) return '未审核' if (status === 10)
if (status === 20) return isQualified ? '审核' : '不合格' return '审核'
if (status === 30) return '不合格' if (status === 20)
return isQualified ? '已审核' : '不合格'
if (status === 30)
return '不合格'
return '未知' return '未知'
} }
/** 获取状态样式 */ /** 获取状态样式 */
function getStatusClass(status?: number, isQualified?: boolean) { function getStatusClass(status?: number, isQualified?: boolean) {
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]' if (status === 10)
if (status === 20) return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]' return 'bg-[#fff7e6] text-[#fa8c16]'
if (status === 30) return 'bg-[#fff1f0] text-[#f5222d]' if (status === 20)
return isQualified ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'
if (status === 30)
return 'bg-[#fff1f0] text-[#f5222d]'
return 'bg-[#f5f5f5] text-[#999]'
}
/** 获取审批结果文本 */
function getApprovalResultText(result?: number) {
if (result === APPROVAL_RESULT.PENDING)
return '待审批'
if (result === APPROVAL_RESULT.APPROVED)
return '已通过'
if (result === APPROVAL_RESULT.REJECTED)
return '已拒绝'
if (result === APPROVAL_RESULT.TRANSFERRED)
return '已转办'
return '未知'
}
/** 获取审批结果样式 */
function getApprovalResultClass(result?: number) {
if (result === APPROVAL_RESULT.PENDING)
return 'bg-[#fff7e6] text-[#fa8c16]'
if (result === APPROVAL_RESULT.APPROVED)
return 'bg-[#f6ffed] text-[#52c41a]'
if (result === APPROVAL_RESULT.REJECTED)
return 'bg-[#fff1f0] text-[#f5222d]'
return 'bg-[#f5f5f5] text-[#999]' return 'bg-[#f5f5f5] text-[#999]'
} }
@@ -270,7 +509,26 @@ async function getList() {
try { try {
const params = { ...queryParams.value } const params = { ...queryParams.value }
const data = await getPurchaseInPage(params) const data = await getPurchaseInPage(params)
list.value = [...list.value, ...data.list]
// 为每条记录检查是否有审批记录
const listWithApprovalStatus = await Promise.all(
data.list.map(async (item) => {
try {
const records = await getApprovalRecordListByBiz(String(item.id), 'erp_purchase_in')
return {
...item,
hasApprovalRecords: records && records.length > 0,
}
} catch {
return {
...item,
hasApprovalRecords: false,
}
}
}),
)
list.value = [...list.value, ...listWithApprovalStatus]
total.value = data.total total.value = data.total
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading' loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
} catch { } catch {
@@ -345,6 +603,13 @@ function handleEdit(item: PurchaseIn) {
}) })
} }
/** 扫码入库 */
function handleScanIn(item: PurchaseIn) {
uni.navigateTo({
url: `/pages-erp/purchase-in/scan-in/index?id=${item.id}&no=${encodeURIComponent(item.no || '')}`,
})
}
/** 打开审核弹窗 */ /** 打开审核弹窗 */
function handleAudit(item: PurchaseIn) { function handleAudit(item: PurchaseIn) {
auditForm.id = item.id auditForm.id = item.id
@@ -364,7 +629,8 @@ function handleQualifiedChange(val: boolean) {
/** 提交审核 */ /** 提交审核 */
async function submitAudit() { async function submitAudit() {
if (!auditForm.id) return if (!auditForm.id)
return
if (!auditForm.isQualified && !auditForm.returnType) { if (!auditForm.isQualified && !auditForm.returnType) {
toast.warning('请选择返回方式') toast.warning('请选择返回方式')
return return
@@ -394,7 +660,8 @@ function handleReverseAudit(id: number) {
title: '提示', title: '提示',
content: '确定反审核该入库单吗?', content: '确定反审核该入库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm)
return
try { try {
await updatePurchaseInStatus({ await updatePurchaseInStatus({
id, id,
@@ -418,7 +685,8 @@ function handleDelete(id: number) {
title: '提示', title: '提示',
content: '确定要删除该采购入库单吗?', content: '确定要删除该采购入库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm)
return
try { try {
await deletePurchaseIn([id]) await deletePurchaseIn([id])
toast.success('删除成功') toast.success('删除成功')
@@ -432,6 +700,91 @@ function handleDelete(id: number) {
}) })
} }
/** 提交审批 */
function handleSubmitApproval(item: PurchaseIn) {
submitApprovalForm.bizId = String(item.id)
submitApprovalForm.nextApprover = ''
submitApprovalForm.remark = ''
submitApprovalVisible.value = true
}
/** 确认提交审批 */
async function confirmSubmitApproval() {
if (!submitApprovalForm.nextApprover) {
toast.warning('请输入审批人')
return
}
submitApprovalLoading.value = true
try {
await submitApproval({
bizId: submitApprovalForm.bizId,
bizTableName: 'erp_purchase_in',
nextApprover: submitApprovalForm.nextApprover,
remark: submitApprovalForm.remark,
})
toast.success('提交审批成功')
submitApprovalVisible.value = false
list.value = []
queryParams.value.pageNo = 1
getList()
} finally {
submitApprovalLoading.value = false
}
}
/** 查看审批记录 */
async function handleViewApproval(item: PurchaseIn) {
try {
toast.loading('加载中...')
const records = await getApprovalRecordListByBiz(String(item.id), 'erp_purchase_in')
approvalRecords.value = records || []
approvalRecordsVisible.value = true
} finally {
toast.close()
}
}
/** 处理审批 */
async function handleProcessApproval(item: PurchaseIn) {
try {
toast.loading('加载中...')
const records = await getApprovalRecordListByBiz(String(item.id), 'erp_purchase_in')
// 找到待处理的审批记录
const pendingRecord = records?.find((r: any) => r.approvalResult === APPROVAL_RESULT.PENDING)
if (!pendingRecord) {
toast.warning('没有待处理的审批记录')
return
}
processApprovalForm.id = pendingRecord.id
processApprovalForm.approvalResult = APPROVAL_RESULT.APPROVED
processApprovalForm.comment = ''
processApprovalVisible.value = true
} finally {
toast.close()
}
}
/** 确认处理审批 */
async function confirmProcessApproval() {
if (!processApprovalForm.id)
return
processApprovalLoading.value = true
try {
await processApproval({
id: processApprovalForm.id,
approvalResult: processApprovalForm.approvalResult,
comment: processApprovalForm.comment,
})
toast.success('审批处理成功')
processApprovalVisible.value = false
list.value = []
queryParams.value.pageNo = 1
getList()
} finally {
processApprovalLoading.value = false
}
}
/** 触底加载更多 */ /** 触底加载更多 */
onReachBottom(() => { onReachBottom(() => {
loadMore() loadMore()

View File

@@ -0,0 +1,131 @@
<template>
<view class="recent-scan-list">
<view v-if="records.length === 0" class="recent-scan-list__empty">
暂无扫码记录开始扫码入库
</view>
<view
v-for="(record, index) in records"
:key="record.id || index"
class="scan-card"
:class="{ 'scan-card--latest': latestIndex === index }"
>
<view class="scan-card__header">
<text class="scan-card__name">{{ record.productName || '-' }}</text>
<text class="scan-card__delete" @tap="emit('delete', index)">删除</text>
</view>
<view class="scan-card__meta">
<text>条码{{ record.productBarCode || '-' }}</text>
<text>规格{{ record.productSpec || '-' }}</text>
</view>
<view class="scan-card__meta">
<text>仓库{{ record.warehouseName || '-' }}</text>
<text>单位{{ record.productUnit || '-' }}</text>
</view>
<view class="scan-card__meta">
<text>库位{{ record.locationCode || '-' }}</text>
<text>批次{{ record.batchNo || '-' }}</text>
</view>
<view class="scan-card__footer">
<text class="scan-card__time">{{ formatTime(record.scanTime) }}</text>
<text class="scan-card__count">{{ record.scanCount }}</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import type { ScanRecord } from '../index.vue'
defineProps<{
records: ScanRecord[]
latestIndex?: number
}>()
const emit = defineEmits<{
(event: 'delete', index: number): void
(event: 'clear'): void
}>()
function formatTime(time?: string) {
if (!time) return '-'
const date = new Date(time)
return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`
}
</script>
<style lang="scss" scoped>
.recent-scan-list {
&__empty {
padding: 48rpx;
border-radius: 16rpx;
background: #fff;
color: #86909c;
text-align: center;
font-size: 26rpx;
}
}
.scan-card {
margin-bottom: 16rpx;
padding: 24rpx;
border: 2rpx solid transparent;
border-radius: 16rpx;
background: #fff;
&--latest {
border-color: #1677ff;
box-shadow: 0 8rpx 20rpx rgba(22, 119, 255, 0.12);
}
&__header,
&__meta,
&__footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
&__header {
margin-bottom: 10rpx;
}
&__name {
color: #1f2329;
font-size: 28rpx;
font-weight: 600;
}
&__delete {
flex-shrink: 0;
color: #f53f3f;
font-size: 24rpx;
}
&__meta {
margin-top: 6rpx;
color: #4e5969;
font-size: 22rpx;
flex-wrap: wrap;
}
&__footer {
margin-top: 10rpx;
padding-top: 10rpx;
border-top: 2rpx solid #f2f3f5;
}
&__time {
color: #86909c;
font-size: 22rpx;
}
&__count {
color: #1677ff;
font-size: 28rpx;
font-weight: 700;
}
}
</style>

View File

@@ -0,0 +1,69 @@
<template>
<view class="scan-context-bar">
<view class="scan-context-bar__main">
<view class="scan-context-bar__order">
<text class="scan-context-bar__label">入库单</text>
<text class="scan-context-bar__value">{{ purchaseInNo || '未关联入库单' }}</text>
</view>
<view class="scan-context-bar__stats">
<text>记录 {{ recordCount }} </text>
<text>累计 {{ scannedCount }} </text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
defineProps<{
purchaseInId?: number
purchaseInNo?: string
scannedCount: number
recordCount: number
}>()
</script>
<style lang="scss" scoped>
.scan-context-bar {
padding: 20rpx 24rpx;
border-radius: 16rpx;
background: #fff;
margin-bottom: 16rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
&__main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
&__order {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
flex: 1;
}
&__label {
flex-shrink: 0;
color: #86909c;
font-size: 24rpx;
}
&__value {
color: #1f2329;
font-size: 28rpx;
font-weight: 600;
}
&__stats {
display: flex;
gap: 20rpx;
flex-shrink: 0;
color: #1677ff;
font-size: 24rpx;
font-weight: 600;
}
}
</style>

View File

@@ -0,0 +1,43 @@
<template>
<view v-if="message" class="feedback-bar" :class="`feedback-bar--${tone}`">
{{ message }}
</view>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
tone?: 'success' | 'error' | 'idle'
message?: string
}>(),
{
tone: 'idle',
message: '',
},
)
</script>
<style lang="scss" scoped>
.feedback-bar {
min-height: 76rpx;
padding: 18rpx 24rpx;
border-radius: 14rpx;
font-size: 24rpx;
line-height: 40rpx;
&--idle {
background: #f2f3f5;
color: #4e5969;
}
&--success {
background: #f6ffed;
color: #389e0d;
}
&--error {
background: #fff2f0;
color: #cf1322;
}
}
</style>

View File

@@ -0,0 +1,888 @@
<template>
<view class="yd-page-container scan-page">
<wd-navbar
title="扫码入库"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="handleBack"
/>
<view class="scan-page__content">
<!-- 顶部上下文条 -->
<ScanContextBar
:purchase-in-id="purchaseInId"
:purchase-in-no="purchaseInNo"
:scanned-count="scannedTotalCount"
:record-count="records.length"
/>
<!-- 扫码工作台 -->
<view class="scan-workbench">
<!-- 当前扫码上下文提示 -->
<view class="scan-panel">
<!-- 步骤指示器库位 产品 -->
<view class="scan-step-indicator">
<view class="scan-step-indicator__item" :class="{ 'active': step === 'idle', 'done': step !== 'idle' }">
<view class="scan-step-indicator__dot">1</view>
<text>扫库位</text>
</view>
<view class="scan-step-indicator__line" :class="{ 'done': step !== 'idle' }" />
<view class="scan-step-indicator__item" :class="{ 'active': step === 'scanned' }">
<view class="scan-step-indicator__dot">2</view>
<text>扫产品</text>
</view>
</view>
<!-- 当前作业提示 -->
<view class="scan-current-hint">
<text v-if="step === 'idle'">请扫描库位条码</text>
<text v-else>产品已入库请继续扫码</text>
</view>
<!-- 库位扫码区 -->
<view class="scan-row" :class="{ 'scan-row--dim': step !== 'idle' }">
<input
v-model="locationCode"
class="scan-field"
:class="{ 'scan-field--active': step === 'idle' }"
placeholder="扫描库位条码"
confirm-type="next"
:focus="locationInputFocus"
:cursor-spacing="20"
:adjust-position="true"
:hold-keyboard="true"
@blur="handleLocationBlur"
@confirm="handleLocationScan"
>
<button class="scan-camera-btn" :disabled="scanLoading" @tap="handleCameraScan('location')">
</button>
</view>
<!-- 库位预览扫库位码后显示 -->
<view class="scan-location-preview" v-if="locationInfo">
<view class="scan-location-preview__row">
<text class="scan-location-preview__label">仓库</text>
<text class="scan-location-preview__value">{{ locationInfo.warehouseName }}</text>
</view>
<view class="scan-location-preview__row">
<text class="scan-location-preview__label">库位</text>
<text class="scan-location-preview__value scan-location-preview__value--code">
{{ locationInfo.locationCode }}
</text>
<text class="scan-location-preview__badge" :class="locationInfo.enableLocation ? 'badge--green' : 'badge--gray'">
{{ locationInfo.enableLocation ? '库位管理' : '无库位管理' }}
</text>
</view>
</view>
<!-- 产品扫码区 -->
<view class="scan-row" :class="{ 'scan-row--dim': step === 'idle' }">
<input
v-model="productBarCode"
class="scan-field"
:class="{ 'scan-field--active': step === 'scanned' }"
placeholder="扫描产品条码"
confirm-type="done"
:focus="productInputFocus"
:cursor-spacing="20"
:adjust-position="true"
:hold-keyboard="true"
@blur="handleProductBlur"
@confirm="handleProductScan"
>
<button class="scan-camera-btn" :disabled="scanLoading" @tap="handleCameraScan('product')">
</button>
</view>
<!-- 产品预览扫产品码后显示 -->
<view class="scan-product-preview" v-if="productPreview">
<view class="scan-product-preview__row">
<text class="scan-product-preview__label">产品</text>
<text class="scan-product-preview__value scan-product-preview__value--name">
{{ productPreview.name }}
</text>
</view>
<view class="scan-product-preview__row">
<text class="scan-product-preview__label">规格</text>
<text class="scan-product-preview__value">{{ productPreview.standard || '-' }}</text>
</view>
<view class="scan-product-preview__row">
<text class="scan-product-preview__label">条码</text>
<text class="scan-product-preview__value">{{ productPreview.barCode || '-' }}</text>
</view>
</view>
<ScanFeedbackBar :tone="feedbackTone" :message="feedbackMessage" />
</view>
<!-- 扫码记录列表 -->
<view class="scan-panel scan-panel--list">
<view class="scan-panel__header">
<view class="scan-panel__title">
扫码记录
</view>
<view class="scan-panel__meta">
{{ records.length }}
</view>
</view>
<RecentScanList
:records="records"
:latest-index="latestRecordIndex"
@delete="handleDeleteRecord"
/>
</view>
<!-- 提交栏 -->
<view class="scan-footer">
<button class="scan-footer__clear" @tap="handleClearAll">
清空记录
</button>
<button class="scan-footer__submit" :loading="submitting" @tap="handleSubmit">
保存入库记录
</button>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import type { ProductByBarCode } from '@/api/erp/product'
import type { LocationByCodeVO } from '@/api/erp/location'
import { computed, nextTick, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { getProductByBarCode } from '@/api/erp/product'
import { getLocationByCode } from '@/api/erp/location'
import { getPurchaseIn } from '@/api/erp/purchase-in'
import { createPurchaseInScanRecord, deletePurchaseInScanRecord, getPurchaseInScanRecordList } from '@/api/erp/purchase-in-scan-record'
import ScanFeedbackBar from '@/pages-erp/purchase-in/scan-in/components/scan-feedback-bar.vue'
import RecentScanList from '@/pages-erp/purchase-in/scan-in/components/recent-scan-list.vue'
import ScanContextBar from '@/pages-erp/purchase-in/scan-in/components/scan-context-bar.vue'
import { navigateBackPlus } from '@/utils'
import { normalizeCameraScanResult, normalizeScanCode } from '@/utils/scan'
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
/** 扫码入库记录 */
export interface ScanRecord {
id?: number
purchaseInId: number
productId?: number
productName?: string
productSpec?: string
productBarCode?: string
productUnit?: string
warehouseId?: number
warehouseName?: string
locationCode?: string
batchNo?: string
scanCount: number
scanTime?: string
operatorId?: number
operatorName?: string
}
type Step = 'idle' | 'scanned'
/** 页面参数id=入库单ID, no=入库单号 */
const props = defineProps<{
id?: number
no?: string
}>()
const toast = useToast()
// 页面参数
const purchaseInId = ref<number>()
const purchaseInNo = ref<string>()
// 扫码步骤
const step = ref<Step>('idle')
// 扫码数据
const locationCode = ref('')
const locationInfo = ref<LocationByCodeVO | null>(null)
const productBarCode = ref('')
const productPreview = ref<ProductByBarCode | null>(null)
const batchNo = ref('')
// 状态
const scanLoading = ref(false)
const submitting = ref(false)
const records = ref<ScanRecord[]>([])
const feedbackTone = ref<'success' | 'error' | 'idle'>('idle')
const feedbackMessage = ref('')
// 输入框焦点控制
const locationInputFocus = ref(false)
const productInputFocus = ref(false)
// 计算属性
const canConfirm = computed(() => {
return locationInfo.value?.warehouseId && productPreview.value?.id && scanLoading.value === false
})
const scannedTotalCount = computed(() =>
records.value.reduce((sum, r) => sum + Number(r.scanCount || 0), 0),
)
const latestRecordIndex = computed(() => {
if (records.value.length === 0) return undefined
return records.value.length - 1
})
/** 返回上一页 */
function handleBack() {
navigateBackPlus('/pages-erp/purchase-in/index')
}
/** 初始化页面 */
onMounted(async () => {
if (props.id) purchaseInId.value = props.id
if (props.no) purchaseInNo.value = decodeURIComponent(props.no)
if (purchaseInId.value) {
try {
const data = await getPurchaseIn(purchaseInId.value)
purchaseInNo.value = data.no
} catch {
// 忽略
}
await loadRecords()
}
// PDA 扫码枪需要输入框自动获得焦点,延迟确保页面完全渲染
await nextTick()
setTimeout(() => {
focusLocationInput()
}, 500)
})
/** 重置到初始状态 */
function resetToIdle() {
clearScanInputs()
locationInfo.value = null
productPreview.value = null
step.value = 'idle'
// 延迟清空错误 + 聚焦光标,让用户先看到错误提示
setTimeout(() => {
clearFeedback()
focusLocationInput()
}, 800)
}
/** 聚焦库位码输入框 */
function focusLocationInput() {
productInputFocus.value = false
locationInputFocus.value = false
nextTick(() => {
locationInputFocus.value = true
})
}
/** 库位输入框失焦处理 - 如果当前步骤是 idle自动重新聚焦 */
function handleLocationBlur() {
if (step.value === 'idle' && !scanLoading.value) {
setTimeout(() => {
if (step.value === 'idle') {
focusLocationInput()
}
}, 100)
}
}
/** 产品输入框失焦处理 - 如果当前步骤是 scanned自动重新聚焦 */
function handleProductBlur() {
if (step.value === 'scanned' && !scanLoading.value) {
setTimeout(() => {
if (step.value === 'scanned') {
focusProductInput()
}
}, 100)
}
}
/** 加载已有扫码记录 */
async function loadRecords() {
if (!purchaseInId.value) return
try {
const data = await getPurchaseInScanRecordList(purchaseInId.value)
records.value = data || []
} catch {
records.value = []
}
}
/**
* 扫库位码:自动反查仓库信息
*/
async function handleLocationScan() {
const code = normalizeScanCode(locationCode.value)
if (!code) {
setErrorFeedback('请先扫描库位条码')
return
}
scanLoading.value = true
try {
try {
locationInfo.value = await getLocationByCode(code)
} catch {
setErrorFeedback(`库位码 ${code} 不存在`)
resetToIdle()
return
}
if (!locationInfo.value?.warehouseId) {
setErrorFeedback(`库位码 ${code} 未找到对应仓库`)
resetToIdle()
return
}
locationCode.value = code
step.value = 'scanned'
productBarCode.value = ''
productPreview.value = null
batchNo.value = ''
clearFeedback()
// 聚焦产品输入框,等待扫码枪输入
focusProductInput()
} finally {
scanLoading.value = false
}
}
/** 聚焦产品码输入框 */
function focusProductInput() {
locationInputFocus.value = false
productInputFocus.value = false
nextTick(() => {
productInputFocus.value = true
})
}
/**
* 扫产品码:自动反查产品信息
*/
async function handleProductScan() {
const code = normalizeScanCode(productBarCode.value)
if (!code) {
setErrorFeedback('请先扫描产品条码')
return
}
if (!locationInfo.value) {
setErrorFeedback('请先扫描库位条码')
step.value = 'idle'
return
}
scanLoading.value = true
try {
try {
productPreview.value = await getProductByBarCode(code)
} catch {
setErrorFeedback(`条码 ${code} 未匹配到产品`)
resetToIdle()
return
}
if (!productPreview.value?.id) {
setErrorFeedback(`条码 ${code} 未匹配到产品`)
resetToIdle()
return
}
productBarCode.value = code
step.value = 'scanned'
clearFeedback()
// 自动确认入库
nextTick(() => handleConfirm())
} finally {
scanLoading.value = false
}
}
/**
* 确认入库
*/
async function handleConfirm() {
if (!canConfirm.value) return
scanLoading.value = true
try {
const record: ScanRecord = {
purchaseInId: purchaseInId.value || 0,
productId: productPreview.value!.id,
productName: productPreview.value!.name,
productSpec: productPreview.value!.standard,
productBarCode: productPreview.value!.barCode,
productUnit: productPreview.value!.unitName,
warehouseId: locationInfo.value!.warehouseId,
warehouseName: locationInfo.value!.warehouseName,
locationCode: locationInfo.value!.locationCode,
batchNo: batchNo.value.trim() || undefined,
scanCount: 1,
scanTime: new Date().toISOString(),
}
// 提交到后端
try {
const newId = await createPurchaseInScanRecord(record)
record.id = newId
} catch {
record.id = Date.now()
}
// 追加到列表
records.value.push(record)
// 重置,准备下一次扫码
const productName = productPreview.value!.name
const locationCodeText = locationInfo.value!.locationCode
clearScanInputs()
step.value = 'idle'
setSuccessFeedback(`${productName}${locationCodeText} 入库成功`)
await nextTick()
// 聚焦库位输入框,等待扫码枪输入
focusLocationInput()
} finally {
scanLoading.value = false
}
}
/** 相机扫码 */
function handleCameraScan(target: 'location' | 'product') {
if (scanLoading.value) return
// #ifdef APP-PLUS
// Android 运行时权限检查
plus.android.requestPermissions(
['android.permission.CAMERA'],
function(result) {
const granted = result.granted
if (granted && granted.length > 0) {
doScan(target)
} else {
toast.error('请在设置中开启相机权限')
uni.openSetting()
}
},
function() {
toast.error('相机权限获取失败')
},
)
// #endif
// #ifndef APP-PLUS
doScan(target)
// #endif
}
function doScan(target: 'location' | 'product') {
uni.scanCode({
onlyFromCamera: true,
success: async (result) => {
const code = normalizeCameraScanResult(result)
if (!code) return
if (target === 'location') {
locationCode.value = code
await handleLocationScan()
} else {
productBarCode.value = code
await handleProductScan()
}
},
fail: (error) => {
if (String(error?.errMsg || '').includes('cancel')) return
toast.error('相机扫码失败,请重试')
},
})
}
/** 删除单条记录 */
async function handleDeleteRecord(index: number) {
const record = records.value[index]
if (!record) return
if (record.id && record.id > 0 && record.id < 1000000000000) {
try {
await deletePurchaseInScanRecord(record.id)
} catch {
toast.error('删除失败')
return
}
}
records.value.splice(index, 1)
}
/** 清空所有记录 */
function handleClearAll() {
if (records.value.length === 0) return
uni.showModal({
title: '确认清空',
content: '确定要清空所有扫码记录吗?',
success: async (res) => {
if (!res.confirm) return
const toDelete = records.value.filter(r => r.id && r.id > 0 && r.id < 1000000000000)
for (const r of toDelete) {
try { await deletePurchaseInScanRecord(r.id!) } catch { /* ignore */ }
}
records.value = []
clearFeedback()
},
})
}
/** 保存入库记录 */
async function handleSubmit() {
if (records.value.length === 0) {
toast.warning('暂无扫码记录')
return
}
if (!purchaseInId.value) {
toast.warning('缺少采购入库单ID')
return
}
submitting.value = true
try {
toast.success(`已保存 ${records.value.length} 条入库记录`)
records.value = []
await loadRecords()
} finally {
submitting.value = false
}
}
/** 清空本次扫码输入 */
function clearScanInputs() {
locationCode.value = ''
locationInfo.value = null
productBarCode.value = ''
productPreview.value = null
batchNo.value = ''
}
function setSuccessFeedback(message: string) {
feedbackTone.value = 'success'
feedbackMessage.value = message
}
function setErrorFeedback(message: string) {
feedbackTone.value = 'error'
feedbackMessage.value = message
}
function clearFeedback() {
feedbackTone.value = 'idle'
feedbackMessage.value = ''
}
</script>
<style lang="scss" scoped>
.scan-page {
background: #f4f6f8;
min-height: 100vh;
&__content {
padding: 24rpx;
padding-top: calc(24rpx + env(safe-area-inset-top) + 88rpx);
box-sizing: border-box;
}
}
.scan-workbench {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.scan-panel {
padding: 24rpx;
border-radius: 18rpx;
background: #fff;
&--list {
padding-bottom: 8rpx;
}
&__header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
margin-bottom: 16rpx;
}
&__title {
color: #1f2329;
font-size: 28rpx;
font-weight: 600;
}
&__meta {
color: #86909c;
font-size: 22rpx;
}
}
// 步骤指示器
.scan-step-indicator {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 24rpx;
&__item {
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
text {
font-size: 22rpx;
color: #86909c;
}
&.active text {
color: #1677ff;
font-weight: 600;
}
&.done text {
color: #52c41a;
}
}
&__dot {
width: 48rpx;
height: 48rpx;
line-height: 48rpx;
border-radius: 50%;
background: #f2f3f5;
color: #86909c;
font-size: 24rpx;
font-weight: 600;
text-align: center;
}
&__item.active &__dot {
background: #1677ff;
color: #fff;
}
&__item.done &__dot {
background: #52c41a;
color: #fff;
}
&__line {
flex: 1;
height: 2rpx;
background: #e5e6eb;
margin: 0 12rpx;
margin-bottom: 28rpx;
max-width: 80rpx;
&.done {
background: #52c41a;
}
}
}
// 当前作业提示
.scan-current-hint {
text-align: center;
font-size: 30rpx;
font-weight: 600;
color: #1f2329;
margin-bottom: 20rpx;
}
// 输入行
.scan-row {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 16rpx;
transition: opacity 0.2s;
&--dim {
opacity: 0.4;
pointer-events: none;
}
.scan-field {
flex: 1;
}
}
.scan-field {
height: 88rpx;
padding: 0 24rpx;
line-height: 88rpx;
border: 2rpx solid #e5e6eb;
border-radius: 14rpx;
background: #f7f8fa;
color: #1f2329;
box-sizing: border-box;
font-size: 28rpx;
&--active {
border-color: #1677ff;
background: #fff;
box-shadow: 0 0 0 4rpx rgba(22, 119, 255, 0.1);
}
}
.scan-camera-btn {
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
border-radius: 14rpx;
background: #1677ff;
color: #fff;
font-size: 26rpx;
font-weight: 600;
padding: 0;
border: none;
flex-shrink: 0;
&:active { opacity: 0.85; }
&[disabled] { background: #d9d9d9; }
}
// 库位预览(优先显示)
.scan-location-preview {
margin-bottom: 16rpx;
padding: 20rpx;
border-radius: 14rpx;
background: #f6fff0;
border: 2rpx solid #b7eb8f;
&__row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6rpx 0;
}
&__label {
color: #4e5969;
font-size: 24rpx;
flex-shrink: 0;
}
&__value {
color: #1f2329;
font-size: 24rpx;
font-weight: 600;
margin-right: 12rpx;
&--code {
color: #52c41a;
font-size: 28rpx;
font-weight: 700;
}
}
&__badge {
padding: 4rpx 12rpx;
border-radius: 8rpx;
font-size: 20rpx;
font-weight: 600;
flex-shrink: 0;
&.badge--green {
background: #f6ffed;
color: #52c41a;
border: 1rpx solid #b7eb8f;
}
&.badge--gray {
background: #f7f8fa;
color: #86909c;
border: 1rpx solid #e5e6eb;
}
}
}
// 产品预览
.scan-product-preview {
margin-bottom: 16rpx;
padding: 20rpx;
border-radius: 14rpx;
background: #f0f5ff;
border: 2rpx solid #adc6ff;
&__row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6rpx 0;
}
&__label {
color: #4e5969;
font-size: 24rpx;
flex-shrink: 0;
}
&__value {
color: #1f2329;
font-size: 24rpx;
text-align: right;
&--name {
font-size: 28rpx;
font-weight: 600;
}
}
}
// 底部栏
.scan-footer {
position: sticky;
bottom: 0;
display: flex;
gap: 16rpx;
padding: 20rpx 0 calc(20rpx + env(safe-area-inset-bottom));
background: #f4f6f8;
&__clear {
flex: 1;
height: 88rpx;
line-height: 88rpx;
border-radius: 16rpx;
background: #fff;
color: #4e5969;
font-size: 28rpx;
border: 2rpx solid #e5e6eb;
}
&__submit {
flex: 2;
height: 88rpx;
line-height: 88rpx;
border-radius: 16rpx;
background: #1677ff;
color: #fff;
font-size: 28rpx;
font-weight: 600;
}
}
</style>

View File

@@ -0,0 +1,85 @@
<template>
<view class="order-context-bar">
<view class="order-context-bar__main">
<view class="order-context-bar__order">
<text class="order-context-bar__label">单号</text>
<text class="order-context-bar__value">{{ orderNo || '-' }}</text>
</view>
<view class="order-context-bar__progress">
已扫 {{ scannedCount }} / {{ targetCount }}
</view>
</view>
<view class="order-context-bar__meta">
<text>供应商{{ supplierName || '-' }}</text>
<text>仓库{{ warehouseName || '-' }}</text>
<text class="order-context-bar__exception">异常{{ exceptionCount }}</text>
</view>
</view>
</template>
<script setup lang="ts">
defineProps<{
orderNo: string
supplierName?: string
warehouseName?: string
scannedCount: number
targetCount: number
exceptionCount: number
}>()
</script>
<style lang="scss" scoped>
.order-context-bar {
padding: 20rpx 24rpx;
border-bottom: 2rpx solid #e5e6eb;
background: rgba(255, 255, 255, 0.96);
&__main,
&__meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
&__order {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
flex: 1;
}
&__label {
flex-shrink: 0;
color: #86909c;
font-size: 24rpx;
}
&__value {
min-width: 0;
color: #1f2329;
font-size: 30rpx;
font-weight: 600;
}
&__progress {
flex-shrink: 0;
color: #1677ff;
font-size: 24rpx;
font-weight: 600;
}
&__meta {
margin-top: 12rpx;
color: #4e5969;
font-size: 22rpx;
flex-wrap: wrap;
}
&__exception {
color: #d4380d;
}
}
</style>

View File

@@ -0,0 +1,187 @@
<template>
<view class="recent-scan-list">
<view v-if="items.length === 0" class="recent-scan-list__empty">
暂无最近扫码记录
</view>
<view
v-for="(item, index) in items"
:key="buildItemKey(item)"
class="scan-card"
:class="{ 'scan-card--latest': latestIndex === index }"
>
<view class="scan-card__header">
<text class="scan-card__name">{{ item.productName || '-' }}</text>
<text class="scan-card__undo" @tap="emit('undo', index, item)">撤销</text>
</view>
<view class="scan-card__meta">
<text>条码{{ item.productBarCode || '-' }}</text>
<view class="scan-card__quantity">
<text class="scan-card__step" @tap="emit('decrease', index, item)">-</text>
<input
class="scan-card__count-input"
type="number"
:value="formatCount(item.count)"
@blur="handleCountBlur($event, index, item)"
@confirm="handleCountBlur($event, index, item)"
>
<text class="scan-card__step" @tap="emit('increase', index, item)">+</text>
</view>
</view>
<view class="scan-card__meta">
<text>批次{{ item.batchNo || '-' }}</text>
<text>剩余{{ formatCount(item.remainCount) }}</text>
</view>
<view class="scan-card__meta">
<text>库位{{ item.locationCode || '-' }}</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import type { PurchaseScanItem } from '@/utils/purchase-scan'
defineProps<{
items: PurchaseScanItem[]
latestIndex?: number
}>()
const emit = defineEmits<{
(event: 'undo', index: number, item: PurchaseScanItem): void
(event: 'increase', index: number, item: PurchaseScanItem): void
(event: 'decrease', index: number, item: PurchaseScanItem): void
(event: 'change-count', index: number, nextCount: number, item: PurchaseScanItem): void
}>()
/**
* 功能说明:生成最近扫码卡片的稳定 key复用采购扫码的聚合维度。
* 适用场景:最近扫码列表渲染时为每条记录提供唯一标识。
* @param item 当前扫码记录
* @return 组合后的字符串 key
* 注意事项:采购扫码项已按订单行、批次和库位聚合,这里直接使用相同维度生成稳定 key避免列表重排时节点误复用。
*/
function buildItemKey(item: PurchaseScanItem) {
return [
item.orderItemId || item.productId || 'unknown',
item.batchNo || 'no-batch',
item.locationCode || 'no-location',
].join('-')
}
/**
* 功能说明:格式化数量展示,避免空值直接透出到工作台。
* 适用场景:最近扫码卡片展示扫码数量和剩余数量。
* @param value 原始数量
* @return 格式化后的数量文案
* 注意事项:采购扫码数量可能来自接口或本地累加,这里统一转数值后再按整数/小数展示。
*/
function formatCount(value?: number) {
if (value === undefined || value === null) {
return '-'
}
const normalizedValue = Number(value)
return normalizedValue.toFixed(Number.isInteger(normalizedValue) ? 0 : 4)
}
/**
* 功能说明:处理扫码卡片中的手动数量录入。
* 适用场景:操作员直接输入目标数量后离焦或回车确认。
* @param event 输入框事件
* @param index 当前记录索引
* @param item 当前扫码记录
* @return 无
* 注意事项:这里只负责把输入值抛给页面层,实际数量校验与上限判断统一由页面业务逻辑处理。
*/
function handleCountBlur(event: Record<string, any>, index: number, item: PurchaseScanItem) {
const rawValue = event?.detail?.value
emit('change-count', index, Number(rawValue), item)
}
</script>
<style lang="scss" scoped>
.recent-scan-list {
&__empty {
padding: 28rpx;
border-radius: 16rpx;
background: #fff;
color: #86909c;
text-align: center;
}
}
.scan-card {
margin-bottom: 16rpx;
padding: 24rpx;
border: 2rpx solid transparent;
border-radius: 16rpx;
background: #fff;
&--latest {
border-color: #1677ff;
box-shadow: 0 8rpx 20rpx rgba(22, 119, 255, 0.12);
}
&__header,
&__meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
&__header {
margin-bottom: 12rpx;
}
&__name {
color: #1f2329;
font-size: 28rpx;
font-weight: 600;
}
&__undo {
flex-shrink: 0;
color: #f53f3f;
font-size: 24rpx;
}
&__meta {
margin-top: 8rpx;
color: #4e5969;
font-size: 24rpx;
flex-wrap: wrap;
}
&__quantity {
display: flex;
align-items: center;
gap: 12rpx;
}
&__step {
width: 44rpx;
height: 44rpx;
line-height: 44rpx;
border-radius: 8rpx;
background: #f2f3f5;
color: #1f2329;
text-align: center;
font-size: 30rpx;
}
&__count-input {
width: 104rpx;
height: 44rpx;
line-height: 44rpx;
border: 2rpx solid #d9dce3;
border-radius: 8rpx;
background: #fff;
color: #1f2329;
text-align: center;
box-sizing: border-box;
}
}
</style>

View File

@@ -0,0 +1,43 @@
<template>
<view v-if="message" class="feedback-bar" :class="`feedback-bar--${tone}`">
{{ message }}
</view>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
tone?: 'success' | 'error' | 'idle'
message?: string
}>(),
{
tone: 'idle',
message: '',
},
)
</script>
<style lang="scss" scoped>
.feedback-bar {
min-height: 76rpx;
padding: 18rpx 24rpx;
border-radius: 14rpx;
font-size: 24rpx;
line-height: 40rpx;
&--idle {
background: #f2f3f5;
color: #4e5969;
}
&--success {
background: #f6ffed;
color: #389e0d;
}
&--error {
background: #fff2f0;
color: #cf1322;
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,7 @@
<!-- 基本信息 --> <!-- 基本信息 -->
<wd-cell-group title="基本信息" border> <wd-cell-group title="基本信息" border>
<wd-cell title="采购单编号" :value="formData.no" /> <wd-cell title="采购单编号" :value="formData.no" />
<wd-cell title="扫码识别值" :value="formData.no || '-'" />
<wd-cell title="采购状态"> <wd-cell title="采购状态">
<view <view
class="rounded-8rpx px-16rpx py-4rpx text-24rpx" class="rounded-8rpx px-16rpx py-4rpx text-24rpx"

View File

@@ -261,6 +261,7 @@ import { createPurchaseOrder, getPurchaseOrder, updatePurchaseOrder } from '@/ap
import { getProductSimpleList } from '@/api/erp/product' import { getProductSimpleList } from '@/api/erp/product'
import { getSupplierSimpleList } from '@/api/erp/supplier' import { getSupplierSimpleList } from '@/api/erp/supplier'
import { getPurchaseRequisition, getPurchaseRequisitionPage } from '@/api/erp/purchase-requisition' import { getPurchaseRequisition, getPurchaseRequisitionPage } from '@/api/erp/purchase-requisition'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -318,14 +319,8 @@ function onSupplierConfirm({ value }: any) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateVal?: string | number) { function formatDate(dateVal?: string | number | Date) {
if (!dateVal) return '-' return formatDateValue(dateVal) || '-'
if (typeof dateVal === 'number') {
const d = new Date(dateVal)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return String(dateVal).substring(0, 10)
} }
/** 打开请购单选择弹窗 */ /** 打开请购单选择弹窗 */

View File

@@ -182,6 +182,7 @@ import {
updatePurchaseRequisitionStatus, updatePurchaseRequisitionStatus,
} from '@/api/erp/purchase-requisition' } from '@/api/erp/purchase-requisition'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -276,15 +277,13 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 格式化日期时间 */ /** 格式化日期时间 */
function formatDateTime(dateStr?: string) { function formatDateTime(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr, 'YYYY-MM-DD HH:mm') || '-'
return dateStr.substring(0, 16).replace('T', ' ')
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -233,6 +233,7 @@ import {
REQUISITION_TYPE_OPTIONS, REQUISITION_TYPE_OPTIONS,
updatePurchaseRequisition, updatePurchaseRequisition,
} from '@/api/erp/purchase-requisition' } from '@/api/erp/purchase-requisition'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -347,14 +348,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
if (typeof dateStr === 'number') {
const d = new Date(dateStr)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -219,6 +219,7 @@ import {
updatePurchaseRequisitionStatus, updatePurchaseRequisitionStatus,
} from '@/api/erp/purchase-requisition' } from '@/api/erp/purchase-requisition'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils' import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({ definePage({
@@ -359,9 +360,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -0,0 +1,554 @@
<template>
<view class="yd-page-container">
<!-- 顶部导航栏 -->
<wd-navbar
:title="detail?.status === 20 ? '出库单详情' : '编辑出库单'"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="handleBack"
/>
<!-- 主内容区 -->
<view class="page-content">
<!-- 顶部状态卡 -->
<view class="status-card">
<view class="status-card__left">
<view class="status-card__no">{{ detail?.no || '-' }}</view>
<view class="status-card__meta">
<text>{{ formatDate(detail?.outTime) }}</text>
<text>·</text>
<text>{{ detail?.customerName || '-' }}</text>
</view>
</view>
<view class="status-card__right">
<view
class="status-card__badge"
:class="detail?.status === 20 ? 'badge--success' : 'badge--warning'"
>
{{ detail?.status === 20 ? '已审核' : '未审核' }}
</view>
</view>
</view>
<!-- 基本信息 -->
<view class="section">
<view class="section__title">基本信息</view>
<view class="info-grid">
<view class="info-grid__item">
<text class="info-grid__label">客户</text>
<text class="info-grid__value">{{ detail?.customerName || '-' }}</text>
</view>
<view class="info-grid__item">
<text class="info-grid__label">销售员</text>
<text class="info-grid__value">{{ detail?.saleUserName || '-' }}</text>
</view>
<view class="info-grid__item" v-if="detail?.orderNo">
<text class="info-grid__label">关联订单</text>
<text class="info-grid__value text-[#1890ff]">{{ detail?.orderNo }}</text>
</view>
<view class="info-grid__item" v-if="detail?.deliveryNoticeNo">
<text class="info-grid__label">发货通知单</text>
<text class="info-grid__value text-[#1890ff]">{{ detail?.deliveryNoticeNo }}</text>
</view>
<view class="info-grid__item" v-if="detail?.accountName">
<text class="info-grid__label">结算账户</text>
<text class="info-grid__value">{{ detail?.accountName }}</text>
</view>
<view class="info-grid__item" v-if="detail?.remark">
<text class="info-grid__label">备注</text>
<text class="info-grid__value">{{ detail?.remark }}</text>
</view>
</view>
</view>
<!-- 产品明细 -->
<view class="section">
<view class="section__title">出库明细 {{ items.length }} </view>
<view class="item-list">
<view v-for="(item, index) in items" :key="index" class="item-card">
<view class="item-card__header">
<text class="item-card__name">{{ item.productName || '-' }}</text>
<text class="item-card__count">x{{ formatCount(item.count) }}</text>
</view>
<view class="item-card__body">
<view class="item-card__row">
<text class="item-card__label">规格</text>
<text class="item-card__value">{{ item.productSpec || '-' }}</text>
</view>
<view class="item-card__row" v-if="item.warehouseName">
<text class="item-card__label">仓库</text>
<text class="item-card__value">{{ item.warehouseName }}</text>
</view>
<view class="item-card__row" v-if="item.locationCode">
<text class="item-card__label">库位</text>
<text class="item-card__value text-[#52c41a]">{{ item.locationCode }}</text>
</view>
<view class="item-card__row" v-if="item.batchNo">
<text class="item-card__label">批次号</text>
<text class="item-card__value">{{ item.batchNo }}</text>
</view>
<view class="item-card__row">
<text class="item-card__label">单价</text>
<text class="item-card__value">¥{{ formatPrice(item.productPrice) }}</text>
</view>
<view class="item-card__row">
<text class="item-card__label">金额</text>
<text class="item-card__value text-[#f5222d] font-semibold">¥{{ formatPrice(item.totalPrice) }}</text>
</view>
</view>
</view>
<view v-if="items.length === 0" class="item-empty">暂无产品明细</view>
</view>
</view>
<!-- 金额汇总 -->
<view class="section">
<view class="section__title">金额汇总</view>
<view class="price-summary">
<view class="price-summary__row">
<text>总数量</text>
<text class="font-semibold">{{ formatCount(detail?.totalCount) }}</text>
</view>
<view class="price-summary__row">
<text>产品金额</text>
<text>¥{{ formatPrice(detail?.totalProductPrice) }}</text>
</view>
<view class="price-summary__row" v-if="detail?.discountPercent">
<text>优惠率</text>
<text>{{ detail?.discountPercent }}%</text>
</view>
<view class="price-summary__row" v-if="detail?.discountPrice">
<text>收款优惠</text>
<text class="text-[#52c41a]">-¥{{ formatPrice(detail?.discountPrice) }}</text>
</view>
<view class="price-summary__row" v-if="detail?.otherPrice">
<text>其它费用</text>
<text class="text-[#fa8c16]">+¥{{ formatPrice(detail?.otherPrice) }}</text>
</view>
<view class="price-summary__divider" />
<view class="price-summary__row price-summary__row--highlight">
<text>应收金额</text>
<text class="text-[#f5222d] font-bold text-36rpx">¥{{ formatPrice(detail?.totalPrice) }}</text>
</view>
<view class="price-summary__row">
<text>已收金额</text>
<text :class="receiptStatus === 2 ? 'text-[#52c41a]' : 'text-[#f5222d]'">
¥{{ formatPrice(detail?.receiptPrice) }}
</text>
</view>
<view class="price-summary__row" v-if="receiptStatus !== 2">
<text>未收金额</text>
<text class="text-[#f5222d] font-semibold">
¥{{ formatPrice((detail?.totalPrice || 0) - (detail?.receiptPrice || 0)) }}
</text>
</view>
<view class="price-summary__status">
<wd-tag :type="receiptStatus === 2 ? 'success' : receiptStatus === 1 ? 'warning' : 'danger'" plain>
{{ receiptStatusText }}
</wd-tag>
</view>
</view>
</view>
<!-- 操作日志 -->
<view class="section" v-if="detail?.createTime || detail?.creatorName">
<view class="section__title">操作信息</view>
<view class="info-grid">
<view class="info-grid__item" v-if="detail?.creatorName">
<text class="info-grid__label">创建人</text>
<text class="info-grid__value">{{ detail?.creatorName }}</text>
</view>
<view class="info-grid__item" v-if="detail?.createTime">
<text class="info-grid__label">创建时间</text>
<text class="info-grid__value">{{ formatDate(detail?.createTime) }}</text>
</view>
</view>
</view>
</view>
<!-- 底部操作栏 -->
<view class="bottom-bar">
<wd-button
v-if="detail?.status !== 20"
type="primary"
size="large"
:loading="actionLoading"
@click="handleEdit"
>
编辑
</wd-button>
<wd-button
v-if="detail?.status === 10"
type="success"
size="large"
:loading="actionLoading"
@click="handleApprove"
>
审批
</wd-button>
<wd-button
v-if="detail?.status === 20"
type="warning"
size="large"
plain
:loading="actionLoading"
@click="handleReverseApprove"
>
反审批
</wd-button>
<wd-button
v-if="detail?.status !== 20"
type="error"
size="large"
plain
:loading="actionLoading"
@click="handleDelete"
>
删除
</wd-button>
</view>
</view>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { getSaleOut, updateSaleOutStatus, deleteSaleOut } from '@/api/erp/sale-out'
import { getNavbarHeight, navigateBackPlus } from '@/utils'
import { formatDate as formatDateValue } from '@/utils/date'
const props = defineProps<{ id?: number }>()
const toast = useToast()
const detail = ref<any>(null)
const actionLoading = ref(false)
const items = computed(() => detail.value?.items || [])
const receiptStatus = computed(() => {
const total = detail.value?.totalPrice || 0
const received = detail.value?.receiptPrice || 0
if (total === 0) return 0
if (received >= total) return 2
if (received > 0) return 1
return 0
})
const receiptStatusText = computed(() => {
const status = receiptStatus.value
if (status === 2) return '已结清'
if (status === 1) return '部分收款'
return '未收款'
})
function formatCount(count?: number) {
return count !== undefined && count !== null ? count.toFixed(2) : '0.00'
}
function formatPrice(price?: number) {
return price !== undefined && price !== null ? price.toFixed(2) : '0.00'
}
function formatDate(dateStr?: string | number | Date) {
return formatDateValue(dateStr) || '-'
}
function handleBack() {
navigateBackPlus()
}
function handleEdit() {
uni.navigateTo({ url: `/pages-erp/sale-out/form/index?id=${props.id}` })
}
async function handleApprove() {
uni.showModal({
title: '提示',
content: '确定要审批该出库单吗?',
success: async (res) => {
if (!res.confirm) return
actionLoading.value = true
try {
await updateSaleOutStatus(props.id!, 20)
toast.success('审批成功')
await refreshDetail()
} catch {
toast.error('审批失败')
} finally {
actionLoading.value = false
}
},
})
}
async function handleReverseApprove() {
uni.showModal({
title: '提示',
content: '确定要反审批该出库单吗?',
success: async (res) => {
if (!res.confirm) return
actionLoading.value = true
try {
await updateSaleOutStatus(props.id!, 10)
toast.success('反审批成功')
await refreshDetail()
} catch {
toast.error('反审批失败')
} finally {
actionLoading.value = false
}
},
})
}
async function handleDelete() {
uni.showModal({
title: '提示',
content: '确定要删除该出库单吗?',
success: async (res) => {
if (!res.confirm) return
actionLoading.value = true
try {
await deleteSaleOut([props.id!])
toast.success('删除成功')
navigateBackPlus()
} catch {
toast.error('删除失败')
actionLoading.value = false
}
},
})
}
async function refreshDetail() {
if (props.id) {
detail.value = await getSaleOut(props.id)
}
}
onMounted(async () => {
await refreshDetail()
})
</script>
<style lang="scss" scoped>
.page-content {
padding-top: calc(env(safe-area-inset-top) + 88rpx);
padding-bottom: 180rpx;
}
.status-card {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 32rpx;
background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
color: #fff;
&__left {
flex: 1;
min-width: 0;
}
&__no {
font-size: 36rpx;
font-weight: 700;
margin-bottom: 12rpx;
}
&__meta {
font-size: 24rpx;
opacity: 0.85;
display: flex;
align-items: center;
gap: 8rpx;
}
&__badge {
padding: 8rpx 20rpx;
border-radius: 30rpx;
font-size: 24rpx;
font-weight: 600;
flex-shrink: 0;
}
.badge--success {
background: rgba(255, 255, 255, 0.25);
color: #fff;
}
.badge--warning {
background: rgba(255, 255, 255, 0.25);
color: #fff;
}
}
.section {
margin: 24rpx;
background: #fff;
border-radius: 16rpx;
overflow: hidden;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
&__title {
padding: 24rpx 32rpx;
font-size: 28rpx;
font-weight: 600;
color: #1f2329;
border-bottom: 1rpx solid #f0f0f0;
background: #fafafa;
}
}
.info-grid {
padding: 8rpx 0;
&__item {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 20rpx 32rpx;
border-bottom: 1rpx solid #f9f9f9;
&:last-child {
border-bottom: none;
}
}
&__label {
font-size: 26rpx;
color: #86909c;
flex-shrink: 0;
width: 160rpx;
}
&__value {
font-size: 26rpx;
color: #1f2329;
text-align: right;
flex: 1;
word-break: break-all;
}
}
.item-list {
padding: 0 24rpx;
margin-top: 16rpx;
}
.item-card {
border: 2rpx solid #f0f0f0;
border-radius: 12rpx;
margin-bottom: 16rpx;
overflow: hidden;
&__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 24rpx;
background: #f6f8fa;
border-bottom: 1rpx solid #f0f0f0;
}
&__name {
font-size: 28rpx;
font-weight: 600;
color: #1f2329;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&__count {
font-size: 28rpx;
font-weight: 700;
color: #f5222d;
flex-shrink: 0;
margin-left: 16rpx;
}
&__body {
padding: 16rpx 24rpx;
}
&__row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8rpx 0;
}
&__label {
font-size: 24rpx;
color: #86909c;
flex-shrink: 0;
}
&__value {
font-size: 24rpx;
color: #1f2329;
text-align: right;
}
}
.item-empty {
text-align: center;
padding: 48rpx;
color: #86909c;
font-size: 26rpx;
}
.price-summary {
padding: 24rpx 32rpx;
&__row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 0;
font-size: 26rpx;
color: #4e5969;
&--highlight {
font-size: 28rpx;
color: #1f2329;
margin-top: 8rpx;
}
}
&__divider {
height: 1rpx;
background: #f0f0f0;
margin: 16rpx 0;
}
&__status {
display: flex;
justify-content: flex-end;
margin-top: 12rpx;
}
}
.bottom-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx 32rpx calc(20rpx + env(safe-area-inset-bottom));
background: #fff;
display: flex;
gap: 16rpx;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
:deep(.wd-button) {
flex: 1;
height: 88rpx;
border-radius: 16rpx;
}
}
</style>

View File

@@ -0,0 +1,707 @@
<template>
<view class="yd-page-container">
<!-- 顶部导航栏 -->
<wd-navbar
:title="getTitle"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="handleBack"
/>
<!-- 表单区域 -->
<view>
<wd-form ref="formRef" :model="formData" :rules="formRules">
<wd-cell-group title="基本信息" border>
<wd-cell title="出库单号" title-width="180rpx" center>
<wd-input
v-model="formData.no"
placeholder="不填则自动生成"
:disabled="!!props.id"
/>
</wd-cell>
<wd-cell title="出库时间" title-width="180rpx" prop="outTime" center>
<wd-datetime-picker
v-model="formData.outTime"
type="date"
label=""
placeholder="请选择出库时间"
/>
</wd-cell>
<wd-cell title="关联订单" title-width="180rpx" is-link center @click="openOrderSelect">
<text v-if="formData.orderNo" class="text-[#1890ff]">{{ formData.orderNo }}</text>
<text v-else class="text-[#999]">点击选择销售订单</text>
</wd-cell>
<wd-cell title="发货通知单" title-width="180rpx" center>
<text>{{ formData.deliveryNoticeNo || '-' }}</text>
</wd-cell>
<wd-cell title="客户" title-width="180rpx" center>
<text>{{ getCustomerName() || '-' }}</text>
</wd-cell>
<wd-cell title="销售员" title-width="180rpx" prop="saleUserId" center>
<wd-picker
v-model="formData.saleUserId"
:columns="saleUserColumns"
label=""
placeholder="请选择销售员"
@confirm="onSaleUserConfirm"
/>
</wd-cell>
<wd-textarea
v-model="formData.remark"
label="备注"
label-width="180rpx"
placeholder="请输入备注"
:maxlength="200"
show-word-limit
clearable
/>
</wd-cell-group>
<wd-cell-group title="价格信息" border>
<wd-input
v-model="formData.discountPercent"
label="优惠率(%)"
label-width="180rpx"
type="number"
placeholder="请输入优惠率"
clearable
/>
<wd-cell title="收款优惠" title-width="180rpx" center>
<text>¥{{ formData.discountPrice || 0 }}</text>
</wd-cell>
<wd-input
v-model="formData.otherPrice"
label="其它费用"
label-width="180rpx"
type="number"
placeholder="请输入其它费用"
clearable
/>
<wd-cell title="优惠后金额" title-width="180rpx" center>
<text>¥{{ (formData.totalPrice || 0) - (formData.otherPrice || 0) }}</text>
</wd-cell>
<wd-cell title="结算账户" title-width="180rpx" center>
<wd-picker
v-model="formData.accountId"
:columns="accountColumns"
label=""
placeholder="请选择结算账户"
@confirm="onAccountConfirm"
/>
</wd-cell>
<wd-cell title="应收金额" title-width="180rpx" center>
<text class="text-[#e6a23c] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
</wd-cell>
</wd-cell-group>
</wd-form>
</view>
<!-- 出库明细 -->
<view class="mx-24rpx mt-24rpx pb-180rpx">
<view class="mb-16rpx flex items-center justify-between">
<view class="text-32rpx text-[#333] font-semibold">
出库明细{{ formData.items?.length || 0 }}
</view>
</view>
<view
v-for="(item, index) in formData.items"
:key="index"
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
>
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-12rpx">
<text class="text-28rpx text-[#333] font-semibold">
产品 #{{ index + 1 }} {{ item.productName || '' }}
</text>
<view class="flex gap-12rpx">
<wd-button
v-if="formData.items && formData.items.length > 1"
size="small" type="error" plain @click="handleRemoveItem(index)"
>
删除
</wd-button>
</view>
</view>
<view class="p-24rpx">
<!-- 仓库选择 -->
<view class="mb-16rpx">
<text class="mb-8rpx block text-24rpx text-[#999]">仓库</text>
<wd-picker
v-model="item.warehouseId"
:columns="warehouseColumns"
placeholder="请选择仓库"
@confirm="(e: any) => onItemWarehouseConfirm(e, index)"
/>
</view>
<!-- 库位编码 -->
<view v-if="isLocationEnabled(item.warehouseId)" class="mb-16rpx">
<text class="mb-8rpx block text-24rpx text-[#999]">库位编码</text>
<wd-input
v-model="item.locationCode"
placeholder="库房号-区域-货位号,如 1-A-01"
clearable
/>
</view>
<!-- 批次号 -->
<view class="mb-16rpx">
<text class="mb-8rpx block text-24rpx text-[#999]">批次号</text>
<wd-input
v-model="item.batchNo"
placeholder="请输入批次号"
clearable
/>
</view>
<!-- 自动填充的产品信息只读 -->
<view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
<view class="mb-8rpx flex justify-between text-24rpx">
<text class="text-[#999]">产品名称</text>
<text class="text-[#333]">{{ item.productName || '-' }}</text>
</view>
<view v-if="item.productSpec" class="mb-8rpx flex justify-between text-24rpx">
<text class="text-[#999]">规格</text>
<text class="text-[#333]">{{ item.productSpec }}</text>
</view>
<view class="mb-8rpx flex justify-between text-24rpx">
<text class="text-[#999]">单位</text>
<text class="text-[#333]">{{ item.productUnitName || '-' }}</text>
</view>
<view class="mb-8rpx flex justify-between text-24rpx">
<text class="text-[#999]">条码</text>
<text class="text-[#333]">{{ item.productBarCode || '-' }}</text>
</view>
</view>
<view class="mb-16rpx flex gap-16rpx">
<view class="flex-1">
<text class="mb-8rpx block text-24rpx text-[#999]">数量</text>
<wd-input
v-model="item.count"
type="number"
placeholder="数量"
clearable
/>
</view>
<view class="flex-1">
<text class="mb-8rpx block text-24rpx text-[#999]">单价</text>
<wd-input
v-model="item.productPrice"
type="number"
placeholder="单价"
clearable
/>
</view>
</view>
<view class="mb-16rpx flex gap-16rpx">
<view class="flex-1">
<text class="mb-8rpx block text-24rpx text-[#999]">税率(%)</text>
<wd-input
v-model="item.taxPercent"
type="number"
placeholder="税率"
clearable
/>
</view>
<view class="flex-1">
<text class="mb-8rpx block text-24rpx text-[#999]">金额</text>
<text class="block pt-16rpx text-28rpx text-[#333]">{{ calcTotalPrice(item) }}</text>
</view>
</view>
<view>
<text class="mb-8rpx block text-24rpx text-[#999]">备注</text>
<wd-input
v-model="item.remark"
placeholder="请输入备注"
clearable
/>
</view>
</view>
</view>
<view v-if="!formData.items?.length" class="py-60rpx text-center text-28rpx text-[#999]">
暂无产品请先选择关联订单
</view>
</view>
<!-- 底部保存按钮 -->
<view class="yd-detail-footer">
<wd-button
type="primary"
block
:loading="formLoading"
@click="handleSubmit"
>
保存
</wd-button>
</view>
<!-- 销售订单选择弹窗 -->
<wd-popup v-model="orderSelectVisible" position="right" custom-style="width: 100%; height: 100%;">
<view class="yd-page-container">
<wd-navbar
title="选择销售订单"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="orderSelectVisible = false"
/>
<wd-search
v-model="orderQueryParams.no"
placeholder="搜索订单单号"
@search="getOrderList"
@clear="getOrderList"
/>
<view class="px-24rpx">
<view
v-for="item in orderList"
:key="item.id"
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
:class="{ 'border-2 border-[#1890ff]': selectedOrderId === item.id }"
@click="handleSelectOrder(item)"
>
<view class="p-24rpx">
<view class="mb-12rpx flex items-center justify-between">
<view class="text-30rpx text-[#333] font-semibold">
{{ item.no }}
</view>
<wd-icon v-if="selectedOrderId === item.id" name="check" color="#1890ff" size="40rpx" />
</view>
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">客户</text>
<text>{{ item.customerName || '-' }}</text>
</view>
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">产品</text>
<text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
</view>
<view class="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-12rpx">
<view class="text-center">
<view class="text-28rpx text-[#333] font-semibold">
{{ item.totalCount || 0 }}
</view>
<view class="text-22rpx text-[#999]">
总数量
</view>
</view>
<view class="text-center">
<view class="text-28rpx text-[#1890ff] font-semibold">
{{ item.outCount || 0 }}
</view>
<view class="text-22rpx text-[#999]">
已出库
</view>
</view>
<view class="text-center">
<view class="text-28rpx text-[#e6a23c] font-semibold">
¥{{ item.totalPrice || 0 }}
</view>
<view class="text-22rpx text-[#999]">
金额
</view>
</view>
</view>
</view>
</view>
<view v-if="orderList.length === 0" class="py-100rpx text-center">
<wd-status-tip image="content" tip="暂无可出库订单" />
</view>
<wd-loadmore
v-if="orderList.length > 0"
:state="orderLoadMoreState"
@reload="loadMoreOrders"
/>
</view>
<view class="yd-detail-footer">
<wd-button type="primary" block :disabled="!selectedOrderId" @click="confirmSelectOrder">
确认选择
</wd-button>
</view>
</view>
</wd-popup>
</view>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
import type { SaleOut, SaleOutItem } from '@/api/erp/sale-out'
import type { LoadMoreState } from '@/http/types'
import type { User } from '@/api/system/user'
import { computed, onMounted, ref, watch } from 'vue'
import { useToast } from 'wot-design-uni'
import { createSaleOut, getSaleOut, updateSaleOut } from '@/api/erp/sale-out'
import { getCustomerSimpleList } from '@/api/erp/customer'
import { getSimpleUserList } from '@/api/system/user'
import { navigateBackPlus } from '@/utils'
/** 客户简单信息 */
interface CustomerSimple {
id: number
name: string
}
/** 账户简单信息 */
interface AccountSimple {
id: number
name: string
defaultStatus?: boolean
}
/** 仓库简单信息 */
interface WarehouseSimple {
id: number
name: string
defaultStatus?: boolean
enableLocation?: boolean
}
/** 销售订单 */
interface SaleOrder {
id?: number
no?: string
customerId?: number
customerName?: string
saleUserId?: number
accountId?: number
discountPercent?: number
remark?: string
totalCount?: number
outCount?: number
totalPrice?: number
productNames?: string
items?: any[]
}
const props = defineProps<{
id?: number | any
}>()
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
const toast = useToast()
const getTitle = computed(() => props.id ? '编辑销售出库' : '新增销售出库')
const formLoading = ref(false)
const formData = ref<SaleOut>({
id: undefined,
no: undefined,
customerId: undefined,
accountId: undefined,
saleUserId: undefined,
outTime: new Date().getTime(),
remark: '',
discountPercent: 0,
discountPrice: 0,
otherPrice: 0,
totalPrice: 0,
orderId: undefined,
orderNo: undefined,
deliveryNoticeId: undefined,
deliveryNoticeNo: undefined,
items: [],
})
const formRules = {
outTime: [{ required: true, message: '出库时间不能为空' }],
}
const formRef = ref<FormInstance>()
const customerList = ref<CustomerSimple[]>([])
const accountList = ref<AccountSimple[]>([])
const warehouseList = ref<WarehouseSimple[]>([])
const userList = ref<User[]>([])
const defaultWarehouse = ref<WarehouseSimple>()
// 销售订单选择相关
const orderSelectVisible = ref(false)
const orderList = ref<SaleOrder[]>([])
const orderLoadMoreState = ref<LoadMoreState>('loading')
const orderQueryParams = ref({
pageNo: 1,
pageSize: 10,
no: undefined as string | undefined,
})
const orderTotal = ref(0)
const selectedOrderId = ref<number>()
/** 账户下拉列 */
const accountColumns = computed(() => [
accountList.value.map(a => ({ value: a.id, label: a.name })),
])
/** 仓库下拉列 */
const warehouseColumns = computed(() => [
warehouseList.value.map(w => ({ value: w.id, label: w.name })),
])
/** 销售员下拉列 */
const saleUserColumns = computed(() => [
userList.value.map(u => ({ value: u.id, label: u.nickname })),
])
/** 判断仓库是否启用库位管理 */
function isLocationEnabled(warehouseId?: number): boolean {
if (!warehouseId) return false
const warehouse = warehouseList.value.find(w => w.id === warehouseId)
return warehouse?.enableLocation === true
}
/** 获取客户名称 */
function getCustomerName() {
if (!formData.value.customerId) return ''
const customer = customerList.value.find(c => c.id === formData.value.customerId)
return customer?.name || formData.value.customerName || ''
}
/** 账户选择回调 */
function onAccountConfirm({ value }: any) {
formData.value.accountId = value?.[0]
}
/** 销售员选择回调 */
function onSaleUserConfirm({ value }: any) {
formData.value.saleUserId = value?.[0]
}
/** 行项仓库选择回调 */
function onItemWarehouseConfirm(e: any, index: number) {
if (formData.value.items && formData.value.items[index]) {
const warehouseId = e?.value?.[0] ?? e?.selectedItems?.[0]?.value ?? formData.value.items[index].warehouseId
formData.value.items[index].warehouseId = warehouseId
const warehouse = warehouseList.value.find(w => w.id === warehouseId)
if (warehouse) {
formData.value.items[index].warehouseName = warehouse.name
if (!warehouse.enableLocation) {
formData.value.items[index].locationCode = undefined
}
}
}
}
/** 计算行项金额 */
function calcTotalPrice(item: SaleOutItem) {
if (item.productPrice && item.count) {
const productTotal = Number(item.productPrice) * Number(item.count)
const taxPrice = item.taxPercent ? productTotal * Number(item.taxPercent) / 100 : 0
return `¥${(productTotal + taxPrice).toFixed(2)}`
}
return '-'
}
/** 监听表单数据变化,计算总价 */
watch(
() => formData.value,
(val) => {
if (!val || !val.items) return
val.items.forEach((item) => {
if (item.productPrice && item.count) {
item.totalProductPrice = Number(item.productPrice) * Number(item.count)
item.taxPrice = item.taxPercent ? item.totalProductPrice * Number(item.taxPercent) / 100 : 0
item.totalPrice = item.totalProductPrice + (item.taxPrice || 0)
}
})
const totalPrice = val.items.reduce((prev, curr) => prev + (curr.totalPrice || 0), 0)
const discountPrice = val.discountPercent ? totalPrice * Number(val.discountPercent) / 100 : 0
formData.value.discountPrice = Math.round(discountPrice * 100) / 100
formData.value.totalPrice = Math.round((totalPrice - discountPrice + Number(val.otherPrice || 0)) * 100) / 100
},
{ deep: true },
)
/** 加载下拉列表数据 */
async function loadDropdownData() {
try {
const { http } = await import('@/http/http')
const [customers, accounts, warehouses, users] = await Promise.all([
getCustomerSimpleList(),
http.get<AccountSimple[]>('/erp/account/simple-list'),
http.get<WarehouseSimple[]>('/erp/warehouse/simple-list'),
getSimpleUserList(),
])
customerList.value = customers || []
accountList.value = accounts || []
warehouseList.value = warehouses || []
userList.value = users || []
// 设置默认账户
const defaultAccount = accountList.value.find(a => a.defaultStatus)
if (defaultAccount && !formData.value.accountId) {
formData.value.accountId = defaultAccount.id
}
// 设置默认仓库
defaultWarehouse.value = warehouseList.value.find(w => w.defaultStatus)
} catch {
// error handled by http
}
}
/** 返回上一页 */
function handleBack() {
navigateBackPlus('/pages-erp/sale-out/index')
}
/** 删除出库明细行 */
function handleRemoveItem(index: number) {
uni.showModal({
title: '提示',
content: `确定要删除第 ${index + 1} 项产品吗?`,
success: (res) => {
if (res.confirm) {
formData.value.items?.splice(index, 1)
}
},
})
}
/** 打开订单选择弹窗 */
function openOrderSelect() {
orderSelectVisible.value = true
orderQueryParams.value.pageNo = 1
orderList.value = []
selectedOrderId.value = formData.value.orderId
getOrderList()
}
/** 获取可出库订单列表 */
async function getOrderList() {
orderLoadMoreState.value = 'loading'
try {
const { http } = await import('@/http/http')
const data = await http.get<{ list: SaleOrder[]; total: number }>('/erp/sale-order/out-enable-page', {
pageNo: orderQueryParams.value.pageNo,
pageSize: orderQueryParams.value.pageSize,
no: orderQueryParams.value.no,
})
if (orderQueryParams.value.pageNo === 1) {
orderList.value = data.list || []
} else {
orderList.value = [...orderList.value, ...(data.list || [])]
}
orderTotal.value = data.total || 0
orderLoadMoreState.value = orderList.value.length >= orderTotal.value ? 'finished' : 'loading'
} catch {
orderLoadMoreState.value = 'error'
}
}
/** 加载更多订单 */
function loadMoreOrders() {
if (orderLoadMoreState.value === 'finished') return
orderQueryParams.value.pageNo++
getOrderList()
}
/** 选择订单 */
function handleSelectOrder(item: SaleOrder) {
selectedOrderId.value = item.id
}
/** 确认选择订单 */
async function confirmSelectOrder() {
if (!selectedOrderId.value) return
try {
toast.loading('加载订单详情...')
const { http } = await import('@/http/http')
const orderDetail = await http.get<SaleOrder>(`/erp/sale-order/get?id=${selectedOrderId.value}`)
// 设置订单信息
formData.value.orderId = orderDetail.id
formData.value.orderNo = orderDetail.no
formData.value.deliveryNoticeId = undefined
formData.value.deliveryNoticeNo = undefined
formData.value.customerId = orderDetail.customerId
formData.value.accountId = orderDetail.accountId
formData.value.saleUserId = orderDetail.saleUserId
formData.value.discountPercent = orderDetail.discountPercent
formData.value.remark = orderDetail.remark
// 设置出库明细
if (orderDetail.items) {
formData.value.items = orderDetail.items
.filter((item: any) => (item.count || 0) - (item.outCount || 0) > 0)
.map((item: any) => ({
productId: item.productId,
productName: item.productName,
productUnitId: item.productUnitId,
productUnitName: item.productUnitName,
productPrice: item.productPrice ?? item.salePrice ?? 0,
productSpec: item.productSpec,
productBarCode: item.productBarCode,
count: (item.count || 0) - (item.outCount || 0),
totalCount: item.count,
outCount: item.outCount,
taxPercent: item.taxPercent,
warehouseId: defaultWarehouse.value?.id,
warehouseName: defaultWarehouse.value?.name,
orderItemId: item.id,
remark: item.remark,
}))
}
orderSelectVisible.value = false
} finally {
toast.close()
}
}
/** 加载详情 */
async function getDetail() {
if (!props.id) return
try {
toast.loading('加载中...')
formData.value = await getSaleOut(props.id)
formData.value.outTime = typeof formData.value.outTime === 'string'
? new Date(formData.value.outTime).getTime()
: formData.value.outTime
} finally {
toast.close()
}
}
/** 提交表单 */
async function handleSubmit() {
const { valid } = await formRef.value!.validate()
if (!valid) return
// 校验出库明细
if (!formData.value.items || formData.value.items.length === 0) {
toast.warning('请至少添加一项出库产品')
return
}
for (let i = 0; i < formData.value.items.length; i++) {
const item = formData.value.items[i]
if (!item.count || Number(item.count) <= 0) {
toast.warning(`${i + 1} 项产品数量不能为空`)
return
}
}
formLoading.value = true
try {
const submitData = {
...formData.value,
items: formData.value.items?.map(item => ({
...item,
productPrice: Number(item.productPrice ?? 0),
count: Number(item.count ?? 0),
})),
}
if (props.id) {
await updateSaleOut(submitData)
toast.success('修改成功')
} else {
await createSaleOut(submitData)
toast.success('新增成功')
}
setTimeout(() => {
handleBack()
}, 500)
} finally {
formLoading.value = false
}
}
/** 初始化 */
onMounted(async () => {
await loadDropdownData()
getDetail()
})
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,408 @@
<template>
<view class="yd-page-container">
<!-- 顶部导航栏 -->
<wd-navbar
title="销售出库"
left-arrow placeholder safe-area-inset-top fixed
@click-left="handleBack"
/>
<!-- 搜索组件 -->
<view @click="searchVisible = true">
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
</view>
<!-- 快捷筛选标签 -->
<view class="mx-24rpx mb-16rpx flex items-center overflow-hidden rounded-12rpx bg-white shadow-sm">
<view
v-for="tab in statusTabs"
:key="tab.value"
class="relative flex-1 py-20rpx text-center text-26rpx"
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
@click="onTabChange(tab.value)"
>
{{ tab.label }}
<view
v-if="queryParams.status === tab.value"
class="absolute bottom-0 left-1/4 h-4rpx w-1/2 rounded-2rpx bg-[#1890ff]"
/>
</view>
</view>
<!-- 出库单列表 -->
<view class="px-24rpx">
<view
v-for="item in list"
:key="item.id"
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
@click="handleDetail(item)"
>
<view class="p-24rpx">
<!-- 头部单号 + 状态 -->
<view class="mb-16rpx flex items-center justify-between">
<view class="text-28rpx text-[#333] font-semibold">
{{ item.no || '-' }}
</view>
<view
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
:class="item.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
>
{{ item.status === 20 ? '已审核' : '未审核' }}
</view>
</view>
<!-- 客户 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">客户</text>
<text>{{ item.customerName || '-' }}</text>
</view>
<!-- 订单号 -->
<view v-if="item.orderNo" class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">订单</text>
<text>{{ item.orderNo }}</text>
</view>
<!-- 产品 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">产品</text>
<text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
</view>
<!-- 数量金额区域 -->
<view class="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-16rpx">
<view class="text-center">
<view class="text-32rpx text-[#333] font-semibold">
{{ formatCount(item.totalCount) }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
数量
</view>
</view>
<view class="text-center">
<view class="text-32rpx text-[#f5222d] font-semibold">
{{ formatPrice(item.totalPrice) }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
金额
</view>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
<wd-button
v-if="hasAccessByCodes(['erp:sale-out:query'])"
size="small" type="warning" plain @click="handleScanOut(item)"
>
扫码出库
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-out:update']) && item.status !== 20"
size="small" type="primary" plain @click="handleEdit(item)"
>
编辑
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-out:update-status']) && item.status === 10"
size="small" type="success" plain @click="handleApprove(item.id!)"
>
审批
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-out:update-status']) && item.status === 20"
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
>
反审批
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-out:delete']) && item.status !== 20"
size="small" type="error" plain @click="handleDelete(item.id!)"
>
删除
</wd-button>
</view>
</view>
<!-- 加载更多 -->
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
<wd-status-tip image="content" tip="暂无销售出库单数据" />
</view>
<wd-loadmore
v-if="list.length > 0"
:state="loadMoreState"
@reload="loadMore"
/>
</view>
<!-- 搜索弹窗 -->
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
<view class="yd-search-form-item">
<view class="yd-search-form-label">
出库单号
</view>
<wd-input v-model="searchForm.no" placeholder="请输入出库单号" clearable />
</view>
<view class="yd-search-form-item">
<view class="yd-search-form-label">
审核状态
</view>
<view class="yd-search-form-radio-group">
<view
v-for="opt in statusOptions"
:key="opt.value"
class="yd-search-form-radio"
:class="{ 'yd-search-form-radio--active': searchForm.status === opt.value }"
@click="searchForm.status = opt.value"
>
{{ opt.label }}
</view>
</view>
</view>
<view class="yd-search-form-actions">
<wd-button class="flex-1" plain @click="handleReset">
重置
</wd-button>
<wd-button class="flex-1" type="primary" @click="handleSearch">
搜索
</wd-button>
</view>
</view>
</wd-popup>
</view>
</template>
<script lang="ts" setup>
import type { SaleOut } from '@/api/erp/sale-out'
import type { LoadMoreState } from '@/http/types'
import { onReachBottom } from '@dcloudio/uni-app'
import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { deleteSaleOut, getSaleOutPage, updateSaleOutStatus } from '@/api/erp/sale-out'
import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
const { hasAccessByCodes } = useAccess()
const toast = useToast()
const total = ref(0)
const list = ref<SaleOut[]>([])
const loadMoreState = ref<LoadMoreState>('loading')
const queryParams = ref<Record<string, any>>({
pageNo: 1,
pageSize: 10,
status: undefined,
})
// 搜索相关
const searchVisible = ref(false)
const searchForm = reactive({
no: undefined as string | undefined,
status: undefined as number | undefined,
})
/** 状态标签 */
const statusTabs = [
{ value: undefined, label: '全部' },
{ value: 10, label: '未审核' },
{ value: 20, label: '已审核' },
]
/** 状态选项 */
const statusOptions = [
{ value: undefined, label: '全部' },
{ value: 10, label: '未审核' },
{ value: 20, label: '已审核' },
]
/** 搜索条件 placeholder */
const searchPlaceholder = computed(() => {
const conditions: string[] = []
if (searchForm.no)
conditions.push(`单号:${searchForm.no}`)
if (searchForm.status !== undefined) {
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
if (statusLabel && statusLabel !== '全部')
conditions.push(`状态:${statusLabel}`)
}
return conditions.length > 0 ? conditions.join(' | ') : '搜索销售出库单'
})
/** 格式化数量 */
function formatCount(count?: number) {
if (count === undefined || count === null)
return '-'
return count.toFixed(2)
}
/** 格式化金额 */
function formatPrice(price?: number) {
if (price === undefined || price === null)
return '-'
return `¥${price.toFixed(2)}`
}
/** 格式化日期 */
function formatDate(dateStr?: string | number | Date) {
return formatDateValue(dateStr) || '-'
}
/** 返回上一页 */
function handleBack() {
navigateBackPlus()
}
/** 切换状态标签 */
function onTabChange(status: number | undefined) {
queryParams.value.status = status
list.value = []
queryParams.value.pageNo = 1
getList()
}
/** 查询出库单列表 */
async function getList() {
loadMoreState.value = 'loading'
try {
const params = { ...queryParams.value }
if (searchForm.no)
params.no = searchForm.no
const data = await getSaleOutPage(params)
list.value = [...list.value, ...data.list]
total.value = data.total
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
} catch {
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
loadMoreState.value = 'error'
}
}
/** 搜索 */
function handleSearch() {
searchVisible.value = false
queryParams.value = {
pageNo: 1,
pageSize: queryParams.value.pageSize,
status: searchForm.status,
}
list.value = []
getList()
}
/** 重置 */
function handleReset() {
searchForm.no = undefined
searchForm.status = undefined
searchVisible.value = false
queryParams.value = { pageNo: 1, pageSize: 10, status: undefined }
list.value = []
getList()
}
/** 加载更多 */
function loadMore() {
if (loadMoreState.value === 'finished')
return
queryParams.value.pageNo++
getList()
}
/** 编辑 */
function handleEdit(item: SaleOut) {
// TODO: 跳转到编辑页
uni.navigateTo({ url: `/pages-erp/sale-out/form/index?id=${item.id}` })
}
/** 扫码出库 */
function handleScanOut(item: SaleOut) {
uni.navigateTo({
url: `/pages-erp/sale-out/scan-out/index?id=${item.id}&no=${encodeURIComponent(item.no || '')}`,
})
}
/** 详情 */
function handleDetail(item: SaleOut) {
uni.navigateTo({ url: `/pages-erp/sale-out/detail/index?id=${item.id}` })
}
/** 审批 */
function handleApprove(id: number) {
uni.showModal({
title: '提示',
content: '确定要审批该出库单吗?',
success: async (res) => {
if (!res.confirm)
return
try {
await updateSaleOutStatus(id, 20)
toast.success('审批成功')
refreshList()
} catch {
// error handled by http
}
},
})
}
/** 反审批 */
function handleReverseApprove(id: number) {
uni.showModal({
title: '提示',
content: '确定要反审批该出库单吗?',
success: async (res) => {
if (!res.confirm)
return
try {
await updateSaleOutStatus(id, 10)
toast.success('反审批成功')
refreshList()
} catch {
// error handled by http
}
},
})
}
/** 删除 */
function handleDelete(id: number) {
uni.showModal({
title: '提示',
content: '确定要删除该出库单吗?',
success: async (res) => {
if (!res.confirm)
return
try {
await deleteSaleOut([id])
toast.success('删除成功')
refreshList()
} catch {
// error handled by http
}
},
})
}
/** 刷新列表 */
function refreshList() {
list.value = []
queryParams.value.pageNo = 1
getList()
}
/** 触底加载更多 */
onReachBottom(() => {
loadMore()
})
/** 初始化 */
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,136 @@
<template>
<view class="recent-scan-list">
<view v-if="records.length === 0" class="recent-scan-list__empty">
暂无扫码记录
</view>
<view
v-for="(record, index) in records"
:key="record.id || index"
class="recent-scan-item"
:class="{ 'recent-scan-item--new': index === latestIndex }"
>
<view class="recent-scan-item__main">
<view class="recent-scan-item__info">
<text class="recent-scan-item__name">{{ record.productName || '-' }}</text>
<text class="recent-scan-item__spec">{{ record.productSpec || '-' }}</text>
</view>
<view class="recent-scan-item__meta">
<text class="recent-scan-item__location">{{ record.locationCode || '-' }}</text>
<text class="recent-scan-item__count">x{{ record.scanCount || 1 }}</text>
</view>
</view>
<view class="recent-scan-item__time">
<text>{{ formatTime(record.scanTime) }}</text>
<text class="recent-scan-item__delete" @tap.stop="$emit('delete', index)">删除</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
defineProps<{
records: any[]
latestIndex?: number
}>()
defineEmits<{
(event: 'delete', index: number): void
}>()
function formatTime(timeStr?: string) {
if (!timeStr) return ''
try {
const d = new Date(timeStr)
return `${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}:${d.getSeconds().toString().padStart(2, '0')}`
} catch {
return ''
}
}
</script>
<style lang="scss" scoped>
.recent-scan-list {
&__empty {
text-align: center;
color: #86909c;
font-size: 24rpx;
padding: 24rpx 0;
}
}
.recent-scan-item {
padding: 16rpx 0;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: none;
}
&--new {
background: #f6ffed;
margin: 0 -24rpx;
padding: 16rpx 24rpx;
border-radius: 12rpx;
border-bottom: none;
}
&__main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12rpx;
margin-bottom: 8rpx;
}
&__info {
display: flex;
flex-direction: column;
gap: 4rpx;
min-width: 0;
flex: 1;
}
&__name {
font-size: 26rpx;
font-weight: 600;
color: #1f2329;
}
&__spec {
font-size: 22rpx;
color: #86909c;
}
&__meta {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 4rpx;
}
&__location {
font-size: 24rpx;
color: #52c41a;
font-weight: 600;
}
&__count {
font-size: 24rpx;
color: #f5222d;
font-weight: 600;
}
&__time {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 20rpx;
color: #86909c;
}
&__delete {
color: #f5222d;
padding: 4rpx 8rpx;
}
}
</style>

View File

@@ -0,0 +1,69 @@
<template>
<view class="scan-context-bar">
<view class="scan-context-bar__main">
<view class="scan-context-bar__order">
<text class="scan-context-bar__label">出库单</text>
<text class="scan-context-bar__value">{{ saleOutNo || '未关联出库单' }}</text>
</view>
<view class="scan-context-bar__stats">
<text>记录 {{ recordCount }} </text>
<text>累计 {{ scannedCount }} </text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
defineProps<{
saleOutId?: number
saleOutNo?: string
scannedCount: number
recordCount: number
}>()
</script>
<style lang="scss" scoped>
.scan-context-bar {
padding: 20rpx 24rpx;
border-radius: 16rpx;
background: #fff;
margin-bottom: 16rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
&__main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
&__order {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
flex: 1;
}
&__label {
flex-shrink: 0;
color: #86909c;
font-size: 24rpx;
}
&__value {
color: #1f2329;
font-size: 28rpx;
font-weight: 600;
}
&__stats {
display: flex;
gap: 20rpx;
flex-shrink: 0;
color: #1677ff;
font-size: 24rpx;
font-weight: 600;
}
}
</style>

View File

@@ -0,0 +1,43 @@
<template>
<view v-if="message" class="feedback-bar" :class="`feedback-bar--${tone}`">
{{ message }}
</view>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
tone?: 'success' | 'error' | 'idle'
message?: string
}>(),
{
tone: 'idle',
message: '',
},
)
</script>
<style lang="scss" scoped>
.feedback-bar {
min-height: 76rpx;
padding: 18rpx 24rpx;
border-radius: 14rpx;
font-size: 24rpx;
line-height: 40rpx;
&--idle {
background: #f2f3f5;
color: #4e5969;
}
&--success {
background: #f6ffed;
color: #389e0d;
}
&--error {
background: #fff2f0;
color: #cf1322;
}
}
</style>

View File

@@ -0,0 +1,887 @@
<template>
<view class="yd-page-container scan-page">
<wd-navbar
title="扫码出库"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="handleBack"
/>
<view class="scan-page__content">
<!-- 顶部上下文条 -->
<ScanContextBar
:sale-out-id="saleOutId"
:sale-out-no="saleOutNo"
:scanned-count="scannedTotalCount"
:record-count="records.length"
/>
<!-- 扫码工作台 -->
<view class="scan-workbench">
<!-- 当前扫码上下文提示 -->
<view class="scan-panel">
<!-- 步骤指示器库位 产品 -->
<view class="scan-step-indicator">
<view class="scan-step-indicator__item" :class="{ 'active': step === 'idle', 'done': step !== 'idle' }">
<view class="scan-step-indicator__dot">1</view>
<text>扫库位</text>
</view>
<view class="scan-step-indicator__line" :class="{ 'done': step !== 'idle' }" />
<view class="scan-step-indicator__item" :class="{ 'active': step === 'scanned' }">
<view class="scan-step-indicator__dot">2</view>
<text>扫产品</text>
</view>
</view>
<!-- 当前作业提示 -->
<view class="scan-current-hint">
<text v-if="step === 'idle'">请扫描库位条码</text>
<text v-else>产品已出库请继续扫码</text>
</view>
<!-- 库位扫码区 -->
<view class="scan-row" :class="{ 'scan-row--dim': step !== 'idle' }">
<input
v-model="locationCode"
class="scan-field"
:class="{ 'scan-field--active': step === 'idle' }"
placeholder="扫描库位条码"
confirm-type="next"
:focus="locationInputFocus"
:cursor-spacing="20"
:adjust-position="true"
:hold-keyboard="true"
@blur="handleLocationBlur"
@confirm="handleLocationScan"
>
<button class="scan-camera-btn" :disabled="scanLoading" @tap="handleCameraScan('location')">
</button>
</view>
<!-- 库位预览扫库位码后显示 -->
<view class="scan-location-preview" v-if="locationInfo">
<view class="scan-location-preview__row">
<text class="scan-location-preview__label">仓库</text>
<text class="scan-location-preview__value">{{ locationInfo.warehouseName }}</text>
</view>
<view class="scan-location-preview__row">
<text class="scan-location-preview__label">库位</text>
<text class="scan-location-preview__value scan-location-preview__value--code">
{{ locationInfo.locationCode }}
</text>
<text class="scan-location-preview__badge" :class="locationInfo.enableLocation ? 'badge--green' : 'badge--gray'">
{{ locationInfo.enableLocation ? '库位管理' : '无库位管理' }}
</text>
</view>
</view>
<!-- 产品扫码区 -->
<view class="scan-row" :class="{ 'scan-row--dim': step === 'idle' }">
<input
v-model="productBarCode"
class="scan-field"
:class="{ 'scan-field--active': step === 'scanned' }"
placeholder="扫描产品条码"
confirm-type="done"
:focus="productInputFocus"
:cursor-spacing="20"
:adjust-position="true"
:hold-keyboard="true"
@blur="handleProductBlur"
@confirm="handleProductScan"
>
<button class="scan-camera-btn" :disabled="scanLoading" @tap="handleCameraScan('product')">
</button>
</view>
<!-- 产品预览扫产品码后显示 -->
<view class="scan-product-preview" v-if="productPreview">
<view class="scan-product-preview__row">
<text class="scan-product-preview__label">产品</text>
<text class="scan-product-preview__value scan-product-preview__value--name">
{{ productPreview.name }}
</text>
</view>
<view class="scan-product-preview__row">
<text class="scan-product-preview__label">规格</text>
<text class="scan-product-preview__value">{{ productPreview.standard || '-' }}</text>
</view>
<view class="scan-product-preview__row">
<text class="scan-product-preview__label">条码</text>
<text class="scan-product-preview__value">{{ productPreview.barCode || '-' }}</text>
</view>
</view>
<ScanFeedbackBar :tone="feedbackTone" :message="feedbackMessage" />
</view>
<!-- 扫码记录列表 -->
<view class="scan-panel scan-panel--list">
<view class="scan-panel__header">
<view class="scan-panel__title">
扫码记录
</view>
<view class="scan-panel__meta">
{{ records.length }}
</view>
</view>
<RecentScanList
:records="records"
:latest-index="latestRecordIndex"
@delete="handleDeleteRecord"
/>
</view>
<!-- 提交栏 -->
<view class="scan-footer">
<button class="scan-footer__clear" @tap="handleClearAll">
清空记录
</button>
<button class="scan-footer__submit" :loading="submitting" @tap="handleSubmit">
保存出库记录
</button>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import type { ProductByBarCode } from '@/api/erp/product'
import type { LocationByCodeVO } from '@/api/erp/location'
import { computed, nextTick, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { getProductByBarCode } from '@/api/erp/product'
import { getLocationByCode } from '@/api/erp/location'
import { getSaleOut } from '@/api/erp/sale-out'
import { createSaleOutScanRecord, deleteSaleOutScanRecord, getSaleOutScanRecordList } from '@/api/erp/sale-out-scan-record'
import ScanFeedbackBar from '@/pages-erp/sale-out/scan-out/components/scan-feedback-bar.vue'
import RecentScanList from '@/pages-erp/sale-out/scan-out/components/recent-scan-list.vue'
import ScanContextBar from '@/pages-erp/sale-out/scan-out/components/scan-context-bar.vue'
import { navigateBackPlus } from '@/utils'
import { normalizeCameraScanResult, normalizeScanCode } from '@/utils/scan'
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
/** 扫码出库记录 */
export interface ScanRecord {
id?: number
saleOutId: number
productId?: number
productName?: string
productSpec?: string
productBarCode?: string
productUnit?: string
warehouseId?: number
warehouseName?: string
locationCode?: string
batchNo?: string
scanCount: number
scanTime?: string
operatorId?: number
operatorName?: string
}
type Step = 'idle' | 'scanned'
/** 页面参数id=出库单ID, no=出库单号 */
const props = defineProps<{
id?: number
no?: string
}>()
const toast = useToast()
// 页面参数
const saleOutId = ref<number>()
const saleOutNo = ref<string>()
// 扫码步骤
const step = ref<Step>('idle')
// 扫码数据
const locationCode = ref('')
const locationInfo = ref<LocationByCodeVO | null>(null)
const productBarCode = ref('')
const productPreview = ref<ProductByBarCode | null>(null)
const batchNo = ref('')
// 状态
const scanLoading = ref(false)
const submitting = ref(false)
const records = ref<ScanRecord[]>([])
const feedbackTone = ref<'success' | 'error' | 'idle'>('idle')
const feedbackMessage = ref('')
// 输入框焦点控制
const locationInputFocus = ref(false)
const productInputFocus = ref(false)
// 计算属性
const canConfirm = computed(() => {
return locationInfo.value?.warehouseId && productPreview.value?.id && scanLoading.value === false
})
const scannedTotalCount = computed(() =>
records.value.reduce((sum, r) => sum + Number(r.scanCount || 0), 0),
)
const latestRecordIndex = computed(() => {
if (records.value.length === 0) return undefined
return records.value.length - 1
})
/** 返回上一页 */
function handleBack() {
navigateBackPlus('/pages-erp/sale-out/index')
}
/** 初始化页面 */
onMounted(async () => {
if (props.id) saleOutId.value = props.id
if (props.no) saleOutNo.value = decodeURIComponent(props.no)
if (saleOutId.value) {
try {
const data = await getSaleOut(saleOutId.value)
saleOutNo.value = data.no
} catch {
// 忽略
}
await loadRecords()
}
// PDA 扫码枪需要输入框自动获得焦点,延迟确保页面完全渲染
await nextTick()
setTimeout(() => {
focusLocationInput()
}, 500)
})
/** 重置到初始状态 */
function resetToIdle() {
clearScanInputs()
locationInfo.value = null
productPreview.value = null
step.value = 'idle'
// 延迟清空错误 + 聚焦光标,让用户先看到错误提示
setTimeout(() => {
clearFeedback()
focusLocationInput()
}, 800)
}
/** 聚焦库位码输入框 */
function focusLocationInput() {
productInputFocus.value = false
locationInputFocus.value = false
nextTick(() => {
locationInputFocus.value = true
})
}
/** 库位输入框失焦处理 - 如果当前步骤是 idle自动重新聚焦 */
function handleLocationBlur() {
if (step.value === 'idle' && !scanLoading.value) {
setTimeout(() => {
if (step.value === 'idle') {
focusLocationInput()
}
}, 100)
}
}
/** 产品输入框失焦处理 - 如果当前步骤是 scanned自动重新聚焦 */
function handleProductBlur() {
if (step.value === 'scanned' && !scanLoading.value) {
setTimeout(() => {
if (step.value === 'scanned') {
focusProductInput()
}
}, 100)
}
}
/** 加载已有扫码记录 */
async function loadRecords() {
if (!saleOutId.value) return
try {
const data = await getSaleOutScanRecordList(saleOutId.value)
records.value = data || []
} catch {
records.value = []
}
}
/**
* 扫库位码:自动反查仓库信息
*/
async function handleLocationScan() {
const code = normalizeScanCode(locationCode.value)
if (!code) {
setErrorFeedback('请先扫描库位条码')
return
}
scanLoading.value = true
try {
try {
locationInfo.value = await getLocationByCode(code)
} catch {
setErrorFeedback(`库位码 ${code} 不存在`)
resetToIdle()
return
}
if (!locationInfo.value?.warehouseId) {
setErrorFeedback(`库位码 ${code} 未找到对应仓库`)
resetToIdle()
return
}
locationCode.value = code
step.value = 'scanned'
productBarCode.value = ''
productPreview.value = null
batchNo.value = ''
clearFeedback()
// 聚焦产品输入框,等待扫码枪输入
focusProductInput()
} finally {
scanLoading.value = false
}
}
/** 聚焦产品码输入框 */
function focusProductInput() {
locationInputFocus.value = false
productInputFocus.value = false
nextTick(() => {
productInputFocus.value = true
})
}
/**
* 扫产品码:自动反查产品信息
*/
async function handleProductScan() {
const code = normalizeScanCode(productBarCode.value)
if (!code) {
setErrorFeedback('请先扫描产品条码')
return
}
if (!locationInfo.value) {
setErrorFeedback('请先扫描库位条码')
step.value = 'idle'
return
}
scanLoading.value = true
try {
try {
productPreview.value = await getProductByBarCode(code)
} catch {
setErrorFeedback(`条码 ${code} 未匹配到产品`)
resetToIdle()
return
}
if (!productPreview.value?.id) {
setErrorFeedback(`条码 ${code} 未匹配到产品`)
resetToIdle()
return
}
productBarCode.value = code
step.value = 'scanned'
clearFeedback()
// 自动确认出库
nextTick(() => handleConfirm())
} finally {
scanLoading.value = false
}
}
/**
* 确认出库
*/
async function handleConfirm() {
if (!canConfirm.value) return
scanLoading.value = true
try {
const record: ScanRecord = {
saleOutId: saleOutId.value || 0,
productId: productPreview.value!.id,
productName: productPreview.value!.name,
productSpec: productPreview.value!.standard,
productBarCode: productPreview.value!.barCode,
productUnit: productPreview.value!.unitName,
warehouseId: locationInfo.value!.warehouseId,
warehouseName: locationInfo.value!.warehouseName,
locationCode: locationInfo.value!.locationCode,
batchNo: batchNo.value.trim() || undefined,
scanCount: 1,
scanTime: new Date().toISOString(),
}
// 提交到后端
try {
const newId = await createSaleOutScanRecord(record)
record.id = newId
} catch {
record.id = Date.now()
}
// 追加到列表
records.value.push(record)
// 重置,准备下一次扫码
const productName = productPreview.value!.name
const locationCodeText = locationInfo.value!.locationCode
clearScanInputs()
step.value = 'idle'
setSuccessFeedback(`${productName}${locationCodeText} 出库成功`)
await nextTick()
// 聚焦库位输入框,等待扫码枪输入
focusLocationInput()
} finally {
scanLoading.value = false
}
}
/** 相机扫码 */
function handleCameraScan(target: 'location' | 'product') {
if (scanLoading.value) return
// #ifdef APP-PLUS
plus.android.requestPermissions(
['android.permission.CAMERA'],
function(result) {
const granted = result.granted
if (granted && granted.length > 0) {
doScan(target)
} else {
toast.error('请在设置中开启相机权限')
uni.openSetting()
}
},
function() {
toast.error('相机权限获取失败')
},
)
// #endif
// #ifndef APP-PLUS
doScan(target)
// #endif
}
function doScan(target: 'location' | 'product') {
uni.scanCode({
onlyFromCamera: true,
success: async (result) => {
const code = normalizeCameraScanResult(result)
if (!code) return
if (target === 'location') {
locationCode.value = code
await handleLocationScan()
} else {
productBarCode.value = code
await handleProductScan()
}
},
fail: (error) => {
if (String(error?.errMsg || '').includes('cancel')) return
toast.error('相机扫码失败,请重试')
},
})
}
/** 删除单条记录 */
async function handleDeleteRecord(index: number) {
const record = records.value[index]
if (!record) return
if (record.id && record.id > 0 && record.id < 1000000000000) {
try {
await deleteSaleOutScanRecord(record.id)
} catch {
toast.error('删除失败')
return
}
}
records.value.splice(index, 1)
}
/** 清空所有记录 */
function handleClearAll() {
if (records.value.length === 0) return
uni.showModal({
title: '确认清空',
content: '确定要清空所有扫码记录吗?',
success: async (res) => {
if (!res.confirm) return
const toDelete = records.value.filter(r => r.id && r.id > 0 && r.id < 1000000000000)
for (const r of toDelete) {
try { await deleteSaleOutScanRecord(r.id!) } catch { /* ignore */ }
}
records.value = []
clearFeedback()
},
})
}
/** 保存出库记录 */
async function handleSubmit() {
if (records.value.length === 0) {
toast.warning('暂无扫码记录')
return
}
if (!saleOutId.value) {
toast.warning('缺少销售出库单ID')
return
}
submitting.value = true
try {
toast.success(`已保存 ${records.value.length} 条出库记录`)
records.value = []
await loadRecords()
} finally {
submitting.value = false
}
}
/** 清空本次扫码输入 */
function clearScanInputs() {
locationCode.value = ''
locationInfo.value = null
productBarCode.value = ''
productPreview.value = null
batchNo.value = ''
}
function setSuccessFeedback(message: string) {
feedbackTone.value = 'success'
feedbackMessage.value = message
}
function setErrorFeedback(message: string) {
feedbackTone.value = 'error'
feedbackMessage.value = message
}
function clearFeedback() {
feedbackTone.value = 'idle'
feedbackMessage.value = ''
}
</script>
<style lang="scss" scoped>
.scan-page {
background: #f4f6f8;
min-height: 100vh;
&__content {
padding: 24rpx;
padding-top: calc(24rpx + env(safe-area-inset-top) + 88rpx);
box-sizing: border-box;
}
}
.scan-workbench {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.scan-panel {
padding: 24rpx;
border-radius: 18rpx;
background: #fff;
&--list {
padding-bottom: 8rpx;
}
&__header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
margin-bottom: 16rpx;
}
&__title {
color: #1f2329;
font-size: 28rpx;
font-weight: 600;
}
&__meta {
color: #86909c;
font-size: 22rpx;
}
}
// 步骤指示器
.scan-step-indicator {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 24rpx;
&__item {
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
text {
font-size: 22rpx;
color: #86909c;
}
&.active text {
color: #1677ff;
font-weight: 600;
}
&.done text {
color: #52c41a;
}
}
&__dot {
width: 48rpx;
height: 48rpx;
line-height: 48rpx;
border-radius: 50%;
background: #f2f3f5;
color: #86909c;
font-size: 24rpx;
font-weight: 600;
text-align: center;
}
&__item.active &__dot {
background: #1677ff;
color: #fff;
}
&__item.done &__dot {
background: #52c41a;
color: #fff;
}
&__line {
flex: 1;
height: 2rpx;
background: #e5e6eb;
margin: 0 12rpx;
margin-bottom: 28rpx;
max-width: 80rpx;
&.done {
background: #52c41a;
}
}
}
// 当前作业提示
.scan-current-hint {
text-align: center;
font-size: 30rpx;
font-weight: 600;
color: #1f2329;
margin-bottom: 20rpx;
}
// 输入行
.scan-row {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 16rpx;
transition: opacity 0.2s;
&--dim {
opacity: 0.4;
pointer-events: none;
}
.scan-field {
flex: 1;
}
}
.scan-field {
height: 88rpx;
padding: 0 24rpx;
line-height: 88rpx;
border: 2rpx solid #e5e6eb;
border-radius: 14rpx;
background: #f7f8fa;
color: #1f2329;
box-sizing: border-box;
font-size: 28rpx;
&--active {
border-color: #1677ff;
background: #fff;
box-shadow: 0 0 0 4rpx rgba(22, 119, 255, 0.1);
}
}
.scan-camera-btn {
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
border-radius: 14rpx;
background: #1677ff;
color: #fff;
font-size: 26rpx;
font-weight: 600;
padding: 0;
border: none;
flex-shrink: 0;
&:active { opacity: 0.85; }
&[disabled] { background: #d9d9d9; }
}
// 库位预览
.scan-location-preview {
margin-bottom: 16rpx;
padding: 20rpx;
border-radius: 14rpx;
background: #f6fff0;
border: 2rpx solid #b7eb8f;
&__row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6rpx 0;
}
&__label {
color: #4e5969;
font-size: 24rpx;
flex-shrink: 0;
}
&__value {
color: #1f2329;
font-size: 24rpx;
font-weight: 600;
margin-right: 12rpx;
&--code {
color: #52c41a;
font-size: 28rpx;
font-weight: 700;
}
}
&__badge {
padding: 4rpx 12rpx;
border-radius: 8rpx;
font-size: 20rpx;
font-weight: 600;
flex-shrink: 0;
&.badge--green {
background: #f6ffed;
color: #52c41a;
border: 1rpx solid #b7eb8f;
}
&.badge--gray {
background: #f7f8fa;
color: #86909c;
border: 1rpx solid #e5e6eb;
}
}
}
// 产品预览
.scan-product-preview {
margin-bottom: 16rpx;
padding: 20rpx;
border-radius: 14rpx;
background: #f0f5ff;
border: 2rpx solid #adc6ff;
&__row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6rpx 0;
}
&__label {
color: #4e5969;
font-size: 24rpx;
flex-shrink: 0;
}
&__value {
color: #1f2329;
font-size: 24rpx;
text-align: right;
&--name {
font-size: 28rpx;
font-weight: 600;
}
}
}
// 底部栏
.scan-footer {
position: sticky;
bottom: 0;
display: flex;
gap: 16rpx;
padding: 20rpx 0 calc(20rpx + env(safe-area-inset-bottom));
background: #f4f6f8;
&__clear {
flex: 1;
height: 88rpx;
line-height: 88rpx;
border-radius: 16rpx;
background: #fff;
color: #4e5969;
font-size: 28rpx;
border: 2rpx solid #e5e6eb;
}
&__submit {
flex: 2;
height: 88rpx;
line-height: 88rpx;
border-radius: 16rpx;
background: #1677ff;
color: #fff;
font-size: 28rpx;
font-weight: 600;
}
}
</style>

View File

@@ -116,6 +116,7 @@ import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockCheck, getStockCheck, updateStockCheckStatus } from '@/api/erp/stock-check' import { deleteStockCheck, getStockCheck, updateStockCheckStatus } from '@/api/erp/stock-check'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -146,9 +147,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -169,6 +169,7 @@ import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { createStockCheck, getStockCheck, updateStockCheck } from '@/api/erp/stock-check' import { createStockCheck, getStockCheck, updateStockCheck } from '@/api/erp/stock-check'
import { getWarehouseSimpleList } from '@/api/erp/warehouse' import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -240,14 +241,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
if (typeof dateStr === 'number') {
const d = new Date(dateStr)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -164,6 +164,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockCheck, getStockCheckPage, updateStockCheckStatus } from '@/api/erp/stock-check' import { deleteStockCheck, getStockCheckPage, updateStockCheckStatus } from '@/api/erp/stock-check'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils' import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({ definePage({
@@ -229,9 +230,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -104,6 +104,7 @@ import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockGain, getStockGain, updateStockGainStatus } from '@/api/erp/stock-gain' import { deleteStockGain, getStockGain, updateStockGainStatus } from '@/api/erp/stock-gain'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -134,9 +135,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -157,6 +157,7 @@ import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { createStockGain, getStockGain, updateStockGain } from '@/api/erp/stock-gain' import { createStockGain, getStockGain, updateStockGain } from '@/api/erp/stock-gain'
import { getWarehouseSimpleList } from '@/api/erp/warehouse' import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -229,14 +230,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
if (typeof dateStr === 'number') {
const d = new Date(dateStr)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -169,6 +169,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockGain, getStockGainPage, updateStockGainStatus } from '@/api/erp/stock-gain' import { deleteStockGain, getStockGainPage, updateStockGainStatus } from '@/api/erp/stock-gain'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils' import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({ definePage({
@@ -234,9 +235,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -116,6 +116,7 @@ import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockIn, getStockIn, updateStockInStatus } from '@/api/erp/stock-in' import { deleteStockIn, getStockIn, updateStockInStatus } from '@/api/erp/stock-in'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -146,9 +147,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -173,6 +173,7 @@ import { useToast } from 'wot-design-uni'
import { createStockIn, getStockIn, updateStockIn } from '@/api/erp/stock-in' import { createStockIn, getStockIn, updateStockIn } from '@/api/erp/stock-in'
import { getSupplierSimpleList } from '@/api/erp/supplier' import { getSupplierSimpleList } from '@/api/erp/supplier'
import { getWarehouseSimpleList } from '@/api/erp/warehouse' import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -259,14 +260,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
if (typeof dateStr === 'number') {
const d = new Date(dateStr)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -169,6 +169,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockIn, getStockInPage, updateStockInStatus } from '@/api/erp/stock-in' import { deleteStockIn, getStockInPage, updateStockInStatus } from '@/api/erp/stock-in'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils' import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({ definePage({
@@ -234,9 +235,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -0,0 +1,435 @@
<template>
<view class="yd-page-container scan-page">
<wd-navbar
title="扫码其它入库"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="handleBack"
/>
<view class="scan-page__content">
<view class="scan-section">
<view class="scan-section__title">
单据信息
</view>
<picker :range="warehouses" range-key="name" :value="selectedWarehouseIndex" @change="handleWarehouseChange">
<view class="scan-field">
{{ currentWarehouse?.name || '请选择入库仓库' }}
</view>
</picker>
<picker :range="suppliers" range-key="name" :value="selectedSupplierIndex" @change="handleSupplierChange">
<view class="scan-field">
{{ currentSupplierName }}
</view>
</picker>
<input v-model="remark" class="scan-field" placeholder="请输入备注">
</view>
<view class="scan-section">
<view class="scan-section__title">
扫码录入
</view>
<input v-model="batchNo" class="scan-field" placeholder="请输入或扫描批次号(可选)">
<input v-model="locationCode" class="scan-field" placeholder="请输入或扫描库位码(可选)">
<ScanInput
v-model="scanCode"
placeholder="请先选择仓库,再扫描产品条码"
:loading="scanLoading"
:auto-focus="false"
@submit="handleScanSubmit"
@camera-scan="handleCameraScan"
/>
</view>
<view class="scan-section">
<view class="scan-section__title">
入库明细
</view>
<ItemList :items="items" @increase="increaseCount" @decrease="decreaseCount" @remove="removeItem" />
</view>
<SubmitBar :loading="submitting" submit-text="提交其它入库" @submit="handleSubmit" @secondary="clearItems" />
</view>
</view>
</template>
<script setup lang="ts">
import type { ProductByBarCode } from '@/api/erp/product'
import type { StockIn, StockInItem } from '@/api/erp/stock-in'
import type { Warehouse } from '@/api/erp/warehouse'
import type { ItemCardValue } from '@/components/erp-scan/item-list.vue'
import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { getProductByBarCode } from '@/api/erp/product'
import { createStockIn } from '@/api/erp/stock-in'
import { getSupplierSimpleList } from '@/api/erp/supplier'
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import ItemList from '@/components/erp-scan/item-list.vue'
import ScanInput from '@/components/erp-scan/scan-input.vue'
import SubmitBar from '@/components/erp-scan/submit-bar.vue'
import { navigateBackPlus } from '@/utils'
import { buildScanMergeKey, normalizeCameraScanResult, normalizeScanCode } from '@/utils/scan'
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
interface StockInScanItem extends ItemCardValue {
remark?: string
}
interface OptionalSupplierOption {
id?: number
name: string
}
const toast = useToast()
const scanCode = ref('')
const scanLoading = ref(false)
const submitting = ref(false)
const remark = ref('')
const warehouses = ref<Warehouse[]>([])
const suppliers = ref<OptionalSupplierOption[]>([])
const selectedWarehouseId = ref<number>()
const selectedSupplierId = ref<number>()
const items = ref<StockInScanItem[]>([])
const batchNo = ref('')
const locationCode = ref('')
const EMPTY_SUPPLIER_OPTION: OptionalSupplierOption = {
id: undefined,
name: '不选择供应商(可选)',
}
const currentWarehouse = computed(() =>
warehouses.value.find(item => item.id === selectedWarehouseId.value),
)
const currentSupplierName = computed(() => suppliers.value.find(item => item.id === selectedSupplierId.value)?.name || EMPTY_SUPPLIER_OPTION.name)
const selectedWarehouseIndex = computed(() => Math.max(warehouses.value.findIndex(item => item.id === selectedWarehouseId.value), 0))
const selectedSupplierIndex = computed(() => {
const index = suppliers.value.findIndex(item => item.id === selectedSupplierId.value)
return index < 0 ? 0 : index
})
/**
* 功能说明:返回上一页,若没有上一级页面则回到其它入库列表页。
* 适用场景:用户从快捷页返回库存业务列表。
* @return 无
* 注意事项:使用增强返回逻辑,避免页面栈为空时返回失败。
*/
function handleBack() {
navigateBackPlus('/pages-erp/stock-in/index')
}
/**
* 功能说明:加载扫码其它入库页依赖的基础下拉数据。
* 适用场景:页面首次进入时准备仓库和供应商数据。
* @return 无
* 注意事项:默认仓库优先取系统默认仓库,减少仓库人员开始作业前的额外点击。
*/
async function loadInitialData() {
const [warehouseList, supplierList] = await Promise.all([
getWarehouseSimpleList(),
getSupplierSimpleList(),
])
warehouses.value = warehouseList
suppliers.value = [EMPTY_SUPPLIER_OPTION, ...supplierList]
selectedWarehouseId.value = warehouseList.find(item => item.defaultStatus)?.id || warehouseList[0]?.id
}
/**
* 功能说明:切换当前入库仓库。
* 适用场景:操作员选择本次扫码作业仓库。
* @param event picker 事件
* @return 无
* 注意事项:已录入明细不会被自动改仓,避免把历史扫码明细误迁到新仓库。
*/
function handleWarehouseChange(event: Record<string, any>) {
const warehouse = warehouses.value[Number(event.detail.value)]
selectedWarehouseId.value = warehouse?.id
}
/**
* 功能说明:切换当前供应商。
* 适用场景:其它入库单头维护可选供应商。
* @param event picker 事件
* @return 无
* 注意事项:供应商当前不是强校验项,因此仅在存在时传给后端。
*/
function handleSupplierChange(event: Record<string, any>) {
const supplier = suppliers.value[Number(event.detail.value)]
selectedSupplierId.value = supplier?.id
}
/**
* 功能说明:把扫码命中的产品合并到当前入库明细。
* 适用场景:扫码枪连续扫到同一产品时自动累计数量。
* @param product 条码命中的产品
* @return 无
* 注意事项:重复扫码按“仓库 + 产品”合并,避免同一产品刷出多行影响 PDA 作业效率。
*/
function appendScannedProduct(product: ProductByBarCode) {
const warehouseId = selectedWarehouseId.value as number
const currentBatchNo = batchNo.value.trim()
const currentLocationCode = locationCode.value.trim()
const targetKey = buildScanMergeKey({
warehouseId,
productId: product.id,
count: 1,
batchNo: currentBatchNo,
locationCode: currentLocationCode,
}, true)
const existedIndex = items.value.findIndex(item => buildScanMergeKey({
warehouseId: item.warehouseId,
productId: item.productId,
count: item.count,
batchNo: item.batchNo,
locationCode: item.locationCode,
}, true) === targetKey)
if (existedIndex >= 0) {
items.value[existedIndex].count += 1
return
}
items.value.unshift({
warehouseId,
warehouseName: currentWarehouse.value?.name,
productId: product.id,
productName: product.name,
productBarCode: product.barCode,
productSpec: product.standard,
productUnitName: product.unitName,
productPrice: Number(product.minPrice || 0),
batchNo: currentBatchNo,
locationCode: currentLocationCode,
count: 1,
})
}
/**
* 功能说明:处理扫码提交。
* 适用场景:扫码枪回车或用户点击确认按钮。
* @param sourceCode 可选的外部条码输入值
* @return 无
* 注意事项:未选择仓库时直接拦截,避免条码产品被录入到错误仓库上下文。
*/
async function handleScanSubmit(sourceCode?: string) {
if (scanLoading.value) {
return
}
if (!selectedWarehouseId.value) {
toast.error('请先选择仓库')
return
}
const barCode = normalizeScanCode(sourceCode ?? scanCode.value)
if (!barCode) {
toast.error('请先扫描条码')
return
}
scanLoading.value = true
try {
const product = await getProductByBarCode(barCode)
if (!product?.id) {
toast.error('未匹配到启用中的产品')
return
}
appendScannedProduct(product)
scanCode.value = ''
} finally {
scanLoading.value = false
}
}
/**
* 功能说明:触发相机扫码,并将结果接入现有扫码录入流程。
* 适用场景:普通手机没有外接扫码枪时,通过摄像头录入条码。
* @return 无
* 注意事项:扫码取消应静默返回,不应污染当前输入框内容或产生误报。
*/
function handleCameraScan() {
if (scanLoading.value) {
return
}
uni.scanCode({
onlyFromCamera: true,
success: async (result) => {
const barCode = normalizeCameraScanResult(result)
if (!barCode) {
return
}
scanCode.value = barCode
await handleScanSubmit(barCode)
},
fail: (error) => {
// 用户主动取消扫码不属于异常流程,这里静默返回,避免产生干扰提示。
if (String(error?.errMsg || '').includes('cancel')) {
return
}
toast.error('相机扫码失败,请重试')
},
})
}
/**
* 功能说明:增加指定明细数量。
* 适用场景:扫码后人工补正入库数量。
* @param index 明细下标
* @return 无
* 注意事项:其它入库不需要前端库存拦截,只做数量累加。
*/
function increaseCount(index: number) {
items.value[index].count += 1
}
/**
* 功能说明:减少指定明细数量。
* 适用场景:误扫后人工回退数量。
* @param index 明细下标
* @return 无
* 注意事项:数量最低保留 1避免留下 0 数量脏明细。
*/
function decreaseCount(index: number) {
if (items.value[index].count <= 1) {
return
}
items.value[index].count -= 1
}
/**
* 功能说明:删除指定明细。
* 适用场景:误扫错误产品后移除整行。
* @param index 明细下标
* @return 无
* 注意事项:这里只删除当前行,不联动其他已录入产品。
*/
function removeItem(index: number) {
items.value.splice(index, 1)
}
/**
* 功能说明:清空当前录入明细。
* 适用场景:整单作废后重新扫码。
* @return 无
* 注意事项:清空后保留当前仓库和供应商上下文,避免重新开始时重复选择。
*/
function clearItems() {
items.value = []
}
/**
* 功能说明:将页面明细转换成其它入库接口需要的明细结构。
* 适用场景:提交前组装请求体。
* @return 其它入库明细数组
* 注意事项:这里只保留后端真正需要的字段,避免把展示字段一并带入接口契约。
*/
function buildSubmitItems(): StockInItem[] {
return items.value.map(item => ({
warehouseId: item.warehouseId,
locationCode: item.locationCode,
productId: item.productId,
productPrice: item.productPrice,
batchNo: item.batchNo,
count: item.count,
remark: item.remark,
}))
}
/**
* 功能说明:提交扫码其它入库单。
* 适用场景:扫码录入完成后生成正式其它入库单。
* @return 无
* 注意事项:提交失败时保留当前录入数据,方便用户修正后重试。
*/
async function handleSubmit() {
if (submitting.value) {
return
}
if (items.value.length === 0) {
toast.error('请先扫描入库明细')
return
}
submitting.value = true
try {
const payload: StockIn = {
inTime: new Date().toISOString(),
remark: remark.value,
items: buildSubmitItems(),
}
if (selectedSupplierId.value !== undefined) {
payload.supplierId = selectedSupplierId.value
}
await createStockIn(payload)
toast.success('入库成功')
clearItems()
remark.value = ''
batchNo.value = ''
locationCode.value = ''
} finally {
submitting.value = false
}
}
/**
* 功能说明:初始化扫码其它入库页。
* 适用场景:页面首次挂载时准备基础数据。
* @return 无
* 注意事项:初始化失败时由请求封装统一提示,这里不额外重复 toast。
*/
onMounted(async () => {
await loadInitialData()
})
</script>
<style lang="scss" scoped>
.scan-page {
background: #f4f6f8;
&__content {
padding: 24rpx;
}
}
.scan-section {
margin-bottom: 24rpx;
padding: 24rpx;
border-radius: 20rpx;
background: #fff;
&__title {
margin-bottom: 20rpx;
font-size: 30rpx;
font-weight: 600;
color: #1f2329;
}
}
.scan-field {
height: 84rpx;
margin-bottom: 16rpx;
padding: 0 24rpx;
line-height: 84rpx;
border: 2rpx solid #e5e6eb;
border-radius: 12rpx;
background: #f7f8fa;
color: #1f2329;
}
</style>

View File

@@ -104,6 +104,7 @@ import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockLoss, getStockLoss, updateStockLossStatus } from '@/api/erp/stock-loss' import { deleteStockLoss, getStockLoss, updateStockLossStatus } from '@/api/erp/stock-loss'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -134,9 +135,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -157,6 +157,7 @@ import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { createStockLoss, getStockLoss, updateStockLoss } from '@/api/erp/stock-loss' import { createStockLoss, getStockLoss, updateStockLoss } from '@/api/erp/stock-loss'
import { getWarehouseSimpleList } from '@/api/erp/warehouse' import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -229,14 +230,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
if (typeof dateStr === 'number') {
const d = new Date(dateStr)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -169,6 +169,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockLoss, getStockLossPage, updateStockLossStatus } from '@/api/erp/stock-loss' import { deleteStockLoss, getStockLossPage, updateStockLossStatus } from '@/api/erp/stock-loss'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils' import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({ definePage({
@@ -234,9 +235,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -107,6 +107,7 @@ import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockMove, getStockMove, updateStockMoveStatus } from '@/api/erp/stock-move' import { deleteStockMove, getStockMove, updateStockMoveStatus } from '@/api/erp/stock-move'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -137,9 +138,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -166,6 +166,7 @@ import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { createStockMove, getStockMove, updateStockMove } from '@/api/erp/stock-move' import { createStockMove, getStockMove, updateStockMove } from '@/api/erp/stock-move'
import { getWarehouseSimpleList } from '@/api/erp/warehouse' import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -238,14 +239,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
if (typeof dateStr === 'number') {
const d = new Date(dateStr)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -164,6 +164,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockMove, getStockMovePage, updateStockMoveStatus } from '@/api/erp/stock-move' import { deleteStockMove, getStockMovePage, updateStockMoveStatus } from '@/api/erp/stock-move'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils' import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({ definePage({
@@ -229,9 +230,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -12,6 +12,7 @@
<!-- 基本信息 --> <!-- 基本信息 -->
<wd-cell-group title="基本信息" border> <wd-cell-group title="基本信息" border>
<wd-cell title="出库单号" :value="detail.no || '-'" /> <wd-cell title="出库单号" :value="detail.no || '-'" />
<wd-cell title="扫码识别值" :value="detail.no || '-'" />
<wd-cell title="出库时间" :value="formatDate(detail.outTime)" /> <wd-cell title="出库时间" :value="formatDate(detail.outTime)" />
<wd-cell title="客户" :value="detail.customerName || '-'" /> <wd-cell title="客户" :value="detail.customerName || '-'" />
<wd-cell title="审核状态"> <wd-cell title="审核状态">
@@ -78,6 +79,14 @@
<!-- 底部操作按钮 --> <!-- 底部操作按钮 -->
<view class="yd-detail-footer"> <view class="yd-detail-footer">
<wd-button
v-if="hasAccessByCodes(['erp:stock-out:query']) && detail.status !== 20"
type="primary"
plain
@click="handleTaskScan"
>
去扫码
</wd-button>
<wd-button <wd-button
v-if="hasAccessByCodes(['erp:stock-out:update']) && detail.status !== 20" v-if="hasAccessByCodes(['erp:stock-out:update']) && detail.status !== 20"
type="primary" type="primary"
@@ -116,6 +125,7 @@ import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockOut, getStockOut, updateStockOutStatus } from '@/api/erp/stock-out' import { deleteStockOut, getStockOut, updateStockOutStatus } from '@/api/erp/stock-out'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -135,20 +145,23 @@ const detail = ref<StockOut>({})
/** 格式化数量 */ /** 格式化数量 */
function formatCount(count?: number) { function formatCount(count?: number) {
if (count === undefined || count === null) return '-' if (count === undefined || count === null) {
return '-'
}
return count.toFixed(2) return count.toFixed(2)
} }
/** 格式化金额 */ /** 格式化金额 */
function formatPrice(price?: number) { function formatPrice(price?: number) {
if (price === undefined || price === null) return '-' if (price === undefined || price === null) {
return '-'
}
return `¥${price.toFixed(2)}` return `¥${price.toFixed(2)}`
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */
@@ -158,7 +171,9 @@ function handleBack() {
/** 加载详情 */ /** 加载详情 */
async function getDetail() { async function getDetail() {
if (!props.id) return if (!props.id) {
return
}
try { try {
toast.loading('加载中...') toast.loading('加载中...')
detail.value = await getStockOut(props.id) detail.value = await getStockOut(props.id)
@@ -172,13 +187,20 @@ function handleEdit() {
uni.navigateTo({ url: `/pages-erp/stock-out/form/index?id=${props.id}` }) uni.navigateTo({ url: `/pages-erp/stock-out/form/index?id=${props.id}` })
} }
/** 去扫码执行 */
function handleTaskScan() {
uni.navigateTo({ url: `/pages-erp/stock-out/scan/index?id=${props.id}` })
}
/** 审批 */ /** 审批 */
function handleApprove() { function handleApprove() {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定要审批该出库单吗?', content: '确定要审批该出库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm) {
return
}
try { try {
await updateStockOutStatus(props.id, 20) await updateStockOutStatus(props.id, 20)
toast.success('审批成功') toast.success('审批成功')
@@ -196,7 +218,9 @@ function handleReverseApprove() {
title: '提示', title: '提示',
content: '确定要反审批该出库单吗?', content: '确定要反审批该出库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm) {
return
}
try { try {
await updateStockOutStatus(props.id, 10) await updateStockOutStatus(props.id, 10)
toast.success('反审批成功') toast.success('反审批成功')
@@ -214,7 +238,9 @@ function handleDelete() {
title: '提示', title: '提示',
content: '确定要删除该出库单吗?', content: '确定要删除该出库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm) {
return
}
try { try {
await deleteStockOut([props.id]) await deleteStockOut([props.id])
toast.success('删除成功') toast.success('删除成功')

View File

@@ -172,6 +172,7 @@ import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { createStockOut, getStockOut, updateStockOut } from '@/api/erp/stock-out' import { createStockOut, getStockOut, updateStockOut } from '@/api/erp/stock-out'
import { getWarehouseSimpleList } from '@/api/erp/warehouse' import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import { formatDate as formatDateValue } from '@/utils/date'
import { navigateBackPlus } from '@/utils' import { navigateBackPlus } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -258,14 +259,8 @@ function formatPrice(price?: number) {
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
if (typeof dateStr === 'number') {
const d = new Date(dateStr)
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */

View File

@@ -13,18 +13,18 @@
</view> </view>
<!-- 快捷筛选标签 --> <!-- 快捷筛选标签 -->
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm"> <view class="mx-24rpx mb-16rpx flex items-center overflow-hidden rounded-12rpx bg-white shadow-sm">
<view <view
v-for="tab in statusTabs" v-for="tab in statusTabs"
:key="tab.value" :key="tab.value"
class="flex-1 py-20rpx text-center text-26rpx relative" class="relative flex-1 py-20rpx text-center text-26rpx"
:class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'" :class="queryParams.status === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
@click="onTabChange(tab.value)" @click="onTabChange(tab.value)"
> >
{{ tab.label }} {{ tab.label }}
<view <view
v-if="queryParams.status === tab.value" v-if="queryParams.status === tab.value"
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]" class="absolute bottom-0 left-1/4 h-4rpx w-1/2 rounded-2rpx bg-[#1890ff]"
/> />
</view> </view>
</view> </view>
@@ -58,7 +58,7 @@
<!-- 产品 --> <!-- 产品 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">产品</text> <text class="text-[#999]">产品</text>
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text> <text class="line-clamp-1 ml-16rpx text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
</view> </view>
<!-- 出库时间 --> <!-- 出库时间 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]"> <view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
@@ -71,19 +71,33 @@
<text>{{ item.creatorName || '-' }}</text> <text>{{ item.creatorName || '-' }}</text>
</view> </view>
<!-- 数量金额区域 --> <!-- 数量金额区域 -->
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]"> <view class="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-16rpx">
<view class="text-center"> <view class="text-center">
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view> <view class="text-32rpx text-[#333] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">数量</view> {{ formatCount(item.totalCount) }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
数量
</view>
</view> </view>
<view class="text-center"> <view class="text-center">
<view class="text-32rpx text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</view> <view class="text-32rpx text-[#f5222d] font-semibold">
<view class="text-22rpx text-[#999] mt-4rpx">金额</view> {{ formatPrice(item.totalPrice) }}
</view>
<view class="mt-4rpx text-22rpx text-[#999]">
金额
</view>
</view> </view>
</view> </view>
</view> </view>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop> <view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
<wd-button
v-if="hasAccessByCodes(['erp:stock-out:query']) && item.status !== 20"
size="small" type="primary" plain @click="handleTaskScan(item)"
>
去扫码
</wd-button>
<wd-button <wd-button
v-if="hasAccessByCodes(['erp:stock-out:update']) && item.status !== 20" v-if="hasAccessByCodes(['erp:stock-out:update']) && item.status !== 20"
size="small" type="primary" plain @click="handleEdit(item)" size="small" type="primary" plain @click="handleEdit(item)"
@@ -135,11 +149,15 @@
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false"> <wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }"> <view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
<view class="yd-search-form-item"> <view class="yd-search-form-item">
<view class="yd-search-form-label">出库单号</view> <view class="yd-search-form-label">
出库单号
</view>
<wd-input v-model="searchForm.no" placeholder="请输入出库单号" clearable /> <wd-input v-model="searchForm.no" placeholder="请输入出库单号" clearable />
</view> </view>
<view class="yd-search-form-item"> <view class="yd-search-form-item">
<view class="yd-search-form-label">审核状态</view> <view class="yd-search-form-label">
审核状态
</view>
<view class="yd-search-form-radio-group"> <view class="yd-search-form-radio-group">
<view <view
v-for="opt in statusOptions" v-for="opt in statusOptions"
@@ -153,8 +171,12 @@
</view> </view>
</view> </view>
<view class="yd-search-form-actions"> <view class="yd-search-form-actions">
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button> <wd-button class="flex-1" plain @click="handleReset">
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button> 重置
</wd-button>
<wd-button class="flex-1" type="primary" @click="handleSearch">
搜索
</wd-button>
</view> </view>
</view> </view>
</wd-popup> </wd-popup>
@@ -169,6 +191,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni' import { useToast } from 'wot-design-uni'
import { deleteStockOut, getStockOutPage, updateStockOutStatus } from '@/api/erp/stock-out' import { deleteStockOut, getStockOutPage, updateStockOutStatus } from '@/api/erp/stock-out'
import { useAccess } from '@/hooks/useAccess' import { useAccess } from '@/hooks/useAccess'
import { formatDate as formatDateValue } from '@/utils/date'
import { getNavbarHeight, navigateBackPlus } from '@/utils' import { getNavbarHeight, navigateBackPlus } from '@/utils'
definePage({ definePage({
@@ -213,30 +236,33 @@ const statusOptions = [
/** 搜索条件 placeholder */ /** 搜索条件 placeholder */
const searchPlaceholder = computed(() => { const searchPlaceholder = computed(() => {
const conditions: string[] = [] const conditions: string[] = []
if (searchForm.no) conditions.push(`单号:${searchForm.no}`) if (searchForm.no)
conditions.push(`单号:${searchForm.no}`)
if (searchForm.status !== undefined) { if (searchForm.status !== undefined) {
const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label const statusLabel = statusOptions.find(o => o.value === searchForm.status)?.label
if (statusLabel && statusLabel !== '全部') conditions.push(`状态:${statusLabel}`) if (statusLabel && statusLabel !== '全部')
conditions.push(`状态:${statusLabel}`)
} }
return conditions.length > 0 ? conditions.join(' | ') : '搜索出库单' return conditions.length > 0 ? conditions.join(' | ') : '搜索出库单'
}) })
/** 格式化数量 */ /** 格式化数量 */
function formatCount(count?: number) { function formatCount(count?: number) {
if (count === undefined || count === null) return '-' if (count === undefined || count === null)
return '-'
return count.toFixed(2) return count.toFixed(2)
} }
/** 格式化金额 */ /** 格式化金额 */
function formatPrice(price?: number) { function formatPrice(price?: number) {
if (price === undefined || price === null) return '-' if (price === undefined || price === null)
return '-'
return `¥${price.toFixed(2)}` return `¥${price.toFixed(2)}`
} }
/** 格式化日期 */ /** 格式化日期 */
function formatDate(dateStr?: string) { function formatDate(dateStr?: string | number | Date) {
if (!dateStr) return '-' return formatDateValue(dateStr) || '-'
return dateStr.substring(0, 10)
} }
/** 返回上一页 */ /** 返回上一页 */
@@ -257,7 +283,8 @@ async function getList() {
loadMoreState.value = 'loading' loadMoreState.value = 'loading'
try { try {
const params = { ...queryParams.value } const params = { ...queryParams.value }
if (searchForm.no) params.no = searchForm.no if (searchForm.no)
params.no = searchForm.no
const data = await getStockOutPage(params) const data = await getStockOutPage(params)
list.value = [...list.value, ...data.list] list.value = [...list.value, ...data.list]
total.value = data.total total.value = data.total
@@ -292,7 +319,8 @@ function handleReset() {
/** 加载更多 */ /** 加载更多 */
function loadMore() { function loadMore() {
if (loadMoreState.value === 'finished') return if (loadMoreState.value === 'finished')
return
queryParams.value.pageNo++ queryParams.value.pageNo++
getList() getList()
} }
@@ -307,6 +335,11 @@ function handleEdit(item: StockOut) {
uni.navigateTo({ url: `/pages-erp/stock-out/form/index?id=${item.id}` }) uni.navigateTo({ url: `/pages-erp/stock-out/form/index?id=${item.id}` })
} }
/** 去扫码执行 */
function handleTaskScan(item: StockOut) {
uni.navigateTo({ url: `/pages-erp/stock-out/scan/index?id=${item.id}` })
}
/** 详情 */ /** 详情 */
function handleDetail(item: StockOut) { function handleDetail(item: StockOut) {
uni.navigateTo({ url: `/pages-erp/stock-out/detail/index?id=${item.id}` }) uni.navigateTo({ url: `/pages-erp/stock-out/detail/index?id=${item.id}` })
@@ -318,7 +351,8 @@ function handleApprove(id: number) {
title: '提示', title: '提示',
content: '确定要审批该出库单吗?', content: '确定要审批该出库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm)
return
try { try {
await updateStockOutStatus(id, 20) await updateStockOutStatus(id, 20)
toast.success('审批成功') toast.success('审批成功')
@@ -336,7 +370,8 @@ function handleReverseApprove(id: number) {
title: '提示', title: '提示',
content: '确定要反审批该出库单吗?', content: '确定要反审批该出库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm)
return
try { try {
await updateStockOutStatus(id, 10) await updateStockOutStatus(id, 10)
toast.success('反审批成功') toast.success('反审批成功')
@@ -354,7 +389,8 @@ function handleDelete(id: number) {
title: '提示', title: '提示',
content: '确定要删除该出库单吗?', content: '确定要删除该出库单吗?',
success: async (res) => { success: async (res) => {
if (!res.confirm) return if (!res.confirm)
return
try { try {
await deleteStockOut([id]) await deleteStockOut([id])
toast.success('删除成功') toast.success('删除成功')

View File

@@ -0,0 +1,490 @@
<template>
<view class="yd-page-container scan-page">
<wd-navbar
title="扫码其它出库"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="handleBack"
/>
<view class="scan-page__content">
<view class="scan-section">
<view class="scan-section__title">
单据信息
</view>
<picker :range="warehouses" range-key="name" :value="selectedWarehouseIndex" @change="handleWarehouseChange">
<view class="scan-field">
{{ currentWarehouse?.name || '请选择出库仓库' }}
</view>
</picker>
<picker :range="customers" range-key="name" :value="selectedCustomerIndex" @change="handleCustomerChange">
<view class="scan-field">
{{ currentCustomerName }}
</view>
</picker>
<input v-model="remark" class="scan-field" placeholder="请输入备注">
</view>
<view class="scan-section">
<view class="scan-section__title">
扫码录入
</view>
<input v-model="batchNo" class="scan-field" placeholder="请输入或扫描批次号(可选)">
<input v-model="locationCode" class="scan-field" placeholder="请输入或扫描库位码(可选)">
<ScanInput
v-model="scanCode"
placeholder="请先选择仓库,再扫描产品条码"
:loading="scanLoading"
:auto-focus="false"
@submit="handleScanSubmit"
@camera-scan="handleCameraScan"
/>
</view>
<view class="scan-section">
<view class="scan-section__title">
出库明细
</view>
<ItemList :items="items" :show-stock="true" @increase="increaseCount" @decrease="decreaseCount" @remove="removeItem" />
</view>
<SubmitBar :loading="submitting" submit-text="提交其它出库" @submit="handleSubmit" @secondary="clearItems" />
</view>
</view>
</template>
<script setup lang="ts">
import type { ProductByBarCode } from '@/api/erp/product'
import type { Stock } from '@/api/erp/stock'
import type { StockOut, StockOutItem } from '@/api/erp/stock-out'
import type { Warehouse } from '@/api/erp/warehouse'
import type { ItemCardValue } from '@/components/erp-scan/item-list.vue'
import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { getCustomerSimpleList } from '@/api/erp/customer'
import { getProductByBarCode } from '@/api/erp/product'
import { getStock2 } from '@/api/erp/stock'
import { createStockOut } from '@/api/erp/stock-out'
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
import ItemList from '@/components/erp-scan/item-list.vue'
import ScanInput from '@/components/erp-scan/scan-input.vue'
import SubmitBar from '@/components/erp-scan/submit-bar.vue'
import { navigateBackPlus } from '@/utils'
import { buildScanMergeKey, normalizeCameraScanResult, normalizeScanCode } from '@/utils/scan'
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
interface StockOutScanItem extends ItemCardValue {
remark?: string
}
interface OptionalCustomerOption {
id?: number
name: string
}
const toast = useToast()
const scanCode = ref('')
const scanLoading = ref(false)
const submitting = ref(false)
const remark = ref('')
const warehouses = ref<Warehouse[]>([])
const customers = ref<OptionalCustomerOption[]>([])
const selectedWarehouseId = ref<number>()
const selectedCustomerId = ref<number>()
const items = ref<StockOutScanItem[]>([])
const batchNo = ref('')
const locationCode = ref('')
const EMPTY_CUSTOMER_OPTION: OptionalCustomerOption = {
id: undefined,
name: '不选择客户(可选)',
}
const currentWarehouse = computed(() =>
warehouses.value.find(item => item.id === selectedWarehouseId.value),
)
const currentCustomerName = computed(() => customers.value.find(item => item.id === selectedCustomerId.value)?.name || EMPTY_CUSTOMER_OPTION.name)
const selectedWarehouseIndex = computed(() => Math.max(warehouses.value.findIndex(item => item.id === selectedWarehouseId.value), 0))
const selectedCustomerIndex = computed(() => {
const index = customers.value.findIndex(item => item.id === selectedCustomerId.value)
return index < 0 ? 0 : index
})
/**
* 功能说明:返回上一页,若没有上一级页面则回到其它出库列表页。
* 适用场景:用户从快捷页返回库存业务列表。
* @return 无
* 注意事项:使用增强返回逻辑,避免页面栈为空时返回失败。
*/
function handleBack() {
navigateBackPlus('/pages-erp/stock-out/index')
}
/**
* 功能说明:加载扫码其它出库页依赖的基础下拉数据。
* 适用场景:页面首次进入时准备仓库和客户数据。
* @return 无
* 注意事项:默认仓库优先取系统默认仓库,减少开始作业前的额外点击。
*/
async function loadInitialData() {
const [warehouseList, customerList] = await Promise.all([
getWarehouseSimpleList(),
getCustomerSimpleList(),
])
warehouses.value = warehouseList
customers.value = [EMPTY_CUSTOMER_OPTION, ...customerList]
selectedWarehouseId.value = warehouseList.find(item => item.defaultStatus)?.id || warehouseList[0]?.id
}
/**
* 功能说明:切换当前出库仓库。
* 适用场景:操作员选择本次扫码作业仓库。
* @param event picker 事件
* @return 无
* 注意事项:已录入明细不会被自动改仓,避免中途切仓导致历史扫码上下文错乱。
*/
function handleWarehouseChange(event: Record<string, any>) {
const warehouse = warehouses.value[Number(event.detail.value)]
selectedWarehouseId.value = warehouse?.id
}
/**
* 功能说明:切换当前客户。
* 适用场景:其它出库单头维护可选客户信息。
* @param event picker 事件
* @return 无
* 注意事项:客户当前不是必填项,但保留该字段便于后续业务追溯。
*/
function handleCustomerChange(event: Record<string, any>) {
const customer = customers.value[Number(event.detail.value)]
selectedCustomerId.value = customer?.id
}
/**
* 功能说明:按产品和仓库查询即时库存。
* 适用场景:扫码新增明细前或手工增加数量前进行库存校验。
* @param productId 产品编号
* @return 当前仓库下的库存信息
* 注意事项:出库页需要每次实时查询,避免沿用旧库存误放行。
*/
async function loadStockInfo(productId: number): Promise<Stock> {
return await getStock2(productId, selectedWarehouseId.value as number)
}
/**
* 功能说明:校验目标数量是否超过当前库存。
* 适用场景:扫码新增、重复扫码累计、手工增加数量。
* @param stockCount 当前库存数量
* @param nextCount 目标数量
* @param productName 产品名称
* @return 是否允许继续
* 注意事项:不在前端提前拦截的话,仓库人员可能连续扫码后才在提交时整体失败,体验会很差。
*/
function validateStock(stockCount: number, nextCount: number, productName: string): boolean {
if (Number(stockCount || 0) < nextCount) {
toast.error(`${productName} 库存不足`)
return false
}
return true
}
/**
* 功能说明:把扫码命中的产品合并到当前出库明细。
* 适用场景:扫码枪连续扫到同一产品时自动累计数量。
* @param product 条码命中的产品
* @return 无
* 注意事项:重复扫码前会先刷新库存并验证累计后数量,避免页面沿用旧库存误放行。
*/
async function appendScannedProduct(product: ProductByBarCode) {
const warehouseId = selectedWarehouseId.value as number
const currentBatchNo = batchNo.value.trim()
const currentLocationCode = locationCode.value.trim()
const targetKey = buildScanMergeKey({
warehouseId,
productId: product.id,
count: 1,
batchNo: currentBatchNo,
locationCode: currentLocationCode,
}, true)
const existedIndex = items.value.findIndex(item => buildScanMergeKey({
warehouseId: item.warehouseId,
productId: item.productId,
count: item.count,
batchNo: item.batchNo,
locationCode: item.locationCode,
}, true) === targetKey)
const stockInfo = await loadStockInfo(product.id)
const stockCount = Number(stockInfo?.count || 0)
if (existedIndex >= 0) {
const nextCount = items.value[existedIndex].count + 1
if (!validateStock(stockCount, nextCount, product.name)) {
return
}
items.value[existedIndex].count = nextCount
items.value[existedIndex].stockCount = stockCount
items.value[existedIndex].remainCount = Math.max(stockCount - nextCount, 0)
return
}
if (!validateStock(stockCount, 1, product.name)) {
return
}
items.value.unshift({
warehouseId,
warehouseName: currentWarehouse.value?.name,
productId: product.id,
productName: product.name,
productBarCode: product.barCode,
productSpec: product.standard,
productUnitName: product.unitName,
productPrice: Number(stockInfo?.unitPrice ?? product.minPrice ?? 0),
stockCount,
remainCount: Math.max(stockCount - 1, 0),
batchNo: currentBatchNo,
locationCode: currentLocationCode,
count: 1,
})
}
/**
* 功能说明:处理扫码提交。
* 适用场景:扫码枪回车或用户点击确认按钮。
* @param sourceCode 可选的外部条码输入值
* @return 无
* 注意事项:未选择仓库时直接拦截,避免库存查询与出库校验失去仓库上下文。
*/
async function handleScanSubmit(sourceCode?: string) {
if (scanLoading.value) {
return
}
if (!selectedWarehouseId.value) {
toast.error('请先选择仓库')
return
}
const barCode = normalizeScanCode(sourceCode ?? scanCode.value)
if (!barCode) {
toast.error('请先扫描条码')
return
}
scanLoading.value = true
try {
const product = await getProductByBarCode(barCode)
if (!product?.id) {
toast.error('未匹配到启用中的产品')
return
}
await appendScannedProduct(product)
scanCode.value = ''
} finally {
scanLoading.value = false
}
}
/**
* 功能说明:触发相机扫码,并将结果接入现有扫码录入流程。
* 适用场景:普通手机没有外接扫码枪时,通过摄像头录入条码。
* @return 无
* 注意事项:扫码取消应静默返回,避免把用户主动取消误判成系统错误。
*/
function handleCameraScan() {
if (scanLoading.value) {
return
}
uni.scanCode({
onlyFromCamera: true,
success: async (result) => {
const barCode = normalizeCameraScanResult(result)
if (!barCode) {
return
}
scanCode.value = barCode
await handleScanSubmit(barCode)
},
fail: (error) => {
// 用户主动取消扫码不属于异常流程,这里静默返回,避免产生干扰提示。
if (String(error?.errMsg || '').includes('cancel')) {
return
}
toast.error('相机扫码失败,请重试')
},
})
}
/**
* 功能说明:增加指定明细数量。
* 适用场景:扫码后人工补正出库数量。
* @param index 明细下标
* @return 无
* 注意事项:每次加数量前都重新校验库存,避免页面显示的库存已被其他单据消耗后继续放行。
*/
async function increaseCount(index: number) {
const item = items.value[index]
const stockInfo = await loadStockInfo(item.productId)
const nextCount = item.count + 1
if (!validateStock(Number(stockInfo?.count || 0), nextCount, item.productName)) {
return
}
item.stockCount = Number(stockInfo?.count || 0)
item.remainCount = Math.max(Number(stockInfo?.count || 0) - nextCount, 0)
item.count = nextCount
}
/**
* 功能说明:减少指定明细数量。
* 适用场景:误扫后人工回退数量。
* @param index 明细下标
* @return 无
* 注意事项:数量最低保留 1避免出现 0 数量明细继续提交。
*/
function decreaseCount(index: number) {
if (items.value[index].count <= 1) {
return
}
items.value[index].count -= 1
}
/**
* 功能说明:删除指定明细。
* 适用场景:误扫错误产品后移除整行。
* @param index 明细下标
* @return 无
* 注意事项:这里只删除当前行,不联动其他产品数量和库存展示。
*/
function removeItem(index: number) {
items.value.splice(index, 1)
}
/**
* 功能说明:清空当前录入明细。
* 适用场景:整单作废后重新扫码。
* @return 无
* 注意事项:清空后保留当前仓库和客户上下文,便于同一作业场景继续录单。
*/
function clearItems() {
items.value = []
}
/**
* 功能说明:将页面明细转换成其它出库接口需要的明细结构。
* 适用场景:提交前组装请求体。
* @return 其它出库明细数组
* 注意事项:这里只保留后端真正需要的字段,避免把展示字段一并带入接口契约。
*/
function buildSubmitItems(): StockOutItem[] {
return items.value.map(item => ({
warehouseId: item.warehouseId,
locationCode: item.locationCode,
productId: item.productId,
productPrice: item.productPrice,
batchNo: item.batchNo,
count: item.count,
remark: item.remark,
}))
}
/**
* 功能说明:提交扫码其它出库单。
* 适用场景:扫码录入完成后生成正式其它出库单。
* @return 无
* 注意事项:前端库存校验只做即时提醒,最终正确性以后端校验结果为准。
*/
async function handleSubmit() {
if (submitting.value) {
return
}
if (items.value.length === 0) {
toast.error('请先扫描出库明细')
return
}
submitting.value = true
try {
const payload: StockOut = {
outTime: new Date().toISOString(),
remark: remark.value,
items: buildSubmitItems(),
}
if (selectedCustomerId.value !== undefined) {
payload.customerId = selectedCustomerId.value
}
await createStockOut(payload)
toast.success('出库成功')
clearItems()
remark.value = ''
batchNo.value = ''
locationCode.value = ''
} finally {
submitting.value = false
}
}
/**
* 功能说明:初始化扫码其它出库页。
* 适用场景:页面首次挂载时准备基础数据。
* @return 无
* 注意事项:初始化失败时由请求封装统一提示,这里不额外重复 toast。
*/
onMounted(async () => {
await loadInitialData()
})
</script>
<style lang="scss" scoped>
.scan-page {
background: #f4f6f8;
&__content {
padding: 24rpx;
}
}
.scan-section {
margin-bottom: 24rpx;
padding: 24rpx;
border-radius: 20rpx;
background: #fff;
&__title {
margin-bottom: 20rpx;
font-size: 30rpx;
font-weight: 600;
color: #1f2329;
}
}
.scan-field {
height: 84rpx;
margin-bottom: 16rpx;
padding: 0 24rpx;
line-height: 84rpx;
border: 2rpx solid #e5e6eb;
border-radius: 12rpx;
background: #f7f8fa;
color: #1f2329;
}
</style>

1438
src/pages.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -54,6 +54,14 @@ const menuGroupsData: MenuGroup[] = [
iconColor: '#52c41a', iconColor: '#52c41a',
permission: 'erp:purchase-in:query', permission: 'erp:purchase-in:query',
}, },
{
key: 'purchaseInScan',
name: '扫码入库',
icon: 'scan',
url: '/pages-erp/purchase-in/scan-in/index',
iconColor: '#13c2c2',
permission: 'erp:purchase-in:query',
},
{ {
key: 'purchaseReturn', key: 'purchaseReturn',
name: '采购退货', name: '采购退货',
@@ -88,25 +96,47 @@ const menuGroupsData: MenuGroup[] = [
}, },
], ],
}, },
// {
// key: 'agri',
// name: '农业溯源',
// menus: [
// {
// key: 'agriBizFlow',
// name: '闭环操作台',
// icon: 'flow',
// url: '/pages-agri/biz-flow/index',
// iconColor: '#52c41a',
// permission: 'agri:biz:harvest',
// },
// {
// key: 'agriTraceSnapshot',
// name: '溯源快照',
// icon: 'scan',
// url: '/pages-agri/trace-snapshot/index',
// iconColor: '#1890ff',
// permission: 'agri:trace-snapshot:query',
// },
// ],
// },
{ {
key: 'agri', key: 'sale',
name: '农业溯源', name: '销售管理',
menus: [ menus: [
{ {
key: 'agriBizFlow', key: 'saleOut',
name: '闭环操作台', name: '销售出库',
icon: 'flow', icon: 'arrow-right',
url: '/pages-agri/biz-flow/index', url: '/pages-erp/sale-out/index',
iconColor: '#52c41a', iconColor: '#f5222d',
permission: 'agri:biz:harvest', permission: 'erp:sale-out:query',
}, },
{ {
key: 'agriTraceSnapshot', key: 'saleOutScan',
name: '溯源快照', name: '扫码出库',
icon: 'scan', icon: 'scan',
url: '/pages-agri/trace-snapshot/index', url: '/pages-erp/sale-out/scan-out/index',
iconColor: '#1890ff', iconColor: '#cf1322',
permission: 'agri:trace-snapshot:query', permission: 'erp:sale-out:query',
}, },
], ],
}, },
@@ -138,6 +168,14 @@ const menuGroupsData: MenuGroup[] = [
iconColor: '#722ed1', iconColor: '#722ed1',
permission: 'erp:stock-record:query', permission: 'erp:stock-record:query',
}, },
{
key: 'purchaseInScan',
name: '扫码采购入库',
icon: 'scan',
url: '/pages-erp/purchase-in/scan/index',
iconColor: '#2f54eb',
permission: 'erp:purchase-in:query',
},
{ {
key: 'stockIn', key: 'stockIn',
name: '其他入库', name: '其他入库',
@@ -146,6 +184,14 @@ const menuGroupsData: MenuGroup[] = [
iconColor: '#13c2c2', iconColor: '#13c2c2',
permission: 'erp:stock-in:query', permission: 'erp:stock-in:query',
}, },
{
key: 'stockInScan',
name: '扫码其它入库',
icon: 'scan',
url: '/pages-erp/stock-in/scan/index',
iconColor: '#36cfc9',
permission: 'erp:stock-in:query',
},
{ {
key: 'stockOut', key: 'stockOut',
name: '其他出库', name: '其他出库',
@@ -154,6 +200,22 @@ const menuGroupsData: MenuGroup[] = [
iconColor: '#fa8c16', iconColor: '#fa8c16',
permission: 'erp:stock-out:query', permission: 'erp:stock-out:query',
}, },
{
key: 'stockOutScan',
name: '扫码其它出库',
icon: 'scan',
url: '/pages-erp/stock-out/scan/index',
iconColor: '#ff7a45',
permission: 'erp:stock-out:query',
},
{
key: 'stockOutTaskScan',
name: '扫码销售出库',
icon: 'scan',
url: '/pages-erp/stock-out/scan/index',
iconColor: '#cf1322',
permission: 'erp:stock-out:query',
},
{ {
key: 'stockGain', key: 'stockGain',
name: '库存报溢', name: '库存报溢',

View File

@@ -0,0 +1,616 @@
import { describe, expect, it } from 'vitest'
import {
appendPurchaseBatchLocationItem,
appendPurchaseScanItem,
buildPurchasePendingGuideItems,
buildPurchasePendingItems,
buildPurchaseScanFeedback,
buildPurchaseSubmitGuard,
findPendingOrderItemByBarCode,
findPendingOrderItemForBatchFlow,
findPurchaseOrderByScanCode,
removePurchaseScanItemAt,
updatePurchaseScanItemCount,
} from '../purchase-scan'
function createOrderItem(overrides: Record<string, any> = {}) {
return {
id: 1,
productId: 101,
productBarCode: 'BC-001',
productName: '测试产品',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
productSpec: '10kg',
count: 10,
inCount: 2,
taxPercent: 13,
remark: '订单备注',
...overrides,
}
}
function createPurchaseOrder(overrides: Record<string, any> = {}) {
return {
id: 1,
no: 'CG2025001',
supplierName: '供应商A',
...overrides,
}
}
function createPurchaseScanItem(overrides: Record<string, any> = {}) {
return {
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productSpec: '10kg',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
taxPercent: 13,
totalCount: 10,
inCount: 2,
remainCount: 7,
batchNo: 'B-01',
locationCode: 'A-01',
count: 1,
remark: '订单备注',
...overrides,
}
}
describe('buildPurchasePendingItems', () => {
it('应只保留仍可入库的订单行', () => {
const items = buildPurchasePendingItems([
createOrderItem({ id: 1, count: 10, inCount: 8 }),
createOrderItem({ id: 2, count: 5, inCount: 5 }),
], { id: 9, name: '默认仓' })
expect(items).toHaveLength(1)
expect(items[0].orderItemId).toBe(1)
expect(items[0].count).toBe(2)
expect(items[0].remainCount).toBe(2)
expect(items[0].warehouseId).toBe(9)
})
})
describe('buildPurchasePendingGuideItems', () => {
it('应只输出仍需提示扫码的商品,并保留核心展示字段', () => {
const result = buildPurchasePendingGuideItems([
createPurchaseScanItem({ productName: '苹果', productBarCode: 'BC-001', productSpec: '大果', productUnitName: '箱', remainCount: 3 }),
createPurchaseScanItem({ productName: '香蕉', productBarCode: 'BC-002', productSpec: '散装', productUnitName: '件', remainCount: 0 }),
])
expect(result).toEqual([
{
orderItemId: 1,
productName: '苹果',
productBarCode: 'BC-001',
productSpec: '大果',
productUnitName: '箱',
remainCount: 3,
},
])
})
})
describe('findPendingOrderItemByBarCode', () => {
it('应命中唯一待入库条码行', () => {
const result = findPendingOrderItemByBarCode([
createOrderItem({ id: 1, productBarCode: 'BC-001', count: 5, inCount: 1 }),
], 'BC-001')
expect(result.type).toBe('matched')
if (result.type === 'matched') {
expect(result.item.id).toBe(1)
expect(result.remainCount).toBe(4)
}
})
it('同条码命中多个待入库订单行时应返回冲突', () => {
const result = findPendingOrderItemByBarCode([
createOrderItem({ id: 1, productBarCode: 'BC-001' }),
createOrderItem({ id: 2, productBarCode: 'BC-001' }),
], 'BC-001')
expect(result.type).toBe('ambiguous')
})
it('没有可入库命中时应返回未找到', () => {
const result = findPendingOrderItemByBarCode([
createOrderItem({ id: 1, productBarCode: 'BC-001', count: 5, inCount: 5 }),
], 'BC-001')
expect(result.type).toBe('not_found')
})
})
describe('findPendingOrderItemForBatchFlow', () => {
it('仅剩一个待入库物料时应允许直接进入批次库位流程', () => {
const result = findPendingOrderItemForBatchFlow([
createOrderItem({ id: 1, count: 8, inCount: 3 }),
])
expect(result.type).toBe('matched')
if (result.type === 'matched') {
expect(result.item.id).toBe(1)
expect(result.remainCount).toBe(5)
}
})
it('存在多个待入库物料时应返回冲突', () => {
const result = findPendingOrderItemForBatchFlow([
createOrderItem({ id: 1, count: 8, inCount: 3 }),
createOrderItem({ id: 2, count: 6, inCount: 1 }),
])
expect(result.type).toBe('ambiguous')
})
})
describe('findPurchaseOrderByScanCode', () => {
it('应按标准化后的订单编号精确命中', () => {
const result = findPurchaseOrderByScanCode([
createPurchaseOrder({ id: 1, no: 'CG-2025-001' }),
createPurchaseOrder({ id: 2, no: 'CG-2025-002' }),
], ' cg2025001 ')
expect(result?.id).toBe(1)
})
it('未命中时应返回 undefined', () => {
const result = findPurchaseOrderByScanCode([
createPurchaseOrder({ id: 1, no: 'CG-2025-001' }),
], 'CG2025999')
expect(result).toBeUndefined()
})
})
describe('appendPurchaseScanItem', () => {
it('首次扫码应新增一条采购入库明细', () => {
const result = appendPurchaseScanItem([], {
orderItem: createOrderItem({ id: 1 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-01',
locationCode: 'A-01',
})
expect(result.ok).toBe(true)
if (result.ok) {
expect(result.items).toHaveLength(1)
expect(result.items[0].count).toBe(1)
expect(result.items[0].remainCount).toBe(7)
}
})
it('相同订单行且相同批次库位重复扫码应累计数量', () => {
const result = appendPurchaseScanItem([{
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productSpec: '10kg',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
taxPercent: 13,
totalCount: 10,
inCount: 2,
remainCount: 8,
batchNo: 'B-01',
locationCode: 'A-01',
count: 1,
}], {
orderItem: createOrderItem({ id: 1 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-01',
locationCode: 'A-01',
})
expect(result.ok).toBe(true)
if (result.ok) {
expect(result.items).toHaveLength(1)
expect(result.items[0].count).toBe(2)
expect(result.items[0].remainCount).toBe(6)
}
})
it('不同批次不应错误合并', () => {
const result = appendPurchaseScanItem([{
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productSpec: '10kg',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
taxPercent: 13,
totalCount: 10,
inCount: 2,
remainCount: 8,
batchNo: 'B-01',
locationCode: 'A-01',
count: 1,
}], {
orderItem: createOrderItem({ id: 1 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-02',
locationCode: 'A-01',
})
expect(result.ok).toBe(true)
if (result.ok) {
expect(result.items).toHaveLength(2)
}
})
it('相同批次但不同库位时不应错误合并', () => {
const result = appendPurchaseScanItem([{
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productSpec: '10kg',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
taxPercent: 13,
totalCount: 10,
inCount: 2,
remainCount: 8,
batchNo: 'B-01',
locationCode: 'A-01',
count: 1,
}], {
orderItem: createOrderItem({ id: 1 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-01',
locationCode: 'A-02',
})
expect(result.ok).toBe(true)
if (result.ok) {
expect(result.items).toHaveLength(2)
expect(result.items[0].locationCode).toBe('A-02')
expect(result.items[1].locationCode).toBe('A-01')
}
})
it('累计数量超过订单剩余数时应拦截', () => {
const result = appendPurchaseScanItem([{
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productSpec: '10kg',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
taxPercent: 13,
totalCount: 3,
inCount: 2,
remainCount: 1,
batchNo: 'B-01',
locationCode: 'A-01',
count: 1,
}], {
orderItem: createOrderItem({ id: 1, count: 3, inCount: 2 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-01',
locationCode: 'A-01',
})
expect(result.ok).toBe(false)
expect(result).toMatchObject({ ok: false, reason: 'exceed_remaining' })
})
it('同一订单行跨批次累计超过剩余数时也应拦截', () => {
const result = appendPurchaseScanItem([
{
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productSpec: '10kg',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
taxPercent: 13,
totalCount: 4,
inCount: 2,
remainCount: 1,
batchNo: 'B-01',
locationCode: 'A-01',
count: 1,
},
{
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productSpec: '10kg',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
taxPercent: 13,
totalCount: 4,
inCount: 2,
remainCount: 1,
batchNo: 'B-02',
locationCode: 'A-01',
count: 1,
},
], {
orderItem: createOrderItem({ id: 1, count: 4, inCount: 2 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-03',
locationCode: 'A-01',
})
expect(result.ok).toBe(false)
expect(result).toMatchObject({ ok: false, reason: 'exceed_remaining' })
})
})
describe('appendPurchaseBatchLocationItem', () => {
it('首次按批次库位确认时应按剩余数量创建记录', () => {
const result = appendPurchaseBatchLocationItem([], {
orderItem: createOrderItem({ id: 1, count: 10, inCount: 2 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-01',
locationCode: 'A-01',
})
expect(result.ok).toBe(true)
if (result.ok) {
expect(result.items).toHaveLength(1)
expect(result.items[0].count).toBe(8)
expect(result.items[0].remainCount).toBe(0)
}
})
it('同订单行同批次同库位重复确认时不应超出剩余上限', () => {
const result = appendPurchaseBatchLocationItem([
createPurchaseScanItem({
orderItemId: 1,
totalCount: 10,
inCount: 2,
remainCount: 0,
count: 8,
batchNo: 'B-01',
locationCode: 'A-01',
}),
], {
orderItem: createOrderItem({ id: 1, count: 10, inCount: 2 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-01',
locationCode: 'A-01',
})
expect(result.ok).toBe(false)
expect(result).toMatchObject({ ok: false, reason: 'exceed_remaining' })
})
})
describe('appendPurchaseScanItem recent-first behavior', () => {
it('新增不同批次时应把最新记录放在最前面', () => {
const result = appendPurchaseScanItem([{
orderItemId: 1,
warehouseId: 9,
warehouseName: '默认仓',
productId: 101,
productName: '测试产品',
productBarCode: 'BC-001',
productUnitId: 11,
productUnitName: '件',
productPrice: 12.5,
totalCount: 10,
inCount: 2,
remainCount: 7,
batchNo: 'B-01',
locationCode: 'A-01',
count: 1,
}], {
orderItem: createOrderItem({ id: 1 }),
warehouseId: 9,
warehouseName: '默认仓',
batchNo: 'B-02',
locationCode: 'A-01',
})
expect(result.ok).toBe(true)
if (result.ok) {
expect(result.items[0].batchNo).toBe('B-02')
expect(result.items[1].batchNo).toBe('B-01')
}
})
})
describe('buildPurchaseSubmitGuard', () => {
it('缺少采购订单时不允许提交', () => {
expect(buildPurchaseSubmitGuard({
hasOrder: false,
hasAccount: true,
itemCount: 2,
exceptionCount: 0,
})).toEqual({
ok: false,
reason: '请先选择采购订单',
})
})
it('缺少结算账户时不允许提交', () => {
expect(buildPurchaseSubmitGuard({
hasOrder: true,
hasAccount: false,
itemCount: 2,
exceptionCount: 0,
})).toEqual({
ok: false,
reason: '请选择结算账户',
})
})
it('没有扫码明细时不允许提交', () => {
expect(buildPurchaseSubmitGuard({
hasOrder: true,
hasAccount: true,
itemCount: 0,
exceptionCount: 0,
})).toEqual({
ok: false,
reason: '请先扫描入库明细',
})
})
it('存在异常时不允许提交', () => {
expect(buildPurchaseSubmitGuard({
hasOrder: true,
hasAccount: true,
itemCount: 2,
exceptionCount: 1,
})).toEqual({
ok: false,
reason: '存在未处理异常,请先处理后再提交',
})
})
it('前置条件全部满足时允许提交', () => {
expect(buildPurchaseSubmitGuard({
hasOrder: true,
hasAccount: true,
itemCount: 2,
exceptionCount: 0,
})).toEqual({ ok: true })
})
})
describe('buildPurchaseScanFeedback', () => {
it('成功扫码时应返回 success 状态文案', () => {
expect(buildPurchaseScanFeedback({
type: 'success',
productName: '西兰花',
delta: 1,
scannedCount: 12,
targetCount: 30,
})).toMatchObject({
tone: 'success',
message: '西兰花 +1已扫 12 / 30',
})
})
it('数量减少时应返回负向调整文案', () => {
expect(buildPurchaseScanFeedback({
type: 'success',
productName: '西兰花',
delta: -1,
scannedCount: 11,
targetCount: 30,
})).toMatchObject({
tone: 'success',
message: '西兰花 -1已扫 11 / 30',
})
})
it('失败扫码时应优先返回指定错误文案', () => {
expect(buildPurchaseScanFeedback({
type: 'error',
message: '商品条码未匹配到采购订单',
})).toMatchObject({
tone: 'error',
message: '商品条码未匹配到采购订单',
})
})
it('失败扫码未传文案时应返回默认兜底提示', () => {
expect(buildPurchaseScanFeedback({
type: 'error',
})).toMatchObject({
tone: 'error',
message: '扫码失败,请重试',
})
})
})
describe('removePurchaseScanItemAt', () => {
it('撤销首条记录后应删除该项并保留其他记录', () => {
const result = removePurchaseScanItemAt([
{ ...createPurchaseScanItem({ batchNo: 'B-01', count: 1 }) },
{ ...createPurchaseScanItem({ batchNo: 'B-02', count: 2 }) },
], 0)
expect(result).toHaveLength(1)
expect(result[0].batchNo).toBe('B-02')
})
})
describe('updatePurchaseScanItemCount', () => {
it('应更新目标行数量并回写该行剩余数量', () => {
const result = updatePurchaseScanItemCount([
createPurchaseScanItem({ orderItemId: 1, count: 2, remainCount: 6, batchNo: 'B-01' }),
createPurchaseScanItem({ orderItemId: 1, count: 1, remainCount: 7, batchNo: 'B-02' }),
], 0, 3)
expect(result.ok).toBe(true)
if (result.ok) {
expect(result.items[0].count).toBe(3)
expect(result.items[0].remainCount).toBe(4)
expect(result.items[1].count).toBe(1)
}
})
it('同一订单行累计超出剩余上限时应拦截', () => {
const result = updatePurchaseScanItemCount([
createPurchaseScanItem({ orderItemId: 1, totalCount: 10, inCount: 2, count: 5, remainCount: 3, batchNo: 'B-01' }),
createPurchaseScanItem({ orderItemId: 1, totalCount: 10, inCount: 2, count: 2, remainCount: 6, batchNo: 'B-02' }),
], 0, 7)
expect(result.ok).toBe(false)
expect(result).toMatchObject({ ok: false, reason: 'exceed_remaining' })
})
it('数量小于 1 时应拦截', () => {
const result = updatePurchaseScanItemCount([
createPurchaseScanItem({ count: 2 }),
], 0, 0)
expect(result.ok).toBe(false)
expect(result).toMatchObject({ ok: false, reason: 'invalid_count' })
})
it('索引不存在时应返回 not_found', () => {
const result = updatePurchaseScanItemCount([
createPurchaseScanItem({ count: 2 }),
], 9, 3)
expect(result.ok).toBe(false)
expect(result).toMatchObject({ ok: false, reason: 'not_found' })
})
})

View File

@@ -0,0 +1,111 @@
import type { ScanItem } from '../scan'
import { describe, expect, it } from 'vitest'
import {
buildScanMergeKey,
mergeScannedItem,
normalizeCameraScanResult,
normalizeScanCode,
} from '../scan'
/**
* 功能说明:构造测试明细数据,避免每个用例重复拼装字段。
* 适用场景:扫码合并工具函数单元测试。
* @param overrides 需要覆盖的字段
* @return 测试用明细对象
* 注意事项:测试数据默认模拟“自由扫码”场景,订单约束字段按需覆盖。
*/
function createItem(overrides: Partial<ScanItem> = {}): ScanItem {
return {
warehouseId: 1,
productId: 1001,
count: 1,
orderItemId: undefined,
batchNo: undefined,
locationCode: undefined,
...overrides,
}
}
describe('normalizeScanCode', () => {
it('应去掉回车换行和前后空格', () => {
expect(normalizeScanCode(' TEST-001\r\n')).toBe('TEST-001')
})
it('空值应返回空字符串', () => {
expect(normalizeScanCode('')).toBe('')
})
})
describe('normalizeCameraScanResult', () => {
it('应从手机扫码结果对象中提取并清洗条码', () => {
expect(normalizeCameraScanResult({ result: ' MOBILE-001\r\n' })).toBe('MOBILE-001')
})
it('扫码取消或结果为空时应返回空字符串', () => {
expect(normalizeCameraScanResult({ result: '' })).toBe('')
})
})
describe('buildScanMergeKey', () => {
it('自由扫码模式应按仓库和产品生成合并键', () => {
expect(buildScanMergeKey(createItem())).toBe('1:1001')
})
it('订单约束模式应额外带上订单明细编号', () => {
expect(buildScanMergeKey(createItem({ orderItemId: 5001 }), true)).toBe('1:1001:5001::')
})
it('订单约束模式应带上批次号和库位码', () => {
expect(buildScanMergeKey(createItem({
orderItemId: 5001,
batchNo: 'BATCH-01',
locationCode: 'A-01-02',
}), true)).toBe('1:1001:5001:BATCH-01:A-01-02')
})
})
describe('mergeScannedItem', () => {
it('同仓库同产品重复扫码应累计数量', () => {
const merged = mergeScannedItem([createItem({ count: 2 })], createItem(), false)
expect(merged).toHaveLength(1)
expect(merged[0].count).toBe(3)
})
it('跨仓库扫码不应错误合并', () => {
const merged = mergeScannedItem([createItem({ warehouseId: 2 })], createItem(), false)
expect(merged).toHaveLength(2)
})
it('订单约束模式下不同订单行不应合并', () => {
const merged = mergeScannedItem(
[createItem({ orderItemId: 9001 })],
createItem({ orderItemId: 9002 }),
true,
)
expect(merged).toHaveLength(2)
})
it('订单约束模式下不同批次不应合并', () => {
const merged = mergeScannedItem(
[createItem({ orderItemId: 9001, batchNo: 'BATCH-01', locationCode: 'A-01' })],
createItem({ orderItemId: 9001, batchNo: 'BATCH-02', locationCode: 'A-01' }),
true,
)
expect(merged).toHaveLength(2)
})
it('订单约束模式下不同库位不应合并', () => {
const merged = mergeScannedItem(
[createItem({ orderItemId: 9001, batchNo: 'BATCH-01', locationCode: 'A-01' })],
createItem({ orderItemId: 9001, batchNo: 'BATCH-01', locationCode: 'A-02' }),
true,
)
expect(merged).toHaveLength(2)
})
})

View File

@@ -19,16 +19,11 @@ export function formatDate(time?: FormatDate, format: Format = 'YYYY-MM-DD') {
if (!time) { if (!time) {
return '' return ''
} }
try {
const date = dayjs.isDayjs(time) ? time : dayjs(time) const date = dayjs.isDayjs(time) ? time : dayjs(time)
if (!date.isValid()) { if (!date.isValid()) {
throw new Error('Invalid date')
}
return date.format(format)
} catch (error) {
console.error(`Error formatting date: ${error}`)
return String(time ?? '') return String(time ?? '')
} }
return date.format(format)
} }
/** 格式化日期时间 */ /** 格式化日期时间 */

498
src/utils/purchase-scan.ts Normal file
View File

@@ -0,0 +1,498 @@
import type { PurchaseInItem } from '@/api/erp/purchase-in'
import type { PurchaseOrder, PurchaseOrderItem } from '@/api/erp/purchase-order'
export interface PurchaseScanItem extends PurchaseInItem {
productBarCode?: string
productSpec?: string
totalCount?: number
inCount?: number
remainCount?: number
batchNo?: string
locationCode?: string
}
export interface PurchaseWarehouseOption {
id?: number
name?: string
}
export interface PurchasePendingGuideItem {
orderItemId?: number
productName?: string
productBarCode?: string
productSpec?: string
productUnitName?: string
remainCount?: number
}
interface PendingLookupMatched {
type: 'matched'
item: PurchaseOrderItem
remainCount: number
}
interface PendingLookupAmbiguous {
type: 'ambiguous'
}
interface PendingLookupNotFound {
type: 'not_found'
}
type PendingLookupResult = PendingLookupMatched | PendingLookupAmbiguous | PendingLookupNotFound
interface AppendPurchaseScanSuccess {
ok: true
items: PurchaseScanItem[]
}
interface AppendPurchaseScanFailure {
ok: false
reason: 'exceed_remaining'
}
interface UpdatePurchaseScanFailure {
ok: false
reason: 'exceed_remaining' | 'invalid_count' | 'not_found'
}
export interface PurchaseScanFeedback {
tone: 'success' | 'error'
message: string
}
/**
* 功能说明:判断两条采购扫码记录是否允许合并
* 适用场景:采购扫码时识别是否命中同一订单行、同一仓库、同一批次和同一库位
* @param current 已存在的扫码记录
* @param payload 本次扫码载荷
* @return 字段完全匹配时返回 true否则返回 false
* 注意事项:这里使用本地字段比较,避免依赖其他扫描域的通用 merge key 逻辑导致采购批次/库位约束失效
*/
function isSamePurchaseScanTarget(
current: PurchaseScanItem,
payload: {
orderItem: PurchaseOrderItem
warehouseId?: number
batchNo?: string
locationCode?: string
},
): boolean {
// 批次号和库位编码统一转成字符串兜底,避免 undefined 与空字符串比较不一致导致误合并
const currentBatchNo = String(current.batchNo || '')
const targetBatchNo = String(payload.batchNo || '')
const currentLocationCode = String(current.locationCode || '')
const targetLocationCode = String(payload.locationCode || '')
return Number(current.orderItemId || 0) === Number(payload.orderItem.id || 0)
&& Number(current.warehouseId || 0) === Number(payload.warehouseId || 0)
&& Number(current.productId || 0) === Number(payload.orderItem.productId || 0)
&& currentBatchNo === targetBatchNo
&& currentLocationCode === targetLocationCode
}
/**
* 功能说明:构建采购扫码台待入库明细列表
* 适用场景:采购订单选定后,生成仍可入库的候选明细
* @param orderItems 采购订单明细列表
* @param warehouse 当前选中的仓库信息
* @return 仅包含仍可入库数量的扫码明细列表
* 注意事项:会过滤掉剩余数量小于等于 0 的订单行,避免无效扫码
*/
export function buildPurchasePendingItems(
orderItems: PurchaseOrderItem[],
warehouse?: PurchaseWarehouseOption,
): PurchaseScanItem[] {
return orderItems
.filter(item => Number(item.count || 0) - Number(item.inCount || 0) > 0)
.map((item) => {
const remainCount = Number(item.count || 0) - Number(item.inCount || 0)
return {
orderItemId: item.id,
warehouseId: warehouse?.id,
warehouseName: warehouse?.name,
productId: item.productId,
productName: item.productName,
productBarCode: item.productBarCode,
productUnitId: item.productUnitId,
productUnitName: item.productUnitName,
productPrice: item.productPrice,
productSpec: item.productSpec,
taxPercent: item.taxPercent,
totalCount: item.count,
inCount: item.inCount,
remainCount,
count: remainCount,
remark: item.remark,
}
})
}
/**
* 功能说明:构建采购扫码工作台的待扫码提示清单。
* 适用场景:采购单锁定成功后,向操作员展示当前还需要扫码入库的商品。
* @param items 当前仍待入库的采购扫码明细
* @return 仅包含提示展示所需字段的轻量列表
* 注意事项:只保留剩余数量大于 0 的记录,避免把已完成项继续展示在待扫码提示区。
*/
export function buildPurchasePendingGuideItems(items: PurchaseScanItem[]): PurchasePendingGuideItem[] {
return items
.filter(item => Number(item.remainCount || 0) > 0)
.map(item => ({
orderItemId: item.orderItemId,
productName: item.productName,
productBarCode: item.productBarCode,
productSpec: item.productSpec,
productUnitName: item.productUnitName,
remainCount: item.remainCount,
}))
}
/**
* 功能说明:根据条码查找唯一可扫码的采购订单行
* 适用场景PDA 扫码商品条码后定位待入库订单明细
* @param orderItems 采购订单明细列表
* @param barCode 扫描得到的商品条码
* @return 唯一命中、冲突或未命中的查找结果
* 注意事项:只会匹配剩余可入库数量大于 0 的订单行
*/
export function findPendingOrderItemByBarCode(
orderItems: PurchaseOrderItem[],
barCode: string,
): PendingLookupResult {
const matchedItems = orderItems.filter((item) => {
const remainCount = Number(item.count || 0) - Number(item.inCount || 0)
return remainCount > 0 && item.productBarCode === barCode
})
if (matchedItems.length === 0) {
return { type: 'not_found' }
}
if (matchedItems.length > 1) {
return { type: 'ambiguous' }
}
const item = matchedItems[0]
return {
type: 'matched',
item,
remainCount: Number(item.count || 0) - Number(item.inCount || 0),
}
}
/**
* 功能说明:在不扫描商品码的采购入库场景下,判断当前采购单是否能直接进入批次/库位流程。
* 适用场景:原辅料采购入库锁单后,仅当待入库物料唯一时允许继续扫描批次和库位。
* @param orderItems 采购订单明细列表
* @return 唯一命中、冲突或未命中的查找结果
* 注意事项:多个待入库订单行时前端不应擅自猜测目标物料,否则会把整批原辅料记到错误订单行。
*/
export function findPendingOrderItemForBatchFlow(
orderItems: PurchaseOrderItem[],
): PendingLookupResult {
const pendingItems = orderItems.filter((item) => {
const remainCount = Number(item.count || 0) - Number(item.inCount || 0)
return remainCount > 0
})
if (pendingItems.length === 0) {
return { type: 'not_found' }
}
if (pendingItems.length > 1) {
return { type: 'ambiguous' }
}
const item = pendingItems[0]
return {
type: 'matched',
item,
remainCount: Number(item.count || 0) - Number(item.inCount || 0),
}
}
/**
* 功能说明:根据扫码内容匹配采购订单
* 适用场景:扫描采购单号后在已加载订单列表中定位目标订单
* @param orders 采购订单列表
* @param scanCode 扫描得到的订单编码
* @return 匹配到的采购订单,未命中时返回 undefined
* 注意事项:会先做去空格、去分隔符和大写标准化,兼容扫码枪格式差异
*/
export function findPurchaseOrderByScanCode(
orders: PurchaseOrder[],
scanCode: string,
): PurchaseOrder | undefined {
const normalizedCode = scanCode.trim().replace(/[^a-z0-9]/gi, '').toUpperCase()
if (!normalizedCode) {
return undefined
}
return orders.find((item) => {
const normalizedNo = String(item.no || '').trim().replace(/[^a-z0-9]/gi, '').toUpperCase()
return normalizedNo === normalizedCode
})
}
/**
* 功能说明:追加一条采购扫码记录,并在可合并时累加数量
* 适用场景PDA 每次成功扫码后更新本地入库明细列表
* @param items 当前已扫码的采购入库明细
* @param payload 本次扫码匹配到的订单行及批次库位信息
* @return 追加成功时返回最新明细列表,超出剩余数量时返回失败原因
* 注意事项:不同批次或库位不能合并;新增记录需要放在最前面,保证最近扫码优先展示
*/
export function appendPurchaseScanItem(
items: PurchaseScanItem[],
payload: {
orderItem: PurchaseOrderItem
warehouseId?: number
warehouseName?: string
batchNo?: string
locationCode?: string
},
): AppendPurchaseScanSuccess | AppendPurchaseScanFailure {
const remainCount = Number(payload.orderItem.count || 0) - Number(payload.orderItem.inCount || 0)
const scannedTotal = items
.filter(item => item.orderItemId === payload.orderItem.id)
.reduce((sum, item) => sum + Number(item.count || 0), 0)
// 采购扫码的合并约束必须在本域内自包含,防止共享扫描工具变更后破坏批次/库位隔离语义
const existedIndex = items.findIndex(item => isSamePurchaseScanTarget(item, payload))
if (existedIndex >= 0) {
const nextCount = Number(items[existedIndex].count || 0) + 1
// 这里按订单行累计校验,避免跨批次累计后超出采购订单剩余可入库数量
if (scannedTotal + 1 > remainCount) {
return { ok: false, reason: 'exceed_remaining' }
}
return {
ok: true,
items: items.map((item, index) => (
index === existedIndex
? {
...item,
count: nextCount,
remainCount: remainCount - nextCount,
}
: item
)),
}
}
// 新批次新增时同样需要校验总扫码数,避免不同批次拆分后绕过剩余数量限制
if (scannedTotal + 1 > remainCount) {
return { ok: false, reason: 'exceed_remaining' }
}
return {
ok: true,
// 最近一次扫码的记录放在最前面,便于 PDA 工作台优先展示最新操作结果
items: [{
orderItemId: payload.orderItem.id,
warehouseId: payload.warehouseId,
warehouseName: payload.warehouseName,
productId: payload.orderItem.productId,
productName: payload.orderItem.productName,
productBarCode: payload.orderItem.productBarCode,
productUnitId: payload.orderItem.productUnitId,
productUnitName: payload.orderItem.productUnitName,
productPrice: payload.orderItem.productPrice,
productSpec: payload.orderItem.productSpec,
taxPercent: payload.orderItem.taxPercent,
totalCount: payload.orderItem.count,
inCount: payload.orderItem.inCount,
remainCount: remainCount - 1,
batchNo: payload.batchNo,
locationCode: payload.locationCode,
count: 1,
remark: payload.orderItem.remark,
}, ...items],
}
}
/**
* 功能说明:按批次和库位确认一条采购入库记录,不依赖商品条码扫描。
* 适用场景:原辅料采购入库锁单后,扫描批次号和库位码完成上架确认。
* @param items 当前已确认的采购入库明细
* @param payload 本次确认对应的订单行及批次库位信息
* @return 新增成功时返回最新明细列表,超出剩余数量时返回失败原因
* 注意事项:默认按当前订单行剩余数量整行确认;若后续存在部分入库,再由工作台手动调整数量。
*/
export function appendPurchaseBatchLocationItem(
items: PurchaseScanItem[],
payload: {
orderItem: PurchaseOrderItem
warehouseId?: number
warehouseName?: string
batchNo?: string
locationCode?: string
},
): AppendPurchaseScanSuccess | AppendPurchaseScanFailure {
const remainCount = Number(payload.orderItem.count || 0) - Number(payload.orderItem.inCount || 0)
const existedIndex = items.findIndex(item => isSamePurchaseScanTarget(item, payload))
if (remainCount < 1) {
return { ok: false, reason: 'exceed_remaining' }
}
if (existedIndex >= 0) {
return { ok: false, reason: 'exceed_remaining' }
}
return {
ok: true,
items: [{
orderItemId: payload.orderItem.id,
warehouseId: payload.warehouseId,
warehouseName: payload.warehouseName,
productId: payload.orderItem.productId,
productName: payload.orderItem.productName,
productBarCode: payload.orderItem.productBarCode,
productUnitId: payload.orderItem.productUnitId,
productUnitName: payload.orderItem.productUnitName,
productPrice: payload.orderItem.productPrice,
productSpec: payload.orderItem.productSpec,
taxPercent: payload.orderItem.taxPercent,
totalCount: payload.orderItem.count,
inCount: payload.orderItem.inCount,
remainCount: 0,
batchNo: payload.batchNo,
locationCode: payload.locationCode,
count: remainCount,
remark: payload.orderItem.remark,
}, ...items],
}
}
/**
* 功能说明:构建采购扫码后的前端反馈文案
* 适用场景:扫码成功或失败后,统一生成工作台提示消息
* @param payload 扫码结果及相关上下文
* @return 标准化的反馈状态和提示文案
* 注意事项:成功场景会对商品名、增量和进度做默认值兜底,避免提示文案缺失
*/
export function buildPurchaseScanFeedback(payload: {
type: 'success' | 'error'
productName?: string
delta?: number
scannedCount?: number
targetCount?: number
message?: string
}): PurchaseScanFeedback {
if (payload.type === 'error') {
return {
tone: 'error',
message: payload.message || '扫码失败,请重试',
}
}
const delta = Number(payload.delta ?? 1)
const deltaText = delta >= 0 ? `+${delta}` : String(delta)
return {
tone: 'success',
message: `${payload.productName || '商品'} ${deltaText},已扫 ${payload.scannedCount || 0} / ${payload.targetCount || 0}`,
}
}
/**
* 功能说明:按索引移除一条采购扫码记录
* 适用场景:用户撤销最近或指定一条扫码明细
* @param items 当前已扫码明细列表
* @param index 需要删除的目标索引
* @return 删除目标索引后的新列表
* 注意事项:保持其他记录原有顺序不变,便于工作台撤销后稳定渲染
*/
export function removePurchaseScanItemAt(
items: PurchaseScanItem[],
index: number,
): PurchaseScanItem[] {
return items.filter((_, currentIndex) => currentIndex !== index)
}
/**
* 功能说明:更新指定采购扫码记录的数量,并校验整条订单行累计数量上限。
* 适用场景PDA 工作台手动加减数量,或直接录入目标数量。
* @param items 当前已扫码明细列表
* @param index 需要更新的目标索引
* @param nextCount 调整后的目标数量
* @return 更新成功时返回新列表,非法数量或超上限时返回失败原因
* 注意事项:校验维度按订单行累计执行,避免多批次/多库位拆分后绕过采购剩余数量约束。
*/
export function updatePurchaseScanItemCount(
items: PurchaseScanItem[],
index: number,
nextCount: number,
): AppendPurchaseScanSuccess | UpdatePurchaseScanFailure {
const targetItem = items[index]
if (!targetItem) {
return { ok: false, reason: 'not_found' }
}
const normalizedNextCount = Number(nextCount)
if (!Number.isFinite(normalizedNextCount) || normalizedNextCount < 1) {
return { ok: false, reason: 'invalid_count' }
}
const remainCount = Number(targetItem.totalCount || 0) - Number(targetItem.inCount || 0)
const nextScannedTotal = items.reduce((sum, item, currentIndex) => {
if (item.orderItemId !== targetItem.orderItemId) {
return sum
}
return sum + Number(currentIndex === index ? normalizedNextCount : item.count || 0)
}, 0)
if (nextScannedTotal > remainCount) {
return { ok: false, reason: 'exceed_remaining' }
}
return {
ok: true,
items: items.map((item, currentIndex) => {
if (item.orderItemId !== targetItem.orderItemId) {
return item
}
return {
...item,
count: currentIndex === index ? normalizedNextCount : item.count,
remainCount: remainCount - nextScannedTotal,
}
}),
}
}
/**
* 功能说明:构建采购入库提交前的门禁校验结果
* 适用场景:提交采购入库单前统一检查前置条件和异常状态
* @param payload 提交所需的订单、账户、明细和异常统计信息
* @return 校验通过返回 ok=true否则返回不可提交原因
* 注意事项:校验顺序按业务前置条件执行,优先给出最直接的阻断原因
*/
export function buildPurchaseSubmitGuard(payload: {
hasOrder: boolean
hasAccount: boolean
itemCount: number
exceptionCount: number
}): { ok: true } | { ok: false, reason: string } {
// 未选采购订单时直接阻断,避免后续明细和账户校验失去业务上下文
if (!payload.hasOrder) {
return { ok: false, reason: '请先选择采购订单' }
}
// 结算账户是提交单据的必要字段,缺失时不能继续提交
if (!payload.hasAccount) {
return { ok: false, reason: '请选择结算账户' }
}
// 没有扫码明细时提交没有业务意义,需要明确拦截
if (payload.itemCount <= 0) {
return { ok: false, reason: '请先扫描入库明细' }
}
// 存在未处理异常时阻断提交,避免异常数据直接进入正式入库流程
if (payload.exceptionCount > 0) {
return { ok: false, reason: '存在未处理异常,请先处理后再提交' }
}
return { ok: true }
}

89
src/utils/scan.ts Normal file
View File

@@ -0,0 +1,89 @@
/**
* 功能说明:定义扫码明细的最小结构,统一扫码页里的重复合并计算输入。
* 适用场景:扫码其它入库、扫码其它出库的条码累计逻辑。
*/
export interface ScanItem {
warehouseId: number
productId: number
count: number
orderItemId?: number
batchNo?: string
locationCode?: string
}
/**
* 功能说明:清洗扫码枪输入的条码文本,去掉回车、换行和前后空白。
* 适用场景:扫码枪通过键盘模拟输入后,页面提交前统一清洗条码值。
* @param raw 原始扫码内容
* @return 清洗后的条码字符串
* 注意事项:扫码枪通常会追加回车,不先清洗会导致条码查产品接口无法命中。
*/
export function normalizeScanCode(raw: string): string {
return (raw || '').replace(/[\r\n]/g, '').trim()
}
/**
* 功能说明:把相机扫码结果统一转换成业务可用条码。
* 适用场景:`uni.scanCode` 返回对象后,与扫码枪输入共用同一套处理流程。
* @param result uni-app 扫码返回结果
* @return 清洗后的条码字符串
* 注意事项:扫码取消、空返回或结构变化时,需要安全降级为空字符串,避免页面直接抛错。
*/
export function normalizeCameraScanResult(result?: { result?: string } | null): string {
return normalizeScanCode(result?.result || '')
}
/**
* 功能说明:生成扫码明细的合并键,决定重复扫码时应该累加到哪一行。
* 适用场景:自由扫码模式按“仓库 + 产品”合并,订单约束模式再附加订单行编号。
* @param item 当前明细
* @param withOrderConstraint 是否启用订单约束模式
* @return 合并键字符串
* 注意事项:订单约束场景若不带订单行编号,会把不同订单行的同一产品错误合并。
*/
export function buildScanMergeKey(item: ScanItem, withOrderConstraint = false): string {
const segments = [String(item.warehouseId), String(item.productId)]
// 订单约束扫码时需要把订单明细编号带入合并键,避免不同订单行误合并。
if (withOrderConstraint) {
segments.push(String(item.orderItemId || 0))
segments.push(item.batchNo || '')
segments.push(item.locationCode || '')
}
return segments.join(':')
}
/**
* 功能说明:将一次新的扫码结果合并到现有明细列表中。
* 适用场景:连续扫到同一产品时自动累计数量,减少仓库人员手工修改次数。
* @param items 当前明细列表
* @param scannedItem 新扫码得到的明细
* @param withOrderConstraint 是否启用订单约束模式
* @return 合并后的新明细列表
* 注意事项:这里返回新数组而不是原地修改,避免页面状态更新不稳定。
*/
export function mergeScannedItem(
items: ScanItem[],
scannedItem: ScanItem,
withOrderConstraint = false,
): ScanItem[] {
const targetKey = buildScanMergeKey(scannedItem, withOrderConstraint)
const existedIndex = items.findIndex(item => buildScanMergeKey(item, withOrderConstraint) === targetKey)
if (existedIndex === -1) {
return [...items, scannedItem]
}
return items.map((item, index) => {
if (index !== existedIndex) {
return item
}
// 命中同一合并键时只累计数量,避免把已录入明细拆成多行,影响 PDA 连续扫码效率。
return {
...item,
count: Number(item.count || 0) + Number(scannedItem.count || 0),
}
})
}

View File

@@ -101,6 +101,7 @@ export default defineConfig(({ command, mode }) => {
}), }),
// Components 需要在 Uni 之前引入 // Components 需要在 Uni 之前引入
Components({ Components({
resolvers: [WotResolver()],
extensions: ['vue'], extensions: ['vue'],
deep: true, // 是否递归扫描子目录, deep: true, // 是否递归扫描子目录,
directoryAsNamespace: false, // 是否把目录名作为命名空间前缀true 时组件名为 目录名+组件名, directoryAsNamespace: false, // 是否把目录名作为命名空间前缀true 时组件名为 目录名+组件名,
@@ -154,13 +155,6 @@ export default defineConfig(({ command, mode }) => {
}, },
), ),
syncManifestPlugin(), syncManifestPlugin(),
Components({
resolvers: [WotResolver()],
extensions: ['vue'],
deep: true, // 是否递归扫描子目录,
directoryAsNamespace: false, // 是否把目录名作为命名空间前缀true 时组件名为 目录名+组件名,
dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持)
}),
// 自动打开开发者工具插件 (必须修改 .env 文件中的 VITE_WX_APPID) // 自动打开开发者工具插件 (必须修改 .env 文件中的 VITE_WX_APPID)
openDevTools(), openDevTools(),
], ],

File diff suppressed because one or more lines are too long

20
vitest.config.ts Normal file
View File

@@ -0,0 +1,20 @@
import path from 'node:path'
import { defineConfig } from 'vitest/config'
/**
* 功能说明:为纯工具函数测试提供独立的 Vitest 配置,避免 uni-app 构建插件影响测试执行。
* 适用场景:运行扫码工具、数据清洗、明细合并等不依赖页面渲染的单元测试。
* @return Vitest 配置对象
* 注意事项:当前仅解析 `@/` 别名并执行 `src/utils/__tests__` 下的测试,避免把页面编译链路引入测试环境。
*/
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
test: {
environment: 'node',
include: ['src/utils/__tests__/**/*.spec.ts'],
},
})