system-copyright-react/src/route/CopyrightGgoods/CopyrightGgoods.tsx

476 lines
16 KiB
TypeScript
Raw Normal View History

2024-05-31 09:19:30 +08:00
import './copyrightG-goods.css'
2024-06-04 16:02:06 +08:00
import {
2025-04-11 16:20:46 +08:00
// Select, DatePicker, Button,
Table,
2024-05-31 09:19:30 +08:00
// message,
2025-04-11 16:20:46 +08:00
Space,
Pagination,
// InputNumber
Spin,
Modal,
2025-04-14 16:14:27 +08:00
Image,
Button,
Input
2024-06-04 16:02:06 +08:00
} from 'antd';
2025-04-14 16:14:27 +08:00
import { showImage } from '../../request/request'
2025-04-11 16:20:46 +08:00
import { useLocation } from 'react-router-dom';
import dayjs, { } from 'dayjs';
2025-04-14 16:14:27 +08:00
import { buyGoodsList, goodsDetail, createOrder, confirmPayment } from '../../request/api'
2025-04-11 16:20:46 +08:00
// import type { InputNumberProps } from 'antd';
2024-05-31 09:19:30 +08:00
// import type { TableColumnsType } from 'antd';
2025-04-11 16:20:46 +08:00
// import { SearchOutlined, ClearOutlined } from '@ant-design/icons';
// import type { DatePickerProps } from 'antd';
// import locale from 'antd/es/date-picker/locale/zh_CN';
import { useState, useEffect } from 'react';
import useMessage from "antd/es/message/useMessage";
2024-05-31 09:19:30 +08:00
const { Column } = Table;
2025-04-14 16:14:27 +08:00
const { TextArea } = Input;
2024-05-21 11:21:34 +08:00
export default function CopyrightGgoods() {
2025-04-11 16:20:46 +08:00
const [messageApi, messageContext] = useMessage();
2024-06-12 17:01:55 +08:00
const height = window.innerHeight - 180;
2025-04-11 16:20:46 +08:00
const [goodsId, setGoodsId] = useState<any>() //商品ID
const [goodsDetailModal, setGoodsDetailModal] = useState(false) //订单详情
2025-04-14 16:14:27 +08:00
const [buyTipsModal, setBuyTipsModal] = useState(false) //卖提示框
2025-04-11 16:20:46 +08:00
2024-05-31 09:19:30 +08:00
// const [messageApi, contextHolder] = message.useMessage();
2025-04-11 16:20:46 +08:00
// const dateFormat = 'YYYY-MM-DD';
// const [minPrice, setMinPrice] = useState<any>() //最低价格
// const [maxPrice, setMaxPrice] = useState<any>() //最高价格
// const [date, setDate] = useState<any>() //获取时间
// const [sort, setSort] = useState<any>() //排序
// const [language, setLanguage] = useState<any>() //开发语言
// const [type, setType] = useState<any>() //软著类型
const [page, setPage] = useState(1) //页
const [total, setTotal] = useState(0) //总条数
const [loading, setLoading] = useState(false) //加载中
2025-04-14 16:14:27 +08:00
// const [payLoading, setPayLoading] = useState(false) //正在付款
2025-04-11 16:20:46 +08:00
const { state } = useLocation()
const copyrightKeywords = state ? state.copyrightKeywords : ''; // 版权关键字
const minPrice = state ? state.minPrice : ''; // 最低价格
const maxPrice = state ? state.maxPrice : ''; // 最高价格
const sort = state ? state.sort : ''; // 排序
const copyrightDate = state ? state.copyrightDate : ''; // 版权日期
const copyrightLanguage = state ? state.copyrightLanguage : ''; // 开发语言
const copyrightType = state ? state.copyrightType : ''; // 软著类型
2024-08-12 14:43:58 +08:00
2024-05-31 09:19:30 +08:00
2025-04-11 16:20:46 +08:00
const [data, setData] = useState([]); // 表格数据
2025-04-14 16:14:27 +08:00
// 确认支付
const confirmPaymentFun = async (orderId: string) => {
try {
// setLoading(true)
const res: any = await confirmPayment(orderId)
console.log(res);
// setLoading(false)
} catch (error: any) {
if (error.response) {
const data = error.response.data;
messageApi.open({
type: 'error',
content: data.msg ? data.msg : `${data.path}(${data.status})`,
});
} else {
console.error(error)
}
}
}
// 创建订单
const createOrderFun = async (goodsId: string) => {
try {
// setPayLoading(true)
const res: any = await createOrder(goodsId)
// console.log(res);
confirmPaymentFun(res.data)
} catch (error: any) {
if (error.response) {
const data = error.response.data;
messageApi.open({
type: 'error',
content: data.msg ? data.msg : `${data.path}(${data.status})`,
});
} else {
console.error(error)
}
}
}
2025-04-11 16:20:46 +08:00
const getBuyGoodsList = async (page: number) => {
try {
setLoading(true)
const res: any = await buyGoodsList({
page: page,
rows: 10,
keywords: copyrightKeywords ? copyrightKeywords : '', // 版权关键字
priceRangeStart: minPrice ? minPrice : '', // 最低价格
priceRangeEnd: maxPrice ? maxPrice : '', // 最高价格
priceOrder: sort ? sort : '', // 排序
goodsGetTime: copyrightDate ? dayjs(copyrightDate).year() : '', // 版权日期
goodsDevelop: copyrightLanguage ? copyrightLanguage : '', // 开发语言
goodsType: copyrightType ? copyrightType.join(',') : '', // 软著类型
})
2025-04-14 16:14:27 +08:00
// console.log(res);
2025-04-11 16:20:46 +08:00
setLoading(false)
setPage(res.page)
setData(res.rows)
setTotal(res.total)
setLoading(false)
} catch (error: any) {
2025-04-14 16:14:27 +08:00
// setLoading(false)
2025-04-11 16:20:46 +08:00
if (error.response) {
const data = error.response.data;
messageApi.open({
type: 'error',
content: data.msg ? data.msg : `${data.path}(${data.status})`,
});
} else {
console.error(error)
}
2025-04-14 16:14:27 +08:00
}finally {
setLoading(false)
2025-04-11 16:20:46 +08:00
}
}
2025-04-14 16:14:27 +08:00
const [goodsDetailData, setGoodsDetailData] = useState<any>({}) // 商品详情数据
const getGoodsDetail = async (goodsId: string) => {
try {
setLoading(true)
const res: any = await goodsDetail(goodsId)
// console.log(res);
setGoodsId(res.goodsId)
setGoodsDetailData(res)
setLoading(false)
} catch (error: any) {
// setLoading(false)
if (error.response) {
const data = error.response.data;
messageApi.open({
type: 'error',
content: data.msg ? data.msg : `${data.path}(${data.status})`,
});
}
}finally {
setLoading(false)
2025-04-11 16:20:46 +08:00
}
2025-04-14 16:14:27 +08:00
}
useEffect(() => {
// console.log('copyrightKeywords', copyrightKeywords);
// console.log('minPrice', minPrice);
// console.log('maxPrice', maxPrice);
// console.log('sort', sort);
// console.log('copyrightDate', copyrightDate);
// console.log('copyrightLanguage', copyrightLanguage);
// console.log('copyrightType', copyrightType);
// if (copyrightDate) {
// console.log('sellDate', dayjs(copyrightDate).year());
// }
2025-04-11 16:20:46 +08:00
setPage(1)
getBuyGoodsList(1)
}, [state])
2024-05-31 09:19:30 +08:00
2024-05-21 11:21:34 +08:00
return (
2025-04-14 16:14:27 +08:00
2024-06-12 17:01:55 +08:00
<div className='copyrightG-goods' style={{ height: `${height}px`, overflow: 'auto' }}>
2025-04-11 16:20:46 +08:00
{messageContext}
2024-05-31 09:19:30 +08:00
{/* {contextHolder} */}
<div className='copyrightG-goods-table'>
{/* 表格 */}
2025-04-11 16:20:46 +08:00
{/* {data.length == 0 ? (
2024-05-31 09:19:30 +08:00
<div className='nodata' style={{ height: `${height - 93}px` }}>
<Empty
description={
'暂无数据'
} />
2025-04-11 16:20:46 +08:00
</div>) : ( */}
{/* <div> */}
<Spin tip="正在加载..." size="small" spinning={loading}>
<div style={{ height: `${height - 80}px` }}>
<Table
scroll={{ y: `${height - 150}px` }}
dataSource={data}
pagination={false} // 不显示分页
style={{ textAlign: 'center' }} // 设置表格内容居中显示
rowKey="goodsId" // 指定数据项的唯一标识符
locale={{ emptyText: '暂无数据' }}
>
<Column
width={70}
title="序号" render={(_text, _record, index: number) => (
index + 1
)} align="center" />
<Column
title="软著名称"
dataIndex="goodsName"
align="center"
render={(text) => (
<span style={{ color: '#1B8BD2', fontSize: '16px', fontWeight: '700' }}>{text}</span>
)}
/>
{/* <Column
title="软著简称"
dataIndex="short"
align="center"
/> */}
<Column
title="软著证号"
dataIndex="goodsNumber"
align="center"
// ellipsis
/>
<Column title="售价" dataIndex="goodsOpenPrice" align="center"
render={(text) => (
<span style={{ color: '#FF5D15', fontSize: '24px', fontWeight: '700' }}>{text}</span>
)} />
<Column title="软著版本" dataIndex="goodsVersion" align="center" />
<Column title="软著取得时间" dataIndex="goodsGetTime" align="center" />
<Column title="软著开发语言" dataIndex="goodsDevelop" align="center" />
{/* <Column title="实名认证状态" dataIndex="address" key="key" /> */}
<Column
align="center"
title="操作"
render={(_text, record: any) => (
<Space size="middle">
<span className='copyrightG-goods-table-btn' onClick={() => {
2025-04-14 16:14:27 +08:00
// console.log(record);
2025-04-11 16:20:46 +08:00
setGoodsDetailModal(true)
2025-04-14 16:14:27 +08:00
getGoodsDetail(record.goodsId)
2025-04-11 16:20:46 +08:00
}}></span>
</Space>
)}
/>
</Table>
</div>
</Spin>
{/* defaultCurrent: 默认当前页数 total:数据总数 defaultPageSize:'页面显示几条' */}
<div className='product-release-pagination' >
<Pagination
showSizeChanger={false}
current={page} total={total} defaultPageSize={10} onChange={(page) => {
console.log(page)
setPage(page)
}} />
</div>
</div>
{/* )} */}
<Modal
title="著作权商品信息"
okText="确认"
cancelText="取消"
destroyOnClose={true}
footer={null}
open={goodsDetailModal}
// onOk={() => {
// setOrderDetailModal(false)
// }}
onCancel={() => {
setGoodsDetailModal(false)
}}
2025-04-14 16:14:27 +08:00
width={1200}
2025-04-11 16:20:46 +08:00
centered
>
2025-04-14 16:14:27 +08:00
<Spin tip="正在加载..." size="small" spinning={loading}>
<div className='goodsDetail'>
<div className='goodsDetailImg' style={{
position: 'relative',
}}>
<Image src={showImage(goodsDetailData.goodsPhoto, false)} preview={{
mask: '查看', // 设置点击放大时显示的文字
}}
height={'100%'}
style={{ maxWidth: '100%' }}
></Image>
<div style={{
position: 'absolute',
bottom: '3px',
left: '265px',
color: 'rgb(160, 160, 160)',
// backgroundColor: 'rgba(0, 0, 0, 0.5)', // 半透明背景色
}}></div>
</div>
<div className='goodsDetailInputBox'>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsName} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsSubName} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox detailBoxRight'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsNumber} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsVersion} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox'>
<div className='detailBoxTitle detailBoxRight'></div>
<Input value={goodsDetailData.goodsGetTime} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsDevelop} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox'>
<div className='detailBoxTitle detailBoxRight'></div>
<Input value={goodsDetailData.goodsGetType} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsOpenPrice} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox'>
<div className='detailBoxTitle detailBoxRight'></div>
<Input value={goodsDetailData.goodsStatusTime} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div className='detailBoxText'>
<div className='detailBoxTitle'></div>
<TextArea
disabled
style={{
width: '100%',
// width: 1100,
height: 150,
fontSize: 16,
color: "#5C5C5C",
resize: 'none',
background: '#F5F5F9'
}} value={goodsDetailData.goodsDescription}></TextArea>
</div>
</div>
2024-06-11 17:45:40 +08:00
</div>
2025-04-14 16:14:27 +08:00
<div style={{
display: 'flex',
justifyContent: 'center',
marginTop: 20
}}>
<Button style={{
marginRight: 20,
fontSize: 16,
color: '#7C7C7C ',
background: '#E9E9E9',
fontWeight: '700',
height: 40,
width: 100,
2025-04-11 16:20:46 +08:00
2025-04-14 16:14:27 +08:00
}}
onClick={() => {
setGoodsDetailModal(false)
}}
></Button>
<Button style={{
fontSize: 16,
// color: '#FFFFFF',
// background: '#FFA800',
fontWeight: '700',
height: 40,
width: 100,
}}
type="primary"
onClick={() => {
setBuyTipsModal(true)
}}
></Button>
2025-04-11 16:20:46 +08:00
</div>
2025-04-14 16:14:27 +08:00
</Spin>
2025-04-11 16:20:46 +08:00
</Modal>
2024-05-31 09:19:30 +08:00
2025-04-14 16:14:27 +08:00
<Modal
title="提示"
okText="确认"
cancelText="取消"
destroyOnClose={true}
open={buyTipsModal}
onCancel={() => {
setBuyTipsModal(false)
}}
onOk={() => {
// alert(goodsId)
createOrderFun(goodsId)
}}
// width={1200}
centered
>
</Modal>
2024-05-31 09:19:30 +08:00
2024-05-21 11:21:34 +08:00
</div>
)
}