fix(首页统计):优化剪辑管理订单号生成素材api
This commit is contained in:
@@ -7,11 +7,12 @@ import {
|
||||
QueryFilter,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
ModalForm,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Button, Space, Typography, Popconfirm, message, Tag, Tooltip } from 'antd';
|
||||
import { getEditTaskList, deleteEditTask } from '@/services/orders/api';
|
||||
import CreateForm from './components/CreateForm';
|
||||
import { getEditTaskList, deleteEditTask, generateEditTask } from '@/services/orders/api';
|
||||
import UpdateForm from './components/UpdateForm';
|
||||
import { request } from 'umi';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
@@ -24,7 +25,7 @@ const STATUS_OPTIONS = [
|
||||
];
|
||||
|
||||
// 状态颜色映射
|
||||
const statusColorMap = {
|
||||
const statusColorMap: { [key: number]: { color: string; text: string } } = {
|
||||
0: { color: 'default', text: '待处理' },
|
||||
1: { color: 'processing', text: '处理中' },
|
||||
2: { color: 'success', text: '处理完成' },
|
||||
@@ -76,6 +77,36 @@ const TableList: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// 新增:根据订单号生成建议任务
|
||||
const handleAdd = async (values: { orderSn: string }) => {
|
||||
if (!values.orderSn) {
|
||||
message.error('请输入订单编号');
|
||||
return false;
|
||||
}
|
||||
const hide = message.loading('正在根据订单号生成建议任务...');
|
||||
try {
|
||||
const res = await generateEditTask(values.orderSn);
|
||||
hide();
|
||||
if (res.resp_code === 0) {
|
||||
message.success('生成建议任务成功');
|
||||
return true;
|
||||
} else {
|
||||
message.error(res.resp_msg || '生成建议任务失败');
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
hide();
|
||||
message.error('生成建议任务失败');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// 修复handleEdit未定义
|
||||
const handleEdit = async (record: ORDERS.EditTask, values: Partial<ORDERS.EditTask>) => {
|
||||
// 这里保留原有编辑逻辑,如需自定义可补充
|
||||
return false;
|
||||
};
|
||||
|
||||
// 表格操作处理
|
||||
const handleTableAction = useCallback(async (
|
||||
action: 'add' | 'edit' | 'delete',
|
||||
@@ -85,7 +116,7 @@ const TableList: React.FC = () => {
|
||||
let success = false;
|
||||
switch (action) {
|
||||
case 'add':
|
||||
success = await handleAdd(values as ORDERS.EditTask);
|
||||
success = await handleAdd(values as { orderSn: string });
|
||||
success && handleModalVisible(false);
|
||||
break;
|
||||
case 'edit':
|
||||
@@ -104,6 +135,7 @@ const TableList: React.FC = () => {
|
||||
if (success && actionRef.current) {
|
||||
actionRef.current.reload();
|
||||
}
|
||||
return success;
|
||||
}, []);
|
||||
|
||||
// 修改 request 处理方式
|
||||
@@ -227,8 +259,12 @@ const TableList: React.FC = () => {
|
||||
修改
|
||||
</Link>
|
||||
<Popconfirm
|
||||
title={`确认删除该剪辑任务?`}
|
||||
description="删除后将无法恢复,请谨慎操作"
|
||||
title={
|
||||
<span>
|
||||
确认删除该剪辑任务?<br />
|
||||
<span style={{ color: 'red' }}>删除后将无法恢复,请谨慎操作</span>
|
||||
</span>
|
||||
}
|
||||
onConfirm={() => handleTableAction('delete', record)}
|
||||
>
|
||||
<Link>删除</Link>
|
||||
@@ -245,7 +281,7 @@ const TableList: React.FC = () => {
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
onFinish={setParams}
|
||||
onFinish={async (formData) => { setParams(formData); return true; }}
|
||||
>
|
||||
<ProFormText
|
||||
name="orderSn"
|
||||
@@ -292,11 +328,27 @@ const TableList: React.FC = () => {
|
||||
overflow: 'auto',
|
||||
}}
|
||||
/>
|
||||
<CreateForm
|
||||
<ModalForm
|
||||
title="新增剪辑任务"
|
||||
visible={createModalVisible}
|
||||
onVisibleChange={handleModalVisible}
|
||||
onSubmit={async (values) => handleTableAction('add', undefined, values)}
|
||||
/>
|
||||
modalProps={{ destroyOnClose: true }}
|
||||
onFinish={async (values) => {
|
||||
const success = await handleAdd(values as { orderSn: string });
|
||||
if (success) {
|
||||
handleModalVisible(false);
|
||||
actionRef.current?.reload();
|
||||
}
|
||||
return success;
|
||||
}}
|
||||
>
|
||||
<ProFormText
|
||||
name="orderSn"
|
||||
label="订单编号"
|
||||
placeholder="请输入订单编号"
|
||||
rules={[{ required: true, message: '请输入订单编号' }]}
|
||||
/>
|
||||
</ModalForm>
|
||||
<UpdateForm
|
||||
updateModalVisible={updateModalVisible}
|
||||
onVisibleChange={handleUpdateModalVisible}
|
||||
|
||||
@@ -432,4 +432,12 @@ export async function updateExpiredCoupons() {
|
||||
method: 'POST',
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// 根据订单号生成建议剪辑任务
|
||||
export async function generateEditTask(orderNo: string) {
|
||||
return request<API.Result<string>>('/api-order/auto/cut/generate', {
|
||||
method: 'POST',
|
||||
params: { orderNo },
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user