Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e48dcda74 | |||
| a1217e36b5 | |||
| 2169fec9c1 | |||
| 5f9b83dbda | |||
| 5f964ee82a | |||
|
|
5f68a682a7 | ||
|
|
651cc999a7 | ||
|
|
eac6df3207 | ||
|
|
7859af83b2 | ||
|
|
7f84bbca79 | ||
| 2c203ff4cf | |||
| 4bb81373f5 | |||
| 66f47cdde4 | |||
| 6f1f32df62 | |||
| 505fda77f0 | |||
| 5586e8e39a | |||
| 45eb9232d7 |
@@ -1,3 +1,6 @@
|
||||
module.exports = {
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
ignores: [
|
||||
(message = '') => /^[^::\s]+[::]\s*V\d+(?:\.\d+)*\s+\S+/.test(message.trim()),
|
||||
],
|
||||
}
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -30,8 +30,8 @@ docs/.vitepress/cache
|
||||
src/types
|
||||
# 单独把这个文件排除掉,用以解决部分电脑生成的 auto-import.d.ts 的API不完整导致类型提示报错问题
|
||||
!src/types/auto-import.d.ts
|
||||
src/manifest.json
|
||||
src/pages.json
|
||||
#src/manifest.json
|
||||
#src/pages.json
|
||||
|
||||
# 2025-10-15 by 菲鸽: lock 文件还是需要加入版本管理,今天又遇到版本不一致导致无法运行的问题了。
|
||||
# pnpm-lock.yaml
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
npx lint-staged --allow-empty
|
||||
367
docs/superpowers/specs/2026-05-14-purchase-in-pda-scan-design.md
Normal file
367
docs/superpowers/specs/2026-05-14-purchase-in-pda-scan-design.md
Normal 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 作业台页”:
|
||||
|
||||
- 先锁单,再作业
|
||||
- 一枪一件,自动累计
|
||||
- 正常路径绝不打断
|
||||
- 异常路径明确、可恢复
|
||||
- 明细区服务作业反馈,不服务传统录单表单
|
||||
- 危险操作降级,提交操作集中
|
||||
|
||||
该方案优先满足工厂仓库高频扫码场景,同时保留手机摄像头作为备用输入方式。
|
||||
12
env/.env
vendored
12
env/.env
vendored
@@ -1,7 +1,7 @@
|
||||
VITE_APP_TITLE = '芋道管理系统'
|
||||
VITE_APP_TITLE = '亚为mom小程序'
|
||||
VITE_APP_PORT = 9000
|
||||
|
||||
VITE_UNI_APPID = '__UNI__D1E5001'
|
||||
VITE_UNI_APPID = '__UNI__2EB12DE'
|
||||
VITE_WX_APPID = 'wx1a832d51073d3a35'
|
||||
|
||||
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
|
||||
@@ -10,8 +10,8 @@ VITE_WX_APPID = 'wx1a832d51073d3a35'
|
||||
VITE_APP_PUBLIC_BASE=/
|
||||
|
||||
# 后台请求地址
|
||||
VITE_SERVER_BASEURL = 'http://localhost:48080/admin-api'
|
||||
VITE_UPLOAD_BASEURL = 'http://localhost:48080/upload'
|
||||
VITE_SERVER_BASEURL = 'http://127.0.0.1:48080/admin-api'
|
||||
VITE_UPLOAD_BASEURL = 'http://127.0.0.1:48080/upload'
|
||||
# 备注:如果后台带统一前缀,则也要加到后面,eg: https://ukw0y1.laf.run/api
|
||||
|
||||
# 注意,如果是微信小程序,还有一套请求地址的配置,根据 develop、trial、release 分别设置上传地址,见 `src/utils/index.ts`。
|
||||
@@ -39,8 +39,8 @@ VITE_APP_TENANT_ENABLE=true
|
||||
VITE_APP_CAPTCHA_ENABLE=false
|
||||
# 默认账户密码
|
||||
VITE_APP_DEFAULT_LOGIN_TENANT_ID = 1
|
||||
VITE_APP_DEFAULT_LOGIN_USERNAME = admin
|
||||
VITE_APP_DEFAULT_LOGIN_PASSWORD = admin123
|
||||
VITE_APP_DEFAULT_LOGIN_USERNAME = YAVII
|
||||
VITE_APP_DEFAULT_LOGIN_PASSWORD = yavii123
|
||||
|
||||
# API 加解密
|
||||
VITE_APP_API_ENCRYPT_ENABLE = true
|
||||
|
||||
@@ -82,33 +82,33 @@ export default defineManifestConfig({
|
||||
/* 图标配置 */
|
||||
icons: {
|
||||
android: {
|
||||
hdpi: 'static/app/icons/72x72.png',
|
||||
xhdpi: 'static/app/icons/96x96.png',
|
||||
xxhdpi: 'static/app/icons/144x144.png',
|
||||
xxxhdpi: 'static/app/icons/192x192.png',
|
||||
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: 'static/app/icons/1024x1024.png',
|
||||
appstore: 'src/static/app/icons/1024x1024.png',
|
||||
ipad: {
|
||||
'app': 'static/app/icons/76x76.png',
|
||||
'app@2x': 'static/app/icons/152x152.png',
|
||||
'notification': 'static/app/icons/20x20.png',
|
||||
'notification@2x': 'static/app/icons/40x40.png',
|
||||
'proapp@2x': 'static/app/icons/167x167.png',
|
||||
'settings': 'static/app/icons/29x29.png',
|
||||
'settings@2x': 'static/app/icons/58x58.png',
|
||||
'spotlight': 'static/app/icons/40x40.png',
|
||||
'spotlight@2x': 'static/app/icons/80x80.png',
|
||||
'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': 'static/app/icons/120x120.png',
|
||||
'app@3x': 'static/app/icons/180x180.png',
|
||||
'notification@2x': 'static/app/icons/40x40.png',
|
||||
'notification@3x': 'static/app/icons/60x60.png',
|
||||
'settings@2x': 'static/app/icons/58x58.png',
|
||||
'settings@3x': 'static/app/icons/87x87.png',
|
||||
'spotlight@2x': 'static/app/icons/80x80.png',
|
||||
'spotlight@3x': 'static/app/icons/120x120.png',
|
||||
'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',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -88,11 +88,11 @@
|
||||
"build:quickapp-webview": "uni build -p quickapp-webview",
|
||||
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
|
||||
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
||||
"test": "vitest run --config vitest.config.ts",
|
||||
"type-check": "vue-tsc --noEmit",
|
||||
"init-husky": "git init && husky",
|
||||
"init-baseFiles": "node ./scripts/create-base-files.js",
|
||||
"init-json": "pnpm init-baseFiles",
|
||||
"prepare": "pnpm init-husky & pnpm init-baseFiles",
|
||||
"lint": "eslint",
|
||||
"lint:fix": "eslint --fix"
|
||||
},
|
||||
@@ -173,6 +173,7 @@
|
||||
"unplugin-auto-import": "^20.0.0",
|
||||
"vite": "5.2.8",
|
||||
"vite-plugin-restart": "^1.0.0",
|
||||
"vitest": "^3.2.4",
|
||||
"vue-tsc": "^3.0.6"
|
||||
},
|
||||
"pnpm": {
|
||||
@@ -188,6 +189,6 @@
|
||||
"unconfig": "7.3.2"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*": "eslint --fix"
|
||||
"*.{js,jsx,ts,tsx,vue}": "eslint --fix --cache --cache-location .eslintcache"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
|
||||
import { tabBar } from './src/tabbar/config'
|
||||
|
||||
export default defineUniPages({
|
||||
pages: [],
|
||||
globalStyle: {
|
||||
navigationStyle: 'default',
|
||||
navigationBarTitleText: '芋道管理系统',
|
||||
|
||||
279
pnpm-lock.yaml
generated
279
pnpm-lock.yaml
generated
@@ -135,7 +135,7 @@ importers:
|
||||
version: 20.19.11
|
||||
'@uni-helper/eslint-config':
|
||||
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':
|
||||
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)))
|
||||
@@ -235,6 +235,9 @@ importers:
|
||||
vite-plugin-restart:
|
||||
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))
|
||||
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:
|
||||
specifier: ^3.0.6
|
||||
version: 3.0.6(typescript@5.8.3)
|
||||
@@ -1937,12 +1940,18 @@ packages:
|
||||
'@types/babel__traverse@7.28.0':
|
||||
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':
|
||||
resolution: {integrity: sha512-7uz5EHdzz2TqoMfV7ee61Egf5y6NkcO4FB/1iCCQnbeiI1F3xzv3vK5dBCXUCLQgGYS+mUeigK1iKQzvED+QnQ==}
|
||||
|
||||
'@types/debug@4.1.12':
|
||||
resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}
|
||||
|
||||
'@types/deep-eql@4.0.2':
|
||||
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
|
||||
|
||||
'@types/estree@1.0.8':
|
||||
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
||||
|
||||
@@ -2345,6 +2354,35 @@ packages:
|
||||
vitest:
|
||||
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':
|
||||
resolution: {integrity: sha512-hEEd5ET/oSmBC6pi1j6NaNYRWoAiDhINbT8rmwtINugR39loROSlufGdYMF9TaKGfz+ViGs1Idi3mAhnuPcoGQ==}
|
||||
|
||||
@@ -2565,6 +2603,10 @@ packages:
|
||||
array-timsort@1.0.3:
|
||||
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:
|
||||
resolution: {integrity: sha512-qdwwKEhckRk0XE22/xDdmU3v/60E8Edu4qFhgTLIhGGDs/PAJwLw9pQn8Rj99PitlbBZbYpx0k/lbir4kg0SuA==}
|
||||
engines: {node: '>=16.14.0'}
|
||||
@@ -2758,6 +2800,10 @@ packages:
|
||||
centra@2.7.0:
|
||||
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:
|
||||
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
||||
engines: {node: '>=10'}
|
||||
@@ -2776,6 +2822,10 @@ packages:
|
||||
character-entities@2.0.2:
|
||||
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:
|
||||
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
||||
engines: {node: '>= 8.10.0'}
|
||||
@@ -3045,6 +3095,10 @@ packages:
|
||||
dedent@0.7.0:
|
||||
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:
|
||||
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
||||
|
||||
@@ -3478,6 +3532,10 @@ packages:
|
||||
resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==}
|
||||
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:
|
||||
resolution: {integrity: sha512-E1q5hSUG2AmYQwQJ041nvgpkODHQvB+RKlB4IYdru6uJsyFTRyZAP463M+1lINorwbqAmUggi6+WwkD8lCS/Dw==}
|
||||
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
|
||||
@@ -4299,6 +4357,9 @@ packages:
|
||||
longest-streak@3.1.0:
|
||||
resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
|
||||
|
||||
loupe@3.2.1:
|
||||
resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==}
|
||||
|
||||
lru-cache@5.1.1:
|
||||
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
|
||||
|
||||
@@ -4782,6 +4843,10 @@ packages:
|
||||
pathe@2.0.3:
|
||||
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:
|
||||
resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==}
|
||||
|
||||
@@ -5210,6 +5275,9 @@ packages:
|
||||
resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
siginfo@2.0.0:
|
||||
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
|
||||
|
||||
signal-exit@3.0.7:
|
||||
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
|
||||
|
||||
@@ -5271,6 +5339,9 @@ packages:
|
||||
resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
stackback@0.0.2:
|
||||
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
|
||||
|
||||
statuses@2.0.1:
|
||||
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
@@ -5399,6 +5470,9 @@ packages:
|
||||
timm@1.7.1:
|
||||
resolution: {integrity: sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==}
|
||||
|
||||
tinybench@2.9.0:
|
||||
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
|
||||
|
||||
tinycolor2@1.6.0:
|
||||
resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
|
||||
|
||||
@@ -5416,6 +5490,18 @@ packages:
|
||||
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
|
||||
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:
|
||||
resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
|
||||
|
||||
@@ -5652,6 +5738,11 @@ packages:
|
||||
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
|
||||
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:
|
||||
resolution: {integrity: sha512-t2ktkTOa+DQX05TEZm/3FE0DyrYEyFXdhG5gLcta5p71zOpg9yG3DeRcHWJVLJgWNoaVtOr4fUlr1kKu+WfXyQ==}
|
||||
peerDependencies:
|
||||
@@ -5685,6 +5776,34 @@ packages:
|
||||
terser:
|
||||
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:
|
||||
resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==}
|
||||
|
||||
@@ -5772,6 +5891,11 @@ packages:
|
||||
engines: {node: '>= 8'}
|
||||
hasBin: true
|
||||
|
||||
why-is-node-running@2.3.0:
|
||||
resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
|
||||
engines: {node: '>=8'}
|
||||
hasBin: true
|
||||
|
||||
word-wrap@1.2.5:
|
||||
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -5916,7 +6040,7 @@ snapshots:
|
||||
'@jridgewell/gen-mapping': 0.3.13
|
||||
'@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:
|
||||
'@antfu/install-pkg': 1.1.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))
|
||||
'@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)
|
||||
'@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
|
||||
cac: 6.7.14
|
||||
eslint: 9.34.0(jiti@2.6.1)
|
||||
@@ -8508,6 +8632,11 @@ snapshots:
|
||||
dependencies:
|
||||
'@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':
|
||||
dependencies:
|
||||
'@types/node': 20.19.11
|
||||
@@ -8516,6 +8645,8 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/ms': 2.1.0
|
||||
|
||||
'@types/deep-eql@4.0.2': {}
|
||||
|
||||
'@types/estree@1.0.8': {}
|
||||
|
||||
'@types/graceful-fs@4.1.9':
|
||||
@@ -8711,9 +8842,9 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.46.0
|
||||
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:
|
||||
'@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: 9.34.0(jiti@2.6.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)
|
||||
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:
|
||||
'@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)
|
||||
eslint: 9.34.0(jiti@2.6.1)
|
||||
optionalDependencies:
|
||||
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:
|
||||
- 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':
|
||||
dependencies:
|
||||
'@volar/source-map': 2.4.23
|
||||
@@ -9383,6 +9557,8 @@ snapshots:
|
||||
|
||||
array-timsort@1.0.3: {}
|
||||
|
||||
assertion-error@2.0.1: {}
|
||||
|
||||
ast-kit@0.11.3(rollup@4.50.0):
|
||||
dependencies:
|
||||
'@babel/parser': 7.28.3
|
||||
@@ -9633,6 +9809,14 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- 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:
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
@@ -9646,6 +9830,8 @@ snapshots:
|
||||
|
||||
character-entities@2.0.2: {}
|
||||
|
||||
check-error@2.1.3: {}
|
||||
|
||||
chokidar@3.6.0:
|
||||
dependencies:
|
||||
anymatch: 3.1.3
|
||||
@@ -9877,6 +10063,8 @@ snapshots:
|
||||
|
||||
dedent@0.7.0: {}
|
||||
|
||||
deep-eql@5.0.2: {}
|
||||
|
||||
deep-is@0.1.4: {}
|
||||
|
||||
deepmerge@4.3.1: {}
|
||||
@@ -10381,6 +10569,8 @@ snapshots:
|
||||
|
||||
exit@0.1.2: {}
|
||||
|
||||
expect-type@1.3.0: {}
|
||||
|
||||
expect@27.5.1:
|
||||
dependencies:
|
||||
'@jest/types': 27.5.1
|
||||
@@ -11427,6 +11617,8 @@ snapshots:
|
||||
|
||||
longest-streak@3.1.0: {}
|
||||
|
||||
loupe@3.2.1: {}
|
||||
|
||||
lru-cache@5.1.1:
|
||||
dependencies:
|
||||
yallist: 3.1.1
|
||||
@@ -12045,6 +12237,8 @@ snapshots:
|
||||
|
||||
pathe@2.0.3: {}
|
||||
|
||||
pathval@2.0.1: {}
|
||||
|
||||
perfect-debounce@1.0.0: {}
|
||||
|
||||
phin@2.9.3: {}
|
||||
@@ -12475,6 +12669,8 @@ snapshots:
|
||||
side-channel-map: 1.0.1
|
||||
side-channel-weakmap: 1.0.2
|
||||
|
||||
siginfo@2.0.0: {}
|
||||
|
||||
signal-exit@3.0.7: {}
|
||||
|
||||
signal-exit@4.1.0: {}
|
||||
@@ -12527,6 +12723,8 @@ snapshots:
|
||||
dependencies:
|
||||
escape-string-regexp: 2.0.0
|
||||
|
||||
stackback@0.0.2: {}
|
||||
|
||||
statuses@2.0.1: {}
|
||||
|
||||
std-env@3.9.0: {}
|
||||
@@ -12645,6 +12843,8 @@ snapshots:
|
||||
|
||||
timm@1.7.1: {}
|
||||
|
||||
tinybench@2.9.0: {}
|
||||
|
||||
tinycolor2@1.6.0: {}
|
||||
|
||||
tinyexec@0.3.2: {}
|
||||
@@ -12661,6 +12861,12 @@ snapshots:
|
||||
fdir: 6.5.0(picomatch@4.0.3)
|
||||
picomatch: 4.0.3
|
||||
|
||||
tinypool@1.1.1: {}
|
||||
|
||||
tinyrainbow@2.0.0: {}
|
||||
|
||||
tinyspy@4.0.4: {}
|
||||
|
||||
tmpl@1.0.5: {}
|
||||
|
||||
to-regex-range@5.0.1:
|
||||
@@ -12946,6 +13152,23 @@ snapshots:
|
||||
|
||||
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)):
|
||||
dependencies:
|
||||
micromatch: 4.0.8
|
||||
@@ -12962,6 +13185,45 @@ snapshots:
|
||||
sass: 1.77.8
|
||||
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: {}
|
||||
|
||||
vue-demi@0.14.10(vue@3.4.21(typescript@5.8.3)):
|
||||
@@ -13047,6 +13309,11 @@ snapshots:
|
||||
dependencies:
|
||||
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: {}
|
||||
|
||||
wot-design-uni@1.13.0(vue@3.4.21(typescript@5.8.3)):
|
||||
|
||||
74
src/api/agri/biz/flow.ts
Normal file
74
src/api/agri/biz/flow.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
export interface AgriHarvestSubmitReqVO {
|
||||
batchType: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
plotId?: number
|
||||
plotName?: string
|
||||
farmerId?: number
|
||||
quantity?: number
|
||||
unit?: string
|
||||
harvestTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriSortingSubmitReqVO {
|
||||
batchId: number
|
||||
weightResult?: number
|
||||
unqualifiedCategory?: string
|
||||
imageUrl?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriPackingSubmitReqVO {
|
||||
batchId: number
|
||||
netWeight?: number
|
||||
labelCode?: string
|
||||
packingTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriWarehouseInReqVO {
|
||||
batchId: number
|
||||
inMode?: string
|
||||
warehouseTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriShipmentDispatchReqVO {
|
||||
batchId: number
|
||||
vehicleNo: string
|
||||
boxCount?: number
|
||||
shipmentTime?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface AgriShipmentSignReqVO {
|
||||
batchId: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export function submitHarvest(data: AgriHarvestSubmitReqVO) {
|
||||
return http.post<number>('/agri/biz/flow/harvest', data)
|
||||
}
|
||||
|
||||
export function submitSorting(data: AgriSortingSubmitReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/sorting', data)
|
||||
}
|
||||
|
||||
export function submitPacking(data: AgriPackingSubmitReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/packing', data)
|
||||
}
|
||||
|
||||
export function submitWarehouseIn(data: AgriWarehouseInReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/warehouse-in', data)
|
||||
}
|
||||
|
||||
export function dispatchShipment(data: AgriShipmentDispatchReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/shipment-dispatch', data)
|
||||
}
|
||||
|
||||
export function signShipment(data: AgriShipmentSignReqVO) {
|
||||
return http.post<void>('/agri/biz/flow/shipment-sign', data)
|
||||
}
|
||||
45
src/api/agri/trace/snapshot.ts
Normal file
45
src/api/agri/trace/snapshot.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
export interface AgriTraceSnapshotVO {
|
||||
id: number
|
||||
traceCode: string
|
||||
batchId: number
|
||||
batchNo: string
|
||||
productName?: string
|
||||
plotName?: string
|
||||
harvestTime?: string
|
||||
harvestOperatorId?: number
|
||||
harvestOperatorName?: string
|
||||
packingTime?: string
|
||||
packingOperatorId?: number
|
||||
packingOperatorName?: string
|
||||
warehouseTime?: string
|
||||
warehouseOperatorId?: number
|
||||
warehouseOperatorName?: string
|
||||
shipmentTime?: string
|
||||
shipmentOperatorId?: number
|
||||
shipmentOperatorName?: string
|
||||
vehicleNo?: string
|
||||
invoiceStatus?: string
|
||||
snapshotJson?: string
|
||||
}
|
||||
|
||||
export interface AgriTraceSnapshotPageReqVO extends PageParam {
|
||||
batchId?: number
|
||||
batchNo?: string
|
||||
traceCode?: string
|
||||
productName?: string
|
||||
}
|
||||
|
||||
export function getAgriTraceSnapshotPage(params: AgriTraceSnapshotPageReqVO) {
|
||||
return http.get<PageResult<AgriTraceSnapshotVO>>('/agri/trace/snapshot/page', params)
|
||||
}
|
||||
|
||||
export function getAgriTraceSnapshot(id: number) {
|
||||
return http.get<AgriTraceSnapshotVO>(`/agri/trace/snapshot/get?id=${id}`)
|
||||
}
|
||||
|
||||
export function getAgriTraceSnapshotByTraceCode(traceCode: string) {
|
||||
return http.get<AgriTraceSnapshotVO>('/agri/trace/snapshot/get-by-trace-code', { traceCode })
|
||||
}
|
||||
82
src/api/erp/approval/index.ts
Normal file
82
src/api/erp/approval/index.ts
Normal 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 })
|
||||
}
|
||||
13
src/api/erp/box/index.ts
Normal file
13
src/api/erp/box/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 框管理记录 */
|
||||
export interface Box {
|
||||
id?: number
|
||||
boxNumber: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** 获取框管理分页列表(用于提取框编号) */
|
||||
export function getBoxPage(params?: Record<string, any>) {
|
||||
return http.get<{ list: Box[], total: number }>('/erp/box/page', { pageNo: 1, pageSize: 100, ...params })
|
||||
}
|
||||
12
src/api/erp/customer/index.ts
Normal file
12
src/api/erp/customer/index.ts
Normal 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')
|
||||
}
|
||||
73
src/api/erp/farmer/index.ts
Normal file
73
src/api/erp/farmer/index.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 农户信息 */
|
||||
export interface Farmer {
|
||||
id?: number
|
||||
name?: string
|
||||
idCardNumber?: string
|
||||
mobile?: string
|
||||
address?: string
|
||||
plantingBase?: string
|
||||
contractNumber?: string
|
||||
contractedArea?: number
|
||||
orderQuantity?: number
|
||||
actualArea?: number
|
||||
transplantTime?: string
|
||||
transplantQuantity?: number
|
||||
maturityTime?: string
|
||||
expectedHarvestTime?: string
|
||||
usedVariety?: string
|
||||
plantingMethod?: string
|
||||
adminName?: string
|
||||
contact?: string
|
||||
telephone?: string
|
||||
email?: string
|
||||
fax?: string
|
||||
remark?: string
|
||||
status?: number
|
||||
sort?: number
|
||||
taxNo?: string
|
||||
taxPercent?: number
|
||||
bankName?: string
|
||||
bankAccount?: string
|
||||
bankAddress?: string
|
||||
}
|
||||
|
||||
/** 品种选项 */
|
||||
export const VARIETY_OPTIONS = [
|
||||
{ value: '红宝石', label: '红宝石' },
|
||||
{ value: '1401', label: '1401' },
|
||||
{ value: '1501', label: '1501' },
|
||||
{ value: '3366', label: '3366' },
|
||||
]
|
||||
|
||||
/** 获取农户分页列表 */
|
||||
export function getFarmerPage(params: PageParam) {
|
||||
return http.get<PageResult<Farmer>>('/erp/farmer/page', { ...params, type: 2 })
|
||||
}
|
||||
|
||||
/** 获取农户详情 */
|
||||
export function getFarmer(id: number) {
|
||||
return http.get<Farmer>(`/erp/farmer/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建农户 */
|
||||
export function createFarmer(data: Farmer) {
|
||||
return http.post<number>('/erp/farmer/create', data)
|
||||
}
|
||||
|
||||
/** 更新农户 */
|
||||
export function updateFarmer(data: Farmer) {
|
||||
return http.put<boolean>('/erp/farmer/update', data)
|
||||
}
|
||||
|
||||
/** 删除农户 */
|
||||
export function deleteFarmer(id: number) {
|
||||
return http.delete<boolean>(`/erp/farmer/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取农户精简列表 */
|
||||
export function getFarmerSimpleList() {
|
||||
return http.get<Farmer[]>('/erp/farmer/simple-list')
|
||||
}
|
||||
13
src/api/erp/farming/index.ts
Normal file
13
src/api/erp/farming/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 田间管理记录 */
|
||||
export interface FarmingManagement {
|
||||
id?: number
|
||||
code: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** 获取田间管理分页列表(用于提取田间编号) */
|
||||
export function getFarmingManagementPage(params?: Record<string, any>) {
|
||||
return http.get<{ list: FarmingManagement[], total: number }>('/erp/farming-management/page', { pageNo: 1, pageSize: 100, ...params })
|
||||
}
|
||||
14
src/api/erp/location/index.ts
Normal file
14
src/api/erp/location/index.ts
Normal 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 })
|
||||
}
|
||||
85
src/api/erp/pick-broccoli/index.ts
Normal file
85
src/api/erp/pick-broccoli/index.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 西兰花采摘记录信息 */
|
||||
export interface PickBroccoli {
|
||||
id?: number
|
||||
pickCode?: string
|
||||
userId?: number
|
||||
userName?: string
|
||||
fieldCode?: string
|
||||
fieldName?: string
|
||||
basketCode?: string
|
||||
basketWeight?: number
|
||||
licensePlate?: string
|
||||
pickTime?: string
|
||||
loadTime?: string
|
||||
loaderId?: number
|
||||
loaderName?: string
|
||||
status?: number
|
||||
unloadTime?: string
|
||||
unloaderId?: number
|
||||
unloaderName?: string
|
||||
warehouseId?: string
|
||||
warehouseName?: string
|
||||
unloadBatch?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
remark?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
/** 获取采摘记录分页列表 */
|
||||
export function getPickBroccoliPage(params: PageParam) {
|
||||
return http.get<PageResult<PickBroccoli>>('/erp/pick-broccoli/page', params)
|
||||
}
|
||||
|
||||
/** 获取采摘记录详情 */
|
||||
export function getPickBroccoli(id: number) {
|
||||
return http.get<PickBroccoli>(`/erp/pick-broccoli/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采摘记录 */
|
||||
export function createPickBroccoli(data: PickBroccoli) {
|
||||
return http.post<number>('/erp/pick-broccoli/create', data)
|
||||
}
|
||||
|
||||
/** 更新采摘记录 */
|
||||
export function updatePickBroccoli(data: PickBroccoli) {
|
||||
return http.put<boolean>('/erp/pick-broccoli/update', data)
|
||||
}
|
||||
|
||||
/** 删除采摘记录 */
|
||||
export function deletePickBroccoli(id: number) {
|
||||
return http.delete<boolean>(`/erp/pick-broccoli/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 更新采摘记录状态 */
|
||||
export function updatePickBroccoliStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/pick-broccoli/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 装车操作 */
|
||||
export function loadTruck(id: number, licensePlate: string, loaderId: number, loaderName: string) {
|
||||
return http.put<boolean>(`/erp/pick-broccoli/load-truck?id=${id}&licensePlate=${licensePlate}&loaderId=${loaderId}&loaderName=${loaderName}`)
|
||||
}
|
||||
|
||||
/** 卸车入库操作 */
|
||||
export function unloadTruck(licensePlate: string, unloaderId: number, unloaderName: string, warehouseId: string, warehouseName: string) {
|
||||
return http.put<boolean>(`/erp/pick-broccoli/unload-truck?licensePlate=${licensePlate}&unloaderId=${unloaderId}&unloaderName=${unloaderName}&warehouseId=${warehouseId}&warehouseName=${warehouseName}`)
|
||||
}
|
||||
|
||||
/** 获取已装车车辆列表 */
|
||||
export function getLoadedTrucks() {
|
||||
return http.get<any[]>('/erp/pick-broccoli/list-loaded-trucks')
|
||||
}
|
||||
|
||||
/** 卸车预览 */
|
||||
export function getUnloadPreview(licensePlate: string) {
|
||||
return http.get<any>(`/erp/pick-broccoli/unload-preview?licensePlate=${licensePlate}`)
|
||||
}
|
||||
|
||||
/** 生成采摘编号 */
|
||||
export function generatePickCode() {
|
||||
return http.get<{ code: string }>('/erp/pick-broccoli/generate-code')
|
||||
}
|
||||
38
src/api/erp/product/index.ts
Normal file
38
src/api/erp/product/index.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 产品精简信息 */
|
||||
export interface ProductSimple {
|
||||
id: number
|
||||
name: string
|
||||
barCode?: string
|
||||
unitId?: number
|
||||
unitName?: string
|
||||
standard?: string
|
||||
purchasePrice?: number
|
||||
salePrice?: number
|
||||
minPrice?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
weight?: number
|
||||
}
|
||||
|
||||
/** 按条码查询的产品信息 */
|
||||
export interface ProductByBarCode {
|
||||
id: number
|
||||
name: string
|
||||
barCode?: string
|
||||
unitId?: number
|
||||
unitName?: string
|
||||
standard?: string
|
||||
minPrice?: number
|
||||
}
|
||||
|
||||
/** 获取产品精简列表 */
|
||||
export function getProductSimpleList() {
|
||||
return http.get<ProductSimple[]>('/erp/product/simple-list')
|
||||
}
|
||||
|
||||
/** 按条码查询启用中的产品 */
|
||||
export function getProductByBarCode(barCode: string) {
|
||||
return http.get<ProductByBarCode>('/erp/product/get-by-barcode', { barCode })
|
||||
}
|
||||
42
src/api/erp/purchase-in-scan-record/index.ts
Normal file
42
src/api/erp/purchase-in-scan-record/index.ts
Normal 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}`)
|
||||
}
|
||||
113
src/api/erp/purchase-in/index.ts
Normal file
113
src/api/erp/purchase-in/index.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 采购入库项 */
|
||||
export interface PurchaseInItem {
|
||||
id?: number
|
||||
productId: number
|
||||
productUnitId: number
|
||||
productPrice?: number
|
||||
count: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
remark?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
batchNo?: string
|
||||
locationCode?: string
|
||||
productName?: string
|
||||
productBarCode?: string
|
||||
productUnitName?: string
|
||||
productSpec?: string
|
||||
productCategoryName?: string
|
||||
stockCount?: number
|
||||
totalCount?: number
|
||||
inCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
orderItemId?: number
|
||||
}
|
||||
|
||||
/** 采购入库信息 */
|
||||
export interface PurchaseIn {
|
||||
id?: number
|
||||
no?: string
|
||||
status?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
accountId?: number
|
||||
accountName?: string
|
||||
inTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
discountPercent?: number
|
||||
discountPrice?: number
|
||||
otherPrice?: number
|
||||
paymentPrice?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
creator?: string
|
||||
creatorName?: string
|
||||
createTime?: string
|
||||
items?: PurchaseInItem[]
|
||||
productNames?: string
|
||||
orderId?: number
|
||||
orderNo?: string
|
||||
isQualified?: boolean
|
||||
returnType?: string | null
|
||||
returnRemark?: string
|
||||
hasApprovalRecords?: boolean
|
||||
}
|
||||
|
||||
/** 审核表单数据 */
|
||||
export interface AuditFormData {
|
||||
id: number
|
||||
isQualified: boolean
|
||||
returnType?: string
|
||||
returnRemark?: string
|
||||
status: number
|
||||
}
|
||||
|
||||
/** 返回方式枚举 */
|
||||
export const RETURN_TYPE_ENUM = {
|
||||
RETURN_BACK: 'return_back',
|
||||
DESTROY: 'destroy',
|
||||
}
|
||||
|
||||
/** 返回方式选项 */
|
||||
export const RETURN_TYPE_OPTIONS = [
|
||||
{ label: '原路返回', value: RETURN_TYPE_ENUM.RETURN_BACK },
|
||||
{ label: '就地销毁', value: RETURN_TYPE_ENUM.DESTROY },
|
||||
]
|
||||
|
||||
/** 获取采购入库分页列表 */
|
||||
export function getPurchaseInPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseIn>>('/erp/purchase-in/page', params)
|
||||
}
|
||||
|
||||
/** 获取采购入库详情 */
|
||||
export function getPurchaseIn(id: number) {
|
||||
return http.get<PurchaseIn>(`/erp/purchase-in/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采购入库 */
|
||||
export function createPurchaseIn(data: PurchaseIn) {
|
||||
return http.post<number>('/erp/purchase-in/create', data)
|
||||
}
|
||||
|
||||
/** 更新采购入库 */
|
||||
export function updatePurchaseIn(data: PurchaseIn) {
|
||||
return http.put<boolean>('/erp/purchase-in/update', data)
|
||||
}
|
||||
|
||||
/** 更新采购入库状态 */
|
||||
export function updatePurchaseInStatus(data: AuditFormData) {
|
||||
return http.put<boolean>('/erp/purchase-in/update-status', data)
|
||||
}
|
||||
|
||||
/** 删除采购入库 */
|
||||
export function deletePurchaseIn(ids: number[]) {
|
||||
return http.delete<boolean>(`/erp/purchase-in/delete?ids=${ids.join(',')}`)
|
||||
}
|
||||
90
src/api/erp/purchase-order/index.ts
Normal file
90
src/api/erp/purchase-order/index.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 采购订单项 */
|
||||
export interface PurchaseOrderItem {
|
||||
id?: number
|
||||
productId: number
|
||||
productUnitId: number
|
||||
productPrice?: number
|
||||
count: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
remark?: string
|
||||
inCount?: number
|
||||
returnCount?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
productName?: string
|
||||
productBarCode?: string
|
||||
productUnitName?: string
|
||||
stockCount?: number
|
||||
productSpec?: string
|
||||
}
|
||||
|
||||
/** 采购订单信息 */
|
||||
export interface PurchaseOrder {
|
||||
id?: number
|
||||
no?: string
|
||||
status?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
accountId?: number
|
||||
orderTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
discountPercent?: number
|
||||
discountPrice?: number
|
||||
depositPrice?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
creator?: string
|
||||
creatorName?: string
|
||||
createTime?: string
|
||||
items?: PurchaseOrderItem[]
|
||||
productNames?: string
|
||||
inCount?: number
|
||||
returnCount?: number
|
||||
auditorId?: number
|
||||
auditorName?: string
|
||||
purchaseRequisitionId?: number
|
||||
purchaseRequisitionNo?: string
|
||||
invoiceType?: number
|
||||
invoiceTypeName?: string
|
||||
freightPayer?: number
|
||||
freightPayerName?: string
|
||||
settlementMethod?: number
|
||||
settlementMethodName?: string
|
||||
}
|
||||
|
||||
/** 获取采购订单分页列表 */
|
||||
export function getPurchaseOrderPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseOrder>>('/erp/purchase-order/page', params)
|
||||
}
|
||||
|
||||
/** 获取采购订单详情 */
|
||||
export function getPurchaseOrder(id: number) {
|
||||
return http.get<PurchaseOrder>(`/erp/purchase-order/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采购订单 */
|
||||
export function createPurchaseOrder(data: PurchaseOrder) {
|
||||
return http.post<number>('/erp/purchase-order/create', data)
|
||||
}
|
||||
|
||||
/** 更新采购订单 */
|
||||
export function updatePurchaseOrder(data: PurchaseOrder) {
|
||||
return http.put<boolean>('/erp/purchase-order/update', data)
|
||||
}
|
||||
|
||||
/** 更新采购订单状态 */
|
||||
export function updatePurchaseOrderStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/purchase-order/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 删除采购订单 */
|
||||
export function deletePurchaseOrder(ids: number[]) {
|
||||
return http.delete<boolean>(`/erp/purchase-order/delete?ids=${ids.join(',')}`)
|
||||
}
|
||||
126
src/api/erp/purchase-requisition/index.ts
Normal file
126
src/api/erp/purchase-requisition/index.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 请购单明细信息 */
|
||||
export interface PurchaseRequisitionItem {
|
||||
id?: number
|
||||
requisitionId?: number
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitId?: number
|
||||
productUnitName?: string
|
||||
productSpec?: string
|
||||
productBarCode?: string
|
||||
productPrice?: number
|
||||
count?: number
|
||||
totalProductPrice?: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
totalPrice?: number
|
||||
purpose?: string
|
||||
brandId?: number
|
||||
brandName?: string
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
approveCount?: number
|
||||
purchaseCount?: number
|
||||
remark?: string
|
||||
createTime?: string
|
||||
saleOrderId?: number
|
||||
saleOrderNo?: string
|
||||
}
|
||||
|
||||
/** 请购单信息 */
|
||||
export interface PurchaseRequisition {
|
||||
id?: number
|
||||
no?: string
|
||||
type?: number
|
||||
priority?: number
|
||||
status?: number
|
||||
requesterId?: number
|
||||
requesterName?: string
|
||||
requesterNickname?: string
|
||||
requesterDeptId?: number
|
||||
requesterDeptName?: string
|
||||
requestTime?: string
|
||||
expectedTime?: string
|
||||
approverId?: number
|
||||
approverName?: string
|
||||
approveTime?: string
|
||||
approveRemark?: string
|
||||
totalCount?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
totalPrice?: number
|
||||
additionalFee?: number
|
||||
emergencyDegree?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
items?: PurchaseRequisitionItem[]
|
||||
hasApprovalRecords?: boolean
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取请购单分页列表 */
|
||||
export function getPurchaseRequisitionPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseRequisition>>('/erp/purchase-requisition/page', params)
|
||||
}
|
||||
|
||||
/** 获取请购单详情 */
|
||||
export function getPurchaseRequisition(id: number) {
|
||||
return http.get<PurchaseRequisition>(`/erp/purchase-requisition/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建请购单 */
|
||||
export function createPurchaseRequisition(data: PurchaseRequisition) {
|
||||
return http.post<number>('/erp/purchase-requisition/create', data)
|
||||
}
|
||||
|
||||
/** 更新请购单 */
|
||||
export function updatePurchaseRequisition(data: PurchaseRequisition) {
|
||||
return http.put<boolean>('/erp/purchase-requisition/update', data)
|
||||
}
|
||||
|
||||
/** 删除请购单 */
|
||||
export function deletePurchaseRequisition(id: number) {
|
||||
return http.delete<boolean>(`/erp/purchase-requisition/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 更新请购单状态 */
|
||||
export function updatePurchaseRequisitionStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/purchase-requisition/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 请购类型选项 */
|
||||
export const REQUISITION_TYPE_OPTIONS = [
|
||||
{ value: 1, label: '请购' },
|
||||
{ value: 2, label: '补货' },
|
||||
{ value: 3, label: '其他' },
|
||||
]
|
||||
|
||||
/** 优先级选项 */
|
||||
export const PRIORITY_OPTIONS = [
|
||||
{ value: 1, label: '低' },
|
||||
{ value: 2, label: '中' },
|
||||
{ value: 3, label: '高' },
|
||||
{ value: 4, label: '紧急' },
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
export const STATUS_OPTIONS = [
|
||||
{ value: 1, label: '待审核' },
|
||||
{ value: 2, label: '已审核' },
|
||||
{ value: 3, label: '已驳回' },
|
||||
{ value: 4, label: '已取消' },
|
||||
{ value: 5, label: '已采购' },
|
||||
]
|
||||
|
||||
/** 紧急程度选项 */
|
||||
export const EMERGENCY_OPTIONS = [
|
||||
{ value: 1, label: '普通' },
|
||||
{ value: 2, label: '较急' },
|
||||
{ value: 3, label: '紧急' },
|
||||
{ value: 4, label: '特急' },
|
||||
]
|
||||
87
src/api/erp/purchase-return/index.ts
Normal file
87
src/api/erp/purchase-return/index.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 采购退货项 */
|
||||
export interface PurchaseReturnItem {
|
||||
id?: number
|
||||
productId: number
|
||||
productUnitId: number
|
||||
productPrice?: number
|
||||
count: number
|
||||
taxPercent?: number
|
||||
taxPrice?: number
|
||||
remark?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productName?: string
|
||||
productBarCode?: string
|
||||
productUnitName?: string
|
||||
productSpec?: string
|
||||
productCategoryName?: string
|
||||
stockCount?: number
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
orderItemId?: number
|
||||
inCount?: number
|
||||
returnCount?: number
|
||||
}
|
||||
|
||||
/** 采购退货信息 */
|
||||
export interface PurchaseReturn {
|
||||
id?: number
|
||||
no?: string
|
||||
status?: number
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
accountId?: number
|
||||
accountName?: string
|
||||
returnTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
totalProductPrice?: number
|
||||
totalTaxPrice?: number
|
||||
discountPercent?: number
|
||||
discountPrice?: number
|
||||
otherPrice?: number
|
||||
refundPrice?: number
|
||||
fileUrl?: string
|
||||
remark?: string
|
||||
creator?: string
|
||||
creatorName?: string
|
||||
createTime?: string
|
||||
items?: PurchaseReturnItem[]
|
||||
productNames?: string
|
||||
orderId?: number
|
||||
orderNo?: string
|
||||
}
|
||||
|
||||
/** 获取采购退货分页列表 */
|
||||
export function getPurchaseReturnPage(params: PageParam) {
|
||||
return http.get<PageResult<PurchaseReturn>>('/erp/purchase-return/page', params)
|
||||
}
|
||||
|
||||
/** 获取采购退货详情 */
|
||||
export function getPurchaseReturn(id: number) {
|
||||
return http.get<PurchaseReturn>(`/erp/purchase-return/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建采购退货 */
|
||||
export function createPurchaseReturn(data: PurchaseReturn) {
|
||||
return http.post<number>('/erp/purchase-return/create', data)
|
||||
}
|
||||
|
||||
/** 更新采购退货 */
|
||||
export function updatePurchaseReturn(data: PurchaseReturn) {
|
||||
return http.put<boolean>('/erp/purchase-return/update', data)
|
||||
}
|
||||
|
||||
/** 更新采购退货状态 */
|
||||
export function updatePurchaseReturnStatus(id: number, status: number) {
|
||||
return http.put<boolean>(`/erp/purchase-return/update-status?id=${id}&status=${status}`)
|
||||
}
|
||||
|
||||
/** 删除采购退货 */
|
||||
export function deletePurchaseReturn(ids: number[]) {
|
||||
return http.delete<boolean>(`/erp/purchase-return/delete?ids=${ids.join(',')}`)
|
||||
}
|
||||
42
src/api/erp/sale-out-scan-record/index.ts
Normal file
42
src/api/erp/sale-out-scan-record/index.ts
Normal 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}`)
|
||||
}
|
||||
91
src/api/erp/sale-out/index.ts
Normal file
91
src/api/erp/sale-out/index.ts
Normal 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(',')}`)
|
||||
}
|
||||
64
src/api/erp/stock-check/index.ts
Normal file
64
src/api/erp/stock-check/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 盘点单项 */
|
||||
export interface StockCheckItem {
|
||||
id?: number
|
||||
stockCheckId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
stockCount?: number
|
||||
actualCount?: number
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 盘点单信息 */
|
||||
export interface StockCheck {
|
||||
id?: number
|
||||
no?: string
|
||||
checkTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockCheckItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取盘点单分页列表 */
|
||||
export function getStockCheckPage(params: PageParam) {
|
||||
return http.get<PageResult<StockCheck>>('/erp/stock-check/page', params)
|
||||
}
|
||||
|
||||
/** 获取盘点单详情 */
|
||||
export function getStockCheck(id: number) {
|
||||
return http.get<StockCheck>(`/erp/stock-check/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建盘点单 */
|
||||
export function createStockCheck(data: StockCheck) {
|
||||
return http.post<number>('/erp/stock-check/create', data)
|
||||
}
|
||||
|
||||
/** 更新盘点单 */
|
||||
export function updateStockCheck(data: StockCheck) {
|
||||
return http.put<boolean>('/erp/stock-check/update', data)
|
||||
}
|
||||
|
||||
/** 更新盘点单状态 */
|
||||
export function updateStockCheckStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-check/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除盘点单 */
|
||||
export function deleteStockCheck(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-check/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
63
src/api/erp/stock-gain/index.ts
Normal file
63
src/api/erp/stock-gain/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 报溢单项 */
|
||||
export interface StockGainItem {
|
||||
id?: number
|
||||
stockGainId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 报溢单信息 */
|
||||
export interface StockGain {
|
||||
id?: number
|
||||
no?: string
|
||||
gainTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
reason?: string
|
||||
remark?: string
|
||||
items?: StockGainItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取报溢单分页列表 */
|
||||
export function getStockGainPage(params: PageParam) {
|
||||
return http.get<PageResult<StockGain>>('/erp/stock-gain/page', params)
|
||||
}
|
||||
|
||||
/** 获取报溢单详情 */
|
||||
export function getStockGain(id: number) {
|
||||
return http.get<StockGain>(`/erp/stock-gain/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建报溢单 */
|
||||
export function createStockGain(data: StockGain) {
|
||||
return http.post<number>('/erp/stock-gain/create', data)
|
||||
}
|
||||
|
||||
/** 更新报溢单 */
|
||||
export function updateStockGain(data: StockGain) {
|
||||
return http.put<boolean>('/erp/stock-gain/update', data)
|
||||
}
|
||||
|
||||
/** 更新报溢单状态 */
|
||||
export function updateStockGainStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-gain/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除报溢单 */
|
||||
export function deleteStockGain(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-gain/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
66
src/api/erp/stock-in/index.ts
Normal file
66
src/api/erp/stock-in/index.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 其他入库单项 */
|
||||
export interface StockInItem {
|
||||
id?: number
|
||||
stockInId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
locationCode?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
batchNo?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 其他入库单信息 */
|
||||
export interface StockIn {
|
||||
id?: number
|
||||
no?: string
|
||||
supplierId?: number
|
||||
supplierName?: string
|
||||
inTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockInItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取其他入库单分页列表 */
|
||||
export function getStockInPage(params: PageParam) {
|
||||
return http.get<PageResult<StockIn>>('/erp/stock-in/page', params)
|
||||
}
|
||||
|
||||
/** 获取其他入库单详情 */
|
||||
export function getStockIn(id: number) {
|
||||
return http.get<StockIn>(`/erp/stock-in/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建其他入库单 */
|
||||
export function createStockIn(data: StockIn) {
|
||||
return http.post<number>('/erp/stock-in/create', data)
|
||||
}
|
||||
|
||||
/** 更新其他入库单 */
|
||||
export function updateStockIn(data: StockIn) {
|
||||
return http.put<boolean>('/erp/stock-in/update', data)
|
||||
}
|
||||
|
||||
/** 更新其他入库单状态 */
|
||||
export function updateStockInStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-in/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除其他入库单 */
|
||||
export function deleteStockIn(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-in/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
63
src/api/erp/stock-loss/index.ts
Normal file
63
src/api/erp/stock-loss/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 报损单项 */
|
||||
export interface StockLossItem {
|
||||
id?: number
|
||||
stockLossId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 报损单信息 */
|
||||
export interface StockLoss {
|
||||
id?: number
|
||||
no?: string
|
||||
lossTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
reason?: string
|
||||
remark?: string
|
||||
items?: StockLossItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取报损单分页列表 */
|
||||
export function getStockLossPage(params: PageParam) {
|
||||
return http.get<PageResult<StockLoss>>('/erp/stock-loss/page', params)
|
||||
}
|
||||
|
||||
/** 获取报损单详情 */
|
||||
export function getStockLoss(id: number) {
|
||||
return http.get<StockLoss>(`/erp/stock-loss/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建报损单 */
|
||||
export function createStockLoss(data: StockLoss) {
|
||||
return http.post<number>('/erp/stock-loss/create', data)
|
||||
}
|
||||
|
||||
/** 更新报损单 */
|
||||
export function updateStockLoss(data: StockLoss) {
|
||||
return http.put<boolean>('/erp/stock-loss/update', data)
|
||||
}
|
||||
|
||||
/** 更新报损单状态 */
|
||||
export function updateStockLossStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-loss/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除报损单 */
|
||||
export function deleteStockLoss(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-loss/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
64
src/api/erp/stock-move/index.ts
Normal file
64
src/api/erp/stock-move/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 调拨单项 */
|
||||
export interface StockMoveItem {
|
||||
id?: number
|
||||
stockMoveId?: number
|
||||
fromWarehouseId?: number
|
||||
fromWarehouseName?: string
|
||||
toWarehouseId?: number
|
||||
toWarehouseName?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 调拨单信息 */
|
||||
export interface StockMove {
|
||||
id?: number
|
||||
no?: string
|
||||
moveTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockMoveItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取调拨单分页列表 */
|
||||
export function getStockMovePage(params: PageParam) {
|
||||
return http.get<PageResult<StockMove>>('/erp/stock-move/page', params)
|
||||
}
|
||||
|
||||
/** 获取调拨单详情 */
|
||||
export function getStockMove(id: number) {
|
||||
return http.get<StockMove>(`/erp/stock-move/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建调拨单 */
|
||||
export function createStockMove(data: StockMove) {
|
||||
return http.post<number>('/erp/stock-move/create', data)
|
||||
}
|
||||
|
||||
/** 更新调拨单 */
|
||||
export function updateStockMove(data: StockMove) {
|
||||
return http.put<boolean>('/erp/stock-move/update', data)
|
||||
}
|
||||
|
||||
/** 更新调拨单状态 */
|
||||
export function updateStockMoveStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-move/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除调拨单 */
|
||||
export function deleteStockMove(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-move/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
66
src/api/erp/stock-out/index.ts
Normal file
66
src/api/erp/stock-out/index.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 其他出库单项 */
|
||||
export interface StockOutItem {
|
||||
id?: number
|
||||
stockOutId?: number
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
locationCode?: string
|
||||
productId?: number
|
||||
productName?: string
|
||||
productUnitName?: string
|
||||
batchNo?: string
|
||||
count?: number
|
||||
productPrice?: number
|
||||
totalPrice?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 其他出库单信息 */
|
||||
export interface StockOut {
|
||||
id?: number
|
||||
no?: string
|
||||
customerId?: number
|
||||
customerName?: string
|
||||
outTime?: string
|
||||
totalCount?: number
|
||||
totalPrice?: number
|
||||
status?: number
|
||||
remark?: string
|
||||
items?: StockOutItem[]
|
||||
productNames?: string
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取其他出库单分页列表 */
|
||||
export function getStockOutPage(params: PageParam) {
|
||||
return http.get<PageResult<StockOut>>('/erp/stock-out/page', params)
|
||||
}
|
||||
|
||||
/** 获取其他出库单详情 */
|
||||
export function getStockOut(id: number) {
|
||||
return http.get<StockOut>(`/erp/stock-out/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建其他出库单 */
|
||||
export function createStockOut(data: StockOut) {
|
||||
return http.post<number>('/erp/stock-out/create', data)
|
||||
}
|
||||
|
||||
/** 更新其他出库单 */
|
||||
export function updateStockOut(data: StockOut) {
|
||||
return http.put<boolean>('/erp/stock-out/update', data)
|
||||
}
|
||||
|
||||
/** 更新其他出库单状态 */
|
||||
export function updateStockOutStatus(id: number, status: number) {
|
||||
return http.put<boolean>('/erp/stock-out/update-status', undefined, { id, status })
|
||||
}
|
||||
|
||||
/** 删除其他出库单 */
|
||||
export function deleteStockOut(ids: number[]) {
|
||||
return http.delete<boolean>('/erp/stock-out/delete', undefined, { ids: ids.join(',') })
|
||||
}
|
||||
45
src/api/erp/stock-record/index.ts
Normal file
45
src/api/erp/stock-record/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 产品库存明细信息 */
|
||||
export interface StockRecord {
|
||||
id?: number
|
||||
productId?: number
|
||||
productName?: string
|
||||
unitName?: string
|
||||
categoryName?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
count?: number
|
||||
totalCount?: number
|
||||
bizType?: number
|
||||
bizId?: number
|
||||
bizItemId?: number
|
||||
bizNo?: string
|
||||
unitPrice?: number
|
||||
stockValue?: number
|
||||
creatorName?: string
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 业务类型选项 */
|
||||
export const BIZ_TYPE_OPTIONS = [
|
||||
{ value: 1, label: '采购入库' },
|
||||
{ value: 2, label: '采购退货' },
|
||||
{ value: 3, label: '销售出库' },
|
||||
{ value: 4, label: '销售退货' },
|
||||
{ value: 10, label: '其他入库' },
|
||||
{ value: 11, label: '其他出库' },
|
||||
{ value: 12, label: '库存调拨' },
|
||||
{ value: 13, label: '库存盘点' },
|
||||
]
|
||||
|
||||
/** 获取产品库存明细分页列表 */
|
||||
export function getStockRecordPage(params: PageParam) {
|
||||
return http.get<PageResult<StockRecord>>('/erp/stock-record/page', params)
|
||||
}
|
||||
|
||||
/** 获取产品库存明细详情 */
|
||||
export function getStockRecord(id: number) {
|
||||
return http.get<StockRecord>(`/erp/stock-record/get?id=${id}`)
|
||||
}
|
||||
40
src/api/erp/stock/index.ts
Normal file
40
src/api/erp/stock/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 产品库存信息 */
|
||||
export interface Stock {
|
||||
id?: number
|
||||
productId?: number
|
||||
productName?: string
|
||||
unitName?: string
|
||||
categoryName?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
count?: number
|
||||
unitPrice?: number
|
||||
stockValue?: number
|
||||
}
|
||||
|
||||
/** 获取产品库存分页列表 */
|
||||
export function getStockPage(params: PageParam) {
|
||||
return http.get<PageResult<Stock>>('/erp/stock/page', params)
|
||||
}
|
||||
|
||||
/** 获取产品库存详情 */
|
||||
export function getStock(id: number) {
|
||||
return http.get<Stock>(`/erp/stock/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取产品库存详情(通过产品ID和仓库ID) */
|
||||
export function getStock2(productId: number, warehouseId: number) {
|
||||
return http.get<Stock>('/erp/stock/get', { productId, warehouseId })
|
||||
}
|
||||
|
||||
/** 获取产品库存数量 */
|
||||
export function getStockCount(productId: number, warehouseId?: number) {
|
||||
const params: Record<string, any> = { productId }
|
||||
if (warehouseId) {
|
||||
params.warehouseId = warehouseId
|
||||
}
|
||||
return http.get<number>('/erp/stock/get-count', params)
|
||||
}
|
||||
57
src/api/erp/supplier/index.ts
Normal file
57
src/api/erp/supplier/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 供应商信息 */
|
||||
export interface Supplier {
|
||||
id?: number
|
||||
name?: string
|
||||
contact?: string
|
||||
mobile?: string
|
||||
telephone?: string
|
||||
email?: string
|
||||
fax?: string
|
||||
remark?: string
|
||||
status?: number
|
||||
sort?: number
|
||||
taxNo?: string
|
||||
taxPercent?: number
|
||||
bankName?: string
|
||||
bankAccount?: string
|
||||
bankAddress?: string
|
||||
}
|
||||
|
||||
/** 供应商精简信息 */
|
||||
export interface SupplierSimple {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
/** 获取供应商分页列表 */
|
||||
export function getSupplierPage(params: PageParam) {
|
||||
return http.get<PageResult<Supplier>>('/erp/supplier/page', { ...params, type: 1 })
|
||||
}
|
||||
|
||||
/** 获取供应商详情 */
|
||||
export function getSupplier(id: number) {
|
||||
return http.get<Supplier>(`/erp/supplier/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建供应商 */
|
||||
export function createSupplier(data: Supplier) {
|
||||
return http.post<number>('/erp/supplier/create', data)
|
||||
}
|
||||
|
||||
/** 更新供应商 */
|
||||
export function updateSupplier(data: Supplier) {
|
||||
return http.put<boolean>('/erp/supplier/update', data)
|
||||
}
|
||||
|
||||
/** 删除供应商 */
|
||||
export function deleteSupplier(id: number) {
|
||||
return http.delete<boolean>(`/erp/supplier/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取供应商精简列表 */
|
||||
export function getSupplierSimpleList() {
|
||||
return http.get<SupplierSimple[]>('/erp/supplier/simple-list')
|
||||
}
|
||||
55
src/api/erp/warehouse/index.ts
Normal file
55
src/api/erp/warehouse/index.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { PageParam, PageResult } from '@/http/types'
|
||||
import { http } from '@/http/http'
|
||||
|
||||
/** 仓库信息 */
|
||||
export interface Warehouse {
|
||||
id?: number
|
||||
name?: string
|
||||
address?: string
|
||||
sort?: number
|
||||
remark?: string
|
||||
principal?: string
|
||||
warehousePrice?: number
|
||||
truckagePrice?: number
|
||||
status?: number
|
||||
defaultStatus?: boolean
|
||||
enableLocation?: boolean
|
||||
roomNoMax?: number
|
||||
locationCapacity?: number
|
||||
createTime?: number
|
||||
}
|
||||
|
||||
/** 获取仓库分页列表 */
|
||||
export function getWarehousePage(params: PageParam) {
|
||||
return http.get<PageResult<Warehouse>>('/erp/warehouse/page', params)
|
||||
}
|
||||
|
||||
/** 获取仓库详情 */
|
||||
export function getWarehouse(id: number) {
|
||||
return http.get<Warehouse>(`/erp/warehouse/get?id=${id}`)
|
||||
}
|
||||
|
||||
/** 创建仓库 */
|
||||
export function createWarehouse(data: Warehouse) {
|
||||
return http.post<number>('/erp/warehouse/create', data)
|
||||
}
|
||||
|
||||
/** 更新仓库 */
|
||||
export function updateWarehouse(data: Warehouse) {
|
||||
return http.put<boolean>('/erp/warehouse/update', data)
|
||||
}
|
||||
|
||||
/** 更新仓库默认状态 */
|
||||
export function updateWarehouseDefaultStatus(id: number, defaultStatus: boolean) {
|
||||
return http.put<boolean>('/erp/warehouse/update-default-status', undefined, { id, defaultStatus })
|
||||
}
|
||||
|
||||
/** 删除仓库 */
|
||||
export function deleteWarehouse(id: number) {
|
||||
return http.delete<boolean>(`/erp/warehouse/delete?id=${id}`)
|
||||
}
|
||||
|
||||
/** 获取仓库精简列表 */
|
||||
export function getWarehouseSimpleList() {
|
||||
return http.get<Warehouse[]>('/erp/warehouse/simple-list')
|
||||
}
|
||||
171
src/components/erp-scan/item-list.vue
Normal file
171
src/components/erp-scan/item-list.vue
Normal 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>
|
||||
130
src/components/erp-scan/scan-input.vue
Normal file
130
src/components/erp-scan/scan-input.vue
Normal 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>
|
||||
49
src/components/erp-scan/submit-bar.vue
Normal file
49
src/components/erp-scan/submit-bar.vue
Normal 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
136
src/manifest.json
Normal 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": "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
437
src/pages-agri/biz-flow/index.vue
Normal file
437
src/pages-agri/biz-flow/index.vue
Normal file
@@ -0,0 +1,437 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="闭环操作台"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 流程说明 -->
|
||||
<view class="mx-24rpx mt-20rpx mb-16rpx px-24rpx py-16rpx rounded-12rpx bg-[#e6f7ff] text-24rpx text-[#1890ff]">
|
||||
最小闭环操作台:采收 → 分拣 → 装箱 → 入库 → 发运 → 签收
|
||||
</view>
|
||||
|
||||
<!-- 数量/重量看板 -->
|
||||
<view class="mx-24rpx mb-20rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="px-24rpx py-20rpx border-b border-[#f0f0f0] text-28rpx text-[#333] font-semibold">
|
||||
数量 / 重量看板
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<view class="flex flex-wrap">
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">当前批次ID</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ metricPanel.batchId ?? '-' }}</text>
|
||||
</view>
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">最近更新</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ metricPanel.updatedAt || '-' }}</text>
|
||||
</view>
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">采收数量</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.harvestQuantity, metricPanel.harvestUnit) }}</text>
|
||||
</view>
|
||||
<view class="w-1/2 mb-16rpx">
|
||||
<text class="text-24rpx text-[#999]">分拣称重</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.sortingWeight, 'kg') }}</text>
|
||||
</view>
|
||||
<view class="w-1/2">
|
||||
<text class="text-24rpx text-[#999]">装箱净重</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.packingNetWeight, 'kg') }}</text>
|
||||
</view>
|
||||
<view class="w-1/2">
|
||||
<text class="text-24rpx text-[#999]">发运箱数</text>
|
||||
<text class="ml-12rpx text-26rpx text-[#333]">{{ formatMetric(metricPanel.shipmentBoxCount, '箱') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 扫码按钮 -->
|
||||
<view class="mx-24rpx mb-20rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333]">快捷操作</view>
|
||||
<wd-button size="small" type="info" plain icon="scan" @click="handleScanCode">
|
||||
扫码填充批次ID
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 操作步骤 Tab -->
|
||||
<view class="mx-24rpx mb-20rpx">
|
||||
<wd-tabs v-model="activeTab">
|
||||
<wd-tab title="采收" name="harvest" />
|
||||
<wd-tab title="分拣" name="sorting" />
|
||||
<wd-tab title="装箱" name="packing" />
|
||||
<wd-tab title="入库" name="warehouse" />
|
||||
<wd-tab title="发运" name="shipment" />
|
||||
<wd-tab title="签收" name="sign" />
|
||||
</wd-tabs>
|
||||
</view>
|
||||
|
||||
<!-- 采收表单 -->
|
||||
<view v-show="activeTab === 'harvest'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-picker
|
||||
v-model="harvestForm.batchType"
|
||||
label="批次类型"
|
||||
:columns="batchTypeColumns"
|
||||
label-width="200rpx"
|
||||
/>
|
||||
<wd-input v-model="harvestForm.productName" label="产品名称" label-width="200rpx" placeholder="请输入产品名称" />
|
||||
<wd-input v-model="harvestForm.plotName" label="地块名称" label-width="200rpx" placeholder="请输入地块名称" />
|
||||
<wd-input
|
||||
v-model="harvestForm.quantity"
|
||||
label="数量"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入数量"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input v-model="harvestForm.unit" label="单位" label-width="200rpx" placeholder="kg" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onHarvest">提交采收</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分拣表单 -->
|
||||
<view v-show="activeTab === 'sorting'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="sortingForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="sortingForm.weightResult"
|
||||
label="称重结果"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入称重结果"
|
||||
type="digit"
|
||||
/>
|
||||
<wd-input v-model="sortingForm.unqualifiedCategory" label="不合格分类" label-width="200rpx" placeholder="请输入不合格分类" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onSorting">提交分拣</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 装箱表单 -->
|
||||
<view v-show="activeTab === 'packing'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="packingForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="packingForm.netWeight"
|
||||
label="净重"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入净重"
|
||||
type="digit"
|
||||
/>
|
||||
<wd-input v-model="packingForm.labelCode" label="标签编码" label-width="200rpx" placeholder="请输入标签编码" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onPacking">提交装箱</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 入库表单 -->
|
||||
<view v-show="activeTab === 'warehouse'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="warehouseForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-picker
|
||||
v-model="warehouseForm.inMode"
|
||||
label="入库模式"
|
||||
:columns="inModeColumns"
|
||||
label-width="200rpx"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onWarehouseIn">提交入库</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 发运表单 -->
|
||||
<view v-show="activeTab === 'shipment'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="shipmentForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input v-model="shipmentForm.vehicleNo" label="车牌号" label-width="200rpx" placeholder="请输入车牌号" />
|
||||
<wd-input
|
||||
v-model="shipmentForm.boxCount"
|
||||
label="箱数"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入箱数"
|
||||
type="number"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onDispatch">提交发运</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 签收表单 -->
|
||||
<view v-show="activeTab === 'sign'" class="mx-24rpx rounded-12rpx bg-white shadow-sm overflow-hidden">
|
||||
<view class="p-24rpx">
|
||||
<wd-cell-group border>
|
||||
<wd-input
|
||||
v-model="signForm.batchId"
|
||||
label="批次ID"
|
||||
label-width="200rpx"
|
||||
placeholder="请输入批次ID"
|
||||
type="number"
|
||||
/>
|
||||
<wd-input v-model="signForm.remark" label="备注" label-width="200rpx" placeholder="请输入备注" />
|
||||
</wd-cell-group>
|
||||
<view class="mt-32rpx">
|
||||
<wd-button type="primary" block @click="onSign">提交签收</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import {
|
||||
dispatchShipment,
|
||||
signShipment,
|
||||
submitHarvest,
|
||||
submitPacking,
|
||||
submitSorting,
|
||||
submitWarehouseIn
|
||||
} from '@/api/agri/biz/flow'
|
||||
import { BATCH_TYPE_OPTIONS, IN_MODE_OPTIONS } from '@/utils/agriTraceDict'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const activeTab = ref('harvest')
|
||||
|
||||
const harvestForm = reactive({
|
||||
batchType: 'HARVEST',
|
||||
productName: '',
|
||||
plotName: '',
|
||||
quantity: '' as string | number,
|
||||
unit: 'kg'
|
||||
})
|
||||
|
||||
const sortingForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
weightResult: '' as string | number,
|
||||
unqualifiedCategory: ''
|
||||
})
|
||||
|
||||
const packingForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
netWeight: '' as string | number,
|
||||
labelCode: ''
|
||||
})
|
||||
|
||||
const warehouseForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
inMode: 'BOX'
|
||||
})
|
||||
|
||||
const shipmentForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
vehicleNo: '',
|
||||
boxCount: '' as string | number
|
||||
})
|
||||
|
||||
const signForm = reactive({
|
||||
batchId: '' as string | number,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const metricPanel = reactive({
|
||||
batchId: undefined as number | undefined,
|
||||
harvestQuantity: undefined as number | undefined,
|
||||
harvestUnit: 'kg',
|
||||
sortingWeight: undefined as number | undefined,
|
||||
packingNetWeight: undefined as number | undefined,
|
||||
shipmentBoxCount: undefined as number | undefined,
|
||||
updatedAt: ''
|
||||
})
|
||||
|
||||
/** 批次类型下拉列 */
|
||||
const batchTypeColumns = computed(() => [
|
||||
BATCH_TYPE_OPTIONS.map(v => ({ value: v.value, label: v.label }))
|
||||
])
|
||||
|
||||
/** 入库模式下拉列 */
|
||||
const inModeColumns = computed(() => [
|
||||
IN_MODE_OPTIONS.map(v => ({ value: v.value, label: v.label }))
|
||||
])
|
||||
|
||||
const formatMetric = (value?: number, unit?: string) => {
|
||||
if (value === undefined || value === null) {
|
||||
return '-'
|
||||
}
|
||||
return unit ? `${value} ${unit}` : `${value}`
|
||||
}
|
||||
|
||||
const refreshMetricPanel = (patch: Partial<typeof metricPanel>) => {
|
||||
Object.assign(metricPanel, patch, {
|
||||
updatedAt: new Date().toLocaleString()
|
||||
})
|
||||
}
|
||||
|
||||
const syncBatchIdToFollowUpForms = (batchId: number) => {
|
||||
sortingForm.batchId = batchId
|
||||
packingForm.batchId = batchId
|
||||
warehouseForm.batchId = batchId
|
||||
shipmentForm.batchId = batchId
|
||||
signForm.batchId = batchId
|
||||
}
|
||||
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
const onHarvest = async () => {
|
||||
const id = await submitHarvest({
|
||||
...harvestForm,
|
||||
quantity: harvestForm.quantity ? Number(harvestForm.quantity) : undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: id,
|
||||
harvestQuantity: harvestForm.quantity ? Number(harvestForm.quantity) : undefined,
|
||||
harvestUnit: harvestForm.unit || 'kg'
|
||||
})
|
||||
syncBatchIdToFollowUpForms(id)
|
||||
uni.showToast({ title: `采收成功,批次ID:${id}`, icon: 'none' })
|
||||
activeTab.value = 'sorting'
|
||||
}
|
||||
|
||||
const onSorting = async () => {
|
||||
await submitSorting({
|
||||
batchId: Number(sortingForm.batchId),
|
||||
weightResult: sortingForm.weightResult ? Number(sortingForm.weightResult) : undefined,
|
||||
unqualifiedCategory: sortingForm.unqualifiedCategory || undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: Number(sortingForm.batchId),
|
||||
sortingWeight: sortingForm.weightResult ? Number(sortingForm.weightResult) : undefined
|
||||
})
|
||||
uni.showToast({ title: '分拣成功', icon: 'success' })
|
||||
activeTab.value = 'packing'
|
||||
}
|
||||
|
||||
const onPacking = async () => {
|
||||
await submitPacking({
|
||||
batchId: Number(packingForm.batchId),
|
||||
netWeight: packingForm.netWeight ? Number(packingForm.netWeight) : undefined,
|
||||
labelCode: packingForm.labelCode || undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: Number(packingForm.batchId),
|
||||
packingNetWeight: packingForm.netWeight ? Number(packingForm.netWeight) : undefined
|
||||
})
|
||||
uni.showToast({ title: '装箱成功', icon: 'success' })
|
||||
activeTab.value = 'warehouse'
|
||||
}
|
||||
|
||||
const onWarehouseIn = async () => {
|
||||
await submitWarehouseIn({
|
||||
batchId: Number(warehouseForm.batchId),
|
||||
inMode: warehouseForm.inMode || undefined
|
||||
})
|
||||
uni.showToast({ title: '入库成功', icon: 'success' })
|
||||
activeTab.value = 'shipment'
|
||||
}
|
||||
|
||||
const onDispatch = async () => {
|
||||
await dispatchShipment({
|
||||
batchId: Number(shipmentForm.batchId),
|
||||
vehicleNo: shipmentForm.vehicleNo,
|
||||
boxCount: shipmentForm.boxCount ? Number(shipmentForm.boxCount) : undefined
|
||||
})
|
||||
refreshMetricPanel({
|
||||
batchId: Number(shipmentForm.batchId),
|
||||
shipmentBoxCount: shipmentForm.boxCount ? Number(shipmentForm.boxCount) : undefined
|
||||
})
|
||||
uni.showToast({ title: '发运成功', icon: 'success' })
|
||||
activeTab.value = 'sign'
|
||||
}
|
||||
|
||||
const onSign = async () => {
|
||||
await signShipment({
|
||||
batchId: Number(signForm.batchId),
|
||||
remark: signForm.remark || undefined
|
||||
})
|
||||
uni.showToast({ title: '签收成功', icon: 'success' })
|
||||
}
|
||||
|
||||
/** 扫码填充批次ID */
|
||||
const handleScanCode = () => {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.scanCode({
|
||||
onlyFromCamera: false,
|
||||
scanType: ['qrCode', 'barCode'],
|
||||
success: (res) => {
|
||||
const result = res.result
|
||||
// 尝试解析批次ID(支持纯数字或JSON格式)
|
||||
let batchId: number | undefined
|
||||
try {
|
||||
const parsed = JSON.parse(result)
|
||||
batchId = parsed.batchId || parsed.id
|
||||
} catch {
|
||||
// 如果不是JSON,尝试直接解析为数字
|
||||
const num = Number(result)
|
||||
if (!isNaN(num) && num > 0) {
|
||||
batchId = num
|
||||
}
|
||||
}
|
||||
if (batchId) {
|
||||
syncBatchIdToFollowUpForms(batchId)
|
||||
refreshMetricPanel({ batchId })
|
||||
uni.showToast({ title: `已填充批次ID: ${batchId}`, icon: 'none' })
|
||||
} else {
|
||||
uni.showToast({ title: '无法识别批次ID', icon: 'none' })
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({ title: '扫码取消或失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.showToast({ title: '当前环境不支持扫码', icon: 'none' })
|
||||
// #endif
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
334
src/pages-agri/trace-snapshot/index.vue
Normal file
334
src/pages-agri/trace-snapshot/index.vue
Normal file
@@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="溯源快照"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<view class="flex items-center px-24rpx">
|
||||
<view class="flex-1" @click="searchVisible = true">
|
||||
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
|
||||
</view>
|
||||
<wd-button size="small" type="primary" icon="scan" class="ml-16rpx" @click="handleScanQuery">
|
||||
扫码
|
||||
</wd-button>
|
||||
</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 flex-1 truncate">
|
||||
{{ item.traceCode || '-' }}
|
||||
</view>
|
||||
<view class="text-24rpx text-[#1890ff] ml-12rpx">
|
||||
{{ item.batchNo || '' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 产品名 + 地块名 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text>{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">地块</text>
|
||||
<text>{{ item.plotName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 采收信息 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">采收</text>
|
||||
<text>{{ item.harvestOperatorName || '-' }} / {{ formatTime(item.harvestTime) }}</text>
|
||||
</view>
|
||||
<!-- 装箱信息 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">装箱</text>
|
||||
<text>{{ item.packingOperatorName || '-' }} / {{ formatTime(item.packingTime) }}</text>
|
||||
</view>
|
||||
<!-- 入库信息 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">入库</text>
|
||||
<text>{{ item.warehouseOperatorName || '-' }} / {{ formatTime(item.warehouseTime) }}</text>
|
||||
</view>
|
||||
<!-- 发运信息 -->
|
||||
<view class="flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">发运</text>
|
||||
<text>{{ item.shipmentOperatorName || '-' }} / {{ item.vehicleNo || '-' }}</text>
|
||||
</view>
|
||||
</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.batchNo" placeholder="请输入批次号" no-border />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">溯源码</view>
|
||||
<wd-input v-model="searchForm.traceCode" placeholder="请输入溯源码" no-border />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">产品名</view>
|
||||
<wd-input v-model="searchForm.productName" placeholder="请输入产品名称" no-border />
|
||||
</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 class="mt-20rpx">
|
||||
<wd-button type="info" block plain @click="handleTraceCodeQuery">按溯源码查单条</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 详情弹窗 -->
|
||||
<wd-popup v-model="detailVisible" position="bottom" custom-style="height: 70%;">
|
||||
<view class="p-24rpx">
|
||||
<view class="text-32rpx text-[#333] font-semibold mb-24rpx">溯源详情</view>
|
||||
<view v-if="currentDetail" class="text-26rpx text-[#666]">
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">ID</text><text>{{ currentDetail.id }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">溯源码</text><text class="flex-1 break-all">{{ currentDetail.traceCode }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">批次号</text><text>{{ currentDetail.batchNo }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">产品名</text><text>{{ currentDetail.productName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">地块名</text><text>{{ currentDetail.plotName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">采收操作人</text><text>{{ currentDetail.harvestOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">采收时间</text><text>{{ formatTime(currentDetail.harvestTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">装箱操作人</text><text>{{ currentDetail.packingOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">装箱时间</text><text>{{ formatTime(currentDetail.packingTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">入库操作人</text><text>{{ currentDetail.warehouseOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">入库时间</text><text>{{ formatTime(currentDetail.warehouseTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">发运操作人</text><text>{{ currentDetail.shipmentOperatorName || '-' }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">发运时间</text><text>{{ formatTime(currentDetail.shipmentTime) }}</text></view>
|
||||
<view class="mb-16rpx flex"><text class="text-[#999] w-160rpx">车牌号</text><text>{{ currentDetail.vehicleNo || '-' }}</text></view>
|
||||
</view>
|
||||
<wd-button type="primary" block class="mt-32rpx" @click="detailVisible = false">关闭</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { AgriTraceSnapshotVO } from '@/api/agri/trace/snapshot'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import {
|
||||
getAgriTraceSnapshotByTraceCode,
|
||||
getAgriTraceSnapshotPage
|
||||
} from '@/api/agri/trace/snapshot'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const total = ref(0)
|
||||
const list = ref<AgriTraceSnapshotVO[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
batchNo: '',
|
||||
traceCode: '',
|
||||
productName: ''
|
||||
})
|
||||
|
||||
// 详情弹窗
|
||||
const detailVisible = ref(false)
|
||||
const currentDetail = ref<AgriTraceSnapshotVO | null>(null)
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.batchNo) conditions.push(`批次:${searchForm.batchNo}`)
|
||||
if (searchForm.traceCode) conditions.push(`溯源码:${searchForm.traceCode}`)
|
||||
if (searchForm.productName) conditions.push(`产品:${searchForm.productName}`)
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索溯源快照'
|
||||
})
|
||||
|
||||
/** 格式化时间 */
|
||||
function formatTime(time?: string | number) {
|
||||
if (!time) return '-'
|
||||
// 如果是时间戳(数字),转换为日期字符串
|
||||
if (typeof time === 'number') {
|
||||
const date = new Date(time)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`
|
||||
}
|
||||
// 如果是字符串,处理 ISO 格式
|
||||
if (typeof time === 'string') {
|
||||
return time.replace('T', ' ').substring(0, 16)
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params: Record<string, any> = { ...queryParams.value }
|
||||
if (searchForm.batchNo) params.batchNo = searchForm.batchNo
|
||||
if (searchForm.traceCode) params.traceCode = searchForm.traceCode
|
||||
if (searchForm.productName) params.productName = searchForm.productName
|
||||
const data = await getAgriTraceSnapshotPage(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,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.batchNo = ''
|
||||
searchForm.traceCode = ''
|
||||
searchForm.productName = ''
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 按溯源码查单条 */
|
||||
async function handleTraceCodeQuery() {
|
||||
if (!searchForm.traceCode) {
|
||||
uni.showToast({ title: '请先输入溯源码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
searchVisible.value = false
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const data = await getAgriTraceSnapshotByTraceCode(searchForm.traceCode)
|
||||
list.value = data ? [data] : []
|
||||
total.value = list.value.length
|
||||
loadMoreState.value = 'finished'
|
||||
} catch {
|
||||
loadMoreState.value = 'error'
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: AgriTraceSnapshotVO) {
|
||||
currentDetail.value = item
|
||||
detailVisible.value = true
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 扫码查询 */
|
||||
function handleScanQuery() {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.scanCode({
|
||||
onlyFromCamera: false,
|
||||
scanType: ['qrCode', 'barCode'],
|
||||
success: async (res) => {
|
||||
const result = res.result
|
||||
// 尝试解析溯源码(支持纯字符串或JSON格式)
|
||||
let traceCode: string | undefined
|
||||
try {
|
||||
const parsed = JSON.parse(result)
|
||||
traceCode = parsed.traceCode || parsed.code
|
||||
} catch {
|
||||
// 如果不是JSON,直接使用扫码结果
|
||||
traceCode = result
|
||||
}
|
||||
if (traceCode) {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const data = await getAgriTraceSnapshotByTraceCode(traceCode)
|
||||
list.value = data ? [data] : []
|
||||
total.value = list.value.length
|
||||
loadMoreState.value = 'finished'
|
||||
if (data) {
|
||||
uni.showToast({ title: '查询成功', icon: 'success' })
|
||||
} else {
|
||||
uni.showToast({ title: '未找到该溯源码', icon: 'none' })
|
||||
}
|
||||
} catch {
|
||||
loadMoreState.value = 'error'
|
||||
uni.showToast({ title: '查询失败', icon: 'none' })
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: '无法识别溯源码', icon: 'none' })
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({ title: '扫码取消或失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.showToast({ title: '当前环境不支持扫码', icon: 'none' })
|
||||
// #endif
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
298
src/pages-erp/farmer/form/index.vue
Normal file
298
src/pages-erp/farmer/form/index.vue
Normal file
@@ -0,0 +1,298 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-input
|
||||
v-model="formData.name"
|
||||
label="户主姓名"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入户主姓名"
|
||||
prop="name"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.idCardNumber"
|
||||
label="身份证号"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入身份证号"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.mobile"
|
||||
label="手机号码"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入手机号码"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.address"
|
||||
label="住址"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入住址"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="种植信息" border>
|
||||
<wd-input
|
||||
v-model="formData.plantingBase"
|
||||
label="种植基地"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入所属种植基地"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.contractNumber"
|
||||
label="合同号"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入合同号"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.contractedArea"
|
||||
label="签订面积"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入签订面积"
|
||||
type="number"
|
||||
suffix-icon="亩"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.orderQuantity"
|
||||
label="订购数量"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入订购数量"
|
||||
type="number"
|
||||
suffix-icon="株"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.actualArea"
|
||||
label="实种面积"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入实种面积"
|
||||
type="number"
|
||||
suffix-icon="亩"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="移栽时间" title-width="180rpx" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.transplantTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择移栽时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.transplantQuantity"
|
||||
label="移栽数量"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入移栽数量"
|
||||
type="number"
|
||||
suffix-icon="盘"
|
||||
clearable
|
||||
/>
|
||||
<wd-cell title="成熟时间" title-width="180rpx" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.maturityTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择成熟时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="预计采收" title-width="180rpx" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.expectedHarvestTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择预计采收时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="使用品种" title-width="180rpx" center>
|
||||
<wd-picker
|
||||
v-model="formData.usedVariety"
|
||||
:columns="varietyColumns"
|
||||
label=""
|
||||
placeholder="请选择使用品种"
|
||||
@confirm="onVarietyConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.plantingMethod"
|
||||
label="种植方式"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入种植方式"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.adminName"
|
||||
label="管理员"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入管理员姓名"
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="其他信息" border>
|
||||
<wd-cell title="开启状态" title-width="180rpx" center>
|
||||
<wd-switch v-model="statusEnabled" />
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.sort"
|
||||
label="排序"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入排序"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { Farmer } from '@/api/erp/farmer'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createFarmer, getFarmer, updateFarmer, VARIETY_OPTIONS } from '@/api/erp/farmer'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<Farmer>({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
idCardNumber: undefined,
|
||||
mobile: undefined,
|
||||
address: undefined,
|
||||
plantingBase: undefined,
|
||||
contractNumber: undefined,
|
||||
contractedArea: undefined,
|
||||
orderQuantity: undefined,
|
||||
actualArea: undefined,
|
||||
transplantTime: undefined,
|
||||
transplantQuantity: undefined,
|
||||
maturityTime: undefined,
|
||||
expectedHarvestTime: undefined,
|
||||
usedVariety: undefined,
|
||||
plantingMethod: undefined,
|
||||
adminName: undefined,
|
||||
remark: undefined,
|
||||
status: 0,
|
||||
sort: 0,
|
||||
})
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '户主姓名不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 状态开关
|
||||
const statusEnabled = ref(true)
|
||||
watch(statusEnabled, (val) => {
|
||||
formData.value.status = val ? 0 : 1
|
||||
})
|
||||
watch(() => formData.value.status, (val) => {
|
||||
statusEnabled.value = val === 0
|
||||
})
|
||||
|
||||
/** 品种下拉列 */
|
||||
const varietyColumns = computed(() => [
|
||||
VARIETY_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
/** 品种选择回调 */
|
||||
function onVarietyConfirm({ value }: any) {
|
||||
formData.value.usedVariety = value?.[0]
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/farmer/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getFarmer(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updateFarmer(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createFarmer(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
289
src/pages-erp/farmer/index.vue
Normal file
289
src/pages-erp/farmer/index.vue
Normal file
@@ -0,0 +1,289 @@
|
||||
<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="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
@click="handleEdit(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:姓名 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.name || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="item.status === 0 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'"
|
||||
>
|
||||
{{ item.status === 0 ? '正常' : '停用' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 住址 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">住址</text>
|
||||
<text>{{ item.address || '-' }}</text>
|
||||
</view>
|
||||
<!-- 种植基地 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">种植基地</text>
|
||||
<text>{{ item.plantingBase || '-' }}</text>
|
||||
</view>
|
||||
<!-- 合同号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">合同号</text>
|
||||
<text>{{ item.contractNumber || '-' }}</text>
|
||||
</view>
|
||||
<!-- 使用品种 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">使用品种</text>
|
||||
<text>{{ item.usedVariety || '-' }}</text>
|
||||
</view>
|
||||
<!-- 管理员 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">管理员</text>
|
||||
<text>{{ item.adminName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.contractedArea ?? '-' }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">签订面积</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.actualArea ?? '-' }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">实种面积</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#1890ff] font-semibold">{{ item.orderQuantity ?? '-' }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">订购数量</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:farmer:update'])"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:farmer:delete'])"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:farmer:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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.name" placeholder="请输入户主姓名" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">种植基地</view>
|
||||
<wd-input v-model="searchForm.plantingBase" placeholder="请输入种植基地" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">使用品种</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.usedVariety"
|
||||
:columns="varietyColumns"
|
||||
placeholder="请选择使用品种"
|
||||
@confirm="onVarietyConfirm"
|
||||
/>
|
||||
</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 { Farmer } from '@/api/erp/farmer'
|
||||
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 { deleteFarmer, getFarmerPage, VARIETY_OPTIONS } from '@/api/erp/farmer'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<Farmer[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
name: undefined as string | undefined,
|
||||
plantingBase: undefined as string | undefined,
|
||||
usedVariety: undefined as string | undefined,
|
||||
})
|
||||
|
||||
/** 品种下拉列 */
|
||||
const varietyColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...VARIETY_OPTIONS.map(v => ({ value: v.value, label: v.label }))],
|
||||
])
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.name) conditions.push(`姓名:${searchForm.name}`)
|
||||
if (searchForm.plantingBase) conditions.push(`基地:${searchForm.plantingBase}`)
|
||||
if (searchForm.usedVariety) conditions.push(`品种:${searchForm.usedVariety}`)
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索农户'
|
||||
})
|
||||
|
||||
/** 品种选择回调 */
|
||||
function onVarietyConfirm({ value }: any) {
|
||||
searchForm.usedVariety = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询农户列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getFarmerPage(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 = {
|
||||
...searchForm,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.name = undefined
|
||||
searchForm.plantingBase = undefined
|
||||
searchForm.usedVariety = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 新增农户 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/farmer/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: Farmer) {
|
||||
uni.navigateTo({ url: `/pages-erp/farmer/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该农户吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteFarmer(id)
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
126
src/pages-erp/pick-broccoli/components/search-form.vue
Normal file
126
src/pages-erp/pick-broccoli/components/search-form.vue
Normal file
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = 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="formData.pickCode"
|
||||
placeholder="请输入采摘编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
采摘人员
|
||||
</view>
|
||||
<wd-input
|
||||
v-model="formData.userName"
|
||||
placeholder="请输入采摘人员姓名"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="1">
|
||||
已采摘
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
已装框
|
||||
</wd-radio>
|
||||
<wd-radio :value="3">
|
||||
已装车
|
||||
</wd-radio>
|
||||
<wd-radio :value="4">
|
||||
已入库
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
pickCode: undefined as string | undefined,
|
||||
userName: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
1: '已采摘',
|
||||
2: '已装框',
|
||||
3: '已装车',
|
||||
4: '已入库',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.pickCode) {
|
||||
conditions.push(`编号:${formData.pickCode}`)
|
||||
}
|
||||
if (formData.userName) {
|
||||
conditions.push(`人员:${formData.userName}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采摘记录'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.pickCode) {
|
||||
params.pickCode = formData.pickCode
|
||||
}
|
||||
if (formData.userName) {
|
||||
params.userName = formData.userName
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.pickCode = undefined
|
||||
formData.userName = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
237
src/pages-erp/pick-broccoli/detail/index.vue
Normal file
237
src/pages-erp/pick-broccoli/detail/index.vue
Normal file
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采摘记录详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="采摘编号" :value="formData.pickCode" />
|
||||
<wd-cell title="状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status)"
|
||||
>
|
||||
{{ getStatusText(formData.status) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联产品" :value="formData.productName || '-'" />
|
||||
<wd-cell title="采摘人员" :value="formData.userName || '-'" />
|
||||
<wd-cell title="田间编号" :value="formData.fieldCode || '-'" />
|
||||
<wd-cell title="采摘时间" :value="formatDate(formData.pickTime)" />
|
||||
<wd-cell title="创建时间" :value="formatDate(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 采摘信息 -->
|
||||
<wd-cell-group title="采摘信息" border>
|
||||
<wd-cell title="框编号" :value="formData.basketCode || '-'" />
|
||||
<wd-cell title="每筐重量" :value="formData.basketWeight ? `${formData.basketWeight} kg` : '-'" />
|
||||
<wd-cell title="车牌号" :value="formData.licensePlate || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 装车信息 (status >= 3) -->
|
||||
<wd-cell-group v-if="(formData.status ?? 0) >= 3" title="装车信息" border>
|
||||
<wd-cell title="装车人员" :value="formData.loaderName || '-'" />
|
||||
<wd-cell title="装车时间" :value="formatDate(formData.loadTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 卸车入库信息 (status === 4) -->
|
||||
<wd-cell-group v-if="formData.status === 4" title="卸车入库信息" border>
|
||||
<wd-cell title="卸车人员" :value="formData.unloaderName || '-'" />
|
||||
<wd-cell title="卸车时间" :value="formatDate(formData.unloadTime)" />
|
||||
<wd-cell title="入库仓库" :value="formData.warehouseName || '-'" />
|
||||
<wd-cell title="卸车批次号" :value="formData.unloadBatch || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && (formData?.status ?? 0) < 3"
|
||||
class="flex-1" type="primary" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && formData?.status === 1"
|
||||
class="flex-1" type="success" @click="handleStatusUpdate(2, '装框')"
|
||||
>
|
||||
装框
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && formData?.status === 2"
|
||||
class="flex-1" type="warning" @click="handleLoadTruck"
|
||||
>
|
||||
装车
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:delete']) && (formData?.status ?? 0) < 3"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePickBroccoli, getPickBroccoli, loadTruck, updatePickBroccoliStatus } from '@/api/erp/pick-broccoli'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PickBroccoli>()
|
||||
const deleting = ref(false)
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return '已采摘'
|
||||
case 2: return '已装框'
|
||||
case 3: return '已装车'
|
||||
case 4: return '已卸车入库'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||
case 2: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 3: return 'bg-[#f9f0ff] text-[#722ed1]'
|
||||
case 4: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/pick-broccoli/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPickBroccoli(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/pick-broccoli/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 状态更新(装框) */
|
||||
function handleStatusUpdate(status: number, text: string) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确认将该记录状态更新为"${text}完成"吗?`,
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePickBroccoliStatus(props.id, status)
|
||||
toast.success(`${text}操作成功`)
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 装车操作 */
|
||||
function handleLoadTruck() {
|
||||
uni.showModal({
|
||||
title: '装车',
|
||||
content: '请输入车牌号',
|
||||
editable: true,
|
||||
placeholderText: '车牌号',
|
||||
success: async (res) => {
|
||||
if (!res.confirm || !res.content) return
|
||||
try {
|
||||
await loadTruck(props.id, res.content, 0, '')
|
||||
toast.success('装车操作成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采摘记录吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePickBroccoli(props.id)
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
354
src/pages-erp/pick-broccoli/form/index.vue
Normal file
354
src/pages-erp/pick-broccoli/form/index.vue
Normal file
@@ -0,0 +1,354 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-input
|
||||
v-model="formData.pickCode"
|
||||
label="采摘编号"
|
||||
label-width="180rpx"
|
||||
prop="pickCode"
|
||||
placeholder="自动生成"
|
||||
:disabled="isLoaded"
|
||||
readonly
|
||||
>
|
||||
<template v-if="!props.id" #suffix>
|
||||
<wd-button size="small" type="primary" @click="handleGenerateCode">
|
||||
生成
|
||||
</wd-button>
|
||||
</template>
|
||||
</wd-input>
|
||||
<wd-cell title="采摘人员" title-width="180rpx" prop="userName" center>
|
||||
<wd-picker
|
||||
v-model="formData.userId"
|
||||
:columns="userColumns"
|
||||
label=""
|
||||
placeholder="请选择采摘人员"
|
||||
:disabled="isLoaded"
|
||||
@confirm="onUserConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联产品" title-width="180rpx" prop="productName" center>
|
||||
<wd-picker
|
||||
v-model="formData.productId"
|
||||
:columns="productColumns"
|
||||
label=""
|
||||
placeholder="请选择产品"
|
||||
:disabled="isLoaded"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="田间编号" title-width="180rpx" prop="fieldCode" center>
|
||||
<wd-picker
|
||||
v-model="formData.fieldCode"
|
||||
:columns="fieldColumns"
|
||||
label=""
|
||||
placeholder="请选择田间编号"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 采摘信息 -->
|
||||
<wd-cell-group title="采摘信息" border>
|
||||
<wd-cell title="框编号" title-width="180rpx" prop="basketCode" center>
|
||||
<wd-picker
|
||||
v-model="formData.basketCode"
|
||||
:columns="basketColumns"
|
||||
label=""
|
||||
placeholder="请选择框编号"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-input
|
||||
v-model="formData.basketWeight"
|
||||
label="每筐重量(kg)"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入每筐重量"
|
||||
clearable
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.licensePlate"
|
||||
label="车牌号"
|
||||
label-width="180rpx"
|
||||
clearable
|
||||
placeholder="请输入车牌号"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
<wd-cell title="采摘时间" title-width="180rpx" prop="pickTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.pickTime"
|
||||
type="datetime"
|
||||
label=""
|
||||
placeholder="请选择采摘时间"
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 状态信息(编辑时) -->
|
||||
<wd-cell-group v-if="formData.id" title="状态信息" border>
|
||||
<wd-cell title="当前状态" :value="getStatusText(formData.status)" />
|
||||
<wd-cell v-if="formData.loadTime" title="装车时间" :value="formatDate(formData.loadTime)" />
|
||||
<wd-cell v-if="formData.loaderName" title="装车人" :value="formData.loaderName" />
|
||||
<wd-cell v-if="formData.unloadTime" title="卸车时间" :value="formatDate(formData.unloadTime)" />
|
||||
<wd-cell v-if="formData.unloaderName" title="卸车人员" :value="formData.unloaderName" />
|
||||
<wd-cell v-if="formData.warehouseName" title="仓库名称" :value="formData.warehouseName" />
|
||||
<wd-cell v-if="formData.unloadBatch" title="卸车批次号" :value="formData.unloadBatch" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group title="其他" border>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注信息(可选)"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
:disabled="isLoaded"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
:disabled="isLoaded"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import type { User } from '@/api/system/user'
|
||||
import type { ProductSimple } from '@/api/erp/product'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPickBroccoli, generatePickCode, getPickBroccoli, updatePickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import { getSimpleUserList } from '@/api/system/user'
|
||||
import { getProductSimpleList } from '@/api/erp/product'
|
||||
import { getFarmingManagementPage } from '@/api/erp/farming'
|
||||
import { getBoxPage } from '@/api/erp/box'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<PickBroccoli>({
|
||||
id: undefined,
|
||||
pickCode: '',
|
||||
userId: undefined,
|
||||
userName: '',
|
||||
productId: undefined,
|
||||
productName: '',
|
||||
fieldCode: '',
|
||||
basketCode: '',
|
||||
basketWeight: undefined,
|
||||
licensePlate: '',
|
||||
pickTime: undefined,
|
||||
status: 1,
|
||||
remark: '',
|
||||
})
|
||||
const formRules = {
|
||||
pickCode: [{ required: true, message: '采摘编号不能为空' }],
|
||||
userName: [{ required: true, message: '采摘人员不能为空' }],
|
||||
productName: [{ required: true, message: '关联产品不能为空' }],
|
||||
fieldCode: [{ required: true, message: '田间编号不能为空' }],
|
||||
basketCode: [{ required: true, message: '框编号不能为空' }],
|
||||
pickTime: [{ required: true, message: '采摘时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const userList = ref<User[]>([])
|
||||
const productList = ref<ProductSimple[]>([])
|
||||
const fieldList = ref<string[]>([])
|
||||
const basketList = ref<string[]>([])
|
||||
|
||||
/** 采摘人员下拉列 */
|
||||
const userColumns = computed(() => [
|
||||
userList.value.map(u => ({ value: u.id, label: u.nickname })),
|
||||
])
|
||||
|
||||
/** 产品下拉列 */
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(p => ({ value: p.id, label: p.name })),
|
||||
])
|
||||
|
||||
/** 田间编号下拉列 */
|
||||
const fieldColumns = computed(() => [
|
||||
fieldList.value.map(code => ({ value: code, label: code })),
|
||||
])
|
||||
|
||||
/** 框编号下拉列 */
|
||||
const basketColumns = computed(() => [
|
||||
basketList.value.map(code => ({ value: code, label: code })),
|
||||
])
|
||||
|
||||
/** 采摘人员选择回调 */
|
||||
function onUserConfirm({ value }: any) {
|
||||
const userId = value?.[0]
|
||||
formData.value.userId = userId
|
||||
const user = userList.value.find(u => u.id === userId)
|
||||
if (user) {
|
||||
formData.value.userName = user.nickname
|
||||
}
|
||||
}
|
||||
|
||||
/** 产品选择回调 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
const productId = value?.[0]
|
||||
formData.value.productId = productId
|
||||
const product = productList.value.find(p => p.id === productId)
|
||||
if (product) {
|
||||
formData.value.productName = product.name
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载下拉列表数据 */
|
||||
async function loadDropdownData() {
|
||||
try {
|
||||
const [users, products, farmingResult, boxResult] = await Promise.all([
|
||||
getSimpleUserList(),
|
||||
getProductSimpleList(),
|
||||
getFarmingManagementPage(),
|
||||
getBoxPage(),
|
||||
])
|
||||
userList.value = users || []
|
||||
productList.value = products || []
|
||||
// 提取田间编号
|
||||
const farmingList = farmingResult?.list || []
|
||||
fieldList.value = [...new Set(farmingList.filter(f => f.code?.trim()).map(f => f.code))]
|
||||
// 提取框编号
|
||||
const boxList = boxResult?.list || []
|
||||
basketList.value = boxList.filter(b => b.boxNumber?.trim()).map(b => b.boxNumber)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
}
|
||||
|
||||
/** 已装车状态时禁用所有字段 */
|
||||
const isLoaded = computed(() => (formData.value.status ?? 0) >= 3)
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return '已采摘'
|
||||
case 2: return '已装框'
|
||||
case 3: return '已装车'
|
||||
case 4: return '已卸车入库'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/pick-broccoli/index')
|
||||
}
|
||||
|
||||
/** 生成采摘编号 */
|
||||
async function handleGenerateCode() {
|
||||
try {
|
||||
const data = await generatePickCode()
|
||||
if (data && data.code) {
|
||||
formData.value.pickCode = data.code
|
||||
} else {
|
||||
// 前端生成备用编号
|
||||
const d = new Date()
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
const rnd = Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
|
||||
formData.value.pickCode = `CJXL${y}${m}${day}${rnd}`
|
||||
}
|
||||
} catch {
|
||||
// 前端生成备用编号
|
||||
const d = new Date()
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
const rnd = Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
|
||||
formData.value.pickCode = `CJXL${y}${m}${day}${rnd}`
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
// 新增时自动生成编号
|
||||
await handleGenerateCode()
|
||||
return
|
||||
}
|
||||
formData.value = await getPickBroccoli(props.id)
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePickBroccoli(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPickBroccoli(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
331
src/pages-erp/pick-broccoli/index.vue
Normal file
331
src/pages-erp/pick-broccoli/index.vue
Normal file
@@ -0,0 +1,331 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采摘管理"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 采摘记录列表 -->
|
||||
<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="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:采摘编号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.pickCode }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusText(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text>{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 采摘人员 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">采摘人员</text>
|
||||
<text>{{ item.userName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 田间编号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">田间编号</text>
|
||||
<text>{{ item.fieldCode || '-' }}</text>
|
||||
</view>
|
||||
<!-- 框编号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">框编号</text>
|
||||
<text>{{ item.basketCode || '-' }}</text>
|
||||
</view>
|
||||
<!-- 重量 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">重量</text>
|
||||
<text class="font-semibold">{{ item.basketWeight || 0 }} kg</text>
|
||||
</view>
|
||||
<!-- 车牌号 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">车牌号</text>
|
||||
<text>{{ item.licensePlate || '-' }}</text>
|
||||
</view>
|
||||
<!-- 采摘时间 -->
|
||||
<view class="flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">采摘时间</text>
|
||||
<text>{{ formatDate(item.pickTime) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && (item.status ?? 0) < 3"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && item.status === 1"
|
||||
size="small" type="success" plain @click="handleStatusUpdate(item, 2, '装框')"
|
||||
>
|
||||
装框
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && item.status === 2"
|
||||
size="small" type="warning" plain @click="handleLoadTruck(item)"
|
||||
>
|
||||
装车
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:delete']) && (item.status ?? 0) < 3"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:pick-broccoli:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePickBroccoli, getPickBroccoliPage, loadTruck, updatePickBroccoliStatus } from '@/api/erp/pick-broccoli'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PickBroccoli[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return '已采摘'
|
||||
case 2: return '已装框'
|
||||
case 3: return '已装车'
|
||||
case 4: return '已入库'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 1: return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||
case 2: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 3: return 'bg-[#f9f0ff] text-[#722ed1]'
|
||||
case 4: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采摘记录列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPickBroccoliPage(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 handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 刷新列表 */
|
||||
function refreshList() {
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 打开详情 */
|
||||
function handleCardClick(item: PickBroccoli) {
|
||||
handleDetail(item)
|
||||
}
|
||||
|
||||
/** 新增采摘记录 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/pick-broccoli/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PickBroccoli) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/pick-broccoli/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PickBroccoli) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/pick-broccoli/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 状态更新(装框) */
|
||||
function handleStatusUpdate(item: PickBroccoli, status: number, text: string) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确认将该记录状态更新为"${text}完成"吗?`,
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePickBroccoliStatus(item.id!, status)
|
||||
toast.success(`${text}操作成功`)
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 装车操作 — 简易输入车牌号 + 装车人 */
|
||||
function handleLoadTruck(item: PickBroccoli) {
|
||||
// 小程序端用简化方式:直接输入车牌号
|
||||
uni.showModal({
|
||||
title: '装车',
|
||||
content: '请输入车牌号',
|
||||
editable: true,
|
||||
placeholderText: '车牌号',
|
||||
success: async (res) => {
|
||||
if (!res.confirm || !res.content) return
|
||||
try {
|
||||
// 使用当前用户作为装车人(简化处理)
|
||||
await loadTruck(item.id!, res.content, 0, '')
|
||||
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 deletePickBroccoli(id)
|
||||
toast.success('删除成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
104
src/pages-erp/purchase-in/components/search-form.vue
Normal file
104
src/pages-erp/purchase-in/components/search-form.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = 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="formData.no"
|
||||
placeholder="请输入入库单编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
审核状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="10">
|
||||
未审核
|
||||
</wd-radio>
|
||||
<wd-radio :value="20">
|
||||
已审核
|
||||
</wd-radio>
|
||||
<wd-radio :value="30">
|
||||
不合格
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
10: '未审核',
|
||||
20: '已审核',
|
||||
30: '不合格',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.no) {
|
||||
conditions.push(`编号:${formData.no}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采购入库单'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.no) {
|
||||
params.no = formData.no
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.no = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
417
src/pages-erp/purchase-in/detail/index.vue
Normal file
417
src/pages-erp/purchase-in/detail/index.vue
Normal file
@@ -0,0 +1,417 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购入库详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="入库单编号" :value="formData.no" />
|
||||
<wd-cell title="审核状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status, formData.isQualified)"
|
||||
>
|
||||
{{ getStatusText(formData.status, formData.isQualified) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" :value="formData.supplierName || '-'" />
|
||||
<wd-cell title="入库时间" :value="formatDateTime(formData.inTime)" />
|
||||
<wd-cell title="关联订单" :value="formData.orderNo || '-'" />
|
||||
<wd-cell title="创建人" :value="formData.creatorName || '-'" />
|
||||
<wd-cell title="创建时间" :value="formatDateTime(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="String(formData.totalCount || 0)" />
|
||||
<wd-cell title="合计产品价格" :value="`¥${formData.totalProductPrice || 0}`" />
|
||||
<wd-cell title="合计税额" :value="`¥${formData.totalTaxPrice || 0}`" />
|
||||
<wd-cell title="优惠率" :value="`${formData.discountPercent || 0}%`" />
|
||||
<wd-cell title="优惠金额" :value="`¥${formData.discountPrice || 0}`" />
|
||||
<wd-cell title="其他费用" :value="`¥${formData.otherPrice || 0}`" />
|
||||
<wd-cell title="应付金额">
|
||||
<text class="text-[#e6a23c] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="已付金额">
|
||||
<text class="text-[#52c41a] font-semibold">¥{{ formData.paymentPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="未付金额">
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(formData.totalPrice || 0) - (formData.paymentPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (formData.totalPrice || 0) - (formData.paymentPrice || 0) }}
|
||||
</text>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 不合格信息 -->
|
||||
<wd-cell-group v-if="formData.status !== 10 && !formData.isQualified" title="不合格信息" border>
|
||||
<wd-cell title="返回方式" :value="getReturnTypeLabel(formData.returnType)" />
|
||||
<wd-cell v-if="formData.returnRemark" title="返回备注" :value="formData.returnRemark" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 入库明细 -->
|
||||
<view class="mx-24rpx mt-24rpx">
|
||||
<view class="mb-16rpx text-32rpx text-[#333] font-semibold">
|
||||
入库明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
<view v-if="formData.items && formData.items.length > 0">
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="item.id || index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<!-- 产品头部 -->
|
||||
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-16rpx">
|
||||
<view class="flex items-center">
|
||||
<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>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<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 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]">
|
||||
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||
<text>{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<!-- 单价 / 数量 / 单位 -->
|
||||
<view class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单价:</text>
|
||||
<text class="text-[#f5222d]">¥{{ item.productPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">数量:</text>
|
||||
<text class="font-semibold">{{ item.count || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单位:</text>
|
||||
<text>{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 税率 / 税额 -->
|
||||
<view v-if="item.taxPercent" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税率:</text>
|
||||
<text>{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税额:</text>
|
||||
<text>¥{{ item.taxPrice || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 金额 / 库存 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">金额:</text>
|
||||
<text class="text-[#e6a23c]">¥{{ item.totalPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">库存:</text>
|
||||
<text>{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view v-if="item.remark" class="text-24rpx text-[#999]">
|
||||
备注:{{ item.remark }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无入库明细
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update']) && formData?.status === 10"
|
||||
class="flex-1" type="warning" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && formData?.status === 10"
|
||||
class="flex-1" type="success" @click="handleAudit"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && (formData?.status === 20 || formData?.status === 30)"
|
||||
class="flex-1" type="warning" @click="handleReverseAudit"
|
||||
>
|
||||
反审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:delete']) && formData?.status === 10"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = 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-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回方式
|
||||
</view>
|
||||
<wd-radio-group v-model="auditForm.returnType" shape="button">
|
||||
<wd-radio
|
||||
v-for="opt in RETURN_TYPE_OPTIONS"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回备注
|
||||
</view>
|
||||
<wd-textarea
|
||||
v-model="auditForm.returnRemark"
|
||||
placeholder="请输入返回方式备注"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="mt-32rpx flex gap-24rpx">
|
||||
<wd-button class="flex-1" plain @click="auditVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" :loading="auditLoading" @click="submitAudit">
|
||||
确定
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseIn } from '@/api/erp/purchase-in'
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseIn, getPurchaseIn, RETURN_TYPE_OPTIONS, updatePurchaseInStatus } from '@/api/erp/purchase-in'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import { formatDateTime } from '@/utils/date'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PurchaseIn>()
|
||||
const deleting = ref(false)
|
||||
|
||||
// 审核相关
|
||||
const auditVisible = ref(false)
|
||||
const auditLoading = ref(false)
|
||||
const auditForm = reactive({
|
||||
isQualified: true,
|
||||
returnType: undefined as string | undefined,
|
||||
returnRemark: undefined as string | undefined,
|
||||
})
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number, isQualified?: boolean) {
|
||||
if (status === 10)
|
||||
return '未审核'
|
||||
if (status === 20)
|
||||
return isQualified ? '已审核' : '不合格'
|
||||
if (status === 30)
|
||||
return '不合格'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number, isQualified?: boolean) {
|
||||
if (status === 10)
|
||||
return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
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 getReturnTypeLabel(value?: string | null) {
|
||||
if (!value)
|
||||
return '-'
|
||||
const option = RETURN_TYPE_OPTIONS.find(opt => opt.value === value)
|
||||
return option ? option.label : value
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-in/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseIn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑操作 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-in/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 打开审核弹窗 */
|
||||
function handleAudit() {
|
||||
auditForm.isQualified = true
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
auditVisible.value = true
|
||||
}
|
||||
|
||||
/** 合格状态变化 */
|
||||
function handleQualifiedChange(val: boolean) {
|
||||
if (val) {
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交审核 */
|
||||
async function submitAudit() {
|
||||
if (!props.id)
|
||||
return
|
||||
if (!auditForm.isQualified && !auditForm.returnType) {
|
||||
toast.warning('请选择返回方式')
|
||||
return
|
||||
}
|
||||
auditLoading.value = true
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id: props.id,
|
||||
isQualified: auditForm.isQualified,
|
||||
returnType: auditForm.returnType,
|
||||
returnRemark: auditForm.returnRemark,
|
||||
status: auditForm.isQualified ? 20 : 30,
|
||||
})
|
||||
toast.success('审核成功')
|
||||
auditVisible.value = false
|
||||
getDetail()
|
||||
} finally {
|
||||
auditLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 反审核操作 */
|
||||
function handleReverseAudit() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审核该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id: props.id,
|
||||
isQualified: false,
|
||||
status: 10,
|
||||
})
|
||||
toast.success('反审核成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除操作 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePurchaseIn([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
812
src/pages-erp/purchase-in/form/index.vue
Normal file
812
src/pages-erp/purchase-in/form/index.vue
Normal file
@@ -0,0 +1,812 @@
|
||||
<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="inTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.inTime"
|
||||
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>{{ getSupplierName() || '-' }}</text>
|
||||
</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" prop="accountId" 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="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
|
||||
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) => onWarehouseConfirm(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 class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">库存</text>
|
||||
<text class="text-[#333]">{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
<view v-if="item.totalCount != null" class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">原数量</text>
|
||||
<text class="text-[#333]">{{ item.totalCount }}</text>
|
||||
</view>
|
||||
<view v-if="item.inCount != null" class="flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">已入库</text>
|
||||
<text class="text-[#333]">{{ item.inCount }}</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.supplierName || '-' }}</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-[#52c41a] font-semibold">
|
||||
{{ item.inCount || 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 { PurchaseIn, PurchaseInItem } from '@/api/erp/purchase-in'
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPurchaseIn, getPurchaseIn, updatePurchaseIn } from '@/api/erp/purchase-in'
|
||||
import { getPurchaseOrder, getPurchaseOrderPage } from '@/api/erp/purchase-order'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
/** 账户简单信息 */
|
||||
interface AccountSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
}
|
||||
|
||||
/** 仓库简单信息 */
|
||||
interface WarehouseSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
enableLocation?: boolean
|
||||
roomNoMax?: number
|
||||
locationCapacity?: number
|
||||
}
|
||||
|
||||
/** 供应商简单信息 */
|
||||
interface SupplierSimple {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
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<PurchaseIn>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
supplierId: undefined,
|
||||
accountId: undefined,
|
||||
inTime: new Date().getTime(),
|
||||
orderId: undefined,
|
||||
orderNo: undefined,
|
||||
discountPercent: 0,
|
||||
discountPrice: 0,
|
||||
otherPrice: 0,
|
||||
totalPrice: 0,
|
||||
remark: '',
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
inTime: [{ required: true, message: '入库时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const supplierList = ref<SupplierSimple[]>([])
|
||||
const accountList = ref<AccountSimple[]>([])
|
||||
const warehouseList = ref<WarehouseSimple[]>([])
|
||||
const defaultWarehouse = ref<WarehouseSimple>()
|
||||
|
||||
// 采购订单选择相关
|
||||
const orderSelectVisible = ref(false)
|
||||
const orderList = ref<PurchaseOrder[]>([])
|
||||
const orderLoadMoreState = ref<LoadMoreState>('loading')
|
||||
const orderQueryParams = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
no: undefined as string | undefined,
|
||||
inEnable: true,
|
||||
})
|
||||
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 })),
|
||||
])
|
||||
|
||||
/** 判断仓库是否启用库位管理 */
|
||||
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() {
|
||||
if (!formData.value.supplierId)
|
||||
return ''
|
||||
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
|
||||
return supplier?.name || formData.value.supplierName || ''
|
||||
}
|
||||
|
||||
/** 账户选择回调 */
|
||||
function onAccountConfirm({ value }: any) {
|
||||
formData.value.accountId = value?.[0]
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm(e: any, index: number) {
|
||||
console.log('[仓库选择] 完整事件:', e, 'index:', index)
|
||||
if (formData.value.items && formData.value.items[index]) {
|
||||
// wd-picker 的 confirm 事件返回 { value, selectedItems }
|
||||
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) {
|
||||
formData.value.items[index].warehouseName = warehouse.name
|
||||
// 如果仓库未启用库位管理,清空库位编码
|
||||
if (!warehouse.enableLocation) {
|
||||
formData.value.items[index].locationCode = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算行项金额 */
|
||||
function calcTotalPrice(item: PurchaseInItem) {
|
||||
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 [suppliers, accounts, warehouses] = await Promise.all([
|
||||
http.get<SupplierSimple[]>('/erp/supplier/simple-list'),
|
||||
http.get<AccountSimple[]>('/erp/account/simple-list'),
|
||||
http.get<WarehouseSimple[]>('/erp/warehouse/simple-list'),
|
||||
])
|
||||
supplierList.value = suppliers || []
|
||||
accountList.value = accounts || []
|
||||
warehouseList.value = warehouses || []
|
||||
console.log('[仓库数据] warehouseList:', warehouseList.value)
|
||||
// 设置默认账户
|
||||
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/purchase-in/index')
|
||||
}
|
||||
|
||||
/** 删除入库明细行 */
|
||||
function handleRemoveItem(index: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定要删除第 ${index + 1} 项产品吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 拆分明细行:复制当前产品行为一条新行,用于“同一产品分多个库位”录入 */
|
||||
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() {
|
||||
orderSelectVisible.value = true
|
||||
orderQueryParams.value.pageNo = 1
|
||||
orderList.value = []
|
||||
selectedOrderId.value = formData.value.orderId
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
/** 获取可入库订单列表 */
|
||||
async function getOrderList() {
|
||||
orderLoadMoreState.value = 'loading'
|
||||
try {
|
||||
const data = await getPurchaseOrderPage(orderQueryParams.value)
|
||||
if (orderQueryParams.value.pageNo === 1) {
|
||||
orderList.value = data.list
|
||||
} else {
|
||||
orderList.value = [...orderList.value, ...data.list]
|
||||
}
|
||||
orderTotal.value = data.total
|
||||
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: PurchaseOrder) {
|
||||
selectedOrderId.value = item.id
|
||||
}
|
||||
|
||||
/** 确认选择订单 */
|
||||
async function confirmSelectOrder() {
|
||||
if (!selectedOrderId.value)
|
||||
return
|
||||
try {
|
||||
toast.loading('加载订单详情...')
|
||||
const orderDetail = await getPurchaseOrder(selectedOrderId.value)
|
||||
// 设置订单信息
|
||||
formData.value.orderId = orderDetail.id
|
||||
formData.value.orderNo = orderDetail.no
|
||||
formData.value.supplierId = orderDetail.supplierId
|
||||
formData.value.supplierName = orderDetail.supplierName
|
||||
formData.value.accountId = orderDetail.accountId
|
||||
formData.value.discountPercent = orderDetail.discountPercent
|
||||
formData.value.remark = orderDetail.remark
|
||||
// 设置入库明细
|
||||
if (orderDetail.items) {
|
||||
formData.value.items = orderDetail.items
|
||||
.filter(item => (item.count || 0) - (item.inCount || 0) > 0)
|
||||
.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productUnitId: item.productUnitId,
|
||||
productUnitName: item.productUnitName,
|
||||
productPrice: item.productPrice,
|
||||
productSpec: item.productSpec,
|
||||
productBarCode: item.productBarCode,
|
||||
count: (item.count || 0) - (item.inCount || 0),
|
||||
totalCount: item.count,
|
||||
inCount: item.inCount,
|
||||
taxPercent: item.taxPercent,
|
||||
warehouseId: defaultWarehouse.value?.id,
|
||||
warehouseName: defaultWarehouse.value?.name,
|
||||
stockCount: item.stockCount,
|
||||
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 getPurchaseIn(props.id)
|
||||
} 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.warehouseId) {
|
||||
toast.warning(`第 ${i + 1} 项产品请选择仓库`)
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.warning(`第 ${i + 1} 项产品数量不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePurchaseIn(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseIn(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
800
src/pages-erp/purchase-in/index.vue
Normal file
800
src/pages-erp/purchase-in/index.vue
Normal file
@@ -0,0 +1,800 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购入库"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 状态快速筛选 -->
|
||||
<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="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="handleQuickFilter(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="activeStatus === 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="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.no }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status, item.isQualified)"
|
||||
>
|
||||
{{ getStatusText(item.status, item.isQualified) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 供应商 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</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="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">入库时间</text>
|
||||
<text>{{ formatDate(item.inTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</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="mt-12rpx flex items-center justify-around border-t border-[#f0f0f0] pt-16rpx">
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.totalCount || 0 }}
|
||||
</view>
|
||||
<view class="mt-4rpx text-22rpx text-[#999]">
|
||||
总数量
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#e6a23c] font-semibold">
|
||||
¥{{ item.totalPrice || 0 }}
|
||||
</view>
|
||||
<view class="mt-4rpx text-22rpx text-[#999]">
|
||||
应付
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#52c41a] font-semibold">
|
||||
¥{{ item.paymentPrice || 0 }}
|
||||
</view>
|
||||
<view class="mt-4rpx text-22rpx text-[#999]">
|
||||
已付
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view
|
||||
class="text-30rpx font-semibold"
|
||||
:class="(item.totalPrice || 0) - (item.paymentPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (item.totalPrice || 0) - (item.paymentPrice || 0) }}
|
||||
</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:purchase-in:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
修改
|
||||
</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
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleAudit(item)"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:update-status']) && (item.status === 20 || item.status === 30)"
|
||||
size="small" type="warning" plain @click="handleReverseAudit(item.id!)"
|
||||
>
|
||||
反审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:delete']) && item.status === 10 && !item.hasApprovalRecords"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-in:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<wd-popup v-model="auditVisible" position="bottom" closable @close="auditVisible = 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-switch v-model="auditForm.isQualified" @change="handleQualifiedChange" />
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回方式
|
||||
</view>
|
||||
<wd-radio-group v-model="auditForm.returnType" shape="button">
|
||||
<wd-radio
|
||||
v-for="opt in RETURN_TYPE_OPTIONS"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</view>
|
||||
<view v-if="!auditForm.isQualified" class="mb-24rpx">
|
||||
<view class="mb-12rpx text-26rpx text-[#666]">
|
||||
返回备注
|
||||
</view>
|
||||
<wd-textarea
|
||||
v-model="auditForm.returnRemark"
|
||||
placeholder="请输入返回方式备注"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</view>
|
||||
<view class="mt-32rpx flex gap-24rpx">
|
||||
<wd-button class="flex-1" plain @click="auditVisible = false">
|
||||
取消
|
||||
</wd-button>
|
||||
<wd-button class="flex-1" type="primary" :loading="auditLoading" @click="submitAudit">
|
||||
确定
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseIn } from '@/api/erp/purchase-in'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
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 { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PurchaseIn[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const activeStatus = ref<number | undefined>(undefined)
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
const statusTabs = [
|
||||
{ label: '全部', value: undefined },
|
||||
{ label: '未审核', value: 10 },
|
||||
{ label: '已审核', value: 20 },
|
||||
{ label: '不合格', value: 30 },
|
||||
]
|
||||
|
||||
// 审核相关
|
||||
const auditVisible = ref(false)
|
||||
const auditLoading = ref(false)
|
||||
const auditForm = reactive({
|
||||
id: undefined as number | undefined,
|
||||
isQualified: true,
|
||||
returnType: 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) {
|
||||
if (!date)
|
||||
return '-'
|
||||
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) {
|
||||
if (status === 10)
|
||||
return '未审核'
|
||||
if (status === 20)
|
||||
return isQualified ? '已审核' : '不合格'
|
||||
if (status === 30)
|
||||
return '不合格'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number, isQualified?: boolean) {
|
||||
if (status === 10)
|
||||
return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
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]'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采购入库列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPurchaseInPage(params)
|
||||
|
||||
// 为每条记录检查是否有审批记录
|
||||
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
|
||||
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 handleQuickFilter(status?: number) {
|
||||
activeStatus.value = status
|
||||
queryParams.value.status = status
|
||||
queryParams.value.pageNo = 1
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
status: activeStatus.value,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
activeStatus.value = undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 已审核打开详情,未审核打开编辑 */
|
||||
function handleCardClick(item: PurchaseIn) {
|
||||
if (item.status === 20 || item.status === 30) {
|
||||
handleDetail(item)
|
||||
} else if (item.status === 10) {
|
||||
handleEdit(item)
|
||||
}
|
||||
}
|
||||
|
||||
/** 新增采购入库 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/purchase-in/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PurchaseIn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-in/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseIn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-in/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 扫码入库 */
|
||||
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) {
|
||||
auditForm.id = item.id
|
||||
auditForm.isQualified = true
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
auditVisible.value = true
|
||||
}
|
||||
|
||||
/** 合格状态变化 */
|
||||
function handleQualifiedChange(val: boolean) {
|
||||
if (val) {
|
||||
auditForm.returnType = undefined
|
||||
auditForm.returnRemark = undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交审核 */
|
||||
async function submitAudit() {
|
||||
if (!auditForm.id)
|
||||
return
|
||||
if (!auditForm.isQualified && !auditForm.returnType) {
|
||||
toast.warning('请选择返回方式')
|
||||
return
|
||||
}
|
||||
auditLoading.value = true
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id: auditForm.id,
|
||||
isQualified: auditForm.isQualified,
|
||||
returnType: auditForm.returnType,
|
||||
returnRemark: auditForm.returnRemark,
|
||||
status: auditForm.isQualified ? 20 : 30,
|
||||
})
|
||||
toast.success('审核成功')
|
||||
auditVisible.value = false
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} finally {
|
||||
auditLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 反审核 */
|
||||
function handleReverseAudit(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定反审核该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm)
|
||||
return
|
||||
try {
|
||||
await updatePurchaseInStatus({
|
||||
id,
|
||||
isQualified: false,
|
||||
status: 10,
|
||||
})
|
||||
toast.success('反审核成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm)
|
||||
return
|
||||
try {
|
||||
await deletePurchaseIn([id])
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交审批 */
|
||||
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(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
888
src/pages-erp/purchase-in/scan-in/index.vue
Normal file
888
src/pages-erp/purchase-in/scan-in/index.vue
Normal 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>
|
||||
@@ -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>
|
||||
187
src/pages-erp/purchase-in/scan/components/recent-scan-list.vue
Normal file
187
src/pages-erp/purchase-in/scan/components/recent-scan-list.vue
Normal 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>
|
||||
@@ -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>
|
||||
1427
src/pages-erp/purchase-in/scan/index.vue
Normal file
1427
src/pages-erp/purchase-in/scan/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
104
src/pages-erp/purchase-order/components/search-form.vue
Normal file
104
src/pages-erp/purchase-order/components/search-form.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = 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="formData.no"
|
||||
placeholder="请输入采购单编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
采购状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="10">
|
||||
未审批
|
||||
</wd-radio>
|
||||
<wd-radio :value="20">
|
||||
已审批
|
||||
</wd-radio>
|
||||
<wd-radio :value="30">
|
||||
已驳回
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
10: '未审批',
|
||||
20: '已审批',
|
||||
30: '已驳回',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.no) {
|
||||
conditions.push(`编号:${formData.no}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采购订单'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.no) {
|
||||
params.no = formData.no
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.no = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
298
src/pages-erp/purchase-order/detail/index.vue
Normal file
298
src/pages-erp/purchase-order/detail/index.vue
Normal file
@@ -0,0 +1,298 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购订单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="采购单编号" :value="formData.no" />
|
||||
<wd-cell title="扫码识别值" :value="formData.no || '-'" />
|
||||
<wd-cell title="采购状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status)"
|
||||
>
|
||||
{{ getStatusText(formData.status) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" :value="formData.supplierName || '-'" />
|
||||
<wd-cell title="下单时间" :value="formatDateTime(formData.orderTime)" />
|
||||
<wd-cell title="创建人" :value="formData.creatorName || '-'" />
|
||||
<wd-cell title="审核人" :value="formData.auditorName || '-'" />
|
||||
<wd-cell title="创建时间" :value="formatDateTime(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合同信息 -->
|
||||
<wd-cell-group title="合同信息" border>
|
||||
<wd-cell title="发票类别" :value="formData.invoiceTypeName || '-'" />
|
||||
<wd-cell title="运费承担方" :value="formData.freightPayerName || '-'" />
|
||||
<wd-cell title="结算方式" :value="formData.settlementMethodName || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="String(formData.totalCount || 0)" />
|
||||
<wd-cell title="合计产品价格" :value="`¥${formData.totalProductPrice || 0}`" />
|
||||
<wd-cell title="合计税额" :value="`¥${formData.totalTaxPrice || 0}`" />
|
||||
<wd-cell title="优惠率" :value="`${formData.discountPercent || 0}%`" />
|
||||
<wd-cell title="优惠金额" :value="`¥${formData.discountPrice || 0}`" />
|
||||
<wd-cell title="定金金额" :value="`¥${formData.depositPrice || 0}`" />
|
||||
<wd-cell title="最终合计价格">
|
||||
<text class="text-[#f5222d] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 入库/退货信息 -->
|
||||
<wd-cell-group title="入库/退货" border>
|
||||
<wd-cell title="入库数量" :value="String(formData.inCount || 0)" />
|
||||
<wd-cell title="退货数量" :value="String(formData.returnCount || 0)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 请购单信息 -->
|
||||
<wd-cell-group v-if="formData.purchaseRequisitionNo" title="关联请购单" border>
|
||||
<wd-cell title="请购单编号" :value="formData.purchaseRequisitionNo" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 订单明细 -->
|
||||
<view class="mx-24rpx mt-24rpx">
|
||||
<view class="mb-16rpx text-32rpx text-[#333] font-semibold">
|
||||
订单明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
<view v-if="formData.items && formData.items.length > 0">
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="item.id || index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<!-- 产品头部 -->
|
||||
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-16rpx">
|
||||
<view class="flex items-center">
|
||||
<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>
|
||||
</view>
|
||||
<text v-if="item.supplierName" class="text-24rpx text-[#1890ff]">{{ item.supplierName }}</text>
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<!-- 产品规格 -->
|
||||
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||
<text>{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<!-- 单价 / 数量 / 单位 -->
|
||||
<view class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单价:</text>
|
||||
<text class="text-[#f5222d]">¥{{ item.productPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">数量:</text>
|
||||
<text class="font-semibold">{{ item.count || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单位:</text>
|
||||
<text>{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 税率 / 税额 -->
|
||||
<view v-if="item.taxPercent" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税率:</text>
|
||||
<text>{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税额:</text>
|
||||
<text>¥{{ item.taxPrice || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 入库 / 退货 / 库存 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">入库:</text>
|
||||
<text>{{ item.inCount || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">退货:</text>
|
||||
<text>{{ item.returnCount || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">库存:</text>
|
||||
<text>{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view v-if="item.remark" class="text-24rpx text-[#999]">
|
||||
备注:{{ item.remark }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无订单明细
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update']) && formData?.status === 10"
|
||||
class="flex-1" type="warning" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && formData?.status === 10"
|
||||
class="flex-1" type="success" @click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:delete']) && formData?.status !== 20"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseOrder, getPurchaseOrder, updatePurchaseOrderStatus } from '@/api/erp/purchase-order'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import { formatDateTime } from '@/utils/date'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PurchaseOrder>()
|
||||
const deleting = ref(false)
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return '未审批'
|
||||
case 20: return '已审批'
|
||||
case 30: return '已驳回'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 20: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
case 30: return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-order/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseOrder(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑操作 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-order/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批操作 */
|
||||
function handleApprove() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批通过该采购订单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseOrderStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除操作 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购订单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePurchaseOrder([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
524
src/pages-erp/purchase-order/form/index.vue
Normal file
524
src/pages-erp/purchase-order/form/index.vue
Normal file
@@ -0,0 +1,524 @@
|
||||
<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" is-link center @click="openRequisitionPicker">
|
||||
<text v-if="formData.purchaseRequisitionNo" class="text-[#1890ff]">{{ formData.purchaseRequisitionNo }}</text>
|
||||
<text v-else class="text-[#999]">请选择(可选)</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" title-width="180rpx" prop="supplierId" center>
|
||||
<wd-picker
|
||||
v-model="formData.supplierId"
|
||||
:columns="supplierColumns"
|
||||
label=""
|
||||
placeholder="请选择供应商"
|
||||
@confirm="onSupplierConfirm"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="采购时间" title-width="180rpx" prop="orderTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.orderTime"
|
||||
type="datetime"
|
||||
label=""
|
||||
placeholder="请选择采购时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="合同信息" border>
|
||||
<wd-cell title="发票类别" title-width="180rpx" center>
|
||||
<wd-radio-group v-model="formData.invoiceType" shape="button">
|
||||
<wd-radio :value="1">
|
||||
增值税普通发票
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
增值税专用发票
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</wd-cell>
|
||||
<wd-cell title="运费承担方" title-width="180rpx" center>
|
||||
<wd-radio-group v-model="formData.freightPayer" shape="button">
|
||||
<wd-radio :value="1">
|
||||
卖方承担
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
买方承担
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</wd-cell>
|
||||
<wd-cell title="结算方式" title-width="180rpx" center>
|
||||
<wd-radio-group v-model="formData.settlementMethod" shape="button">
|
||||
<wd-radio :value="1">
|
||||
款到发货
|
||||
</wd-radio>
|
||||
<wd-radio :value="2">
|
||||
货到票到付款
|
||||
</wd-radio>
|
||||
<wd-radio :value="3">
|
||||
预付部分货到付清
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group title="其他信息" border>
|
||||
<wd-input
|
||||
v-model="formData.discountPercent"
|
||||
label="优惠率(%)"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入优惠率"
|
||||
clearable
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.depositPrice"
|
||||
label="定金金额"
|
||||
label-width="180rpx"
|
||||
type="number"
|
||||
placeholder="请输入定金金额"
|
||||
clearable
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.remark"
|
||||
label="备注"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入备注"
|
||||
:maxlength="200"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</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>
|
||||
<wd-button size="small" type="primary" @click="handleAddItem">
|
||||
+ 添加产品
|
||||
</wd-button>
|
||||
</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>
|
||||
<wd-button size="small" type="error" plain @click="handleRemoveItem(index)">
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<view class="mb-16rpx">
|
||||
<text class="mb-8rpx block text-24rpx text-[#999]">选择产品</text>
|
||||
<wd-picker
|
||||
v-model="item.productId"
|
||||
:columns="productColumns"
|
||||
placeholder="请选择产品"
|
||||
@confirm="(e: any) => onProductConfirm(e, index)"
|
||||
/>
|
||||
</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.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 class="flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text class="text-[#333]">{{ item.supplierName || '-' }}</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="requisitionPickerVisible" position="bottom" :safe-area-inset-bottom="true">
|
||||
<view class="bg-white">
|
||||
<view class="flex items-center justify-between border-b border-[#eee] px-24rpx py-24rpx">
|
||||
<text class="text-32rpx font-semibold">选择请购单</text>
|
||||
<wd-icon name="close" size="40rpx" @click="requisitionPickerVisible = false" />
|
||||
</view>
|
||||
<view class="max-h-[60vh] overflow-y-auto">
|
||||
<view v-if="requisitionLoading" class="py-60rpx text-center text-[#999]">
|
||||
加载中...
|
||||
</view>
|
||||
<view v-else-if="requisitionList.length === 0" class="py-60rpx text-center text-[#999]">
|
||||
暂无已审核的请购单
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="req in requisitionList"
|
||||
:key="req.id"
|
||||
class="border-b border-[#f5f5f5] px-24rpx py-20rpx"
|
||||
@click="onRequisitionSelect(req)"
|
||||
>
|
||||
<view class="mb-8rpx flex items-center justify-between">
|
||||
<text class="text-28rpx text-[#333] font-semibold">{{ req.no }}</text>
|
||||
<text class="text-24rpx text-[#1890ff]">¥{{ req.totalPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-24rpx text-[#999]">
|
||||
<text>请购人:{{ req.requesterNickname || '-' }}</text>
|
||||
<text>{{ formatDate(req.requestTime) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PurchaseOrder, PurchaseOrderItem } from '@/api/erp/purchase-order'
|
||||
import type { ProductSimple } from '@/api/erp/product'
|
||||
import type { SupplierSimple } from '@/api/erp/supplier'
|
||||
import type { PurchaseRequisition } from '@/api/erp/purchase-requisition'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPurchaseOrder, getPurchaseOrder, updatePurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import { getProductSimpleList } from '@/api/erp/product'
|
||||
import { getSupplierSimpleList } from '@/api/erp/supplier'
|
||||
import { getPurchaseRequisition, getPurchaseRequisitionPage } from '@/api/erp/purchase-requisition'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<PurchaseOrder>({
|
||||
id: undefined,
|
||||
purchaseRequisitionId: undefined,
|
||||
purchaseRequisitionNo: undefined,
|
||||
supplierId: undefined,
|
||||
orderTime: undefined,
|
||||
discountPercent: undefined,
|
||||
depositPrice: undefined,
|
||||
invoiceType: undefined,
|
||||
freightPayer: undefined,
|
||||
settlementMethod: undefined,
|
||||
remark: '',
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
supplierId: [{ required: true, message: '供应商不能为空' }],
|
||||
orderTime: [{ required: true, message: '采购时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const supplierList = ref<SupplierSimple[]>([])
|
||||
const productList = ref<ProductSimple[]>([])
|
||||
const requisitionList = ref<PurchaseRequisition[]>([])
|
||||
const requisitionPickerVisible = ref(false)
|
||||
const requisitionLoading = ref(false)
|
||||
|
||||
/** 供应商下拉列 */
|
||||
const supplierColumns = computed(() => [
|
||||
supplierList.value.map(s => ({ value: s.id, label: s.name })),
|
||||
])
|
||||
|
||||
/** 产品下拉列 */
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(p => ({ value: p.id, label: p.name })),
|
||||
])
|
||||
|
||||
/** 供应商选择回调 */
|
||||
function onSupplierConfirm({ value }: any) {
|
||||
formData.value.supplierId = value?.[0]
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(dateVal?: string | number | Date) {
|
||||
return formatDateValue(dateVal) || '-'
|
||||
}
|
||||
|
||||
/** 打开请购单选择弹窗 */
|
||||
async function openRequisitionPicker() {
|
||||
requisitionPickerVisible.value = true
|
||||
requisitionLoading.value = true
|
||||
try {
|
||||
const res = await getPurchaseRequisitionPage({ pageNo: 1, pageSize: 50, status: 2 })
|
||||
requisitionList.value = res.list || []
|
||||
} finally {
|
||||
requisitionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 请购单选择回调:带出税率税额等信息 */
|
||||
async function onRequisitionSelect(requisition: PurchaseRequisition) {
|
||||
requisitionPickerVisible.value = false
|
||||
formData.value.purchaseRequisitionId = requisition.id
|
||||
formData.value.purchaseRequisitionNo = requisition.no
|
||||
|
||||
// 自动填充供应商
|
||||
if (requisition.supplierId) {
|
||||
formData.value.supplierId = requisition.supplierId
|
||||
}
|
||||
|
||||
try {
|
||||
toast.loading('加载请购单明细...')
|
||||
// 获取请购单详情(包含明细项)
|
||||
const detail = await getPurchaseRequisition(requisition.id!)
|
||||
|
||||
// 转换请购单明细为采购订单明细(带上税率和税额)
|
||||
const orderItems: PurchaseOrderItem[] = (detail.items || []).map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productSpec: item.productSpec,
|
||||
productUnitId: item.productUnitId,
|
||||
productUnitName: item.productUnitName,
|
||||
productBarCode: item.productBarCode,
|
||||
productPrice: item.productPrice,
|
||||
count: item.count,
|
||||
totalProductPrice: item.totalProductPrice || item.totalPrice,
|
||||
taxPercent: item.taxPercent || 0,
|
||||
taxPrice: item.taxPrice || 0,
|
||||
totalPrice: item.totalPrice,
|
||||
supplierId: item.supplierId,
|
||||
supplierName: item.supplierName,
|
||||
remark: item.remark,
|
||||
}))
|
||||
|
||||
formData.value.items = orderItems
|
||||
|
||||
// 带上备注
|
||||
if (detail.remark) {
|
||||
formData.value.remark = `基于请购单 ${detail.no} 生成\n${detail.remark}`
|
||||
}
|
||||
|
||||
toast.success('已导入请购单明细')
|
||||
} catch {
|
||||
toast.error('获取请购单详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 产品选择回调:自动填充规格/单位/条码/单价/供应商 */
|
||||
function onProductConfirm({ value }: any, index: number) {
|
||||
const productId = value?.[0]
|
||||
if (formData.value.items && formData.value.items[index]) {
|
||||
const item = formData.value.items[index]
|
||||
item.productId = productId
|
||||
const product = productList.value.find(p => p.id === productId)
|
||||
if (product) {
|
||||
item.productName = product.name
|
||||
item.productSpec = product.standard || ''
|
||||
item.productUnitName = product.unitName || ''
|
||||
item.productUnitId = product.unitId as any
|
||||
item.productBarCode = product.barCode || ''
|
||||
item.productPrice = product.purchasePrice
|
||||
item.supplierId = product.supplierId
|
||||
item.supplierName = product.supplierName || ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算行项金额 */
|
||||
function calcTotalPrice(item: PurchaseOrderItem) {
|
||||
if (item.productPrice && item.count) {
|
||||
const total = Number(item.productPrice) * Number(item.count)
|
||||
return `¥${total.toFixed(2)}`
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
/** 加载下拉列表数据 */
|
||||
async function loadDropdownData() {
|
||||
try {
|
||||
const [suppliers, products] = await Promise.all([
|
||||
getSupplierSimpleList(),
|
||||
getProductSimpleList(),
|
||||
])
|
||||
supplierList.value = suppliers || []
|
||||
productList.value = products || []
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-order/index')
|
||||
}
|
||||
|
||||
/** 添加订单明细行 */
|
||||
function handleAddItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
productId: undefined as any,
|
||||
productName: undefined as any,
|
||||
productUnitId: undefined as any,
|
||||
productUnitName: undefined as any,
|
||||
productPrice: undefined,
|
||||
productSpec: undefined as any,
|
||||
productBarCode: undefined as any,
|
||||
count: 1 as any,
|
||||
taxPercent: undefined,
|
||||
supplierId: undefined,
|
||||
supplierName: undefined as any,
|
||||
remark: '',
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除订单明细行 */
|
||||
function handleRemoveItem(index: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定要删除第 ${index + 1} 项产品吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
formData.value = await getPurchaseOrder(props.id)
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
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.productId) {
|
||||
toast.warning(`第 ${i + 1} 项产品ID不能为空`)
|
||||
return
|
||||
}
|
||||
if (!item.count) {
|
||||
toast.warning(`第 ${i + 1} 项产品数量不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePurchaseOrder(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseOrder(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
344
src/pages-erp/purchase-order/index.vue
Normal file
344
src/pages-erp/purchase-order/index.vue
Normal file
@@ -0,0 +1,344 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购订单"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 状态快速筛选 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="handleQuickFilter(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="activeStatus === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx 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="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.no }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusText(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 供应商 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 订单时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">订单时间</text>
|
||||
<text>{{ formatDate(item.orderTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#52c41a] font-semibold">{{ item.inCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">已入库</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">含税金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update']) && item.status !== 20"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleUpdateStatus(item.id!, 20)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && item.status === 20"
|
||||
size="small" type="error" plain @click="handleUpdateStatus(item.id!, 10)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-order: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-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-order:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseOrder, getPurchaseOrderPage, updatePurchaseOrderStatus } from '@/api/erp/purchase-order'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PurchaseOrder[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const activeStatus = ref<number | undefined>(undefined)
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
const statusTabs = [
|
||||
{ label: '全部', value: undefined },
|
||||
{ label: '待审核', value: 10 },
|
||||
{ label: '已审核', value: 20 },
|
||||
]
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return '未审批'
|
||||
case 20: return '已审批'
|
||||
case 30: return '已驳回'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
switch (status) {
|
||||
case 10: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
case 20: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
case 30: return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采购订单列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPurchaseOrderPage(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 handleQuickFilter(status?: number) {
|
||||
activeStatus.value = status
|
||||
queryParams.value.status = status
|
||||
queryParams.value.pageNo = 1
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
status: activeStatus.value,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
activeStatus.value = undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 已审核打开详情,未审核打开编辑 */
|
||||
function handleCardClick(item: PurchaseOrder) {
|
||||
if (item.status === 20) {
|
||||
handleDetail(item)
|
||||
} else if (item.status === 10) {
|
||||
handleEdit(item)
|
||||
}
|
||||
}
|
||||
|
||||
/** 新增采购订单 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/purchase-order/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PurchaseOrder) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-order/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseOrder) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-order/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批/反审批 */
|
||||
function handleUpdateStatus(id: number, status: number) {
|
||||
const text = status === 20 ? '审批' : '反审批'
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定${text}该订单吗?`,
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseOrderStatus(id, status)
|
||||
toast.success(`${text}成功`)
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购订单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseOrder([id])
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
373
src/pages-erp/purchase-requisition/detail/index.vue
Normal file
373
src/pages-erp/purchase-requisition/detail/index.vue
Normal file
@@ -0,0 +1,373 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="请购单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="请购单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="请购类型">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getTypeClass(detail.type)"
|
||||
>
|
||||
{{ getTypeLabel(detail.type) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getStatusClass(detail.status)"
|
||||
>
|
||||
{{ getStatusLabel(detail.status) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="优先级">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getPriorityClass(detail.priority)"
|
||||
>
|
||||
{{ getPriorityLabel(detail.priority) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="紧急程度">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getEmergencyClass(detail.emergencyDegree)"
|
||||
>
|
||||
{{ getEmergencyLabel(detail.emergencyDegree) }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="请购人" :value="detail.requesterNickname || '-'" />
|
||||
<wd-cell title="请购部门" :value="detail.requesterDeptName || '-'" />
|
||||
<wd-cell title="请购时间" :value="formatDate(detail.requestTime)" />
|
||||
<wd-cell title="期望到货" :value="formatDate(detail.expectedTime)" />
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计产品金额" :value="formatPrice(detail.totalProductPrice)" />
|
||||
<wd-cell title="合计税额" :value="formatPrice(detail.totalTaxPrice)" />
|
||||
<wd-cell title="合计金额(含税)" :value="formatPrice(detail.totalPrice)" />
|
||||
<wd-cell title="附加费" :value="formatPrice(detail.additionalFee)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 审核信息 -->
|
||||
<wd-cell-group v-if="detail.status !== 1" title="审核信息" border>
|
||||
<wd-cell title="审核人" :value="detail.approverName || '-'" />
|
||||
<wd-cell title="审核时间" :value="formatDateTime(detail.approveTime)" />
|
||||
<wd-cell title="审核意见" :value="detail.approveRemark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 请购产品清单 -->
|
||||
<wd-cell-group title="请购产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">规格</text>
|
||||
<text class="text-[#666]">{{ item.productSpec || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#666]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">需求数量</text>
|
||||
<text class="text-[#333] font-semibold">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">参考单价</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.productPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">产品金额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.totalProductPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.taxPercent" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">税率</text>
|
||||
<text class="text-[#666]">{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view v-if="item.taxPrice" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">税额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.taxPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">含税金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.supplierName" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">建议供应商</text>
|
||||
<text class="text-[#666]">{{ item.supplierName }}</text>
|
||||
</view>
|
||||
<view v-if="item.purpose" class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">用途</text>
|
||||
<text class="text-[#666]">{{ item.purpose }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update']) && detail.status === 1"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update-status']) && detail.status === 1"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:approve']) && detail.status === 1"
|
||||
type="warning"
|
||||
@click="handleReject"
|
||||
>
|
||||
驳回
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:delete']) && detail.status === 1"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseRequisition } from '@/api/erp/purchase-requisition'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import {
|
||||
deletePurchaseRequisition,
|
||||
EMERGENCY_OPTIONS,
|
||||
getPurchaseRequisition,
|
||||
PRIORITY_OPTIONS,
|
||||
REQUISITION_TYPE_OPTIONS,
|
||||
STATUS_OPTIONS,
|
||||
updatePurchaseRequisitionStatus,
|
||||
} from '@/api/erp/purchase-requisition'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<PurchaseRequisition>({})
|
||||
|
||||
/** 获取类型标签 */
|
||||
function getTypeLabel(type?: number) {
|
||||
return REQUISITION_TYPE_OPTIONS.find(o => o.value === type)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取类型样式 */
|
||||
function getTypeClass(type?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
2: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
3: 'bg-[#f9f0ff] text-[#722ed1]',
|
||||
}
|
||||
return map[type || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取状态标签 */
|
||||
function getStatusLabel(status?: number) {
|
||||
return STATUS_OPTIONS.find(o => o.value === status)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
2: 'bg-[#f6ffed] text-[#52c41a]',
|
||||
3: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
4: 'bg-[#f5f5f5] text-[#999]',
|
||||
5: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
}
|
||||
return map[status || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取优先级标签 */
|
||||
function getPriorityLabel(priority?: number) {
|
||||
return PRIORITY_OPTIONS.find(o => o.value === priority)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取优先级样式 */
|
||||
function getPriorityClass(priority?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[priority || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取紧急程度标签 */
|
||||
function getEmergencyLabel(emergency?: number) {
|
||||
return EMERGENCY_OPTIONS.find(o => o.value === emergency)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取紧急程度样式 */
|
||||
function getEmergencyClass(emergency?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[emergency || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
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 formatDateTime(dateStr?: string | number | Date) {
|
||||
return formatDateValue(dateStr, 'YYYY-MM-DD HH:mm') || '-'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-requisition/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getPurchaseRequisition(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/purchase-requisition/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审核 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审核通过该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(props.id, 2)
|
||||
toast.success('审核成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 驳回 */
|
||||
function handleReject() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要驳回该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(props.id, 3)
|
||||
toast.success('驳回成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseRequisition(props.id)
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
512
src/pages-erp/purchase-requisition/form/index.vue
Normal file
512
src/pages-erp/purchase-requisition/form/index.vue
Normal file
@@ -0,0 +1,512 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="请购单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="请购类型"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getTypeLabel(formData.type)"
|
||||
@click="typePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="优先级"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getPriorityLabel(formData.priority)"
|
||||
@click="priorityPickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="紧急程度"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getEmergencyLabel(formData.emergencyDegree)"
|
||||
@click="emergencyPickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="请购时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.requestTime ? formatDate(formData.requestTime) : '请选择'"
|
||||
@click="requestDatePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="期望到货"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.expectedTime ? formatDate(formData.expectedTime) : '请选择'"
|
||||
@click="expectedDatePickerVisible = true"
|
||||
/>
|
||||
<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>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="需求数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="参考单价"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">产品金额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.totalProductPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.taxPercent"
|
||||
label="税率(%)"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入税率"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">税额</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.taxPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">含税金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.purpose"
|
||||
label="用途说明"
|
||||
label-width="140rpx"
|
||||
placeholder="请输入用途"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
label="备注"
|
||||
label-width="140rpx"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计产品金额" :value="formatPrice(totalProductPrice)" />
|
||||
<wd-cell title="合计税额" :value="formatPrice(totalTaxPrice)" />
|
||||
<wd-cell title="合计金额(含税)" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 请购类型选择器 -->
|
||||
<wd-picker
|
||||
v-model="typePickerVisible"
|
||||
:columns="typeColumns"
|
||||
@confirm="onTypeConfirm"
|
||||
/>
|
||||
|
||||
<!-- 优先级选择器 -->
|
||||
<wd-picker
|
||||
v-model="priorityPickerVisible"
|
||||
:columns="priorityColumns"
|
||||
@confirm="onPriorityConfirm"
|
||||
/>
|
||||
|
||||
<!-- 紧急程度选择器 -->
|
||||
<wd-picker
|
||||
v-model="emergencyPickerVisible"
|
||||
:columns="emergencyColumns"
|
||||
@confirm="onEmergencyConfirm"
|
||||
/>
|
||||
|
||||
<!-- 请购时间选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="requestDatePickerVisible"
|
||||
type="date"
|
||||
:value="formData.requestTime"
|
||||
@confirm="onRequestDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 期望到货选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="expectedDatePickerVisible"
|
||||
type="date"
|
||||
:value="formData.expectedTime"
|
||||
@confirm="onExpectedDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { PurchaseRequisition, PurchaseRequisitionItem } from '@/api/erp/purchase-requisition'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import {
|
||||
createPurchaseRequisition,
|
||||
EMERGENCY_OPTIONS,
|
||||
getPurchaseRequisition,
|
||||
PRIORITY_OPTIONS,
|
||||
REQUISITION_TYPE_OPTIONS,
|
||||
updatePurchaseRequisition,
|
||||
} from '@/api/erp/purchase-requisition'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<PurchaseRequisition>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
type: 1,
|
||||
priority: 2,
|
||||
emergencyDegree: 1,
|
||||
requestTime: undefined,
|
||||
expectedTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
type: [{ required: true, message: '请购类型不能为空' }],
|
||||
requestTime: [{ required: true, message: '请购时间不能为空' }],
|
||||
expectedTime: [{ required: true, message: '期望到货时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 类型选择器
|
||||
const typePickerVisible = ref(false)
|
||||
const typeColumns = computed(() => [
|
||||
REQUISITION_TYPE_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
// 优先级选择器
|
||||
const priorityPickerVisible = ref(false)
|
||||
const priorityColumns = computed(() => [
|
||||
PRIORITY_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
// 紧急程度选择器
|
||||
const emergencyPickerVisible = ref(false)
|
||||
const emergencyColumns = computed(() => [
|
||||
EMERGENCY_OPTIONS.map(v => ({ value: v.value, label: v.label })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const requestDatePickerVisible = ref(false)
|
||||
const expectedDatePickerVisible = ref(false)
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计产品金额 */
|
||||
const totalProductPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalProductPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计税额 */
|
||||
const totalTaxPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.taxPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额(含税) */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 获取类型标签 */
|
||||
function getTypeLabel(type?: number) {
|
||||
return REQUISITION_TYPE_OPTIONS.find(o => o.value === type)?.label || '请选择'
|
||||
}
|
||||
|
||||
/** 获取优先级标签 */
|
||||
function getPriorityLabel(priority?: number) {
|
||||
return PRIORITY_OPTIONS.find(o => o.value === priority)?.label || '请选择'
|
||||
}
|
||||
|
||||
/** 获取紧急程度标签 */
|
||||
function getEmergencyLabel(emergency?: number) {
|
||||
return EMERGENCY_OPTIONS.find(o => o.value === emergency)?.label || '请选择'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/purchase-requisition/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseRequisition(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 类型确认 */
|
||||
function onTypeConfirm({ value }: any) {
|
||||
formData.value.type = value?.[0]
|
||||
typePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 优先级确认 */
|
||||
function onPriorityConfirm({ value }: any) {
|
||||
formData.value.priority = value?.[0]
|
||||
priorityPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 紧急程度确认 */
|
||||
function onEmergencyConfirm({ value }: any) {
|
||||
formData.value.emergencyDegree = value?.[0]
|
||||
emergencyPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 请购时间确认 */
|
||||
function onRequestDateConfirm({ value }: any) {
|
||||
formData.value.requestTime = value
|
||||
requestDatePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 期望到货确认 */
|
||||
function onExpectedDateConfirm({ value }: any) {
|
||||
formData.value.expectedTime = value
|
||||
expectedDatePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalProductPrice: 0,
|
||||
taxPercent: undefined,
|
||||
taxPrice: 0,
|
||||
totalPrice: 0,
|
||||
purpose: undefined,
|
||||
remark: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额(含税) */
|
||||
function calcItemTotal(item: PurchaseRequisitionItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
const taxPercent = Number(item.taxPercent) || 0
|
||||
// 产品金额 = 单价 × 数量
|
||||
const totalProductPrice = count * price
|
||||
// 税额 = 产品金额 × 税率 / 100
|
||||
const taxPrice = totalProductPrice * taxPercent / 100
|
||||
// 含税金额 = 产品金额 + 税额
|
||||
item.totalProductPrice = Math.round(totalProductPrice * 100) / 100
|
||||
item.taxPrice = Math.round(taxPrice * 100) / 100
|
||||
item.totalPrice = Math.round((totalProductPrice + taxPrice) * 100) / 100
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加请购产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalProductPrice = totalProductPrice.value
|
||||
formData.value.totalTaxPrice = totalTaxPrice.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updatePurchaseRequisition(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseRequisition(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
515
src/pages-erp/purchase-requisition/index.vue
Normal file
515
src/pages-erp/purchase-requisition/index.vue
Normal file
@@ -0,0 +1,515 @@
|
||||
<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="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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 w-1/2 h-4rpx 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="flex items-center gap-8rpx">
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-4rpx text-22rpx"
|
||||
:class="getTypeClass(item.type)"
|
||||
>
|
||||
{{ getTypeLabel(item.type) }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-4rpx text-22rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusLabel(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 优先级 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">优先级</text>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getPriorityClass(item.priority)"
|
||||
>
|
||||
{{ getPriorityLabel(item.priority) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 请购人 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">请购人</text>
|
||||
<text>{{ item.requesterNickname || '-' }}</text>
|
||||
</view>
|
||||
<!-- 请购部门 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">请购部门</text>
|
||||
<text>{{ item.requesterDeptName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 请购时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">请购时间</text>
|
||||
<text>{{ formatDate(item.requestTime) }}</text>
|
||||
</view>
|
||||
<!-- 期望到货 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">期望到货</text>
|
||||
<text>{{ formatDate(item.expectedTime) }}</text>
|
||||
</view>
|
||||
<!-- 紧急程度 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">紧急程度</text>
|
||||
<view
|
||||
class="rounded-8rpx px-12rpx py-2rpx text-22rpx"
|
||||
:class="getEmergencyClass(item.emergencyDegree)"
|
||||
>
|
||||
{{ getEmergencyLabel(item.emergencyDegree) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">总金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update']) && item.status === 1"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:update-status']) && item.status === 1"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审核
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:approve']) && item.status === 1"
|
||||
size="small" type="warning" plain @click="handleReject(item.id!)"
|
||||
>
|
||||
驳回
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:delete']) && item.status === 1"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-requisition:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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 typeOptions"
|
||||
:key="opt.value"
|
||||
class="yd-search-form-radio"
|
||||
:class="{ 'yd-search-form-radio--active': searchForm.type === opt.value }"
|
||||
@click="searchForm.type = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</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 { PurchaseRequisition } from '@/api/erp/purchase-requisition'
|
||||
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 {
|
||||
deletePurchaseRequisition,
|
||||
EMERGENCY_OPTIONS,
|
||||
getPurchaseRequisitionPage,
|
||||
PRIORITY_OPTIONS,
|
||||
REQUISITION_TYPE_OPTIONS,
|
||||
STATUS_OPTIONS,
|
||||
updatePurchaseRequisitionStatus,
|
||||
} from '@/api/erp/purchase-requisition'
|
||||
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<PurchaseRequisition[]>([])
|
||||
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,
|
||||
type: undefined as number | undefined,
|
||||
status: undefined as number | undefined,
|
||||
})
|
||||
|
||||
/** 状态标签 */
|
||||
const statusTabs = [
|
||||
{ value: undefined, label: '全部' },
|
||||
{ value: 1, label: '待审核' },
|
||||
{ value: 2, label: '已审核' },
|
||||
{ value: 5, label: '已采购' },
|
||||
]
|
||||
|
||||
/** 类型选项 */
|
||||
const typeOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
...REQUISITION_TYPE_OPTIONS,
|
||||
]
|
||||
|
||||
/** 状态选项 */
|
||||
const statusOptions = [
|
||||
{ value: undefined, label: '全部' },
|
||||
...STATUS_OPTIONS,
|
||||
]
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
|
||||
if (searchForm.type !== undefined) {
|
||||
const typeLabel = REQUISITION_TYPE_OPTIONS.find(o => o.value === searchForm.type)?.label
|
||||
if (typeLabel) conditions.push(`类型:${typeLabel}`)
|
||||
}
|
||||
if (searchForm.status !== undefined) {
|
||||
const statusLabel = STATUS_OPTIONS.find(o => o.value === searchForm.status)?.label
|
||||
if (statusLabel) conditions.push(`状态:${statusLabel}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索请购单'
|
||||
})
|
||||
|
||||
/** 获取类型标签 */
|
||||
function getTypeLabel(type?: number) {
|
||||
return REQUISITION_TYPE_OPTIONS.find(o => o.value === type)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取类型样式 */
|
||||
function getTypeClass(type?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
2: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
3: 'bg-[#f9f0ff] text-[#722ed1]',
|
||||
}
|
||||
return map[type || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取状态标签 */
|
||||
function getStatusLabel(status?: number) {
|
||||
return STATUS_OPTIONS.find(o => o.value === status)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
2: 'bg-[#f6ffed] text-[#52c41a]',
|
||||
3: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
4: 'bg-[#f5f5f5] text-[#999]',
|
||||
5: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
}
|
||||
return map[status || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取优先级标签 */
|
||||
function getPriorityLabel(priority?: number) {
|
||||
return PRIORITY_OPTIONS.find(o => o.value === priority)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取优先级样式 */
|
||||
function getPriorityClass(priority?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[priority || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 获取紧急程度标签 */
|
||||
function getEmergencyLabel(emergency?: number) {
|
||||
return EMERGENCY_OPTIONS.find(o => o.value === emergency)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取紧急程度样式 */
|
||||
function getEmergencyClass(emergency?: number) {
|
||||
const map: Record<number, string> = {
|
||||
1: 'bg-[#f5f5f5] text-[#999]',
|
||||
2: 'bg-[#e6f7ff] text-[#1890ff]',
|
||||
3: 'bg-[#fff7e6] text-[#fa8c16]',
|
||||
4: 'bg-[#fff1f0] text-[#f5222d]',
|
||||
}
|
||||
return map[emergency || 1] || 'bg-[#f5f5f5] text-[#666]'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
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
|
||||
if (searchForm.type !== undefined) params.type = searchForm.type
|
||||
const data = await getPurchaseRequisitionPage(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.type = 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 handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/purchase-requisition/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseRequisition) {
|
||||
uni.navigateTo({ url: `/pages-erp/purchase-requisition/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: PurchaseRequisition) {
|
||||
uni.navigateTo({ url: `/pages-erp/purchase-requisition/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审核 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审核通过该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(id, 2)
|
||||
toast.success('审核成功')
|
||||
refreshList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 驳回 */
|
||||
function handleReject(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要驳回该请购单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseRequisitionStatus(id, 3)
|
||||
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 deletePurchaseRequisition(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>
|
||||
100
src/pages-erp/purchase-return/components/search-form.vue
Normal file
100
src/pages-erp/purchase-return/components/search-form.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<!-- 搜索框入口 -->
|
||||
<view @click="visible = true">
|
||||
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||
</view>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<wd-popup v-model="visible" position="top" @close="visible = 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="formData.no"
|
||||
placeholder="请输入退货单编号"
|
||||
clearable
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">
|
||||
审核状态
|
||||
</view>
|
||||
<wd-radio-group v-model="formData.status" shape="button">
|
||||
<wd-radio :value="-1">
|
||||
全部
|
||||
</wd-radio>
|
||||
<wd-radio :value="10">
|
||||
待审核
|
||||
</wd-radio>
|
||||
<wd-radio :value="20">
|
||||
已审核
|
||||
</wd-radio>
|
||||
</wd-radio-group>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { getNavbarHeight } from '@/utils'
|
||||
|
||||
const emit = defineEmits<{
|
||||
search: [data: Record<string, any>]
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const formData = reactive({
|
||||
no: undefined as string | undefined,
|
||||
status: -1,
|
||||
})
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
10: '待审核',
|
||||
20: '已审核',
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder 拼接 */
|
||||
const placeholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (formData.no) {
|
||||
conditions.push(`编号:${formData.no}`)
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索采购退货单'
|
||||
})
|
||||
|
||||
/** 搜索 */
|
||||
function handleSearch() {
|
||||
visible.value = false
|
||||
const params: Record<string, any> = {}
|
||||
if (formData.no) {
|
||||
params.no = formData.no
|
||||
}
|
||||
if (formData.status !== -1) {
|
||||
params.status = formData.status
|
||||
}
|
||||
emit('search', params)
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
formData.no = undefined
|
||||
formData.status = -1
|
||||
visible.value = false
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
309
src/pages-erp/purchase-return/detail/index.vue
Normal file
309
src/pages-erp/purchase-return/detail/index.vue
Normal file
@@ -0,0 +1,309 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购退货详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view v-if="formData">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="退货单编号" :value="formData.no" />
|
||||
<wd-cell title="审核状态">
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(formData.status)"
|
||||
>
|
||||
{{ getStatusText(formData.status) }}
|
||||
</view>
|
||||
</wd-cell>
|
||||
<wd-cell title="供应商" :value="formData.supplierName || '-'" />
|
||||
<wd-cell title="退货时间" :value="formatDateTime(formData.returnTime)" />
|
||||
<wd-cell title="关联订单" :value="formData.orderNo || '-'" />
|
||||
<wd-cell title="创建人" :value="formData.creatorName || '-'" />
|
||||
<wd-cell title="创建时间" :value="formatDateTime(formData.createTime)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="String(formData.totalCount || 0)" />
|
||||
<wd-cell title="合计产品价格" :value="`¥${formData.totalProductPrice || 0}`" />
|
||||
<wd-cell title="合计税额" :value="`¥${formData.totalTaxPrice || 0}`" />
|
||||
<wd-cell title="优惠率" :value="`${formData.discountPercent || 0}%`" />
|
||||
<wd-cell title="优惠金额" :value="`¥${formData.discountPrice || 0}`" />
|
||||
<wd-cell title="其他费用" :value="`¥${formData.otherPrice || 0}`" />
|
||||
<wd-cell title="应退金额">
|
||||
<text class="text-[#e6a23c] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="已退金额">
|
||||
<text class="text-[#52c41a] font-semibold">¥{{ formData.refundPrice || 0 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="未退金额">
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(formData.totalPrice || 0) - (formData.refundPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (formData.totalPrice || 0) - (formData.refundPrice || 0) }}
|
||||
</text>
|
||||
</wd-cell>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 退货明细 -->
|
||||
<view class="mx-24rpx mt-24rpx">
|
||||
<view class="mb-16rpx text-32rpx text-[#333] font-semibold">
|
||||
退货明细({{ formData.items?.length || 0 }}项)
|
||||
</view>
|
||||
<view v-if="formData.items && formData.items.length > 0">
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="item.id || index"
|
||||
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<!-- 产品头部 -->
|
||||
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-16rpx">
|
||||
<view class="flex items-center">
|
||||
<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>
|
||||
</view>
|
||||
<text v-if="item.warehouseName" class="text-24rpx text-[#1890ff]">{{ item.warehouseName }}</text>
|
||||
</view>
|
||||
<view class="p-24rpx">
|
||||
<!-- 产品规格 -->
|
||||
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||
<text>{{ item.productSpec }}</text>
|
||||
</view>
|
||||
<!-- 单价 / 数量 / 单位 -->
|
||||
<view class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单价:</text>
|
||||
<text class="text-[#f5222d]">¥{{ item.productPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">数量:</text>
|
||||
<text class="font-semibold">{{ item.count || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">单位:</text>
|
||||
<text>{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 税率 / 税额 -->
|
||||
<view v-if="item.taxPercent" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||
<view class="mr-24rpx flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税率:</text>
|
||||
<text>{{ item.taxPercent }}%</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">税额:</text>
|
||||
<text>¥{{ item.taxPrice || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 金额 / 库存 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">金额:</text>
|
||||
<text class="text-[#e6a23c]">¥{{ item.totalPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<text class="mr-8rpx text-[#999]">库存:</text>
|
||||
<text>{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 备注 -->
|
||||
<view v-if="item.remark" class="text-24rpx text-[#999]">
|
||||
备注:{{ item.remark }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="py-60rpx text-center text-28rpx text-[#999]">
|
||||
暂无退货明细
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 备注 -->
|
||||
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||
<wd-cell :value="formData.remark" />
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<view class="yd-detail-footer-actions">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update']) && formData?.status === 10"
|
||||
class="flex-1" type="warning" @click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && formData?.status === 10"
|
||||
class="flex-1" type="success" @click="handleAudit"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && formData?.status === 20"
|
||||
class="flex-1" type="warning" @click="handleReverseAudit"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:delete'])"
|
||||
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseReturn } from '@/api/erp/purchase-return'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseReturn, getPurchaseReturn, updatePurchaseReturnStatus } from '@/api/erp/purchase-return'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import { formatDateTime } from '@/utils/date'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const formData = ref<PurchaseReturn>()
|
||||
const deleting = ref(false)
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
if (status === 10) return '待审核'
|
||||
if (status === 20) return '已审核'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20) return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus('/pages-erp/purchase-return/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getPurchaseReturn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑操作 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-return/form/index?id=${props.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批操作 */
|
||||
function handleAudit() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseReturnStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批操作 */
|
||||
function handleReverseAudit() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updatePurchaseReturnStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除操作 */
|
||||
function handleDelete() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
deleting.value = true
|
||||
try {
|
||||
await deletePurchaseReturn([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
609
src/pages-erp/purchase-return/form/index.vue
Normal file
609
src/pages-erp/purchase-return/form/index.vue
Normal file
@@ -0,0 +1,609 @@
|
||||
<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
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="退货时间" title-width="180rpx" prop="returnTime" center>
|
||||
<wd-datetime-picker
|
||||
v-model="formData.returnTime"
|
||||
type="date"
|
||||
label=""
|
||||
placeholder="请选择退货时间"
|
||||
/>
|
||||
</wd-cell>
|
||||
<wd-cell title="关联订单" title-width="180rpx" center is-link @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>{{ getSupplierName() || '-' }}</text>
|
||||
</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 }}</text>
|
||||
</wd-cell>
|
||||
<wd-cell title="结算账户" title-width="180rpx" prop="accountId" center>
|
||||
<wd-picker
|
||||
v-model="formData.accountId"
|
||||
:columns="accountColumns"
|
||||
label=""
|
||||
placeholder="请选择结算账户"
|
||||
@confirm="onAccountConfirm"
|
||||
/>
|
||||
</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>
|
||||
<wd-button
|
||||
v-if="formData.items && formData.items.length > 1"
|
||||
size="small" type="error" plain @click="handleRemoveItem(index)"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</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) => onWarehouseConfirm(e, index)"
|
||||
/>
|
||||
</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 class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">库存</text>
|
||||
<text class="text-[#333]">{{ item.stockCount || 0 }}</text>
|
||||
</view>
|
||||
<view v-if="item.inCount != null" class="mb-8rpx flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">已入库</text>
|
||||
<text class="text-[#333]">{{ item.inCount }}</text>
|
||||
</view>
|
||||
<view v-if="item.returnCount != null" class="flex justify-between text-24rpx">
|
||||
<text class="text-[#999]">已退货</text>
|
||||
<text class="text-[#333]">{{ item.returnCount }}</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.supplierName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-around mt-12rpx pt-12rpx border-t border-[#f0f0f0]">
|
||||
<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-[#52c41a] font-semibold">{{ item.inCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999]">已入库</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-28rpx text-[#f5222d] font-semibold">{{ item.returnCount || 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 { PurchaseReturn, PurchaseReturnItem } from '@/api/erp/purchase-return'
|
||||
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createPurchaseReturn, getPurchaseReturn, updatePurchaseReturn } from '@/api/erp/purchase-return'
|
||||
import { getPurchaseOrder, getPurchaseOrderPage } from '@/api/erp/purchase-order'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
/** 账户简单信息 */
|
||||
interface AccountSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
}
|
||||
|
||||
/** 仓库简单信息 */
|
||||
interface WarehouseSimple {
|
||||
id: number
|
||||
name: string
|
||||
defaultStatus?: boolean
|
||||
}
|
||||
|
||||
/** 供应商简单信息 */
|
||||
interface SupplierSimple {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
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<PurchaseReturn>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
supplierId: undefined,
|
||||
accountId: undefined,
|
||||
returnTime: undefined,
|
||||
orderId: undefined,
|
||||
orderNo: undefined,
|
||||
discountPercent: 0,
|
||||
discountPrice: 0,
|
||||
otherPrice: 0,
|
||||
totalPrice: 0,
|
||||
remark: '',
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
returnTime: [{ required: true, message: '退货时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
const supplierList = ref<SupplierSimple[]>([])
|
||||
const accountList = ref<AccountSimple[]>([])
|
||||
const warehouseList = ref<WarehouseSimple[]>([])
|
||||
const defaultWarehouse = ref<WarehouseSimple>()
|
||||
|
||||
// 采购订单选择相关(可退货订单)
|
||||
const orderSelectVisible = ref(false)
|
||||
const orderList = ref<PurchaseOrder[]>([])
|
||||
const orderLoadMoreState = ref<LoadMoreState>('loading')
|
||||
const orderQueryParams = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
no: undefined as string | undefined,
|
||||
returnEnable: true, // 可退货订单
|
||||
})
|
||||
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 })),
|
||||
])
|
||||
|
||||
/** 获取供应商名称 */
|
||||
function getSupplierName() {
|
||||
if (!formData.value.supplierId) return ''
|
||||
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
|
||||
return supplier?.name || formData.value.supplierName || ''
|
||||
}
|
||||
|
||||
/** 账户选择回调 */
|
||||
function onAccountConfirm({ value }: any) {
|
||||
formData.value.accountId = value?.[0]
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any, index: number) {
|
||||
if (formData.value.items && formData.value.items[index]) {
|
||||
formData.value.items[index].warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === value?.[0])
|
||||
if (warehouse) {
|
||||
formData.value.items[index].warehouseName = warehouse.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算行项金额 */
|
||||
function calcTotalPrice(item: PurchaseReturnItem) {
|
||||
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 [suppliers, accounts, warehouses] = await Promise.all([
|
||||
http.get<SupplierSimple[]>('/erp/supplier/simple-list'),
|
||||
http.get<AccountSimple[]>('/erp/account/simple-list'),
|
||||
http.get<WarehouseSimple[]>('/erp/warehouse/simple-list'),
|
||||
])
|
||||
supplierList.value = suppliers || []
|
||||
accountList.value = accounts || []
|
||||
warehouseList.value = warehouses || []
|
||||
// 设置默认账户
|
||||
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/purchase-return/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 data = await getPurchaseOrderPage(orderQueryParams.value)
|
||||
if (orderQueryParams.value.pageNo === 1) {
|
||||
orderList.value = data.list
|
||||
} else {
|
||||
orderList.value = [...orderList.value, ...data.list]
|
||||
}
|
||||
orderTotal.value = data.total
|
||||
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: PurchaseOrder) {
|
||||
selectedOrderId.value = item.id
|
||||
}
|
||||
|
||||
/** 确认选择订单 */
|
||||
async function confirmSelectOrder() {
|
||||
if (!selectedOrderId.value) return
|
||||
try {
|
||||
toast.loading('加载订单详情...')
|
||||
const orderDetail = await getPurchaseOrder(selectedOrderId.value)
|
||||
// 设置订单信息
|
||||
formData.value.orderId = orderDetail.id
|
||||
formData.value.orderNo = orderDetail.no
|
||||
formData.value.supplierId = orderDetail.supplierId
|
||||
formData.value.supplierName = orderDetail.supplierName
|
||||
formData.value.accountId = orderDetail.accountId
|
||||
formData.value.discountPercent = orderDetail.discountPercent
|
||||
formData.value.remark = orderDetail.remark
|
||||
// 设置退货明细(可退货数量 = 已入库 - 已退货)
|
||||
if (orderDetail.items) {
|
||||
formData.value.items = orderDetail.items
|
||||
.filter(item => ((item.inCount || 0) - (item.returnCount || 0)) > 0)
|
||||
.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productUnitId: item.productUnitId,
|
||||
productUnitName: item.productUnitName,
|
||||
productPrice: item.productPrice,
|
||||
productSpec: item.productSpec,
|
||||
productBarCode: item.productBarCode,
|
||||
count: (item.inCount || 0) - (item.returnCount || 0),
|
||||
inCount: item.inCount,
|
||||
returnCount: item.returnCount,
|
||||
taxPercent: item.taxPercent,
|
||||
warehouseId: defaultWarehouse.value?.id,
|
||||
warehouseName: defaultWarehouse.value?.name,
|
||||
stockCount: item.stockCount,
|
||||
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 getPurchaseReturn(props.id)
|
||||
} 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.warehouseId) {
|
||||
toast.warning(`第 ${i + 1} 项产品请选择仓库`)
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.warning(`第 ${i + 1} 项产品数量不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
if (props.id) {
|
||||
await updatePurchaseReturn(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createPurchaseReturn(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadDropdownData()
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
366
src/pages-erp/purchase-return/index.vue
Normal file
366
src/pages-erp/purchase-return/index.vue
Normal file
@@ -0,0 +1,366 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="采购退货"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 搜索组件 -->
|
||||
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||
|
||||
<!-- 状态快速筛选 -->
|
||||
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
:class="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||
@click="handleQuickFilter(tab.value)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<view
|
||||
v-if="activeStatus === tab.value"
|
||||
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx 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="handleCardClick(item)"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:单号 + 状态 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.no }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusText(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 供应商 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">供应商</text>
|
||||
<text>{{ item.supplierName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 退货时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">退货时间</text>
|
||||
<text>{{ formatDate(item.returnTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">应退</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-30rpx text-[#52c41a] font-semibold">¥{{ item.refundPrice || 0 }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">已退</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view
|
||||
class="text-30rpx font-semibold"
|
||||
:class="(item.totalPrice || 0) - (item.refundPrice || 0) > 0 ? 'text-[#f5222d]' : 'text-[#999]'"
|
||||
>
|
||||
¥{{ (item.totalPrice || 0) - (item.refundPrice || 0) }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">未退</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:query'])"
|
||||
size="small" plain @click="handleDetail(item)"
|
||||
>
|
||||
详情
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
修改
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleAudit(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseAudit(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:delete'])"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:purchase-return:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { PurchaseReturn } from '@/api/erp/purchase-return'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deletePurchaseReturn, getPurchaseReturnPage, updatePurchaseReturnStatus } from '@/api/erp/purchase-return'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import SearchForm from './components/search-form.vue'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const total = ref(0)
|
||||
const list = ref<PurchaseReturn[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const activeStatus = ref<number | undefined>(undefined)
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
const statusTabs = [
|
||||
{ label: '全部', value: undefined },
|
||||
{ label: '待审核', value: 10 },
|
||||
{ label: '已审核', value: 20 },
|
||||
]
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return '-'
|
||||
return new Date(date).toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
/** 获取状态文本 */
|
||||
function getStatusText(status?: number) {
|
||||
if (status === 10) return '待审核'
|
||||
if (status === 20) return '已审核'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
/** 获取状态样式 */
|
||||
function getStatusClass(status?: number) {
|
||||
if (status === 10) return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||
if (status === 20) return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
return 'bg-[#f5f5f5] text-[#999]'
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询采购退货列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params = { ...queryParams.value }
|
||||
const data = await getPurchaseReturnPage(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 handleQuickFilter(status?: number) {
|
||||
activeStatus.value = status
|
||||
queryParams.value.status = status
|
||||
queryParams.value.pageNo = 1
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery(data?: Record<string, any>) {
|
||||
queryParams.value = {
|
||||
...data,
|
||||
status: activeStatus.value,
|
||||
pageNo: 1,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function handleReset() {
|
||||
activeStatus.value = undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') {
|
||||
return
|
||||
}
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 卡片点击 — 已审核打开详情,待审核打开编辑 */
|
||||
function handleCardClick(item: PurchaseReturn) {
|
||||
if (item.status === 20) {
|
||||
handleDetail(item)
|
||||
} else if (item.status === 10) {
|
||||
handleEdit(item)
|
||||
}
|
||||
}
|
||||
|
||||
/** 新增采购退货 */
|
||||
function handleAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages-erp/purchase-return/form/index',
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(item: PurchaseReturn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-return/detail/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: PurchaseReturn) {
|
||||
uni.navigateTo({
|
||||
url: `/pages-erp/purchase-return/form/index?id=${item.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleAudit(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseReturnStatus(id, 20)
|
||||
toast.success('审批成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseAudit(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定反审批该退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updatePurchaseReturnStatus(id, 10)
|
||||
toast.success('反审批成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该采购退货单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deletePurchaseReturn([id])
|
||||
toast.success('删除成功')
|
||||
list.value = []
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
554
src/pages-erp/sale-out/detail/index.vue
Normal file
554
src/pages-erp/sale-out/detail/index.vue
Normal 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>
|
||||
707
src/pages-erp/sale-out/form/index.vue
Normal file
707
src/pages-erp/sale-out/form/index.vue
Normal 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>
|
||||
408
src/pages-erp/sale-out/index.vue
Normal file
408
src/pages-erp/sale-out/index.vue
Normal 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>
|
||||
136
src/pages-erp/sale-out/scan-out/components/recent-scan-list.vue
Normal file
136
src/pages-erp/sale-out/scan-out/components/recent-scan-list.vue
Normal 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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
887
src/pages-erp/sale-out/scan-out/index.vue
Normal file
887
src/pages-erp/sale-out/scan-out/index.vue
Normal 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>
|
||||
238
src/pages-erp/stock-check/detail/index.vue
Normal file
238
src/pages-erp/stock-check/detail/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="盘点单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="盘点单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="盘点时间" :value="formatDate(detail.checkTime)" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="盘点数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="盘点金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 盘点产品清单 -->
|
||||
<wd-cell-group title="盘点产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">账面数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.stockCount) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">实际数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.actualCount) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">盈亏数量</text>
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(item.count || 0) >= 0 ? 'text-[#52c41a]' : 'text-[#f5222d]'"
|
||||
>
|
||||
{{ (item.count || 0) >= 0 ? '+' : '' }}{{ formatCount(item.count) }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockCheck } from '@/api/erp/stock-check'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockCheck, getStockCheck, updateStockCheckStatus } from '@/api/erp/stock-check'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockCheck>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-check/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockCheck(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-check/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockCheckStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockCheckStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockCheck([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
397
src/pages-erp/stock-check/form/index.vue
Normal file
397
src/pages-erp/stock-check/form/index.vue
Normal file
@@ -0,0 +1,397 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="盘点单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="盘点时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.checkTime ? formatDate(formData.checkTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<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>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.stockCount"
|
||||
label="账面数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入账面数量"
|
||||
@change="calcItemDiff(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.actualCount"
|
||||
label="实际数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入实际数量"
|
||||
@change="calcItemDiff(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">盈亏数量</text>
|
||||
<text
|
||||
class="font-semibold"
|
||||
:class="(item.count || 0) >= 0 ? 'text-[#52c41a]' : 'text-[#f5222d]'"
|
||||
>
|
||||
{{ (item.count || 0) >= 0 ? '+' : '' }}{{ formatCount(item.count) }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="盘点数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="盘点金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.checkTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockCheck, StockCheckItem } from '@/api/erp/stock-check'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockCheck, getStockCheck, updateStockCheck } from '@/api/erp/stock-check'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<StockCheck>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
checkTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
checkTime: [{ required: true, message: '盘点时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + Math.abs(Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + Math.abs(Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-check/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockCheck(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.checkTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
stockCount: undefined,
|
||||
actualCount: undefined,
|
||||
count: 0,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算盈亏数量 */
|
||||
function calcItemDiff(item: StockCheckItem) {
|
||||
const stockCount = Number(item.stockCount) || 0
|
||||
const actualCount = Number(item.actualCount) || 0
|
||||
item.count = actualCount - stockCount
|
||||
calcItemTotal(item)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockCheckItem) {
|
||||
const count = Math.abs(Number(item.count) || 0)
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加盘点产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockCheck(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockCheck(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
383
src/pages-erp/stock-check/index.vue
Normal file
383
src/pages-erp/stock-check/index.vue
Normal file
@@ -0,0 +1,383 @@
|
||||
<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="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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 w-1/2 h-4rpx 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 class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 盘点时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">盘点时间</text>
|
||||
<text>{{ formatDate(item.checkTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">盘点数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">盘点金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-check:delete']) && item.status === 10"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-check:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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 { StockCheck } from '@/api/erp/stock-check'
|
||||
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 { deleteStockCheck, getStockCheckPage, updateStockCheckStatus } from '@/api/erp/stock-check'
|
||||
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<StockCheck[]>([])
|
||||
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 getStockCheckPage(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 handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-check/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockCheck) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-check/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockCheck) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-check/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该盘点单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockCheckStatus(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 updateStockCheckStatus(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 deleteStockCheck([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>
|
||||
226
src/pages-erp/stock-gain/detail/index.vue
Normal file
226
src/pages-erp/stock-gain/detail/index.vue
Normal file
@@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="报溢单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报溢单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="报溢时间" :value="formatDate(detail.gainTime)" />
|
||||
<wd-cell title="报溢原因" :value="detail.reason || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 报溢产品清单 -->
|
||||
<wd-cell-group title="报溢产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#52c41a] font-semibold">+{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockGain } from '@/api/erp/stock-gain'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockGain, getStockGain, updateStockGainStatus } from '@/api/erp/stock-gain'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockGain>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-gain/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockGain(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-gain/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockGainStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockGainStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockGain([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
380
src/pages-erp/stock-gain/form/index.vue
Normal file
380
src/pages-erp/stock-gain/form/index.vue
Normal file
@@ -0,0 +1,380 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报溢单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="报溢时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.gainTime ? formatDate(formData.gainTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.reason"
|
||||
label="报溢原因"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入报溢原因"
|
||||
clearable
|
||||
/>
|
||||
<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>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.gainTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockGain, StockGainItem } from '@/api/erp/stock-gain'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockGain, getStockGain, updateStockGain } from '@/api/erp/stock-gain'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<StockGain>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
gainTime: undefined,
|
||||
reason: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
gainTime: [{ required: true, message: '报溢时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-gain/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockGain(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.gainTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockGainItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加报溢产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockGain(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockGain(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
388
src/pages-erp/stock-gain/index.vue
Normal file
388
src/pages-erp/stock-gain/index.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<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="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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 w-1/2 h-4rpx 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 class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 报溢时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报溢时间</text>
|
||||
<text>{{ formatDate(item.gainTime) }}</text>
|
||||
</view>
|
||||
<!-- 报溢原因 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报溢原因</text>
|
||||
<text>{{ item.reason || '-' }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#52c41a] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:delete']) && item.status === 10"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-gain:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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 { StockGain } from '@/api/erp/stock-gain'
|
||||
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 { deleteStockGain, getStockGainPage, updateStockGainStatus } from '@/api/erp/stock-gain'
|
||||
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<StockGain[]>([])
|
||||
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 getStockGainPage(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 handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-gain/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockGain) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-gain/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockGain) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-gain/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报溢单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockGainStatus(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 updateStockGainStatus(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 deleteStockGain([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>
|
||||
238
src/pages-erp/stock-in/detail/index.vue
Normal file
238
src/pages-erp/stock-in/detail/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="入库单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="入库单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="入库时间" :value="formatDate(detail.inTime)" />
|
||||
<wd-cell title="供应商" :value="detail.supplierName || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 入库产品清单 -->
|
||||
<wd-cell-group title="入库产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#666]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单价</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.productPrice) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.remark" class="mt-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">备注</text>
|
||||
<text class="text-[#666]">{{ item.remark }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update']) && detail.status !== 20"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:delete']) && detail.status !== 20"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockIn } from '@/api/erp/stock-in'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockIn, getStockIn, updateStockInStatus } from '@/api/erp/stock-in'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockIn>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-in/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockIn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-in/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockInStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockInStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockIn([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
419
src/pages-erp/stock-in/form/index.vue
Normal file
419
src/pages-erp/stock-in/form/index.vue
Normal file
@@ -0,0 +1,419 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="入库单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="入库时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.inTime ? formatDate(formData.inTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="供应商"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getSupplierName()"
|
||||
@click="supplierPickerVisible = true"
|
||||
/>
|
||||
<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>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view class="mt-12rpx">
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
label="备注"
|
||||
label-width="120rpx"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.inTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 供应商选择器 -->
|
||||
<wd-picker
|
||||
v-model="supplierPickerVisible"
|
||||
:columns="supplierColumns"
|
||||
@confirm="onSupplierConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockIn, StockInItem } from '@/api/erp/stock-in'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockIn, getStockIn, updateStockIn } from '@/api/erp/stock-in'
|
||||
import { getSupplierSimpleList } from '@/api/erp/supplier'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<StockIn>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
supplierId: undefined,
|
||||
inTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
inTime: [{ required: true, message: '入库时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 供应商列表
|
||||
const supplierList = ref<{ id: number, name: string }[]>([])
|
||||
const supplierPickerVisible = ref(false)
|
||||
const supplierColumns = computed(() => [
|
||||
supplierList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表(简化,实际可能需要从产品API获取)
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 获取供应商名称 */
|
||||
function getSupplierName() {
|
||||
if (!formData.value.supplierId) return '请选择'
|
||||
const supplier = supplierList.value.find(s => s.id === formData.value.supplierId)
|
||||
return supplier?.name || '请选择'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-in/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockIn(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.inTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 供应商确认 */
|
||||
function onSupplierConfirm({ value }: any) {
|
||||
formData.value.supplierId = value?.[0]
|
||||
supplierPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
remark: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockInItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加入库产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockIn(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockIn(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载供应商列表
|
||||
supplierList.value = await getSupplierSimpleList()
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
388
src/pages-erp/stock-in/index.vue
Normal file
388
src/pages-erp/stock-in/index.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<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="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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 w-1/2 h-4rpx 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.supplierName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 入库时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">入库时间</text>
|
||||
<text>{{ formatDate(item.inTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update']) && item.status !== 20"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-in: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-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-in:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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 { StockIn } from '@/api/erp/stock-in'
|
||||
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 { deleteStockIn, getStockInPage, updateStockInStatus } from '@/api/erp/stock-in'
|
||||
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<StockIn[]>([])
|
||||
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 getStockInPage(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 handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-in/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockIn) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-in/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockIn) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-in/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该入库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockInStatus(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 updateStockInStatus(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 deleteStockIn([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>
|
||||
435
src/pages-erp/stock-in/scan/index.vue
Normal file
435
src/pages-erp/stock-in/scan/index.vue
Normal 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>
|
||||
226
src/pages-erp/stock-loss/detail/index.vue
Normal file
226
src/pages-erp/stock-loss/detail/index.vue
Normal file
@@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="报损单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报损单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="报损时间" :value="formatDate(detail.lossTime)" />
|
||||
<wd-cell title="报损原因" :value="detail.reason || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 报损产品清单 -->
|
||||
<wd-cell-group title="报损产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#f5222d] font-semibold">-{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockLoss } from '@/api/erp/stock-loss'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockLoss, getStockLoss, updateStockLossStatus } from '@/api/erp/stock-loss'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockLoss>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-loss/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockLoss(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-loss/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockLossStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockLossStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockLoss([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
380
src/pages-erp/stock-loss/form/index.vue
Normal file
380
src/pages-erp/stock-loss/form/index.vue
Normal file
@@ -0,0 +1,380 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="报损单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="报损时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.lossTime ? formatDate(formData.lossTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-input
|
||||
v-model="formData.reason"
|
||||
label="报损原因"
|
||||
label-width="180rpx"
|
||||
placeholder="请输入报损原因"
|
||||
clearable
|
||||
/>
|
||||
<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>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.lossTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockLoss, StockLossItem } from '@/api/erp/stock-loss'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockLoss, getStockLoss, updateStockLoss } from '@/api/erp/stock-loss'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<StockLoss>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
lossTime: undefined,
|
||||
reason: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
lossTime: [{ required: true, message: '报损时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-loss/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockLoss(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.lossTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockLossItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加报损产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockLoss(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockLoss(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
388
src/pages-erp/stock-loss/index.vue
Normal file
388
src/pages-erp/stock-loss/index.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<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="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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 w-1/2 h-4rpx 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 class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 报损时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报损时间</text>
|
||||
<text>{{ formatDate(item.lossTime) }}</text>
|
||||
</view>
|
||||
<!-- 报损原因 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">报损原因</text>
|
||||
<text>{{ item.reason || '-' }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#f5222d] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:delete']) && item.status === 10"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-loss:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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 { StockLoss } from '@/api/erp/stock-loss'
|
||||
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 { deleteStockLoss, getStockLossPage, updateStockLossStatus } from '@/api/erp/stock-loss'
|
||||
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<StockLoss[]>([])
|
||||
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 getStockLossPage(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 handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-loss/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockLoss) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-loss/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockLoss) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-loss/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该报损单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockLossStatus(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 updateStockLossStatus(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 deleteStockLoss([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>
|
||||
229
src/pages-erp/stock-move/detail/index.vue
Normal file
229
src/pages-erp/stock-move/detail/index.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="调拨单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="调拨单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="调拨时间" :value="formatDate(detail.moveTime)" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="调拨数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="调拨金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 调拨产品清单 -->
|
||||
<wd-cell-group title="调拨产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">调出仓库</text>
|
||||
<text class="text-[#f5222d]">{{ item.fromWarehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">调入仓库</text>
|
||||
<text class="text-[#52c41a]">{{ item.toWarehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update']) && detail.status === 10"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:delete']) && detail.status === 10"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockMove } from '@/api/erp/stock-move'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockMove, getStockMove, updateStockMoveStatus } from '@/api/erp/stock-move'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockMove>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-move/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockMove(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-move/form/index?id=${props.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockMoveStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockMoveStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteStockMove([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
416
src/pages-erp/stock-move/form/index.vue
Normal file
416
src/pages-erp/stock-move/form/index.vue
Normal file
@@ -0,0 +1,416 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="调拨单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="调拨时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.moveTime ? formatDate(formData.moveTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<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>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="调出仓库"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.fromWarehouseName || '请选择'"
|
||||
@click="openFromWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="调入仓库"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.toWarehouseName || '请选择'"
|
||||
@click="openToWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="140rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="140rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="140rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="调拨数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="调拨金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.moveTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 调出仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="fromWarehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onFromWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 调入仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="toWarehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onToWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockMove, StockMoveItem } from '@/api/erp/stock-move'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockMove, getStockMove, updateStockMove } from '@/api/erp/stock-move'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<StockMove>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
moveTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
moveTime: [{ required: true, message: '调拨时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const fromWarehousePickerVisible = ref(false)
|
||||
const toWarehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-move/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockMove(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.moveTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开调出仓库选择器 */
|
||||
function openFromWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
fromWarehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 调出仓库确认 */
|
||||
function onFromWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.fromWarehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.fromWarehouseId)
|
||||
item.fromWarehouseName = warehouse?.name
|
||||
}
|
||||
fromWarehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开调入仓库选择器 */
|
||||
function openToWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
toWarehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 调入仓库确认 */
|
||||
function onToWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.toWarehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.toWarehouseId)
|
||||
item.toWarehouseName = warehouse?.name
|
||||
}
|
||||
toWarehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
fromWarehouseId: undefined,
|
||||
fromWarehouseName: undefined,
|
||||
toWarehouseId: undefined,
|
||||
toWarehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockMoveItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加调拨产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.fromWarehouseId) {
|
||||
toast.error('请选择调出仓库')
|
||||
return
|
||||
}
|
||||
if (!item.toWarehouseId) {
|
||||
toast.error('请选择调入仓库')
|
||||
return
|
||||
}
|
||||
if (item.fromWarehouseId === item.toWarehouseId) {
|
||||
toast.error('调出仓库和调入仓库不能相同')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockMove(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockMove(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
383
src/pages-erp/stock-move/index.vue
Normal file
383
src/pages-erp/stock-move/index.vue
Normal file
@@ -0,0 +1,383 @@
|
||||
<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="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||
<view
|
||||
v-for="tab in statusTabs"
|
||||
:key="tab.value"
|
||||
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||
: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 w-1/2 h-4rpx 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 class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
|
||||
</view>
|
||||
<!-- 调拨时间 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">调拨时间</text>
|
||||
<text>{{ formatDate(item.moveTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量金额区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#333] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">调拨数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatPrice(item.totalPrice) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">调拨金额</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update']) && item.status === 10"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-move:delete']) && item.status === 10"
|
||||
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-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-move:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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 { StockMove } from '@/api/erp/stock-move'
|
||||
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 { deleteStockMove, getStockMovePage, updateStockMoveStatus } from '@/api/erp/stock-move'
|
||||
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<StockMove[]>([])
|
||||
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 getStockMovePage(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 handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-move/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockMove) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-move/form/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(item: StockMove) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-move/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该调拨单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await updateStockMoveStatus(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 updateStockMoveStatus(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 deleteStockMove([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>
|
||||
264
src/pages-erp/stock-out/detail/index.vue
Normal file
264
src/pages-erp/stock-out/detail/index.vue
Normal file
@@ -0,0 +1,264 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
title="出库单详情"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="pb-180rpx">
|
||||
<!-- 基本信息 -->
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="出库单号" :value="detail.no || '-'" />
|
||||
<wd-cell title="扫码识别值" :value="detail.no || '-'" />
|
||||
<wd-cell title="出库时间" :value="formatDate(detail.outTime)" />
|
||||
<wd-cell title="客户" :value="detail.customerName || '-'" />
|
||||
<wd-cell title="审核状态">
|
||||
<template #value>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="detail.status === 20 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff7e6] text-[#fa8c16]'"
|
||||
>
|
||||
{{ detail.status === 20 ? '已审核' : '未审核' }}
|
||||
</view>
|
||||
</template>
|
||||
</wd-cell>
|
||||
<wd-cell title="备注" :value="detail.remark || '-'" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 金额信息 -->
|
||||
<wd-cell-group title="金额信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(detail.totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(detail.totalPrice)" />
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 出库产品清单 -->
|
||||
<wd-cell-group title="出库产品清单" border>
|
||||
<view v-if="!detail.items || detail.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品数据
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in detail.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text class="text-[#666]">{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text class="text-[#666]">{{ item.productUnitName || '-' }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">数量</text>
|
||||
<text class="text-[#666]">{{ formatCount(item.count) }}</text>
|
||||
</view>
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">单价</text>
|
||||
<text class="text-[#666]">{{ formatPrice(item.productPrice) }}</text>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view v-if="item.remark" class="mt-8rpx flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">备注</text>
|
||||
<text class="text-[#666]">{{ item.remark }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<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
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update']) && detail.status !== 20"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && detail.status === 10"
|
||||
type="success"
|
||||
@click="handleApprove"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && detail.status === 20"
|
||||
type="warning"
|
||||
@click="handleReverseApprove"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:delete']) && detail.status !== 20"
|
||||
type="error"
|
||||
@click="handleDelete"
|
||||
>
|
||||
删除
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StockOut } from '@/api/erp/stock-out'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { deleteStockOut, getStockOut, updateStockOutStatus } from '@/api/erp/stock-out'
|
||||
import { useAccess } from '@/hooks/useAccess'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
id: number | any
|
||||
}>()
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const { hasAccessByCodes } = useAccess()
|
||||
const toast = useToast()
|
||||
const detail = ref<StockOut>({})
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-out/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
detail.value = await getStockOut(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit() {
|
||||
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() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updateStockOutStatus(props.id, 20)
|
||||
toast.success('审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 反审批 */
|
||||
function handleReverseApprove() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要反审批该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await updateStockOutStatus(props.id, 10)
|
||||
toast.success('反审批成功')
|
||||
getDetail()
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
function handleDelete() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await deleteStockOut([props.id])
|
||||
toast.success('删除成功')
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} catch {
|
||||
// error handled by http
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
416
src/pages-erp/stock-out/form/index.vue
Normal file
416
src/pages-erp/stock-out/form/index.vue
Normal file
@@ -0,0 +1,416 @@
|
||||
<template>
|
||||
<view class="yd-page-container">
|
||||
<!-- 顶部导航栏 -->
|
||||
<wd-navbar
|
||||
:title="getTitle"
|
||||
left-arrow placeholder safe-area-inset-top fixed
|
||||
@click-left="handleBack"
|
||||
/>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<view class="pb-180rpx">
|
||||
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<wd-cell-group title="基本信息" border>
|
||||
<wd-cell title="出库单号" :value="formData.no || '保存时自动生成'" />
|
||||
<wd-cell
|
||||
title="出库时间"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="formData.outTime ? formatDate(formData.outTime) : '请选择'"
|
||||
@click="datePickerVisible = true"
|
||||
/>
|
||||
<wd-cell
|
||||
title="客户"
|
||||
title-width="180rpx"
|
||||
is-link
|
||||
:value="getCustomerName()"
|
||||
@click="customerPickerVisible = true"
|
||||
/>
|
||||
<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>
|
||||
<view v-if="formData.items.length === 0" class="py-40rpx text-center text-[#999]">
|
||||
暂无产品,请点击下方按钮添加
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
v-for="(item, index) in formData.items"
|
||||
:key="index"
|
||||
class="mx-24rpx mb-20rpx rounded-12rpx bg-[#f9f9f9] p-24rpx"
|
||||
>
|
||||
<view class="mb-12rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '请选择产品' }}
|
||||
</view>
|
||||
<wd-icon name="delete" size="40rpx" color="#f56c6c" @click="removeItem(index)" />
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="仓库"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.warehouseName || '请选择'"
|
||||
@click="openWarehousePicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-cell
|
||||
title="产品"
|
||||
title-width="120rpx"
|
||||
is-link
|
||||
:value="item.productName || '请选择'"
|
||||
@click="openProductPicker(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.count"
|
||||
label="数量"
|
||||
label-width="120rpx"
|
||||
type="number"
|
||||
placeholder="请输入数量"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="mb-12rpx">
|
||||
<wd-input
|
||||
v-model="item.productPrice"
|
||||
label="单价"
|
||||
label-width="120rpx"
|
||||
type="digit"
|
||||
placeholder="请输入单价"
|
||||
@change="calcItemTotal(item)"
|
||||
/>
|
||||
</view>
|
||||
<view class="flex items-center justify-between text-26rpx">
|
||||
<text class="text-[#999]">金额</text>
|
||||
<text class="text-[#f5222d] font-semibold">{{ formatPrice(item.totalPrice) }}</text>
|
||||
</view>
|
||||
<view class="mt-12rpx">
|
||||
<wd-input
|
||||
v-model="item.remark"
|
||||
label="备注"
|
||||
label-width="120rpx"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-24rpx pb-24rpx">
|
||||
<wd-button type="primary" plain block @click="addItem">
|
||||
<wd-icon name="add" class="mr-8rpx" />
|
||||
添加产品
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<wd-cell-group title="合计信息" border>
|
||||
<wd-cell title="合计数量" :value="formatCount(totalCount)" />
|
||||
<wd-cell title="合计金额" :value="formatPrice(totalPrice)" />
|
||||
</wd-cell-group>
|
||||
</wd-form>
|
||||
</view>
|
||||
|
||||
<!-- 底部保存按钮 -->
|
||||
<view class="yd-detail-footer">
|
||||
<wd-button
|
||||
type="primary"
|
||||
block
|
||||
:loading="formLoading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<wd-datetime-picker
|
||||
v-model="datePickerVisible"
|
||||
type="date"
|
||||
:value="formData.outTime"
|
||||
@confirm="onDateConfirm"
|
||||
/>
|
||||
|
||||
<!-- 客户选择器 -->
|
||||
<wd-picker
|
||||
v-model="customerPickerVisible"
|
||||
:columns="customerColumns"
|
||||
@confirm="onCustomerConfirm"
|
||||
/>
|
||||
|
||||
<!-- 仓库选择器 -->
|
||||
<wd-picker
|
||||
v-model="warehousePickerVisible"
|
||||
:columns="warehouseColumns"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<wd-picker
|
||||
v-model="productPickerVisible"
|
||||
:columns="productColumns"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { StockOut, StockOutItem } from '@/api/erp/stock-out'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createStockOut, getStockOut, updateStockOut } from '@/api/erp/stock-out'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { formatDate as formatDateValue } from '@/utils/date'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
|
||||
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<StockOut>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
customerId: undefined,
|
||||
outTime: undefined,
|
||||
remark: undefined,
|
||||
items: [],
|
||||
})
|
||||
const formRules = {
|
||||
outTime: [{ required: true, message: '出库时间不能为空' }],
|
||||
}
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 客户列表
|
||||
const customerList = ref<{ id: number, name: string }[]>([])
|
||||
const customerPickerVisible = ref(false)
|
||||
const customerColumns = computed(() => [
|
||||
customerList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
const warehousePickerVisible = ref(false)
|
||||
const warehouseColumns = computed(() => [
|
||||
warehouseList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 产品列表
|
||||
const productList = ref<{ id: number, name: string, unitName?: string }[]>([])
|
||||
const productPickerVisible = ref(false)
|
||||
const productColumns = computed(() => [
|
||||
productList.value.map(v => ({ value: v.id, label: v.name })),
|
||||
])
|
||||
|
||||
// 日期选择器
|
||||
const datePickerVisible = ref(false)
|
||||
|
||||
// 当前编辑的产品项索引
|
||||
const currentItemIndex = ref(-1)
|
||||
|
||||
/** 合计数量 */
|
||||
const totalCount = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.count) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 合计金额 */
|
||||
const totalPrice = computed(() => {
|
||||
return formData.value.items?.reduce((sum, item) => sum + (Number(item.totalPrice) || 0), 0) || 0
|
||||
})
|
||||
|
||||
/** 获取客户名称 */
|
||||
function getCustomerName() {
|
||||
if (!formData.value.customerId) return '请选择'
|
||||
const customer = customerList.value.find(c => c.id === formData.value.customerId)
|
||||
return customer?.name || '请选择'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
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('/pages-erp/stock-out/index')
|
||||
}
|
||||
|
||||
/** 加载详情 */
|
||||
async function getDetail() {
|
||||
if (!props.id) return
|
||||
try {
|
||||
toast.loading('加载中...')
|
||||
formData.value = await getStockOut(props.id)
|
||||
} finally {
|
||||
toast.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期确认 */
|
||||
function onDateConfirm({ value }: any) {
|
||||
formData.value.outTime = value
|
||||
datePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 客户确认 */
|
||||
function onCustomerConfirm({ value }: any) {
|
||||
formData.value.customerId = value?.[0]
|
||||
customerPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开仓库选择器 */
|
||||
function openWarehousePicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
warehousePickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 仓库确认 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.warehouseId = value?.[0]
|
||||
const warehouse = warehouseList.value.find(w => w.id === item.warehouseId)
|
||||
item.warehouseName = warehouse?.name
|
||||
}
|
||||
warehousePickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 打开产品选择器 */
|
||||
function openProductPicker(index: number) {
|
||||
currentItemIndex.value = index
|
||||
productPickerVisible.value = true
|
||||
}
|
||||
|
||||
/** 产品确认 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
if (currentItemIndex.value >= 0 && formData.value.items) {
|
||||
const item = formData.value.items[currentItemIndex.value]
|
||||
item.productId = value?.[0]
|
||||
const product = productList.value.find(p => p.id === item.productId)
|
||||
item.productName = product?.name
|
||||
item.productUnitName = product?.unitName
|
||||
}
|
||||
productPickerVisible.value = false
|
||||
}
|
||||
|
||||
/** 添加产品项 */
|
||||
function addItem() {
|
||||
if (!formData.value.items) {
|
||||
formData.value.items = []
|
||||
}
|
||||
formData.value.items.push({
|
||||
warehouseId: undefined,
|
||||
warehouseName: undefined,
|
||||
productId: undefined,
|
||||
productName: undefined,
|
||||
productUnitName: undefined,
|
||||
count: undefined,
|
||||
productPrice: undefined,
|
||||
totalPrice: 0,
|
||||
remark: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
/** 移除产品项 */
|
||||
function removeItem(index: number) {
|
||||
formData.value.items?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 计算产品项金额 */
|
||||
function calcItemTotal(item: StockOutItem) {
|
||||
const count = Number(item.count) || 0
|
||||
const price = Number(item.productPrice) || 0
|
||||
item.totalPrice = count * price
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formRef.value!.validate()
|
||||
if (!valid) return
|
||||
|
||||
// 校验产品清单
|
||||
if (!formData.value.items || formData.value.items.length === 0) {
|
||||
toast.error('请添加出库产品')
|
||||
return
|
||||
}
|
||||
|
||||
for (const item of formData.value.items) {
|
||||
if (!item.warehouseId) {
|
||||
toast.error('请选择仓库')
|
||||
return
|
||||
}
|
||||
if (!item.productId) {
|
||||
toast.error('请选择产品')
|
||||
return
|
||||
}
|
||||
if (!item.count || Number(item.count) <= 0) {
|
||||
toast.error('请输入有效的数量')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 设置合计
|
||||
formData.value.totalCount = totalCount.value
|
||||
formData.value.totalPrice = totalPrice.value
|
||||
|
||||
if (props.id) {
|
||||
await updateStockOut(formData.value)
|
||||
toast.success('修改成功')
|
||||
} else {
|
||||
await createStockOut(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
setTimeout(() => {
|
||||
handleBack()
|
||||
}, 500)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
// 加载详情
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
424
src/pages-erp/stock-out/index.vue
Normal file
424
src/pages-erp/stock-out/index.vue
Normal file
@@ -0,0 +1,424 @@
|
||||
<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 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="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">出库时间</text>
|
||||
<text>{{ formatDate(item.outTime) }}</text>
|
||||
</view>
|
||||
<!-- 创建人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">创建人</text>
|
||||
<text>{{ item.creatorName || '-' }}</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:stock-out:query']) && item.status !== 20"
|
||||
size="small" type="primary" plain @click="handleTaskScan(item)"
|
||||
>
|
||||
去扫码
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update']) && item.status !== 20"
|
||||
size="small" type="primary" plain @click="handleEdit(item)"
|
||||
>
|
||||
编辑
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && item.status === 10"
|
||||
size="small" type="success" plain @click="handleApprove(item.id!)"
|
||||
>
|
||||
审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-out:update-status']) && item.status === 20"
|
||||
size="small" type="warning" plain @click="handleReverseApprove(item.id!)"
|
||||
>
|
||||
反审批
|
||||
</wd-button>
|
||||
<wd-button
|
||||
v-if="hasAccessByCodes(['erp:stock-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-fab
|
||||
v-if="hasAccessByCodes(['erp:stock-out:create'])"
|
||||
position="right-bottom"
|
||||
type="primary"
|
||||
:expandable="false"
|
||||
@click="handleAdd"
|
||||
/>
|
||||
|
||||
<!-- 搜索弹窗 -->
|
||||
<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 { StockOut } from '@/api/erp/stock-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 { deleteStockOut, getStockOutPage, updateStockOutStatus } from '@/api/erp/stock-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<StockOut[]>([])
|
||||
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 getStockOutPage(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 handleAdd() {
|
||||
uni.navigateTo({ url: '/pages-erp/stock-out/form/index' })
|
||||
}
|
||||
|
||||
/** 编辑 */
|
||||
function handleEdit(item: StockOut) {
|
||||
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) {
|
||||
uni.navigateTo({ url: `/pages-erp/stock-out/detail/index?id=${item.id}` })
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
function handleApprove(id: number) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要审批该出库单吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm)
|
||||
return
|
||||
try {
|
||||
await updateStockOutStatus(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 updateStockOutStatus(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 deleteStockOut([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>
|
||||
490
src/pages-erp/stock-out/scan/index.vue
Normal file
490
src/pages-erp/stock-out/scan/index.vue
Normal 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>
|
||||
293
src/pages-erp/stock-record/index.vue
Normal file
293
src/pages-erp/stock-record/index.vue
Normal file
@@ -0,0 +1,293 @@
|
||||
<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="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:业务单号 + 业务类型 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-28rpx text-[#333] font-semibold">
|
||||
{{ item.bizNo || '-' }}
|
||||
</view>
|
||||
<view
|
||||
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||
:class="getBizTypeClass(item.bizType)"
|
||||
>
|
||||
{{ getBizTypeLabel(item.bizType) }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 产品 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">产品</text>
|
||||
<text>{{ item.productName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 分类 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">分类</text>
|
||||
<text>{{ item.categoryName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 仓库 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text>{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 出入库日期 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">出入库日期</text>
|
||||
<text>{{ formatDate(item.createTime) }}</text>
|
||||
</view>
|
||||
<!-- 操作人 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">操作人</text>
|
||||
<text>{{ item.creatorName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 数量区域 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view
|
||||
class="text-32rpx font-semibold"
|
||||
:class="(item.count ?? 0) >= 0 ? 'text-[#52c41a]' : 'text-[#f5222d]'"
|
||||
>
|
||||
{{ formatCount(item.count) }}
|
||||
</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">出入库数量</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<view class="text-32rpx text-[#1890ff] font-semibold">{{ formatCount(item.totalCount) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">库存量</view>
|
||||
</view>
|
||||
</view>
|
||||
</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.bizNo" placeholder="请输入业务单号" clearable />
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">操作类型</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.bizType"
|
||||
:columns="bizTypeColumns"
|
||||
label=""
|
||||
placeholder="请选择操作类型"
|
||||
@confirm="onBizTypeConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">仓库</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.warehouseId"
|
||||
:columns="warehouseColumns"
|
||||
label=""
|
||||
placeholder="请选择仓库"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
</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 { StockRecord } from '@/api/erp/stock-record'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { BIZ_TYPE_OPTIONS, getStockRecordPage } from '@/api/erp/stock-record'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const total = ref(0)
|
||||
const list = ref<StockRecord[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
bizNo: undefined as string | undefined,
|
||||
bizType: undefined as number | undefined,
|
||||
warehouseId: undefined as number | undefined,
|
||||
})
|
||||
|
||||
// 仓库列表
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
|
||||
/** 业务类型下拉列 */
|
||||
const bizTypeColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...BIZ_TYPE_OPTIONS.map(v => ({ value: v.value, label: v.label }))],
|
||||
])
|
||||
|
||||
/** 仓库下拉列 */
|
||||
const warehouseColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...warehouseList.value.map(v => ({ value: v.id, label: v.name }))],
|
||||
])
|
||||
|
||||
/** 业务类型选择回调 */
|
||||
function onBizTypeConfirm({ value }: any) {
|
||||
searchForm.bizType = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
searchForm.warehouseId = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.bizNo) conditions.push(`单号:${searchForm.bizNo}`)
|
||||
if (searchForm.bizType !== undefined) {
|
||||
const bizTypeLabel = BIZ_TYPE_OPTIONS.find(o => o.value === searchForm.bizType)?.label
|
||||
if (bizTypeLabel) conditions.push(`类型:${bizTypeLabel}`)
|
||||
}
|
||||
if (searchForm.warehouseId) {
|
||||
const warehouse = warehouseList.value.find(w => w.id === searchForm.warehouseId)
|
||||
if (warehouse) conditions.push(`仓库:${warehouse.name}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索库存记录'
|
||||
})
|
||||
|
||||
/** 获取业务类型标签 */
|
||||
function getBizTypeLabel(bizType?: number) {
|
||||
if (bizType === undefined) return '-'
|
||||
return BIZ_TYPE_OPTIONS.find(o => o.value === bizType)?.label || '-'
|
||||
}
|
||||
|
||||
/** 获取业务类型样式 */
|
||||
function getBizTypeClass(bizType?: number) {
|
||||
if (bizType === undefined) return 'bg-[#f0f0f0] text-[#666]'
|
||||
// 入库类型:绿色
|
||||
if ([1, 4, 10].includes(bizType)) return 'bg-[#f6ffed] text-[#52c41a]'
|
||||
// 出库类型:红色
|
||||
if ([2, 3, 11].includes(bizType)) return 'bg-[#fff1f0] text-[#f5222d]'
|
||||
// 其他:蓝色
|
||||
return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||
}
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count >= 0 ? `+${count.toFixed(2)}` : count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 格式化日期 */
|
||||
function formatDate(timestamp?: number) {
|
||||
if (!timestamp) return '-'
|
||||
const d = new Date(timestamp)
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询库存记录列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params: Record<string, any> = { ...queryParams.value }
|
||||
if (searchForm.bizNo) params.bizNo = searchForm.bizNo
|
||||
if (searchForm.bizType !== undefined) params.bizType = searchForm.bizType
|
||||
if (searchForm.warehouseId) params.warehouseId = searchForm.warehouseId
|
||||
const data = await getStockRecordPage(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,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.bizNo = undefined
|
||||
searchForm.bizType = undefined
|
||||
searchForm.warehouseId = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
getList()
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
238
src/pages-erp/stock/index.vue
Normal file
238
src/pages-erp/stock/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<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="px-24rpx">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||
>
|
||||
<view class="p-24rpx">
|
||||
<!-- 头部:产品名称 + 分类 -->
|
||||
<view class="mb-16rpx flex items-center justify-between">
|
||||
<view class="text-30rpx text-[#333] font-semibold">
|
||||
{{ item.productName || '-' }}
|
||||
</view>
|
||||
<view class="text-24rpx text-[#999]">
|
||||
{{ item.categoryName || '' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 单位 -->
|
||||
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">单位</text>
|
||||
<text>{{ item.unitName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 仓库 -->
|
||||
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||
<text class="text-[#999]">仓库</text>
|
||||
<text>{{ item.warehouseName || '-' }}</text>
|
||||
</view>
|
||||
<!-- 库存量 -->
|
||||
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||
<view class="text-center">
|
||||
<view class="text-36rpx text-[#1890ff] font-semibold">{{ formatCount(item.count) }}</view>
|
||||
<view class="text-22rpx text-[#999] mt-4rpx">库存量</view>
|
||||
</view>
|
||||
</view>
|
||||
</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-picker
|
||||
v-model="searchForm.productId"
|
||||
:columns="productColumns"
|
||||
label=""
|
||||
placeholder="请选择产品"
|
||||
@confirm="onProductConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="yd-search-form-item">
|
||||
<view class="yd-search-form-label">仓库</view>
|
||||
<wd-picker
|
||||
v-model="searchForm.warehouseId"
|
||||
:columns="warehouseColumns"
|
||||
label=""
|
||||
placeholder="请选择仓库"
|
||||
@confirm="onWarehouseConfirm"
|
||||
/>
|
||||
</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 { Stock } from '@/api/erp/stock'
|
||||
import type { LoadMoreState } from '@/http/types'
|
||||
import { onReachBottom } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { getStockPage } from '@/api/erp/stock'
|
||||
import { getWarehouseSimpleList } from '@/api/erp/warehouse'
|
||||
import { getNavbarHeight, navigateBackPlus } from '@/utils'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '',
|
||||
navigationStyle: 'custom',
|
||||
},
|
||||
})
|
||||
|
||||
const total = ref(0)
|
||||
const list = ref<Stock[]>([])
|
||||
const loadMoreState = ref<LoadMoreState>('loading')
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 搜索相关
|
||||
const searchVisible = ref(false)
|
||||
const searchForm = reactive({
|
||||
productId: undefined as number | undefined,
|
||||
warehouseId: undefined as number | undefined,
|
||||
})
|
||||
|
||||
// 产品和仓库列表
|
||||
const productList = ref<{ id: number, name: string }[]>([])
|
||||
const warehouseList = ref<{ id: number, name: string }[]>([])
|
||||
|
||||
/** 产品下拉列 */
|
||||
const productColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...productList.value.map(v => ({ value: v.id, label: v.name }))],
|
||||
])
|
||||
|
||||
/** 仓库下拉列 */
|
||||
const warehouseColumns = computed(() => [
|
||||
[{ value: '', label: '全部' }, ...warehouseList.value.map(v => ({ value: v.id, label: v.name }))],
|
||||
])
|
||||
|
||||
/** 产品选择回调 */
|
||||
function onProductConfirm({ value }: any) {
|
||||
searchForm.productId = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 仓库选择回调 */
|
||||
function onWarehouseConfirm({ value }: any) {
|
||||
searchForm.warehouseId = value?.[0] || undefined
|
||||
}
|
||||
|
||||
/** 搜索条件 placeholder */
|
||||
const searchPlaceholder = computed(() => {
|
||||
const conditions: string[] = []
|
||||
if (searchForm.productId) {
|
||||
const product = productList.value.find(p => p.id === searchForm.productId)
|
||||
if (product) conditions.push(`产品:${product.name}`)
|
||||
}
|
||||
if (searchForm.warehouseId) {
|
||||
const warehouse = warehouseList.value.find(w => w.id === searchForm.warehouseId)
|
||||
if (warehouse) conditions.push(`仓库:${warehouse.name}`)
|
||||
}
|
||||
return conditions.length > 0 ? conditions.join(' | ') : '搜索库存'
|
||||
})
|
||||
|
||||
/** 格式化数量 */
|
||||
function formatCount(count?: number) {
|
||||
if (count === undefined || count === null) return '-'
|
||||
return count.toFixed(2)
|
||||
}
|
||||
|
||||
/** 返回上一页 */
|
||||
function handleBack() {
|
||||
navigateBackPlus()
|
||||
}
|
||||
|
||||
/** 查询库存列表 */
|
||||
async function getList() {
|
||||
loadMoreState.value = 'loading'
|
||||
try {
|
||||
const params: Record<string, any> = { ...queryParams.value }
|
||||
if (searchForm.productId) {
|
||||
params.productIds = [searchForm.productId]
|
||||
}
|
||||
if (searchForm.warehouseId) {
|
||||
params.warehouseIds = [searchForm.warehouseId]
|
||||
}
|
||||
const data = await getStockPage(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,
|
||||
}
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置 */
|
||||
function handleReset() {
|
||||
searchForm.productId = undefined
|
||||
searchForm.warehouseId = undefined
|
||||
searchVisible.value = false
|
||||
queryParams.value = { pageNo: 1, pageSize: 10 }
|
||||
list.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 加载更多 */
|
||||
function loadMore() {
|
||||
if (loadMoreState.value === 'finished') return
|
||||
queryParams.value.pageNo++
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 触底加载更多 */
|
||||
onReachBottom(() => {
|
||||
loadMore()
|
||||
})
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
getList()
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await getWarehouseSimpleList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user