diff --git a/docs/design/20261016-订单入库批量上传批次报告并落生产日期.md b/docs/design/20261016-订单入库批量上传批次报告并落生产日期.md index d49f6ff..cdfbbd7 100644 --- a/docs/design/20261016-订单入库批量上传批次报告并落生产日期.md +++ b/docs/design/20261016-订单入库批量上传批次报告并落生产日期.md @@ -49,7 +49,7 @@ ### 3.1 小程序 UI - **按钮**:`inspection-panel` 底部操作区,在「一键全部合格入库」**下方**新增「**一键上传批次报告**」(同宽、次级样式,避免抢主按钮)。 -- **选择**:`wx.chooseMedia`(拍照/相册、多选);PDF 走 `wx.chooseMessageFile`(微信里能从聊天选到 PDF)。每次最多 N 张(建议 9,与既有拍照一致)。 +- **选择**:点按钮先弹动作菜单,**三项分开**:**「拍照」**(`wx.chooseMedia sourceType:['camera']`)/ **「相册」**(`sourceType:['album']`,可多选)/ **「聊天文件(PDF)」**(`wx.chooseMessageFile`,微信里能从聊天选到 PDF)。每次最多 N 张(建议 9,与既有拍照一致)。 - **上传+解析**:逐张上传到 `quality-reports` 桶(复用 F5),再调**新增的 mobile 端点**(§3.3)→ 返回每份报告 `{report_id, product_names, produced_at}`。 - **核对表(弹层)**:列出 `报告 → 品名 → 匹配到的待验收行 → 生产日期`,其中: - 生产日期**可编辑**(AI 只提取、人来改); diff --git a/miniprogram/components/inspection-panel/index.js b/miniprogram/components/inspection-panel/index.js index 2ab4fbc..c48065a 100644 --- a/miniprogram/components/inspection-panel/index.js +++ b/miniprogram/components/inspection-panel/index.js @@ -887,24 +887,25 @@ Component({ } }, - /** 批次报告:上传(拍照/相册 或 聊天里的 PDF)→ 解析 → 按商品名匹配待验收行 → 弹核对表 */ + /** 批次报告:上传(拍照 / 相册 / 聊天里的 PDF,三者分开)→ 解析 → 按商品名匹配待验收行 → 弹核对表 */ onUploadBatchReports() { if (this.data.reportBusy) return; wx.showActionSheet({ - itemList: ['拍照/相册', '聊天文件(PDF)'], + itemList: ['拍照', '相册', '聊天文件(PDF)'], success: (res) => { - if (res.tapIndex === 0) this.pickReportImages(); - else if (res.tapIndex === 1) this.pickReportFiles(); + if (res.tapIndex === 0) this.pickReportImages(['camera']); + else if (res.tapIndex === 1) this.pickReportImages(['album']); + else if (res.tapIndex === 2) this.pickReportFiles(); }, fail: () => undefined, }); }, - pickReportImages() { + pickReportImages(sourceType) { wx.chooseMedia({ count: 9, mediaType: ['image'], - sourceType: ['camera', 'album'], + sourceType: sourceType || ['camera', 'album'], success: (res) => { const files = (res.tempFiles || []).filter((f) => f && f.tempFilePath); if (files.length) { diff --git a/server/tests/inspectionBatchReportProductionDate.test.ts b/server/tests/inspectionBatchReportProductionDate.test.ts index e36e653..5c195f4 100644 --- a/server/tests/inspectionBatchReportProductionDate.test.ts +++ b/server/tests/inspectionBatchReportProductionDate.test.ts @@ -121,6 +121,13 @@ describe('小程序:按钮 / 核对表 / 两个提交路径都带上字段', ( expect(wrap).toContain('display: flex'); }); + it('上传入口:拍照 / 相册 / 聊天文件(PDF)三项分开,不合并', () => { + expect(mpPanelJs).toContain("itemList: ['拍照', '相册', '聊天文件(PDF)']"); + expect(mpPanelJs).not.toContain('拍照/相册'); + expect(mpPanelJs).toContain("this.pickReportImages(['camera'])"); + expect(mpPanelJs).toContain("this.pickReportImages(['album'])"); + }); + it('核对表:按商品名匹配 + 日期可改 + 确定才写入行', () => { expect(mpPanelJs).toContain('buildReportReview(reports)'); expect(mpPanelJs).toContain('match_label');