feat: 航线管理页面优化
This commit is contained in:
+12
-1
@@ -1,8 +1,11 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.FileCenterService;
|
||||
import com.central.device.model.LineFile;
|
||||
import com.central.device.model.vo.WaypointInfoVO;
|
||||
import com.central.device.service.ILineFileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -13,6 +16,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -32,6 +36,9 @@ import java.util.stream.Collectors;
|
||||
public class LineFileController {
|
||||
private final ILineFileService lineFileService;
|
||||
|
||||
@Resource
|
||||
private FileCenterService fileCenterService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@@ -56,7 +63,11 @@ public class LineFileController {
|
||||
if (model == null) {
|
||||
return Result.failed("未找到对应的航线文件信息");
|
||||
}
|
||||
return Result.succeed(model, "查询成功");
|
||||
String fileurl = fileCenterService.getFileViewUrl(model.getWaylineId());
|
||||
WaypointInfoVO infoVO = new WaypointInfoVO();
|
||||
BeanUtil.copyProperties(model,infoVO);
|
||||
infoVO.setFileUrl(fileurl);
|
||||
return Result.succeed(infoVO, "查询成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询航线文件失败,id: {}", id, e);
|
||||
return Result.failed("查询航线文件失败:" + e.getMessage());
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package com.central.device.feign;
|
||||
|
||||
import com.central.common.constant.ServiceNameConstants;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.fallback.FileCenterServiceFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* user-center模块远程调用
|
||||
*
|
||||
* @author lsl
|
||||
* @version 1.0
|
||||
* @description user-center模块远程调用
|
||||
* @create 2025/1/13
|
||||
**/
|
||||
@FeignClient(name = ServiceNameConstants.FILE_SERVICE, fallbackFactory = FileCenterServiceFallbackFactory.class, dismiss404 = true)
|
||||
public interface FileCenterService {
|
||||
|
||||
/**
|
||||
* 通过ID查询预览地址
|
||||
*
|
||||
* @param id 文件ID
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/file/{id}")
|
||||
String getFileViewUrl(@PathVariable("id") String id);
|
||||
|
||||
@GetMapping("/type/{id}")
|
||||
String getFileContentType(@PathVariable("id") String id);
|
||||
|
||||
@GetMapping("/qrcode/{codeId}")
|
||||
Result<Map> uploadQrCodeFile(@PathVariable("codeId") String codeId) throws Exception;
|
||||
|
||||
@PostMapping("/path")
|
||||
FileInfo creatFileInfo(@RequestBody String path);
|
||||
|
||||
@GetMapping("/files/path")
|
||||
String getViewUrlByPath(@RequestParam("path") String path) ;
|
||||
|
||||
@GetMapping("/files/path/style")
|
||||
String getViewUrlByPathStyle(@RequestParam("params") Map<String,String> params) ;
|
||||
|
||||
@GetMapping("/list/files")
|
||||
List<String> getListFiles(@RequestParam("prefix") String prefix) ;
|
||||
|
||||
/**
|
||||
* 预热文件到CDN
|
||||
*
|
||||
* @param urls 需要预热的URL列表
|
||||
* @param area 预热范围:domestic-仅中国内地,overseas-全球(不包含中国内地),不传-全球
|
||||
* @return 预热任务ID
|
||||
*/
|
||||
@PostMapping("/cdn/prefetch")
|
||||
Result<String> prefetchFiles(@RequestBody List<String> urls, @RequestParam(value = "area", required = false) String area);
|
||||
|
||||
/**
|
||||
* 批量预热文件到CDN
|
||||
*
|
||||
* @param urls 需要预热的URL列表
|
||||
* @param batchSize 每批次处理的URL数量
|
||||
* @param area 预热范围
|
||||
* @return 预热任务执行结果
|
||||
*/
|
||||
@PostMapping("/cdn/batch/prefetch")
|
||||
Result<Boolean> batchPrefetchFiles(@RequestBody List<String> urls,
|
||||
@RequestParam(value = "batchSize", defaultValue = "100") int batchSize,
|
||||
@RequestParam(value = "area", required = false) String area);
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.central.device.feign.fallback;
|
||||
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.FileCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件中心调用失败回调
|
||||
*
|
||||
* @author lsl
|
||||
* @version 1.0
|
||||
* @description 用户中心调用失败回调
|
||||
* @create 2025/1/17 11:33
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCenterService> {
|
||||
|
||||
@Override
|
||||
public FileCenterService create(Throwable cause) {
|
||||
return new FileCenterService() {
|
||||
|
||||
@Override
|
||||
public String getFileViewUrl(String id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileContentType(String id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Map> uploadQrCodeFile(String codeId) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo creatFileInfo(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByPath(String path) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByPathStyle(Map<String, String> params) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getListFiles(String prefix) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> prefetchFiles(List<String> urls, String area) {
|
||||
log.warn("CDN预热文件失败,URLs: {}, area: {}", urls, area, cause);
|
||||
return Result.failed("CDN预热文件失败: " + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> batchPrefetchFiles(List<String> urls, int batchSize, String area) {
|
||||
log.warn("CDN批量预热文件失败,URLs: {}, batchSize: {}, area: {}", urls, batchSize, area, cause);
|
||||
return Result.failed("CDN批量预热文件失败: " + cause.getMessage());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,6 @@ public class LineFile extends SuperEntity {
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
private String tenantId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.central.device.model.vo;
|
||||
|
||||
import com.central.device.model.LineFile;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WaypointInfoVO extends LineFile {
|
||||
|
||||
private String fileUrl;
|
||||
}
|
||||
@@ -3,6 +3,22 @@
|
||||
|
||||
<mapper namespace="com.central.device.mapper.LineFileMapper">
|
||||
<select id="findList" resultType="com.central.device.model.LineFile">
|
||||
select * from wayline_file t
|
||||
select * from wayline_file t where 1=1
|
||||
<if test="p.name != null and p.name != ''">
|
||||
and t.name like concat('%', #{p.name}, '%')
|
||||
</if>
|
||||
<if test="p.waylineId != null and p.waylineId != ''">
|
||||
and t.wayline_id = #{p.waylineId}
|
||||
</if>
|
||||
<if test="p.workspaceId != null and p.workspaceId != ''">
|
||||
and t.workspace_id = #{p.workspaceId}
|
||||
</if>
|
||||
<if test="p.droneModelKey != null and p.droneModelKey != ''">
|
||||
and t.drone_model_key = #{p.droneModelKey}
|
||||
</if>
|
||||
<if test="p.userName != null and p.userName != ''">
|
||||
and t.user_name like concat('%', #{p.userName}, '%')
|
||||
</if>
|
||||
order by t.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ public class RefundServiceImpl extends SuperServiceImpl<RefundMapper, Refund> im
|
||||
result.put("reason", refund.getRefundReason());
|
||||
result.put("refundReason", refund.getRefundReason());
|
||||
result.put("approveReason", refund.getApproveReason());
|
||||
result.put("createTime", refund.getCreateTime());
|
||||
result.put("refundTime", refund.getRefundTime());
|
||||
result.put("applyTime", refund.getCreateTime());
|
||||
|
||||
// 处理图片列表 - refundImgs 可能是逗号分隔的字符串或JSON
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 2.7 MiB |
@@ -59,7 +59,8 @@ const BasicLayout: React.FC = (props: any) => {
|
||||
if (!cand) return undefined;
|
||||
const lower = cand.toLowerCase();
|
||||
if (lower.startsWith('http')) return cand; // 澶栭摼
|
||||
if (lower.endsWith('.html')) return cand.startsWith('/') ? cand : `/${cand}`; // 闈欐€佽矾鐢? if (lower === '/welcome' || lower === 'welcome') return '/welcome';
|
||||
if (lower.endsWith('.html')) return cand.startsWith('/') ? cand : `/${cand}`; // 闈欐€佽矾鐢?
|
||||
if (lower === '/welcome' || lower === 'welcome') return '/welcome';
|
||||
// 鍏煎鍚庣鑿滃崟鏈甫 .html 鐨勫彾瀛愯矾鐢憋紝渚嬪 /system/tenant => /system/tenant.html
|
||||
const ensureSlash = cand.startsWith('/') ? cand : `/${cand}`;
|
||||
const parts = ensureSlash.split('/').filter(Boolean);
|
||||
@@ -96,7 +97,7 @@ const BasicLayout: React.FC = (props: any) => {
|
||||
|
||||
const item: MenuDataItem = {
|
||||
key: keyStr,
|
||||
name: menu.name || `鑿滃崟${index + 1}`,
|
||||
name: menu.name || `保存中${index + 1}`,
|
||||
path,
|
||||
icon: getIcon(path),
|
||||
children: childrenList.map((child: MenuNode, i: number) => normalize(child, i, keyStr)),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { ModalForm, ProForm, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
||||
import { Button, Upload, message } from 'antd';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import { deviceApi } from '@/services/device';
|
||||
|
||||
export type WaylineFormValues = {
|
||||
id?: number;
|
||||
@@ -33,21 +34,57 @@ async function uploadWaylineFile(file: File) {
|
||||
const WaylineForm: React.FC<WaylineFormProps> = ({ title, visible, onVisibleChange, onFinish, initialValues, workspaceOptions }) => {
|
||||
const formRef = useRef<any>();
|
||||
const [fileInfo, setFileInfo] = useState<{ id: string; url: string } | undefined>();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
/**
|
||||
* 当编辑页面打开时,如果有waylineId,调用接口获取完整信息
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (initialValues) {
|
||||
if (visible && initialValues?.waylineId) {
|
||||
setLoading(true);
|
||||
deviceApi
|
||||
.getWaylineInfoByWaylineId(initialValues.waylineId)
|
||||
.then((data) => {
|
||||
if (data) {
|
||||
formRef.current?.setFieldsValue({
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
waylineId: data.waylineId,
|
||||
workspaceId: data.workspaceId,
|
||||
sign: data.sign,
|
||||
});
|
||||
// 如果有fileUrl,设置文件信息
|
||||
if (data.fileUrl) {
|
||||
setFileInfo({
|
||||
id: data.waylineId || data.id?.toString() || '',
|
||||
url: data.fileUrl,
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('获取航线信息失败:', err);
|
||||
message.error('获取航线信息失败');
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
} else if (visible && initialValues) {
|
||||
// 新增时直接回显
|
||||
formRef.current?.setFieldsValue(initialValues);
|
||||
}
|
||||
}, [initialValues]);
|
||||
}, [visible, initialValues?.waylineId]);
|
||||
|
||||
return (
|
||||
<ModalForm<WaylineFormValues>
|
||||
title={title}
|
||||
visible={visible}
|
||||
formRef={formRef}
|
||||
loading={loading}
|
||||
onVisibleChange={(v) => {
|
||||
onVisibleChange?.(v);
|
||||
if (!v) setFileInfo(undefined);
|
||||
if (!v) {
|
||||
setFileInfo(undefined);
|
||||
setLoading(false);
|
||||
}
|
||||
}}
|
||||
onFinish={async (values) => {
|
||||
if (!values.waylineId && !fileInfo) {
|
||||
|
||||
@@ -2,7 +2,8 @@ import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
||||
import type { ActionType } from '@ant-design/pro-components';
|
||||
import { ProTable } from '@ant-design/pro-components';
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import { Space } from 'antd';
|
||||
import { Space, message } from 'antd';
|
||||
import { DownloadOutlined } from '@ant-design/icons';
|
||||
import { deviceApi } from '@/services/device';
|
||||
import { downloadByUrl } from '@/utils/download';
|
||||
|
||||
@@ -21,27 +22,64 @@ const WaylineTable = forwardRef<WaylineTableRef, WaylineTableProps>(({ params, o
|
||||
|
||||
useImperativeHandle(ref, () => ({ reload: () => actionRef.current?.reload() }));
|
||||
|
||||
/**
|
||||
* 处理航线文件下载
|
||||
* 先通过waylineId获取航线信息(包含fileUrl),再使用fileUrl下载
|
||||
*/
|
||||
const handleDownload = async (record: any) => {
|
||||
try {
|
||||
if (!record.waylineId) {
|
||||
message.error('航线ID缺失');
|
||||
return;
|
||||
}
|
||||
|
||||
const hide = message.loading('获取航线信息中...');
|
||||
try {
|
||||
// 通过waylineId获取航线完整信息,包括fileUrl
|
||||
const waylineInfo = await deviceApi.getWaylineInfoByWaylineId(record.waylineId);
|
||||
hide();
|
||||
|
||||
if (!waylineInfo) {
|
||||
message.error('无法获取航线信息');
|
||||
return;
|
||||
}
|
||||
|
||||
const fileUrl = waylineInfo.fileUrl;
|
||||
if (!fileUrl) {
|
||||
message.error('航线文件URL不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用fileUrl直接下载
|
||||
const fileName = record.name || `wayline_${record.waylineId}`;
|
||||
downloadByUrl(fileUrl, fileName);
|
||||
message.success('开始下载航线文件');
|
||||
} catch (error) {
|
||||
hide();
|
||||
console.error('获取航线信息失败:', error);
|
||||
message.error('获取航线信息失败');
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('下载失败');
|
||||
console.error('下载航线文件错误:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const columns: ProColumns<any>[] = [
|
||||
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
|
||||
{ title: '航线名称', dataIndex: 'name' },
|
||||
{ title: '航线ID', dataIndex: 'waylineId' },
|
||||
{ title: '空间ID', dataIndex: 'workspaceId' },
|
||||
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
|
||||
{
|
||||
title: '航线文件', dataIndex: 'fileUrl', search: false,
|
||||
render: (_, record) => record.fileUrl ? (
|
||||
<a
|
||||
href={record.fileUrl}
|
||||
onClick={(e) => { e.preventDefault(); downloadByUrl(record.fileUrl, record.name || 'wayline.kmz'); }}
|
||||
>下载文件</a>
|
||||
) : '-'
|
||||
},
|
||||
{ title: '文件签名', dataIndex: 'sign', ellipsis: true, copyable: true },
|
||||
{
|
||||
title: '操作', key: 'action', valueType: 'option',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<a onClick={() => onEdit?.(record)}>编辑</a>
|
||||
<a onClick={() => handleDownload(record)} title="下载航线文件">
|
||||
<DownloadOutlined /> 下载
|
||||
</a>
|
||||
<a style={{ color: '#1677ff' }} onClick={() => onDelete?.(record)}>删除</a>
|
||||
</Space>
|
||||
)
|
||||
@@ -62,3 +100,4 @@ const WaylineTable = forwardRef<WaylineTableRef, WaylineTableProps>(({ params, o
|
||||
});
|
||||
|
||||
export default WaylineTable;
|
||||
|
||||
|
||||
@@ -62,8 +62,15 @@ const WaylinePage: React.FC = () => {
|
||||
|
||||
return (
|
||||
<PageContainer header={{ title: '航线管理' }}>
|
||||
<SearchBarPlus defaultCollapsed split span={6} onTenantChanged={() => tableRef.current?.reload()} onFinish={async (values) => setQuery(values)}>
|
||||
<ProFormText name="name" label="名称" placeholder="请输入关键字" />
|
||||
<SearchBarPlus
|
||||
defaultCollapsed
|
||||
split span={6}
|
||||
hideReset
|
||||
showTenant={false}
|
||||
onTenantChanged={() => tableRef.current?.reload()}
|
||||
onFinish={async (values) => setQuery(values)}>
|
||||
<ProFormText name="name" label="航线名称" />
|
||||
<ProFormText name="waylineId" label="航线code" />
|
||||
</SearchBarPlus>
|
||||
|
||||
<ActionBar left={<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={() => setCreateOpen(true)}>新增</GradientButton>} />
|
||||
|
||||
@@ -1,344 +0,0 @@
|
||||
# 首页轮播图 - 问题修复总结
|
||||
|
||||
## 🔧 已修复的问题
|
||||
|
||||
### 1. **表格列显示缺失问题** ✅
|
||||
|
||||
**问题描述:** 表格中没有显示标题、类型和描述字段
|
||||
|
||||
**修复方案:** 在 `index.tsx` 中添加了缺失的表格列
|
||||
|
||||
**修改内容:**
|
||||
|
||||
```typescript
|
||||
// 新增的列定义
|
||||
{
|
||||
title: '标题',
|
||||
dataIndex: 'title',
|
||||
ellipsis: true,
|
||||
copyable: true,
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
width: 100,
|
||||
valueEnum: TYPE_OPTIONS.reduce((acc, curr) => ({
|
||||
...acc,
|
||||
[curr.value]: { text: curr.label },
|
||||
}), {}),
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'description',
|
||||
ellipsis: true,
|
||||
},
|
||||
```
|
||||
|
||||
**结果:**
|
||||
- ✅ 表格现在完整显示:序号 → 标题 → 图片 → 链接 → 类型 → 描述 → 排序 → 状态 → 操作
|
||||
- ✅ 标题支持复制功能
|
||||
- ✅ 类型字段使用 valueEnum 规范化显示
|
||||
|
||||
---
|
||||
|
||||
### 2. **类型字段缺失问题** ✅
|
||||
|
||||
**问题描述:** 表单中没有类型字段,无法选择轮播图类型
|
||||
|
||||
**修复方案:**
|
||||
|
||||
#### a. 更新类型定义 (`HomeCarouselForm.tsx`)
|
||||
|
||||
```typescript
|
||||
export interface HomeCarouselItem {
|
||||
id?: number;
|
||||
imageUrl?: string;
|
||||
linkUrl?: string;
|
||||
sort?: number;
|
||||
status?: number;
|
||||
title?: string;
|
||||
description?: string;
|
||||
type?: number; // 新增
|
||||
}
|
||||
```
|
||||
|
||||
#### b. 在编辑表单添加类型选择
|
||||
|
||||
```typescript
|
||||
<ProFormSelect
|
||||
name="type"
|
||||
label="类型"
|
||||
placeholder="请选择类型"
|
||||
options={[
|
||||
{ label: '首页轮播', value: 0 },
|
||||
{ label: '活动', value: 1 },
|
||||
{ label: '其他', value: 2 },
|
||||
]}
|
||||
rules={[{ required: true, message: '请选择类型' }]}
|
||||
/>
|
||||
```
|
||||
|
||||
#### c. 在新增表单添加类型选择
|
||||
|
||||
同样在 `CreateForm.tsx` 中添加了完整的类型选择字段
|
||||
|
||||
**结果:**
|
||||
- ✅ 编辑和新增表单都支持类型选择
|
||||
- ✅ 类型为必填项,确保数据完整性
|
||||
|
||||
---
|
||||
|
||||
### 3. **描述字段缺失问题** ✅
|
||||
|
||||
**问题描述:** 表单中缺少描述字段,无法为轮播图添加描述
|
||||
|
||||
**修复方案:** 在编辑和新增表单中添加了描述文本域
|
||||
|
||||
```typescript
|
||||
<ProFormTextArea
|
||||
name="description"
|
||||
label="描述"
|
||||
placeholder="请输入轮播图描述"
|
||||
fieldProps={{
|
||||
rows: 3,
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
**结果:**
|
||||
- ✅ 可以为轮播图添加多行描述信息
|
||||
- ✅ 文本域高度为 3 行,便于输入较长内容
|
||||
|
||||
---
|
||||
|
||||
### 4. **按钮点击无响应问题** ✅
|
||||
|
||||
**问题描述:** 点击"新增轮播图"和"编辑"按钮没有任何反应,弹窗无法打开
|
||||
|
||||
**问题原因:**
|
||||
- 使用 `Button` 组件时可能存在样式或事件冒泡问题
|
||||
- 表格操作列使用 `Space` 包裹可能导致事件捕获失效
|
||||
|
||||
**修复方案:**
|
||||
|
||||
#### a. 改进新增按钮
|
||||
|
||||
**改进前:**
|
||||
```typescript
|
||||
<Button
|
||||
key="add"
|
||||
type="primary"
|
||||
onClick={() => setCreateOpen(true)}
|
||||
>
|
||||
<PlusOutlined /> 新增轮播图
|
||||
</Button>
|
||||
```
|
||||
|
||||
**改进后:**
|
||||
```typescript
|
||||
<a
|
||||
key="add"
|
||||
onClick={() => {
|
||||
console.log('新增按钮被点击');
|
||||
setCreateOpen(true);
|
||||
}}
|
||||
style={{ color: '#1890ff', cursor: 'pointer' }}
|
||||
>
|
||||
<PlusOutlined /> 新增轮播图
|
||||
</a>
|
||||
```
|
||||
|
||||
#### b. 改进编辑和删除按钮
|
||||
|
||||
**改进前:**
|
||||
```typescript
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Link onClick={() => { /* ... */ }}>
|
||||
<EditOutlined /> 编辑
|
||||
</Link>
|
||||
{/* ... */}
|
||||
</Space>
|
||||
)
|
||||
```
|
||||
|
||||
**改进后(使用 array 渲染):**
|
||||
```typescript
|
||||
render: (_, record) => [
|
||||
<a
|
||||
key="edit"
|
||||
onClick={() => {
|
||||
console.log('编辑按钮被点击', record);
|
||||
setCurrent(record);
|
||||
setEditOpen(true);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</a>,
|
||||
<Popconfirm
|
||||
key="delete"
|
||||
title="确认删除?"
|
||||
description="删除后将无法恢复,请谨慎操作"
|
||||
onConfirm={() => handleDelete(record)}
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
>
|
||||
<a>删除</a>
|
||||
</Popconfirm>,
|
||||
]
|
||||
```
|
||||
|
||||
**改进点:**
|
||||
1. ✅ 使用原生 `<a>` 标签替代 `Link` 组件,减少事件捕获问题
|
||||
2. ✅ 使用 array 渲染方式替代 `Space` 包裹,避免事件冒泡问题
|
||||
3. ✅ 添加 `console.log` 便于调试点击事件
|
||||
4. ✅ 为 Popconfirm 添加中文按钮文本
|
||||
5. ✅ 为表格操作列添加 `fixed: 'right'` 确保列固定在右侧
|
||||
|
||||
**结果:**
|
||||
- ✅ 新增按钮点击立即响应,打开新增表单
|
||||
- ✅ 编辑按钮点击立即响应,打开编辑表单并显示现有数据
|
||||
- ✅ 删除按钮点击显示确认对话框,确认后删除记录
|
||||
|
||||
---
|
||||
|
||||
## 📋 完整的表单字段列表
|
||||
|
||||
现在完整支持以下字段的编辑和显示:
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
|------|------|------|------|
|
||||
| title | string | ✅ | 轮播图标题 |
|
||||
| imageUrl | string | ✅ | 图片地址(本地或远程 URL) |
|
||||
| linkUrl | string | ❌ | 跳转链接(可选) |
|
||||
| type | number | ✅ | 类型(0-首页轮播, 1-活动, 2-其他) |
|
||||
| description | string | ❌ | 轮播图描述(可选) |
|
||||
| sort | number | ❌ | 排序号(默认 1,数字越小越靠前) |
|
||||
| status | number | ✅ | 状态(0-禁用, 1-启用) |
|
||||
|
||||
---
|
||||
|
||||
## 🎯 关键改进点
|
||||
|
||||
### 用户体验优化
|
||||
|
||||
1. **搜索功能**
|
||||
- 支持按标题搜索
|
||||
- 支持按状态筛选
|
||||
- 搜索结果自动刷新表格
|
||||
|
||||
2. **表单验证**
|
||||
- 标题、图片、类型、状态为必填项
|
||||
- 链接支持 URL 格式验证
|
||||
- 实时显示验证错误提示
|
||||
|
||||
3. **操作反馈**
|
||||
- 新增/编辑/删除时显示加载状态
|
||||
- 操作完成后显示成功/失败提示
|
||||
- 表格自动刷新显示最新数据
|
||||
|
||||
4. **界面美化**
|
||||
- 使用 AntImage 组件显示图片预览
|
||||
- 链接可点击访问目标 URL
|
||||
- 类型使用中文标签显示
|
||||
- 状态使用颜色语义化表示(绿-启用,红-禁用)
|
||||
|
||||
---
|
||||
|
||||
## 🔍 调试信息
|
||||
|
||||
为了便于调试,代码中添加了 console.log 日志:
|
||||
|
||||
```typescript
|
||||
// 新增按钮点击时
|
||||
console.log('新增按钮被点击');
|
||||
|
||||
// 编辑按钮点击时
|
||||
console.log('编辑按钮被点击', record);
|
||||
```
|
||||
|
||||
可以打开浏览器开发者工具的 Console 选项卡,查看这些日志确认按钮是否被正确触发。
|
||||
|
||||
---
|
||||
|
||||
## 📝 使用流程
|
||||
|
||||
### 新增轮播图
|
||||
|
||||
1. 点击工具栏的"新增轮播图"按钮
|
||||
2. 在弹窗中填写:
|
||||
- 标题(必填)
|
||||
- 图片地址(必填)
|
||||
- 跳转链接(可选)
|
||||
- 类型(必填)
|
||||
- 描述(可选)
|
||||
- 排序号(默认 1)
|
||||
- 状态(默认启用)
|
||||
3. 上传图片并预览
|
||||
4. 点击"提交"按钮
|
||||
5. 成功后表格自动刷新显示新增的轮播图
|
||||
|
||||
### 编辑轮播图
|
||||
|
||||
1. 在表格中点击目标轮播图的"编辑"按钮
|
||||
2. 弹窗打开并显示现有数据
|
||||
3. 修改需要改动的字段
|
||||
4. 点击"提交"按钮
|
||||
5. 成功后表格自动刷新显示更新的轮播图
|
||||
|
||||
### 删除轮播图
|
||||
|
||||
1. 在表格中点击目标轮播图的"删除"按钮
|
||||
2. 确认对话框出现
|
||||
3. 点击"确认"按钮确认删除
|
||||
4. 成功后表格自动刷新
|
||||
|
||||
---
|
||||
|
||||
## 📚 文件变更统计
|
||||
|
||||
```
|
||||
修改文件:
|
||||
- index.tsx (表格列、按钮事件、表单集成)
|
||||
- components/HomeCarouselForm.tsx (表单字段、类型定义)
|
||||
- components/CreateForm.tsx (表单字段、新增逻辑)
|
||||
|
||||
Git Commits:
|
||||
- ed7fc3fe: fix: 修复首页轮播图表单和按钮响应问题
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ 验收清单
|
||||
|
||||
- [x] 表格显示标题字段
|
||||
- [x] 表格显示类型字段
|
||||
- [x] 表格显示描述字段
|
||||
- [x] 新增按钮可点击响应
|
||||
- [x] 编辑按钮可点击响应
|
||||
- [x] 表单包含类型选择
|
||||
- [x] 表单包含描述文本域
|
||||
- [x] 编辑时表单数据正确加载
|
||||
- [x] 删除时显示确认对话框
|
||||
- [x] 操作成功后表格自动刷新
|
||||
- [x] 添加调试日志便于排查问题
|
||||
|
||||
---
|
||||
|
||||
## 🚀 下一步建议
|
||||
|
||||
1. **本地测试**
|
||||
- 打开浏览器 F12 开发者工具
|
||||
- 查看 Console 选项卡确认按钮点击日志
|
||||
- 测试各个功能的完整流程
|
||||
|
||||
2. **后端确认**
|
||||
- 确保 API 字段名与前端一致
|
||||
- 验证新增/编辑/删除接口正确返回
|
||||
- 检查图片上传接口是否配置正确
|
||||
|
||||
3. **后续优化**
|
||||
- 考虑添加批量删除功能
|
||||
- 考虑添加导入/导出功能
|
||||
- 考虑优化大图片上传的性能
|
||||
|
||||
@@ -1,389 +0,0 @@
|
||||
## HomeCarousel 页面优化总结
|
||||
|
||||
### 优化内容概览
|
||||
|
||||
根据 `react-web` 中的最佳实践,对 `react-web-next` 的 HomeCarousel 页面进行了全面优化,采用组件化架构。
|
||||
|
||||
---
|
||||
|
||||
## 📁 文件结构
|
||||
|
||||
```
|
||||
src/pages/orders/HomeCarousel/
|
||||
├── index.tsx # 主页面 - 列表展示和页面逻辑
|
||||
├── components/
|
||||
│ ├── HomeCarouselForm.tsx # 编辑表单组件
|
||||
│ └── CreateForm.tsx # 新增表单组件(包含图片上传)
|
||||
├── index.less # 页面样式
|
||||
└── constants.ts # 常量和类型定义
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 主要优化点
|
||||
|
||||
### 1. **架构优化** (index.tsx:1-211)
|
||||
|
||||
**改进前:**
|
||||
- 混乱的状态管理,参数名称不统一
|
||||
- 使用了自定义 UI 组件 (ActionBar, GlassCard, GradientButton)
|
||||
- 操作逻辑分散在渲染中
|
||||
|
||||
**改进后:**
|
||||
- 采用 Pro Components 标准组件库
|
||||
- 使用 QueryFilter 和 ProTable 的官方规范
|
||||
- 清晰的状态和变量命名
|
||||
- 分离业务逻辑到独立函数 `handleDelete()`
|
||||
|
||||
**关键改进:**
|
||||
```typescript
|
||||
// 状态管理规范化
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [current, setCurrent] = useState<HomeCarouselItem | undefined>(undefined);
|
||||
const [searchParams, setSearchParams] = useState<Record<string, any>>({});
|
||||
|
||||
// 使用 ActionRef 管理表格刷新
|
||||
const actionRef = useRef<ActionType>();
|
||||
|
||||
// 独立的业务逻辑函数
|
||||
const handleDelete = async (record: HomeCarouselItem) => {
|
||||
const hide = message.loading('删除中...');
|
||||
try {
|
||||
await ordersApi.deleteHomeCarousel(record.id!);
|
||||
message.success('删除成功');
|
||||
actionRef.current?.reload();
|
||||
return true;
|
||||
} catch (e) {
|
||||
message.error('删除失败');
|
||||
return false;
|
||||
} finally {
|
||||
hide();
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### 2. **表格列配置优化** (index.tsx:43-111)
|
||||
|
||||
**改进前:**
|
||||
- 使用基础 HTML img 标签
|
||||
- 状态展示用 Tag 组件,颜色值硬编码
|
||||
- 链接无法点击
|
||||
|
||||
**改进后:**
|
||||
```typescript
|
||||
// 使用 AntImage 组件,支持图片预览
|
||||
{
|
||||
title: '图片',
|
||||
dataIndex: 'imageUrl',
|
||||
width: 120,
|
||||
render: (imageUrl: string) => (
|
||||
<AntImage
|
||||
src={imageUrl}
|
||||
width={100}
|
||||
placeholder={...}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
// 链接可点击访问
|
||||
{
|
||||
title: '跳转链接',
|
||||
dataIndex: 'linkUrl',
|
||||
ellipsis: true,
|
||||
render: (url: string) => (
|
||||
<Link href={url} target="_blank">{url}</Link>
|
||||
),
|
||||
},
|
||||
|
||||
// 使用 valueEnum 规范化状态
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 80,
|
||||
valueEnum: {
|
||||
1: { text: '启用', status: 'Success' },
|
||||
0: { text: '禁用', status: 'Error' },
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### 3. **搜索栏优化** (index.tsx:114-143)
|
||||
|
||||
**改进前:**
|
||||
- 使用自定义 SearchBarPlus 组件
|
||||
- 没有明确的搜索字段定义
|
||||
|
||||
**改进后:**
|
||||
- 使用标准 `QueryFilter` 组件
|
||||
- 支持搜索:标题、状态
|
||||
- 搜索参数规范化处理
|
||||
- 集成样式类
|
||||
|
||||
```typescript
|
||||
<QueryFilter
|
||||
defaultCollapsed={false}
|
||||
split
|
||||
span={8}
|
||||
className={styles['query-filter']}
|
||||
onFinish={async (values) => {
|
||||
setSearchParams(values);
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
>
|
||||
<ProFormText
|
||||
name="title"
|
||||
label="标题"
|
||||
placeholder="请输入标题关键字"
|
||||
fieldProps={{ allowClear: true }}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="status"
|
||||
label="状态"
|
||||
options={STATUS_OPTIONS}
|
||||
fieldProps={{ allowClear: true }}
|
||||
/>
|
||||
</QueryFilter>
|
||||
```
|
||||
|
||||
### 4. **表单组件分离** (components/)
|
||||
|
||||
**新增两个独立的表单组件:**
|
||||
|
||||
#### HomeCarouselForm.tsx(编辑表单)
|
||||
- 专注于编辑功能
|
||||
- 标题为"编辑轮播图"
|
||||
- 包含所有字段:图片地址、标题、链接、排序、状态
|
||||
- 更好的占位符文本和验证规则
|
||||
|
||||
#### CreateForm.tsx(新增表单)
|
||||
- 专注于创建功能
|
||||
- 包含图片上传功能
|
||||
- 实时预览上传的图片
|
||||
- 完整的验证和错误处理
|
||||
- 上传前验证(图片类型、大小)
|
||||
|
||||
**核心特性:**
|
||||
```typescript
|
||||
// 图片上传处理
|
||||
const handleBeforeUpload = (file: RcFile) => {
|
||||
const isImage = file.type.startsWith('image/');
|
||||
const isLt10M = file.size / 1024 / 1024 < 10;
|
||||
if (!isImage) message.error('只能上传图片文件');
|
||||
if (!isLt10M) message.error('图片大小不能超过10MB');
|
||||
return isImage && isLt10M;
|
||||
};
|
||||
|
||||
// 图片预览
|
||||
{imageUrl && (
|
||||
<div style={{ marginTop: 16 }}>
|
||||
<p style={{ marginBottom: 8 }}>图片预览:</p>
|
||||
<AntImage src={imageUrl} width={200} />
|
||||
</div>
|
||||
)}
|
||||
```
|
||||
|
||||
### 5. **样式文件** (index.less)
|
||||
|
||||
**新增样式规范:**
|
||||
```less
|
||||
.query-filter {
|
||||
padding: 24px;
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03), ...;
|
||||
}
|
||||
|
||||
// 表单项间距
|
||||
.ant-form-item {
|
||||
margin-bottom: 24px;
|
||||
&:last-child { margin-bottom: 0; }
|
||||
}
|
||||
|
||||
// 表格美化
|
||||
.ant-pro-table {
|
||||
margin-top: 16px;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
|
||||
.ant-table-thead > tr > th {
|
||||
background-color: #fafafa;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
// 图片组件美化
|
||||
.ant-image-img { border-radius: 4px; }
|
||||
.ant-modal-content { border-radius: 8px; }
|
||||
```
|
||||
|
||||
### 6. **常量管理** (constants.ts)
|
||||
|
||||
**统一管理所有常量和配置:**
|
||||
|
||||
```typescript
|
||||
// 状态选项 - 与表单、表格保持同步
|
||||
export const STATUS_OPTIONS = [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
];
|
||||
|
||||
// 上传配置
|
||||
export const UPLOAD_CONFIG = {
|
||||
maxCount: 1,
|
||||
accept: 'image/*',
|
||||
maxSize: 10 * 1024 * 1024,
|
||||
};
|
||||
|
||||
// 错误消息 - 保持国际化就绪
|
||||
export const ERROR_MESSAGES = {
|
||||
UPLOAD_FAILED: '上传失败',
|
||||
IMAGE_REQUIRED: '请上传轮播图片',
|
||||
SAVE_FAILED: '保存失败',
|
||||
// ...
|
||||
} as const;
|
||||
|
||||
// 成功消息
|
||||
export const SUCCESS_MESSAGES = {
|
||||
UPLOAD_SUCCESS: '上传成功',
|
||||
CREATE_SUCCESS: '新增成功',
|
||||
UPDATE_SUCCESS: '修改成功',
|
||||
DELETE_SUCCESS: '删除成功',
|
||||
} as const;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 功能流程图
|
||||
|
||||
### 新增轮播图流程
|
||||
```
|
||||
点击"新增轮播图" 按钮
|
||||
↓
|
||||
打开 CreateForm 弹窗
|
||||
↓
|
||||
输入标题、链接、排序、状态信息
|
||||
↓
|
||||
上传图片(带预览)
|
||||
↓
|
||||
点击提交
|
||||
↓
|
||||
调用 ordersApi.saveOrUpdateHomeCarousel()
|
||||
↓
|
||||
成功 → 重新加载表格列表
|
||||
失败 → 显示错误消息
|
||||
```
|
||||
|
||||
### 编辑轮播图流程
|
||||
```
|
||||
表格中点击"编辑" 按钮
|
||||
↓
|
||||
打开 HomeCarouselForm 弹窗(填充已有数据)
|
||||
↓
|
||||
修改需要改动的字段
|
||||
↓
|
||||
点击提交
|
||||
↓
|
||||
调用 ordersApi.saveOrUpdateHomeCarousel()
|
||||
↓
|
||||
成功 → 重新加载表格列表
|
||||
失败 → 显示错误消息
|
||||
```
|
||||
|
||||
### 删除轮播图流程
|
||||
```
|
||||
表格中点击"删除" 按钮
|
||||
↓
|
||||
弹出确认对话框(提示"删除后将无法恢复")
|
||||
↓
|
||||
确认删除
|
||||
↓
|
||||
调用 ordersApi.deleteHomeCarousel()
|
||||
↓
|
||||
success → 重新加载表格列表
|
||||
failed → 显示错误消息
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 对比总结
|
||||
|
||||
| 方面 | 改进前 | 改进后 |
|
||||
|------|-------|-------|
|
||||
| **UI 组件** | 自定义组件 (ActionBar, GlassCard) | 标准 Pro Components |
|
||||
| **状态管理** | 混乱的参数名称 | 规范的状态变量 |
|
||||
| **表单分离** | 单一表单组件处理新增编辑 | 两个独立组件 (CreateForm, HomeCarouselForm) |
|
||||
| **图片处理** | 基础 img 标签 | AntImage 组件 + 上传 + 预览 |
|
||||
| **链接展示** | 纯文本 | 可点击链接 |
|
||||
| **搜索功能** | SearchBarPlus (自定义) | QueryFilter (标准) |
|
||||
| **代码组织** | 混合式 | 组件化、常量分离 |
|
||||
| **验证规则** | 缺少 | 完整的表单验证 |
|
||||
| **样式管理** | 无 | 规范的 LESS 样式 |
|
||||
| **错误处理** | 基础 | 详细的加载和错误反馈 |
|
||||
|
||||
---
|
||||
|
||||
## 🚀 使用指南
|
||||
|
||||
### 安装依赖
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### 本地开发
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
### 构建生产版本
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📝 注意事项
|
||||
|
||||
1. **API 接口**:确保后端支持以下接口:
|
||||
- GET `/api-order/home/carousel` - 获取列表
|
||||
- POST `/api-order/home/carousel` - 新增/编辑
|
||||
- DELETE `/api-order/home/carousel/{id}` - 删除
|
||||
|
||||
2. **图片上传**:CreateForm 中的上传地址需要配置为实际的后端接口
|
||||
|
||||
3. **字段映射**:
|
||||
- `imageUrl` - 图片地址(必填)
|
||||
- `linkUrl` - 跳转链接
|
||||
- `title` - 标题
|
||||
- `sort` - 排序(默认1)
|
||||
- `status` - 状态(1启用,0禁用)
|
||||
|
||||
4. **性能优化**:
|
||||
- 表格列配置使用 `width` 属性固定宽度
|
||||
- 图片使用 lazy loading 和占位符
|
||||
- 搜索结果自动触发表格刷新
|
||||
|
||||
---
|
||||
|
||||
## 🎨 美化亮点
|
||||
|
||||
✅ 统一的 Pro Components 设计语言
|
||||
✅ 清晰的视觉层级和间距
|
||||
✅ 友好的用户反馈(加载状态、错误提示)
|
||||
✅ 响应式布局(QueryFilter span=8)
|
||||
✅ 圆角、阴影等细致设计
|
||||
✅ 状态颜色语义化(成功绿、失败红)
|
||||
✅ 图片预览增强用户体验
|
||||
|
||||
---
|
||||
|
||||
## 📚 技术栈
|
||||
|
||||
- **React 17** - UI 框架
|
||||
- **UmiJS 3** - 前端集成框架
|
||||
- **@ant-design/pro-components** - 企业级组件库
|
||||
- **Ant Design 4** - UI 设计系统
|
||||
- **TypeScript** - 类型安全
|
||||
- **LESS** - 样式预处理
|
||||
|
||||
@@ -10,22 +10,47 @@ import {
|
||||
import { Button, Upload, message } from 'antd';
|
||||
import { Image as AntImage } from 'antd';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import type { RcFile, UploadProps } from 'antd/es/upload';
|
||||
import type { HomeCarouselItem } from './HomeCarouselForm';
|
||||
import type { RcFile } from 'antd/es/upload';
|
||||
|
||||
export interface HomeCarouselItem {
|
||||
id?: number;
|
||||
imageUrl?: string;
|
||||
linkUrl?: string;
|
||||
sort?: number;
|
||||
status?: number;
|
||||
title?: string;
|
||||
description?: string;
|
||||
type?: number;
|
||||
}
|
||||
|
||||
export interface CreateFormProps {
|
||||
open: boolean;
|
||||
initialValues?: Partial<HomeCarouselItem>;
|
||||
onOpenChange: (v: boolean) => void;
|
||||
onFinish: (values: HomeCarouselItem) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const CreateForm: React.FC<CreateFormProps> = ({
|
||||
open,
|
||||
initialValues,
|
||||
onOpenChange,
|
||||
onFinish,
|
||||
}) => {
|
||||
const [imageUrl, setImageUrl] = useState<string>();
|
||||
const [imagePath, setImagePath] = useState<string>();
|
||||
const [imageUrl, setImageUrl] = useState<string>(initialValues?.imageUrl || '');
|
||||
const [imagePath, setImagePath] = useState<string>(initialValues?.imageUrl || '');
|
||||
|
||||
// 上传文件到服务器
|
||||
const doUpload = async (file: File) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const token = (typeof window !== 'undefined') ? sessionStorage.getItem('access_token') : undefined;
|
||||
const headers: Record<string, string> = {};
|
||||
if (token) headers['Authorization'] = 'Bearer ' + token;
|
||||
const resp = await fetch('/api-file/files-anon', { method: 'POST', body: formData, headers });
|
||||
const data = await resp.json();
|
||||
if (!data || (!data.url && !data.path)) throw new Error('上传失败');
|
||||
return data as { url: string; path: string };
|
||||
};
|
||||
|
||||
const handleBeforeUpload = (file: RcFile) => {
|
||||
const isImage = file.type.startsWith('image/');
|
||||
@@ -39,38 +64,28 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
return isImage && isLt10M;
|
||||
};
|
||||
|
||||
const handleChange: UploadProps['onChange'] = (info) => {
|
||||
if (info.file.status === 'done') {
|
||||
const response = info.file.response as any;
|
||||
if (response && response.url && response.path) {
|
||||
setImageUrl(response.url);
|
||||
setImagePath(response.path);
|
||||
message.success('上传成功');
|
||||
}
|
||||
} else if (info.file.status === 'error') {
|
||||
message.error('上传失败');
|
||||
}
|
||||
};
|
||||
const isEdit = !!initialValues?.id;
|
||||
|
||||
return (
|
||||
<ModalForm<HomeCarouselItem>
|
||||
title="新增轮播图"
|
||||
open={open}
|
||||
onOpenChange={(visible) => {
|
||||
title={isEdit ? '编辑轮播图' : '新增轮播图'}
|
||||
visible={open}
|
||||
onVisibleChange={(visible) => {
|
||||
onOpenChange(visible);
|
||||
if (!visible) {
|
||||
setImageUrl(undefined);
|
||||
setImagePath(undefined);
|
||||
setImageUrl('');
|
||||
setImagePath('');
|
||||
}
|
||||
}}
|
||||
initialValues={initialValues}
|
||||
onFinish={async (values) => {
|
||||
if (!imagePath) {
|
||||
if (!isEdit && !imagePath) {
|
||||
message.error('请上传轮播图片');
|
||||
return false;
|
||||
}
|
||||
return onFinish({
|
||||
...values,
|
||||
imageUrl: imagePath,
|
||||
imageUrl: imagePath || values.imageUrl,
|
||||
});
|
||||
}}
|
||||
modalProps={{
|
||||
@@ -88,7 +103,6 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
name="linkUrl"
|
||||
label="跳转链接"
|
||||
placeholder="请输入跳转链接"
|
||||
rules={[{ type: 'url', message: '请输入正确的URL格式' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="type"
|
||||
@@ -110,7 +124,7 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
}}
|
||||
/>
|
||||
<ProFormDigit
|
||||
name="sort"
|
||||
name="sortOrder"
|
||||
label="排序"
|
||||
placeholder="请输入排序号"
|
||||
min={1}
|
||||
@@ -131,27 +145,39 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<label style={{ display: 'block', marginBottom: 8, fontWeight: 500 }}>
|
||||
上传图片 <span style={{ color: '#ff4d4f' }}>*</span>
|
||||
上传图片 {!isEdit && <span style={{ color: '#ff4d4f' }}>*</span>}
|
||||
</label>
|
||||
<Upload
|
||||
maxCount={1}
|
||||
accept="image/*"
|
||||
showUploadList={false}
|
||||
beforeUpload={handleBeforeUpload}
|
||||
onChange={handleChange}
|
||||
action="/api/upload"
|
||||
customRequest={async ({ file, onSuccess, onError }) => {
|
||||
try {
|
||||
if (file instanceof File) {
|
||||
const r = await doUpload(file as File);
|
||||
setImageUrl(r.url);
|
||||
setImagePath(r.path);
|
||||
message.success('上传成功');
|
||||
onSuccess?.('ok');
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('上传失败');
|
||||
onError?.(err as any);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Button icon={<UploadOutlined />}>
|
||||
{imageUrl ? '更换图片' : '上传轮播图片'}
|
||||
{imageUrl ? '更换图片' : isEdit ? '上传或更换图片' : '上传轮播图片'}
|
||||
</Button>
|
||||
</Upload>
|
||||
</div>
|
||||
|
||||
{imageUrl && (
|
||||
{(imageUrl || (isEdit && initialValues?.imageUrl)) && (
|
||||
<div style={{ marginTop: 16 }}>
|
||||
<p style={{ marginBottom: 8 }}>图片预览:</p>
|
||||
<AntImage
|
||||
src={imageUrl}
|
||||
src={imageUrl || initialValues?.imageUrl}
|
||||
width={200}
|
||||
style={{ borderRadius: 4 }}
|
||||
placeholder={
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ModalForm, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
|
||||
|
||||
export interface HomeCarouselItem {
|
||||
id?: number;
|
||||
imageUrl?: string;
|
||||
linkUrl?: string;
|
||||
sort?: number;
|
||||
status?: number;
|
||||
title?: string;
|
||||
description?: string;
|
||||
type?: number;
|
||||
}
|
||||
|
||||
export interface HomeCarouselFormProps {
|
||||
open: boolean;
|
||||
initialValues?: Partial<HomeCarouselItem>;
|
||||
onOpenChange: (v: boolean) => void;
|
||||
onFinish: (values: HomeCarouselItem) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const HomeCarouselForm: React.FC<HomeCarouselFormProps> = ({
|
||||
open,
|
||||
initialValues,
|
||||
onOpenChange,
|
||||
onFinish,
|
||||
}) => {
|
||||
return (
|
||||
<ModalForm<HomeCarouselItem>
|
||||
title="编辑轮播图"
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
onFinish={onFinish}
|
||||
initialValues={initialValues}
|
||||
modalProps={{
|
||||
destroyOnClose: true,
|
||||
maskClosable: false,
|
||||
}}
|
||||
>
|
||||
<ProFormText
|
||||
name="title"
|
||||
label="标题"
|
||||
placeholder="请输入轮播图标题"
|
||||
rules={[{ required: true, message: '标题不能为空' }]}
|
||||
/>
|
||||
<ProFormText
|
||||
name="imageUrl"
|
||||
label="图片地址"
|
||||
placeholder="请输入图片地址或使用上传功能"
|
||||
rules={[{ required: true, message: '请输入图片地址' }]}
|
||||
/>
|
||||
<ProFormText
|
||||
name="linkUrl"
|
||||
label="跳转链接"
|
||||
placeholder="请输入跳转链接"
|
||||
rules={[{ type: 'url', message: '请输入正确的URL格式' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="type"
|
||||
label="类型"
|
||||
placeholder="请选择类型"
|
||||
options={[
|
||||
{ label: '首页轮播', value: 0 },
|
||||
{ label: '活动', value: 1 },
|
||||
{ label: '其他', value: 2 },
|
||||
]}
|
||||
rules={[{ required: true, message: '请选择类型' }]}
|
||||
/>
|
||||
<ProFormTextArea
|
||||
name="description"
|
||||
label="描述"
|
||||
placeholder="请输入轮播图描述"
|
||||
fieldProps={{
|
||||
rows: 3,
|
||||
}}
|
||||
/>
|
||||
<ProFormDigit
|
||||
name="sort"
|
||||
label="排序"
|
||||
min={1}
|
||||
fieldProps={{ precision: 0 }}
|
||||
placeholder="请输入排序号(数字越小越靠前)"
|
||||
initialValue={1}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="status"
|
||||
label="状态"
|
||||
placeholder="请选择状态"
|
||||
options={[
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
]}
|
||||
rules={[{ required: true, message: '请选择状态' }]}
|
||||
initialValue={1}
|
||||
/>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
export default HomeCarouselForm;
|
||||
@@ -1,54 +0,0 @@
|
||||
@import (reference) '~antd/es/style/themes/index';
|
||||
|
||||
// 查询栏样式
|
||||
.query-filter {
|
||||
padding: 24px;
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02);
|
||||
|
||||
:global {
|
||||
.ant-form-item {
|
||||
margin-bottom: 24px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-select,
|
||||
.ant-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ant-form-item-label > label {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表格样式
|
||||
:global {
|
||||
.ant-pro-table {
|
||||
margin-top: 16px;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
|
||||
.ant-table-thead > tr > th {
|
||||
background-color: #fafafa;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 图片预览样式
|
||||
:global {
|
||||
.ant-image-img {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.ant-modal-content {
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { PageContainer, ProTable, QueryFilter, ProFormText, ProFormSelect } from '@ant-design/pro-components';
|
||||
import { Popconfirm, message, Typography, Image as AntImage } from 'antd';
|
||||
import { PageContainer, ProTable, ProFormText, ProFormSelect } from '@ant-design/pro-components';
|
||||
import { Popconfirm, message, Space, Image as AntImage, Typography } from 'antd';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
|
||||
import { ordersApi } from '@/services/orders';
|
||||
import HomeCarouselForm from './components/HomeCarouselForm';
|
||||
import CreateForm from './components/CreateForm';
|
||||
import type { HomeCarouselItem } from './components/HomeCarouselForm';
|
||||
import styles from './index.less';
|
||||
import type { HomeCarouselItem } from './components/CreateForm';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
@@ -25,8 +24,7 @@ const TYPE_OPTIONS = [
|
||||
|
||||
const HomeCarouselPage: React.FC = () => {
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [formOpen, setFormOpen] = useState(false);
|
||||
const [current, setCurrent] = useState<HomeCarouselItem | undefined>(undefined);
|
||||
const [searchParams, setSearchParams] = useState<Record<string, any>>({});
|
||||
|
||||
@@ -58,30 +56,6 @@ const HomeCarouselPage: React.FC = () => {
|
||||
ellipsis: true,
|
||||
copyable: true,
|
||||
},
|
||||
{
|
||||
title: '图片',
|
||||
dataIndex: 'imageUrl',
|
||||
width: 120,
|
||||
render: (imageUrl: string) => (
|
||||
<AntImage
|
||||
src={imageUrl}
|
||||
width={100}
|
||||
placeholder={
|
||||
<div style={{ background: '#f5f5f5', height: 100, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
加载中...
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '跳转链接',
|
||||
dataIndex: 'linkUrl',
|
||||
ellipsis: true,
|
||||
render: (url: string) => (
|
||||
url ? <Link href={url} target="_blank">{url}</Link> : '-'
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
@@ -91,6 +65,34 @@ const HomeCarouselPage: React.FC = () => {
|
||||
[curr.value]: { text: curr.label },
|
||||
}), {}),
|
||||
},
|
||||
{
|
||||
title: '图片',
|
||||
dataIndex: 'imageUrl',
|
||||
width: 120,
|
||||
render: (_: any, record: HomeCarouselItem) => (
|
||||
record.imageUrl ? (
|
||||
<AntImage
|
||||
src={record.imageUrl}
|
||||
width={100}
|
||||
placeholder={
|
||||
<div style={{ background: '#f5f5f5', height: 100, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
加载中...
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<span>-</span>
|
||||
)
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '跳转链接',
|
||||
dataIndex: 'redirectUrl',
|
||||
ellipsis: true,
|
||||
render: (_: any, record: HomeCarouselItem) => (
|
||||
record.linkUrl ? <Link href={record.linkUrl} target="_blank">{record.linkUrl}</Link> : '-'
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'description',
|
||||
@@ -98,7 +100,7 @@ const HomeCarouselPage: React.FC = () => {
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
dataIndex: 'sortOrder',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
@@ -115,117 +117,106 @@ const HomeCarouselPage: React.FC = () => {
|
||||
valueType: 'option',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
render: (_, record) => [
|
||||
<a
|
||||
key="edit"
|
||||
onClick={() => {
|
||||
console.log('编辑按钮被点击', record);
|
||||
setCurrent(record);
|
||||
setEditOpen(true);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</a>,
|
||||
<Popconfirm
|
||||
key="delete"
|
||||
title="确认删除?"
|
||||
description="删除后将无法恢复,请谨慎操作"
|
||||
onConfirm={() => handleDelete(record)}
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
>
|
||||
<a>删除</a>
|
||||
</Popconfirm>,
|
||||
],
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<a
|
||||
onClick={() => {
|
||||
setCurrent(record);
|
||||
setFormOpen(true);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</a>
|
||||
<Popconfirm
|
||||
title="确认删除轮播图?"
|
||||
onConfirm={() => handleDelete(record)}
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
>
|
||||
<a style={{ color: '#1677ff' }}>删除</a>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<QueryFilter
|
||||
defaultCollapsed={false}
|
||||
split
|
||||
span={8}
|
||||
className={styles['query-filter']}
|
||||
onFinish={async (values) => {
|
||||
setSearchParams(values);
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
style={{ marginBottom: 16 }}
|
||||
>
|
||||
<ProFormText
|
||||
name="title"
|
||||
label="标题"
|
||||
placeholder="请输入标题关键字"
|
||||
fieldProps={{
|
||||
allowClear: true,
|
||||
}}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="status"
|
||||
label="状态"
|
||||
placeholder="请选择状态"
|
||||
options={STATUS_OPTIONS}
|
||||
fieldProps={{
|
||||
allowClear: true,
|
||||
}}
|
||||
/>
|
||||
</QueryFilter>
|
||||
<PageContainer header={{ title: '轮播图管理' }}>
|
||||
{/*<SearchBarPlus*/}
|
||||
{/* defaultCollapsed*/}
|
||||
{/* split*/}
|
||||
{/* span={8}*/}
|
||||
{/* hideReset*/}
|
||||
{/* showTenant={false}*/}
|
||||
{/* onFinish={async (values) => {*/}
|
||||
{/* setSearchParams(values);*/}
|
||||
{/* actionRef.current?.reload();*/}
|
||||
{/* }}*/}
|
||||
{/*>*/}
|
||||
{/* <ProFormText*/}
|
||||
{/* name="title"*/}
|
||||
{/* label="标题"*/}
|
||||
{/* placeholder="请输入标题关键字"*/}
|
||||
{/* />*/}
|
||||
{/* <ProFormSelect*/}
|
||||
{/* name="status"*/}
|
||||
{/* label="状态"*/}
|
||||
{/* placeholder="请选择状态"*/}
|
||||
{/* options={STATUS_OPTIONS}*/}
|
||||
{/* fieldProps={{*/}
|
||||
{/* allowClear: true,*/}
|
||||
{/* }}*/}
|
||||
{/* />*/}
|
||||
{/*</SearchBarPlus>*/}
|
||||
|
||||
<ProTable<HomeCarouselItem>
|
||||
rowKey="id"
|
||||
headerTitle="轮播图列表"
|
||||
actionRef={actionRef}
|
||||
columns={columns}
|
||||
request={(p) => ordersApi.homeCarousel({ ...(p as any), ...searchParams })}
|
||||
search={false}
|
||||
pagination={{
|
||||
defaultPageSize: 10,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
toolBarRender={() => [
|
||||
<a
|
||||
key="add"
|
||||
onClick={() => {
|
||||
console.log('新增按钮被点击');
|
||||
setCreateOpen(true);
|
||||
}}
|
||||
style={{ color: '#1890ff', cursor: 'pointer' }}
|
||||
>
|
||||
<PlusOutlined /> 新增轮播图
|
||||
</a>,
|
||||
]}
|
||||
<ActionBar
|
||||
left={
|
||||
<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={() => {
|
||||
setCurrent(undefined);
|
||||
setFormOpen(true);
|
||||
}}>
|
||||
新增轮播图
|
||||
</GradientButton>
|
||||
}
|
||||
/>
|
||||
|
||||
<GlassCard>
|
||||
<ProTable<HomeCarouselItem>
|
||||
rowKey="id"
|
||||
actionRef={actionRef}
|
||||
columns={columns}
|
||||
request={(p) => ordersApi.homeCarousel({ ...(p as any), ...searchParams })}
|
||||
search={false}
|
||||
pagination={{
|
||||
defaultPageSize: 10,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
toolBarRender={false}
|
||||
/>
|
||||
</GlassCard>
|
||||
|
||||
<CreateForm
|
||||
open={createOpen}
|
||||
onOpenChange={setCreateOpen}
|
||||
onFinish={async (values) => {
|
||||
const hide = message.loading('保存中...');
|
||||
try {
|
||||
await ordersApi.saveOrUpdateHomeCarousel(values);
|
||||
message.success('新增成功');
|
||||
actionRef.current?.reload();
|
||||
return true;
|
||||
} catch (e) {
|
||||
message.error('保存失败');
|
||||
return false;
|
||||
} finally {
|
||||
hide();
|
||||
open={formOpen}
|
||||
initialValues={current}
|
||||
onOpenChange={(visible) => {
|
||||
setFormOpen(visible);
|
||||
if (!visible) {
|
||||
setCurrent(undefined);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<HomeCarouselForm
|
||||
open={editOpen}
|
||||
initialValues={current}
|
||||
onOpenChange={setEditOpen}
|
||||
onFinish={async (values) => {
|
||||
const hide = message.loading('保存中...');
|
||||
try {
|
||||
await ordersApi.saveOrUpdateHomeCarousel({ ...(current as any), ...values });
|
||||
message.success('修改成功');
|
||||
if (current?.id) {
|
||||
// 编辑模式
|
||||
await ordersApi.saveOrUpdateHomeCarousel({ ...(current as any), ...values });
|
||||
message.success('修改成功');
|
||||
} else {
|
||||
// 新增模式
|
||||
await ordersApi.saveOrUpdateHomeCarousel(values);
|
||||
message.success('新增成功');
|
||||
}
|
||||
actionRef.current?.reload();
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
||||
@@ -376,7 +376,13 @@ const RefundReviewModal: React.FC<RefundReviewModalProps> = ({
|
||||
{/* 申请时间 */}
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<span style={{ fontWeight: 'bold' }}>申请时间</span>
|
||||
<div style={{ marginTop: 4 }}>{formatTime(refundData?.createTime || refundData?.applyTime)}</div>
|
||||
<div style={{ marginTop: 4 }}>{formatTime(refundData?.applyTime || refundData?.applyTime)}</div>
|
||||
<span style={{ fontWeight: 'bold' }}>退款时间</span>
|
||||
<div style={{ marginTop: 4 }}>{formatTime(refundData?.refundTime || refundData?.refundTime)}</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
@@ -87,7 +87,7 @@ const TenantForm: React.FC<TenantFormProps> = ({ visible, title, initialValues,
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProForm.Item name='parentTenantId' label='上级租户'>
|
||||
<TreeSelect style={{ width: 260 }} allowClear dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} treeDefaultExpandAll treeData={toTreeData(tree)} placeholder='选择上级租户' disabled={editing} />
|
||||
<TreeSelect style={{ width: 260 }} allowClear dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} treeDefaultExpandAll treeData={toTreeData(tree)} placeholder='选择上级租户'/>
|
||||
</ProForm.Item>
|
||||
<ProForm.Item name='tenantType' label='类型' rules={[{ required: true, message: '请选择类型' }]}>
|
||||
<Select style={{ width: 260 }} placeholder='选择类型' disabled={editing && !initialValues?.parentTenantId}>
|
||||
|
||||
@@ -30,6 +30,41 @@ export const deviceApi = {
|
||||
const res = await request(`/api-device/wayline/${id}`, { method: 'DELETE' });
|
||||
return (res as any).data || res;
|
||||
},
|
||||
/**
|
||||
* 根据航线ID获取航线详细信息(包括文件URL)
|
||||
* @param waylineId 航线ID
|
||||
* @returns 航线详细信息
|
||||
*/
|
||||
getWaylineInfoByWaylineId: async (waylineId: string) => {
|
||||
const res = await request(`/api-device/wayline/${waylineId}`, { method: 'GET' });
|
||||
return (res as any).data as {
|
||||
id?: number;
|
||||
name?: string;
|
||||
waylineId?: string;
|
||||
sign?: string;
|
||||
workspaceId?: string;
|
||||
fileUrl?: string;
|
||||
objectKey?: string;
|
||||
[k: string]: any;
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 获取航线文件访问URL
|
||||
* @param id 航线文件ID
|
||||
* @returns 访问URL
|
||||
*/
|
||||
getWaylineFileUrl: async (id: number) => {
|
||||
const res = await request(`/api-device/wayline/url/${id}`, { method: 'GET' });
|
||||
return (res as any).data || '';
|
||||
},
|
||||
/**
|
||||
* 下载航线文件
|
||||
* @param id 航线文件ID
|
||||
* @returns 下载URL
|
||||
*/
|
||||
downloadWaylineFile: (id: number) => {
|
||||
return `/api-device/wayline/download/${id}`;
|
||||
},
|
||||
deviceList: async (params: { page?: number; limit?: number; [k:string]: any }) => {
|
||||
const res = await request('/api-device/device', { method: 'GET', params });
|
||||
return { data: (res as any).data, total: (res as any).count } as { data: DeviceItem[]; total: number };
|
||||
|
||||
Reference in New Issue
Block a user