@@ -3,6 +3,16 @@
|
|||||||
|
|
||||||
<mapper namespace="com.central.device.mapper.AgeDeviceMapper">
|
<mapper namespace="com.central.device.mapper.AgeDeviceMapper">
|
||||||
<select id="findList" resultType="com.central.device.model.AgeDevice">
|
<select id="findList" resultType="com.central.device.model.AgeDevice">
|
||||||
select * from manage_device t
|
select * from manage_device t where 1=1
|
||||||
|
<if test="p.deviceName != null and p.deviceName != ''">
|
||||||
|
and t.device_name like concat('%', #{p.deviceName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="p.deviceSn != null and p.deviceSn != ''">
|
||||||
|
and t.device_sn = #{p.deviceSn}
|
||||||
|
</if>
|
||||||
|
<if test="p.deviceType != null and p.deviceType != ''">
|
||||||
|
and t.device_type = #{p.deviceType}
|
||||||
|
</if>
|
||||||
|
order by t.id desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
+4
-4
@@ -58,7 +58,7 @@ public class AutoCutVideoController {
|
|||||||
// 1. 验证订单状态
|
// 1. 验证订单状态
|
||||||
Order order = orderService.getOrderByNumber(orderNo);
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
if (order == null || !OrderStatus.isValidForEdit(order.getOrderStatus())) {
|
if (order == null || !OrderStatus.isValidForEdit(order.getOrderStatus())) {
|
||||||
return Result.failed("订单状态不允许生成视频");
|
return Result.failed("订单状态不允许生成剪辑视频");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检查是否开启一键成片
|
// 1. 检查是否开启一键成片
|
||||||
@@ -204,7 +204,7 @@ public class AutoCutVideoController {
|
|||||||
|
|
||||||
@Operation(summary = "获取剪辑任务列表")
|
@Operation(summary = "获取剪辑任务列表")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<PageResult<EditTask>> getTaskList(
|
public PageResult<EditTask> getTaskList(
|
||||||
@RequestParam(defaultValue = "1") Integer page,
|
@RequestParam(defaultValue = "1") Integer page,
|
||||||
@RequestParam(defaultValue = "10") Integer limit,
|
@RequestParam(defaultValue = "10") Integer limit,
|
||||||
@RequestParam(required = false) String orderSn,
|
@RequestParam(required = false) String orderSn,
|
||||||
@@ -220,11 +220,11 @@ public class AutoCutVideoController {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
PageResult<EditTask> result = editTaskService.getTaskList(params);
|
PageResult<EditTask> result = editTaskService.getTaskList(params);
|
||||||
return Result.succeed(result);
|
return result;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("查询剪辑任务列表失败", e);
|
log.error("查询剪辑任务列表失败", e);
|
||||||
return Result.failed("查询任务列表失败");
|
return new PageResult<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.service.impl.SuperServiceImpl;
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
|
import com.central.common.utils.StringUtils;
|
||||||
import com.central.order.mapper.VideoTemplateMapper;
|
import com.central.order.mapper.VideoTemplateMapper;
|
||||||
import com.central.order.model.VideoTemplate;
|
import com.central.order.model.VideoTemplate;
|
||||||
import com.central.order.service.IVideoTemplateService;
|
import com.central.order.service.IVideoTemplateService;
|
||||||
@@ -26,7 +27,15 @@ public class VideoTemplateServiceImpl extends SuperServiceImpl<VideoTemplateMapp
|
|||||||
LambdaQueryWrapper<VideoTemplate> wrapper = new LambdaQueryWrapper<VideoTemplate>()
|
LambdaQueryWrapper<VideoTemplate> wrapper = new LambdaQueryWrapper<VideoTemplate>()
|
||||||
.eq(VideoTemplate::getIsDel, 0)
|
.eq(VideoTemplate::getIsDel, 0)
|
||||||
.orderByDesc(VideoTemplate::getCreateTime);
|
.orderByDesc(VideoTemplate::getCreateTime);
|
||||||
|
if(StringUtils.isNotEmpty(MapUtils.getString(params,"templateName"))){
|
||||||
|
wrapper.like(VideoTemplate::getTemplateName,MapUtils.getString(params,"templateName"));
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotEmpty(MapUtils.getString(params,"templateId"))){
|
||||||
|
wrapper.eq(VideoTemplate::getTemplateId,MapUtils.getString(params,"templateId"));
|
||||||
|
}
|
||||||
|
if((MapUtils.getInteger(params,"status"))!=null ){
|
||||||
|
wrapper.eq(VideoTemplate::getStatus,MapUtils.getString(params,"status"));
|
||||||
|
}
|
||||||
Page<VideoTemplate> result = baseMapper.selectPage(page, wrapper);
|
Page<VideoTemplate> result = baseMapper.selectPage(page, wrapper);
|
||||||
return PageResult.<VideoTemplate>builder().data(result.getRecords()).count(result.getTotal()).build();
|
return PageResult.<VideoTemplate>builder().data(result.getRecords()).count(result.getTotal()).build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,13 @@ const DeviceForm: React.FC<DeviceFormProps> = ({ title, visible, onVisibleChange
|
|||||||
const formRef = useRef<any>();
|
const formRef = useRef<any>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (initialValues) formRef.current?.setFieldsValue(initialValues);
|
if (visible && initialValues) {
|
||||||
}, [initialValues]);
|
// 延迟设置,确保表单已经渲染
|
||||||
|
setTimeout(() => {
|
||||||
|
formRef.current?.setFieldsValue(initialValues);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}, [visible, initialValues]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm<DeviceFormValues>
|
<ModalForm<DeviceFormValues>
|
||||||
@@ -40,6 +45,7 @@ const DeviceForm: React.FC<DeviceFormProps> = ({ title, visible, onVisibleChange
|
|||||||
onVisibleChange={onVisibleChange}
|
onVisibleChange={onVisibleChange}
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
|
initialValues={initialValues} // 同时设置 initialValues 属性
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText name="deviceSn" label="设备序列号" rules={[{ required: true, message: '请输入设备序列号' }]} width="md" />
|
<ProFormText name="deviceSn" label="设备序列号" rules={[{ required: true, message: '请输入设备序列号' }]} width="md" />
|
||||||
@@ -47,7 +53,7 @@ const DeviceForm: React.FC<DeviceFormProps> = ({ title, visible, onVisibleChange
|
|||||||
<ProFormText name="nickname" label="昵称" width="md" />
|
<ProFormText name="nickname" label="昵称" width="md" />
|
||||||
<ProFormSelect name="deviceType" label="设备类型" options={DEVICE_TYPE_OPTIONS} width="md" />
|
<ProFormSelect name="deviceType" label="设备类型" options={DEVICE_TYPE_OPTIONS} width="md" />
|
||||||
<ProFormText name="firmwareVersion" label="固件版本" width="md" />
|
<ProFormText name="firmwareVersion" label="固件版本" width="md" />
|
||||||
<ProFormTextArea name="remark" label="备注" width="lg" />
|
<ProFormTextArea name="deviceDesc" label="备注" width="lg" />
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
import React, { forwardRef, useImperativeHandle, useRef, useEffect } from 'react';
|
||||||
import { ProTable } from '@ant-design/pro-components';
|
import { ProTable } from '@ant-design/pro-components';
|
||||||
import type { ProColumns, ActionType } from '@ant-design/pro-components';
|
import type { ProColumns, ActionType } from '@ant-design/pro-components';
|
||||||
import { Space, Switch } from 'antd';
|
import { Space } from 'antd';
|
||||||
import { deviceApi } from '@/services/device';
|
import { deviceApi } from '@/services/device';
|
||||||
|
|
||||||
export interface DeviceTableRef { reload: () => void }
|
export interface DeviceTableRef { reload: () => void }
|
||||||
@@ -16,14 +16,36 @@ const DeviceTable = forwardRef<DeviceTableRef, DeviceTableProps>(({ params, onEd
|
|||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
useImperativeHandle(ref, () => ({ reload: () => actionRef.current?.reload() }));
|
useImperativeHandle(ref, () => ({ reload: () => actionRef.current?.reload() }));
|
||||||
|
|
||||||
|
// 当查询参数变化时,自动重置到第一页
|
||||||
|
useEffect(() => {
|
||||||
|
if (actionRef.current) {
|
||||||
|
// 重置页码到第一页
|
||||||
|
actionRef.current.setPageInfo?.({ current: 1 });
|
||||||
|
// 重新加载数据
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}, [JSON.stringify(params)]); // 使用JSON.stringify确保对象内容变化时触发
|
||||||
|
|
||||||
|
// 设备类型映射
|
||||||
|
const deviceTypeMap: Record<number, string> = {
|
||||||
|
1: '机场',
|
||||||
|
2: '无人机',
|
||||||
|
3: '遥控器',
|
||||||
|
};
|
||||||
|
|
||||||
const columns: ProColumns<any>[] = [
|
const columns: ProColumns<any>[] = [
|
||||||
{ dataIndex: 'index', valueType: 'indexBorder', width: 48, fixed: 'left' },
|
{ dataIndex: 'index', valueType: 'indexBorder', width: 48, fixed: 'left' },
|
||||||
{ title: '设备序列号', dataIndex: 'deviceSn', copyable: true, fixed: 'left', width: 160 },
|
{ title: '设备序列号', dataIndex: 'deviceSn', copyable: true, fixed: 'left', width: 160 },
|
||||||
{ title: '设备名称', dataIndex: 'deviceName' },
|
{ title: '设备名称', dataIndex: 'deviceName' },
|
||||||
{ title: '昵称', dataIndex: 'nickname' },
|
{ title: '昵称', dataIndex: 'nickname' },
|
||||||
{ title: '设备类型', dataIndex: 'deviceType' },
|
{
|
||||||
{ title: '固件版本', dataIndex: 'firmwareVersion' },
|
title: '设备类型',
|
||||||
{ title: '绑定状态', dataIndex: 'boundStatus', render: (_, r) => <Switch checked={r.boundStatus === 1} disabled /> },
|
dataIndex: 'deviceType',
|
||||||
|
render: (_, record) => deviceTypeMap[record.deviceType] || record.deviceType
|
||||||
|
},
|
||||||
|
{ title: '备注', dataIndex: 'deviceDesc' },
|
||||||
|
// { title: '固件版本', dataIndex: 'firmwareVersion' }, // 隐藏固件版本
|
||||||
|
// { title: '绑定状态', dataIndex: 'boundStatus', render: (_, r) => <Switch checked={r.boundStatus === 1} disabled /> }, // 隐藏绑定状态
|
||||||
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
|
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
|
||||||
{
|
{
|
||||||
title: '操作', key: 'action', valueType: 'option', width: 140, fixed: 'right',
|
title: '操作', key: 'action', valueType: 'option', width: 140, fixed: 'right',
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const DevicePage: React.FC = () => {
|
|||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
const hide = message.loading('正在删除...');
|
const hide = message.loading('正在删除...');
|
||||||
try {
|
try {
|
||||||
await deviceApi.deleteDevice(record.deviceSn);
|
await deviceApi.deleteDevice(record.id);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
tableRef.current?.reload();
|
tableRef.current?.reload();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -64,12 +64,12 @@ const DevicePage: React.FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ title: '设备管理' }}>
|
<PageContainer header={{ title: '设备管理' }}>
|
||||||
<SearchBarPlus defaultCollapsed split span={6} onTenantChanged={() => tableRef.current?.reload()} onFinish={async (values) => setQuery(values)}>
|
<SearchBarPlus defaultCollapsed split span={6} onTenantChanged={() => tableRef.current?.reload()} showTenant={false} onFinish={async (values) => setQuery(values)}>
|
||||||
<ProFormText name="deviceSn" label="设备序列号" />
|
<ProFormText name="deviceSn" label="设备序列号" />
|
||||||
<ProFormText name="deviceName" label="设备名称" />
|
<ProFormText name="deviceName" label="设备名称" />
|
||||||
<ProFormSelect name="deviceType" label="设备类型" options={[
|
<ProFormSelect name="deviceType" label="设备类型" options={[
|
||||||
{ label: '无人机', value: 1 },
|
{ label: '机场', value: 1 },
|
||||||
{ label: '地面站', value: 2 },
|
{ label: '无人机', value: 2 },
|
||||||
{ label: '遥控器', value: 3 },
|
{ label: '遥控器', value: 3 },
|
||||||
]} />
|
]} />
|
||||||
</SearchBarPlus>
|
</SearchBarPlus>
|
||||||
@@ -86,7 +86,16 @@ const DevicePage: React.FC = () => {
|
|||||||
</GlassCard>
|
</GlassCard>
|
||||||
|
|
||||||
<DeviceForm title="新增设备" visible={createOpen} onVisibleChange={setCreateOpen} onFinish={add} />
|
<DeviceForm title="新增设备" visible={createOpen} onVisibleChange={setCreateOpen} onFinish={add} />
|
||||||
<DeviceForm title="编辑设备" visible={editOpen} onVisibleChange={setEditOpen} onFinish={edit} initialValues={current || {}} />
|
<DeviceForm
|
||||||
|
title="编辑设备"
|
||||||
|
visible={editOpen}
|
||||||
|
onVisibleChange={(v) => {
|
||||||
|
setEditOpen(v);
|
||||||
|
if (!v) setCurrent(null); // 关闭时清空当前编辑数据
|
||||||
|
}}
|
||||||
|
onFinish={edit}
|
||||||
|
initialValues={current || {}}
|
||||||
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,6 +22,18 @@ interface WaylineFormProps {
|
|||||||
initialValues?: Partial<WaylineFormValues>;
|
initialValues?: Partial<WaylineFormValues>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验文件名是否合法
|
||||||
|
* 只允许字母、数字和下划线
|
||||||
|
*/
|
||||||
|
function validateFileName(fileName: string): boolean {
|
||||||
|
// 获取不带扩展名的文件名
|
||||||
|
const nameWithoutExtension = fileName.substring(0, fileName.lastIndexOf('.')) || fileName;
|
||||||
|
// 正则表达式:只允许字母、数字和下划线
|
||||||
|
const regex = /^[a-zA-Z0-9_]+$/;
|
||||||
|
return regex.test(nameWithoutExtension);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算文件的 MD5 值
|
* 计算文件的 MD5 值
|
||||||
*/
|
*/
|
||||||
@@ -127,6 +139,13 @@ const WaylineForm: React.FC<WaylineFormProps> = ({ title, visible, onVisibleChan
|
|||||||
customRequest={async ({ file, onSuccess, onError }) => {
|
customRequest={async ({ file, onSuccess, onError }) => {
|
||||||
try {
|
try {
|
||||||
if (file instanceof File) {
|
if (file instanceof File) {
|
||||||
|
// 校验文件名
|
||||||
|
if (!validateFileName(file.name)) {
|
||||||
|
message.error('文件名不合法!只允许使用字母、数字和下划线');
|
||||||
|
onError?.(new Error('文件名不合法'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 计算文件 MD5
|
// 计算文件 MD5
|
||||||
const md5 = await calculateFileMD5(file);
|
const md5 = await calculateFileMD5(file);
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,129 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import { PageContainer, ProFormText, ProTable, ProFormSelect } from '@ant-design/pro-components';
|
import { PageContainer, ProFormText, ProTable, ProFormSelect, ProFormTextArea, ActionType, ModalForm, ProForm } from '@ant-design/pro-components';
|
||||||
import { Popconfirm, Space, message } from 'antd';
|
import { Popconfirm, Space, message, Modal } from 'antd';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
|
||||||
import { ordersApi } from '@/services/orders';
|
import { ordersApi } from '@/services/orders';
|
||||||
import { ActionBar, GradientButton, SearchBarPlus } from '@/components/ui';
|
import { SearchBarPlus, GlassCard } from '@/components/ui';
|
||||||
|
|
||||||
const EditTaskPage: React.FC = () => {
|
const EditTaskPage: React.FC = () => {
|
||||||
const [params, setParams] = useState<Record<string, any>>({});
|
const [params, setParams] = useState<Record<string, any>>({});
|
||||||
|
const [editVisible, setEditVisible] = useState(false);
|
||||||
|
const [currentTask, setCurrentTask] = useState<any>(null);
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
|
|
||||||
|
// 当查询参数变化时,自动重置到第一页
|
||||||
|
useEffect(() => {
|
||||||
|
if (actionRef.current) {
|
||||||
|
// 重置页码到第一页
|
||||||
|
actionRef.current.setPageInfo?.({ current: 1 });
|
||||||
|
// 重新加载数据
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}, [JSON.stringify(params)]); // 使用JSON.stringify确保对象内容变化时触发
|
||||||
|
|
||||||
|
// 处理创建编辑任务
|
||||||
|
const handleGenerateEditTask = async (orderSn: string) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认创建编辑任务',
|
||||||
|
content: `确定为订单 ${orderSn} 创建编辑任务吗?`,
|
||||||
|
onOk: async () => {
|
||||||
|
const hide = message.loading('正在创建编辑任务...');
|
||||||
|
try {
|
||||||
|
// 直接传递 orderSn 字符串,或根据实际 API 需要调整参数格式
|
||||||
|
const result = await ordersApi.generateEditTask(orderSn as any);
|
||||||
|
|
||||||
|
// 检查响应结果
|
||||||
|
if (result && result.resp_code === 0) {
|
||||||
|
message.success('编辑任务创建成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
|
} else {
|
||||||
|
// 显示后端返回的错误信息
|
||||||
|
message.error(result?.resp_msg || '创建编辑任务失败');
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
// 处理异常情况
|
||||||
|
message.error(error?.message || '创建编辑任务失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理编辑
|
||||||
|
const handleEdit = async (values: any) => {
|
||||||
|
const hide = message.loading('正在保存...');
|
||||||
|
try {
|
||||||
|
await ordersApi.saveOrUpdateEditTask({
|
||||||
|
...currentTask,
|
||||||
|
...values,
|
||||||
|
});
|
||||||
|
message.success('修改成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
message.error('修改失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const columns: any[] = [
|
const columns: any[] = [
|
||||||
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
|
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
|
||||||
{ title: '任务ID', dataIndex: 'id' },
|
{ title: '任务ID', dataIndex: 'id', width: 120 },
|
||||||
{ title: '订单号', dataIndex: 'orderNo' },
|
{ title: '用户ID', dataIndex: 'userId', width: 120 },
|
||||||
{ title: '状态', dataIndex: 'status' },
|
{ title: '订单号', dataIndex: 'orderSn', width: 180, copyable: true },
|
||||||
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime' },
|
{ title: '任务id', dataIndex: 'jobId', width: 180, copyable: true },
|
||||||
{
|
{
|
||||||
title: '操作', key: 'action',
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 120,
|
||||||
|
valueEnum: {
|
||||||
|
0: { text: '待处理', status: 'Default' },
|
||||||
|
1: { text: '处理中', status: 'Processing' },
|
||||||
|
2: { text: '完成', status: 'Success' },
|
||||||
|
3: { text: '失败', status: 'Error' },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
|
||||||
|
{ title: '更新时间', dataIndex: 'updateTime', valueType: 'dateTime', width: 180 },
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
width: 240,
|
||||||
render: (_: any, record: any) => (
|
render: (_: any, record: any) => (
|
||||||
<Space>
|
<Space>
|
||||||
<Popconfirm title="确认删除?" onConfirm={async () => { try { await ordersApi.deleteEditTask(record.id); message.success('删除成功'); } catch { message.error('删除失败'); } }}>
|
<a onClick={() => {
|
||||||
<a style={{ color: '#1677ff' }}>删除</a>
|
setCurrentTask(record);
|
||||||
|
setEditVisible(true);
|
||||||
|
}}>
|
||||||
|
编辑
|
||||||
|
</a>
|
||||||
|
{/* 只有状态为3(失败)时显示创建编辑任务按钮 */}
|
||||||
|
{record.status === 3 && (
|
||||||
|
<a
|
||||||
|
style={{ color: '#52c41a' }}
|
||||||
|
onClick={() => handleGenerateEditTask(record.orderSn)}
|
||||||
|
>
|
||||||
|
创建编辑任务
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
<Popconfirm
|
||||||
|
title="确认删除?"
|
||||||
|
onConfirm={async () => {
|
||||||
|
const hide = message.loading('正在删除...');
|
||||||
|
try {
|
||||||
|
await ordersApi.deleteEditTask(record.id);
|
||||||
|
message.success('删除成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
|
} catch {
|
||||||
|
message.error('删除失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<a style={{ color: '#ff4d4f' }}>删除</a>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
</Space>
|
</Space>
|
||||||
)
|
)
|
||||||
@@ -27,39 +131,114 @@ const EditTaskPage: React.FC = () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ title: '剪辑任务' }}>
|
<PageContainer header={{ title: '剪辑任务管理' }}>
|
||||||
<SearchBarPlus
|
<SearchBarPlus
|
||||||
defaultCollapsed={false}
|
defaultCollapsed={false}
|
||||||
split
|
split
|
||||||
span={8}
|
span={8}
|
||||||
onTenantChanged={() => { /* 后端上下文 */ }}
|
showTenant={false}
|
||||||
onFinish={async (values) => setParams(values)}
|
onTenantChanged={() => actionRef.current?.reload()}
|
||||||
|
onFinish={async (values) => {
|
||||||
|
setParams(values);
|
||||||
|
// useEffect 会自动触发重置页码并刷新
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ProFormText name="orderNo" label="订单号" />
|
<ProFormText
|
||||||
<ProFormSelect name="status" label="状态" valueEnum={{ pending: '待处理', processing: '处理中', done: '完成' }} />
|
name="orderSn"
|
||||||
|
label="订单号"
|
||||||
|
placeholder="请输入订单号"
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
options={[
|
||||||
|
{ label: '待处理', value: 0 },
|
||||||
|
{ label: '处理中', value: 1 },
|
||||||
|
{ label: '完成', value: 2 },
|
||||||
|
{ label: '失败', value: 3 }
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</SearchBarPlus>
|
</SearchBarPlus>
|
||||||
|
|
||||||
<ActionBar
|
<GlassCard>
|
||||||
left={
|
<ProTable<any>
|
||||||
<Space>
|
rowKey="id"
|
||||||
<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={async () => {
|
actionRef={actionRef}
|
||||||
const hide = message.loading('提交中...');
|
request={async (p) => {
|
||||||
try { await ordersApi.saveOrUpdateEditTask({ orderNo: 'DEMO' }); message.success('新增成功'); } catch { message.error('新增失败'); } finally { hide(); }
|
const { current, pageSize, ...rest } = p;
|
||||||
}}>新增</GradientButton>
|
const result = await ordersApi.getEditTaskList({
|
||||||
</Space>
|
page: current,
|
||||||
}
|
limit: pageSize,
|
||||||
/>
|
...params,
|
||||||
|
...rest
|
||||||
|
} as any);
|
||||||
|
return {
|
||||||
|
data: result.data || [],
|
||||||
|
success: true,
|
||||||
|
total: result.total || 0,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true
|
||||||
|
}}
|
||||||
|
headerTitle="剪辑任务列表"
|
||||||
|
/>
|
||||||
|
</GlassCard>
|
||||||
|
|
||||||
<ProTable<any>
|
{/* 编辑表单 */}
|
||||||
rowKey="id"
|
<ModalForm
|
||||||
request={(p) => ordersApi.getEditTaskList({ ...p, ...params } as any)}
|
title="编辑剪辑任务"
|
||||||
columns={columns}
|
visible={editVisible}
|
||||||
search={false}
|
onVisibleChange={(v) => {
|
||||||
pagination={{ showSizeChanger: true, showQuickJumper: true }}
|
setEditVisible(v);
|
||||||
/>
|
if (!v) setCurrentTask(null);
|
||||||
|
}}
|
||||||
|
onFinish={handleEdit}
|
||||||
|
initialValues={currentTask}
|
||||||
|
modalProps={{
|
||||||
|
destroyOnClose: true,
|
||||||
|
maskClosable: false,
|
||||||
|
}}
|
||||||
|
width={600}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
name="orderSn"
|
||||||
|
label="订单号"
|
||||||
|
width="md"
|
||||||
|
disabled
|
||||||
|
placeholder="订单号"
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
width="md"
|
||||||
|
options={[
|
||||||
|
{ label: '待处理', value: 0 },
|
||||||
|
{ label: '处理中', value: 1 },
|
||||||
|
{ label: '完成', value: 2 },
|
||||||
|
{ label: '失败', value: 3 },
|
||||||
|
]}
|
||||||
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
<ProFormTextArea
|
||||||
|
name="remark"
|
||||||
|
label="备注"
|
||||||
|
placeholder="请输入备注信息"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 4,
|
||||||
|
maxLength: 500,
|
||||||
|
showCount: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ModalForm>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EditTaskPage;
|
export default EditTaskPage;
|
||||||
|
|
||||||
|
|||||||
@@ -63,11 +63,11 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
|
|
||||||
// 景区素材类型字典(按业务提供)
|
// 景区素材类型字典(按业务提供)
|
||||||
const TYPE_LABEL: Record<number, string> = {
|
const TYPE_LABEL: Record<number, string> = {
|
||||||
5: '视频',
|
5: '景区视频',
|
||||||
6: '首页 Banner',
|
6: '景区订单展示图',
|
||||||
4: '展示图片',
|
4: '展示大图',
|
||||||
3: '景区详情',
|
3: '拍照引导图',
|
||||||
2: '景区小图展示',
|
2: '拍照角度展示图',
|
||||||
1: '活动',
|
1: '活动',
|
||||||
};
|
};
|
||||||
const typeName = (t: any) => TYPE_LABEL[Number(t)] || '其他';
|
const typeName = (t: any) => TYPE_LABEL[Number(t)] || '其他';
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ export interface TourismItem {
|
|||||||
longitude?: string;
|
longitude?: string;
|
||||||
latitude?: string;
|
latitude?: string;
|
||||||
showInHomepage?: number; // 1 是,0 否
|
showInHomepage?: number; // 1 是,0 否
|
||||||
description?: string;
|
tourismDesc?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TourismFormProps {
|
export interface TourismFormProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
initialValues?: Partial<TourismItem>;
|
initialValues?: Partial<TourismItem>;
|
||||||
onOpenChange: (v: boolean) => void;
|
onOpenChange: (v: boolean) => void;
|
||||||
onFinish: (values: TourismItem) => Promise<boolean>;
|
onFinish: (values: TourismItem) => Promise<boolean>;
|
||||||
@@ -64,7 +65,7 @@ const TourismForm: React.FC<TourismFormProps> = ({ open, title, initialValues, o
|
|||||||
]}
|
]}
|
||||||
initialValue={1}
|
initialValue={1}
|
||||||
/>
|
/>
|
||||||
<ProFormTextArea name="description" label="描述" />
|
<ProFormTextArea name="tourismDesc" label="描述" />
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ export interface TourismFileFormProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TYPE_OPTIONS = [
|
const TYPE_OPTIONS = [
|
||||||
{ label: '视频', value: 5 },
|
{ label: '景区视频', value: 5 },
|
||||||
{ label: '首页 Banner', value: 6 },
|
{ label: '景区订单展示图', value: 6 },
|
||||||
{ label: '展示图片', value: 4 },
|
{ label: '展示大图', value: 4 },
|
||||||
{ label: '景区详情', value: 3 },
|
{ label: '拍照引导图', value: 3 },
|
||||||
{ label: '景区小图展示', value: 2 },
|
{ label: '拍照角度展示图', value: 2 },
|
||||||
{ label: '活动', value: 1 },
|
{ label: '活动', value: 1 },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import TourismFileForm, { TourismFileItem } from './components/TourismFileForm';
|
|||||||
|
|
||||||
// 资源类型枚举(用于卡片展示的颜色)
|
// 资源类型枚举(用于卡片展示的颜色)
|
||||||
const TYPE_OPTIONS = [
|
const TYPE_OPTIONS = [
|
||||||
{ label: '视频', value: 5, color: '#f5222d' },
|
{ label: '景区视频', value: 5, color: '#f5222d' },
|
||||||
{ label: '首页 Banner', value: 6, color: '#2f54eb' },
|
{ label: '景区订单展示图', value: 6, color: '#2f54eb' },
|
||||||
{ label: '展示图片', value: 4, color: '#52c41a' },
|
{ label: '展示大图', value: 4, color: '#52c41a' },
|
||||||
{ label: '景区详情', value: 3, color: '#722ed1' },
|
{ label: '拍照引导图', value: 3, color: '#722ed1' },
|
||||||
{ label: '景区小图展示', value: 2, color: '#13c2c2' },
|
{ label: '拍照角度展示图', value: 2, color: '#13c2c2' },
|
||||||
{ label: '活动', value: 1, color: '#1890ff' },
|
{ label: '活动', value: 1, color: '#1890ff' },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|||||||
+182
@@ -0,0 +1,182 @@
|
|||||||
|
import React, { useEffect, useRef } from 'react';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormText,
|
||||||
|
ProFormTextArea,
|
||||||
|
ProFormSelect,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import { ordersApi } from '@/services/orders';
|
||||||
|
|
||||||
|
export const STATUS_OPTIONS = [
|
||||||
|
{ label: '启用', value: 1 },
|
||||||
|
{ label: '禁用', value: 0 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export type VideoTemplateFormValues = {
|
||||||
|
id?: number;
|
||||||
|
templateId?: string;
|
||||||
|
templateName?: string;
|
||||||
|
name?: string; // 兼容旧字段
|
||||||
|
description?: string;
|
||||||
|
config?: string;
|
||||||
|
status?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface VideoTemplateFormProps {
|
||||||
|
title: string;
|
||||||
|
visible: boolean;
|
||||||
|
onVisibleChange: (visible: boolean) => void;
|
||||||
|
onFinish: (values: VideoTemplateFormValues) => Promise<boolean>;
|
||||||
|
initialValues?: Partial<VideoTemplateFormValues>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VideoTemplateForm: React.FC<VideoTemplateFormProps> = ({
|
||||||
|
title,
|
||||||
|
visible,
|
||||||
|
onVisibleChange,
|
||||||
|
onFinish,
|
||||||
|
initialValues,
|
||||||
|
}) => {
|
||||||
|
const formRef = useRef<any>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (visible && initialValues) {
|
||||||
|
// 延迟设置,确保表单已经渲染
|
||||||
|
setTimeout(() => {
|
||||||
|
// 处理字段兼容性
|
||||||
|
const values = {
|
||||||
|
...initialValues,
|
||||||
|
templateName: initialValues.templateName || initialValues.name,
|
||||||
|
config: initialValues.config || '{}', // 确保config有默认值
|
||||||
|
};
|
||||||
|
formRef.current?.setFieldsValue(values);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}, [visible, initialValues]);
|
||||||
|
|
||||||
|
const handleFinish = async (values: VideoTemplateFormValues) => {
|
||||||
|
try {
|
||||||
|
// 确保兼容性
|
||||||
|
const submitValues = {
|
||||||
|
...values,
|
||||||
|
name: values.templateName, // 同时设置name字段
|
||||||
|
};
|
||||||
|
const result = await onFinish(submitValues);
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
message.error('操作失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalForm<VideoTemplateFormValues>
|
||||||
|
title={title}
|
||||||
|
width={800}
|
||||||
|
visible={visible}
|
||||||
|
formRef={formRef}
|
||||||
|
onVisibleChange={onVisibleChange}
|
||||||
|
onFinish={handleFinish}
|
||||||
|
initialValues={{
|
||||||
|
status: 1, // 默认启用
|
||||||
|
config: '{}', // 默认空JSON对象
|
||||||
|
...initialValues,
|
||||||
|
}}
|
||||||
|
modalProps={{
|
||||||
|
destroyOnClose: true,
|
||||||
|
maskClosable: false,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group title="基本信息">
|
||||||
|
<ProFormText
|
||||||
|
name="templateId"
|
||||||
|
label="模板ID"
|
||||||
|
width="md"
|
||||||
|
placeholder="请输入模板ID"
|
||||||
|
rules={[
|
||||||
|
{ required: true, message: '请输入模板ID' },
|
||||||
|
{
|
||||||
|
pattern: /^[a-zA-Z0-9_-]+$/,
|
||||||
|
message: '模板ID只能包含字母、数字、下划线和横线'
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
name="templateName"
|
||||||
|
label="模板名称"
|
||||||
|
width="md"
|
||||||
|
placeholder="请输入模板名称"
|
||||||
|
rules={[
|
||||||
|
{ required: true, message: '请输入模板名称' },
|
||||||
|
{ max: 50, message: '模板名称不能超过50个字符' }
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
width="md"
|
||||||
|
options={STATUS_OPTIONS}
|
||||||
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group title="详细配置">
|
||||||
|
<ProFormTextArea
|
||||||
|
name="description"
|
||||||
|
label="模板描述"
|
||||||
|
width="xl"
|
||||||
|
placeholder="请输入模板描述"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 4,
|
||||||
|
maxLength: 200,
|
||||||
|
showCount: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormTextArea
|
||||||
|
name="config"
|
||||||
|
label="模板配置"
|
||||||
|
width="xl"
|
||||||
|
placeholder='请输入JSON格式的模板配置,例如: {"key": "value"}'
|
||||||
|
tooltip="请输入有效的JSON格式配置,默认为空对象 {}"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 8,
|
||||||
|
maxLength: 2000,
|
||||||
|
showCount: true,
|
||||||
|
style: { fontFamily: 'monospace' },
|
||||||
|
onBlur: (e) => {
|
||||||
|
// 格式化JSON
|
||||||
|
const value = e.target.value;
|
||||||
|
if (value) {
|
||||||
|
try {
|
||||||
|
const json = JSON.parse(value);
|
||||||
|
const formatted = JSON.stringify(json, null, 2);
|
||||||
|
formRef.current?.setFieldValue('config', formatted);
|
||||||
|
} catch (error) {
|
||||||
|
// 格式化失败,保持原样
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
rules={[
|
||||||
|
{ required: true, message: '请输入模板配置' },
|
||||||
|
{
|
||||||
|
validator: async (_, value) => {
|
||||||
|
if (value) {
|
||||||
|
try {
|
||||||
|
JSON.parse(value);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error('请输入有效的JSON格式');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default VideoTemplateForm;
|
||||||
+188
@@ -0,0 +1,188 @@
|
|||||||
|
import React, { forwardRef, useImperativeHandle, useRef, useEffect } from 'react';
|
||||||
|
import { ProTable } from '@ant-design/pro-components';
|
||||||
|
import type { ProColumns, ActionType } from '@ant-design/pro-components';
|
||||||
|
import { Space, Tag, Typography, Modal, message } from 'antd';
|
||||||
|
import { ordersApi } from '@/services/orders';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
export interface VideoTemplateTableRef {
|
||||||
|
reload: () => void;
|
||||||
|
reloadAndReset: () => void; // 重新加载并重置页码
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VideoTemplateTableProps {
|
||||||
|
params?: Record<string, any>;
|
||||||
|
onEdit?: (record: any) => void;
|
||||||
|
onStatusChange?: (record: any, status: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VideoTemplateTable = forwardRef<VideoTemplateTableRef, VideoTemplateTableProps>(
|
||||||
|
({ params, onEdit, onStatusChange }, ref) => {
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
|
|
||||||
|
useImperativeHandle(ref, () => ({
|
||||||
|
reload: () => actionRef.current?.reload(),
|
||||||
|
reloadAndReset: () => {
|
||||||
|
// 重置到第一页并重新加载
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.setPageInfo?.({ current: 1 });
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 当查询参数变化时,自动重置到第一页
|
||||||
|
useEffect(() => {
|
||||||
|
if (actionRef.current) {
|
||||||
|
// 重置页码到第一页
|
||||||
|
actionRef.current.setPageInfo?.({ current: 1 });
|
||||||
|
// 重新加载数据
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}, [JSON.stringify(params)]); // 使用JSON.stringify确保对象内容变化时触发
|
||||||
|
|
||||||
|
// 处理删除
|
||||||
|
const handleDelete = async (record: any) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认删除',
|
||||||
|
content: `确定要删除模板[${record.templateName || record.name}]吗?`,
|
||||||
|
onOk: async () => {
|
||||||
|
const hide = message.loading('正在删除...');
|
||||||
|
try {
|
||||||
|
await ordersApi.deleteVideoTemplate(record.id);
|
||||||
|
message.success('删除成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
|
} catch (error) {
|
||||||
|
message.error('删除失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理状态更新
|
||||||
|
const handleStatusChange = async (record: any) => {
|
||||||
|
const newStatus = record.status === 1 ? 0 : 1;
|
||||||
|
const statusText = newStatus === 1 ? '启用' : '禁用';
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认操作',
|
||||||
|
content: `确定要${statusText}该模板吗?`,
|
||||||
|
onOk: async () => {
|
||||||
|
const hide = message.loading('正在更新...');
|
||||||
|
try {
|
||||||
|
await ordersApi.updateVideoTemplateStatus(record.id, newStatus);
|
||||||
|
message.success('状态更新成功');
|
||||||
|
onStatusChange?.(record, newStatus);
|
||||||
|
actionRef.current?.reload();
|
||||||
|
} catch (error) {
|
||||||
|
message.error('状态更新失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
width: 48,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '模板ID',
|
||||||
|
dataIndex: 'templateId',
|
||||||
|
width: 180,
|
||||||
|
ellipsis: true,
|
||||||
|
copyable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '模板名称',
|
||||||
|
dataIndex: 'templateName',
|
||||||
|
width: 180,
|
||||||
|
render: (text, record) => text || record.name,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '模板配置',
|
||||||
|
dataIndex: 'config',
|
||||||
|
width: 200,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 100,
|
||||||
|
render: (_, record) => (
|
||||||
|
<Tag color={record.status === 1 ? 'success' : 'default'}>
|
||||||
|
{record.status === 1 ? '启用' : '禁用'}
|
||||||
|
</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
width: 180,
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
dataIndex: 'updateTime',
|
||||||
|
width: 180,
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
valueType: 'option',
|
||||||
|
width: 180,
|
||||||
|
fixed: 'right',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Space>
|
||||||
|
<Link onClick={() => onEdit?.(record)}>编辑</Link>
|
||||||
|
<Link onClick={() => handleStatusChange(record)}>
|
||||||
|
{record.status === 1 ? '禁用' : '启用'}
|
||||||
|
</Link>
|
||||||
|
<Link style={{ color: '#ff4d4f' }} onClick={() => handleDelete(record)}>
|
||||||
|
删除
|
||||||
|
</Link>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ProTable<any>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="视频模板列表"
|
||||||
|
actionRef={actionRef}
|
||||||
|
request={async (p) => {
|
||||||
|
const { current, pageSize, ...rest } = p;
|
||||||
|
const result = await ordersApi.getVideoTemplateList({
|
||||||
|
page: current,
|
||||||
|
limit: pageSize,
|
||||||
|
...params,
|
||||||
|
...rest,
|
||||||
|
} as any);
|
||||||
|
return {
|
||||||
|
data: result.data || [],
|
||||||
|
success: true,
|
||||||
|
total: result.total || 0,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
scroll={{ x: 1200 }}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export default VideoTemplateTable;
|
||||||
@@ -1,48 +1,128 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
import { PageContainer, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
||||||
import { Space, Switch, message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import { ordersApi } from '@/services/orders';
|
import { ordersApi } from '@/services/orders';
|
||||||
import { ActionBar, GradientButton, SearchBarPlus } from '@/components/ui';
|
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
|
||||||
|
import VideoTemplateTable, { VideoTemplateTableRef } from './components/VideoTemplateTable';
|
||||||
|
import VideoTemplateForm, { VideoTemplateFormValues, STATUS_OPTIONS } from './components/VideoTemplateForm';
|
||||||
|
|
||||||
const VideoTemplatePage: React.FC = () => {
|
const VideoTemplatePage: React.FC = () => {
|
||||||
const [params, setParams] = useState<Record<string, any>>({});
|
const tableRef = useRef<VideoTemplateTableRef>(null);
|
||||||
|
const [query, setQuery] = useState<Record<string, any>>({});
|
||||||
|
const [createOpen, setCreateOpen] = useState(false);
|
||||||
|
const [editOpen, setEditOpen] = useState(false);
|
||||||
|
const [current, setCurrent] = useState<any | null>(null);
|
||||||
|
|
||||||
const columns: any[] = [
|
// 处理新增
|
||||||
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
|
const handleAdd = async (values: VideoTemplateFormValues) => {
|
||||||
{ title: '模板名称', dataIndex: 'name' },
|
const hide = message.loading('正在保存...');
|
||||||
{ title: '描述', dataIndex: 'description' },
|
try {
|
||||||
{ title: '状态', dataIndex: 'status', render: (v: number, r: any) => <Switch checked={v === 1} onChange={(c) => ordersApi.updateVideoTemplateStatus(r.id, c ? 1 : 0)} /> },
|
await ordersApi.saveVideoTemplate(values as any);
|
||||||
{
|
message.success('新增成功');
|
||||||
title: '操作', key: 'action',
|
tableRef.current?.reload();
|
||||||
render: (_: any, record: any) => (
|
return true;
|
||||||
<Space>
|
} catch (error) {
|
||||||
<a onClick={async () => { message.info('演示环境暂不提供修改参数'); }}>编辑</a>
|
message.error('新增失败');
|
||||||
<a style={{ color: '#1677ff' }} onClick={async () => { try { await ordersApi.deleteVideoTemplate(record.id); message.success('删除成功'); } catch { message.error('删除失败'); } }}>删除</a>
|
return false;
|
||||||
</Space>
|
} finally {
|
||||||
)
|
hide();
|
||||||
},
|
}
|
||||||
];
|
};
|
||||||
|
|
||||||
|
// 处理编辑
|
||||||
|
const handleEdit = async (values: VideoTemplateFormValues) => {
|
||||||
|
const hide = message.loading('正在保存...');
|
||||||
|
try {
|
||||||
|
await ordersApi.updateVideoTemplate({
|
||||||
|
...current,
|
||||||
|
...values,
|
||||||
|
} as any);
|
||||||
|
message.success('修改成功');
|
||||||
|
tableRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
message.error('修改失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ title: '视频模板' }}>
|
<PageContainer header={{ title: '视频模板管理' }}>
|
||||||
<SearchBarPlus defaultCollapsed split span={8} onTenantChanged={() => { /* 租户切换 */ }} onFinish={async (values) => setParams(values)}>
|
<SearchBarPlus
|
||||||
<ProFormText name="name" label="模板名称" />
|
defaultCollapsed
|
||||||
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '启用', 0: '禁用' }} allowClear />
|
split
|
||||||
|
span={8}
|
||||||
|
showTenant={false}
|
||||||
|
onTenantChanged={() => tableRef.current?.reload()}
|
||||||
|
onFinish={async (values) => {
|
||||||
|
setQuery(values);
|
||||||
|
// params变化会触发表格组件内部的useEffect,自动重置页码并刷新
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProFormText
|
||||||
|
name="templateName"
|
||||||
|
label="模板名称"
|
||||||
|
placeholder="请输入模板名称"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
name="templateId"
|
||||||
|
label="模板ID"
|
||||||
|
placeholder="请输入模板ID"
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
options={STATUS_OPTIONS}
|
||||||
|
placeholder="请选择状态"
|
||||||
|
allowClear
|
||||||
|
/>
|
||||||
</SearchBarPlus>
|
</SearchBarPlus>
|
||||||
|
|
||||||
<ActionBar left={<GradientButton size="middle" type="primary" onClick={async () => {
|
<ActionBar
|
||||||
const hide = message.loading('保存中...');
|
left={
|
||||||
try { await ordersApi.saveVideoTemplate({ name: '新模板', status: 1 }); message.success('新增成功'); }
|
<GradientButton
|
||||||
catch { message.error('新增失败'); } finally { hide(); }
|
size="middle"
|
||||||
}}><PlusOutlined /> 新增</GradientButton>} />
|
type="primary"
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
onClick={() => setCreateOpen(true)}
|
||||||
|
>
|
||||||
|
新增模板
|
||||||
|
</GradientButton>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<ProTable<any>
|
<GlassCard>
|
||||||
rowKey="id"
|
<VideoTemplateTable
|
||||||
request={(p) => ordersApi.getVideoTemplateList({ ...p, ...params } as any)}
|
ref={tableRef}
|
||||||
columns={columns}
|
params={query}
|
||||||
search={false}
|
onEdit={(record) => {
|
||||||
pagination={{ showSizeChanger: true, showQuickJumper: true }}
|
setCurrent(record);
|
||||||
|
setEditOpen(true);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</GlassCard>
|
||||||
|
|
||||||
|
{/* 新增表单 */}
|
||||||
|
<VideoTemplateForm
|
||||||
|
title="新增视频模板"
|
||||||
|
visible={createOpen}
|
||||||
|
onVisibleChange={setCreateOpen}
|
||||||
|
onFinish={handleAdd}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 编辑表单 */}
|
||||||
|
<VideoTemplateForm
|
||||||
|
title="编辑视频模板"
|
||||||
|
visible={editOpen}
|
||||||
|
onVisibleChange={(v) => {
|
||||||
|
setEditOpen(v);
|
||||||
|
if (!v) setCurrent(null); // 关闭时清空当前编辑数据
|
||||||
|
}}
|
||||||
|
onFinish={handleEdit}
|
||||||
|
initialValues={current || {}}
|
||||||
/>
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -229,15 +229,15 @@ export const ordersApi = {
|
|||||||
// 编辑任务
|
// 编辑任务
|
||||||
getEditTaskList: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
getEditTaskList: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
||||||
const { current, pageSize, ...rest } = params || {};
|
const { current, pageSize, ...rest } = params || {};
|
||||||
const res = await request('/api-order/editTask/list', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
const res = await request('/api-order/auto/cut/list', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||||
return { data: (res as any).data, total: (res as any).count };
|
return { data: (res as any).data, total: (res as any).count };
|
||||||
},
|
},
|
||||||
saveOrUpdateEditTask: async (data: any) => {
|
saveOrUpdateEditTask: async (data: any) => {
|
||||||
const res = await request('/api-order/editTask', { method: 'POST', data });
|
const res = await request('/api-order/auto/cut/save', { method: 'POST', data });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
deleteEditTask: async (id: number) => {
|
deleteEditTask: async (id: number) => {
|
||||||
const res = await request(`/api-order/editTask/${id}`, { method: 'DELETE' });
|
const res = await request(`/api-order/auto/cut/delete/${id}`, { method: 'DELETE' });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
generateEditTask: async (orderNo: string) => {
|
generateEditTask: async (orderNo: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user