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 f98f7fd9..181622fe 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 @@ -19,7 +19,7 @@ import java.util.Date; @Getter @Setter @EqualsAndHashCode(callSuper = false) -@TableName("tourism_files") +@TableName("tourisms_files") public class TourismFile extends SuperEntity { private static final long serialVersionUID=1L; diff --git a/zlt-business/order-center/src/main/resources/bootstrap.yml b/zlt-business/order-center/src/main/resources/bootstrap.yml index 1566517e..e780c4e4 100644 --- a/zlt-business/order-center/src/main/resources/bootstrap.yml +++ b/zlt-business/order-center/src/main/resources/bootstrap.yml @@ -4,10 +4,10 @@ server: spring: application: name: order-center - cloud: - nacos: - discovery: - ip: 81.70.164.178 +# cloud: +# nacos: +# discovery: +# ip: 81.70.164.178 # cloud: # nacos: # discovery: diff --git a/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml b/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml index b0248d2a..3ad7728f 100644 --- a/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml +++ b/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml @@ -4,7 +4,7 @@ diff --git a/zlt-web/react-web/src/main/frontend/config/routes.ts b/zlt-web/react-web/src/main/frontend/config/routes.ts index f3a2cdf5..f5f5d7da 100644 --- a/zlt-web/react-web/src/main/frontend/config/routes.ts +++ b/zlt-web/react-web/src/main/frontend/config/routes.ts @@ -65,6 +65,10 @@ { path: '/orders/qrcode.html', component: './orders/Qrcode', + }, + { + path: '/orders/tourismFile.html', + component: './orders/TourismFile', } ], }, 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 2a6f40a7..c6c22d30 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 @@ -1,5 +1,6 @@ -import { deleteQrcode, qrcode, saveOrUpdateQrcode } from '@/services/orders/api'; -import { PlusOutlined } from '@ant-design/icons'; +import {deleteTourismFile, saveOrUpdateTourismFile, tourismFile } from '@/services/orders/api'; +import { importImage } from '@/services/system/api'; +import { PlusOutlined, UploadOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { ModalForm, @@ -13,13 +14,15 @@ import { import { Typography, Popconfirm, Space, message, Image, Button } from 'antd'; import React, { useRef, useState } from 'react'; import UpdateForm from './components/UpdateForm'; +import Upload, { RcFile } from 'antd/lib/upload'; +import styles from './index.less'; const { Link } = Typography; -const handleAdd = async (fields: ORDERS.Qrcode) => { +const handleAdd = async (fields: ORDERS.TourismFile) => { const hide = message.loading('正在添加'); try { - const result = await saveOrUpdateQrcode({ ...fields }); + const result = await saveOrUpdateTourismFile({ ...fields }); hide(); if (result.resp_code === 0) { message.success('添加成功'); @@ -35,10 +38,10 @@ const handleAdd = async (fields: ORDERS.Qrcode) => { } }; -const handleEdit = async (fields: ORDERS.Qrcode) => { +const handleEdit = async (fields: ORDERS.TourismFile) => { const hide = message.loading('正在更新'); try { - const result = await saveOrUpdateQrcode({ ...fields }); + const result = await saveOrUpdateTourismFile({ ...fields }); hide(); if (result.resp_code === 0) { message.success('修改成功'); @@ -54,10 +57,10 @@ const handleEdit = async (fields: ORDERS.Qrcode) => { } }; -const handleDelete = async (qrcode: ORDERS.Qrcode) => { +const handleDelete = async (qrcode: ORDERS.TourismFile) => { const hide = message.loading('正在删除'); try { - const result = await deleteQrcode(qrcode.id); + const result = await deleteTourismFile(qrcode.id); hide(); if (result.resp_code === 0) { message.success('删除成功'); @@ -73,41 +76,53 @@ const handleDelete = async (qrcode: ORDERS.Qrcode) => { } }; +const handleImport = async (file: RcFile) => { + const hide = message.loading('正在导入'); + try { + const formData = new FormData(); + formData.append('file', file); + const result = await importImage(formData); + hide(); + message.success('上传素材成功'); + return result; + } catch (error) { + hide(); + message.error('上传素材失败'); + return null; + } +}; + const TableList: React.FC = () => { const actionRef = useRef(); const [params, setParams] = useState>({ }); const [createModalVisible, handleModalVisible] = useState(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); - const [currentRow, setCurrentRow] = useState(); - const columns: ProColumns[] = [ + const [currentRow, setCurrentRow] = useState(); + const [file, setFile] = useState(); + // const setImage = (imageUrl: string) => { + // setFile({ ...file, imageUrl}); + // } + const columns: ProColumns[] = [ { dataIndex: 'index', valueType: 'indexBorder', }, - { - title: 'ID', - dataIndex: 'id', - }, - { - title: 'CodeID', - dataIndex: 'codeId', - }, { title: '景区ID', dataIndex: 'tourismId', }, { - title: '文件', - dataIndex: 'viewUrl', - render: (viewUrl) => + title: '素材', + dataIndex: 'imageUrl', + render: (imageUrl) => }, { - title: '价格', - dataIndex: 'price', + title: '页面链接', + dataIndex: 'linkUrl', }, { - title: '设备SN', - dataIndex: 'deviceSn', + title: '描述', + dataIndex: 'description', }, { title: '状态', @@ -132,7 +147,7 @@ const TableList: React.FC = () => { 修改 { const success = await handleDelete(entity); if (success) { @@ -159,10 +174,10 @@ const TableList: React.FC = () => { > - + rowKey="id" - headerTitle="二维码列表" - request={qrcode} + headerTitle="素材列表" + request={tourismFile} actionRef={actionRef} columns={columns} search={false} @@ -185,13 +200,14 @@ const TableList: React.FC = () => { ]} /> { + values.imageUrl = file const success = await handleAdd(values); if (success) { handleModalVisible(false); @@ -201,73 +217,76 @@ const TableList: React.FC = () => { } }} > - - - - - - - { - if (currentRow) { - - const success = await handleEdit({ ...currentRow, ...values }); - if (success) { - handleUpdateModalVisible(false); - if (actionRef.current) { - actionRef.current.reload(); - } - } - setCurrentRow(undefined); - } - }} - onVisibleChange={handleUpdateModalVisible} - updateModalVisible={updateModalVisible} - values={currentRow} + + + + + { + const result = await handleImport(file); + if (result && result.name) { + setFile(result.name); + } + return false; + }} + > +
+ +
+
+
+ + { + if (currentRow) { + + const success = await handleEdit({ ...currentRow, ...values }); + if (success) { + handleUpdateModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } + setCurrentRow(undefined); + } + }} + onVisibleChange={handleUpdateModalVisible} + updateModalVisible={updateModalVisible} + values={currentRow} + /> ); }; 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 f8dcb5b7..a9bfabcd 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 @@ -53,6 +53,32 @@ export async function deleteTourism(id: number) { return result; } +export async function tourismFile(params?: { [key: string]: string | number }) { + const { current, pageSize, ...rest } = params ?? {}; + const result = await request>('/api-order/tourism/files', { + method: 'GET', + params: { page: current, limit: pageSize, ...rest }, + }); + return { data: result.data, total: result.count }; +} + +export async function saveOrUpdateTourismFile(data: ORDERS.TourismFile): Promise> { + const result = await request>('/api-order/tourism/files', { + method: 'POST', + data, + }); + return result; +} + +export async function deleteTourismFile(id: number) { + const url = `/api-order/tourism/files/${id}`; + const result = await request>(url, { + method: 'DELETE', + }); + return result; +} + + export async function qrcode(params?: { [key: string]: string | number }) { const { current, pageSize, ...rest } = params ?? {}; const result = await request>('/api-order/qrcode', { diff --git a/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts b/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts index 36d7a704..11b855a0 100644 --- a/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts +++ b/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts @@ -39,6 +39,19 @@ declare namespace ORDERS { updateTime?: string; } + type TourismFile = { + id: number; + tourismId: string; + imageUrl: string; + contentType: string; + description: string; + linkUrl: string; + createTime?: string; + status: number; + tenantId?: string; + updateTime?: string; + } + type Qrcode = { id: number; codeId: string;