feat: 1:视频剪辑模板管理

2:视频剪辑任务管理
      3:设备管理
This commit is contained in:
2025-11-11 11:58:59 +08:00
parent 3b4e8eb02c
commit 5e7f983624
16 changed files with 814 additions and 109 deletions
@@ -1,48 +1,128 @@
import React, { useState } from 'react';
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
import { Space, Switch, message } from 'antd';
import React, { useRef, useState } from 'react';
import { PageContainer, ProFormSelect, ProFormText } from '@ant-design/pro-components';
import { message } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
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 [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 },
{ title: '模板名称', dataIndex: 'name' },
{ title: '描述', dataIndex: 'description' },
{ title: '状态', dataIndex: 'status', render: (v: number, r: any) => <Switch checked={v === 1} onChange={(c) => ordersApi.updateVideoTemplateStatus(r.id, c ? 1 : 0)} /> },
{
title: '操作', key: 'action',
render: (_: any, record: any) => (
<Space>
<a onClick={async () => { message.info('演示环境暂不提供修改参数'); }}>编辑</a>
<a style={{ color: '#1677ff' }} onClick={async () => { try { await ordersApi.deleteVideoTemplate(record.id); message.success('删除成功'); } catch { message.error('删除失败'); } }}>删除</a>
</Space>
)
},
];
// 处理新增
const handleAdd = async (values: VideoTemplateFormValues) => {
const hide = message.loading('正在保存...');
try {
await ordersApi.saveVideoTemplate(values as any);
message.success('新增成功');
tableRef.current?.reload();
return true;
} catch (error) {
message.error('新增失败');
return false;
} 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 (
<PageContainer header={{ title: '视频模板' }}>
<SearchBarPlus defaultCollapsed split span={8} onTenantChanged={() => { /* 租户切换 */ }} onFinish={async (values) => setParams(values)}>
<ProFormText name="name" label="模板名称" />
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '启用', 0: '禁用' }} allowClear />
<PageContainer header={{ title: '视频模板管理' }}>
<SearchBarPlus
defaultCollapsed
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>
<ActionBar left={<GradientButton size="middle" type="primary" onClick={async () => {
const hide = message.loading('保存中...');
try { await ordersApi.saveVideoTemplate({ name: '新模板', status: 1 }); message.success('新增成功'); }
catch { message.error('新增失败'); } finally { hide(); }
}}><PlusOutlined /> 新增</GradientButton>} />
<ActionBar
left={
<GradientButton
size="middle"
type="primary"
icon={<PlusOutlined />}
onClick={() => setCreateOpen(true)}
>
新增模板
</GradientButton>
}
/>
<ProTable<any>
rowKey="id"
request={(p) => ordersApi.getVideoTemplateList({ ...p, ...params } as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
<GlassCard>
<VideoTemplateTable
ref={tableRef}
params={query}
onEdit={(record) => {
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>
);