diff --git a/src/forge/Information/Pages/sourceCreate.jsx b/src/forge/Information/Pages/sourceCreate.jsx
new file mode 100644
index 00000000..ba6d6606
--- /dev/null
+++ b/src/forge/Information/Pages/sourceCreate.jsx
@@ -0,0 +1,233 @@
+import React,{ useState , useEffect } from 'react';
+import { Breadcrumb, Button, Form, Icon, Input, message, Select, Upload } from 'antd';
+import { getZoneUrl } from 'educoder';
+import '../index.scss';
+import { Link } from 'react-router-dom';
+import { getTypeByFileId, getSourceZoneList, addResource, getSourceDetailByAu, updateMyResource } from '../api';
+
+function SourceCreate(props){
+ const {history, id} = props;
+ const { getFieldDecorator, validateFields , setFieldsValue, setFields } = props.form;
+ const { deptId, sourceid} = props.match.params;
+ const pathname = props.location.pathname;
+ const [ zoneList , setZoneList ] = useState(undefined);
+ const [files, setFiles] = useState([]);
+ const [loadingBut, setLoadingBut] = useState(false);
+ const [isEdit, setIsEdit] = useState(false);
+
+ const layout = {
+ labelCol: { span: 2 },
+ wrapperCol: { span: 14 },
+ };
+
+ useEffect(()=>{
+ id && getZoneList();
+ },[id])
+
+ useEffect(()=>{
+ if(pathname){
+ if(pathname.endsWith("/edit")){
+ setIsEdit(true);
+ getSourceDetail();
+ }else{
+ setIsEdit(false);
+ }
+ }
+ },[pathname])
+
+ function getSourceDetail() {
+ getSourceDetailByAu(sourceid).then(res=>{
+ if(res && res.data){
+ const {name, domainId, summary, fileList} = res.data.data;
+ const fileMap = fileList.map(item=>{
+ const {fileId, fileSizeInfo, fileOriginName, zoneResourceType: {id, name}} = item;
+ return {
+ uid: fileId,
+ status: "done",
+ response: {fileId: fileId, fileSize: fileSizeInfo},
+ name: fileOriginName,
+ zoneResourceType:{id, name}
+ }
+ })
+ setFiles(fileMap);
+ setFieldsValue({
+ name,
+ domainId,
+ summary,
+ fileList: fileMap
+ });
+ }
+ })
+ }
+
+ function getZoneList(){
+ getSourceZoneList(id).then(response=>{
+ if(response && response.data){
+ setZoneList(response.data.rows);
+ }
+ }).catch(error=>{})
+ }
+
+ // 新建文章
+ function submit(e){
+ e.preventDefault();
+ validateFields((err, fieldsValue)=>{
+ if(err || !files.length){
+ !files.length && setFields({fileList: {value:undefined,errors:[new Error('请上传资源附件!')]}});
+ return;
+ }
+ const fileIds = files.map(item=>{return item.response.fileId}).toString();
+ const params = {
+ ...fieldsValue,
+ zoneId: id,
+ fileIds
+ }
+ delete params.fileList;
+ if(isEdit){
+ delete params.zoneId;
+ params.id= parseInt(sourceid, 10);
+ updateMyResource(params).then((res)=>{
+ const {data:{code, msg}} = res;
+ if(code === 200){
+ message.success("编辑成功");
+ history.push(`/zone/${deptId}/source/self`);
+ }else{
+ message.error(msg || '编辑失败,请联系管理员!')
+ }
+ })
+ return;
+ }
+ addResource(params).then((res)=>{
+ const {data:{code, msg}} = res;
+ if(code === 200){
+ message.success("新增成功");
+ history.push(`/zone/${deptId}/source/self`);
+ }else{
+ message.error(msg || '新增失败,请联系管理员!')
+ }
+ })
+ })
+ }
+
+ function beforeUpload(file){
+ if (file.size > 200 * 1024 * 1024) {
+ message.error('单个文件限制200MB以内');
+ return false;
+ }
+ if(files){
+ const sameNameFIles = files.filter(item=>item.name === file.name);
+ if(sameNameFIles.length >= 1){
+ message.error("请不要重复上传同名文件!");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ async function onChange({file, fileList: fileListByUpload}){
+ if(file && (file.status === "done" || file.status === 'uploading' || file.status === 'removed')){
+ setLoadingBut(true);
+ const fileList = [...files];
+ const index = fileList.findIndex(item=>item.uid === file.uid);
+ if(index !== -1){
+ fileList[index] = file;
+ }else{
+ fileList.push(file);
+ }
+ setFiles(fileList);
+ if(!file.response) return
+ if(file.response.code !== 200){
+ message.error(file.response.msg || '上传失败,请联系管理员!')
+ fileList.pop()
+ setFiles([...fileList]);
+ setLoadingBut(false);
+ }else{
+ // 获取此附件的资源类别
+ await getTypeByFileId(id, file.response.fileId).then((res)=>{
+ const {data:{code, data: data1, msg}} = res;
+ if(code !== 200){
+ return message.error(msg);
+ }
+ fileList[fileList.length-1].zoneResourceType = {
+ id: data1.id,
+ name: data1.name
+ }
+ })
+ setFiles([...fileList]);
+ setLoadingBut(false);
+ }
+ }
+ }
+
+ function deleteFile(uid){
+ const fileList = files.filter(item=>item.uid !== uid);
+ setFiles(fileList);
+ }
+
+ return(
+
+
+ 资源列表
+ {isEdit ? '编辑' : '新建'}资源
+
+
+
+ {getFieldDecorator("name", {
+ rules:[{ required:true,message:"请输入资源名称!" }]
+ })(
+
+ )}
+
+
+ {getFieldDecorator("domainId", {
+ rules:[{ required:true,message:"请选择资源领域!" }]
+ })(
+
+ )}
+
+
+ {getFieldDecorator("summary", {
+ rules:[{ required:true,message:"请输入资源简介!" }]
+ })(
+
+ )}
+
+
+ {getFieldDecorator("fileList", {
+ rules:[{ required:true,message:"请上传资源附件!" }]
+ })(
+
+
+
+ )}
+
+ {/* 附件展示 */}
+
+ {files && files.map((item, index)=>{
+ const {uid, status, response, name, zoneResourceType} = item;
+ return
+ {status === "uploading" ? : }
+ {name}
+ {response && response.fileSize}
+ {zoneResourceType && zoneResourceType.name}
+ {deleteFile(uid)}}/>
+
+ })}
+
+
+
+
+
+
+
+
+ )
+}
+export default Form.create()(SourceCreate);
\ No newline at end of file
diff --git a/src/forge/Information/api.js b/src/forge/Information/api.js
index 9a226ea5..2496268c 100644
--- a/src/forge/Information/api.js
+++ b/src/forge/Information/api.js
@@ -17,6 +17,13 @@ export function getCheckZoneRole(id) {
});
}
+export function getCurrentRole(id) {
+ return fetch({
+ url: `/zone/zoneFront/${id}/checkCurrentRole`,
+ method: 'get',
+ });
+}
+
/********首页接口******/
export function getHomePageList(id) {
return fetch({
@@ -115,6 +122,13 @@ export function applyJoin(id,data) {
}
// 资源模块
+export function addResource(data) {
+ return fetch({
+ url: `/zone/zoneFront/addResource`,
+ method: 'post',
+ data: data
+ });
+}
export function getSourceTypeList(id){
return fetch({
url:`/zone/open/${id}/resourceType/list`,
@@ -158,7 +172,82 @@ export function delSourceMyList(id){
export function postCreateZone(data) {
return fetch({
url: `/zone/application`,
+ })
+}
+
+// 根据文件id获取专区下资源类别
+export function getTypeByFileId(zoneId, fileId){
+ return fetch({
+ url:`/zone/resourceType/zone/${zoneId}/getResourceTypeByFileId/${fileId}`,
+ method: 'get'
+ })
+}
+
+// 新增领域
+export function addSourceType(data) {
+ return fetch({
+ url: `/zone/resourceType`,
method: 'post',
data: data
});
+}
+
+// 修改当前文件对应的资源类别
+export function updateResourceTypeByFileId(data) {
+ return fetch({
+ url: '/zone/resourceType/updateResourceTypeByFileId',
+ method: 'PUT',
+ data: data
+ });
+}
+
+// 获取文章领域列表
+export function getDirListById(id){
+ return fetch({
+ url:`/cms/doc/open/zone/${id}/dirList`,
+ method: 'get'
+ })
+}
+
+// 新增文章
+export function addNewsByDirId(dirId, data) {
+ return fetch({
+ url: `/cms/doc/dir/${dirId}`,
+ method: 'post',
+ data: data
+ });
+}
+
+// 获取文章详细信息(需要用户权限)
+export function getNewsDetailByAu(id){
+ return fetch({
+ url:`/cms/doc/${id}`,
+ method: 'get',
+ })
+}
+
+// 修改文章详细信息(需要用户权限)
+export function updateDoc(id, data) {
+ return fetch({
+ url: `/cms/doc/${id}`,
+ method: 'PUT',
+ data: data
+ });
+}
+
+// 获取资源详细信息(需要用户权限)
+export function getSourceDetailByAu(id){
+ return fetch({
+ url:`/zone/zoneFront/myResource/${id}`,
+ method: 'get',
+ })
+}
+
+// 修改资源详细信息(需要用户权限)
+export function updateMyResource(data) {
+ return fetch({
+ url: `/zone/zoneFront/editResource`,
+ method: 'PUT',
+ data: data
+ });
}
\ No newline at end of file
diff --git a/src/forge/Information/fetch.js b/src/forge/Information/fetch.js
index 897cc41d..29cc15d2 100644
--- a/src/forge/Information/fetch.js
+++ b/src/forge/Information/fetch.js
@@ -7,7 +7,6 @@ function beforeFetch(actionUrl){
}
const service = axios.create({
- headers:{Authorization:"a57ec217a1963611f9a0ff591b305dc3d5b3ba1f"},
baseURL: actionUrl,
timeout: 1800000, // 请求超时时间
});
diff --git a/src/forge/Information/index.jsx b/src/forge/Information/index.jsx
index 14960da6..121f1755 100644
--- a/src/forge/Information/index.jsx
+++ b/src/forge/Information/index.jsx
@@ -8,7 +8,7 @@ import { CNotificationHOC } from "../../modules/courses/common/CNotificationHOC"
import { TPMIndexHOC } from "../../modules/tpm/TPMIndexHOC";
import Loadable from "react-loadable";
import Loading from "../../Loading";
-import { getMainInfos , getCheckZoneRole } from './api';
+import { getMainInfos , getCheckZoneRole, getCurrentRole } from './api';
import PublicBanner from "./Component/publicBanner";
import './index.scss';
import { IsPC } from 'educoder';
@@ -21,6 +21,10 @@ const SourceDetail = Loadable({
loader: () => import("./Pages/sourceDetail"),
loading: Loading,
});
+const SourceCreate = Loadable({
+ loader: () => import("./Pages/sourceCreate"),
+ loading: Loading,
+});
const VIP = Loadable({
loader: () => import("./Pages/zoneVIP"),
loading: Loading,
@@ -64,6 +68,10 @@ const NewsList = Loadable({
loader: () => import("./Pages/newsList"),
loading: Loading,
});
+const NewsCreate = Loadable({
+ loader: () => import("./Pages/newsCreate"),
+ loading: Loading,
+});
const Main = Loadable({
loader: () => import("./Pages/main"),
@@ -81,8 +89,10 @@ function Index(props){
const { deptId } = props.match.params;
const [ id , setId ] = useState(undefined);
const [ temp , setTemp ] = useState(tempEnum.zone);
+ const [ role , setRole ] = useState(undefined);
const { pathname } = props.history.location;
const sourcedetail = pathname.indexOf(`/zone/${deptId}/newdetail/`)>-1 && IsPC();
+ const {current_user} = props;
useEffect(()=>{
if(deptId && deptId!=="apply"){
@@ -115,6 +125,7 @@ function Index(props){
setId(data.id);
if(data.id){
getAdminUrl(data.id);
+ getRole(data.id)
}
}
}).catch(console.error())
@@ -129,6 +140,15 @@ function Index(props){
}
}).catch(error=>{})
}
+
+ function getRole(id){
+ if(current_user && current_user.login){
+ getCurrentRole(id).then(res=>{
+ setRole(res.data.data);
+ }).catch(error=>{})
+ }
+ }
+
return(
{ (!sourcedetail && deptId!=="apply") && (id ?
: )}
@@ -139,10 +159,22 @@ function Index(props){
)}
>
+ (
+
+ )}
+ >
+ (
+
+ )}
+ >
(
-
+
)}
>
)}
>
+ (
+
+ )}
+ >
+ (
+
+ )}
+ >
(
@@ -166,7 +210,7 @@ function Index(props){
(
-
+
)}
>
(
-
+
)}
>
{data && data.helperShow === 1 && {
+export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, className = '', noStorage = false, imageExpand = true, placeholder = '', width = '100%', height = 400, initValue = '', emoji, watch=true, showNullButton = false, showResizeBar = false, startInit = true , forMember = true , isCanAtme = false , isQuoteIssue = false , changeAtWhoLoginList, owner, projectsId , isFocus = true, showLatexButton = true}) => {
const editorEl = useRef();
const resizeBarEl = useRef();
@@ -353,7 +354,7 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: getUploadActionUrl(),
toolbarIcons: function () {
- return showNullButton ? [...mdIcons, 'null-button'] : mdIcons
+ return showLatexButton ? mdIconsHasLatex : mdIcons
},
toolbarIconsClass: {
"line-break": "fa-minus",
From 09f695fb2d944fcd1f60d900cde9f424b7f8fe73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com>
Date: Thu, 21 Sep 2023 09:55:53 +0800
Subject: [PATCH 6/7] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E8=BA=AB?=
=?UTF-8?q?=E4=BB=BD=E6=8C=89=E9=92=AE=E6=96=87=E6=A1=88=E6=94=B9=E4=B8=BA?=
=?UTF-8?q?=E7=AE=A1=E7=90=86XX?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/forge/Information/Pages/main.jsx | 16 ++++------------
src/forge/Information/Pages/source.jsx | 2 +-
src/forge/Information/fetch.js | 2 ++
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/forge/Information/Pages/main.jsx b/src/forge/Information/Pages/main.jsx
index 668aee4b..0952af04 100644
--- a/src/forge/Information/Pages/main.jsx
+++ b/src/forge/Information/Pages/main.jsx
@@ -29,10 +29,10 @@ function Main(props){
const menu = (
);
@@ -56,14 +56,6 @@ function Main(props){
}
}, [newCateId])
- function addNew(type){
- if(role && role.role === "Manager"){
- window.open(role.docManageUrl);
- }else{
- history.push(`/zone/${deptId}/news/add?type=${type}`)
- }
- }
-
function getMainList(){
getNewsAllList(id).then(result=>{
if(result){
@@ -134,9 +126,9 @@ function Main(props){
{role.role === "Member" && }
-
+ {role.role === "Member" ?
-
+ : }
}
{
diff --git a/src/forge/Information/Pages/source.jsx b/src/forge/Information/Pages/source.jsx
index 266c6f15..eed911c1 100644
--- a/src/forge/Information/Pages/source.jsx
+++ b/src/forge/Information/Pages/source.jsx
@@ -95,7 +95,7 @@ function Source(props){
{role.role === "Member" &&