diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java index 0c274a81..fcaaae65 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java @@ -409,6 +409,20 @@ public class OrderController { 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 = "机库查询订单执行情况") @AuditLog(operation = "'机库查询订单执行情况:' + #orderNo") @GetMapping("/status/{orderNo}") diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/TourismFile.java b/zlt-business/order-center/src/main/java/com/central/order/model/TourismFile.java index 90cd8b45..a91c1a6e 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/model/TourismFile.java +++ b/zlt-business/order-center/src/main/java/com/central/order/model/TourismFile.java @@ -36,8 +36,6 @@ public class TourismFile extends SuperEntity { private Date createTime; @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; - - private Long createId; //租户ID private Long tenantId; private String company; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx index 457f8924..12e05cb6 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx @@ -4,7 +4,7 @@ import { ProFormSelect, ProFormText, } from '@ant-design/pro-components'; -import React from 'react'; +import React, { useEffect } from 'react'; import { STATUS_OPTIONS } from '../index'; interface UpdateFormProps { @@ -16,15 +16,19 @@ interface UpdateFormProps { tourismOptions: any[]; // 从父组件接收景区选项 } -const UpdateForm: React.FC = (props) => { - const { - onSubmit, - onVisibleChange, - updateModalVisible, - values, - waylineOptions, - tourismOptions, - } = props; +const UpdateForm: React.FC = ({ + onSubmit, + onVisibleChange, + updateModalVisible, + values, + waylineOptions, + tourismOptions, +}) => { + useEffect(() => { + console.log('UpdateForm values:', values); + console.log('UpdateForm tourismOptions:', tourismOptions); + console.log('UpdateForm waylineOptions:', waylineOptions); + }, [values, tourismOptions, waylineOptions]); return ( = (props) => { visible={updateModalVisible} onVisibleChange={onVisibleChange} modalProps={{ destroyOnClose: true }} - initialValues={values} + initialValues={{ + ...values, + tourismId: Number(values?.tourismId), + waylineId: values?.waylineId, + }} onFinish={onSubmit} > diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx index d9390af2..a6aaf243 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx @@ -100,7 +100,7 @@ const renderStatus = (status: {} | null | undefined) => { const TableList: React.FC = () => { const actionRef = useRef(); - const [params, setParams] = useState>({ }); + const [params, setParams] = useState>({}); const [createModalVisible, handleModalVisible] = useState(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); const [currentRow, setCurrentRow] = useState(); @@ -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 () => { try { const result = await tourism({ @@ -166,6 +148,7 @@ const TableList: React.FC = () => { const options = result.data.map(item => ({ label: item.tourismName, value: item.id, + info: item })); setTourismOptions(options); } @@ -174,98 +157,160 @@ const TableList: React.FC = () => { } }, []); - useEffect(() => { - if (updateModalVisible || createModalVisible) { - fetchTourismList(); - fetchWaylineOptions(); + const fetchWaylineOptions = useCallback(async () => { + try { + const result = await wayline({ current: 1, pageSize: 100 }); + 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[] = [ { dataIndex: 'index', valueType: 'indexBorder', + width: 48, }, { title: 'ID', dataIndex: 'id', + width: 80, }, { title: 'CodeID', dataIndex: 'codeId', + width: 120, }, { - title: '景区ID', + title: '景区名称', 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: '文件', dataIndex: 'viewUrl', - render: (viewUrl) => + width: 120, + render: (viewUrl) => viewUrl ? ( + + ) : '-', }, { title: '价格', dataIndex: 'price', + width: 100, + render: (price) => price ? `¥${(Number(price) / 100).toFixed(2)}` : '-', }, { title: '设备SN', dataIndex: 'deviceSn', + width: 140, + ellipsis: true, }, { title: '状态', dataIndex: 'status', + width: 100, render: (status) => renderStatus(status), }, { title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', + width: 180, }, { title: '操作', key: 'action', - render: (_, entity) => - - { - setCurrentRow({ - ...entity, - waylineId: entity.waylineId, - }); - handleUpdateModalVisible(true); - }} - > - 修改 - - { - const success = await handleTableAction('delete', entity); - }} - > - 删除 - - + width: 120, + render: (_, record) => ( + + { + setCurrentRow(record); + handleUpdateModalVisible(true); + }} + > + 修改 + + handleTableAction('delete', record)} + > + 删除 + + + ), }, ]; return ( - + setParams(values)} + onFinish={setParams} > - + + + - + rowKey="id" headerTitle="二维码列表" - request={qrcode} actionRef={actionRef} columns={columns} + request={qrcode} search={false} params={params} pagination={{ @@ -273,16 +318,13 @@ const TableList: React.FC = () => { showQuickJumper: true, }} toolBarRender={() => [ - <> - - , + , ]} /> ) => Promise; + onSubmit: (values: any) => Promise; onVisibleChange: (visible: boolean) => void; updateModalVisible: boolean; values?: ORDERS.TourismFile; + tourismOptions: any[]; + statusOptions: typeof STATUS_OPTIONS; + typeOptions: typeof TYPE_OPTIONS; } const UpdateForm: React.FC = ({ @@ -25,54 +28,44 @@ const UpdateForm: React.FC = ({ onVisibleChange, updateModalVisible, values, + tourismOptions, + statusOptions, + typeOptions, }) => { - const [imageUrl, setImageUrl] = useState(values?.imageUrl || ''); - const [tourismOptions, setTourismOptions] = useState([]); + const [uploading, setUploading] = useState(false); + const [updateImageUrl, setUpdateImageUrl] = useState(); + const [updateImagePath, setUpdateImagePath] = useState(); + // 处理文件上传 const handleUpload = async (file: RcFile) => { - const hide = message.loading('正在上传'); + setUploading(true); + const hide = message.loading('正在上传...'); + try { const formData = new FormData(); formData.append('file', file); 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) { - const options = result.data.map(item => ({ - label: item.tourismName, - value: item.id, - })); - setTourismOptions(options); + hide(); + + if (result.url && result.path) { + message.success('上传成功'); + setUpdateImageUrl(result.url); + setUpdateImagePath(result.path); + return true; } + + message.error('上传失败:未获取到文件信息'); + return false; } 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 ( = ({ onVisibleChange={onVisibleChange} modalProps={{ destroyOnClose: true }} initialValues={values} - onFinish={async (formValues) => { - const submitData = { - ...formValues, - imageUrl: imageUrl || values?.imageUrl, - }; - await onSubmit(submitData); - }} + onFinish={onSubmit} > = ({ placeholder="请选择景区" options={tourismOptions} showSearch - fieldProps={{ - loading: !tourismOptions.length, - filterOption: (input, option) => - (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), - }} /> = ({ name="type" label="素材类型" placeholder="请选择素材类型" - options={TYPE_OPTIONS} + options={typeOptions} + /> + = ({ label="素材描述" placeholder="输入描述" /> - -
- {imageUrl || values?.imageUrl ? ( - - ) : null} - { + try { + if (file instanceof File) { + const success = await handleUpload(file as RcFile); + if (success) { + onSuccess?.('ok'); + } else { + onError?.(new Error('上传失败')); + } + } + } catch (error) { + onError?.(error); + } + }} + > + - + 更新素材 + + + +
+
diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx index 39cf3710..62a64937 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx @@ -22,12 +22,18 @@ import styles from './index.less'; const { Link } = Typography; -// 提取常量 -export const TYPE_OPTIONS = [ - { label: '展示大图', value: 4 }, - { label: '拍照引导图', value: 3 }, - { label: '拍照角度展示图', value: 2 }, - { label: '活动', value: 1 }, +// 状态常量 +const STATUS_OPTIONS = [ + { label: '启用', value: 0, color: 'success' }, + { label: '未启用', value: 1, color: 'error' }, +] 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; // 状态映射 @@ -95,28 +101,18 @@ const handleDelete = async (tourismFile: ORDERS.TourismFile) => { ); }; -const handleImport = async (file: RcFile) => { - return handleApiRequest( - async () => { - const formData = new FormData(); - formData.append('file', file); - return await importImage(formData); - }, - '正在上传', - '上传素材成功' - ); -}; - -// 渲染函数 -const renderStatus = (status: {} | null | undefined) => { - const statusInfo = statusColorMap[status] || { color: 'gray', text: '未知状态' }; - return {statusInfo.text}; -}; - -const renderType = (type: {} | null | undefined) => { - const typeInfo = typeColorMap[type] || { color: 'gray', text: '未知状态' }; - return {typeInfo.text}; -}; +interface UploadResponse { + id: string; + url: string; + path: string; + name: string; + isImg: boolean; + contentType: string; + size: number; + source: string; + createTime: string; + updateTime: string; +} const TableList: React.FC = () => { const actionRef = useRef(); @@ -124,7 +120,8 @@ const TableList: React.FC = () => { const [createModalVisible, setCreateModalVisible] = useState(false); const [updateModalVisible, setUpdateModalVisible] = useState(false); const [currentRow, setCurrentRow] = useState(); - const [file, setFile] = useState(); + const [createImageUrl, setCreateImageUrl] = useState(); + const [createImagePath, setCreateImagePath] = useState(); const [tourismOptions, setTourismOptions] = useState<{ label: string; value: number; info?: any }[]>([]); // 获取景区列表 @@ -159,6 +156,30 @@ const TableList: React.FC = () => { 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 ( action: 'add' | 'edit' | 'delete', record?: ORDERS.TourismFile, @@ -167,8 +188,16 @@ const TableList: React.FC = () => { let success = false; switch (action) { case 'add': - success = await handleAdd({ ...values, imageUrl: file } as ORDERS.TourismFile); - success && setCreateModalVisible(false); + if (!createImagePath) { + message.error('请上传素材图片'); + return false; + } + success = await handleAdd({ ...values, imageUrl: createImagePath } as ORDERS.TourismFile); + if (success) { + setCreateModalVisible(false); + setCreateImageUrl(undefined); + setCreateImagePath(undefined); + } break; case 'edit': if (record) { @@ -186,7 +215,7 @@ const TableList: React.FC = () => { if (success && actionRef.current) { actionRef.current.reload(); } - }, [file]); + }, [createImagePath]); const columns: ProColumns[] = [ { @@ -197,8 +226,12 @@ const TableList: React.FC = () => { }, { title: '景区名称', - dataIndex: 'tourismName', + dataIndex: 'tourismId', ellipsis: true, + render: (_, record) => { + const option = tourismOptions.find(item => item.value === record.tourismId); + return option?.label || '-'; + }, }, { title: '素材预览', @@ -228,13 +261,23 @@ const TableList: React.FC = () => { title: '状态', dataIndex: 'status', width: 100, - render: renderStatus, + render: (status: number) => { + const statusOption = STATUS_OPTIONS.find(item => item.value === Number(status)); + return statusOption ? ( + {statusOption.label} + ) : '-'; + }, }, { title: "类型", dataIndex: 'type', width: 120, - render: renderType, + render: (type: number) => { + const typeOption = TYPE_OPTIONS.find(item => item.value === Number(type)); + return typeOption ? ( + {typeOption.label} + ) : '-'; + }, }, { title: '创建时间', @@ -329,13 +372,7 @@ const TableList: React.FC = () => { { - console.log('Modal visible changed:', visible); - setCreateModalVisible(visible); - if (visible) { - fetchTourismList(); - } - }} + onVisibleChange={setCreateModalVisible} modalProps={{ destroyOnClose: true }} onFinish={(values) => handleTableAction('add', undefined, values)} > @@ -348,11 +385,6 @@ const TableList: React.FC = () => { placeholder="请选择景区" options={tourismOptions} showSearch - fieldProps={{ - loading: !tourismOptions.length, - filterOption: (input, option) => - (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), - }} /> { placeholder="请选择素材类型" options={TYPE_OPTIONS} /> + { /> { - const result = await handleImport(file); - if (result && result.name) { - setFile(result.name); + customRequest={async ({ file, onSuccess, onError }) => { + try { + if (file instanceof File) { + 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; }} > -
- -
+
+ + {createImageUrl && ( +
+ +
+ )}
@@ -402,6 +457,8 @@ const TableList: React.FC = () => { updateModalVisible={updateModalVisible} values={currentRow} tourismOptions={tourismOptions} + statusOptions={STATUS_OPTIONS} + typeOptions={TYPE_OPTIONS} /> ); diff --git a/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts b/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts index efd8049b..2c0a800d 100644 --- a/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts +++ b/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts @@ -11,6 +11,14 @@ export async function order(params?: { [key: string]: string | number }) { return { data: result.data, total: result.count }; } +export async function updateOrder(data: ORDERS.Order): Promise> { + const result = await request>('/api-order/update/order', { + method: 'POST', + data, + }); + return result; +} + export async function deleteFile(id: number) { const url = `/api-order/files/${id}`; const result = await request>(url, {