订单入库: 批次报告上传把「拍照」「相册」拆开
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s

动作菜单原为「拍照/相册」合并项,改为三项分开:拍照 / 相册 / 聊天文件(PDF)。pickReportImages 按来源传 sourceType(camera / album),相册仍可多选;附契约断言与设计文档更新。
This commit is contained in:
雨天
2026-10-16 15:23:20 +08:00
parent ec2c38ae5c
commit d3e8cdfe0e
3 changed files with 15 additions and 7 deletions
@@ -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 只提取、人来改);
@@ -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) {
@@ -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');