feat(product): 優化編輯後的跳轉邏輯,支援依來源回傳詳情頁或列表

This commit is contained in:
2026-02-05 16:01:29 +08:00
parent 075b9f1c98
commit 1d5bc68444
4 changed files with 15 additions and 4 deletions

View File

@@ -22,6 +22,8 @@ export default function ProductForm({
units,
}: ProductFormProps) {
const isEdit = !!initialData;
const urlParams = new URLSearchParams(window.location.search);
const from = urlParams.get('from');
const { data, setData, post, put, processing, errors } = useForm({
code: initialData?.code || "",
@@ -45,7 +47,7 @@ export default function ProductForm({
e.preventDefault();
if (isEdit) {
put(route("products.update", initialData.id), {
put(route("products.update", { product: initialData.id, from }), {
onSuccess: () => toast.success("商品已更新"),
onError: () => toast.error("更新失敗,請檢查輸入資料"),
});