From d7fd642f7ff6eb882b9c0a777c89c9f4f2a8f292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Fri, 18 Jun 2021 17:07:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=91=E7=9A=84=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E5=8F=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/itemListMyTask/index.jsx | 129 ++++++++++++++ .../components/itemListMyTask/index.scss | 64 +++++++ .../components/itemListTask/index.jsx | 78 +++++---- .../components/itemListTask/index.scss | 4 +- src/military/components/statusNav/index.scss | 2 +- src/military/index.scss | 7 + src/military/task.js | 11 +- src/military/task/api.js | 8 +- src/military/task/myTask/index.jsx | 94 ++++++++--- src/military/task/myTask/index.scss | 17 +- src/military/task/static.js | 7 +- src/military/task/taskDetail/index.jsx | 152 +++++++++++++---- src/military/task/taskDetail/index.scss | 75 +++++++-- src/military/task/taskEdit/index.jsx | 158 ++++++++++++------ src/military/task/taskEdit/index.scss | 3 - src/military/task/taskList/index.jsx | 19 ++- 16 files changed, 650 insertions(+), 178 deletions(-) create mode 100644 src/military/components/itemListMyTask/index.jsx create mode 100644 src/military/components/itemListMyTask/index.scss diff --git a/src/military/components/itemListMyTask/index.jsx b/src/military/components/itemListMyTask/index.jsx new file mode 100644 index 00000000..724249b1 --- /dev/null +++ b/src/military/components/itemListMyTask/index.jsx @@ -0,0 +1,129 @@ +import React, { useEffect, useState } from 'react'; +import { Icon, Modal, Pagination } from 'antd'; +import { Link } from "react-router-dom"; +import Nodata from '../../../forge/Nodata'; +import Loading from "../../../Loading"; +import { publishModeArr } from '../../task/static'; +import './index.scss'; + +const statusArr = ["草稿", "待审核", "已拒绝", "成果征集中", "成果评选中", "公示中", "协议签订中", "支付中", "已完成"]; +export default (props) => { + const { list, itemClick, curPage, total, changePage, taskCategoryValueArr, loading } = props; + + const [page, setPage] = useState(1); + const [activeItem, setActiveItem] = useState(''); + const [visibleProofs, setVisibleProofs] = useState(false); + + const [pageSize, setPageSize] = useState(() => { + return props.pageSize || 10; + }); + + useEffect(() => { + changePage(page); + }, [page]); + + function uploadProofs(item) { + setVisibleProofs(true); + setActiveItem(item); + } + + return ( + + + + {loading ? : + { + list.map(item => { + return ( +
+

+ 任务编号:{item.number} + + {item.createdAt} +

+
    +
  • + {item.name} + {item.status == 4 && 待确认} +
  • +
  • + {taskCategoryValueArr[item.categoryId]} + {publishModeArr[item.publishMode]} +
  • + +
  • {item.papersCount}
  • + +
  • ¥{item.bounty}
  • +
  • + + {statusArr[item.status]} + +
  • +
  • + { + item.status == 0 ? + 编辑草稿 : + 查看详情 + } + + {item.status == 4 && 成果评选} + {item.status == 4 && item.papersCount && (!item.isProofBoolean) && { uploadProofs(item) }} className="line_1 color-blue">上传佐证材料} + + {/* 支付登记 */} + {/* 上传支付凭证 */} +
  • +
+
+ ) + }) + } + + {list.length > 0 ? +
+ {total > pageSize && { setPage(page) }} + current={curPage} + total={total} + showTotal={total => `共 ${total} 条`} + />} +
: + } +
+ } + + { setVisibleProofs(false) }} + className="form-edit-modal" + > + {/*
+ + + + + + + + +
*/} +
+
+ + ) +} \ No newline at end of file diff --git a/src/military/components/itemListMyTask/index.scss b/src/military/components/itemListMyTask/index.scss new file mode 100644 index 00000000..bfdc780c --- /dev/null +++ b/src/military/components/itemListMyTask/index.scss @@ -0,0 +1,64 @@ +.needs_condition_content_nav { + padding: 0px 20px; + background: #f7f7f7; + height: 50px; + line-height: 50px; + color: #656565; + text-align: center; + margin-bottom: 10px; +} + +.needs_condition_content { + border: 1px solid #eaeaea; + border-radius: 4px; + margin-bottom: 20px; + + ul { + margin: 0; + padding: 20px; + box-sizing: border-box; + + li { + text-align: center; + justify-content: center; + align-items: center; + display: -webkit-flex; + } + } + + .list_status { + border-radius: 10px; + padding: 0px 10px; + height: 22px; + line-height: 22px; + display: inline-block; + color: #fff; + background: #fa6400; + margin-left: 0.625rem; + font-size: 0.8rem; + } + .needs_condition_content_t { + height: 40px; + padding: 0px 20px; + background: #f7f7f7; + color: #333; + border-bottom: 1px solid #eaeaea; + line-height: 40px; + } +} + +.tab-list-box { + position: relative; + display: flex; + justify-content: space-between; + padding: 20px; + background: #fff; + border-bottom: 1px solid #dedede; +} + +.flex-column { + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; +} diff --git a/src/military/components/itemListTask/index.jsx b/src/military/components/itemListTask/index.jsx index 894a506e..46de4055 100644 --- a/src/military/components/itemListTask/index.jsx +++ b/src/military/components/itemListTask/index.jsx @@ -1,56 +1,64 @@ import React, { useEffect, useState } from 'react'; import { Icon, Pagination } from 'antd'; import Nodata from '../../../forge/Nodata'; +import Loading from "../../../Loading"; import './index.scss'; const statusArr = ["草稿", "待审核", "已拒绝", "成果征集中", "成果评选中", "公示中", "协议签订中", "支付中", "已完成"]; const classArr = ['', 'list-done', 'list-error', 'list-red', 'list-yellow', '', '', 'list-pay', 'list-gray',]; export default (props) => { - const { list, itemClick, curPage, total, changePage } = props; + const { list, itemClick, curPage, total, changePage, loading } = props; const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(() => { + return props.pageSize || 10; + }); + useEffect(() => { changePage(page); }, [page]); return ( - - { - list.map(item => { - return ( -
-
-
{ itemClick(item.id) }}> - {item.name || item.title} - {item.status && {statusArr[item.status]}} -
-
- {item.visits} - {item.papersCount}人参与 + loading ? : + + { + list.map(item => { + return ( +
+
+
{ itemClick(item.id) }}> + {item.name || item.title} + {item.status && {statusArr[item.status]}} + {(!item.status == '8') && item.delayTime && 延期中} +
+
+ {item.visits} + {item.papersCount}人参与 + {(!item.status == '8') && item.delayTime && {item.delayTime}} +
+ + + + {item.bounty} +
+ ) + }) + } - - - {item.bounty} - -
- ) - }) - } - - {list.length > 0 ? -
- { setPage(page) }} - current={curPage} - total={total} - showTotal={total => `共 ${total} 条`} - /> -
: - } - + {list.length > 0 ? +
+ {total > pageSize && { setPage(page) }} + current={curPage} + total={total} + showTotal={total => `共 ${total} 条`} + />} +
: + } + ) } \ No newline at end of file diff --git a/src/military/components/itemListTask/index.scss b/src/military/components/itemListTask/index.scss index fcbb2054..cf01bab5 100644 --- a/src/military/components/itemListTask/index.scss +++ b/src/military/components/itemListTask/index.scss @@ -22,9 +22,9 @@ } .list-title span { padding: 2px 10px; - margin-left: 0.5em; + margin-left: .625rem; background: #f8c753; - font-size: 13px; + font-size: .8rem; color: #fff; border-radius: 14px; } diff --git a/src/military/components/statusNav/index.scss b/src/military/components/statusNav/index.scss index a6661fa0..ac536c2a 100644 --- a/src/military/components/statusNav/index.scss +++ b/src/military/components/statusNav/index.scss @@ -1,5 +1,5 @@ .status-list { - padding: 1rem 1.8rem; + padding: 1rem 0; display: flex; justify-content: start; } diff --git a/src/military/index.scss b/src/military/index.scss index b389e242..34c1d647 100644 --- a/src/military/index.scss +++ b/src/military/index.scss @@ -166,6 +166,7 @@ text-align: left; } +<<<<<<< HEAD // 富文本样式 .w-e-text table td, .w-e-text table th{ height: 30px; @@ -209,3 +210,9 @@ width: 98%; } } +======= + +.ant-modal-footer{ + text-align: center; +} +>>>>>>> 92f3934... 上传我的需求及 diff --git a/src/military/task.js b/src/military/task.js index 52d1ff4d..d5475db0 100644 --- a/src/military/task.js +++ b/src/military/task.js @@ -20,7 +20,7 @@ const TaskDetail = Loadable({ loading: Loading, }); -const TaskAdd = Loadable({ +const TaskEdit = Loadable({ loader: () => import("./task/taskEdit"), loading: Loading, }); @@ -46,7 +46,14 @@ class Index extends Component { ( - + + )} + > + + ( + )} > diff --git a/src/military/task/api.js b/src/military/task/api.js index 242a81ae..c52cf93b 100644 --- a/src/military/task/api.js +++ b/src/military/task/api.js @@ -63,10 +63,10 @@ export async function getMyTaskList(params) { // 详情查询 export async function getTaskDetail(id) { let res = await fetch({ - url: '/api/tasks/' + id, + url: '/api/tasks/getTask/' + id, method: 'get', }); - if (res.code === '1') { + if (res.data) { return res.data; } else { notification.open({ @@ -94,9 +94,9 @@ export function deleteTask(id) { } //更新 -export function editTask(data) { +export function updateTask(data) { return fetch({ - url: '/api/tasks/update', + url: '/api/tasks/', method: 'put', data: data }); diff --git a/src/military/task/myTask/index.jsx b/src/military/task/myTask/index.jsx index c91ecc52..484bb59c 100644 --- a/src/military/task/myTask/index.jsx +++ b/src/military/task/myTask/index.jsx @@ -1,11 +1,8 @@ import React, { useEffect, useState } from 'react'; -import { Tabs, Pagination, Input, Button } from 'antd'; -import moment from 'moment'; +import { Tabs, Input, Button, } from 'antd'; import StatusNav from '../../components/statusNav'; -import SortBox from '../../components/sortBox'; -import ItemListTask from '../../components/itemListTask'; -import Nodata from '../../../forge/Nodata'; -import { taskTimeArr, taskStatusArr, taskStatusAllArr, sortArr, taskModeIdArr } from '../static'; +import ItemListMyTask from '../../components/itemListMyTask'; +import { taskStatusAllArr, } from '../static'; import { getTaskList, getTaskCategory } from '../api'; import './index.scss'; const Search = Input.Search; @@ -15,33 +12,56 @@ const publishStatusArr = taskStatusAllArr.slice(3); const unpublishStatusArr = taskStatusAllArr.slice(0, 3); -export default ({ history, current_user }) => { - const [identity, setIdentity] = useState('1'); - const [type, setType] = useState('1'); +export default ({ location, history, current_user }) => { + let defaultValue = decodeURI(location.search.split("=")[1] || ""); + + const [identity, setIdentity] = useState('1'); + const [taskCategoryValueArr, setTaskCategoryValueArr] = useState([]); + + const [statusType, setStatusType] = useState(() => { + return defaultValue === 'false' ? '2' : '1'; + }); + const [statusString, setStatusString] = useState(() => { + return defaultValue === 'false' ? '0,1,2' : '3,4,5,6,7,8'; + }); - const [status, setStatus] = useState(''); const [searchInput, setSearchInput] = useState(''); const [orderBy, setOrderBy] = useState(''); const [curPage, setCurPage] = useState(1); const [total, setTotal] = useState(0); const [taskList, setTaskList] = useState([]); + const [loading, setLoading] = useState(false); + + // 获取任务领域数组 + useEffect(() => { + getTaskCategory().then(data => { + if (data) { + const taskCategoryValueArr = []; + for (const item of data) { + taskCategoryValueArr[item.id] = item.name; + } + setTaskCategoryValueArr(taskCategoryValueArr); + } + }); + }, []); useEffect(() => { const params = { - status, + statusString, searchInput, orderBy, curPage, pageSize: 10, }; - + setLoading(true); getTaskList(params).then(data => { if (data) { setTaskList(data.rows); setTotal(data.total); } + setLoading(false); }) - }, [status, searchInput, orderBy, curPage]); + }, [statusString, searchInput, orderBy, curPage]); function taskClick(id) { @@ -53,17 +73,40 @@ export default ({ history, current_user }) => { } function changeOptionId(option, type) { - if(type==='publishStatus'){ - setStatus(option.dicItemCode); + if (type === 'publishStatus') { + setStatusString(option.dicItemCode.toString() || '3,4,5,6,7,8'); + } else if (type === 'unpublishStatus') { + setStatusString(option.dicItemCode.toString() || '0,1,2'); } + setCurPage(1); + } + + function changeStatusType(key) { + if (key === '1') { + setStatusString('3,4,5,6,7,8'); + } else { + setStatusString('0,1,2'); + } + setCurPage(1); + setStatusType(key); } return ( -
{ setIdentity(key) }}> - { setType(key) }}> + setSearchInput(value)} + /> + } + > { changeOptionId={changeOptionId} /> - { setCurPage(page) }} + loading={loading} /> + { options={unpublishStatusArr} changeOptionId={changeOptionId} /> + + { setCurPage(page) }} + loading={loading} + /> - + 请稍候 diff --git a/src/military/task/myTask/index.scss b/src/military/task/myTask/index.scss index b05d89c9..c7cf9fc6 100644 --- a/src/military/task/myTask/index.scss +++ b/src/military/task/myTask/index.scss @@ -4,27 +4,36 @@ background: #fff; text-align: center; } - .ant-tabs-tab{ + .ant-tabs-tab { height: 4.5rem; line-height: 3rem; font-size: 1.15rem; font-weight: 500; } + .ant-tabs-extra-content { + line-height: 4.5rem; + } - .childTab{ + .childTab { background: #fff; .ant-tabs-top-bar { + padding: 0 1.8rem 0 0.8rem; background: #fff; text-align: left; } - .ant-tabs-tab{ + + .ant-tabs-tab { height: 4.5rem; line-height: 3rem; font-size: 1rem; font-weight: normal; } - .ant-tabs-ink-bar{ + .ant-tabs-ink-bar { visibility: hidden; } + .ant-tabs-tabpane { + padding: 1rem 1.8rem; + line-height: 2; + } } } diff --git a/src/military/task/static.js b/src/military/task/static.js index 5b52bffb..83893f4d 100644 --- a/src/military/task/static.js +++ b/src/military/task/static.js @@ -1,7 +1,7 @@ // 开始 export const taskStatusArr = [ - { dicItemCode: 999, name: "正在进行中", dicItemName: '正在进行中' }, - { dicItemCode: 0, name: "已完成", dicItemName: '已完成' }, + { dicItemCode: '3,4,5,6,7', name: "正在进行中", dicItemName: '正在进行中' }, + { dicItemCode: '8', name: "已完成", dicItemName: '已完成' }, ]; export const taskStatusAllArr = [ @@ -14,7 +14,7 @@ export const taskStatusAllArr = [ { dicItemCode: 6, name: "协议签订中", dicItemName: '协议签订中' }, { dicItemCode: 7, name: "支付中", dicItemName: '支付中' }, { dicItemCode: 8, name: "已完成", dicItemName: '已完成' }, -] +]; export const taskTimeArr = [ { dicItemCode: 1, name: "24小时到期", dicItemName: "24小时到期" }, @@ -28,6 +28,7 @@ export const taskModeIdArr = [ { dicItemCode: 3, name: "计件悬赏", dicItemName: "计件悬赏" }, ] +export const publishModeArr=["自主提交","统筹任务"]; export const sortArr = [{ name: '综合', diff --git a/src/military/task/taskDetail/index.jsx b/src/military/task/taskDetail/index.jsx index f78ad68e..5ba31038 100644 --- a/src/military/task/taskDetail/index.jsx +++ b/src/military/task/taskDetail/index.jsx @@ -1,59 +1,149 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, useCallback } from 'react'; +import { Link } from "react-router-dom"; +import { getImageUrl } from 'educoder'; import { httpUrl } from '../../fetch'; -import { getTaskDetail } from '../api'; -import { taskStatus, taskType } from '../static'; +import { getTaskDetail, getTaskCategory } from '../api'; +import { taskModeIdArr} from '../static'; import './index.scss'; +import classNames from 'classnames'; -const taskStatusArr = []; -const taskTypeArr = []; -for (const item of taskStatus) { - taskStatusArr.push(item.name); -} -for (const item of taskType) { - taskTypeArr.push(item.name); +const taskModeNameArr=[]; +for(const item of taskModeIdArr){ + taskModeNameArr[item.dicItemCode]=item.dicItemName; } - -export default ({ match,history, showNotification }) => { - const [detailData, setDetailData] = useState({}); +export default ({ match, current_user, history, showNotification }) => { + console.log(current_user); const id = match.params.taskId; + const [detailData, setDetailData] = useState({}); + const [taskCategoryValueArr, setTaskCategoryValueArr] = useState([]); + + + // 获取任务领域数组 + useEffect(() => { + getTaskCategory().then(data => { + if (data) { + const taskCategoryValueArr = []; + for (const item of data) { + taskCategoryValueArr[item.id] = item.name; + } + setTaskCategoryValueArr(taskCategoryValueArr); + } + }); + }, []); + useEffect(() => { id && getTaskDetail(id).then(data => { setDetailData(data || {}); + console.log(data); }) }, [id]); + const process = useCallback((title, days, active) => { + return ( +
  • + {title} + {days &&

    + {days}天 +

    } +
  • + ) + }, []); + + function downFile(item) { + let url = httpUrl + '/busiAttachments/download/' + item.id; + window.open(url); + } + return (
    - {history.go(-1)}}>公告 >  详情 + 创客空间 > + 任务大厅 > +  任务编号:{detailData.number}
    -
    -
    -
    {detailData.title}
    + +
    +
    +
    + 头像加载失败 +

    {current_user.username}

    +
    +
    +
      +
    • {detailData.name}
    • + {taskCategoryValueArr[detailData.categoryId]} +
    +
    +
      +
    • 悬赏模式:{taskModeNameArr[detailData.taskModeId]}
    • +
    • 任务编号:{detailData.number}
    • +
    • 发布时间:{detailData.publishedAt}
    • +
    • 截止时间:{detailData.expiredAt}
    • +
    + +
    +
    -
    -
    - {detailData.publisher &&

    发布单位:{detailData.publisher}

    } -

    发布时间:{detailData.publishDate || detailData.createdAt}

    -

    截止时间:{detailData.closingDate}

    -
    - {/* 富文本内容插入 */} -
    -
    +
    +
      +
    • 发布任务
    • + + {process('成果提交', detailData.collectingDays, detailData.status > 2)} + + {process('成果评选', detailData.choosingDays, detailData.status > 3)} + + {process('结果公示', detailData.makePublicDays, detailData.status > 4)} + + {process('任务协议签订', detailData.signingDays, detailData.status > 5)} + + {process('支付', detailData.payingDays, detailData.status > 6)} + + {process('任务完成', '', detailData.status > 7)} +
    +
    + +
    需求详情:
    + + {/* 富文本内容插入 */} +
    + + {detailData.tasksAttachments && +
    需求文件:
    { - detailData.fileDownloadPath && -

    公告附件:

    -

    { window.open(httpUrl + detailData.fileDownloadPath) }} >{detailData.fileName}

    -
    + detailData.tasksAttachments.map(item => { + return
    + + { downFile(item) }}> + {item.fileName} + ({item.fileSizeString}) +
    + }) } +
    + } -
    +
    知识产权说明:
    +

    + 1、参赛作品一经采用,其所有权、修改权和使用权均归主办方所有,设计者不得再在任何地方使用;
    + 2、应征者所提交的作品必须由应征者本人创作或参与创作,应征者应确认其作品的原创性,主办单位不承担因作品侵犯他人(或单位)的权利而产生的法律责任,其法律责任由应征者本人承担。 +

    + +
    交稿声明:
    + +

    + 应征者提交的稿件必须是设计作品,广告等无效交稿一律不采用! +

    diff --git a/src/military/task/taskDetail/index.scss b/src/military/task/taskDetail/index.scss index 000938bc..bbc354fa 100644 --- a/src/military/task/taskDetail/index.scss +++ b/src/military/task/taskDetail/index.scss @@ -14,22 +14,73 @@ position: absolute; top:-2.3em; } -// 内容详情 -.item-content { - padding: 10px 10px 0 30px; -} -.content-notice { - padding: 20px; + +.task_tag { + padding: 0px 12px; + background: #F1F8FF; + border-radius: 4px; + float: left; + color: #459BE6; + height: 1.25rem; + line-height: 1.25rem; } -.center-author { - display: flex; - align-items: center; +.tasks_status li { + float: left; + position: relative; + margin-right: 20px; + background: #EBEBEB; + width: 140px; + height: 35px; + line-height: 35px; + color: #05101A; + text-align: center; + margin-bottom: 32px; } -.content-text { - margin: 1em 0; - min-height: 30vh; + +.tasks_status li.active { + background: #4CACFF; + color: #fff; +} + +.tasks_status li:not(:first-child):before { + width: 0; + height: 0; + border-width: 17px; + content: ''; + position: absolute; + left: 0px; + border-style: solid; + top: 0px; + border-color: transparent transparent #fafafa transparent; + transform: rotate(90deg); +} + +.tasks_status li:not(:last-child):after { + width: 0; + height: 0; + border-width: 17px; + content: ''; + position: absolute; + right: -34px; + border-style: solid; + top: 0px; + border-color: transparent transparent #EBEBEB transparent; + transform: rotate(90deg); +} + +.tasks_status li.active:after { + border-color: transparent transparent #4CACFF transparent; + transform: rotate(90deg); +} + +.file-list-box{ + padding:0 1.25rem; +} + +.content-text{ + padding: 1.25rem; } .content-download{ diff --git a/src/military/task/taskEdit/index.jsx b/src/military/task/taskEdit/index.jsx index 5d56b78e..2ae799de 100644 --- a/src/military/task/taskEdit/index.jsx +++ b/src/military/task/taskEdit/index.jsx @@ -1,51 +1,57 @@ import React, { forwardRef, useCallback, useEffect, useState } from 'react'; import { Form, Radio, Input, InputNumber, Icon, Button, Modal } from 'antd'; import classNames from 'classnames'; +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 { getTaskDetail, addTask, updateTask, getTaskCategory } from '../api'; -import {formItemLayout,tailFormItemLayout,formModalLayout}from '../static'; +import { formItemLayout, formModalLayout } from '../static'; import './index.scss'; +const { info } = Modal; + let actionUrl = ''; if (window.location.href.indexOf('localhost') > -1) { actionUrl = httpUrl; } +function getSomeDayAfter(nDay) { + return moment(new Date().setDate(new Date().getDate() + nDay)).format('YYYY-MM-DD HH:mm:ss'); +} + export default Form.create()(forwardRef(({ current_user, form, showNotification, match, history }, ref) => { const [taskCategoryArr, setTaskCategoryArr] = useState([]); const [fileList, setFileList] = useState(null); - const [publishMode, setPublishMode] = useState(0); + const [publishMode, setPublishMode] = useState('0'); const [categoryId, setCategoryId] = useState('7'); const [description, setDescription] = useState(''); - + const [enterpriseName, setEnterpriseName] = useState('神马科技股份有限公司'); + const [displayTime, setDisplayTime] = useState(() => { + return { + collectingTime: getSomeDayAfter(30), + choosingTime: getSomeDayAfter(30 + 15), + makePublicTime: getSomeDayAfter(30 + 15 + 7), + signingTime: getSomeDayAfter(30 + 15 + 7 + 15), + payingTime: getSomeDayAfter(30 + 15 + 7 + 15 + 15) + } + }); + // console.log(displayTime); const [visible, setVisible] = useState(false); const [num, setNum] = useState(0) // 倒计时 const [isSend, setIsSend] = useState(false) // 是否发送验证码 - const id = match.params.requireId; + const id = match.params.taskId; const { getFieldDecorator, validateFields, setFieldsValue, } = form; // 根据是否传id判断是新增还是修改 useEffect(() => { - let formValue = { - taskModeId: 1, - collectionMode: 1, - publishMode: 0, - collectingDays: 30, - choosingDays: 15, - makePublicDays: 7, - signingDays: 15, - payingDays: 15, - }; - let categoryId = '7'; if (id) { getTaskDetail(id).then(data => { - formValue = { + let formValue = { name: data.name, contactName: data.contactName, contactPhone: data.contactPhone, @@ -63,20 +69,42 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, signingDays: data.signingDays, payingDays: data.payingDays, }; - - categoryId = data.categoryId; - if (data.attachmentList.length) { - for (const item of data.attachmentList) { + if (data.tasksAttachments && data.tasksAttachments.length) { + for (const item of data.tasksAttachments) { item.name = item.fileName; item.size = item.fileSize; item.uid = "rc-upload" + item.id } - setFileList(data.attachmentList); + setFileList(data.tasksAttachments); } + setFieldsValue(formValue); + setEnterpriseName(data.enterpriseName); + setCategoryId(data.categoryId); + setDescription(data.description); + + let collectingTime = getSomeDayAfter(data.collectingDays); + let choosingTime = getSomeDayAfter(data.collectingDays + data.choosingDays); + let makePublicTime = getSomeDayAfter(data.collectingDays + data.choosingDays + data.makePublicDays); + let signingTime = getSomeDayAfter(data.collectingDays + data.choosingDays + data.makePublicDays + data.signingDays); + let payingTime = getSomeDayAfter(data.collectingDays + data.choosingDays + data.makePublicDays + data.signingDays + data.payingDays); + setDisplayTime({ collectingTime, choosingTime, makePublicTime, signingTime, payingTime }); + + console.log(data); }); + } else { + let formValue = { + taskModeId: 1, + collectionMode: 1, + publishMode: 0, + collectingDays: 30, + choosingDays: 15, + makePublicDays: 7, + signingDays: 15, + payingDays: 15, + }; + setFieldsValue(formValue); + setCategoryId('7'); } - setFieldsValue(formValue); - setCategoryId(categoryId); }, [id]); useEffect(() => { @@ -91,9 +119,8 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, }); }, []); - /** 倒计时显示*/ - useEffect(() => { + useEffect(() => { let timer = 0; if (isSend && num !== 0) { timer = setInterval(() => { @@ -102,7 +129,7 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, setIsSend(false) clearInterval(timer) } - return n - 1; + return n - 1; }); }, 1000); } @@ -112,7 +139,7 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, }; }, [isSend]); - function getCode(){ + function getCode() { setIsSend(true); setNum(60); } @@ -145,6 +172,7 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, {getFieldDecorator(name, { rules, initialValue, validateFirst: true, })(widget)} +
    ), []); @@ -155,13 +183,39 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, setDescription(html); } + // 新增或者修改后的处理函数 + const publishDeal = useCallback((status, publishMode, res) => { + if (res.data) { + showNotification("需求保存成功!"); + if (!status) { + history.push("/task/myTask?published=false") + } else if (publishMode == 1) { + info({ + title: '提示', + content:
    +

    发布申请已提交,请等待管理员的审核

    +

    我们将在1-2个工作日内完成审核

    +
    , + onOk() { + history.push("/task/myTask?published=false"); + }, + }); + } else { + history.push("/task/myTask"); + } + } else { + showNotification(res.message); + } + }, []); + // 保存 - function saveItem() { + function saveItem(status) { validateFields((error, values) => { if (!error) { let params = { ...values, - enterpriseName: '神马科技股份有限公司', + status, + enterpriseName: enterpriseName, categoryId, }; let dateSum = params.collectingDays + params.choosingDays + params.makePublicDays + params.signingDays + params.payingDays; @@ -173,48 +227,46 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, // 编辑 params.id = id; updateTask(params).then(res => { - if (res.code === '1') { - showNotification("需求更新成功!"); - history.go(-1); - } else { - showNotification(res.message); - } + publishDeal(); }); } else { // 新增 addTask(params).then(res => { - if (res.code === '1') { - showNotification("需求新增成功!"); - history.go(-1); - } else { - showNotification(res.message); - } + publishDeal(); }); } } }) } - - + function changeDate(v, field) { + validateFields((error, values) => { + let collectingTime = getSomeDayAfter(values.collectingDays); + let choosingTime = getSomeDayAfter(values.collectingDays + values.choosingDays); + let makePublicTime = getSomeDayAfter(values.collectingDays + values.choosingDays + values.makePublicDays); + let signingTime = getSomeDayAfter(values.collectingDays + values.choosingDays + values.makePublicDays + values.signingDays); + let payingTime = getSomeDayAfter(values.collectingDays + values.choosingDays + values.makePublicDays + values.signingDays + values.payingDays); + setDisplayTime({ collectingTime, choosingTime, makePublicTime, signingTime, payingTime }); + }) + } return (
    - 创客空间 > - 任务大厅 > + 创客空间 > + 任务大厅 >  发布需求

    任务需求提交

    -
    +

    联系方式(*必填)

    - {"神马科技股份有限公司"} + {enterpriseName} {helper( @@ -384,6 +436,7 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, "collectingDays", [{ required: true, message: "请输入天数" }], { changeDate(v, 'collectingDays') }} className="date-input" /> )} @@ -436,15 +489,15 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, * 注:任务天数总和不得超过180天。

    - - - -
    + + + + - - + diff --git a/src/military/task/taskEdit/index.scss b/src/military/task/taskEdit/index.scss index 000c8ff6..9cfa005d 100644 --- a/src/military/task/taskEdit/index.scss +++ b/src/military/task/taskEdit/index.scss @@ -138,6 +138,3 @@ line-height: 40px; } -.ant-modal-footer{ - text-align: center; -} \ No newline at end of file diff --git a/src/military/task/taskList/index.jsx b/src/military/task/taskList/index.jsx index c294afb0..d4d7ae1e 100644 --- a/src/military/task/taskList/index.jsx +++ b/src/military/task/taskList/index.jsx @@ -4,20 +4,19 @@ import moment from 'moment'; import ChooseNav from '../../components/chooseNav'; import SortBox from '../../components/sortBox'; import ItemListTask from '../../components/itemListTask'; -import Nodata from '../../../forge/Nodata'; import { taskTimeArr, taskStatusArr, sortArr, taskModeIdArr } from '../static'; import { getTaskList, getTaskCategory } from '../api'; const Search = Input.Search; - export default ({ history, current_user }) => { console.log(current_user); + const [loading, setLoading] = useState(false); const [taskCategoryArr, setTaskCategoryArr] = useState([]); const [categoryId, setCategoryId] = useState(''); const [taskModeId, setTaskModeId] = useState(''); const [expiredStartTime, setExpiredStartTime] = useState(''); const [expiredEndTime, setExpiredEndTime] = useState(''); - const [status, setStatus] = useState(''); + const [statusString, setStatusString] = useState('3,4,5,6,7,8'); const [searchInput, setSearchInput] = useState(''); const [orderBy, setOrderBy] = useState(''); const [curPage, setCurPage] = useState(1); @@ -42,20 +41,21 @@ export default ({ history, current_user }) => { taskModeId, expiredStartTime, expiredEndTime, - status, + statusString, searchInput, orderBy, curPage, pageSize: 10, }; - + setLoading(true); getTaskList(params).then(data => { if (data) { setTaskList(data.rows); setTotal(data.total); } + setLoading(false); }) - }, [categoryId, taskModeId, expiredStartTime, expiredEndTime, status, searchInput, orderBy, curPage]); + }, [categoryId, taskModeId, expiredStartTime, expiredEndTime, statusString, searchInput, orderBy, curPage]); function changeOptionId(option, type) { @@ -74,7 +74,7 @@ export default ({ history, current_user }) => { setExpiredEndTime(''); } } else if (type === 'taskStatus') { - setStatus(option.dicItemCode); + setStatusString(option.dicItemCode||'3,4,5,6,7,8'); } } @@ -101,7 +101,6 @@ export default ({ history, current_user }) => { } return ( -
    { maxLength={20} style={{ width: "300px" }} placeholder="请输入任务编号/任务名称关键字" - onSearch={(value) => setSearchInput(value)} /> + onSearch={(value) => setSearchInput(value)} + /> @@ -167,6 +167,7 @@ export default ({ history, current_user }) => { curPage={curPage} total={total} changePage={(page) => { setCurPage(page) }} + loading={loading} />