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

418 lines
13 KiB
TypeScript
Raw Normal View History

2024-05-28 18:00:42 +08:00
// import React from 'react'
import './product-release.css'
2024-06-04 16:02:06 +08:00
import {
Select, DatePicker, Button,
2024-05-31 09:19:30 +08:00
// message,
2024-06-12 17:01:55 +08:00
// Checkbox,
Empty, Switch, Modal, Pagination
2024-06-04 16:02:06 +08:00
} from 'antd';
2024-06-07 09:59:01 +08:00
import EditModal from './components/EditModal/EditModal'
2024-05-31 09:19:30 +08:00
// import type { CheckboxProps } from 'antd';
2024-06-07 09:59:01 +08:00
import { SearchOutlined, ClearOutlined } from '@ant-design/icons';
2024-05-28 18:00:42 +08:00
import type { DatePickerProps } from 'antd';
import locale from 'antd/es/date-picker/locale/zh_CN';
2024-06-12 17:01:55 +08:00
import React, { useState, useEffect } from 'react';
2024-06-04 16:02:06 +08:00
import dayjs, { } from 'dayjs';
2024-05-21 11:21:34 +08:00
export default function ProductRelease() {
2024-06-07 09:59:01 +08:00
const height = window.innerHeight - 180;
2024-05-31 09:19:30 +08:00
// const [messageApi, contextHolder] = message.useMessage();
2024-05-28 18:00:42 +08:00
const dateFormat = 'YYYY年MM月DD日';
2024-06-12 17:01:55 +08:00
const [belongType, setBelongType] = useState<any>() // 所属人类型
const [date, setDate] = useState<any>() // 日期
const [language, setLanguage] = useState<any>() // 开发者语言
const [type, setType] = useState<any>() //软著类型
2024-08-12 14:43:58 +08:00
const [page, setPage] = useState(1) // 分页
2024-06-12 17:01:55 +08:00
const [editModalOpen, setEditModalOpen] = useState(false) // 控制编辑弹窗
const [delModalOpen, setDelModalOpen] = useState(false) // 控制删除弹窗
const [sellModalOpen, setSellModalOpen] = useState(false) // 控制出售弹窗
2024-08-12 14:43:58 +08:00
2024-06-12 17:01:55 +08:00
// 更改所属人类型
2024-05-28 18:00:42 +08:00
const belongTypeChange = (value: string) => {
console.log(`selected ${value}`);
2024-06-04 16:02:06 +08:00
setBelongType(value)
2024-05-28 18:00:42 +08:00
}
2024-06-12 17:01:55 +08:00
// 更改日期
2024-05-28 18:00:42 +08:00
const onChange: DatePickerProps['onChange'] = (date, dateString) => {
console.log(date, dateString);
2024-06-04 16:02:06 +08:00
setDate(date)
// dayjs(formInfo.getFieldValue('projDevCompleteDate')).format(dateFormat),
console.log('日期', dayjs(date).format(dateFormat));
2024-05-28 18:00:42 +08:00
};
2024-06-11 17:45:40 +08:00
// 选择开发者语言
const selectLanguage = (value: string) => {
setLanguage(value)
}
// 选择软著类型
const selectType = (value: string) => {
setType(value)
}
2024-06-07 09:59:01 +08:00
// 初始化搜索条件
const init = () => {
setBelongType(undefined)
setDate(undefined)
2024-06-11 17:45:40 +08:00
setLanguage(undefined)
setType(undefined)
}
// 点击搜索
const searchKeyWords = () => {
2024-06-12 17:01:55 +08:00
setPage(1)
2024-06-11 17:45:40 +08:00
console.log(
2024-06-12 17:01:55 +08:00
// dayjs(date).format(dateFormat)
belongType, language, date, type
2024-06-11 17:45:40 +08:00
);
2024-06-12 17:01:55 +08:00
if (date) {
console.log(dayjs(date).format(dateFormat));
}
2024-06-07 09:59:01 +08:00
}
2024-08-12 14:43:58 +08:00
2024-06-07 09:59:01 +08:00
// 点击清除
const clearKeyWords = () => {
init()
2024-06-12 17:01:55 +08:00
setPage(1)
2024-06-07 09:59:01 +08:00
// 重新获取数据
}
2024-06-12 17:01:55 +08:00
2024-05-31 09:19:30 +08:00
// 选框选择时触发事件
2024-06-12 17:01:55 +08:00
// const checkChange = (e: any, item: any) => {
// console.log(`checked = ${e.target.checked}`);
// console.log(e);
// if (e.target.checked == true) {
// console.log(item.order);
// }
// };
2024-05-31 09:19:30 +08:00
// 开关滑动触发
const opneChange = (e: any, item: any) => {
// 开启
if (e) {
console.log('开启', item.order);
// 关闭
} else {
console.log('关闭', item.order);
}
}
2024-08-12 14:43:58 +08:00
2024-05-31 09:19:30 +08:00
// 点击编辑
const edit = (item: any) => {
console.log(item.order);
2024-06-07 09:59:01 +08:00
setEditModalOpen(true)
2024-05-31 09:19:30 +08:00
};
// 点击删除
const del = (item: any) => {
console.log(item.order);
2024-06-07 09:59:01 +08:00
setDelModalOpen(true)
2024-05-31 09:19:30 +08:00
};
// 点击出售
const sell = (item: any) => {
console.log(item.order);
2024-06-07 09:59:01 +08:00
setSellModalOpen(true)
2024-05-31 09:19:30 +08:00
};
// 点击提交
const submit = (item: any) => {
console.log(item.order);
};
const data: any = [
{
order: '122',
time1: '2020-04-19 11:51:03',
img: 'xxx',
name: 'xxxx系统',
v: '1-1-v',
price: '5.00',
time2: '2020-04-19 11:51:03',
open: '0',
status: '平台已审核',
},
{
order: '123',
time1: '2020-04-19 11:51:03',
img: 'xxx',
name: 'xxxx系统',
v: '1-1-v',
price: '5.00',
time2: '2020-04-19 11:51:03',
open: '1',
status: '平台已审核',
},
{
2024-06-11 17:45:40 +08:00
order: '124',
time1: '2020-04-19 11:51:03',
img: 'xxx',
name: 'xxxx系统',
v: '1-1-v',
price: '5.00',
time2: '2020-04-19 11:51:03',
open: '0',
status: '平台已审核',
},
{
order: '125',
time1: '2020-04-19 11:51:03',
img: 'xxx',
name: 'xxxx系统',
v: '1-1-v',
price: '5.00',
time2: '2020-04-19 11:51:03',
open: '0',
status: '平台已审核',
},
{
order: '126',
2024-05-31 09:19:30 +08:00
time1: '2020-04-19 11:51:03',
img: 'xxx',
name: 'xxxx系统',
v: '1-1-v',
price: '5.00',
time2: '2020-04-19 11:51:03',
open: '0',
status: '平台已审核',
},
2024-06-11 17:45:40 +08:00
2024-05-31 09:19:30 +08:00
];
2024-08-12 14:43:58 +08:00
useEffect(() => {
}, [])
2024-05-31 09:19:30 +08:00
2024-05-21 11:21:34 +08:00
return (
2024-06-12 17:01:55 +08:00
<div className='product-release' style={{ height: `${height}px`, overflow: 'auto' }}>
2024-05-31 09:19:30 +08:00
{/* {contextHolder} */}
2024-05-28 18:00:42 +08:00
<div className='product-release-search'>
<Select
// defaultValue="lucy"
placeholder='请选择所属者类型'
2024-05-31 09:19:30 +08:00
style={{ width: 198, height: 36, marginRight: 12 }}
2024-05-28 18:00:42 +08:00
onChange={belongTypeChange}
options={[
{ value: 'person', label: '个人' },
{ value: 'lucy', label: '企业' },
]}
2024-06-04 16:02:06 +08:00
value={belongType}
2024-05-28 18:00:42 +08:00
/>
<DatePicker placeholder="软件取得时间"
2024-05-31 09:19:30 +08:00
style={{ width: 198, height: 36, marginRight: 12 }}
2024-05-28 18:00:42 +08:00
locale={locale}
onChange={onChange}
2024-06-04 16:02:06 +08:00
value={date}
2024-05-28 18:00:42 +08:00
/>
2024-05-31 09:19:30 +08:00
<Select
// defaultValue="lucy"
placeholder='请选择所开发者语言'
style={{ width: 198, height: 36, marginRight: 12 }}
2024-06-11 17:45:40 +08:00
onChange={selectLanguage}
2024-05-31 09:19:30 +08:00
options={[
2024-06-11 17:45:40 +08:00
{ value: 'java', label: 'java' },
{ value: 'php', label: 'php' },
2024-05-31 09:19:30 +08:00
]}
2024-06-11 17:45:40 +08:00
value={language}
2024-05-31 09:19:30 +08:00
/>
<Select
// defaultValue="lucy"
placeholder='请选择软著类型'
style={{ width: 198, height: 36, marginRight: 12 }}
2024-06-11 17:45:40 +08:00
onChange={selectType}
2024-05-31 09:19:30 +08:00
options={[
{ value: 'person', label: '1' },
{ value: 'lucy', label: '2' },
]}
2024-06-11 17:45:40 +08:00
value={type}
2024-05-31 09:19:30 +08:00
/>
<Button type="primary"
2024-06-04 16:02:06 +08:00
style={{
height: 36,
// backgroundColor: '#FF9F08'
}}
2024-06-11 17:45:40 +08:00
onClick={searchKeyWords}
2024-05-31 09:19:30 +08:00
icon={<SearchOutlined />}>
</Button>
2024-06-07 09:59:01 +08:00
<Button
2024-06-04 16:02:06 +08:00
style={{
height: 36,
2024-06-07 09:59:01 +08:00
marginLeft: 10,
2024-06-04 16:02:06 +08:00
// backgroundColor: '#FF9F08'
}}
2024-06-07 09:59:01 +08:00
icon={<ClearOutlined />}
onClick={clearKeyWords}
2024-06-11 17:45:40 +08:00
>
2024-06-04 16:02:06 +08:00
</Button>
2024-05-31 09:19:30 +08:00
</div>
<div>
{/* 表格 */}
2024-06-11 17:45:40 +08:00
<div className='product-release-table' style={{ height: `${height - 130}px` }}>
2024-05-31 09:19:30 +08:00
{data.length == 0 ? (
<div className='nodata' style={{ height: `${height - 93}px` }}>
<Empty
description={
'暂无数据'
} />
</div>) : (
2024-06-11 17:45:40 +08:00
<div style={{ height: `${height - 130}px`, overflow: 'auto', position: 'relative' }}>
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
<thead >
<tr style={{ background: '#F7F7F7', height: 32, fontSize: 14 }}>
<th style={{ width: 50 }}></th>
<th style={{ width: 110 }}></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody style={{ color: '#888888' }}>
{data.map((item: any, index: any) => {
return (
<React.Fragment key={item.order}>
<tr style={{ height: 15 }}>
<td colSpan={9} style={{ border: 'none' }}>
2024-05-31 09:19:30 +08:00
2024-06-11 17:45:40 +08:00
</td>
</tr>
<tr style={{ background: '#F7F7F7', height: 45 }}>
<td colSpan={9}>
2024-06-12 17:01:55 +08:00
{/* <Checkbox style={{ marginLeft: 16 }} onChange={
2024-06-11 17:45:40 +08:00
(event) => checkChange(event, item)
2024-06-12 17:01:55 +08:00
}></Checkbox> */}
<span style={{ marginLeft: 55 }}>
2024-06-11 17:45:40 +08:00
: {item.order}
</span>
<span style={{ marginLeft: 45 }}>
: {item.time1}
</span>
</td>
</tr>
<tr style={{ textAlign: 'center', height: 110 }}>
<td>{index + 1}</td>
<td className='product-release-table-img-td'>
<div className='product-release-table-img'>
{item.img}
</div>
</td>
<td>
<div className='product-release-table-name'>
{item.name}
</div>
<div>
()
</div>
</td>
<td>{item.v}</td>
<td style={{ fontSize: 24, color: '#FF5D15' }}>{item.price}</td>
<td>{item.time2}</td>
<td>
<Switch checkedChildren="On" unCheckedChildren="Off" onChange={(e) => { opneChange(e, item) }} defaultChecked={item.open == 0 ? false : true} />
</td>
<td>{item.status}</td>
<td>
2024-06-12 17:01:55 +08:00
<span className='product-release-table-btn' onClick={() => {
edit(item)
}}></span>
2024-06-11 17:45:40 +08:00
<span className='product-release-table-btn product-btn' onClick={() => del(item)}></span>
<span className='product-release-table-btn product-btn' onClick={() => sell(item)}></span>
<span className='product-release-table-btn product-btn' onClick={() => submit(item)}></span>
</td>
</tr>
</React.Fragment>
2024-05-31 09:19:30 +08:00
2024-06-11 17:45:40 +08:00
)
})}
</tbody>
</table>
{/* <div style={{ height: 10 }}></div> */}
</div>
2024-05-31 09:19:30 +08:00
)}
</div>
2024-06-11 17:45:40 +08:00
{/* defaultCurrent: 默认当前页数 total:数据总数 defaultPageSize:'页面显示几条' */}
<div className='product-release-pagination'>
2024-08-12 14:43:58 +08:00
<Pagination
showSizeChanger={false}
defaultCurrent={page} total={20} defaultPageSize={10} onChange={(page) => {
// console.log(page)
setPage(page)
}} />
2024-06-11 17:45:40 +08:00
</div>
2024-05-28 18:00:42 +08:00
</div>
2024-06-07 09:59:01 +08:00
{/* 编辑弹窗 */}
<Modal title={'编辑'}
destroyOnClose={true}
open={editModalOpen}
footer={null} // 将 footer 设置为 null 来隐藏自带按钮
width={1152}
onCancel={() => {
setEditModalOpen(false);
}}
>
<div style={{ height: `${height - 20}px`, overflow: 'auto', borderTop: '1px solid #e8e8e8' }}>
2024-06-11 17:45:40 +08:00
<EditModal closeModal={() => { setEditModalOpen(false) }} ></EditModal>
2024-06-07 09:59:01 +08:00
</div>
</Modal>
{/* 删除弹窗 */}
<Modal title="删除"
okText="确认"
cancelText="取消"
destroyOnClose={true}
open={delModalOpen}
onOk={() => {
setDelModalOpen(false)
}}
onCancel={() => {
setDelModalOpen(false)
}}
okButtonProps={{ style: { background: 'red', color: 'white' } }}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: `${height}px`,
}}>
<div style={{
2024-06-11 17:45:40 +08:00
width: 700,
marginTop: 20
2024-06-07 09:59:01 +08:00
}}>
</div>
</Modal>
2024-06-11 17:45:40 +08:00
{/* 出售弹窗 */}
<Modal title="出售"
2024-06-07 09:59:01 +08:00
okText="确认"
cancelText="取消"
destroyOnClose={true}
open={sellModalOpen}
onOk={() => {
setSellModalOpen(false)
}}
onCancel={() => {
setSellModalOpen(false)
}}
okButtonProps={{ style: { background: '#28915A', color: 'white' } }}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: `${height}px`,
}}>
<div style={{
2024-06-11 17:45:40 +08:00
width: 700,
marginTop: 20
2024-06-07 09:59:01 +08:00
}}>
</div>
</Modal>
2024-05-21 11:21:34 +08:00
</div>
)
}
2024-05-28 18:00:42 +08:00