import { useState } from "react";
|
import { useRecordContext, useTranslate } from "react-admin";
|
import { Button } from "@mui/material";
|
import request from "@/utils/request";
|
|
/** 出入库历史单:云仓 ERP 反馈重发(权限 manager:asnOrderLog:cloudWmsResend) */
|
export default function AsnOrderLogCloudWmsResendButton() {
|
const record = useRecordContext();
|
const translate = useTranslate();
|
const [loading, setLoading] = useState(false);
|
|
if (!record?.id) {
|
return null;
|
}
|
|
const onClick = async () => {
|
const ok = window.confirm(
|
translate("resources.asnOrderLog.cloudWmsResendConfirm", {
|
_: "确认将该历史单的云仓入出库反馈重新加入发送队列?",
|
})
|
);
|
if (!ok) return;
|
setLoading(true);
|
try {
|
const res = await request.post(`/asnOrderLog/cloudWms/resendFeedback/${record.id}`);
|
const { code, msg, data } = res.data || {};
|
if (code === 200) {
|
window.alert(msg || "OK");
|
} else {
|
window.alert(msg || "Error");
|
}
|
} catch (e) {
|
window.alert(e?.message || String(e));
|
} finally {
|
setLoading(false);
|
}
|
};
|
|
return (
|
<Button size="small" variant="outlined" disabled={loading} onClick={onClick}>
|
{translate("resources.asnOrderLog.cloudWmsResend", { _: "云仓反馈重发" })}
|
</Button>
|
);
|
}
|