From 567c3175f60fd846ac1e555c2b090eb96fb89c53 Mon Sep 17 00:00:00 2001 From: DXC Date: Mon, 25 May 2026 11:11:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A1=E8=AE=A1=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E5=90=91=E9=87=8F=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20numpy=20=E6=95=B0=E7=BB=84=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E5=BC=82=E5=B8=B8=EF=BC=9B=E8=A1=A5=E5=85=A8=E4=B8=89?= =?UTF-8?q?=E5=A4=A7=E5=85=A5=E5=BA=93=E5=8D=95=E6=9B=B4=E6=96=B0=E5=90=91?= =?UTF-8?q?=E9=87=8F=E6=8F=90=E5=8F=96=EF=BC=8C=E7=BB=9F=E4=B8=80=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=A1=AE=E8=AE=A4=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventory-backend/app/core/audit_listener.py | 5 ++++ .../app/services/inbound/buy_service.py | 2 ++ .../app/services/inbound/product_service.py | 2 ++ .../app/services/inbound/semi_service.py | 2 ++ inventory-web/src/views/stock/inbound/buy.vue | 23 ++++++++++++----- .../src/views/stock/inbound/product.vue | 21 +++++++++++++--- .../src/views/stock/inbound/semi.vue | 25 +++++++++++++------ 7 files changed, 64 insertions(+), 16 deletions(-) diff --git a/inventory-backend/app/core/audit_listener.py b/inventory-backend/app/core/audit_listener.py index 0de0961..9cf081f 100644 --- a/inventory-backend/app/core/audit_listener.py +++ b/inventory-backend/app/core/audit_listener.py @@ -142,6 +142,7 @@ def before_update_listener(mapper, connection, target): changes = {} for attr in state.attrs: if attr.key in IGNORE_FIELDS: continue + if 'embedding' in attr.key: continue if attr.history.has_changes(): old_val = attr.history.deleted[0] if attr.history.deleted else None new_val = attr.history.added[0] if attr.history.added else None @@ -164,6 +165,8 @@ def before_delete_listener(mapper, connection, target): state = inspect(target) snap = {} for attr in state.attrs: + if attr.key in IGNORE_FIELDS: continue + if 'embedding' in attr.key: continue val = getattr(target, attr.key, None) snap[attr.key] = _serialize_value(val) _create_audit_log(connection, mapper, target, 'delete', {'deleted_snapshot': snap}) @@ -180,6 +183,8 @@ def after_insert_listener(mapper, connection, target): state = inspect(target) snap = {} for attr in state.attrs: + if attr.key in IGNORE_FIELDS: continue + if 'embedding' in attr.key: continue val = getattr(target, attr.key, None) snap[attr.key] = _serialize_value(val) _create_audit_log(connection, mapper, target, 'insert', {'created': snap}) diff --git a/inventory-backend/app/services/inbound/buy_service.py b/inventory-backend/app/services/inbound/buy_service.py index 303f3c4..2d3b070 100644 --- a/inventory-backend/app/services/inbound/buy_service.py +++ b/inventory-backend/app/services/inbound/buy_service.py @@ -245,6 +245,8 @@ class BuyInboundService: if k in data: setattr(stock, v, data[k]) if 'arrival_photo' in data: stock.arrival_photo = json.dumps(data['arrival_photo']) + if 'arrival_photo' in data and stock.arrival_photo: + stock.arrival_image_embedding = extract_and_embed(stock.arrival_photo) if 'inspection_report' in data: stock.inspection_report = json.dumps(data['inspection_report']) # 更新税率 diff --git a/inventory-backend/app/services/inbound/product_service.py b/inventory-backend/app/services/inbound/product_service.py index 6005b67..5d8523c 100644 --- a/inventory-backend/app/services/inbound/product_service.py +++ b/inventory-backend/app/services/inbound/product_service.py @@ -219,6 +219,8 @@ class ProductInboundService: if 'product_photo' in data: imgs = data['product_photo'] if isinstance(imgs, list): stock.product_photo = json.dumps(imgs) + if stock.product_photo: + stock.arrival_image_embedding = extract_and_embed(stock.product_photo) if 'quality_report_link' in data: imgs = data['quality_report_link'] if isinstance(imgs, list): stock.quality_report_link = json.dumps(imgs) diff --git a/inventory-backend/app/services/inbound/semi_service.py b/inventory-backend/app/services/inbound/semi_service.py index 41fe240..9fa9195 100644 --- a/inventory-backend/app/services/inbound/semi_service.py +++ b/inventory-backend/app/services/inbound/semi_service.py @@ -275,6 +275,8 @@ class SemiInboundService: imgs = data['arrival_photo'] if isinstance(imgs, list): stock.arrival_photo = json.dumps(imgs) + if stock.arrival_photo: + stock.arrival_image_embedding = extract_and_embed(stock.arrival_photo) if 'quality_report_link' in data: imgs = data['quality_report_link'] if isinstance(imgs, list): diff --git a/inventory-web/src/views/stock/inbound/buy.vue b/inventory-web/src/views/stock/inbound/buy.vue index c162ac2..b477ac1 100644 --- a/inventory-web/src/views/stock/inbound/buy.vue +++ b/inventory-web/src/views/stock/inbound/buy.vue @@ -226,11 +226,7 @@ 打印 编辑 - - - + 删除 @@ -1631,7 +1627,22 @@ const handleSortChange = ({ column, prop, order }: any) => { fetchData() } -const handleDelete = async (row: any) => { try { await deleteBuyInbound(row.id); ElMessage.success('删除成功'); fetchData() } catch (e) { ElMessage.error('删除失败') } } +const handleDelete = (row: any) => { + const recordName = row.sku || row.barcode || '此项'; + ElMessageBox.confirm( + `是否确认删除采购入库记录 "${recordName}" ?`, + "警告", + { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" } + ).then(async () => { + try { + await deleteBuyInbound(row.id); + ElMessage.success('删除成功'); + fetchData(); + } catch (e) { + ElMessage.error('删除失败'); + } + }).catch(() => {}); +}; // ------------------------------------ // 打印逻辑 diff --git a/inventory-web/src/views/stock/inbound/product.vue b/inventory-web/src/views/stock/inbound/product.vue index 1a20cc7..32b9fba 100644 --- a/inventory-web/src/views/stock/inbound/product.vue +++ b/inventory-web/src/views/stock/inbound/product.vue @@ -227,7 +227,7 @@ 编辑 - + 删除 @@ -572,7 +572,7 @@ import { ref, reactive, onMounted, watch, computed } from 'vue' import { Plus, Setting, Refresh, Search, Box, House, Link, InfoFilled, Printer, Camera, Picture, EditPen } from '@element-plus/icons-vue' import { useRouter } from 'vue-router' -import { ElMessage, ElLoading } from 'element-plus' +import { ElMessage, ElMessageBox, ElLoading } from 'element-plus' import dayjs from 'dayjs' import request from '@/utils/request' import { @@ -1358,7 +1358,22 @@ const submitForm = async () => { }) } -const handleDelete = async (row: any) => { try { await deleteProductInbound(row.id); ElMessage.success('删除成功'); fetchData() } catch(e) { ElMessage.error('删除失败') } } +const handleDelete = (row: any) => { + const recordName = row.sku || row.barcode || '此项'; + ElMessageBox.confirm( + `是否确认删除成品入库记录 "${recordName}" ?`, + "警告", + { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" } + ).then(async () => { + try { + await deleteProductInbound(row.id); + ElMessage.success('删除成功'); + fetchData(); + } catch (e) { + ElMessage.error('删除失败'); + } + }).catch(() => {}); +}; const handlePrint = async (row: any) => { printVisible.value = true; printLoading.value = true; previewUrl.value = '' currentPrintData.value = { global_print_id: row.global_print_id, material_name: row.material_name, spec_model: row.spec_model, category: row.category, material_type: row.material_type, warehouse_loc: row.warehouse_loc, serial_number: row.serial_number, sku: row.sku } diff --git a/inventory-web/src/views/stock/inbound/semi.vue b/inventory-web/src/views/stock/inbound/semi.vue index 79299db..7948842 100644 --- a/inventory-web/src/views/stock/inbound/semi.vue +++ b/inventory-web/src/views/stock/inbound/semi.vue @@ -250,11 +250,7 @@ 打印 编辑 - - - + 删除 @@ -627,7 +623,7 @@ import {ref, reactive, onMounted, watch, computed} from 'vue' import {Plus, Setting, Refresh, Search, Lock, Box, House, InfoFilled, Link, Printer, Camera, Picture, EditPen} from '@element-plus/icons-vue' import { useRouter } from 'vue-router' -import {ElMessage, ElLoading} from 'element-plus' +import {ElMessage, ElMessageBox, ElLoading} from 'element-plus' import dayjs from 'dayjs' import request from '@/utils/request' import { @@ -1438,7 +1434,22 @@ const submitForm = async () => { }) } -const handleDelete = async (row: any) => { try { await deleteSemiInbound(row.id); ElMessage.success('删除成功'); fetchData() } catch (e) { ElMessage.error('删除失败') } } +const handleDelete = (row: any) => { + const recordName = row.sku || row.barcode || '此项'; + ElMessageBox.confirm( + `是否确认删除半成品入库记录 "${recordName}" ?`, + "警告", + { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" } + ).then(async () => { + try { + await deleteSemiInbound(row.id); + ElMessage.success('删除成功'); + fetchData(); + } catch (e) { + ElMessage.error('删除失败'); + } + }).catch(() => {}); +}; const handlePrint = async (row: any) => { printVisible.value = true; printLoading.value = true; previewUrl.value = '' currentPrintData.value = { global_print_id: row.global_print_id, material_name: row.material_name, spec_model: row.spec_model, category: row.category, material_type: row.material_type, warehouse_loc: row.warehouse_loc, serial_number: row.serial_number, batch_number: row.batch_number, sku: row.sku }