diff --git a/src/military/task/api.js b/src/military/task/api.js index 3d8052b2d..85645e2b8 100644 --- a/src/military/task/api.js +++ b/src/military/task/api.js @@ -120,10 +120,17 @@ export async function getTaskDetail(id) { if (res.data) { return res.data; } else { - notification.open({ - message: "提示", - description: res.message || '请求错误', - }); + if(res.message&&res.message.indexOf('exist')>-1){ + notification.open({ + 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({ - url: '/api/tasks/' + id, + url: '/api/tasks/' + id + '?isDelete=' + isDelete, method: 'DELETE', }); } @@ -499,7 +506,7 @@ export async function uploadPayProofList(params) { } // 管理员上传支付凭证 -export function uploadPayProof(data){ +export function uploadPayProof(data) { return fetch({ url: `/api/sign/admin/paper/payment/${data.paperId}`, method: 'post', @@ -557,7 +564,7 @@ export function delayTask(data) { return fetch({ url: `/api/tasks/backend/admin/task/delay/${data.taskId}`, method: 'post', - data:data.params, + data: data.params, }); } diff --git a/src/military/task/components/adminRouter/index.jsx b/src/military/task/components/adminRouter/index.jsx index e9003c5e5..4132b4c58 100644 --- a/src/military/task/components/adminRouter/index.jsx +++ b/src/military/task/components/adminRouter/index.jsx @@ -30,7 +30,7 @@ export default props => { 支付报酬凭证上传 - 创客列表 + 任务列表 创意征集评论 }); diff --git a/src/military/task/taskAdmin/index.jsx b/src/military/task/taskAdmin/index.jsx index c97e1defe..2ca99d8a7 100644 --- a/src/military/task/taskAdmin/index.jsx +++ b/src/military/task/taskAdmin/index.jsx @@ -1,10 +1,10 @@ import React, { useCallback, useEffect, useState, useMemo } from 'react'; 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 { paperCheckStatusArr, publishModeArr, taskStatusAllArr, showUserModeArr ,main_web_site_url} from '../static'; -import { getTaskAdminList, changeShowUserMode,deleteTask } from '../api'; +import { paperCheckStatusArr, publishModeArr, taskStatusAllArr, showUserModeArr, main_web_site_url } from '../static'; +import { getTaskAdminList, changeShowUserMode, deleteTask } from '../api'; import '../index.scss'; import './index.scss'; 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 }) => { const { getFieldDecorator, setFieldsValue, getFieldsValue } = form; - const [reload,setReload]=useState(); + const [reload, setReload] = useState(); const [loading, setLoading] = useState(false); const [statusString, setStatusString] = useState(''); const [publishMode, setPublishMode] = useState(''); const [showUserMode, setShowUserMode] = useState(''); + const [isDelete, setIsDelete] = useState('0'); const [sort, setSort] = useState('Desc'); const [order, setOrder] = useState('createdAt'); @@ -46,6 +47,7 @@ export default Form.create()(({ form, showNotification, match, history }) => { curPage, pageSize: 10, orderBy: order + sort, + isDelete, }; setLoading(true); getTaskAdminList(params).then(data => { @@ -55,7 +57,7 @@ export default Form.create()(({ form, showNotification, match, history }) => { } setLoading(false); }) - }, [statusString, order, sort, publishMode, showUserMode, curPage, searchObj,reload]); + }, [statusString, order, sort, publishMode, showUserMode, curPage, searchObj, isDelete, reload]); const helper = useCallback( @@ -102,7 +104,7 @@ export default Form.create()(({ form, showNotification, match, history }) => { dataIndex: 'name', width: "15%", render: (text, record) => ( - {text} + {text} ), }, { @@ -201,21 +203,34 @@ export default Form.create()(({ form, showNotification, match, history }) => { key: 'action', render: (text, record) => ( - + + { + isDelete == '0' ? + : + } + {/* 查看 */} ), }, ] - }, []); + }, [isDelete]); - function deletItem(id){ - deleteTask(id).then(res=>{ - if(res.message==='success'){ - showNotification('删除成功!'); - setReload(Math.random()); - } + function deletItem(id, isDelete) { + Modal.confirm({ + title: "警告", + content: isDelete == '0' ? "确认恢复该任务吗?恢复后用户可以重新看到该任务!" : "确认隐藏?隐藏后用户无法看到该任务!", + 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); }, []); + const changeShow = useCallback((isDelete) => { + setIsDelete(isDelete); + setCurPage(1); + }) + function downloadFile() { window.open(main_web_site_url + '/admin/tasks.xlsx'); } return (
- +
{helper( "任务名称", @@ -301,25 +321,40 @@ export default Form.create()(({ form, showNotification, match, history }) => {
- - +
+ + + - { changeSort('Desc') }}> - - - { changeSort('Asc') }}> - - + + + + { changeSort('Desc') }}> + + + { changeSort('Asc') }}> + + + + +
-
diff --git a/src/military/task/taskAdmin/index.scss b/src/military/task/taskAdmin/index.scss index 1b7a76a5f..087e99ccc 100644 --- a/src/military/task/taskAdmin/index.scss +++ b/src/military/task/taskAdmin/index.scss @@ -48,6 +48,12 @@ a.primary-link { color: #1890ff; } + + .select-box{ + display: flex; + justify-content: space-between; + } + } .inline-form { diff --git a/src/military/task/taskDetail/index.jsx b/src/military/task/taskDetail/index.jsx index c67a4e961..786f78570 100644 --- a/src/military/task/taskDetail/index.jsx +++ b/src/military/task/taskDetail/index.jsx @@ -53,7 +53,6 @@ export default Form.create()( const [visibleProofs, setVisibleProofs] = useState(false); - // 获取任务领域配置数据 useEffect(() => { getTaskCategory().then(data => { @@ -70,8 +69,11 @@ export default Form.create()( // 获取本任务详情 useEffect(() => { id && getTaskDetail(id).then(data => { + if(!data){ + history.push('/task'); + } setDetailData(data || {}); - }) + }); }, [id, reload]); // 检查用户是否同意协议