feat(后台管理):,优化景区名称显示
This commit is contained in:
+14
@@ -409,6 +409,20 @@ public class OrderController {
|
|||||||
return Result.failed("请重试");
|
return Result.failed("请重试");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "后台管理更新订单")
|
||||||
|
@PostMapping("/update/order")
|
||||||
|
public Result updateOrder(@RequestBody Order order) {
|
||||||
|
LoginAppUser loginAppUser = LoginUserContextHolder.getUser();
|
||||||
|
if (loginAppUser.getId() == 1){
|
||||||
|
boolean res = orderService.updateOrder(order);
|
||||||
|
if (res){
|
||||||
|
return Result.succeed("已更新");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.failed("请重试");
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "机库查询订单执行情况")
|
@Operation(summary = "机库查询订单执行情况")
|
||||||
@AuditLog(operation = "'机库查询订单执行情况:' + #orderNo")
|
@AuditLog(operation = "'机库查询订单执行情况:' + #orderNo")
|
||||||
@GetMapping("/status/{orderNo}")
|
@GetMapping("/status/{orderNo}")
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ public class TourismFile extends SuperEntity {
|
|||||||
private Date createTime;
|
private Date createTime;
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
private Long createId;
|
|
||||||
//租户ID
|
//租户ID
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
private String company;
|
private String company;
|
||||||
|
|||||||
+19
-11
@@ -4,7 +4,7 @@ import {
|
|||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
ProFormText,
|
ProFormText,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { STATUS_OPTIONS } from '../index';
|
import { STATUS_OPTIONS } from '../index';
|
||||||
|
|
||||||
interface UpdateFormProps {
|
interface UpdateFormProps {
|
||||||
@@ -16,15 +16,19 @@ interface UpdateFormProps {
|
|||||||
tourismOptions: any[]; // 从父组件接收景区选项
|
tourismOptions: any[]; // 从父组件接收景区选项
|
||||||
}
|
}
|
||||||
|
|
||||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||||
const {
|
onSubmit,
|
||||||
onSubmit,
|
onVisibleChange,
|
||||||
onVisibleChange,
|
updateModalVisible,
|
||||||
updateModalVisible,
|
values,
|
||||||
values,
|
waylineOptions,
|
||||||
waylineOptions,
|
tourismOptions,
|
||||||
tourismOptions,
|
}) => {
|
||||||
} = props;
|
useEffect(() => {
|
||||||
|
console.log('UpdateForm values:', values);
|
||||||
|
console.log('UpdateForm tourismOptions:', tourismOptions);
|
||||||
|
console.log('UpdateForm waylineOptions:', waylineOptions);
|
||||||
|
}, [values, tourismOptions, waylineOptions]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
@@ -32,7 +36,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
visible={updateModalVisible}
|
visible={updateModalVisible}
|
||||||
onVisibleChange={onVisibleChange}
|
onVisibleChange={onVisibleChange}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
initialValues={values}
|
initialValues={{
|
||||||
|
...values,
|
||||||
|
tourismId: Number(values?.tourismId),
|
||||||
|
waylineId: values?.waylineId,
|
||||||
|
}}
|
||||||
onFinish={onSubmit}
|
onFinish={onSubmit}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ const renderStatus = (status: {} | null | undefined) => {
|
|||||||
|
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const [params, setParams] = useState<Record<string, string | number>>({ });
|
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||||
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
const [currentRow, setCurrentRow] = useState<ORDERS.Qrcode>();
|
const [currentRow, setCurrentRow] = useState<ORDERS.Qrcode>();
|
||||||
@@ -137,24 +137,6 @@ const TableList: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchWaylineOptions = async () => {
|
|
||||||
console.log('Fetching wayline options...');
|
|
||||||
try {
|
|
||||||
const result = await wayline({ current: 1, pageSize: 100 });
|
|
||||||
console.log('Wayline result:', result);
|
|
||||||
if (result?.data) {
|
|
||||||
const options = result.data.map((item: any) => ({
|
|
||||||
label: `${item.name}`,
|
|
||||||
value: item.waylineId,
|
|
||||||
wayline: item
|
|
||||||
}));
|
|
||||||
setWaylineOptions(options);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
message.error('获取航线列表失败');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchTourismList = useCallback(async () => {
|
const fetchTourismList = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const result = await tourism({
|
const result = await tourism({
|
||||||
@@ -166,6 +148,7 @@ const TableList: React.FC = () => {
|
|||||||
const options = result.data.map(item => ({
|
const options = result.data.map(item => ({
|
||||||
label: item.tourismName,
|
label: item.tourismName,
|
||||||
value: item.id,
|
value: item.id,
|
||||||
|
info: item
|
||||||
}));
|
}));
|
||||||
setTourismOptions(options);
|
setTourismOptions(options);
|
||||||
}
|
}
|
||||||
@@ -174,98 +157,160 @@ const TableList: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
const fetchWaylineOptions = useCallback(async () => {
|
||||||
if (updateModalVisible || createModalVisible) {
|
try {
|
||||||
fetchTourismList();
|
const result = await wayline({ current: 1, pageSize: 100 });
|
||||||
fetchWaylineOptions();
|
if (result?.data) {
|
||||||
|
const options = result.data.map((item: any) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.waylineId,
|
||||||
|
}));
|
||||||
|
setWaylineOptions(options);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error('获取航线列表失败');
|
||||||
}
|
}
|
||||||
}, [updateModalVisible, createModalVisible, fetchTourismList]);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchTourismList();
|
||||||
|
fetchWaylineOptions();
|
||||||
|
}, [fetchTourismList, fetchWaylineOptions]);
|
||||||
|
|
||||||
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
||||||
{
|
{
|
||||||
dataIndex: 'index',
|
dataIndex: 'index',
|
||||||
valueType: 'indexBorder',
|
valueType: 'indexBorder',
|
||||||
|
width: 48,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'ID',
|
title: 'ID',
|
||||||
dataIndex: 'id',
|
dataIndex: 'id',
|
||||||
|
width: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'CodeID',
|
title: 'CodeID',
|
||||||
dataIndex: 'codeId',
|
dataIndex: 'codeId',
|
||||||
|
width: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '景区ID',
|
title: '景区名称',
|
||||||
dataIndex: 'tourismId',
|
dataIndex: 'tourismId',
|
||||||
|
width: 160,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, entity) => {
|
||||||
|
const tourism = tourismOptions.find(item => item.value === entity.tourismId);
|
||||||
|
return tourism?.label || '-';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '航线名称',
|
||||||
|
dataIndex: 'waylineId',
|
||||||
|
width: 160,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (waylineId) => {
|
||||||
|
const wayline = waylineOptions.find(item => item.value === waylineId);
|
||||||
|
return wayline?.label || waylineId;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '文件',
|
title: '文件',
|
||||||
dataIndex: 'viewUrl',
|
dataIndex: 'viewUrl',
|
||||||
render: (viewUrl) => <Image src={viewUrl} width={100} />
|
width: 120,
|
||||||
|
render: (viewUrl) => viewUrl ? (
|
||||||
|
<Image
|
||||||
|
src={viewUrl}
|
||||||
|
width={100}
|
||||||
|
style={{ objectFit: 'cover' }}
|
||||||
|
/>
|
||||||
|
) : '-',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '价格',
|
title: '价格',
|
||||||
dataIndex: 'price',
|
dataIndex: 'price',
|
||||||
|
width: 100,
|
||||||
|
render: (price) => price ? `¥${(Number(price) / 100).toFixed(2)}` : '-',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '设备SN',
|
title: '设备SN',
|
||||||
dataIndex: 'deviceSn',
|
dataIndex: 'deviceSn',
|
||||||
|
width: 140,
|
||||||
|
ellipsis: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
|
width: 100,
|
||||||
render: (status) => renderStatus(status),
|
render: (status) => renderStatus(status),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
valueType: 'dateTime',
|
valueType: 'dateTime',
|
||||||
|
width: 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
render: (_, entity) =>
|
width: 120,
|
||||||
<Space>
|
render: (_, record) => (
|
||||||
<Link
|
<Space>
|
||||||
onClick={() => {
|
<Link
|
||||||
setCurrentRow({
|
onClick={() => {
|
||||||
...entity,
|
setCurrentRow(record);
|
||||||
waylineId: entity.waylineId,
|
handleUpdateModalVisible(true);
|
||||||
});
|
}}
|
||||||
handleUpdateModalVisible(true);
|
>
|
||||||
}}
|
修改
|
||||||
>
|
</Link>
|
||||||
修改
|
<Popconfirm
|
||||||
</Link>
|
title={`确认删除该二维码?`}
|
||||||
<Popconfirm
|
description="删除后将无法恢复,请谨慎操作"
|
||||||
title={`确认删除景区[${entity.codeId}]?`}
|
onConfirm={() => handleTableAction('delete', record)}
|
||||||
onConfirm={async () => {
|
>
|
||||||
const success = await handleTableAction('delete', entity);
|
<Link>删除</Link>
|
||||||
}}
|
</Popconfirm>
|
||||||
>
|
</Space>
|
||||||
<Link>删除</Link>
|
),
|
||||||
</Popconfirm>
|
|
||||||
</Space>
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ subTitle: '管理任务' }}>
|
<PageContainer header={{ title: '二维码管理' }}>
|
||||||
<QueryFilter
|
<QueryFilter
|
||||||
defaultCollapsed
|
defaultCollapsed={false}
|
||||||
split
|
split
|
||||||
span={6}
|
span={6}
|
||||||
className="query-filter"
|
className="query-filter"
|
||||||
onFinish={async (values) => setParams(values)}
|
onFinish={setParams}
|
||||||
>
|
>
|
||||||
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
|
<ProFormSelect
|
||||||
|
name="tourismId"
|
||||||
|
label="景区"
|
||||||
|
placeholder="请选择景区"
|
||||||
|
options={tourismOptions}
|
||||||
|
showSearch
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="waylineId"
|
||||||
|
label="航线"
|
||||||
|
placeholder="请选择航线"
|
||||||
|
options={waylineOptions}
|
||||||
|
showSearch
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
options={STATUS_OPTIONS}
|
||||||
|
/>
|
||||||
</QueryFilter>
|
</QueryFilter>
|
||||||
<ProTable<ORDERS.Qrcode>
|
<ProTable<ORDERS.Qrcode>
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
headerTitle="二维码列表"
|
headerTitle="二维码列表"
|
||||||
request={qrcode}
|
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
request={qrcode}
|
||||||
search={false}
|
search={false}
|
||||||
params={params}
|
params={params}
|
||||||
pagination={{
|
pagination={{
|
||||||
@@ -273,16 +318,13 @@ const TableList: React.FC = () => {
|
|||||||
showQuickJumper: true,
|
showQuickJumper: true,
|
||||||
}}
|
}}
|
||||||
toolBarRender={() => [
|
toolBarRender={() => [
|
||||||
<>
|
<Button
|
||||||
<Button
|
key="add"
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => {
|
onClick={() => handleModalVisible(true)}
|
||||||
handleModalVisible(true);
|
>
|
||||||
}}
|
<PlusOutlined /> 新增二维码
|
||||||
>
|
</Button>,
|
||||||
<PlusOutlined /> 添加
|
|
||||||
</Button>
|
|
||||||
</>,
|
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<ModalForm
|
<ModalForm
|
||||||
|
|||||||
+74
-77
@@ -14,10 +14,13 @@ import styles from '../index.less';
|
|||||||
import { tourism } from '@/services/orders/api';
|
import { tourism } from '@/services/orders/api';
|
||||||
|
|
||||||
interface UpdateFormProps {
|
interface UpdateFormProps {
|
||||||
onSubmit: (values: Partial<ORDERS.TourismFile>) => Promise<void>;
|
onSubmit: (values: any) => Promise<void>;
|
||||||
onVisibleChange: (visible: boolean) => void;
|
onVisibleChange: (visible: boolean) => void;
|
||||||
updateModalVisible: boolean;
|
updateModalVisible: boolean;
|
||||||
values?: ORDERS.TourismFile;
|
values?: ORDERS.TourismFile;
|
||||||
|
tourismOptions: any[];
|
||||||
|
statusOptions: typeof STATUS_OPTIONS;
|
||||||
|
typeOptions: typeof TYPE_OPTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UpdateForm: React.FC<UpdateFormProps> = ({
|
const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||||
@@ -25,54 +28,44 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
onVisibleChange,
|
onVisibleChange,
|
||||||
updateModalVisible,
|
updateModalVisible,
|
||||||
values,
|
values,
|
||||||
|
tourismOptions,
|
||||||
|
statusOptions,
|
||||||
|
typeOptions,
|
||||||
}) => {
|
}) => {
|
||||||
const [imageUrl, setImageUrl] = useState<string>(values?.imageUrl || '');
|
const [uploading, setUploading] = useState(false);
|
||||||
const [tourismOptions, setTourismOptions] = useState<any[]>([]);
|
const [updateImageUrl, setUpdateImageUrl] = useState<string>();
|
||||||
|
const [updateImagePath, setUpdateImagePath] = useState<string>();
|
||||||
|
|
||||||
|
// 处理文件上传
|
||||||
const handleUpload = async (file: RcFile) => {
|
const handleUpload = async (file: RcFile) => {
|
||||||
const hide = message.loading('正在上传');
|
setUploading(true);
|
||||||
|
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();
|
|
||||||
if (result.name) {
|
|
||||||
setImageUrl(result.name);
|
|
||||||
message.success('上传成功');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
hide();
|
|
||||||
message.error('上传失败');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取景区列表
|
|
||||||
const fetchTourismList = useCallback(async () => {
|
|
||||||
try {
|
|
||||||
const result = await tourism({
|
|
||||||
limit: 100,
|
|
||||||
page: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result.data) {
|
hide();
|
||||||
const options = result.data.map(item => ({
|
|
||||||
label: item.tourismName,
|
if (result.url && result.path) {
|
||||||
value: item.id,
|
message.success('上传成功');
|
||||||
}));
|
setUpdateImageUrl(result.url);
|
||||||
setTourismOptions(options);
|
setUpdateImagePath(result.path);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.error('上传失败:未获取到文件信息');
|
||||||
|
return false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('获取景区列表失败');
|
console.error('Upload error:', error);
|
||||||
|
hide();
|
||||||
|
message.error('上传失败:' + (error.message || '未知错误'));
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
setUploading(false);
|
||||||
}
|
}
|
||||||
}, []);
|
};
|
||||||
|
|
||||||
// 在组件挂载和弹窗打开时获取数据
|
|
||||||
useEffect(() => {
|
|
||||||
if (updateModalVisible) {
|
|
||||||
fetchTourismList();
|
|
||||||
}
|
|
||||||
}, [updateModalVisible, fetchTourismList]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
@@ -81,13 +74,7 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
onVisibleChange={onVisibleChange}
|
onVisibleChange={onVisibleChange}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
initialValues={values}
|
initialValues={values}
|
||||||
onFinish={async (formValues) => {
|
onFinish={onSubmit}
|
||||||
const submitData = {
|
|
||||||
...formValues,
|
|
||||||
imageUrl: imageUrl || values?.imageUrl,
|
|
||||||
};
|
|
||||||
await onSubmit(submitData);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
@@ -98,11 +85,6 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
placeholder="请选择景区"
|
placeholder="请选择景区"
|
||||||
options={tourismOptions}
|
options={tourismOptions}
|
||||||
showSearch
|
showSearch
|
||||||
fieldProps={{
|
|
||||||
loading: !tourismOptions.length,
|
|
||||||
filterOption: (input, option) =>
|
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
rules={[{ required: true, message: '素材类型不为空' }]}
|
rules={[{ required: true, message: '素材类型不为空' }]}
|
||||||
@@ -110,7 +92,15 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
name="type"
|
name="type"
|
||||||
label="素材类型"
|
label="素材类型"
|
||||||
placeholder="请选择素材类型"
|
placeholder="请选择素材类型"
|
||||||
options={TYPE_OPTIONS}
|
options={typeOptions}
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
width="md"
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
options={statusOptions}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
@@ -124,34 +114,41 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
label="素材描述"
|
label="素材描述"
|
||||||
placeholder="输入描述"
|
placeholder="输入描述"
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="status"
|
|
||||||
label="状态"
|
|
||||||
options={[
|
|
||||||
{ label: '启用', value: 0 },
|
|
||||||
{ label: '未启用', value: 1 },
|
|
||||||
]}
|
|
||||||
rules={[{ required: true, message: '请选择状态' }]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className={styles.imageUpload}>
|
<Upload
|
||||||
{imageUrl || values?.imageUrl ? (
|
maxCount={1}
|
||||||
<Image
|
accept="image/*"
|
||||||
src={imageUrl || values?.imageUrl}
|
showUploadList={false}
|
||||||
width={200}
|
disabled={uploading}
|
||||||
className={styles.preview}
|
customRequest={async ({ file, onSuccess, onError }) => {
|
||||||
/>
|
try {
|
||||||
) : null}
|
if (file instanceof File) {
|
||||||
<Upload
|
const success = await handleUpload(file as RcFile);
|
||||||
maxCount={1}
|
if (success) {
|
||||||
showUploadList={false}
|
onSuccess?.('ok');
|
||||||
beforeUpload={handleUpload}
|
} else {
|
||||||
|
onError?.(new Error('上传失败'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
onError?.(error);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
icon={<UploadOutlined />}
|
||||||
|
loading={uploading}
|
||||||
>
|
>
|
||||||
<Button icon={<UploadOutlined />}>
|
更新素材
|
||||||
更换素材
|
</Button>
|
||||||
</Button>
|
</Upload>
|
||||||
</Upload>
|
|
||||||
|
<div style={{ marginTop: 16 }}>
|
||||||
|
<Image
|
||||||
|
src={updateImageUrl || values?.imageUrl}
|
||||||
|
width={200}
|
||||||
|
style={{ objectFit: 'cover' }}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
|
|||||||
@@ -22,12 +22,18 @@ import styles from './index.less';
|
|||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
// 提取常量
|
// 状态常量
|
||||||
export const TYPE_OPTIONS = [
|
const STATUS_OPTIONS = [
|
||||||
{ label: '展示大图', value: 4 },
|
{ label: '启用', value: 0, color: 'success' },
|
||||||
{ label: '拍照引导图', value: 3 },
|
{ label: '未启用', value: 1, color: 'error' },
|
||||||
{ label: '拍照角度展示图', value: 2 },
|
] as const;
|
||||||
{ label: '活动', value: 1 },
|
|
||||||
|
// 类型常量
|
||||||
|
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;
|
] as const;
|
||||||
|
|
||||||
// 状态映射
|
// 状态映射
|
||||||
@@ -95,28 +101,18 @@ const handleDelete = async (tourismFile: ORDERS.TourismFile) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleImport = async (file: RcFile) => {
|
interface UploadResponse {
|
||||||
return handleApiRequest(
|
id: string;
|
||||||
async () => {
|
url: string;
|
||||||
const formData = new FormData();
|
path: string;
|
||||||
formData.append('file', file);
|
name: string;
|
||||||
return await importImage(formData);
|
isImg: boolean;
|
||||||
},
|
contentType: string;
|
||||||
'正在上传',
|
size: number;
|
||||||
'上传素材成功'
|
source: string;
|
||||||
);
|
createTime: string;
|
||||||
};
|
updateTime: string;
|
||||||
|
}
|
||||||
// 渲染函数
|
|
||||||
const renderStatus = (status: {} | null | undefined) => {
|
|
||||||
const statusInfo = statusColorMap[status] || { color: 'gray', text: '未知状态' };
|
|
||||||
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderType = (type: {} | null | undefined) => {
|
|
||||||
const typeInfo = typeColorMap[type] || { color: 'gray', text: '未知状态' };
|
|
||||||
return <Tag color={typeInfo.color}>{typeInfo.text}</Tag>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
@@ -124,7 +120,8 @@ const TableList: React.FC = () => {
|
|||||||
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
|
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
|
||||||
const [updateModalVisible, setUpdateModalVisible] = useState<boolean>(false);
|
const [updateModalVisible, setUpdateModalVisible] = useState<boolean>(false);
|
||||||
const [currentRow, setCurrentRow] = useState<ORDERS.TourismFile>();
|
const [currentRow, setCurrentRow] = useState<ORDERS.TourismFile>();
|
||||||
const [file, setFile] = useState<string>();
|
const [createImageUrl, setCreateImageUrl] = useState<string>();
|
||||||
|
const [createImagePath, setCreateImagePath] = useState<string>();
|
||||||
const [tourismOptions, setTourismOptions] = useState<{ label: string; value: number; info?: any }[]>([]);
|
const [tourismOptions, setTourismOptions] = useState<{ label: string; value: number; info?: any }[]>([]);
|
||||||
|
|
||||||
// 获取景区列表
|
// 获取景区列表
|
||||||
@@ -159,6 +156,30 @@ const TableList: React.FC = () => {
|
|||||||
fetchTourismList();
|
fetchTourismList();
|
||||||
}, [fetchTourismList]);
|
}, [fetchTourismList]);
|
||||||
|
|
||||||
|
const handleUpload = async (file: RcFile) => {
|
||||||
|
const hide = message.loading('正在上传...');
|
||||||
|
try {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', file);
|
||||||
|
const result = await importImage(formData);
|
||||||
|
hide();
|
||||||
|
|
||||||
|
if (result.url && result.path) {
|
||||||
|
message.success('上传成功');
|
||||||
|
return {
|
||||||
|
url: result.url,
|
||||||
|
path: result.path
|
||||||
|
};
|
||||||
|
}
|
||||||
|
message.error('上传失败:未获取到文件信息');
|
||||||
|
return false;
|
||||||
|
} catch (error) {
|
||||||
|
hide();
|
||||||
|
message.error('上传失败:' + (error.message || '未知错误'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleTableAction = useCallback(async (
|
const handleTableAction = useCallback(async (
|
||||||
action: 'add' | 'edit' | 'delete',
|
action: 'add' | 'edit' | 'delete',
|
||||||
record?: ORDERS.TourismFile,
|
record?: ORDERS.TourismFile,
|
||||||
@@ -167,8 +188,16 @@ const TableList: React.FC = () => {
|
|||||||
let success = false;
|
let success = false;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'add':
|
case 'add':
|
||||||
success = await handleAdd({ ...values, imageUrl: file } as ORDERS.TourismFile);
|
if (!createImagePath) {
|
||||||
success && setCreateModalVisible(false);
|
message.error('请上传素材图片');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
success = await handleAdd({ ...values, imageUrl: createImagePath } as ORDERS.TourismFile);
|
||||||
|
if (success) {
|
||||||
|
setCreateModalVisible(false);
|
||||||
|
setCreateImageUrl(undefined);
|
||||||
|
setCreateImagePath(undefined);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
if (record) {
|
if (record) {
|
||||||
@@ -186,7 +215,7 @@ const TableList: React.FC = () => {
|
|||||||
if (success && actionRef.current) {
|
if (success && actionRef.current) {
|
||||||
actionRef.current.reload();
|
actionRef.current.reload();
|
||||||
}
|
}
|
||||||
}, [file]);
|
}, [createImagePath]);
|
||||||
|
|
||||||
const columns: ProColumns<ORDERS.TourismFile>[] = [
|
const columns: ProColumns<ORDERS.TourismFile>[] = [
|
||||||
{
|
{
|
||||||
@@ -197,8 +226,12 @@ const TableList: React.FC = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '景区名称',
|
title: '景区名称',
|
||||||
dataIndex: 'tourismName',
|
dataIndex: 'tourismId',
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
const option = tourismOptions.find(item => item.value === record.tourismId);
|
||||||
|
return option?.label || '-';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '素材预览',
|
title: '素材预览',
|
||||||
@@ -228,13 +261,23 @@ const TableList: React.FC = () => {
|
|||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: renderStatus,
|
render: (status: number) => {
|
||||||
|
const statusOption = STATUS_OPTIONS.find(item => item.value === Number(status));
|
||||||
|
return statusOption ? (
|
||||||
|
<Tag color={statusOption.color}>{statusOption.label}</Tag>
|
||||||
|
) : '-';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "类型",
|
title: "类型",
|
||||||
dataIndex: 'type',
|
dataIndex: 'type',
|
||||||
width: 120,
|
width: 120,
|
||||||
render: renderType,
|
render: (type: number) => {
|
||||||
|
const typeOption = TYPE_OPTIONS.find(item => item.value === Number(type));
|
||||||
|
return typeOption ? (
|
||||||
|
<Tag color={typeOption.color}>{typeOption.label}</Tag>
|
||||||
|
) : '-';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
@@ -329,13 +372,7 @@ const TableList: React.FC = () => {
|
|||||||
<ModalForm
|
<ModalForm
|
||||||
title="添加素材"
|
title="添加素材"
|
||||||
visible={createModalVisible}
|
visible={createModalVisible}
|
||||||
onVisibleChange={(visible) => {
|
onVisibleChange={setCreateModalVisible}
|
||||||
console.log('Modal visible changed:', visible);
|
|
||||||
setCreateModalVisible(visible);
|
|
||||||
if (visible) {
|
|
||||||
fetchTourismList();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
onFinish={(values) => handleTableAction('add', undefined, values)}
|
onFinish={(values) => handleTableAction('add', undefined, values)}
|
||||||
>
|
>
|
||||||
@@ -348,11 +385,6 @@ const TableList: React.FC = () => {
|
|||||||
placeholder="请选择景区"
|
placeholder="请选择景区"
|
||||||
options={tourismOptions}
|
options={tourismOptions}
|
||||||
showSearch
|
showSearch
|
||||||
fieldProps={{
|
|
||||||
loading: !tourismOptions.length,
|
|
||||||
filterOption: (input, option) =>
|
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
rules={[{ required: true, message: '素材类型不为空' }]}
|
rules={[{ required: true, message: '素材类型不为空' }]}
|
||||||
@@ -362,6 +394,15 @@ const TableList: React.FC = () => {
|
|||||||
placeholder="请选择素材类型"
|
placeholder="请选择素材类型"
|
||||||
options={TYPE_OPTIONS}
|
options={TYPE_OPTIONS}
|
||||||
/>
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
width="md"
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
options={STATUS_OPTIONS}
|
||||||
|
initialValue={0}
|
||||||
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
name="linkUrl"
|
name="linkUrl"
|
||||||
@@ -376,23 +417,37 @@ const TableList: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
<Upload
|
<Upload
|
||||||
maxCount={1}
|
maxCount={1}
|
||||||
action="/api-file/files-anon"
|
accept="image/*"
|
||||||
showUploadList={false}
|
showUploadList={false}
|
||||||
beforeUpload={async (file) => {
|
customRequest={async ({ file, onSuccess, onError }) => {
|
||||||
const result = await handleImport(file);
|
try {
|
||||||
if (result && result.name) {
|
if (file instanceof File) {
|
||||||
setFile(result.name);
|
const result = await handleUpload(file as RcFile);
|
||||||
|
if (result) {
|
||||||
|
setCreateImageUrl(result.url);
|
||||||
|
setCreateImagePath(result.path);
|
||||||
|
onSuccess?.('ok');
|
||||||
|
} else {
|
||||||
|
onError?.(new Error('上传失败'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
onError?.(error);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={styles.button_view}>
|
<Button icon={<UploadOutlined />}>上传素材</Button>
|
||||||
<Button>
|
|
||||||
<UploadOutlined />
|
|
||||||
上传素材
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</Upload>
|
</Upload>
|
||||||
|
|
||||||
|
{createImageUrl && (
|
||||||
|
<div style={{ marginTop: 16 }}>
|
||||||
|
<Image
|
||||||
|
src={createImageUrl}
|
||||||
|
width={200}
|
||||||
|
style={{ objectFit: 'cover' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
|
|
||||||
@@ -402,6 +457,8 @@ const TableList: React.FC = () => {
|
|||||||
updateModalVisible={updateModalVisible}
|
updateModalVisible={updateModalVisible}
|
||||||
values={currentRow}
|
values={currentRow}
|
||||||
tourismOptions={tourismOptions}
|
tourismOptions={tourismOptions}
|
||||||
|
statusOptions={STATUS_OPTIONS}
|
||||||
|
typeOptions={TYPE_OPTIONS}
|
||||||
/>
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ export async function order(params?: { [key: string]: string | number }) {
|
|||||||
return { data: result.data, total: result.count };
|
return { data: result.data, total: result.count };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateOrder(data: ORDERS.Order): Promise<API.Result<ORDERS.Order>> {
|
||||||
|
const result = await request<API.Result<ORDERS.Order>>('/api-order/update/order', {
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
export async function deleteFile(id: number) {
|
export async function deleteFile(id: number) {
|
||||||
const url = `/api-order/files/${id}`;
|
const url = `/api-order/files/${id}`;
|
||||||
const result = await request<API.Result<void>>(url, {
|
const result = await request<API.Result<void>>(url, {
|
||||||
|
|||||||
Reference in New Issue
Block a user