From 5e7f9836244b0c6e6c3d1d03fda02f138cd1b720 Mon Sep 17 00:00:00 2001
From: duzhichao <1098974448@qq.com>
Date: Tue, 11 Nov 2025 11:58:59 +0800
Subject: [PATCH] =?UTF-8?q?feat:=201=EF=BC=9A=E8=A7=86=E9=A2=91=E5=89=AA?=
=?UTF-8?q?=E8=BE=91=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86=20=20=20=20=20=20?=
=?UTF-8?q?=202=EF=BC=9A=E8=A7=86=E9=A2=91=E5=89=AA=E8=BE=91=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E7=AE=A1=E7=90=86=20=20=20=20=20=20=203=EF=BC=9A?=
=?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../main/resources/mapper/AgeDeviceMapper.xml | 12 +-
.../controller/AutoCutVideoController.java | 8 +-
.../impl/VideoTemplateServiceImpl.java | 11 +-
.../device/Device/components/DeviceForm.tsx | 12 +-
.../device/Device/components/DeviceTable.tsx | 32 ++-
.../src/pages/device/Device/index.tsx | 19 +-
.../device/Wayline/components/WaylineForm.tsx | 19 ++
.../src/pages/orders/EditTask/index.tsx | 249 +++++++++++++++---
.../Tourism/components/QrcodeTourismForm.tsx | 10 +-
.../orders/Tourism/components/TourismForm.tsx | 5 +-
.../components/TourismFileForm.tsx | 10 +-
.../src/pages/orders/TourismFile/index.tsx | 10 +-
.../components/VideoTemplateForm.tsx | 182 +++++++++++++
.../components/VideoTemplateTable.tsx | 188 +++++++++++++
.../src/pages/orders/VideoTemplate/index.tsx | 150 ++++++++---
zlt-web/react-web-next/src/services/orders.ts | 6 +-
16 files changed, 814 insertions(+), 109 deletions(-)
create mode 100644 zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateForm.tsx
create mode 100644 zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateTable.tsx
diff --git a/zlt-business/device-center/src/main/resources/mapper/AgeDeviceMapper.xml b/zlt-business/device-center/src/main/resources/mapper/AgeDeviceMapper.xml
index efa174ba..b998eb1e 100644
--- a/zlt-business/device-center/src/main/resources/mapper/AgeDeviceMapper.xml
+++ b/zlt-business/device-center/src/main/resources/mapper/AgeDeviceMapper.xml
@@ -3,6 +3,16 @@
diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/AutoCutVideoController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/AutoCutVideoController.java
index 40580951..a894d363 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/controller/AutoCutVideoController.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/controller/AutoCutVideoController.java
@@ -58,7 +58,7 @@ public class AutoCutVideoController {
// 1. 验证订单状态
Order order = orderService.getOrderByNumber(orderNo);
if (order == null || !OrderStatus.isValidForEdit(order.getOrderStatus())) {
- return Result.failed("订单状态不允许生成视频");
+ return Result.failed("订单状态不允许生成剪辑视频");
}
// 1. 检查是否开启一键成片
@@ -204,7 +204,7 @@ public class AutoCutVideoController {
@Operation(summary = "获取剪辑任务列表")
@GetMapping("/list")
- public Result> getTaskList(
+ public PageResult getTaskList(
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@RequestParam(required = false) String orderSn,
@@ -220,11 +220,11 @@ public class AutoCutVideoController {
.build();
PageResult result = editTaskService.getTaskList(params);
- return Result.succeed(result);
+ return result;
} catch (Exception e) {
log.error("查询剪辑任务列表失败", e);
- return Result.failed("查询任务列表失败");
+ return new PageResult<>();
}
}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/VideoTemplateServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/VideoTemplateServiceImpl.java
index f6c7b1aa..96371831 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/service/impl/VideoTemplateServiceImpl.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/VideoTemplateServiceImpl.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.central.common.model.PageResult;
import com.central.common.service.impl.SuperServiceImpl;
+import com.central.common.utils.StringUtils;
import com.central.order.mapper.VideoTemplateMapper;
import com.central.order.model.VideoTemplate;
import com.central.order.service.IVideoTemplateService;
@@ -26,7 +27,15 @@ public class VideoTemplateServiceImpl extends SuperServiceImpl wrapper = new LambdaQueryWrapper()
.eq(VideoTemplate::getIsDel, 0)
.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 result = baseMapper.selectPage(page, wrapper);
return PageResult.builder().data(result.getRecords()).count(result.getTotal()).build();
}
diff --git a/zlt-web/react-web-next/src/pages/device/Device/components/DeviceForm.tsx b/zlt-web/react-web-next/src/pages/device/Device/components/DeviceForm.tsx
index 0f7a8544..0faa1181 100644
--- a/zlt-web/react-web-next/src/pages/device/Device/components/DeviceForm.tsx
+++ b/zlt-web/react-web-next/src/pages/device/Device/components/DeviceForm.tsx
@@ -29,8 +29,13 @@ const DeviceForm: React.FC = ({ title, visible, onVisibleChange
const formRef = useRef();
useEffect(() => {
- if (initialValues) formRef.current?.setFieldsValue(initialValues);
- }, [initialValues]);
+ if (visible && initialValues) {
+ // 延迟设置,确保表单已经渲染
+ setTimeout(() => {
+ formRef.current?.setFieldsValue(initialValues);
+ }, 0);
+ }
+ }, [visible, initialValues]);
return (
@@ -40,6 +45,7 @@ const DeviceForm: React.FC = ({ title, visible, onVisibleChange
onVisibleChange={onVisibleChange}
onFinish={onFinish}
modalProps={{ destroyOnClose: true }}
+ initialValues={initialValues} // 同时设置 initialValues 属性
>
@@ -47,7 +53,7 @@ const DeviceForm: React.FC = ({ title, visible, onVisibleChange
-
+
);
diff --git a/zlt-web/react-web-next/src/pages/device/Device/components/DeviceTable.tsx b/zlt-web/react-web-next/src/pages/device/Device/components/DeviceTable.tsx
index 36f1d7eb..7c2d2d2e 100644
--- a/zlt-web/react-web-next/src/pages/device/Device/components/DeviceTable.tsx
+++ b/zlt-web/react-web-next/src/pages/device/Device/components/DeviceTable.tsx
@@ -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 type { ProColumns, ActionType } from '@ant-design/pro-components';
-import { Space, Switch } from 'antd';
+import { Space } from 'antd';
import { deviceApi } from '@/services/device';
export interface DeviceTableRef { reload: () => void }
@@ -16,14 +16,36 @@ const DeviceTable = forwardRef(({ params, onEd
const actionRef = useRef();
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 = {
+ 1: '机场',
+ 2: '无人机',
+ 3: '遥控器',
+ };
+
const columns: ProColumns[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48, fixed: 'left' },
{ title: '设备序列号', dataIndex: 'deviceSn', copyable: true, fixed: 'left', width: 160 },
{ title: '设备名称', dataIndex: 'deviceName' },
{ title: '昵称', dataIndex: 'nickname' },
- { title: '设备类型', dataIndex: 'deviceType' },
- { title: '固件版本', dataIndex: 'firmwareVersion' },
- { title: '绑定状态', dataIndex: 'boundStatus', render: (_, r) => },
+ {
+ title: '设备类型',
+ dataIndex: 'deviceType',
+ render: (_, record) => deviceTypeMap[record.deviceType] || record.deviceType
+ },
+ { title: '备注', dataIndex: 'deviceDesc' },
+ // { title: '固件版本', dataIndex: 'firmwareVersion' }, // 隐藏固件版本
+ // { title: '绑定状态', dataIndex: 'boundStatus', render: (_, r) => }, // 隐藏绑定状态
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
{
title: '操作', key: 'action', valueType: 'option', width: 140, fixed: 'right',
diff --git a/zlt-web/react-web-next/src/pages/device/Device/index.tsx b/zlt-web/react-web-next/src/pages/device/Device/index.tsx
index bcfbc7fa..72ed28fa 100644
--- a/zlt-web/react-web-next/src/pages/device/Device/index.tsx
+++ b/zlt-web/react-web-next/src/pages/device/Device/index.tsx
@@ -50,7 +50,7 @@ const DevicePage: React.FC = () => {
onOk: async () => {
const hide = message.loading('正在删除...');
try {
- await deviceApi.deleteDevice(record.deviceSn);
+ await deviceApi.deleteDevice(record.id);
message.success('删除成功');
tableRef.current?.reload();
} catch (e) {
@@ -64,12 +64,12 @@ const DevicePage: React.FC = () => {
return (
- tableRef.current?.reload()} onFinish={async (values) => setQuery(values)}>
+ tableRef.current?.reload()} showTenant={false} onFinish={async (values) => setQuery(values)}>
@@ -86,7 +86,16 @@ const DevicePage: React.FC = () => {
-
+ {
+ setEditOpen(v);
+ if (!v) setCurrent(null); // 关闭时清空当前编辑数据
+ }}
+ onFinish={edit}
+ initialValues={current || {}}
+ />
);
};
diff --git a/zlt-web/react-web-next/src/pages/device/Wayline/components/WaylineForm.tsx b/zlt-web/react-web-next/src/pages/device/Wayline/components/WaylineForm.tsx
index 7d8468d7..01bda3ab 100644
--- a/zlt-web/react-web-next/src/pages/device/Wayline/components/WaylineForm.tsx
+++ b/zlt-web/react-web-next/src/pages/device/Wayline/components/WaylineForm.tsx
@@ -22,6 +22,18 @@ interface WaylineFormProps {
initialValues?: Partial;
}
+/**
+ * 校验文件名是否合法
+ * 只允许字母、数字和下划线
+ */
+function validateFileName(fileName: string): boolean {
+ // 获取不带扩展名的文件名
+ const nameWithoutExtension = fileName.substring(0, fileName.lastIndexOf('.')) || fileName;
+ // 正则表达式:只允许字母、数字和下划线
+ const regex = /^[a-zA-Z0-9_]+$/;
+ return regex.test(nameWithoutExtension);
+}
+
/**
* 计算文件的 MD5 值
*/
@@ -127,6 +139,13 @@ const WaylineForm: React.FC = ({ title, visible, onVisibleChan
customRequest={async ({ file, onSuccess, onError }) => {
try {
if (file instanceof File) {
+ // 校验文件名
+ if (!validateFileName(file.name)) {
+ message.error('文件名不合法!只允许使用字母、数字和下划线');
+ onError?.(new Error('文件名不合法'));
+ return;
+ }
+
// 计算文件 MD5
const md5 = await calculateFileMD5(file);
diff --git a/zlt-web/react-web-next/src/pages/orders/EditTask/index.tsx b/zlt-web/react-web-next/src/pages/orders/EditTask/index.tsx
index 82f75f6c..b711c886 100644
--- a/zlt-web/react-web-next/src/pages/orders/EditTask/index.tsx
+++ b/zlt-web/react-web-next/src/pages/orders/EditTask/index.tsx
@@ -1,25 +1,129 @@
-import React, { useState } from 'react';
-import { PageContainer, ProFormText, ProTable, ProFormSelect } from '@ant-design/pro-components';
-import { Popconfirm, Space, message } from 'antd';
-import { PlusOutlined } from '@ant-design/icons';
+import React, { useState, useRef, useEffect } from 'react';
+import { PageContainer, ProFormText, ProTable, ProFormSelect, ProFormTextArea, ActionType, ModalForm, ProForm } from '@ant-design/pro-components';
+import { Popconfirm, Space, message, Modal } from 'antd';
import { ordersApi } from '@/services/orders';
-import { ActionBar, GradientButton, SearchBarPlus } from '@/components/ui';
+import { SearchBarPlus, GlassCard } from '@/components/ui';
const EditTaskPage: React.FC = () => {
const [params, setParams] = useState>({});
+ const [editVisible, setEditVisible] = useState(false);
+ const [currentTask, setCurrentTask] = useState(null);
+ const actionRef = useRef();
+
+ // 当查询参数变化时,自动重置到第一页
+ 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[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
- { title: '任务ID', dataIndex: 'id' },
- { title: '订单号', dataIndex: 'orderNo' },
- { title: '状态', dataIndex: 'status' },
- { title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime' },
+ { title: '任务ID', dataIndex: 'id', width: 120 },
+ { title: '用户ID', dataIndex: 'userId', width: 120 },
+ { title: '订单号', dataIndex: 'orderSn', width: 180, copyable: true },
+ { 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) => (
- { try { await ordersApi.deleteEditTask(record.id); message.success('删除成功'); } catch { message.error('删除失败'); } }}>
- 删除
+ {
+ setCurrentTask(record);
+ setEditVisible(true);
+ }}>
+ 编辑
+
+ {/* 只有状态为3(失败)时显示创建编辑任务按钮 */}
+ {record.status === 3 && (
+ handleGenerateEditTask(record.orderSn)}
+ >
+ 创建编辑任务
+
+ )}
+ {
+ const hide = message.loading('正在删除...');
+ try {
+ await ordersApi.deleteEditTask(record.id);
+ message.success('删除成功');
+ actionRef.current?.reload();
+ } catch {
+ message.error('删除失败');
+ } finally {
+ hide();
+ }
+ }}
+ >
+ 删除
)
@@ -27,39 +131,114 @@ const EditTaskPage: React.FC = () => {
];
return (
-
+
{ /* 后端上下文 */ }}
- onFinish={async (values) => setParams(values)}
+ showTenant={false}
+ onTenantChanged={() => actionRef.current?.reload()}
+ onFinish={async (values) => {
+ setParams(values);
+ // useEffect 会自动触发重置页码并刷新
+ }}
>
-
-
+
+
-
- } onClick={async () => {
- const hide = message.loading('提交中...');
- try { await ordersApi.saveOrUpdateEditTask({ orderNo: 'DEMO' }); message.success('新增成功'); } catch { message.error('新增失败'); } finally { hide(); }
- }}>新增
-
- }
- />
+
+
+ rowKey="id"
+ actionRef={actionRef}
+ request={async (p) => {
+ const { current, pageSize, ...rest } = p;
+ const result = await ordersApi.getEditTaskList({
+ 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="剪辑任务列表"
+ />
+
-
- rowKey="id"
- request={(p) => ordersApi.getEditTaskList({ ...p, ...params } as any)}
- columns={columns}
- search={false}
- pagination={{ showSizeChanger: true, showQuickJumper: true }}
- />
+ {/* 编辑表单 */}
+ {
+ setEditVisible(v);
+ if (!v) setCurrentTask(null);
+ }}
+ onFinish={handleEdit}
+ initialValues={currentTask}
+ modalProps={{
+ destroyOnClose: true,
+ maskClosable: false,
+ }}
+ width={600}
+ >
+
+
+
+
+
+
);
};
export default EditTaskPage;
-
diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx
index 4ee3152e..8c756c10 100644
--- a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx
+++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx
@@ -63,11 +63,11 @@ const QrcodeTourismForm: React.FC = ({ open, title, init
// 景区素材类型字典(按业务提供)
const TYPE_LABEL: Record = {
- 5: '视频',
- 6: '首页 Banner',
- 4: '展示图片',
- 3: '景区详情',
- 2: '景区小图展示',
+ 5: '景区视频',
+ 6: '景区订单展示图',
+ 4: '展示大图',
+ 3: '拍照引导图',
+ 2: '拍照角度展示图',
1: '活动',
};
const typeName = (t: any) => TYPE_LABEL[Number(t)] || '其他';
diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/components/TourismForm.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/TourismForm.tsx
index 0d45fdb0..95333ec9 100644
--- a/zlt-web/react-web-next/src/pages/orders/Tourism/components/TourismForm.tsx
+++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/TourismForm.tsx
@@ -12,12 +12,13 @@ export interface TourismItem {
longitude?: string;
latitude?: string;
showInHomepage?: number; // 1 是,0 否
- description?: string;
+ tourismDesc?: string;
}
export interface TourismFormProps {
open: boolean;
title: string;
+
initialValues?: Partial;
onOpenChange: (v: boolean) => void;
onFinish: (values: TourismItem) => Promise;
@@ -64,7 +65,7 @@ const TourismForm: React.FC = ({ open, title, initialValues, o
]}
initialValue={1}
/>
-
+
);
};
diff --git a/zlt-web/react-web-next/src/pages/orders/TourismFile/components/TourismFileForm.tsx b/zlt-web/react-web-next/src/pages/orders/TourismFile/components/TourismFileForm.tsx
index 532105df..54198b1b 100644
--- a/zlt-web/react-web-next/src/pages/orders/TourismFile/components/TourismFileForm.tsx
+++ b/zlt-web/react-web-next/src/pages/orders/TourismFile/components/TourismFileForm.tsx
@@ -23,11 +23,11 @@ export interface TourismFileFormProps {
}
const TYPE_OPTIONS = [
- { label: '视频', value: 5 },
- { label: '首页 Banner', value: 6 },
- { label: '展示图片', value: 4 },
- { label: '景区详情', value: 3 },
- { label: '景区小图展示', value: 2 },
+ { label: '景区视频', value: 5 },
+ { label: '景区订单展示图', value: 6 },
+ { label: '展示大图', value: 4 },
+ { label: '拍照引导图', value: 3 },
+ { label: '拍照角度展示图', value: 2 },
{ label: '活动', value: 1 },
] as const;
diff --git a/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx b/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx
index ef5f1e9b..a1507c88 100644
--- a/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx
+++ b/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx
@@ -8,11 +8,11 @@ import TourismFileForm, { TourismFileItem } from './components/TourismFileForm';
// 资源类型枚举(用于卡片展示的颜色)
const TYPE_OPTIONS = [
- { label: '视频', value: 5, color: '#f5222d' },
- { label: '首页 Banner', value: 6, color: '#2f54eb' },
- { label: '展示图片', value: 4, color: '#52c41a' },
- { label: '景区详情', value: 3, color: '#722ed1' },
- { label: '景区小图展示', value: 2, color: '#13c2c2' },
+ { label: '景区视频', value: 5, color: '#f5222d' },
+ { label: '景区订单展示图', value: 6, color: '#2f54eb' },
+ { label: '展示大图', value: 4, color: '#52c41a' },
+ { label: '拍照引导图', value: 3, color: '#722ed1' },
+ { label: '拍照角度展示图', value: 2, color: '#13c2c2' },
{ label: '活动', value: 1, color: '#1890ff' },
] as const;
diff --git a/zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateForm.tsx b/zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateForm.tsx
new file mode 100644
index 00000000..dd6e6d71
--- /dev/null
+++ b/zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateForm.tsx
@@ -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;
+ initialValues?: Partial;
+}
+
+const VideoTemplateForm: React.FC = ({
+ title,
+ visible,
+ onVisibleChange,
+ onFinish,
+ initialValues,
+}) => {
+ const formRef = useRef();
+
+ 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 (
+
+ title={title}
+ width={800}
+ visible={visible}
+ formRef={formRef}
+ onVisibleChange={onVisibleChange}
+ onFinish={handleFinish}
+ initialValues={{
+ status: 1, // 默认启用
+ config: '{}', // 默认空JSON对象
+ ...initialValues,
+ }}
+ modalProps={{
+ destroyOnClose: true,
+ maskClosable: false,
+ }}
+ >
+
+
+
+
+
+
+
+
+ {
+ // 格式化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格式');
+ }
+ }
+ },
+ },
+ ]}
+ />
+
+
+ );
+};
+
+export default VideoTemplateForm;
\ No newline at end of file
diff --git a/zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateTable.tsx b/zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateTable.tsx
new file mode 100644
index 00000000..b3f49e7d
--- /dev/null
+++ b/zlt-web/react-web-next/src/pages/orders/VideoTemplate/components/VideoTemplateTable.tsx
@@ -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;
+ onEdit?: (record: any) => void;
+ onStatusChange?: (record: any, status: number) => void;
+}
+
+const VideoTemplateTable = forwardRef(
+ ({ params, onEdit, onStatusChange }, ref) => {
+ const actionRef = useRef();
+
+ 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[] = [
+ {
+ 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) => (
+
+ {record.status === 1 ? '启用' : '禁用'}
+
+ ),
+ },
+ {
+ 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) => (
+
+ onEdit?.(record)}>编辑
+ handleStatusChange(record)}>
+ {record.status === 1 ? '禁用' : '启用'}
+
+ handleDelete(record)}>
+ 删除
+
+
+ ),
+ },
+ ];
+
+ return (
+
+ 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;
diff --git a/zlt-web/react-web-next/src/pages/orders/VideoTemplate/index.tsx b/zlt-web/react-web-next/src/pages/orders/VideoTemplate/index.tsx
index 5d874f71..cc376f93 100644
--- a/zlt-web/react-web-next/src/pages/orders/VideoTemplate/index.tsx
+++ b/zlt-web/react-web-next/src/pages/orders/VideoTemplate/index.tsx
@@ -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>({});
+ const tableRef = useRef(null);
+ const [query, setQuery] = useState>({});
+ const [createOpen, setCreateOpen] = useState(false);
+ const [editOpen, setEditOpen] = useState(false);
+ const [current, setCurrent] = useState(null);
- const columns: any[] = [
- { dataIndex: 'index', valueType: 'indexBorder', width: 48 },
- { title: '模板名称', dataIndex: 'name' },
- { title: '描述', dataIndex: 'description' },
- { title: '状态', dataIndex: 'status', render: (v: number, r: any) => ordersApi.updateVideoTemplateStatus(r.id, c ? 1 : 0)} /> },
- {
- title: '操作', key: 'action',
- render: (_: any, record: any) => (
-
- { message.info('演示环境暂不提供修改参数'); }}>编辑
- { try { await ordersApi.deleteVideoTemplate(record.id); message.success('删除成功'); } catch { message.error('删除失败'); } }}>删除
-
- )
- },
- ];
+ // 处理新增
+ 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 (
-
- { /* 租户切换 */ }} onFinish={async (values) => setParams(values)}>
-
-
+
+ tableRef.current?.reload()}
+ onFinish={async (values) => {
+ setQuery(values);
+ // params变化会触发表格组件内部的useEffect,自动重置页码并刷新
+ }}
+ >
+
+
+
- {
- const hide = message.loading('保存中...');
- try { await ordersApi.saveVideoTemplate({ name: '新模板', status: 1 }); message.success('新增成功'); }
- catch { message.error('新增失败'); } finally { hide(); }
- }}> 新增} />
+ }
+ onClick={() => setCreateOpen(true)}
+ >
+ 新增模板
+
+ }
+ />
-
- rowKey="id"
- request={(p) => ordersApi.getVideoTemplateList({ ...p, ...params } as any)}
- columns={columns}
- search={false}
- pagination={{ showSizeChanger: true, showQuickJumper: true }}
+
+ {
+ setCurrent(record);
+ setEditOpen(true);
+ }}
+ />
+
+
+ {/* 新增表单 */}
+
+
+ {/* 编辑表单 */}
+ {
+ setEditOpen(v);
+ if (!v) setCurrent(null); // 关闭时清空当前编辑数据
+ }}
+ onFinish={handleEdit}
+ initialValues={current || {}}
/>
);
diff --git a/zlt-web/react-web-next/src/services/orders.ts b/zlt-web/react-web-next/src/services/orders.ts
index 52566354..d7f09de0 100644
--- a/zlt-web/react-web-next/src/services/orders.ts
+++ b/zlt-web/react-web-next/src/services/orders.ts
@@ -229,15 +229,15 @@ export const ordersApi = {
// 编辑任务
getEditTaskList: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
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 };
},
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;
},
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;
},
generateEditTask: async (orderNo: string) => {