修改创客删除与恢复

This commit is contained in:
何童崇 2021-11-25 15:59:04 +08:00
parent c9e7da7df3
commit 1bad39e83a
5 changed files with 93 additions and 43 deletions

View File

@ -120,10 +120,17 @@ export async function getTaskDetail(id) {
if (res.data) { if (res.data) {
return res.data; return res.data;
} else { } else {
notification.open({ if(res.message&&res.message.indexOf('exist')>-1){
message: "提示", notification.open({
description: res.message || '请求错误', message: "提示",
}); description: "未查到该任务",
});
}else{
notification.open({
message: "提示",
description: res.message || '请求错误',
});
}
} }
} }
@ -146,9 +153,9 @@ export function updateTask(data) {
} }
//删除 //删除
export function deleteTask(id) { export function deleteTask(id, isDelete) {
return fetch({ return fetch({
url: '/api/tasks/' + id, url: '/api/tasks/' + id + '?isDelete=' + isDelete,
method: 'DELETE', method: 'DELETE',
}); });
} }
@ -499,7 +506,7 @@ export async function uploadPayProofList(params) {
} }
// 管理员上传支付凭证 // 管理员上传支付凭证
export function uploadPayProof(data){ export function uploadPayProof(data) {
return fetch({ return fetch({
url: `/api/sign/admin/paper/payment/${data.paperId}`, url: `/api/sign/admin/paper/payment/${data.paperId}`,
method: 'post', method: 'post',
@ -557,7 +564,7 @@ export function delayTask(data) {
return fetch({ return fetch({
url: `/api/tasks/backend/admin/task/delay/${data.taskId}`, url: `/api/tasks/backend/admin/task/delay/${data.taskId}`,
method: 'post', method: 'post',
data:data.params, data: data.params,
}); });
} }

View File

@ -30,7 +30,7 @@ export default props => {
<Menu.Item><a href="/task/payProof">支付报酬凭证上传</a></Menu.Item> <Menu.Item><a href="/task/payProof">支付报酬凭证上传</a></Menu.Item>
</SubMenu> </SubMenu>
<Menu.Item><a href="/task/taskAdmin">创客列表</a></Menu.Item> <Menu.Item><a href="/task/taskAdmin">任务列表</a></Menu.Item>
<Menu.Item><a href="/task/paperManage">创意征集评论</a></Menu.Item> <Menu.Item><a href="/task/paperManage">创意征集评论</a></Menu.Item>
</Menu> </Menu>
}); });

View File

@ -1,10 +1,10 @@
import React, { useCallback, useEffect, useState, useMemo } from 'react'; import React, { useCallback, useEffect, useState, useMemo } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { Input, Select, Button, Form, DatePicker, Table, Pagination, } from 'antd'; import { Input, Select, Button, Form, DatePicker, Table, Pagination, Modal } from 'antd';
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { paperCheckStatusArr, publishModeArr, taskStatusAllArr, showUserModeArr ,main_web_site_url} from '../static'; import { paperCheckStatusArr, publishModeArr, taskStatusAllArr, showUserModeArr, main_web_site_url } from '../static';
import { getTaskAdminList, changeShowUserMode,deleteTask } from '../api'; import { getTaskAdminList, changeShowUserMode, deleteTask } from '../api';
import '../index.scss'; import '../index.scss';
import './index.scss'; import './index.scss';
const format = "YYYY-MM-DD HH:mm:ss"; const format = "YYYY-MM-DD HH:mm:ss";
@ -23,11 +23,12 @@ for (const item of paperCheckStatusArr) {
export default Form.create()(({ form, showNotification, match, history }) => { export default Form.create()(({ form, showNotification, match, history }) => {
const { getFieldDecorator, setFieldsValue, getFieldsValue } = form; const { getFieldDecorator, setFieldsValue, getFieldsValue } = form;
const [reload,setReload]=useState(); const [reload, setReload] = useState();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [statusString, setStatusString] = useState(''); const [statusString, setStatusString] = useState('');
const [publishMode, setPublishMode] = useState(''); const [publishMode, setPublishMode] = useState('');
const [showUserMode, setShowUserMode] = useState(''); const [showUserMode, setShowUserMode] = useState('');
const [isDelete, setIsDelete] = useState('0');
const [sort, setSort] = useState('Desc'); const [sort, setSort] = useState('Desc');
const [order, setOrder] = useState('createdAt'); const [order, setOrder] = useState('createdAt');
@ -46,6 +47,7 @@ export default Form.create()(({ form, showNotification, match, history }) => {
curPage, curPage,
pageSize: 10, pageSize: 10,
orderBy: order + sort, orderBy: order + sort,
isDelete,
}; };
setLoading(true); setLoading(true);
getTaskAdminList(params).then(data => { getTaskAdminList(params).then(data => {
@ -55,7 +57,7 @@ export default Form.create()(({ form, showNotification, match, history }) => {
} }
setLoading(false); setLoading(false);
}) })
}, [statusString, order, sort, publishMode, showUserMode, curPage, searchObj,reload]); }, [statusString, order, sort, publishMode, showUserMode, curPage, searchObj, isDelete, reload]);
const helper = useCallback( const helper = useCallback(
@ -102,7 +104,7 @@ export default Form.create()(({ form, showNotification, match, history }) => {
dataIndex: 'name', dataIndex: 'name',
width: "15%", width: "15%",
render: (text, record) => ( render: (text, record) => (
<Link className="line_1 primary-link" to={`/task/taskDetail/${record.id}`}>{text}</Link> <Link className="line_1 primary-link" target="_blank" to={`/task/taskDetail/${record.id}`} >{text}</Link>
), ),
}, },
{ {
@ -201,21 +203,34 @@ export default Form.create()(({ form, showNotification, match, history }) => {
key: 'action', key: 'action',
render: (text, record) => ( render: (text, record) => (
<React.Fragment> <React.Fragment>
<Button className="mr5 font-12" type="danger" size="small" onClick={() => { deletItem(record.id) }}>删除</Button>
{
isDelete == '0' ? <Button className="mr5 font-12" type="danger" size="small" onClick={() => { deletItem(record.id, '1') }}>隐藏</Button>
: <Button className="mr5 font-12" type="primary" size="small" onClick={() => { deletItem(record.id, '0') }}>恢复</Button>
}
{/* <Link className="line_1 color-grey3" to={`/task/taskDetail/${record.taskId}`}>查看</Link> */} {/* <Link className="line_1 color-grey3" to={`/task/taskDetail/${record.taskId}`}>查看</Link> */}
</React.Fragment> </React.Fragment>
), ),
}, },
] ]
}, []); }, [isDelete]);
function deletItem(id){ function deletItem(id, isDelete) {
deleteTask(id).then(res=>{ Modal.confirm({
if(res.message==='success'){ title: "警告",
showNotification('删除成功!'); content: isDelete == '0' ? "确认恢复该任务吗?恢复后用户可以重新看到该任务!" : "确认隐藏?隐藏后用户无法看到该任务!",
setReload(Math.random()); okText: '确定',
} cancelText: '取消',
onOk() {
deleteTask(id, isDelete).then(res => {
if (res.message === 'success') {
showNotification('操作成功!');
setReload(Math.random());
}
});
},
}); });
} }
@ -243,13 +258,18 @@ export default Form.create()(({ form, showNotification, match, history }) => {
setCurPage(1); setCurPage(1);
}, []); }, []);
const changeShow = useCallback((isDelete) => {
setIsDelete(isDelete);
setCurPage(1);
})
function downloadFile() { function downloadFile() {
window.open(main_web_site_url + '/admin/tasks.xlsx'); window.open(main_web_site_url + '/admin/tasks.xlsx');
} }
return ( return (
<div className="centerbox task-manage-all "> <div className="centerbox task-manage-all ">
<div className="search-screen" > <div className="search-screen" >
{helper( {helper(
"任务名称", "任务名称",
@ -301,25 +321,40 @@ export default Form.create()(({ form, showNotification, match, history }) => {
</div> </div>
</div> </div>
<Form.Item className="inline-form" label="排序"> <div className="select-box">
<Select <Form.Item className="inline-form" label="显示状态">
style={{ width: '200px' }} <Select
showArrow style={{ width: '200px' }}
onChange={changeSortName} showArrow
defaultValue='createdAt' onChange={changeShow}
> defaultValue='0'
<Option key={'createdAt'} >创建时间</Option> >
<Option key={'publishedAt'} >发布时间</Option> <Option key={'0'} >正常显示默认</Option>
</Select> <Option key={'1'} >已隐藏</Option>
</Select>
</Form.Item>
<span className={classNames({ "sort-active": sort === 'Desc', 'sort-icon': true, 'ml10': true })} onClick={() => { changeSort('Desc') }}> <Form.Item className="inline-form" label="排序">
<i className="fa fa-long-arrow-down font-16 "></i> <Select
</span> style={{ width: '200px' }}
<span className={classNames({ "sort-active": sort === 'Asc', 'sort-icon': true })} onClick={() => { changeSort('Asc') }}> showArrow
<i className="fa fa-long-arrow-up font-16 "></i> onChange={changeSortName}
</span> defaultValue='createdAt'
>
<Option key={'createdAt'} >创建时间</Option>
<Option key={'publishedAt'} >发布时间</Option>
</Select>
<span className={classNames({ "sort-active": sort === 'Desc', 'sort-icon': true, 'ml10': true })} onClick={() => { changeSort('Desc') }}>
<i className="fa fa-long-arrow-down font-16 "></i>
</span>
<span className={classNames({ "sort-active": sort === 'Asc', 'sort-icon': true })} onClick={() => { changeSort('Asc') }}>
<i className="fa fa-long-arrow-up font-16 "></i>
</span>
</Form.Item>
</div>
</Form.Item>

View File

@ -48,6 +48,12 @@
a.primary-link { a.primary-link {
color: #1890ff; color: #1890ff;
} }
.select-box{
display: flex;
justify-content: space-between;
}
} }
.inline-form { .inline-form {

View File

@ -53,7 +53,6 @@ export default Form.create()(
const [visibleProofs, setVisibleProofs] = useState(false); const [visibleProofs, setVisibleProofs] = useState(false);
// //
useEffect(() => { useEffect(() => {
getTaskCategory().then(data => { getTaskCategory().then(data => {
@ -70,8 +69,11 @@ export default Form.create()(
// //
useEffect(() => { useEffect(() => {
id && getTaskDetail(id).then(data => { id && getTaskDetail(id).then(data => {
if(!data){
history.push('/task');
}
setDetailData(data || {}); setDetailData(data || {});
}) });
}, [id, reload]); }, [id, reload]);
// //