From a4d38f8c8608f8b504f3b743e24d6f573a93b25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Tue, 6 Jul 2021 21:28:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BD=90=E8=AF=81=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E4=B8=8E=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/military/fetch.js | 1 - src/military/task.js | 12 ++ src/military/task/api.js | 34 ++++ .../task/components/itemListMyTask/index.jsx | 7 +- .../task/components/itemListPaper/index.jsx | 6 +- .../task/components/itemProofManage/index.jsx | 181 ++++++++++++++++++ .../components/itemProofManage/index.scss | 33 ++++ .../task/components/proofModal/index.jsx | 137 ++++++++++++- .../task/components/proofModal/index.scss | 31 +++ src/military/task/index.scss | 8 +- src/military/task/myTask/index.jsx | 12 +- src/military/task/proofManage/index.js | 152 +++++++++++++++ src/military/task/static.js | 6 + src/military/task/taskDetail/index.jsx | 4 +- src/military/task/taskEdit/index.jsx | 5 +- 15 files changed, 604 insertions(+), 25 deletions(-) create mode 100644 src/military/task/components/itemProofManage/index.jsx create mode 100644 src/military/task/components/itemProofManage/index.scss create mode 100644 src/military/task/proofManage/index.js diff --git a/src/military/fetch.js b/src/military/fetch.js index da73e6fd..cded7401 100644 --- a/src/military/fetch.js +++ b/src/military/fetch.js @@ -3,7 +3,6 @@ import axios from 'axios'; import cookie from 'react-cookies'; - let actionUrl = ''; if (window.location.href.indexOf('localhost') > -1) { actionUrl='http://117.50.100.12:8008'; diff --git a/src/military/task.js b/src/military/task.js index 4eaaa264..29f15168 100644 --- a/src/military/task.js +++ b/src/military/task.js @@ -46,6 +46,11 @@ const PaperComplain = Loadable({ loading: Loading, }); +const ProofManage = Loadable({ + loader: () => import("./task/proofManage"), + loading: Loading, +}); + const Index = (propsTransmit) => { // 开发时,从代理的位置获取用户信息 const [currentUser, setCurrentUser] = useState(null); @@ -115,6 +120,13 @@ const Index = (propsTransmit) => { )} > + ( + + )} + > + ( diff --git a/src/military/task/api.js b/src/military/task/api.js index 29d2df67..f06d9535 100644 --- a/src/military/task/api.js +++ b/src/military/task/api.js @@ -298,3 +298,37 @@ export function checkComplain(data){ } +// 佐证上传 +export function proofAdd(data){ + return fetch({ + url: `/api/taskResultProof/addTaskResultProof`, + method: 'post', + data, + }); +} + +// 审核佐证材料列表查询 +export async function proofList(params) { + let res = await fetch({ + url: '/api/tasks/backend/proofList', + method: 'get', + params, + }); + if (res.data) { + return res.data; + } else { + notification.open({ + message: "提示", + description: res.message || '请求错误', + }); + } +} + +// 审核佐证 +export function checkProof(data){ + return fetch({ + url: `/api/taskResultProof/adminCheckResultAndProof`, + method: 'post', + data, + }); +} \ No newline at end of file diff --git a/src/military/task/components/itemListMyTask/index.jsx b/src/military/task/components/itemListMyTask/index.jsx index f1f1cc7e..0e51924c 100644 --- a/src/military/task/components/itemListMyTask/index.jsx +++ b/src/military/task/components/itemListMyTask/index.jsx @@ -13,11 +13,11 @@ for (const item of taskStatusAllArr) { statusArr[item.dicItemCode] = item.dicItemName; } export default (props) => { - const { list, curPage, total, changePage, taskCategoryValueArr, loading, publish, } = props; + const { list, curPage, total, changePage, taskCategoryValueArr, loading, publish, showNotification ,reloadList} = props; const [page, setPage] = useState(1); const [visibleProofs, setVisibleProofs] = useState(false); - const [taskId, setTaskId] = useState({}); + const [taskId, setTaskId] = useState(); const pageSize = props.pageSize || 10; useEffect(() => { @@ -36,6 +36,7 @@ export default (props) => { }) } + return ( @@ -116,6 +117,8 @@ export default (props) => { taskId={taskId} visible={visibleProofs} changeVisible={setVisibleProofs} + showNotification={showNotification} + reloadList={reloadList} /> diff --git a/src/military/task/components/itemListPaper/index.jsx b/src/military/task/components/itemListPaper/index.jsx index 469f7d44..a212ebb2 100644 --- a/src/military/task/components/itemListPaper/index.jsx +++ b/src/military/task/components/itemListPaper/index.jsx @@ -106,7 +106,7 @@ export default Form.create()((props) => { if (!error) { let files = []; for (const item of fileList) { - files.push(item.id || item.response.data.id); + files.push(item.id || (item.response.data && item.response.data.id)); } complainPaper({ paperId: checkedItem.id, @@ -171,12 +171,12 @@ export default Form.create()((props) => { - + { - item.paperDetail.busiAttachments && item.paperDetail.busiAttachments.map(fileItem => { + item.paperDetail && item.paperDetail.busiAttachments && item.paperDetail.busiAttachments.map(fileItem => { return { downFile(fileItem) }}> {fileItem.fileName} diff --git a/src/military/task/components/itemProofManage/index.jsx b/src/military/task/components/itemProofManage/index.jsx new file mode 100644 index 00000000..7bfbc6f0 --- /dev/null +++ b/src/military/task/components/itemProofManage/index.jsx @@ -0,0 +1,181 @@ +import React, { useEffect, useState } from 'react'; +import { Pagination, Modal, Input } from 'antd'; +import { Link } from "react-router-dom"; +import Nodata from 'forge/Nodata'; +import Loading from "src/Loading"; +import { timeAgo } from 'educoder'; +import { checkProof } from '../../api'; +import { httpUrl } from 'military/fetch'; +import './index.scss'; +import winpng from '../../image/win.png'; + +const { TextArea } = Input; +export default (props) => { + const { list, curPage, total, changePage, loading, showNotification, reloadList } = props; + const [checkedItem, setCheckedItem] = useState(''); + const [page, setPage] = useState(1); + const [visible, setVisible] = useState(false); + const [advice, setRepairAdvice] = useState(''); + const pageSize = props.pageSize || 10; + + useEffect(() => { + changePage(page); + }, [page]); + + + function agreeClick(item) { + Modal.confirm({ + title: '是否确认审批通过?', + onOk() { + checkProof({ + id: item.taskResultProof.id, + isPassed: 1, + taskId: item.id, + advice: "", + }).then(res => { + if (res && res.message === 'success') { + showNotification('操作成功'); + reloadList(); + } + }) + } + }); + } + + function refuseClick(item) { + setCheckedItem(item); + setVisible(true); + } + + function refuse() { + if (!advice) { + showNotification('请输入拒绝的理由'); + return; + } + checkProof({ + id: checkedItem.taskResultProof.id, + taskId: checkedItem.id, + isPassed: 0, + advice: advice + }).then(res => { + if (res && res.message === 'success') { + showNotification('操作成功'); + reloadList(); + setRepairAdvice(''); + setVisible(false); + } + }); + } + + function goUser(login) { + window.location.href = `/users/${login}`; + } + + function goUserMes(login) { + window.location.href = `/users/${login}/message_detail`; + } + + function downFile(item) { + let url = httpUrl + '/busiAttachments/download/' + item.id; + window.open(url); + } + + return ( + loading ? : + + { + list.map(item => { + return ( + + + + + + { goUser(item.user.login) }}>{item.user.nickname || item.user.login} + {timeAgo(item.createdAt)} + + 主体名称: + {item.enterpriseName} + + + {item.taskResultProof.status === 1 && 已同意} + {item.taskResultProof.status === 0 && 已拒绝} + + { + item.taskResultProof.status === 2 && + { goUserMes(item.user.login) }}>私信 + { agreeClick(item) }}>同意 + { refuseClick(item) }}>拒绝 + + } + + + + + 任务编号: + {item.number} + + {item.name} + + + + + + 评选胜出({item.taskResultProof.winnerName.split(',').length}): + {item.taskResultProof.winnerName} + + + + 佐证材料: + { + item.taskProofAttachments && item.taskProofAttachments.map(fileItem => { + return + { downFile(fileItem) }}> + {fileItem.fileName} + ({fileItem.fileSizeString}) + + }) + } + + + {item.taskResultProof.status === 0 && 拒绝原因:test1111} + + + + + ) + }) + } + + {list.length > 0 ? + + {total > pageSize && { setPage(page) }} + current={curPage} + total={total} + showTotal={total => `共 ${total} 条`} + />} + : + } + + { setVisible(false) }} + className="form-edit-modal" + > + { setRepairAdvice(e.target.value) }} + maxLength={200} + /> + + + + ) +} \ No newline at end of file diff --git a/src/military/task/components/itemProofManage/index.scss b/src/military/task/components/itemProofManage/index.scss new file mode 100644 index 00000000..1848c2d2 --- /dev/null +++ b/src/military/task/components/itemProofManage/index.scss @@ -0,0 +1,33 @@ +.list-box { + position: relative; + display: flex; + justify-content: space-between; + padding: 20px; + margin: 0 1.5rem; + background: #fff; + border-bottom: 1px solid #dedede; + a.edu-orangeline-btn { + padding: 0px 10px; + } +} + +a.primary-link { + color: #1890ff; +} + +.infos_item { + float: left; + max-width: 273px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + color: #343434; + margin-right: 6px; + line-height: 35px; + margin-left: 5px; +} + +.file-list-prof{ + background: #fafafa; + padding:.25rem .5rem; +} diff --git a/src/military/task/components/proofModal/index.jsx b/src/military/task/components/proofModal/index.jsx index 5022c6a6..a63c8adc 100644 --- a/src/military/task/components/proofModal/index.jsx +++ b/src/military/task/components/proofModal/index.jsx @@ -1,15 +1,17 @@ -import React, { useEffect, useState, useCallback } from 'react'; +import React, { useEffect, useState, useCallback, useMemo } from 'react'; import { Modal, Table, Radio, Form, Input, Button, Pagination } from 'antd'; import { Link } from "react-router-dom"; import Nodata from 'forge/Nodata'; import Loading from "src/Loading"; -import { getTaskPaper } from "../../api"; +import Upload from 'military/components/Upload'; +import { getTaskPaper, proofAdd } from "../../api"; +import { httpUrl } from 'military/fetch'; import '../../index.scss'; import './index.scss'; export default Form.create()((props) => { - const { changeVisible, taskId, visible, form } = props; + const { changeVisible, taskId, visible, form, showNotification,reloadList } = props; const { getFieldDecorator, validateFields, setFieldsValue, } = form; const pageSize = props.pageSize || 10; @@ -19,13 +21,17 @@ export default Form.create()((props) => { const [total, setTotal] = useState(0); const [dataList, setDataList] = useState([]); + const [fileList, setFileList] = useState([]); + const [selectedRows, setSelectedRows] = useState([]); + // 获取成果列表 useEffect(() => { setLoading(true); let params = { + ...searchObj, taskId, orderBy: '', - pageSize: 10, + pageSize, curPage, status: '', } @@ -39,7 +45,7 @@ export default Form.create()((props) => { setLoading(false); setTotal(data.total); }); - }, [taskId, curPage,]); + }, [taskId, curPage,]); const helper = useCallback( @@ -66,14 +72,100 @@ export default Form.create()((props) => { setSearchObj({}); } + // 上传附件后得到的文件数组 + function UploadFunc(fileList) { + setFileList(fileList); + } + + + const columns = useMemo(() => { + return [{ + title: '作者', + dataIndex: 'name', + render: (text, record) => { + return record.user ? record.user.nickname || record.user.login : '' + } + }, + { + title: '成果物编号', + dataIndex: 'number', + }, + { + title: '更新时间', + dataIndex: 'updatedAt', + }, + { + title: '操作', + dataIndex: 'action', + render: (text, record) => { + return 查看详情 + } + }]; + }, [taskId]); + + const rowSelection = { + onChange: (selectedRowKeys, selectedRows) => { + setSelectedRows(selectedRows); + // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); + }, + }; + + const handleRow = record => { + return { + onClick: event => { + event.currentTarget.getElementsByClassName("ant-checkbox-wrapper")[0].click(); + }, + }; + }; + + function proofItem() { + if (!selectedRows.length) { + showNotification("请至少选择一条数据!"); + } + if (!fileList && !fileList.length) { + showNotification("请上传文件!"); + } + + let files = []; + for (const item of fileList) { + files.push(item.id || (item.response.data && item.response.data.id)); + } + + let paperNumber = []; + let winnerIds = []; + let winnerName = []; + + for (const item of selectedRows) { + paperNumber.push(item.number); + winnerIds.push(item.user.id); + winnerName.push(item.user.nickname || item.user.login); + } + + let params = { + paperNumber: paperNumber.join(), + winnerIds: winnerIds.join(), + winnerName: winnerName.join(), + proofFileNumbers: files.join(), + status: 2, + taskId, + }; + proofAdd(params).then(res => { + if (res && res.message === 'success') { + changeVisible(false); + reloadList(); + } + }); + } + return ( { changeVisible(false) }} - className="task-manage proof-modal" + className="proof-modal" + draggable={true} > 选出胜出者* @@ -95,7 +187,38 @@ export default Form.create()((props) => { 搜索 清除 + row.id} + dataSource={dataList} + columns={columns} + pagination={false} + rowSelection={{ + type: 'checkbox', + ...rowSelection, + }} + onRow={handleRow} + /> + {total > 10 && + { setCurPage(page) }} + current={curPage} + total={total} + />} + + + {/* {getFieldDecorator('files', { + validateFirst: true + })()} */} + diff --git a/src/military/task/components/proofModal/index.scss b/src/military/task/components/proofModal/index.scss index e69de29b..36e7e261 100644 --- a/src/military/task/components/proofModal/index.scss +++ b/src/military/task/components/proofModal/index.scss @@ -0,0 +1,31 @@ +.proof-modal { + min-width: 800px; + width: 80vw; + .ant-form-item-control { + width: 200px; + } + .center-right-but { + .ant-form-item { + margin: 0 1rem 0 0; + } + } + .ant-table-thead > tr > th, + tr > td { + text-align: center; + } + .commentStyle { + .ant-upload { + max-width: 500px; + width: 60vw; + margin-top: 1rem ; + } + .ant-upload-list{ + max-width: 500px; + width: 60vw; + } + + } + .ant-form-item{ + margin-bottom: 0; + } +} diff --git a/src/military/task/index.scss b/src/military/task/index.scss index 9aaefd11..31148de9 100644 --- a/src/military/task/index.scss +++ b/src/military/task/index.scss @@ -71,10 +71,4 @@ text-align: center; } -.proof-modal{ - min-width: 800px; - width: 80vw; - .ant-form-item-control{ - width: 200px; - } -} + diff --git a/src/military/task/myTask/index.jsx b/src/military/task/myTask/index.jsx index cd848455..e2f5f648 100644 --- a/src/military/task/myTask/index.jsx +++ b/src/military/task/myTask/index.jsx @@ -18,7 +18,7 @@ for (const item of taskStatusAllArr) { statusArr[item.dicItemCode] = item.dicItemName; } -export default ({ location, history, current_user }) => { +export default ({ location, history, current_user,showNotification }) => { let defaultValue = decodeURI(location.search.split("=")[1] || ""); const [identity, setIdentity] = useState('1'); @@ -37,6 +37,7 @@ export default ({ location, history, current_user }) => { const [total, setTotal] = useState(0); const [myTaskList, setMyTaskList] = useState([]); const [loading, setLoading] = useState(false); + const [reload,setReload]=useState(0); // 获取任务领域数组 useEffect(() => { @@ -67,7 +68,7 @@ export default ({ location, history, current_user }) => { } setLoading(false); }) - }, [statusString, searchInput, orderBy, curPage]); + }, [statusString, searchInput, orderBy, curPage ,reload]); function taskClick(id) { history.push(`/task/taskDetail/${id}`); @@ -102,6 +103,9 @@ export default ({ location, history, current_user }) => { setStatusType(key); } + const reloadList=useCallback(()=>{ + setReload(reload+1); + },[]); return ( @@ -137,6 +141,8 @@ export default ({ location, history, current_user }) => { changePage={(page) => { setCurPage(page) }} loading={loading} publish={true} + showNotification={showNotification} + reloadList={reloadList} /> @@ -156,6 +162,8 @@ export default ({ location, history, current_user }) => { taskCategoryValueArr={taskCategoryValueArr} changePage={(page) => { setCurPage(page) }} loading={loading} + showNotification={showNotification} + reloadList={reloadList} /> diff --git a/src/military/task/proofManage/index.js b/src/military/task/proofManage/index.js new file mode 100644 index 00000000..900a8c31 --- /dev/null +++ b/src/military/task/proofManage/index.js @@ -0,0 +1,152 @@ +import React, { useCallback, forwardRef, useEffect, useState } from 'react'; +import { Input, Button, Form } from 'antd'; +import ItemProofManage from '../components/itemProofManage'; +import StatusNav from '../../components/statusNav'; +import { proofArr } from '../static'; +import { proofList, } from '../api'; +import '../index.scss'; + +const proofArrCheck=proofArr.slice(0,2); +export default Form.create()(({ current_user, form, showNotification, match, history }) => { + const { getFieldDecorator, validateFields, setFieldsValue } = form; + const [approve, setApprove] = useState(1); + const [loading, setLoading] = useState(false); + const [searchObj, setSearchObj] = useState({}); + const [proofStatusString, setProofStatusString] = useState('2'); + const [curPage, setCurPage] = useState(1); + const [total, setTotal] = useState(0); + const [taskList, setTaskList] = useState([]); + + const [reload, setReload] = useState(0); + + useEffect(() => { + const params = { + ...searchObj, + proofStatusString, + orderBy: 'createdAtDesc', + curPage, + pageSize: 10, + }; + setLoading(true); + proofList(params).then(data => { + if (data) { + setTaskList(data.rows); + setTotal(data.total); + } + setLoading(false); + }) + }, [reload, proofStatusString, curPage, searchObj]); + + + const helper = useCallback( + (name, rules, widget) => ( + + {getFieldDecorator(name, { rules, validateFirst: true, })(widget)} + + ), []); + + + function onSearch() { + validateFields((err, values) => { + if (!err) { + setSearchObj(values); + } + }); + } + + const changeOptionId = useCallback((option) => { + setProofStatusString(option.dicItemCode.toString() || '0,1'); + setCurPage(1); + }, []); + + function changeApprove(approve) { + setApprove(approve); + setCurPage(1); + if (approve === 1) { + setProofStatusString('2'); + } else { + setProofStatusString('0,1'); + } + } + + function clearSearch() { + setFieldsValue({ + numberInput: '', + nameInput: '', + enterpriseNameInput: '' + }); + setSearchObj({}); + } + + const reloadList = useCallback(() => { + setReload(reload + 1); + }, []) + + return ( + + + + + { changeApprove(1) }}>待审批 + { changeApprove(2) }}>已审批 + + + + {helper( + "numberInput", + [{ max: 20, message: '长度不能超过20个字符' }], + + )} + + {helper( + "nameInput", + [{ max: 20, message: '长度不能超过20个字符' }], + + )} + + {helper( + "enterpriseNameInput", + [{ max: 20, message: '长度不能超过20个字符' }], + + )} + + 搜索 + 清除 + + + + + + + + { + approve === 2 && + } + { setCurPage(page) }} + loading={loading} + showNotification={showNotification} + reloadList={reloadList} + /> + + + + + + ) +} +) \ No newline at end of file diff --git a/src/military/task/static.js b/src/military/task/static.js index 22389a0a..da98b586 100644 --- a/src/military/task/static.js +++ b/src/military/task/static.js @@ -35,6 +35,12 @@ export const approveArr = [ { dicItemCode: '9', name: "待修缮", dicItemName: "待修缮" }, ] +export const proofArr = [ + { dicItemCode: 1, name: "已同意", dicItemName: "已同意" }, + { dicItemCode: 0, name: "已拒绝", dicItemName: "已拒绝" }, + { dicItemCode: 2, name: "待审核", dicItemName: "待审核" }, +] + export const publishModeArr=["自主提交","统筹任务"]; export const sortArr = [{ diff --git a/src/military/task/taskDetail/index.jsx b/src/military/task/taskDetail/index.jsx index 4bff220b..61ae2c44 100644 --- a/src/military/task/taskDetail/index.jsx +++ b/src/military/task/taskDetail/index.jsx @@ -143,7 +143,7 @@ export default Form.create()( id && getTaskPaper(params).then(data => { if (data && Array.isArray(data.rows)) { for (const item of data.rows) { - item.detail = item.paperDetail.content; + item.detail = item.paperDetail?item.paperDetail.content:""; } } setDataList(data.rows || []); @@ -204,7 +204,7 @@ export default Form.create()( setFileList(fileList); let files = []; for (const item of fileList) { - files.push(item.id || item.response.data.id); + files.push(item.id || (item.response.data && item.response.data.id)); } setFieldsValue({ files: files.join() diff --git a/src/military/task/taskEdit/index.jsx b/src/military/task/taskEdit/index.jsx index ff5a3e97..dcc565a2 100644 --- a/src/military/task/taskEdit/index.jsx +++ b/src/military/task/taskEdit/index.jsx @@ -147,7 +147,10 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification, setFileList(fileList); let files = []; for (const item of fileList) { - item && files.push(item.id || item.response.data.id); + if (item) { + let itemId = (item.response && item.response.data && item.response.data.id) || item.id; + itemId && files.push(itemId); + } } setFieldsValue({ uploadFileNumbers: files.join()
拒绝原因:test1111