From 7f0b770dca099d025d8daf4917648614fd6c3770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Thu, 25 Nov 2021 11:26:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=AE=A2?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E5=88=9B=E5=AE=A2=E8=B0=83=E7=94=A8?= =?UTF-8?q?Java=E5=8F=91=E9=80=81=E8=AF=B7=E6=B1=82=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppConfig.js | 4 +- src/military/components/Upload.jsx | 2 +- src/military/components/config.js | 2 +- src/military/{fetch.js => javaFetch.js} | 41 +++--- src/military/notice/fetch.js | 118 ++---------------- src/military/task/api.js | 3 +- .../task/components/adminRouter/index.jsx | 3 +- .../task/components/itemTaskManage/index.jsx | 5 + src/military/task/fetch.js | 10 ++ src/military/task/taskAdmin/index.jsx | 37 ++++-- src/military/task/taskAdmin/index.scss | 4 + src/military/task/taskAdminRouter.js | 2 +- src/military/task/taskManage/index.js | 9 +- 13 files changed, 83 insertions(+), 157 deletions(-) rename src/military/{fetch.js => javaFetch.js} (78%) create mode 100644 src/military/task/fetch.js diff --git a/src/AppConfig.js b/src/AppConfig.js index 1b78e7a9..55873f00 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -56,8 +56,8 @@ export function initAxiosInterceptors(props) { // TODO 避免重复的请求 https://github.com/axios/axios#cancellation var proxy = "http://localhost:3000"; - proxy = "https://forge.osredm.com"; - // proxy = "http://117.50.100.12:49999"; + // proxy = "https://forge.osredm.com"; + proxy = "http://117.50.100.12:49999"; const requestMap = {}; window.setfalseInRequestMap = function (keyName) { diff --git a/src/military/components/Upload.jsx b/src/military/components/Upload.jsx index 71a94c32..e1ab4cd0 100644 --- a/src/military/components/Upload.jsx +++ b/src/military/components/Upload.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import { Upload, Button } from 'antd'; import { appendFileSizeToUploadFileAll } from 'educoder'; -import { httpUrl } from '../fetch'; +import { httpUrl } from '../task/fetch'; function Uploads({ className, size, actionUrl, fileList, showNotification, load }) { const [files, setFiles] = useState(undefined); diff --git a/src/military/components/config.js b/src/military/components/config.js index 996a2528..320dd15f 100644 --- a/src/military/components/config.js +++ b/src/military/components/config.js @@ -1,4 +1,4 @@ -import { httpUrl } from '../fetch'; +import { httpUrl } from '../task/fetch'; export const editorConfig = { placeholder: '请输入', diff --git a/src/military/fetch.js b/src/military/javaFetch.js similarity index 78% rename from src/military/fetch.js rename to src/military/javaFetch.js index bbf41f03..829a50d4 100644 --- a/src/military/fetch.js +++ b/src/military/javaFetch.js @@ -1,24 +1,20 @@ -import { notification,message } from 'antd'; +import { notification} from 'antd'; import axios from 'axios'; import cookie from 'react-cookies'; - -let settings=JSON.parse(localStorage.chromesetting); -let actionUrl = settings.api_urls? settings.api_urls.task :'https://task.osredm.com'; -if (window.location.href.indexOf('localhost') < 0) { - axios.defaults.withCredentials = true; -} -export const httpUrl = actionUrl; - -const TokenKey = 'autologin_forge_military'; - -// 创建axios实例 -const service = axios.create({ - baseURL: httpUrl, - timeout: 10000, // 请求超时时间 -}); - -// request拦截器 +export const TokenKey = 'autologin_forge_military'; +export default function javaFetch(actionUrl){ + if (window.location.href.indexOf('localhost') < 0) { + axios.defaults.withCredentials = true; + } + + // 创建axios实例 + const service = axios.create({ + baseURL: actionUrl, + timeout: 1800000, // 请求超时时间 + }); + + // request拦截器 service.interceptors.request.use(config => { if (cookie.load(TokenKey)) { console.log(cookie.load(TokenKey)); @@ -26,11 +22,11 @@ service.interceptors.request.use(config => { } if (window.location.port === "3007") { // 模拟token为登录用户 - const taskToken = sessionStorage.taskToken; + const osredmToken = sessionStorage.osredmToken; if (config.url.indexOf('?') === -1) { - config.url = `${config.url}?token=${taskToken}`; + config.url = `${config.url}?token=${osredmToken}`; } else { - config.url = `${config.url}&token=${taskToken}`; + config.url = `${config.url}&token=${osredmToken}`; } } return config; @@ -110,4 +106,5 @@ service.interceptors.response.use( } ); -export default service; + return service; +} \ No newline at end of file diff --git a/src/military/notice/fetch.js b/src/military/notice/fetch.js index 07e20261..38f2a078 100644 --- a/src/military/notice/fetch.js +++ b/src/military/notice/fetch.js @@ -1,114 +1,10 @@ -import { notification } from 'antd'; -import axios from 'axios'; -import cookie from 'react-cookies'; + +import javaFetch from '../javaFetch'; -let settings = JSON.parse(localStorage.chromesetting); -let actionUrl = settings.api_urls ? settings.api_urls.notice : 'https://info.osredm.com'; -if (window.location.href.indexOf('localhost')< 0) { - axios.defaults.withCredentials = true; -} +let settings=JSON.parse(localStorage.chromesetting); +let actionUrl = settings.api_urls? settings.api_urls.notice :'https://info.osredm.com'; + +const service = javaFetch(actionUrl); export const httpUrl = actionUrl; - -const TokenKey = 'autologin_forge_military'; - - -// 创建axios实例 -const service = axios.create({ - baseURL: httpUrl, - timeout: 10000, // 请求超时时间 -}); - -// request拦截器 -service.interceptors.request.use(config => { - if (cookie.load(TokenKey)) { - console.log(cookie.load(TokenKey)); - config.headers['Authorization'] = cookie.load(TokenKey); // 让每个请求携带自定义token 请根据实际情况自行修改 - } - if (window.location.port === "3007") { - // 模拟token为登录用户 - const taskToken = sessionStorage.taskToken; - if (config.url.indexOf('?') === -1) { - config.url = `${config.url}?token=${taskToken}`; - } else { - config.url = `${config.url}&token=${taskToken}`; - } - } - return config; -}, error => { - // Do something with request error - console.log(error); // for debug - Promise.reject(error); -}); -// respone拦截器 -service.interceptors.response.use( - response => { - const res = response; - if (res.status === 400) { - notification.open({ - message: "提示", - description: res.data.message || '验证失败', - }); - return Promise.reject('error'); - } - if (res.status === 401) { - notification.open({ - message: "提示", - description: res.data.message || '未授权,请登录!', - }); - return Promise.reject('error'); - } - if (res.status === 403) { - notification.open({ - message: "提示", - description: res.data.message || '无权限', - }); - return Promise.reject('error'); - } - if (res.status === 40001) { - notification.open({ - message: "提示", - description: '账户或密码错误!', - }); - return Promise.reject('error'); - } - if (response.status !== 200 && res.status !== 200) { - notification.open({ - message: "提示", - description: res.message, - }); - } else { - return response.data; - } - }, - error => { - console.log(error); - let res = error.response || {}; - if (res.status === 400) { - notification.open({ - message: "提示", - description: res.data.message || '操作失败', - }); - return Promise.reject('error'); - } - if (res.status === 401) { - notification.open({ - message: "提示", - description: res.data.message || '登录信息已过期', - }); - return Promise.reject('error'); - } - if (res.status === 403) { - notification.open({ - message: "提示", - description: res.data.message || '无权限!', - }); - window.location.href = "/403"; - return Promise.reject('error'); - } - - return Promise.reject(error); - } -); - -export default service; +export default service; \ No newline at end of file diff --git a/src/military/task/api.js b/src/military/task/api.js index 06fe7318..3d8052b2 100644 --- a/src/military/task/api.js +++ b/src/military/task/api.js @@ -1,6 +1,5 @@ -import fetch, { } from '../fetch'; +import fetch, { } from './fetch'; import { notification } from 'antd'; -import { func } from 'prop-types'; // 获取字典分类列表 export function getDictionary(id) { diff --git a/src/military/task/components/adminRouter/index.jsx b/src/military/task/components/adminRouter/index.jsx index 89761ea5..e9003c5e 100644 --- a/src/military/task/components/adminRouter/index.jsx +++ b/src/military/task/components/adminRouter/index.jsx @@ -66,7 +66,8 @@ export default props => { return 企业认证 开源项目 - 统筹任务发布审批 + 统筹任务发布审批 + 自主任务发布审批 成果上传申诉审批 公示期成果申诉审批 协议审批 diff --git a/src/military/task/components/itemTaskManage/index.jsx b/src/military/task/components/itemTaskManage/index.jsx index 5cbad31a..0323e876 100644 --- a/src/military/task/components/itemTaskManage/index.jsx +++ b/src/military/task/components/itemTaskManage/index.jsx @@ -155,6 +155,10 @@ export default (props) => {
+ 发布方式: + {item.publishMode == 1 ? '统筹任务' : '自主提交'} + + 所在行业: {categoryArr[item.categoryId]} @@ -163,6 +167,7 @@ export default (props) => { 企业规模: {scale(item.enterpriseSimple.scale)} } + {/* 所在职位: 普通员工 diff --git a/src/military/task/fetch.js b/src/military/task/fetch.js new file mode 100644 index 00000000..9140d89e --- /dev/null +++ b/src/military/task/fetch.js @@ -0,0 +1,10 @@ + +import javaFetch from '../javaFetch'; + + +let settings=JSON.parse(localStorage.chromesetting); +let actionUrl = settings.api_urls? settings.api_urls.task :'https://task.osredm.com'; + +const service = javaFetch(actionUrl); +export const httpUrl = actionUrl; +export default service; \ No newline at end of file diff --git a/src/military/task/taskAdmin/index.jsx b/src/military/task/taskAdmin/index.jsx index 35e5ef13..c97e1def 100644 --- a/src/military/task/taskAdmin/index.jsx +++ b/src/military/task/taskAdmin/index.jsx @@ -4,7 +4,7 @@ import { Input, Select, Button, Form, DatePicker, Table, Pagination, } from 'ant import { Link } from "react-router-dom"; import { paperCheckStatusArr, publishModeArr, taskStatusAllArr, showUserModeArr ,main_web_site_url} from '../static'; -import { getTaskAdminList, changeShowUserMode } from '../api'; +import { getTaskAdminList, changeShowUserMode,deleteTask } from '../api'; import '../index.scss'; import './index.scss'; const format = "YYYY-MM-DD HH:mm:ss"; @@ -23,6 +23,7 @@ for (const item of paperCheckStatusArr) { export default Form.create()(({ form, showNotification, match, history }) => { const { getFieldDecorator, setFieldsValue, getFieldsValue } = form; + const [reload,setReload]=useState(); const [loading, setLoading] = useState(false); const [statusString, setStatusString] = useState(''); const [publishMode, setPublishMode] = useState(''); @@ -54,7 +55,7 @@ export default Form.create()(({ form, showNotification, match, history }) => { } setLoading(false); }) - }, [statusString, order, sort, publishMode, showUserMode, curPage, searchObj]); + }, [statusString, order, sort, publishMode, showUserMode, curPage, searchObj,reload]); const helper = useCallback( @@ -101,7 +102,7 @@ export default Form.create()(({ form, showNotification, match, history }) => { dataIndex: 'name', width: "15%", render: (text, record) => ( - {text} + {text} ), }, { @@ -195,19 +196,29 @@ export default Form.create()(({ form, showNotification, match, history }) => { } }, - // { - // title: '操作', - // key: 'action', - // render: (text, record) => ( - // - // {/* */} - // 查看 - // - // ), - // }, + { + title: '操作', + key: 'action', + render: (text, record) => ( + + + {/* 查看 */} + + ), + }, ] }, []); + + function deletItem(id){ + deleteTask(id).then(res=>{ + if(res.message==='success'){ + showNotification('删除成功!'); + setReload(Math.random()); + } + }); + } + function changeStatus(showUserMode, taskId) { changeShowUserMode({ taskId, diff --git a/src/military/task/taskAdmin/index.scss b/src/military/task/taskAdmin/index.scss index d1b2b4f8..1b7a76a5 100644 --- a/src/military/task/taskAdmin/index.scss +++ b/src/military/task/taskAdmin/index.scss @@ -44,6 +44,10 @@ padding: 1rem 0.2rem; text-align: center; } + + a.primary-link { + color: #1890ff; + } } .inline-form { diff --git a/src/military/task/taskAdminRouter.js b/src/military/task/taskAdminRouter.js index 5bd7498a..6c790a6b 100644 --- a/src/military/task/taskAdminRouter.js +++ b/src/military/task/taskAdminRouter.js @@ -59,7 +59,7 @@ const AdminPage = (propsF) => { {/* 任务管理审核 */} ( )} diff --git a/src/military/task/taskManage/index.js b/src/military/task/taskManage/index.js index 3213b03b..60bcacea 100644 --- a/src/military/task/taskManage/index.js +++ b/src/military/task/taskManage/index.js @@ -1,4 +1,4 @@ -import React, { useCallback, forwardRef, useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { Input, Button, Form } from 'antd'; import ItemTaskManage from '../components/itemTaskManage'; import StatusNav from '../../components/statusNav'; @@ -6,7 +6,9 @@ import { approveArr, main_web_site_url } from '../static'; import { getTaskAdminList, getTaskCategory } from '../api'; import '../index.scss'; -export default Form.create()(({ current_user, form, showNotification, match, history }) => { +export default Form.create()(({ form, showNotification, match, history }) => { + const publishMode = match.params.publishMode; + const { getFieldDecorator, validateFields, setFieldsValue, getFieldsValue } = form; const [categoryArr, setCategoryArr] = useState([]); @@ -20,6 +22,7 @@ export default Form.create()(({ current_user, form, showNotification, match, his const [reload, setReload] = useState(0); + useEffect(() => { getTaskCategory().then(data => { if (data) { @@ -39,7 +42,7 @@ export default Form.create()(({ current_user, form, showNotification, match, his orderBy: 'createdAtDesc', curPage, pageSize: 10, - publishMode: 1 + publishMode: publishMode || 1 }; setLoading(true); getTaskAdminList(params).then(data => { From c9e7da7df3cef2884c00678a8efa4fe763d41bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Thu, 25 Nov 2021 11:40:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppConfig.js | 4 ++-- src/military/task/components/itemAgreementManage/index.jsx | 2 +- src/military/task/components/itemListMyTask/index.jsx | 2 +- src/military/task/components/itemListPaper/index.jsx | 2 +- src/military/task/components/itemProofManage/index.jsx | 2 +- src/military/task/components/itemPublicityComplain/index.jsx | 2 +- src/military/task/components/proofModal/index.jsx | 2 +- src/military/task/paperComplain/index.js | 2 +- src/military/task/taskDetail/index.jsx | 2 +- src/military/task/taskEdit/index.jsx | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/AppConfig.js b/src/AppConfig.js index 55873f00..1b78e7a9 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -56,8 +56,8 @@ export function initAxiosInterceptors(props) { // TODO 避免重复的请求 https://github.com/axios/axios#cancellation var proxy = "http://localhost:3000"; - // proxy = "https://forge.osredm.com"; - proxy = "http://117.50.100.12:49999"; + proxy = "https://forge.osredm.com"; + // proxy = "http://117.50.100.12:49999"; const requestMap = {}; window.setfalseInRequestMap = function (keyName) { diff --git a/src/military/task/components/itemAgreementManage/index.jsx b/src/military/task/components/itemAgreementManage/index.jsx index 787948c1..a6497f21 100644 --- a/src/military/task/components/itemAgreementManage/index.jsx +++ b/src/military/task/components/itemAgreementManage/index.jsx @@ -5,7 +5,7 @@ import Nodata from 'forge/Nodata'; import Loading from "src/Loading"; import { timeAgo, getImageUrl } from 'educoder'; import { adminCheckAgreement } from '../../api'; -import { httpUrl } from 'military/fetch'; +import { httpUrl } from '../../fetch'; import './index.scss'; const { TextArea } = Input; diff --git a/src/military/task/components/itemListMyTask/index.jsx b/src/military/task/components/itemListMyTask/index.jsx index ea70bfa2..33fa35e7 100644 --- a/src/military/task/components/itemListMyTask/index.jsx +++ b/src/military/task/components/itemListMyTask/index.jsx @@ -7,7 +7,7 @@ import Upload from 'military/components/Upload'; import ProofModal from '../proofModal'; import { publishModeArr, taskStatusAllArr, myPaperStatusArr } from '../../static'; import { signMethod, uploadAgreeRequire, downAgreement } from "../../api"; -import { httpUrl } from 'military/fetch'; +import { httpUrl } from '../../fetch'; import '../../index.scss'; import './index.scss'; diff --git a/src/military/task/components/itemListPaper/index.jsx b/src/military/task/components/itemListPaper/index.jsx index 1e7dd06e..70c1f949 100644 --- a/src/military/task/components/itemListPaper/index.jsx +++ b/src/military/task/components/itemListPaper/index.jsx @@ -9,7 +9,7 @@ import AgreementModal from '../agreementModal'; import ComplainModal from '../complainModal'; import { reportPaper, thumbUpPaper, commentAdd, confirmReceipt } from '../../api'; import { paperCheckStatusArr } from '../../static'; -import { httpUrl } from '../../../fetch'; +import { httpUrl } from '../../fetch'; import winpng from '../../image/winner.png'; import './index.scss'; diff --git a/src/military/task/components/itemProofManage/index.jsx b/src/military/task/components/itemProofManage/index.jsx index bf5025e0..36c8860f 100644 --- a/src/military/task/components/itemProofManage/index.jsx +++ b/src/military/task/components/itemProofManage/index.jsx @@ -5,7 +5,7 @@ import Nodata from 'forge/Nodata'; import Loading from "src/Loading"; import { timeAgo, getImageUrl } from 'educoder'; import { checkProof } from '../../api'; -import { httpUrl } from 'military/fetch'; +import { httpUrl } from '../../fetch'; import './index.scss'; const { TextArea } = Input; diff --git a/src/military/task/components/itemPublicityComplain/index.jsx b/src/military/task/components/itemPublicityComplain/index.jsx index e7f8bf2f..4f328975 100644 --- a/src/military/task/components/itemPublicityComplain/index.jsx +++ b/src/military/task/components/itemPublicityComplain/index.jsx @@ -5,7 +5,7 @@ import Nodata from 'forge/Nodata'; import Loading from "src/Loading"; import { timeAgo, getImageUrl } from 'educoder'; import { checkPublicity } from '../../api'; -import { httpUrl } from 'military/fetch'; +import { httpUrl } from '../../fetch'; import './index.scss'; const { TextArea } = Input; diff --git a/src/military/task/components/proofModal/index.jsx b/src/military/task/components/proofModal/index.jsx index 5ac16eff..15c741f4 100644 --- a/src/military/task/components/proofModal/index.jsx +++ b/src/military/task/components/proofModal/index.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useState, useCallback, useMemo } from 'react'; import { Modal, Table, Form, Input, Button, Pagination } from 'antd'; import Upload from 'military/components/Upload'; import { readyCheckPapers, proofAdd } from "../../api"; -import { httpUrl } from 'military/fetch'; +import { httpUrl } from '../../fetch'; import '../../index.scss'; import './index.scss'; diff --git a/src/military/task/paperComplain/index.js b/src/military/task/paperComplain/index.js index 302a8f77..a8564856 100644 --- a/src/military/task/paperComplain/index.js +++ b/src/military/task/paperComplain/index.js @@ -5,7 +5,7 @@ import { Link } from "react-router-dom"; import StatusNav from '../../components/statusNav'; import { complainPaperList, checkComplain } from '../api'; import { paperComplainStatusArr } from '../static'; -import { httpUrl } from 'military/fetch'; +import { httpUrl } from '../fetch'; import '../index.scss'; diff --git a/src/military/task/taskDetail/index.jsx b/src/military/task/taskDetail/index.jsx index 81296eee..c67a4e96 100644 --- a/src/military/task/taskDetail/index.jsx +++ b/src/military/task/taskDetail/index.jsx @@ -10,7 +10,7 @@ import ItemListPaper from '../components/itemListPaper'; import ProofModal from '../components/proofModal'; import { getTaskDetail, getTaskCategory, getTaskPaper, makePublic, addPaper, getAgreement, agreement, checkAgreement, checkHavePaper } from '../api'; import { taskModeIdArr, applyStatusArr, applyStatusAllArr, agreementContent, paperCheckTextArr } from '../static'; -import { httpUrl } from '../../fetch'; +import { httpUrl } from '../fetch'; import './index.scss'; const { TextArea } = Input; diff --git a/src/military/task/taskEdit/index.jsx b/src/military/task/taskEdit/index.jsx index e21b17ad..b3f1dbff 100644 --- a/src/military/task/taskEdit/index.jsx +++ b/src/military/task/taskEdit/index.jsx @@ -5,7 +5,7 @@ import moment from 'moment'; import ReactWEditor from 'wangeditor-for-react'; import { Link } from "react-router-dom"; import Upload from '../../components/Upload'; -import { httpUrl } from '../../fetch'; +import { httpUrl } from '../fetch'; import { getTaskDetail, addTask, updateTask, getTaskCategory, getCompanyInfo } from '../api'; import { formItemLayout, formModalLayout } from '../static'; import { editorConfig } from '../../components/config'; From 1bad39e83a470030c81a0a9f0a2a7fb0c3dd1c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Thu, 25 Nov 2021 15:59:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=AE=A2?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8E=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/military/task/api.js | 23 +++-- .../task/components/adminRouter/index.jsx | 2 +- src/military/task/taskAdmin/index.jsx | 99 +++++++++++++------ src/military/task/taskAdmin/index.scss | 6 ++ src/military/task/taskDetail/index.jsx | 6 +- 5 files changed, 93 insertions(+), 43 deletions(-) diff --git a/src/military/task/api.js b/src/military/task/api.js index 3d8052b2..85645e2b 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 e9003c5e..4132b4c5 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 c97e1def..2ca99d8a 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 1b7a76a5..087e99cc 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 c67a4e96..786f7857 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]); // 检查用户是否同意协议