fix[订单模块]:景区素材管理。后台管理系统创建素材
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<mapper namespace="com.central.order.mapper.TourismFileMapper">
|
||||
|
||||
<select id="findList" resultType="com.central.order.model.TourismFile">
|
||||
select * from tourisms t
|
||||
select * from tourisms_files t
|
||||
</select>
|
||||
|
||||
<resultMap id="TourismFileResultMap" type="com.central.order.model.TourismFile">
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
{
|
||||
path: '/orders/qrcode.html',
|
||||
component: './orders/Qrcode',
|
||||
},
|
||||
{
|
||||
path: '/orders/tourismFile.html',
|
||||
component: './orders/TourismFile',
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
@@ -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<ActionType>();
|
||||
const [params, setParams] = useState<Record<string, string | number>>({ });
|
||||
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||
const [currentRow, setCurrentRow] = useState<ORDERS.Qrcode>();
|
||||
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
||||
const [currentRow, setCurrentRow] = useState<ORDERS.TourismFile>();
|
||||
const [file, setFile] = useState();
|
||||
// const setImage = (imageUrl: string) => {
|
||||
// setFile({ ...file, imageUrl});
|
||||
// }
|
||||
const columns: ProColumns<ORDERS.TourismFile>[] = [
|
||||
{
|
||||
dataIndex: 'index',
|
||||
valueType: 'indexBorder',
|
||||
},
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
},
|
||||
{
|
||||
title: 'CodeID',
|
||||
dataIndex: 'codeId',
|
||||
},
|
||||
{
|
||||
title: '景区ID',
|
||||
dataIndex: 'tourismId',
|
||||
},
|
||||
{
|
||||
title: '文件',
|
||||
dataIndex: 'viewUrl',
|
||||
render: (viewUrl) => <Image src={viewUrl} width={100} />
|
||||
title: '素材',
|
||||
dataIndex: 'imageUrl',
|
||||
render: (imageUrl) => <Image src={imageUrl} width={100} />
|
||||
},
|
||||
{
|
||||
title: '价格',
|
||||
dataIndex: 'price',
|
||||
title: '页面链接',
|
||||
dataIndex: 'linkUrl',
|
||||
},
|
||||
{
|
||||
title: '设备SN',
|
||||
dataIndex: 'deviceSn',
|
||||
title: '描述',
|
||||
dataIndex: 'description',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
@@ -132,7 +147,7 @@ const TableList: React.FC = () => {
|
||||
修改
|
||||
</Link>
|
||||
<Popconfirm
|
||||
title={`确认删除景区[${entity.codeId}]?`}
|
||||
title={`确认删除素材[${entity.id}]?`}
|
||||
onConfirm={async () => {
|
||||
const success = await handleDelete(entity);
|
||||
if (success) {
|
||||
@@ -159,10 +174,10 @@ const TableList: React.FC = () => {
|
||||
>
|
||||
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
|
||||
</QueryFilter>
|
||||
<ProTable<ORDERS.Qrcode>
|
||||
<ProTable<ORDERS.TourismFile>
|
||||
rowKey="id"
|
||||
headerTitle="二维码列表"
|
||||
request={qrcode}
|
||||
headerTitle="素材列表"
|
||||
request={tourismFile}
|
||||
actionRef={actionRef}
|
||||
columns={columns}
|
||||
search={false}
|
||||
@@ -185,13 +200,14 @@ const TableList: React.FC = () => {
|
||||
]}
|
||||
/>
|
||||
<ModalForm
|
||||
title="添加二维码"
|
||||
title="添加素材"
|
||||
// layout="horizontal"
|
||||
visible={createModalVisible}
|
||||
onVisibleChange={handleModalVisible}
|
||||
modalProps={{ destroyOnClose: true }}
|
||||
onFinish={async (values) => {
|
||||
|
||||
values.imageUrl = file
|
||||
const success = await handleAdd(values);
|
||||
if (success) {
|
||||
handleModalVisible(false);
|
||||
@@ -201,73 +217,76 @@ const TableList: React.FC = () => {
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '景区不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="tourismId"
|
||||
label="景区"
|
||||
placeholder="请选择景区"
|
||||
options={[
|
||||
{ label: '北塘古镇', value: 33 },
|
||||
{ label: '海丝首港', value: 32 },
|
||||
{ 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}
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: '景区不为空',
|
||||
},
|
||||
]}
|
||||
width="md"
|
||||
name="tourismId"
|
||||
label="景区"
|
||||
placeholder="请选择景区"
|
||||
options={[
|
||||
{ label: '北塘古镇', value: 33 },
|
||||
{ label: '海丝首港', value: 32 },
|
||||
{ label: '景区C', value: 2 },
|
||||
// 添加更多选项...
|
||||
]}
|
||||
/>
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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<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 }) {
|
||||
const { current, pageSize, ...rest } = params ?? {};
|
||||
const result = await request<SYSTEM.Page<ORDERS.Qrcode>>('/api-order/qrcode', {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user