!17 fix(订单中心):新版UI订单素材接口逻辑,订单列表中新增景区图片参数tourismImgUrl
Merge pull request !17 from Iamasoldier/feature_lsl
This commit is contained in:
@@ -4,10 +4,10 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: file-center
|
name: file-center
|
||||||
# cloud:
|
cloud:
|
||||||
# nacos:
|
nacos:
|
||||||
# discovery:
|
discovery:
|
||||||
# ip: 119.45.169.13
|
ip: 119.45.169.13
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 20MB
|
max-file-size: 20MB
|
||||||
|
|||||||
+81
@@ -723,6 +723,87 @@ public class OrderController {
|
|||||||
return new PageResult<>();
|
return new PageResult<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新版:查询用户订单详情列表(含视频/图片/一键成片)
|
||||||
|
*/
|
||||||
|
@Operation(summary = "新版-查询用户订单详情列表(含视频/图片/一键成片)")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping("/user/v2")
|
||||||
|
public PageResult<Map> listInfoByUserV2(@RequestParam Map<String, Object> params) {
|
||||||
|
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||||
|
params.put("userId", user.getId());
|
||||||
|
List<Integer> orderStatusList = List.of(OrderStatus.COMPLETE.getId(), OrderStatus.UPLOADING.getId(), OrderStatus.UPLOADED.getId());
|
||||||
|
params.put("orderStatusList", orderStatusList);
|
||||||
|
|
||||||
|
PageResult<Order> result = orderService.findListByUser(params);
|
||||||
|
if (result.getCount() > 0){
|
||||||
|
List<Map> page = new ArrayList<>();
|
||||||
|
Map<String, String> fileMap = new HashMap<>();
|
||||||
|
fileMap.put("style", fileStyle);
|
||||||
|
for(Order order : result.getData()){
|
||||||
|
Map<String,Object> orderFileMap = new HashMap<>();
|
||||||
|
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||||
|
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||||
|
orderFileMap.put("orderNo", order.getOrderNo());
|
||||||
|
|
||||||
|
// 只查一次所有文件
|
||||||
|
List<OrderFile> allFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||||
|
|
||||||
|
// aiVideo
|
||||||
|
List<OrderFile> aiVideoFiles = allFiles.stream()
|
||||||
|
.filter(f -> "ai_video".equals(f.getFileTag()))
|
||||||
|
.toList();
|
||||||
|
String aiVideoUrl = null;
|
||||||
|
if (!aiVideoFiles.isEmpty()) {
|
||||||
|
fileMap.put("path", aiVideoFiles.get(0).getFilePath());
|
||||||
|
aiVideoUrl = fileCenterService.getViewUrlByPathStyle(fileMap);
|
||||||
|
}
|
||||||
|
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||||
|
|
||||||
|
// 图片素材
|
||||||
|
List<OrderFile> imgFiles = allFiles.stream()
|
||||||
|
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||||
|
.toList();
|
||||||
|
List<Map<String,String>> imgList = new ArrayList<>();
|
||||||
|
for (OrderFile orderFile : imgFiles){
|
||||||
|
Map<String,String> imgMap = new HashMap<>();
|
||||||
|
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||||
|
imgMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||||
|
imgMap.put("contentType", orderFile.getFileType());
|
||||||
|
imgMap.put("path", orderFile.getFilePath());
|
||||||
|
fileMap.put("path",orderFile.getFilePath());
|
||||||
|
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||||
|
imgList.add(imgMap);
|
||||||
|
}
|
||||||
|
orderFileMap.put("imgList", imgList);
|
||||||
|
|
||||||
|
// 视频素材
|
||||||
|
List<OrderFile> videoFiles = allFiles.stream()
|
||||||
|
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||||
|
.toList();
|
||||||
|
List<Map<String,String>> videoList = new ArrayList<>();
|
||||||
|
for (OrderFile orderFile : videoFiles){
|
||||||
|
Map<String,String> videoMap = new HashMap<>();
|
||||||
|
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||||
|
videoMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||||
|
videoMap.put("contentType", orderFile.getFileType());
|
||||||
|
videoMap.put("path", orderFile.getFilePath());
|
||||||
|
fileMap.put("path",orderFile.getFilePath());
|
||||||
|
videoMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||||
|
videoList.add(videoMap);
|
||||||
|
}
|
||||||
|
orderFileMap.put("videoList", videoList);
|
||||||
|
|
||||||
|
page.add(orderFileMap);
|
||||||
|
}
|
||||||
|
return PageResult.<Map>builder().data(page).resp_code(0).count(result.getCount()).build();
|
||||||
|
}
|
||||||
|
return new PageResult<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除URL中的参数
|
* 移除URL中的参数
|
||||||
* @param url 原始URL
|
* @param url 原始URL
|
||||||
|
|||||||
+4
@@ -220,6 +220,10 @@ public class OrderFileController {
|
|||||||
orderFile.setFilePath(fileInfo.getPath());
|
orderFile.setFilePath(fileInfo.getPath());
|
||||||
orderFile.setFileType(fileInfo.getContentType());
|
orderFile.setFileType(fileInfo.getContentType());
|
||||||
orderFile.setTourismId(order.getTourismId());
|
orderFile.setTourismId(order.getTourismId());
|
||||||
|
// 新增:如果是视频素材且未指定fileTag,默认标记为raw_video
|
||||||
|
if ("video/mp4".equals(orderFile.getFileType()) && (orderFile.getFileTag() == null || orderFile.getFileTag().isEmpty())) {
|
||||||
|
orderFile.setFileTag("raw_video");
|
||||||
|
}
|
||||||
|
|
||||||
// 保存记录
|
// 保存记录
|
||||||
boolean saved = orderFileService.save(orderFile);
|
boolean saved = orderFileService.save(orderFile);
|
||||||
|
|||||||
+3
-1
@@ -14,7 +14,9 @@ public enum HomeCarouselType implements ZltEnum {
|
|||||||
ACTIVITY(1, "活动"),
|
ACTIVITY(1, "活动"),
|
||||||
SHOOTING_ANGLE(2,"拍照角度"),
|
SHOOTING_ANGLE(2,"拍照角度"),
|
||||||
GUIDANCE(3,"引导"),
|
GUIDANCE(3,"引导"),
|
||||||
BIG_PICTURE(4,"大图");
|
BIG_PICTURE(4,"大图"),
|
||||||
|
VIDEO(5,"景区视频"),
|
||||||
|
ORDER_SHOW(6,"订单展示图");
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String content;
|
private String content;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class Order extends SuperEntity {
|
|||||||
|
|
||||||
private transient String waylineLinkUrl;
|
private transient String waylineLinkUrl;
|
||||||
private transient JSONObject streamUrls;
|
private transient JSONObject streamUrls;
|
||||||
|
private transient String tourismImgUrl;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,4 +46,8 @@ public class OrderFile extends SuperEntity {
|
|||||||
private String tenantId;
|
private String tenantId;
|
||||||
private Integer isDel;
|
private Integer isDel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件标签,如ai_video、raw_video等
|
||||||
|
*/
|
||||||
|
private String fileTag;
|
||||||
}
|
}
|
||||||
|
|||||||
+24
@@ -1,5 +1,6 @@
|
|||||||
package com.central.order.service.impl;
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.central.common.lock.DistributedLock;
|
import com.central.common.lock.DistributedLock;
|
||||||
@@ -8,12 +9,15 @@ import com.central.common.service.impl.SuperServiceImpl;
|
|||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
import com.central.order.event.OrderStatusChangeEvent;
|
import com.central.order.event.OrderStatusChangeEvent;
|
||||||
import com.central.order.feign.UserCenterService;
|
import com.central.order.feign.UserCenterService;
|
||||||
|
import com.central.order.feign.FileCenterService;
|
||||||
import com.central.order.mapper.OrderFileMapper;
|
import com.central.order.mapper.OrderFileMapper;
|
||||||
import com.central.order.mapper.OrderMapper;
|
import com.central.order.mapper.OrderMapper;
|
||||||
|
import com.central.order.mapper.TourismFileMapper;
|
||||||
import com.central.order.mapper.TourismMapper;
|
import com.central.order.mapper.TourismMapper;
|
||||||
import com.central.order.model.Order;
|
import com.central.order.model.Order;
|
||||||
import com.central.order.model.OrderFile;
|
import com.central.order.model.OrderFile;
|
||||||
import com.central.order.model.OrderRanking;
|
import com.central.order.model.OrderRanking;
|
||||||
|
import com.central.order.model.TourismFile;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
import com.central.order.util.DateUtils;
|
import com.central.order.util.DateUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -56,6 +60,10 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TourismMapper tourismMapper;
|
private TourismMapper tourismMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TourismFileMapper tourismFileMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderFileMapper orderFileMapper;
|
private OrderFileMapper orderFileMapper;
|
||||||
|
|
||||||
@@ -65,6 +73,9 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserCenterService userCenterService;
|
private UserCenterService userCenterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileCenterService fileCenterService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
* @param params
|
* @param params
|
||||||
@@ -225,6 +236,19 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|||||||
for (Order order : list) {
|
for (Order order : list) {
|
||||||
order.setTourismName(tourismMapper.getTourismById(order.getTourismId()).getTourismName());
|
order.setTourismName(tourismMapper.getTourismById(order.getTourismId()).getTourismName());
|
||||||
order.setCreatedTime(sdf.format(order.getCreateTime()));
|
order.setCreatedTime(sdf.format(order.getCreateTime()));
|
||||||
|
// 设置景区订单展示图(type=6)的imageUrl
|
||||||
|
List<TourismFile> tourismFiles = tourismFileMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<TourismFile>()
|
||||||
|
.eq(TourismFile::getTourismId, order.getTourismId())
|
||||||
|
.eq(TourismFile::getType, 6)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (tourismFiles != null && !tourismFiles.isEmpty()) {
|
||||||
|
String imgUrl = tourismFiles.get(0).getImageUrl();
|
||||||
|
order.setTourismImgUrl(fileCenterService.getViewUrlByPath(imgUrl));
|
||||||
|
} else {
|
||||||
|
order.setTourismImgUrl(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PageResult.<Order>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
return PageResult.<Order>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||||
|
|||||||
+1
@@ -153,6 +153,7 @@ public class VideoEditServiceImpl implements IVideoEditService {
|
|||||||
orderFile.setFileId(fileInfo.getId());
|
orderFile.setFileId(fileInfo.getId());
|
||||||
orderFile.setOrderNo(orderNo);
|
orderFile.setOrderNo(orderNo);
|
||||||
orderFile.setFileType("video/mp4");
|
orderFile.setFileType("video/mp4");
|
||||||
|
orderFile.setFileTag("ai_video");
|
||||||
orderFile.setFilePath(extractFilePath(outputUrl));
|
orderFile.setFilePath(extractFilePath(outputUrl));
|
||||||
orderFile.setUserId(order.getUserId());
|
orderFile.setUserId(order.getUserId());
|
||||||
orderFile.setTourismId(order.getTourismId());
|
orderFile.setTourismId(order.getTourismId());
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
########################## bootstrap级别通用配置 ##########################
|
########################## bootstrap级别通用配置 ##########################
|
||||||
# 默认开发环境
|
# 默认开发环境
|
||||||
spring.profiles.active=dev
|
spring.profiles.active=prod
|
||||||
|
|
||||||
##### nacos(注册中心和配置中心)地址
|
##### nacos(注册中心和配置中心)地址
|
||||||
#spring.cloud.nacos.server-addr=81.70.164.178:8848
|
spring.cloud.nacos.server-addr=81.70.164.178:8848
|
||||||
spring.cloud.nacos.server-addr=127.0.0.1:8848
|
#spring.cloud.nacos.server-addr=192.168.4.61:8848
|
||||||
spring.cloud.nacos.username=nacos
|
spring.cloud.nacos.username=nacos
|
||||||
spring.cloud.nacos.password=nacos
|
#spring.cloud.nacos.password=nacos
|
||||||
#spring.cloud.nacos.password=nacosGFLY
|
spring.cloud.nacos.password=nacosGFLY
|
||||||
spring.cloud.nacos.config.file-extension=yml
|
spring.cloud.nacos.config.file-extension=yml
|
||||||
spring.cloud.nacos.config.shared-configs[0].data-id=common.yml
|
spring.cloud.nacos.config.shared-configs[0].data-id=common.yml
|
||||||
spring.cloud.nacos.config.shared-configs[0].refresh=true
|
spring.cloud.nacos.config.shared-configs[0].refresh=true
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ import {
|
|||||||
QueryFilter,
|
QueryFilter,
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
ProFormText,
|
ProFormText,
|
||||||
|
ModalForm,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Button, Space, Typography, Popconfirm, message, Tag, Tooltip } from 'antd';
|
import { Button, Space, Typography, Popconfirm, message, Tag, Tooltip } from 'antd';
|
||||||
import { getEditTaskList, deleteEditTask } from '@/services/orders/api';
|
import { getEditTaskList, deleteEditTask, generateEditTask } from '@/services/orders/api';
|
||||||
import CreateForm from './components/CreateForm';
|
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
import { request } from 'umi';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ const STATUS_OPTIONS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// 状态颜色映射
|
// 状态颜色映射
|
||||||
const statusColorMap = {
|
const statusColorMap: { [key: number]: { color: string; text: string } } = {
|
||||||
0: { color: 'default', text: '待处理' },
|
0: { color: 'default', text: '待处理' },
|
||||||
1: { color: 'processing', text: '处理中' },
|
1: { color: 'processing', text: '处理中' },
|
||||||
2: { color: 'success', 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 (
|
const handleTableAction = useCallback(async (
|
||||||
action: 'add' | 'edit' | 'delete',
|
action: 'add' | 'edit' | 'delete',
|
||||||
@@ -85,7 +116,7 @@ const TableList: React.FC = () => {
|
|||||||
let success = false;
|
let success = false;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'add':
|
case 'add':
|
||||||
success = await handleAdd(values as ORDERS.EditTask);
|
success = await handleAdd(values as { orderSn: string });
|
||||||
success && handleModalVisible(false);
|
success && handleModalVisible(false);
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
@@ -104,6 +135,7 @@ const TableList: React.FC = () => {
|
|||||||
if (success && actionRef.current) {
|
if (success && actionRef.current) {
|
||||||
actionRef.current.reload();
|
actionRef.current.reload();
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// 修改 request 处理方式
|
// 修改 request 处理方式
|
||||||
@@ -227,8 +259,12 @@ const TableList: React.FC = () => {
|
|||||||
修改
|
修改
|
||||||
</Link>
|
</Link>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={`确认删除该剪辑任务?`}
|
title={
|
||||||
description="删除后将无法恢复,请谨慎操作"
|
<span>
|
||||||
|
确认删除该剪辑任务?<br />
|
||||||
|
<span style={{ color: 'red' }}>删除后将无法恢复,请谨慎操作</span>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
onConfirm={() => handleTableAction('delete', record)}
|
onConfirm={() => handleTableAction('delete', record)}
|
||||||
>
|
>
|
||||||
<Link>删除</Link>
|
<Link>删除</Link>
|
||||||
@@ -245,7 +281,7 @@ const TableList: React.FC = () => {
|
|||||||
split
|
split
|
||||||
span={6}
|
span={6}
|
||||||
className="query-filter"
|
className="query-filter"
|
||||||
onFinish={setParams}
|
onFinish={async (formData) => { setParams(formData); return true; }}
|
||||||
>
|
>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
name="orderSn"
|
name="orderSn"
|
||||||
@@ -292,11 +328,27 @@ const TableList: React.FC = () => {
|
|||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<CreateForm
|
<ModalForm
|
||||||
|
title="新增剪辑任务"
|
||||||
visible={createModalVisible}
|
visible={createModalVisible}
|
||||||
onVisibleChange={handleModalVisible}
|
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
|
<UpdateForm
|
||||||
updateModalVisible={updateModalVisible}
|
updateModalVisible={updateModalVisible}
|
||||||
onVisibleChange={handleUpdateModalVisible}
|
onVisibleChange={handleUpdateModalVisible}
|
||||||
|
|||||||
+39
-45
@@ -3,7 +3,8 @@ import { Button, Upload, message } from 'antd';
|
|||||||
import { UploadOutlined } from '@ant-design/icons';
|
import { UploadOutlined } from '@ant-design/icons';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { TYPE_OPTIONS } from '../constants';
|
import { TYPE_OPTIONS } from '../constants';
|
||||||
import { importImage, saveOrUpdateTourismFile } from '@/services/orders/api';
|
import { importImage } from '@/services/system/api';
|
||||||
|
import { saveOrUpdateTourismFile } from '@/services/orders/api';
|
||||||
import type { RcFile } from 'antd/lib/upload';
|
import type { RcFile } from 'antd/lib/upload';
|
||||||
import styles from '../index.less';
|
import styles from '../index.less';
|
||||||
|
|
||||||
@@ -20,7 +21,8 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
tourismOptions,
|
tourismOptions,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
}) => {
|
}) => {
|
||||||
const [imageUrl, setImageUrl] = useState<string>();
|
const [fileUrl, setFileUrl] = useState<string>();
|
||||||
|
const [fileType, setFileType] = useState<number>();
|
||||||
|
|
||||||
const handleUpload = async (file: RcFile) => {
|
const handleUpload = async (file: RcFile) => {
|
||||||
const hide = message.loading('正在上传');
|
const hide = message.loading('正在上传');
|
||||||
@@ -29,8 +31,8 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const result = await importImage(formData);
|
const result = await importImage(formData);
|
||||||
hide();
|
hide();
|
||||||
if (result.name) {
|
if (result.url) {
|
||||||
setImageUrl(result.name);
|
setFileUrl(result.url);
|
||||||
message.success('上传成功');
|
message.success('上传成功');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -41,20 +43,18 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (values: Record<string, any>) => {
|
const handleSubmit = async (values: Record<string, any>) => {
|
||||||
if (!imageUrl) {
|
if (!fileUrl) {
|
||||||
message.error('请上传素材图片');
|
message.error('请上传素材文件');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hide = message.loading('正在提交');
|
const hide = message.loading('正在提交');
|
||||||
try {
|
try {
|
||||||
const result = await saveOrUpdateTourismFile({
|
const result = await saveOrUpdateTourismFile({
|
||||||
...values,
|
...values,
|
||||||
imageUrl,
|
imageUrl: fileUrl,
|
||||||
status: 0, // 默认启用
|
status: 0, // 默认启用
|
||||||
});
|
});
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
if (result.resp_code === 0) {
|
if (result.resp_code === 0) {
|
||||||
message.success('创建成功');
|
message.success('创建成功');
|
||||||
onSuccess();
|
onSuccess();
|
||||||
@@ -75,14 +75,12 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
visible={visible}
|
visible={visible}
|
||||||
onVisibleChange={(visible) => {
|
onVisibleChange={(visible) => {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
setImageUrl(undefined);
|
setFileUrl(undefined);
|
||||||
|
setFileType(undefined);
|
||||||
}
|
}
|
||||||
onVisibleChange(visible);
|
onVisibleChange(visible);
|
||||||
}}
|
}}
|
||||||
modalProps={{
|
modalProps={{ destroyOnClose: true, maskClosable: false }}
|
||||||
destroyOnClose: true,
|
|
||||||
maskClosable: false,
|
|
||||||
}}
|
|
||||||
onFinish={handleSubmit}
|
onFinish={handleSubmit}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
@@ -96,7 +94,7 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
showSearch
|
showSearch
|
||||||
fieldProps={{
|
fieldProps={{
|
||||||
loading: !tourismOptions.length,
|
loading: !tourismOptions.length,
|
||||||
filterOption: (input, option) =>
|
filterOption: (input: string, option: any) =>
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -106,7 +104,10 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
name="type"
|
name="type"
|
||||||
label="素材类型"
|
label="素材类型"
|
||||||
placeholder="请选择素材类型"
|
placeholder="请选择素材类型"
|
||||||
options={TYPE_OPTIONS}
|
options={TYPE_OPTIONS as any}
|
||||||
|
fieldProps={{
|
||||||
|
onChange: (val: number) => setFileType(val),
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
@@ -121,36 +122,29 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
placeholder="请输入素材描述"
|
placeholder="请输入素材描述"
|
||||||
rules={[{ required: true, message: '请输入素材描述' }]}
|
rules={[{ required: true, message: '请输入素材描述' }]}
|
||||||
/>
|
/>
|
||||||
|
<div style={{ marginBottom: 8 }}>
|
||||||
<div style={{ width: '100%', marginBottom: 24 }}>
|
<span style={{ color: '#666' }}>素材文件:</span>
|
||||||
<div style={{ marginBottom: 8 }}>
|
<span style={{ color: '#ff4d4f' }}>*</span>
|
||||||
<span style={{ color: '#666' }}>素材图片:</span>
|
|
||||||
<span style={{ color: '#ff4d4f' }}>*</span>
|
|
||||||
</div>
|
|
||||||
{imageUrl && (
|
|
||||||
<div style={{ marginBottom: 8 }}>
|
|
||||||
<img
|
|
||||||
src={imageUrl}
|
|
||||||
alt="preview"
|
|
||||||
style={{
|
|
||||||
maxWidth: '200px',
|
|
||||||
maxHeight: '200px',
|
|
||||||
objectFit: 'contain'
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<Upload
|
|
||||||
maxCount={1}
|
|
||||||
showUploadList={false}
|
|
||||||
beforeUpload={handleUpload}
|
|
||||||
accept="image/*"
|
|
||||||
>
|
|
||||||
<Button icon={<UploadOutlined />}>
|
|
||||||
{imageUrl ? '重新上传' : '上传素材'}
|
|
||||||
</Button>
|
|
||||||
</Upload>
|
|
||||||
</div>
|
</div>
|
||||||
|
{fileUrl && (
|
||||||
|
<div style={{ marginBottom: 8 }}>
|
||||||
|
{fileType === 5 ? (
|
||||||
|
<video src={fileUrl} controls style={{ maxWidth: '200px', maxHeight: '200px' }} />
|
||||||
|
) : (
|
||||||
|
<img src={fileUrl} alt="preview" style={{ maxWidth: '200px', maxHeight: '200px', objectFit: 'contain' }} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Upload
|
||||||
|
maxCount={1}
|
||||||
|
showUploadList={false}
|
||||||
|
beforeUpload={handleUpload}
|
||||||
|
accept={fileType === 5 ? 'video/*' : 'image/*'}
|
||||||
|
>
|
||||||
|
<Button icon={<UploadOutlined />}>
|
||||||
|
{fileUrl ? '重新上传' : fileType === 5 ? '上传视频' : '上传图片'}
|
||||||
|
</Button>
|
||||||
|
</Upload>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
|
|||||||
+52
-48
@@ -11,6 +11,11 @@ import type { RcFile } from 'antd/lib/upload';
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import type { TYPE_OPTIONS } from '../constants';
|
import type { TYPE_OPTIONS } from '../constants';
|
||||||
|
|
||||||
|
const STATUS_OPTIONS = [
|
||||||
|
{ label: '启用', value: 0, color: 'success' },
|
||||||
|
{ label: '未启用', value: 1, color: 'error' },
|
||||||
|
] as const;
|
||||||
|
|
||||||
interface UpdateFormProps {
|
interface UpdateFormProps {
|
||||||
onSubmit: (values: any) => Promise<void>;
|
onSubmit: (values: any) => Promise<void>;
|
||||||
onVisibleChange: (visible: boolean) => void;
|
onVisibleChange: (visible: boolean) => void;
|
||||||
@@ -22,30 +27,26 @@ interface UpdateFormProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
const [imageUrl, setImageUrl] = useState<string>();
|
const [fileUrl, setFileUrl] = useState<string>((props.values as any)?.fileUrl || (props.values as any)?.imageUrl || '');
|
||||||
const [imagePath, setImagePath] = useState<string>();
|
const [fileType, setFileType] = useState<number | undefined>((props.values as any)?.type);
|
||||||
|
|
||||||
const handleUpload = async (file: RcFile) => {
|
const handleUpload = async (file: RcFile): Promise<boolean> => {
|
||||||
const hide = message.loading('正在上传...');
|
const hide = message.loading('正在上传');
|
||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const result = await importImage(formData);
|
const result = await importImage(formData);
|
||||||
hide();
|
hide();
|
||||||
|
if (result.url) {
|
||||||
if (result.url && result.path) {
|
setFileUrl(result.url);
|
||||||
message.success('上传成功');
|
message.success('上传成功');
|
||||||
setImageUrl(result.url);
|
|
||||||
setImagePath(result.path);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
message.error('上传失败:未获取到文件信息');
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
hide();
|
hide();
|
||||||
message.error('上传失败:' + (error.message || '未知错误'));
|
message.error('上传失败');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -55,13 +56,13 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
onVisibleChange={props.onVisibleChange}
|
onVisibleChange={props.onVisibleChange}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
if (imagePath) {
|
if (fileUrl) {
|
||||||
values.imageUrl = imagePath;
|
values.fileUrl = fileUrl;
|
||||||
}
|
}
|
||||||
const success = await props.onSubmit(values);
|
const success = await props.onSubmit(values);
|
||||||
if (success) {
|
if (success) {
|
||||||
setImageUrl(undefined);
|
setFileUrl('');
|
||||||
setImagePath(undefined);
|
setFileType(undefined);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}}
|
}}
|
||||||
@@ -83,7 +84,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
name="type"
|
name="type"
|
||||||
label="素材类型"
|
label="素材类型"
|
||||||
placeholder="请选择素材类型"
|
placeholder="请选择素材类型"
|
||||||
options={props.typeOptions}
|
options={props.typeOptions as any}
|
||||||
|
fieldProps={{
|
||||||
|
onChange: (val: number) => setFileType(val),
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
rules={[{ required: true, message: '请选择状态' }]}
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
@@ -91,7 +95,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
name="status"
|
name="status"
|
||||||
label="状态"
|
label="状态"
|
||||||
placeholder="请选择状态"
|
placeholder="请选择状态"
|
||||||
options={props.statusOptions}
|
options={STATUS_OPTIONS as any}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
@@ -105,38 +109,38 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
label="素材描述"
|
label="素材描述"
|
||||||
placeholder="输入描述"
|
placeholder="输入描述"
|
||||||
/>
|
/>
|
||||||
|
<Upload
|
||||||
<Form.Item label="素材图片" required>
|
maxCount={1}
|
||||||
<Upload
|
accept={fileType === 5 ? 'video/*' : 'image/*'}
|
||||||
maxCount={1}
|
showUploadList={false}
|
||||||
accept="image/*"
|
customRequest={async ({ file, onSuccess, onError }) => {
|
||||||
showUploadList={false}
|
try {
|
||||||
customRequest={async ({ file, onSuccess, onError }) => {
|
if (file instanceof File) {
|
||||||
try {
|
const success = await handleUpload(file as RcFile);
|
||||||
if (file instanceof File) {
|
if (success) {
|
||||||
const success = await handleUpload(file as RcFile);
|
onSuccess?.('ok');
|
||||||
if (success) {
|
} else {
|
||||||
onSuccess?.('ok');
|
onError?.(new Error('上传失败') as any);
|
||||||
} else {
|
|
||||||
onError?.(new Error('上传失败'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
onError?.(error);
|
|
||||||
}
|
}
|
||||||
}}
|
} catch (error) {
|
||||||
>
|
onError?.(error as any);
|
||||||
<Button icon={<UploadOutlined />}>上传素材</Button>
|
}
|
||||||
</Upload>
|
}}
|
||||||
|
>
|
||||||
<div style={{ marginTop: 16 }}>
|
<Button icon={<UploadOutlined />}>
|
||||||
<Image
|
{fileUrl ? '重新上传' : fileType === 5 ? '上传视频' : '上传图片'}
|
||||||
src={imageUrl || props.values?.imageUrl}
|
</Button>
|
||||||
width={200}
|
</Upload>
|
||||||
style={{ objectFit: 'cover' }}
|
<div style={{ marginTop: 16 }}>
|
||||||
/>
|
{fileUrl ? (
|
||||||
</div>
|
fileType === 5 ? (
|
||||||
</Form.Item>
|
<video src={fileUrl} controls style={{ maxWidth: '200px', maxHeight: '200px' }} />
|
||||||
|
) : (
|
||||||
|
<Image src={fileUrl} width={200} style={{ objectFit: 'cover' }} />
|
||||||
|
)
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// 将常量配置抽离到单独文件
|
// 将常量配置抽离到单独文件
|
||||||
export const TYPE_OPTIONS = [
|
export const TYPE_OPTIONS = [
|
||||||
|
{ label: '景区视频', value: 5 },
|
||||||
|
{ label: '景区订单展示图', value: 6 },
|
||||||
{ label: '展示大图', value: 4 },
|
{ label: '展示大图', value: 4 },
|
||||||
{ label: '拍照引导图', value: 3 },
|
{ label: '拍照引导图', value: 3 },
|
||||||
{ label: '拍照角度展示图', value: 2 },
|
{ label: '拍照角度展示图', value: 2 },
|
||||||
@@ -17,4 +19,6 @@ export const TYPE_CONFIG = {
|
|||||||
2: { color: '#13c2c2', text: '拍照角度' }, // 青色
|
2: { color: '#13c2c2', text: '拍照角度' }, // 青色
|
||||||
3: { color: '#722ed1', text: '引导' }, // 紫色
|
3: { color: '#722ed1', text: '引导' }, // 紫色
|
||||||
4: { color: '#52c41a', text: '大图' }, // 绿色
|
4: { color: '#52c41a', text: '大图' }, // 绿色
|
||||||
|
5: { color: '#f5222d', text: '景区视频' }, // 红色
|
||||||
|
6: { color: '#2f54eb', text: '订单展示图' }, // 蓝色
|
||||||
} as const;
|
} as const;
|
||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
import { Typography, Popconfirm, Space, message, Image, Button, Tag, Upload, Spin } from 'antd';
|
import { Typography, Popconfirm, Space, message, Image, Button, Tag, Upload, Spin } from 'antd';
|
||||||
import type { RcFile } from 'antd/lib/upload';
|
import type { RcFile } from 'antd/lib/upload';
|
||||||
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
||||||
import { STATUS_CONFIG, TYPE_CONFIG } from './constants';
|
import { STATUS_CONFIG, TYPE_CONFIG, TYPE_OPTIONS } from './constants';
|
||||||
import CreateForm from './components/CreateForm';
|
import CreateForm from './components/CreateForm';
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
import SearchForm from './components/SearchForm';
|
import SearchForm from './components/SearchForm';
|
||||||
@@ -28,14 +28,6 @@ const STATUS_OPTIONS = [
|
|||||||
{ label: '未启用', value: 1, color: 'error' },
|
{ label: '未启用', value: 1, color: 'error' },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
// 类型常量
|
|
||||||
const TYPE_OPTIONS = [
|
|
||||||
{ label: '展示大图', value: 4, color: 'blue' },
|
|
||||||
{ label: '拍照引导图', value: 3, color: 'green' },
|
|
||||||
{ label: '拍照角度展示图', value: 2, color: 'cyan' },
|
|
||||||
{ label: '活动', value: 1, color: 'orange' },
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
// 状态映射
|
// 状态映射
|
||||||
const statusColorMap = {
|
const statusColorMap = {
|
||||||
0: { color: 'green', text: '启用' },
|
0: { color: 'green', text: '启用' },
|
||||||
|
|||||||
@@ -432,4 +432,12 @@ export async function updateExpiredCoupons() {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
return result;
|
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