fix[订单模块]:景区素材管理。后台管理系统创建素材
This commit is contained in:
@@ -19,7 +19,7 @@ import java.util.Date;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("tourism_files")
|
@TableName("tourisms_files")
|
||||||
public class TourismFile extends SuperEntity {
|
public class TourismFile extends SuperEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID=1L;
|
private static final long serialVersionUID=1L;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: order-center
|
name: order-center
|
||||||
cloud:
|
# cloud:
|
||||||
nacos:
|
# nacos:
|
||||||
discovery:
|
# discovery:
|
||||||
ip: 81.70.164.178
|
# ip: 81.70.164.178
|
||||||
# cloud:
|
# cloud:
|
||||||
# nacos:
|
# nacos:
|
||||||
# discovery:
|
# discovery:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<mapper namespace="com.central.order.mapper.TourismFileMapper">
|
<mapper namespace="com.central.order.mapper.TourismFileMapper">
|
||||||
|
|
||||||
<select id="findList" resultType="com.central.order.model.TourismFile">
|
<select id="findList" resultType="com.central.order.model.TourismFile">
|
||||||
select * from tourisms t
|
select * from tourisms_files t
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<resultMap id="TourismFileResultMap" type="com.central.order.model.TourismFile">
|
<resultMap id="TourismFileResultMap" type="com.central.order.model.TourismFile">
|
||||||
|
|||||||
@@ -65,6 +65,10 @@
|
|||||||
{
|
{
|
||||||
path: '/orders/qrcode.html',
|
path: '/orders/qrcode.html',
|
||||||
component: './orders/Qrcode',
|
component: './orders/Qrcode',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/orders/tourismFile.html',
|
||||||
|
component: './orders/TourismFile',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { deleteQrcode, qrcode, saveOrUpdateQrcode } from '@/services/orders/api';
|
import {deleteTourismFile, saveOrUpdateTourismFile, tourismFile } from '@/services/orders/api';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { importImage } from '@/services/system/api';
|
||||||
|
import { PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
||||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import {
|
import {
|
||||||
ModalForm,
|
ModalForm,
|
||||||
@@ -13,13 +14,15 @@ import {
|
|||||||
import { Typography, Popconfirm, Space, message, Image, Button } from 'antd';
|
import { Typography, Popconfirm, Space, message, Image, Button } from 'antd';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
import Upload, { RcFile } from 'antd/lib/upload';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
const handleAdd = async (fields: ORDERS.Qrcode) => {
|
const handleAdd = async (fields: ORDERS.TourismFile) => {
|
||||||
const hide = message.loading('正在添加');
|
const hide = message.loading('正在添加');
|
||||||
try {
|
try {
|
||||||
const result = await saveOrUpdateQrcode({ ...fields });
|
const result = await saveOrUpdateTourismFile({ ...fields });
|
||||||
hide();
|
hide();
|
||||||
if (result.resp_code === 0) {
|
if (result.resp_code === 0) {
|
||||||
message.success('添加成功');
|
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('正在更新');
|
const hide = message.loading('正在更新');
|
||||||
try {
|
try {
|
||||||
const result = await saveOrUpdateQrcode({ ...fields });
|
const result = await saveOrUpdateTourismFile({ ...fields });
|
||||||
hide();
|
hide();
|
||||||
if (result.resp_code === 0) {
|
if (result.resp_code === 0) {
|
||||||
message.success('修改成功');
|
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('正在删除');
|
const hide = message.loading('正在删除');
|
||||||
try {
|
try {
|
||||||
const result = await deleteQrcode(qrcode.id);
|
const result = await deleteTourismFile(qrcode.id);
|
||||||
hide();
|
hide();
|
||||||
if (result.resp_code === 0) {
|
if (result.resp_code === 0) {
|
||||||
message.success('删除成功');
|
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 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.TourismFile>();
|
||||||
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
const [file, setFile] = useState();
|
||||||
|
// const setImage = (imageUrl: string) => {
|
||||||
|
// setFile({ ...file, imageUrl});
|
||||||
|
// }
|
||||||
|
const columns: ProColumns<ORDERS.TourismFile>[] = [
|
||||||
{
|
{
|
||||||
dataIndex: 'index',
|
dataIndex: 'index',
|
||||||
valueType: 'indexBorder',
|
valueType: 'indexBorder',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: 'ID',
|
|
||||||
dataIndex: 'id',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'CodeID',
|
|
||||||
dataIndex: 'codeId',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '景区ID',
|
title: '景区ID',
|
||||||
dataIndex: 'tourismId',
|
dataIndex: 'tourismId',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '文件',
|
title: '素材',
|
||||||
dataIndex: 'viewUrl',
|
dataIndex: 'imageUrl',
|
||||||
render: (viewUrl) => <Image src={viewUrl} width={100} />
|
render: (imageUrl) => <Image src={imageUrl} width={100} />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '价格',
|
title: '页面链接',
|
||||||
dataIndex: 'price',
|
dataIndex: 'linkUrl',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '设备SN',
|
title: '描述',
|
||||||
dataIndex: 'deviceSn',
|
dataIndex: 'description',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
@@ -132,7 +147,7 @@ const TableList: React.FC = () => {
|
|||||||
修改
|
修改
|
||||||
</Link>
|
</Link>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={`确认删除景区[${entity.codeId}]?`}
|
title={`确认删除素材[${entity.id}]?`}
|
||||||
onConfirm={async () => {
|
onConfirm={async () => {
|
||||||
const success = await handleDelete(entity);
|
const success = await handleDelete(entity);
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -159,10 +174,10 @@ const TableList: React.FC = () => {
|
|||||||
>
|
>
|
||||||
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
|
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
|
||||||
</QueryFilter>
|
</QueryFilter>
|
||||||
<ProTable<ORDERS.Qrcode>
|
<ProTable<ORDERS.TourismFile>
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
headerTitle="二维码列表"
|
headerTitle="素材列表"
|
||||||
request={qrcode}
|
request={tourismFile}
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
@@ -185,13 +200,14 @@ const TableList: React.FC = () => {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="添加二维码"
|
title="添加素材"
|
||||||
// layout="horizontal"
|
// layout="horizontal"
|
||||||
visible={createModalVisible}
|
visible={createModalVisible}
|
||||||
onVisibleChange={handleModalVisible}
|
onVisibleChange={handleModalVisible}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
|
|
||||||
|
values.imageUrl = file
|
||||||
const success = await handleAdd(values);
|
const success = await handleAdd(values);
|
||||||
if (success) {
|
if (success) {
|
||||||
handleModalVisible(false);
|
handleModalVisible(false);
|
||||||
@@ -201,73 +217,76 @@ const TableList: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '景区不为空',
|
message: '景区不为空',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
width="md"
|
width="md"
|
||||||
name="tourismId"
|
name="tourismId"
|
||||||
label="景区"
|
label="景区"
|
||||||
placeholder="请选择景区"
|
placeholder="请选择景区"
|
||||||
options={[
|
options={[
|
||||||
{ label: '北塘古镇', value: 33 },
|
{ label: '北塘古镇', value: 33 },
|
||||||
{ label: '海丝首港', value: 32 },
|
{ label: '海丝首港', value: 32 },
|
||||||
{ label: '景区C', value: 2 },
|
{ label: '景区C', value: 2 },
|
||||||
// 添加更多选项...
|
// 添加更多选项...
|
||||||
]}
|
]}
|
||||||
/>
|
|
||||||
<ProFormText
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: '价格不为空',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
width="md"
|
|
||||||
name="price"
|
|
||||||
label="景点打卡价格"
|
|
||||||
placeholder="输入价格(单位:分)"
|
|
||||||
/>
|
|
||||||
<ProFormSelect
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: '设备不为空',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
width="md"
|
|
||||||
name="deviceSn"
|
|
||||||
label="设备编号"
|
|
||||||
placeholder="输入设备编号"
|
|
||||||
options={[
|
|
||||||
{ label: '7CTDM6F00B744S', value: '7CTDM6F00B744S' },
|
|
||||||
// 添加更多选项...
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</ProForm.Group>
|
|
||||||
</ModalForm>
|
|
||||||
<UpdateForm
|
|
||||||
onSubmit={async (values) => {
|
|
||||||
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}
|
|
||||||
/>
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="linkUrl"
|
||||||
|
label="素材链接url"
|
||||||
|
placeholder="输入url"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="description"
|
||||||
|
label="素材描述"
|
||||||
|
placeholder="输入描述 "
|
||||||
|
/>
|
||||||
|
<Upload
|
||||||
|
maxCount={1}
|
||||||
|
action="/api-file/files-anon"
|
||||||
|
showUploadList={false}
|
||||||
|
beforeUpload={async (file) => {
|
||||||
|
const result = await handleImport(file);
|
||||||
|
if (result && result.name) {
|
||||||
|
setFile(result.name);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className={styles.button_view}>
|
||||||
|
<Button>
|
||||||
|
<UploadOutlined />
|
||||||
|
上传素材
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Upload>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
<UpdateForm
|
||||||
|
onSubmit={async (values) => {
|
||||||
|
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}
|
||||||
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,6 +53,32 @@ export async function deleteTourism(id: number) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function tourismFile(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<ORDERS.TourismFile>>('/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<API.Result<ORDERS.TourismFile>> {
|
||||||
|
const result = await request<API.Result<ORDERS.TourismFile>>('/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<API.Result<void>>(url, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function qrcode(params?: { [key: string]: string | number }) {
|
export async function qrcode(params?: { [key: string]: string | number }) {
|
||||||
const { current, pageSize, ...rest } = params ?? {};
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
const result = await request<SYSTEM.Page<ORDERS.Qrcode>>('/api-order/qrcode', {
|
const result = await request<SYSTEM.Page<ORDERS.Qrcode>>('/api-order/qrcode', {
|
||||||
|
|||||||
@@ -39,6 +39,19 @@ declare namespace ORDERS {
|
|||||||
updateTime?: string;
|
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 = {
|
type Qrcode = {
|
||||||
id: number;
|
id: number;
|
||||||
codeId: string;
|
codeId: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user