From 2ed7e0d4c4d60ce862bcde33d7ec20d3d96d18c7 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, 17 Jun 2021 15:28:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=88=9B=E5=AE=A2=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=BB=BB=E5=8A=A1=E5=8F=8A=E5=88=97=E8=A1=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/military/components/chooseNav/index.jsx | 4 +- .../components/itemListTask/index.jsx | 65 +- .../components/itemListTask/index.scss | 78 ++- src/military/components/sortBox/index.jsx | 10 +- src/military/components/statusNav/index.jsx | 26 + src/military/components/statusNav/index.scss | 20 + src/military/fetch.js | 64 +- src/military/index.scss | 49 +- src/military/task.js | 11 + src/military/task/api.js | 45 +- src/military/task/myTask/index.jsx | 103 ++++ src/military/task/myTask/index.scss | 30 + src/military/task/static.js | 102 +++- src/military/task/taskEdit/index.jsx | 562 ++++++++++++------ src/military/task/taskEdit/index.scss | 145 ++++- src/military/task/taskList/index.jsx | 148 +++-- src/military/task/taskList/index.scss | 5 - 17 files changed, 1079 insertions(+), 388 deletions(-) create mode 100644 src/military/components/statusNav/index.jsx create mode 100644 src/military/components/statusNav/index.scss create mode 100644 src/military/task/myTask/index.jsx create mode 100644 src/military/task/myTask/index.scss delete mode 100644 src/military/task/taskList/index.scss diff --git a/src/military/components/chooseNav/index.jsx b/src/military/components/chooseNav/index.jsx index 3f1216c46..e15d29b88 100644 --- a/src/military/components/chooseNav/index.jsx +++ b/src/military/components/chooseNav/index.jsx @@ -16,10 +16,10 @@ export default (props) => {
{title}
-
{ setOption({ code: "", dicItemName: "" }) }}>全部
+
{ setOption({ dicItemCode: "", dicItemName: "" }) }}>全部
{ options.map((item) => { - return
{ setOption(item) }} >{item.dicItemName}
+ return
{ setOption(item) }} >{item.dicItemName}
}) }
diff --git a/src/military/components/itemListTask/index.jsx b/src/military/components/itemListTask/index.jsx index dae5511cf..894a506e1 100644 --- a/src/military/components/itemListTask/index.jsx +++ b/src/military/components/itemListTask/index.jsx @@ -1,21 +1,56 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; +import { Icon, Pagination } from 'antd'; +import Nodata from '../../../forge/Nodata'; + 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, } = props; + const { list, itemClick, curPage, total, changePage } = props; + const [page, setPage] = useState(1); + useEffect(() => { + changePage(page); + }, [page]); return ( - list.map(item => { - return ( -
-
{ itemClick(item.id) }}> - {item.achievementName || item.title} -
-
- {item.publisher &&

发布单位:{item.publisher}

} -

发布时间:{item.publishDate || item.createTime}

-
-
- ) - }) + + { + list.map(item => { + return ( +
+
+
{ itemClick(item.id) }}> + {item.name || item.title} + {item.status && {statusArr[item.status]}} +
+
+ {item.visits} + {item.papersCount}人参与 +
+
+ + + + {item.bounty} + +
+ ) + }) + } + + {list.length > 0 ? +
+ { 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 c47393952..fcbb2054e 100644 --- a/src/military/components/itemListTask/index.scss +++ b/src/military/components/itemListTask/index.scss @@ -1,70 +1,60 @@ .list-box { position: relative; + display: flex; + justify-content: space-between; padding: 20px; + margin: 0 1.5rem; background: #fff; border-bottom: 1px solid #dedede; } +.price { + font-weight: 500; + padding-top: 10px; +} .list-title { - font-size: 17px; - color: #000; + font-size: 1rem; + color: #333; cursor: pointer; + font-weight: 500; } .list-title:hover { color: #409eff; } .list-title span { - padding: 3px 5px; - margin-left:.5em; + padding: 2px 10px; + margin-left: 0.5em; background: #f8c753; font-size: 13px; color: #fff; - border-radius: 3px; + border-radius: 14px; +} +span.list-yellow { + background: #fa6400; +} +span.list-red { + background: #fe0e36; +} +span.list-orange { + background: #ffb121; } span.list-done { background: #35d77e; } +span.list-pay { + background: #1ad757; +} span.list-error { background: #f56c6c; } - -.list-tag { - display: inline-block; - margin: 5px 10px 5px 0; - background: #cfe9ff; - color: #0089ff; - font-size: 14px; - border-radius: 3px; - padding: 2px 5px; +span.list-gray { + background: #bababa; } -.list-other > p { - display: inline-block; - margin: 0 10px 0 0; + +.list-other { font-size: 12px; - color: #666; -} - -.list-box-action { - position: absolute; - display: flex; - align-items: center; - top: 0; - bottom: 0; - right: 100px; - visibility: hidden; -} -.list-box:hover .list-box-action { - visibility: visible; -} -.list-box-action button { - display: inline-block; - margin: 0 25px; - width: 50px; - height: 50px; - color: #0089ff; - line-height: 50px; - text-align: center; - border: 0; - border-radius: 25px; - box-shadow: 2px 2px 5px 2px #eee; - cursor: pointer; + color: #888; + i { + font-size: 14px; + margin-right: 5px; + } } diff --git a/src/military/components/sortBox/index.jsx b/src/military/components/sortBox/index.jsx index b826aed45..546907daa 100644 --- a/src/military/components/sortBox/index.jsx +++ b/src/military/components/sortBox/index.jsx @@ -7,7 +7,7 @@ export default (props) => { const { options, changeOptionId, type, defaultValue } = props; const [myOptions, setMyOptions] = useState(options); - const [option, setOption] = useState(defaultValue || { name: "", type: "" }); + const [option, setOption] = useState(defaultValue); useEffect(() => { changeOptionId(option, type); @@ -16,11 +16,11 @@ export default (props) => { function itemClick(activeItem) { const newOption = { ...activeItem, - value: !activeItem.value + desc: !activeItem.desc }; for(const item of myOptions){ if(item.type===activeItem.type){ - item.value=newOption.value; + item.desc=newOption.desc; } } setOption(newOption); @@ -36,8 +36,8 @@ export default (props) => { {item.name} { item.icon && - - + + }
}) diff --git a/src/military/components/statusNav/index.jsx b/src/military/components/statusNav/index.jsx new file mode 100644 index 000000000..c059dd731 --- /dev/null +++ b/src/military/components/statusNav/index.jsx @@ -0,0 +1,26 @@ +import React, { useEffect, useState } from 'react'; +import classNames from 'classnames'; +import './index.scss'; + +export default (props) => { + const { title, options, changeOptionId, type } = props; + + const [option, setOption] = useState({ code: "", dicItemName: "" ,dicItemCode:""}); + + useEffect(() => { + changeOptionId(option, type); + }, [option]) + + return ( + +
+
{ setOption({ dicItemCode: "", dicItemName: "" }) }}>全部
+ { + options.map((item) => { + return
{ setOption(item) }} >{item.dicItemName}
+ }) + } +
+ + ) +} \ No newline at end of file diff --git a/src/military/components/statusNav/index.scss b/src/military/components/statusNav/index.scss new file mode 100644 index 000000000..a6661fa0b --- /dev/null +++ b/src/military/components/statusNav/index.scss @@ -0,0 +1,20 @@ +.status-list { + padding: 1rem 1.8rem; + display: flex; + justify-content: start; +} +.status-item { + font-size: 14px; + color: #666; + text-align: center; + padding: 3px 15px; + cursor: pointer; + &:hover { + color: #4cacff; + } +} + +.status-item-checked { + background: #f7f7f7; + color: #4cacff ; +} diff --git a/src/military/fetch.js b/src/military/fetch.js index ee3688406..9e5e29cb7 100644 --- a/src/military/fetch.js +++ b/src/military/fetch.js @@ -4,19 +4,20 @@ import cookie from 'react-cookies'; // export const httpUrl='http://117.50.100.12:8001'; // export const httpUrl='http://192.168.31.72:8081'; -export const httpUrl = 'http://106.75.31.211:58088'; +// export const httpUrl = 'http://106.75.31.211:58088'; +export const httpUrl = 'http://192.168.31.72:8089'; -// const TokenKey = 'autologin_forge_military'; -const TokenKey = 'autologin_trustie'; + +const TokenKey = 'autologin_forge_military'; +// const TokenKey = 'autologin_trustie'; axios.defaults.withCredentials = true; // 创建axios实例 const service = axios.create({ - // baseURL: httpUrl, + baseURL: httpUrl, timeout: 5000 // 请求超时时间 }); - // request拦截器 service.interceptors.request.use(config => { if (cookie.load(TokenKey)) { @@ -31,51 +32,14 @@ service.interceptors.request.use(config => { // respone拦截器 service.interceptors.response.use( response => { - const res = response; - if (res.status == 400) { - notification.open({ - message: "提示", - description: '请求错误', - }); - return Promise.reject('error'); - } - if (res.status == 401) { - notification.open({ - message: "提示", - description: '未授权,请登录!', - }); - return Promise.reject('error'); - } - if (res.status == 403) { - notification.open({ - message: "提示", - description: '无权限', - }); - window.location.href="https://testforgeplus.trustie.net/403"; - 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; - } + return response.data; }, error => { - let res = error.response||{}; + let res = error.response || {}; if (res.status == 400) { notification.open({ message: "提示", - description: '请求错误', + description: '验证失败', }); return Promise.reject('error'); } @@ -91,7 +55,15 @@ service.interceptors.response.use( message: "提示", description: '无权限', }); - // window.location.href="https://testforgeplus.trustie.net/403"; + window.location.href="/403"; + return Promise.reject('error'); + } + if (res.status == 404) { + notification.open({ + message: "提示", + description: '无权限', + }); + window.location.href="/404"; return Promise.reject('error'); } if (res.status == 40001) { diff --git a/src/military/index.scss b/src/military/index.scss index dfca5f055..e7295d0d4 100644 --- a/src/military/index.scss +++ b/src/military/index.scss @@ -1,9 +1,21 @@ // 本模块公共样式 - +.color-grey3{ + color: #333; +} +.color-grey9{ + color: #999; +} +.color-orange { + color: #ff6800; +} +.color-deep-blue{ + color:#1B8FFF; +} .centerbox { width: 80vw; max-width: 1280px; margin: 40px auto; + position: relative; } .center-content { background: #fff; @@ -19,6 +31,24 @@ } +.head-navigation { + position: absolute; + top: -2.3em; + a:hover { + color: #409eff; + } +} + +// 内容标题左侧样式 +.center-left-but { + display: flex; + justify-content: start; + align-items: center; + margin-left: 20px; + font-size: 16px; + font-weight: 600; +} + // 内容标题右侧样式 .center-right-but { display: flex; @@ -31,18 +61,6 @@ cursor: pointer; } -// 通用标签样式 -.list-tag { - display: inline-block; - margin-right: 10px; - background: #cfe9ff; - color: #0089ff; - font-size: 14px; - border-radius: 3px; - padding: 2px 5px; - line-height: 25px; -} - // 文件预览modal样式 .file-modal { width: 800px !important; @@ -70,7 +88,7 @@ max-width: 500px; } -.none_panels{ +.none_panels { display: flex; justify-content: center; align-items: center; @@ -78,8 +96,7 @@ height: 40vh; } - -.newFooter .footerInfos>ul { +.newFooter .footerInfos > ul { padding: 0 40px; box-sizing: border-box; max-width: 25%; diff --git a/src/military/task.js b/src/military/task.js index b573a4e8c..52d1ff4d0 100644 --- a/src/military/task.js +++ b/src/military/task.js @@ -25,6 +25,10 @@ const TaskAdd = Loadable({ loading: Loading, }); +const MyTask = Loadable({ + loader: () => import("./task/myTask"), + loading: Loading, +}); class Index extends Component { render() { @@ -46,6 +50,13 @@ class Index extends Component { )} > + ( + + )} + > + ( diff --git a/src/military/task/api.js b/src/military/task/api.js index 522fd7002..242a81ae1 100644 --- a/src/military/task/api.js +++ b/src/military/task/api.js @@ -9,14 +9,47 @@ export function getDictionary(id) { }); } +// 获取任务领域 +export async function getTaskCategory() { + let res = await fetch({ + url: '/api/taskCategory/getTaskCategory', + method: 'get', + }); + if (Array.isArray(res.data.rows)) { + return res.data.rows; + } else { + notification.open({ + message: "提示", + description: res.message || '请求错误', + }); + } +} + // 列表查询 export async function getTaskList(params) { let res = await fetch({ - url: '/api/announcements/', + url: '/api/tasks/', method: 'get', params, }); - if (res.code === '1') { + if (res.data) { + return res.data; + } else { + notification.open({ + message: "提示", + description: res.message || '请求错误', + }); + } +} + +// 我的列表查询 +export async function getMyTaskList(params) { + let res = await fetch({ + url: '/api/myTasks/', + method: 'get', + params, + }); + if (res.data) { return res.data; } else { notification.open({ @@ -30,7 +63,7 @@ export async function getTaskList(params) { // 详情查询 export async function getTaskDetail(id) { let res = await fetch({ - url: '/api/announcements/' + id, + url: '/api/tasks/' + id, method: 'get', }); if (res.code === '1') { @@ -46,7 +79,7 @@ export async function getTaskDetail(id) { //新增公告 export function addTask(data) { return fetch({ - url: '/api/announcements/add', + url: '/api/tasks/add', method: 'post', data: data }); @@ -55,7 +88,7 @@ export function addTask(data) { //删除 export function deleteTask(id) { return fetch({ - url: '/api/announcements/' + id, + url: '/api/tasks/' + id, method: 'DELETE', }); } @@ -63,7 +96,7 @@ export function deleteTask(id) { //更新 export function editTask(data) { return fetch({ - url: '/api/announcements/update', + url: '/api/tasks/update', method: 'put', data: data }); diff --git a/src/military/task/myTask/index.jsx b/src/military/task/myTask/index.jsx new file mode 100644 index 000000000..c91ecc527 --- /dev/null +++ b/src/military/task/myTask/index.jsx @@ -0,0 +1,103 @@ +import React, { useEffect, useState } from 'react'; +import { Tabs, Pagination, Input, Button } from 'antd'; +import moment from 'moment'; +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 { getTaskList, getTaskCategory } from '../api'; +import './index.scss'; +const Search = Input.Search; +const { TabPane } = Tabs; + +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'); + + 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([]); + + useEffect(() => { + const params = { + status, + searchInput, + orderBy, + curPage, + pageSize: 10, + }; + + getTaskList(params).then(data => { + if (data) { + setTaskList(data.rows); + setTotal(data.total); + } + }) + }, [status, searchInput, orderBy, curPage]); + + + function taskClick(id) { + history.push(`/task/taskDetail/${id}`); + } + + function goAdd() { + history.push("/task/taskAdd"); + } + + function changeOptionId(option, type) { + if(type==='publishStatus'){ + setStatus(option.dicItemCode); + } + } + + return ( + +
+ { setIdentity(key) }}> + + { setType(key) }}> + + + + { setCurPage(page) }} + /> + + + + + + + + + + + + + + +
+ ) +} \ No newline at end of file diff --git a/src/military/task/myTask/index.scss b/src/military/task/myTask/index.scss new file mode 100644 index 000000000..b05d89c9d --- /dev/null +++ b/src/military/task/myTask/index.scss @@ -0,0 +1,30 @@ +.my-task { + margin-top: 1.25rem; + .ant-tabs-top-bar { + background: #fff; + text-align: center; + } + .ant-tabs-tab{ + height: 4.5rem; + line-height: 3rem; + font-size: 1.15rem; + font-weight: 500; + } + + .childTab{ + background: #fff; + .ant-tabs-top-bar { + background: #fff; + text-align: left; + } + .ant-tabs-tab{ + height: 4.5rem; + line-height: 3rem; + font-size: 1rem; + font-weight: normal; + } + .ant-tabs-ink-bar{ + visibility: hidden; + } + } +} diff --git a/src/military/task/static.js b/src/military/task/static.js index dd380b5db..5b52bffbe 100644 --- a/src/military/task/static.js +++ b/src/military/task/static.js @@ -1,19 +1,91 @@ -// 公告开始 -export const taskStatus = [ - { code: 0, name: "关闭", dicItemName: '关闭' }, - { code: 1, name: "正常", dicItemName: '正常' }, - { code: 2, name: "草稿", dicItemName: '草稿' }, +// 开始 +export const taskStatusArr = [ + { dicItemCode: 999, name: "正在进行中", dicItemName: '正在进行中' }, + { dicItemCode: 0, name: "已完成", dicItemName: '已完成' }, ]; -export const taskType = [ - { code: 1, name: "更正", dicItemName: "更正" }, - { code: 2, name: "中标", dicItemName: "中标" }, - { code: 3, name: "废标", dicItemName: "废标" }, +export const taskStatusAllArr = [ + { dicItemCode: 0, name: "未发布", dicItemName: '未发布' }, + { dicItemCode: 1, name: "待审核", dicItemName: '待审核' }, + { dicItemCode: 2, name: "已拒绝", dicItemName: '已拒绝' }, + { dicItemCode: 3, name: "成果征集中", dicItemName: '成果征集中' }, + { dicItemCode: 4, name: "成果评选中", dicItemName: '成果评选中' }, + { dicItemCode: 5, name: "公示中", dicItemName: '公示中' }, + { dicItemCode: 6, name: "协议签订中", dicItemName: '协议签订中' }, + { dicItemCode: 7, name: "支付中", dicItemName: '支付中' }, + { dicItemCode: 8, name: "已完成", dicItemName: '已完成' }, +] + +export const taskTimeArr = [ + { dicItemCode: 1, name: "24小时到期", dicItemName: "24小时到期" }, + { dicItemCode: 3, name: "3天内到期", dicItemName: "3天内到期" }, + { dicItemCode: 7, name: "7天内到期", dicItemName: "7天内到期" }, ]; -export const taskChecked = [ - { code: 0, name: "未通过", dicItemName: "未通过" }, - { code: 1, name: "通过", dicItemName: "通过" }, - { code: 2, name: "未处理", dicItemName: "未处理" }, -]; -//公告结束 \ No newline at end of file +export const taskModeIdArr = [ + { dicItemCode: 1, name: "单人悬赏", dicItemName: "单人悬赏" }, + { dicItemCode: 2, name: "多人悬赏", dicItemName: "多人悬赏" }, + { dicItemCode: 3, name: "计件悬赏", dicItemName: "计件悬赏" }, +] + + +export const sortArr = [{ + name: '综合', + type: 'default', +}, { + name: '最新', + type: 'createdAt', + icon: true, + desc: false, +}, +{ + name: '最热', + type: 'visits', + icon: true, + desc: false, +}, +{ + name: '价格', + type: 'bounty', + icon: true, + desc: false, +},]; + + + +export const formItemLayout = { + labelCol: { + xs: { span: 10 }, + sm: { span: 6 }, + lg: { span: 3 }, + }, + wrapperCol: { + xs: { span: 14 }, + sm: { span: 18 }, + lg: { span: 21 }, + }, +}; + +export const formModalLayout = { + labelCol: { + xs: { span: 10 }, + sm: { span: 6 }, + }, + wrapperCol: { + xs: { span: 14 }, + sm: { span: 18 }, + }, +}; + +export const tailFormItemLayout = { + wrapperCol: { + xs: { + span: 20, + offset: 4, + }, + sm: { + span: 20, + offset: 4, + }, + }, +}; \ No newline at end of file diff --git a/src/military/task/taskEdit/index.jsx b/src/military/task/taskEdit/index.jsx index b9fc91253..5d56b78e7 100644 --- a/src/military/task/taskEdit/index.jsx +++ b/src/military/task/taskEdit/index.jsx @@ -1,61 +1,122 @@ import React, { forwardRef, useCallback, useEffect, useState } from 'react'; -import { Form, Input, Select, Button, DatePicker } from 'antd'; -import moment from 'moment'; +import { Form, Radio, Input, InputNumber, Icon, Button, Modal } from 'antd'; +import classNames from 'classnames'; +import ReactWEditor from 'wangeditor-for-react'; +import { Link } from "react-router-dom"; import Upload from '../../components/Upload'; import { httpUrl } from '../../fetch'; -import { getDictionary, getTaskDetail, addTask, updateTask } from '../api'; +import { getTaskDetail, addTask, updateTask, getTaskCategory } from '../api'; +import {formItemLayout,tailFormItemLayout,formModalLayout}from '../static'; import './index.scss'; -const Option = Select.Option; -const { TextArea } = Input; -const format = "YYYY-MM-DD HH:mm:ss"; +let actionUrl = ''; +if (window.location.href.indexOf('localhost') > -1) { + actionUrl = httpUrl; +} -export default Form.create()(forwardRef(({current_user, form, showNotification, match, history }, ref) => { +export default Form.create()(forwardRef(({ current_user, form, showNotification, match, history }, ref) => { - const [requireType, setRequireType] = useState([]); - const [tagType, setTagType] = useState([]); + const [taskCategoryArr, setTaskCategoryArr] = useState([]); const [fileList, setFileList] = useState(null); - const [typeCode, setTypeCode] = useState(''); - const [typeName, setTypeName] = useState(''); + + const [publishMode, setPublishMode] = useState(0); + const [categoryId, setCategoryId] = useState('7'); + const [description, setDescription] = useState(''); + + const [visible, setVisible] = useState(false); + const [num, setNum] = useState(0) // 倒计时 + const [isSend, setIsSend] = useState(false) // 是否发送验证码 const id = match.params.requireId; const { getFieldDecorator, validateFields, setFieldsValue, } = form; + // 根据是否传id判断是新增还是修改 useEffect(() => { - id && getTaskDetail(id).then(data => { - const formValue = { - title: data.title, - attachments: data.attachments, - // typeCode: data.typeCode, //为使用select labelInValue,在代码中初始化值 - endTime: moment(data.endTime), - tag: data.tag, - remark: data.remark - }; - setFieldsValue(formValue); - setTypeName(data.typeName); - setTypeCode(data.typeCode) - if (data.attachmentList.length) { - for (const item of data.attachmentList) { - item.name = item.fileName; - item.size = item.fileSize; - item.uid = "rc-upload" + item.id + 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 = { + name: data.name, + contactName: data.contactName, + contactPhone: data.contactPhone, + uploadFileNumbers: data.uploadFileNumbers, + + bounty: data.bounty, + taskModeId: data.taskModeId, + collectionMode: data.collectionMode, + publishMode: data.publishMode, + + description: data.description, + collectingDays: data.collectingDays, + choosingDays: data.choosingDays, + makePublicDays: data.makePublicDays, + signingDays: data.signingDays, + payingDays: data.payingDays, + }; + + categoryId = data.categoryId; + if (data.attachmentList.length) { + for (const item of data.attachmentList) { + item.name = item.fileName; + item.size = item.fileSize; + item.uid = "rc-upload" + item.id + } + setFileList(data.attachmentList); } - setFileList(data.attachmentList); - } - }) + }); + } + setFieldsValue(formValue); + setCategoryId(categoryId); }, [id]); - // 加载选项数据 useEffect(() => { - getDictionary('requirement_type').then((res) => { - setRequireType(res.data); - }); - getDictionary("tag_type").then((res) => { - setTagType(res.data); + getTaskCategory().then(data => { + if (data) { + for (const item of data) { + item.dicItemCode = item.id; + item.dicItemName = item.name; + } + setTaskCategoryArr(data); + } }); }, []); + /** 倒计时显示*/ + useEffect(() => { + let timer = 0; + if (isSend && num !== 0) { + timer = setInterval(() => { + setNum(n => { + if (n === 1) { + setIsSend(false) + clearInterval(timer) + } + return n - 1; + }); + }, 1000); + } + return () => { + // 组件销毁时,清除定时器 + clearInterval(timer) + }; + }, [isSend]); + + function getCode(){ + setIsSend(true); + setNum(60); + } + // 上传附件后得到的文件数组 function UploadFunc(fileList) { setFileList(fileList); @@ -64,55 +125,50 @@ export default Form.create()(forwardRef(({current_user, form, showNotification, files.push(item.id || item.response.data.id); } setFieldsValue({ - attachments: files.join() + uploadFileNumbers: files.join() }); } const helper = useCallback( - (label, name, rules, widget, initialValue) => ( + (label, name, rules, widget, initialValue, rightComponent) => ( {getFieldDecorator(name, { rules, initialValue, validateFirst: true, })(widget)} + {rightComponent} ), []); - const formItemLayout = { - labelCol: { - xs: { span: 12 }, - sm: { span: 4 }, - }, - wrapperCol: { - xs: { span: 12 }, - sm: { span: 16 }, - }, - }; + const helperNoLabel = useCallback( + (title, name, rules, widget, initialValue) => ( +
+
{title}
+ + {getFieldDecorator(name, { rules, initialValue, validateFirst: true, })(widget)} + + +
+ ), []); - const tailFormItemLayout = { - wrapperCol: { - xs: { - span: 20, - offset: 4, - }, - sm: { - span: 20, - offset: 4, - }, - }, - }; + function changeHtml(html) { + setFieldsValue({ + description: html + }); + setDescription(html); + } - // 修改 + // 保存 function saveItem() { validateFields((error, values) => { if (!error) { let params = { ...values, - createUserAccount:current_user.login|| sessionStorage.getItem("SET_Account"), //用户信息 - createUserName:current_user.username|| sessionStorage.getItem("SET_NAME"), //模拟时使用莫胜吕 - typeName, - typeCode, - status: 0, //状态 + enterpriseName: '神马科技股份有限公司', + categoryId, }; - params.tag = params.tag.join(); - params.endTime = params.endTime.format(format); + let dateSum = params.collectingDays + params.choosingDays + params.makePublicDays + params.signingDays + params.payingDays; + if (dateSum > 180) { + showNotification("任务天数总和不得超过180天!"); + return; + } if (id) { // 编辑 params.id = id; @@ -139,108 +195,280 @@ export default Form.create()(forwardRef(({current_user, form, showNotification, }) } - function changeTypeName(value) { - setTypeCode(value.key); - setTypeName(value.label); - } + + + return (
-
- -
-
{id ? '修改' : '新增'}需求
-
-
- {helper( - "需求名称:", - "title", - [{ required: true, message: "请输入需求名称" }], - - )} - - {helper( - "需求类型:", - "typeCode", - [{ required: true, message: "请选择需求类别" }], - - , { key: typeCode, label: typeName })} - - {helper( - "结束时间:", - "endTime", - [{ required: true, message: "请输入结束时间" }], - - )} - - - - - {/* 用一个隐藏的input实现上传文件的必填校验 */} - {getFieldDecorator('attachments', { - rules: [{ required: true, message: "请上传需求文件" }], validateFirst: true - })()} - - - {helper( - "标签:", - "tag", - [{ required: true, message: "请选择需求标签" }], - - )} - - {helper( - "需求描述:", - "remark", - [{ required: true, message: "请输入需求描述" }], -