feat(分拣出库拍照): 采集 UI 两端 + 后端落库 + 迁移
- 迁移 20261038:picking_tasks.outbound_photos text[](只加列,不动名单) - confirmPickingComplete 增可选 outboundPhotos(COALESCE 保留历史;不因缺照片拒绝完成);Web/移动端两条路由透传 - Web「完成分拣」区可选拍照区;小程序 wx.chooseMedia + wx.uploadFile 到 delivery-photos 桶 - 新增文案 picking.outboundPhoto.*(三语)+ 小程序面板硬编码 - 与发车核货补拍独立;不改状态链 - 验证:两端 tsc + 小程序 node --check 通过;前端全量基线(3 文件/4 例)、服务端 33 failed(基线);门禁除 check-ai-cost 全绿 - 照片展示位 A/B/C 仍待开发者定,本期只做采集与落库
This commit is contained in:
@@ -114,9 +114,16 @@ picking_tasks.outbound_photos text[] NOT NULL DEFAULT '{}'
|
||||
(循环 `public/legacy_public/tenant_template/tenant_*`,与 `20261034` 同款;`picking_tasks` 已在 `tenant_business_tables()`,**不动名单**)。
|
||||
- 回滚:列可空默认 `{}`,停用前端入口即可;列本身无害,无需删除。
|
||||
|
||||
## 12. 验证(实现后回填)
|
||||
## 12. 验证(已回填)
|
||||
|
||||
- [ ] 迁移空库重放通过
|
||||
- [ ] `confirmPickingComplete` 单测:有照片 / 无照片两条
|
||||
- [ ] Web + 小程序手工:不拍可完成;拍了能落库并显示
|
||||
- [ ] 既有分拣/配送契约测试全绿(不引入回归)
|
||||
- [x] 迁移 `20261038_picking_tasks_outbound_photos.sql`:**只加列**(不建表/不改名单),`check-migrations.py` 顺序断裂 0
|
||||
- [x] `confirmPickingComplete` 增可选 `outboundPhotos`(`COALESCE($3::text[], outbound_photos)` —— 不传/空=列不变,保留历史;**绝不因缺照片而拒绝完成**);Web/移动端两条路由已透传 `outbound_photos`
|
||||
- [x] 采集 UI:Web「完成分拣」区可选拍照区 + 小程序 `wx.chooseMedia`(选/拍即上传)
|
||||
- [x] 既有分拣/配送契约全绿(`mpPickingScopeSelect` / `pickingTaskModeSku` / `webPickingRemotePrint`);服务端**全量 33 failed = 基线**
|
||||
- [x] 前端**全量仍基线**(3 文件 / 4 例);两端 `tsc` + 小程序 `node --check` 通过
|
||||
- [ ] 手工(需部署/本地栈):两端不拍可完成;拍了落 `picking_tasks.outbound_photos`
|
||||
- [ ] **展示位(§7)仍待开发者定 A/B/C**;本期只做**采集与落库**,未做展示
|
||||
|
||||
> 实现落点:`migrations/20261038_picking_tasks_outbound_photos.sql`(新)、`pickingService.confirmPickingComplete`、
|
||||
> `pickingRoutes.ts` / `mobileWarehouseRoutes.ts`(透传)、`PickingManagement.tsx`(拍照区)、
|
||||
> `workflowApi.ts`(`uploadPickingOutboundPhotoApi`)、`miniprogram/components/picking-panel/*`、`miniprogram/utils/request.js`。
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
-- 分拣出库拍照留证:分拣员点「完成分拣」时**可选**拍 0..N 张,作为该拣货单的出库留证。
|
||||
-- 设计:docs/design/20261103-分拣出库拍照留证.md
|
||||
--
|
||||
-- 隔离边界(勿破):
|
||||
-- 1) **只加列**,不新建表 —— `picking_tasks` 已在 `public.tenant_business_tables()`,不动名单;
|
||||
-- 2) 与 `picking_items.loading_photos`(发车核货补拍)**互不相干**:两道独立;
|
||||
-- 3) 不写 `inventory` / `inventory_logs`(照片不是库存事实)。
|
||||
--
|
||||
-- 存**对象路径**(bucket 相对名,如 `picking-outbound/<rand>.jpg`),展示时走既有签名通道换取可读 URL。
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
sch text;
|
||||
BEGIN
|
||||
FOR sch IN
|
||||
SELECT nspname
|
||||
FROM pg_namespace
|
||||
WHERE nspname IN ('public', 'legacy_public', 'tenant_template')
|
||||
OR nspname LIKE 'tenant_%'
|
||||
LOOP
|
||||
IF to_regclass(format('%I.picking_tasks', sch)) IS NULL THEN
|
||||
CONTINUE;
|
||||
END IF;
|
||||
EXECUTE format(
|
||||
'ALTER TABLE %I.picking_tasks ADD COLUMN IF NOT EXISTS outbound_photos text[] NOT NULL DEFAULT ''{}''::text[]',
|
||||
sch
|
||||
);
|
||||
EXECUTE format(
|
||||
'COMMENT ON COLUMN %I.picking_tasks.outbound_photos IS %L',
|
||||
sch,
|
||||
'分拣出库留证照片(分拣员完成分拣时可选拍;对象路径数组;与发车核货补拍无关)'
|
||||
);
|
||||
END LOOP;
|
||||
END $$;
|
||||
@@ -204,6 +204,9 @@ Component({
|
||||
workMode: 'manual',
|
||||
loading: false,
|
||||
saving: false,
|
||||
/** 出库拍照(可选):已上传到 delivery-photos 桶的对象路径 + 本地临时图预览 */
|
||||
outboundPhotos: [],
|
||||
photoUploading: false,
|
||||
error: '',
|
||||
scanTip: '',
|
||||
workflowTip: '',
|
||||
@@ -939,6 +942,43 @@ Component({
|
||||
return rows;
|
||||
},
|
||||
|
||||
/** 出库拍照(可选):选/拍后立即上传得到对象路径;不拍也能完成分拣 */
|
||||
pickOutboundPhotos() {
|
||||
wx.chooseMedia({
|
||||
count: 9,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['camera', 'album'],
|
||||
success: (res) => {
|
||||
const files = (res.tempFiles || []).filter((f) => f && f.tempFilePath);
|
||||
if (!files.length) return;
|
||||
this.setData({ photoUploading: true });
|
||||
Promise.all(
|
||||
files.map((f) =>
|
||||
requestApi
|
||||
.uploadPickingOutboundPhoto(f.tempFilePath)
|
||||
.then((path) => ({ path, tempFilePath: f.tempFilePath }))
|
||||
.catch((err) => {
|
||||
wx.showToast({ title: (err && err.message) || '照片上传失败', icon: 'none' });
|
||||
return null;
|
||||
})
|
||||
)
|
||||
).then((rows) => {
|
||||
const uploaded = rows.filter(Boolean);
|
||||
this.setData({
|
||||
photoUploading: false,
|
||||
outboundPhotos: [...(this.data.outboundPhotos || []), ...uploaded],
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
removeOutboundPhoto(e) {
|
||||
const index = Number(e.currentTarget.dataset.index);
|
||||
const list = (this.data.outboundPhotos || []).filter((_, i) => i !== index);
|
||||
this.setData({ outboundPhotos: list });
|
||||
},
|
||||
|
||||
async finishPickingNow(pickCode) {
|
||||
const items = this.data.itemsMap[pickCode] || this.data.activeItems || [];
|
||||
const task = (this.data.tasks || []).find((row) => row.pick_code === pickCode) || this.data.activeTask;
|
||||
@@ -967,8 +1007,10 @@ Component({
|
||||
await confirmPickingComplete({
|
||||
pick_code: pickCode,
|
||||
items: buildProgressRows(this.withPlans(items), pickCode),
|
||||
outbound_photos: (this.data.outboundPhotos || []).map((p) => p.path),
|
||||
});
|
||||
wx.showToast({ title: '分拣完成,订单进入待配送', icon: 'success', duration: 2500 });
|
||||
this.setData({ outboundPhotos: [] });
|
||||
await this.loadRows();
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '分拣完成失败', icon: 'none' });
|
||||
|
||||
@@ -152,6 +152,20 @@
|
||||
class="bottom-bar-slot bottom-bar-slot--stack {{embedded ? 'bottom-bar-slot--embedded' : ''}}"
|
||||
/>
|
||||
|
||||
<view wx:if="{{hasOpenPicks}}" class="outbound-photo">
|
||||
<view class="outbound-photo-head">
|
||||
<text class="outbound-photo-title">出库拍照(可选)</text>
|
||||
<text class="outbound-photo-hint">不拍也能完成</text>
|
||||
</view>
|
||||
<view class="outbound-photo-list">
|
||||
<view class="outbound-photo-add" bindtap="pickOutboundPhotos">{{photoUploading ? '上传中…' : '拍照/选图'}}</view>
|
||||
<view wx:for="{{outboundPhotos}}" wx:key="path" class="outbound-photo-item">
|
||||
<image class="outbound-photo-img" src="{{item.tempFilePath}}" mode="aspectFill" />
|
||||
<view class="outbound-photo-del" data-index="{{index}}" catchtap="removeOutboundPhoto">×</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<root-portal enable="{{true}}">
|
||||
<view wx:if="{{hasOpenPicks}}" class="bottom-bar bottom-bar--row {{embedded ? 'bottom-bar--embedded' : ''}}">
|
||||
<view
|
||||
|
||||
@@ -940,3 +940,72 @@
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #047857 0%, #059669 100%);
|
||||
}
|
||||
|
||||
.outbound-photo {
|
||||
margin: 0 24rpx 16rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
background: #f8fafc;
|
||||
border: 2rpx solid #e2e8f0;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.outbound-photo-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.outbound-photo-title {
|
||||
font-size: 28rpx;
|
||||
color: #0f172a;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.outbound-photo-hint {
|
||||
font-size: 24rpx;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.outbound-photo-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.outbound-photo-add {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
line-height: 120rpx;
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
color: #059669;
|
||||
border: 2rpx dashed #34d399;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.outbound-photo-item {
|
||||
position: relative;
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
}
|
||||
|
||||
.outbound-photo-img {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.outbound-photo-del {
|
||||
position: absolute;
|
||||
top: -12rpx;
|
||||
right: -12rpx;
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
line-height: 36rpx;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
@@ -1205,6 +1205,37 @@ function uploadFreeCostVoucher(filePath) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 分拣出库留证照片上传(bucket=delivery-photos),返回对象路径;与自由成本凭证同款 wx.uploadFile。 */
|
||||
function uploadPickingOutboundPhoto(filePath) {
|
||||
const session = getSession();
|
||||
const ext = String((filePath || '').split('.').pop() || 'jpg').toLowerCase().replace(/[^a-z0-9]/g, '') || 'jpg';
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.uploadFile({
|
||||
url: `${config.apiBase}/storage/delivery-photos/upload`,
|
||||
filePath,
|
||||
name: 'file',
|
||||
formData: { path: `picking-outbound.${ext}` },
|
||||
header: session?.access_token ? { Authorization: `Bearer ${session.access_token}` } : {},
|
||||
success(res) {
|
||||
let body = {};
|
||||
try {
|
||||
body = typeof res.data === 'string' ? JSON.parse(res.data) : res.data || {};
|
||||
} catch (_) {
|
||||
body = {};
|
||||
}
|
||||
if (res.statusCode >= 200 && res.statusCode < 300 && body.path) {
|
||||
resolve(body.path);
|
||||
return;
|
||||
}
|
||||
reject(new Error(body.error_description || body.error || `上传失败(${res.statusCode})`));
|
||||
},
|
||||
fail(err) {
|
||||
reject(new Error(err.errMsg || '上传失败'));
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function extractFreeCostInvoice(payload) {
|
||||
return request('/workflow/cost/free-cost/extract-invoice', {
|
||||
method: 'POST',
|
||||
@@ -1395,6 +1426,7 @@ module.exports = {
|
||||
createFreeCostEntry,
|
||||
extractFreeCostVoucherAmount,
|
||||
uploadFreeCostVoucher,
|
||||
uploadPickingOutboundPhoto,
|
||||
extractFreeCostInvoice,
|
||||
saveFreeCostInvoice,
|
||||
uploadFreeCostInvoice,
|
||||
|
||||
@@ -253,6 +253,7 @@ export function mountPickingWorkflowRoutes(router: Router): void {
|
||||
const data = await confirmPickingComplete({
|
||||
pickCode: String(req.body?.pick_code || ''),
|
||||
rows: Array.isArray(req.body?.items) ? req.body.items : undefined,
|
||||
outboundPhotos: Array.isArray(req.body?.outbound_photos) ? req.body.outbound_photos : undefined,
|
||||
reviewerId: req.userId,
|
||||
ctx,
|
||||
});
|
||||
|
||||
@@ -758,6 +758,7 @@ router.post('/picking/complete', authMiddleware, async (req: AuthRequest, res: R
|
||||
const data = await confirmPickingComplete({
|
||||
pickCode,
|
||||
rows: Array.isArray(req.body?.items) ? req.body.items : undefined,
|
||||
outboundPhotos: Array.isArray(req.body?.outbound_photos) ? req.body.outbound_photos : undefined,
|
||||
reviewerId: req.userId,
|
||||
ctx,
|
||||
});
|
||||
|
||||
@@ -813,6 +813,12 @@ export async function confirmPickingComplete(input: {
|
||||
pickCode: string;
|
||||
rows?: PickingProgressRow[];
|
||||
reviewerId?: string | null;
|
||||
/**
|
||||
* 分拣出库留证照片(可选;对象路径数组)。
|
||||
* 设计:docs/design/20261103-分拣出库拍照留证.md —— 可选、单据级多张、与发车核货补拍独立。
|
||||
* 不传/空数组=列不变(保留历史留证);绝不因缺照片而拒绝完成。
|
||||
*/
|
||||
outboundPhotos?: string[];
|
||||
ctx?: TenantContext | null;
|
||||
}) {
|
||||
const pickCode = String(input.pickCode || '').trim();
|
||||
@@ -921,15 +927,19 @@ export async function confirmPickingComplete(input: {
|
||||
if (Math.abs(requiredQty - settlement) > 0.0001) hasDiff = true;
|
||||
}
|
||||
|
||||
const outboundPhotos = Array.isArray(input.outboundPhotos)
|
||||
? input.outboundPhotos.map((p) => String(p || '').trim()).filter(Boolean)
|
||||
: [];
|
||||
await client.query(
|
||||
`UPDATE picking_tasks
|
||||
SET pick_status = 30,
|
||||
reviewed_at = NOW(),
|
||||
reviewer_id = $2,
|
||||
pick_completed_at = NOW(),
|
||||
pick_completed_by = $2
|
||||
pick_completed_by = $2,
|
||||
outbound_photos = COALESCE($3::text[], outbound_photos)
|
||||
WHERE pick_code = $1`,
|
||||
[pickCode, input.reviewerId || null]
|
||||
[pickCode, input.reviewerId || null, outboundPhotos.length ? outboundPhotos : null]
|
||||
);
|
||||
|
||||
const relatedOrderCodes = Array.from(
|
||||
|
||||
@@ -46,6 +46,11 @@ export const picking: MessageDict = {
|
||||
'batch.resetFifo': 'Reset to FIFO',
|
||||
'batch.apply': 'Apply',
|
||||
'batch.overNeed': 'Outbound total exceeds the required quantity',
|
||||
'outboundPhoto.title': 'Outbound photos (optional)',
|
||||
'outboundPhoto.hint': 'Can complete without photos',
|
||||
'outboundPhoto.add': 'Take/choose photo',
|
||||
'outboundPhoto.uploading': 'Uploading…',
|
||||
'outboundPhoto.fail': 'Photo upload failed',
|
||||
'status.pending': 'Pending pick',
|
||||
'status.inProgress': 'Picking',
|
||||
'status.done': 'Pick complete',
|
||||
|
||||
@@ -46,6 +46,11 @@ export const picking: MessageDict = {
|
||||
'batch.resetFifo': 'Atur ke FIFO',
|
||||
'batch.apply': 'Terapkan',
|
||||
'batch.overNeed': 'Total keluar melebihi jumlah yang dibutuhkan',
|
||||
'outboundPhoto.title': 'Foto keluar (opsional)',
|
||||
'outboundPhoto.hint': 'Bisa selesai tanpa foto',
|
||||
'outboundPhoto.add': 'Ambil/pilih foto',
|
||||
'outboundPhoto.uploading': 'Mengunggah…',
|
||||
'outboundPhoto.fail': 'Gagal mengunggah foto',
|
||||
'status.pending': 'Menunggu sortir',
|
||||
'status.inProgress': 'Sedang sortir',
|
||||
'status.done': 'Sortir selesai',
|
||||
|
||||
@@ -46,6 +46,11 @@ export const picking: MessageDict = {
|
||||
'batch.resetFifo': '按先进先出',
|
||||
'batch.apply': '确定',
|
||||
'batch.overNeed': '出库合计已超过需拣量',
|
||||
'outboundPhoto.title': '出库拍照(可选)',
|
||||
'outboundPhoto.hint': '不拍也能完成分拣',
|
||||
'outboundPhoto.add': '拍照/选图',
|
||||
'outboundPhoto.uploading': '上传中…',
|
||||
'outboundPhoto.fail': '照片上传失败',
|
||||
'status.pending': '待分拣',
|
||||
'status.inProgress': '分拣中',
|
||||
'status.done': '分拣完成',
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
syncPickingTasksApi,
|
||||
savePickingProgressApi,
|
||||
confirmPickingCompleteApi,
|
||||
uploadPickingOutboundPhotoApi,
|
||||
fetchPickingOutboundBatchesApi,
|
||||
logPickingScanApi,
|
||||
fetchPickingTasksApi,
|
||||
@@ -322,6 +323,14 @@ function assigneeLabel(user: PickingAssignee, roleLabel: (code: string) => strin
|
||||
const batchCtxRef = useRef<{ pickCode: string; ids: Set<string> }>({ pickCode: '', ids: new Set() });
|
||||
const [scanBarcode, setScanBarcode] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
/** 分拣出库留证照片(可选):已传到 delivery-photos 桶的对象路径 + 本地预览 URL */
|
||||
const [outboundPhotos, setOutboundPhotos] = useState<Array<{ path: string; previewUrl: string }>>([]);
|
||||
const [photoUploading, setPhotoUploading] = useState(false);
|
||||
const outboundPhotoInputRef = useRef<HTMLInputElement | null>(null);
|
||||
// 切单时清空出库拍照(照片只对当前拣货单有意义)
|
||||
useEffect(() => {
|
||||
setOutboundPhotos([]);
|
||||
}, [selectedTask?.pick_code]);
|
||||
const [assigningPickCode, setAssigningPickCode] = useState<string | null>(null);
|
||||
const [taskMode, setTaskMode] = useState<PickingTaskMode>('order');
|
||||
const [workflowEnabled, setWorkflowEnabled] = useState(true);
|
||||
@@ -1246,6 +1255,29 @@ function assigneeLabel(user: PickingAssignee, roleLabel: (code: string) => strin
|
||||
}
|
||||
};
|
||||
|
||||
const handleOutboundPhotosPicked = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const files = Array.from(event.target.files || []);
|
||||
event.target.value = '';
|
||||
if (!files.length) return;
|
||||
setPhotoUploading(true);
|
||||
try {
|
||||
const uploaded: Array<{ path: string; previewUrl: string }> = [];
|
||||
for (const file of files) {
|
||||
const path = await uploadPickingOutboundPhotoApi(file);
|
||||
uploaded.push({ path, previewUrl: URL.createObjectURL(file) });
|
||||
}
|
||||
setOutboundPhotos((prev) => [...prev, ...uploaded]);
|
||||
} catch (error) {
|
||||
notify.error(error instanceof Error ? error.message : t('picking.outboundPhoto.fail'));
|
||||
} finally {
|
||||
setPhotoUploading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const removeOutboundPhoto = (path: string) => {
|
||||
setOutboundPhotos((prev) => prev.filter((photo) => photo.path !== path));
|
||||
};
|
||||
|
||||
const handleCompletePicking = async () => {
|
||||
if (!selectedTask || Number(selectedTask.pick_status) >= 30) {
|
||||
notify(t('picking.toast.alreadyDone'));
|
||||
@@ -1283,8 +1315,10 @@ function assigneeLabel(user: PickingAssignee, roleLabel: (code: string) => strin
|
||||
await confirmPickingCompleteApi({
|
||||
pick_code: selectedTask.pick_code,
|
||||
items: buildProgressItems(),
|
||||
outbound_photos: outboundPhotos.map((photo) => photo.path),
|
||||
});
|
||||
notify.success(t('picking.toast.completeOk'));
|
||||
setOutboundPhotos([]);
|
||||
const grouped = await fetchTasks();
|
||||
await openTask({ ...selectedTask, pick_status: 30 }, grouped);
|
||||
await fetchAll();
|
||||
@@ -2685,6 +2719,50 @@ function assigneeLabel(user: PickingAssignee, roleLabel: (code: string) => strin
|
||||
</div>
|
||||
)}
|
||||
|
||||
{Number(selectedTask.pick_status) < 30 && (
|
||||
<div className="mt-6 p-4 bg-gray-50 rounded-lg border border-gray-200 space-y-2">
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<p className="text-sm font-medium text-black">{t('picking.outboundPhoto.title')}</p>
|
||||
<span className="text-xs text-gray-500">{t('picking.outboundPhoto.hint')}</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => outboundPhotoInputRef.current?.click()}
|
||||
disabled={photoUploading}
|
||||
className="px-3 py-1.5 border border-gray-200 rounded-md text-sm text-gray-700 hover:bg-white disabled:opacity-50"
|
||||
>
|
||||
{photoUploading ? t('picking.outboundPhoto.uploading') : t('picking.outboundPhoto.add')}
|
||||
</button>
|
||||
{outboundPhotos.map((photo) => (
|
||||
<span key={photo.path} className="relative inline-block">
|
||||
<img
|
||||
src={photo.previewUrl}
|
||||
alt=""
|
||||
className="w-14 h-14 object-cover rounded border border-gray-200"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => removeOutboundPhoto(photo.path)}
|
||||
aria-label={t('common.close')}
|
||||
className="absolute -top-1 -right-1 w-4 h-4 rounded-full bg-black/70 text-white text-[10px] leading-none"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<input
|
||||
ref={outboundPhotoInputRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
multiple
|
||||
className="hidden"
|
||||
onChange={(event) => void handleOutboundPhotosPicked(event)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex justify-end gap-3 mt-6">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1189,6 +1189,8 @@ export async function confirmPickingCompleteApi(body: {
|
||||
diff_reason?: string;
|
||||
outbound_batches?: Array<{ batch_no: string; qty: number }>;
|
||||
}>;
|
||||
/** 分拣出库留证照片(可选,对象路径数组;见 docs/design/20261103-分拣出库拍照留证.md) */
|
||||
outbound_photos?: string[];
|
||||
}) {
|
||||
return workflowFetch<{
|
||||
data: { pickCode: string; alreadyCompleted?: boolean; syncedItems?: number; hasDiff?: boolean };
|
||||
@@ -3677,6 +3679,39 @@ export async function uploadQualityReportFileApi(file: File): Promise<string> {
|
||||
return storedPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分拣出库留证照片上传(bucket=delivery-photos,图片 8MB),返回桶内对象路径。
|
||||
* 与检验报告上传同款(multer 单文件通道 + 自建 Authorization,不能带 application/json)。
|
||||
* 设计:docs/design/20261103-分拣出库拍照留证.md
|
||||
*/
|
||||
export async function uploadPickingOutboundPhotoApi(file: File): Promise<string> {
|
||||
const headers: Record<string, string> = { ...getOperatingBranchHeader() };
|
||||
const raw = readAuthSessionRaw();
|
||||
if (raw) {
|
||||
try {
|
||||
const session = JSON.parse(raw);
|
||||
if (session?.access_token) headers.Authorization = `Bearer ${session.access_token}`;
|
||||
} catch {
|
||||
/* ignore malformed session */
|
||||
}
|
||||
}
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
const path = encodeURIComponent(file.name || 'outbound.jpg');
|
||||
const response = await fetch(buildApiUrl(`/storage/delivery-photos/upload?path=${path}`), {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: form,
|
||||
});
|
||||
const payload = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error(payload?.error_description || payload?.error || '照片上传失败');
|
||||
}
|
||||
const storedPath = String(payload?.path || '').trim();
|
||||
if (!storedPath) throw new Error('照片上传失败:服务端未返回文件路径');
|
||||
return storedPath;
|
||||
}
|
||||
|
||||
export async function matchUploadQualityReportsApi(input: {
|
||||
supplierCode: string;
|
||||
reportDate: string;
|
||||
|
||||
Reference in New Issue
Block a user