feat(weibo): 支持工作台账号转入外部单协作
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Alert,
|
||||
AutoComplete,
|
||||
@@ -128,6 +129,8 @@ interface OrderFormValues {
|
||||
export default function WeiboCollabPage() {
|
||||
const { token } = theme.useToken();
|
||||
const { can } = usePermissions();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const canEdit = can('weibo:collab:edit');
|
||||
const canManage = can('weibo:collab:manage');
|
||||
|
||||
@@ -163,6 +166,7 @@ export default function WeiboCollabPage() {
|
||||
const [detailMetrics, setDetailMetrics] = useState<WeiboCollabMetric[]>([]);
|
||||
const [detailTimeline, setDetailTimeline] = useState<WeiboCollabTimeline[]>([]);
|
||||
const [detailLoading, setDetailLoading] = useState(false);
|
||||
const transferHandledRef = useRef<number | null>(null);
|
||||
|
||||
const [statusOpen, setStatusOpen] = useState(false);
|
||||
const [statusTarget, setStatusTarget] = useState<WeiboCollabStatus>('to_recharge');
|
||||
@@ -297,7 +301,7 @@ export default function WeiboCollabPage() {
|
||||
if (!goodsOptions.some((item) => item.value === option.value)) goodsOptions.push(option);
|
||||
}
|
||||
|
||||
const lookupAccount = async (accountId?: number | null) => {
|
||||
const lookupAccount = useCallback(async (accountId?: number | null) => {
|
||||
setLookup(null);
|
||||
if (!accountId) return;
|
||||
setLookupLoading(true);
|
||||
@@ -310,7 +314,7 @@ export default function WeiboCollabPage() {
|
||||
} finally {
|
||||
setLookupLoading(false);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const openCreate = () => {
|
||||
setEditing(null);
|
||||
@@ -325,6 +329,37 @@ export default function WeiboCollabPage() {
|
||||
setEditOpen(true);
|
||||
};
|
||||
|
||||
const transferAccountId = (
|
||||
location.state as { transferAccountId?: number } | null
|
||||
)?.transferAccountId;
|
||||
|
||||
useEffect(() => {
|
||||
if (!transferAccountId || transferHandledRef.current === transferAccountId) {
|
||||
return;
|
||||
}
|
||||
transferHandledRef.current = transferAccountId;
|
||||
setEditing(null);
|
||||
setLookup(null);
|
||||
form.resetFields();
|
||||
form.setFieldsValue({
|
||||
owner_id: owners[0]?.id,
|
||||
account_id: transferAccountId,
|
||||
required_weidou: 0,
|
||||
home_images: [],
|
||||
draft: false,
|
||||
});
|
||||
setEditOpen(true);
|
||||
void lookupAccount(transferAccountId);
|
||||
navigate(location.pathname, { replace: true, state: null });
|
||||
}, [
|
||||
form,
|
||||
location.pathname,
|
||||
lookupAccount,
|
||||
navigate,
|
||||
owners,
|
||||
transferAccountId,
|
||||
]);
|
||||
|
||||
const openEdit = (order: WeiboCollabOrder) => {
|
||||
setEditing(order);
|
||||
form.setFieldsValue({
|
||||
|
||||
Reference in New Issue
Block a user