Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sass-admin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晨
sass-admin
Commits
7f08f57f
Commit
7f08f57f
authored
Sep 03, 2025
by
end
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改工作台
parent
449fe173
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
1354 additions
and
270 deletions
+1354
-270
dist.zip
+0
-0
src/pages/SystemManagement/Information/addEditForm.jsx
+2
-2
src/pages/TrainingPrograms/ProgeamsManage/Plan/Addactivity/SurveyAddactivity.jsx
+7
-17
src/pages/TrainingPrograms/ProgeamsManage/Plan/Addplan.jsx
+1
-14
src/pages/TrainingPrograms/ProgeamsManage/Plan/Content.jsx
+5
-148
src/pages/TrainingPrograms/ProgeamsManage/Plan/Plan.jsx
+6
-41
src/pages/TrainingPrograms/ProgeamsManage/redux/trainingActivityListAction.js
+1
-1
src/pages/TrainingPrograms/ProgeamsManage/redux/trainingPalnAction.js
+1
-29
src/pages/TrainingTools/Question/Create/AddTest.jsx
+1
-1
src/pages/TrainingTools/Question/Create/TestModal.jsx
+0
-0
src/pages/TrainingTools/Question/Details/index.jsx
+1
-1
src/pages/TrainingTools/Question/UpLoad/SystemUpload.js
+143
-0
src/pages/TrainingTools/Question/UpLoad/UploadUtil.jsx
+180
-0
src/pages/TrainingTools/Question/UpLoad/api.js
+15
-0
src/pages/TrainingTools/Question/UpLoad/buttonUpload.js
+151
-0
src/pages/TrainingTools/Question/UpLoad/butupload.js
+175
-0
src/pages/TrainingTools/Question/UpLoad/index.js
+320
-0
src/pages/TrainingTools/Question/UpLoad/index.less
+61
-0
src/pages/TrainingTools/Question/UpLoad/plupload.js
+145
-0
src/pages/TrainingTools/Question/UpLoad/redux/actionTypes.js
+9
-0
src/pages/TrainingTools/Question/UpLoad/redux/actions.js
+89
-0
src/pages/TrainingTools/Question/UpLoad/redux/reduter.js
+40
-0
src/pages/TrainingTools/Question/index.jsx
+0
-15
src/pages/TrainingTools/exam/questionBank/question/importBtn.jsx
+1
-1
No files found.
dist.zip
View file @
7f08f57f
No preview for this file type
src/pages/SystemManagement/Information/addEditForm.jsx
View file @
7f08f57f
...
...
@@ -473,7 +473,7 @@ class addEdit extends React.Component {
)
}
</
FormItem
>
))
}
{
type
!=
"look"
&&
{
/* {
type != "look" &&
type != "edit" &&
this.state.lists.map((item, index) => {
return (
...
...
@@ -537,7 +537,7 @@ class addEdit extends React.Component {
)}
</FormItem>
);
})
}
})}
*/
}
<
FormItem
{
...
formItemLayout
}
label=
"作者"
>
{
getFieldDecorator
(
"author"
,
{
initialValue
:
seeEdit
&&
seeEdit
.
author
,
...
...
src/pages/TrainingPrograms/ProgeamsManage/Plan/Addactivity/SurveyAddactivity.jsx
View file @
7f08f57f
import
React
from
"react"
;
import
{
connect
}
from
"react-redux"
;
import
{
getSurveylist
}
from
"../../redux/trainingActivityListAction"
;
import
{
Table
,
Button
,
Input
,
Col
,
Row
,
Pagination
}
from
"antd"
;
const
Search
=
Input
.
Search
;
function
handleChange
(
value
)
{
console
.
log
(
`selected
${
value
}
`
);
}
function
handleBlur
()
{
console
.
log
(
"blur"
);
}
function
handleFocus
()
{
console
.
log
(
"focus"
);
}
import
{
Table
,
Pagination
}
from
"antd"
;
const
columns
=
[
{
title
:
"活动时间"
,
...
...
@@ -154,12 +141,15 @@ class SurveyAddactivity extends React.Component {
});
}
render
()
{
const
{
visible
,
loading
}
=
this
.
state
;
const
{
surveylist
,
activitylist
}
=
this
.
props
;
const
{
selectedRowKeys
}
=
this
.
state
;
console
.
log
(
activitylist
,
surveylist
,
'222222222222'
);
const
rowSelection
=
{
selectedRowKeys
,
onChange
:
this
.
onSelectChange
,
getCheckboxProps
:
record
=>
({
disabled
:
activitylist
.
some
(
item
=>
item
.
id
===
record
.
id
),
}),
};
return
(
<
div
>
...
...
@@ -170,7 +160,7 @@ class SurveyAddactivity extends React.Component {
marginTop
:
"20px"
,
}
}
>
<
div
style=
{
{
display
:
"inline-flex"
,
width
:
"45%"
}
}
>
{
/*
<div style={{ display: "inline-flex", width: "45%" }}>
<Col span={24}>
<Search
placeholder="请输入投票名称"
...
...
@@ -181,7 +171,7 @@ class SurveyAddactivity extends React.Component {
</Col>
<Col span={2} />
<Col span={5} />
</
div
>
</div>
*/
}
<
div
style=
{
{
marginTop
:
"20px"
}
}
>
<
Table
rowSelection=
{
rowSelection
}
...
...
src/pages/TrainingPrograms/ProgeamsManage/Plan/Addplan.jsx
View file @
7f08f57f
...
...
@@ -2,21 +2,7 @@ import React from "react";
import
{
Tabs
,
Button
}
from
"antd"
;
import
{
connect
}
from
"react-redux"
;
import
{
addActivity
}
from
"../redux/trainingPalnAction"
;
import
Course
from
"./Addactivity/CourseAddactivity.jsx"
;
import
Exam
from
"./Addactivity/ExamAddactivity.jsx"
;
import
Survey
from
"./Addactivity/SurveyAddactivity.jsx"
;
import
Vote
from
"./Addactivity/VoteAddactivity.jsx"
;
import
Live
from
"./Addactivity/LiveAddactivity.jsx"
;
import
Homework
from
"./Addactivity/HomeworkAddactivity.jsx"
;
import
Certificate
from
"./Addactivity/CertificateAddactivity.jsx"
;
import
Url
from
"./Addactivity/UrlAddactivity.jsx"
;
import
UnderLineActivety
from
"./Addactivity/UnderLineActivety"
;
//线下课程
import
Caseactive
from
"./Addactivity/Caseactivities"
;
//线下课程
import
Selectcase
from
"./Addactivity/Selectedcase"
;
//原创活动、精选作品
import
DataBaseActivity
from
"./Addactivity/DataBaseActivity"
;
//资料库
import
PostingsAddActivities
from
"./Addactivity/PostingsAddActivities"
;
//帖子
import
intl
from
"react-intl-universal"
;
const
TabPane
=
Tabs
.
TabPane
;
function
callback
(
key
)
{
...
...
@@ -68,6 +54,7 @@ class addplan extends React.Component {
componentDidMount
()
{
// bug-12744-czd
let
activitylist
=
this
.
props
.
activitylist
;
console
.
log
(
this
.
props
.
plansForTablePageData
,
'activitylist11111111111'
)
// debugger
let
selectedCourseRowKeys
=
activitylist
.
filter
(
i
=>
i
.
type
===
0
);
let
selectedUnderLineRowKeys
=
activitylist
.
filter
(
i
=>
i
.
type
===
10
);
...
...
src/pages/TrainingPrograms/ProgeamsManage/Plan/Content.jsx
View file @
7f08f57f
...
...
@@ -2,16 +2,12 @@ import React from "react";
import
{
Table
,
Button
,
Select
,
Input
,
Col
,
Row
,
Modal
,
Icon
,
message
,
Popconfirm
,
}
from
"antd"
;
import
{
Drag
DropContext
,
Drag
Source
,
DropTarget
}
from
"react-dnd"
;
import
{
DragSource
,
DropTarget
}
from
"react-dnd"
;
import
{
connect
}
from
"react-redux"
;
import
{
setaclist
}
from
"../redux/acions"
;
import
{
...
...
@@ -20,30 +16,11 @@ import {
sortUpdate
,
optionUpdate
,
}
from
"../redux/trainingPalnAction"
;
import
HTML5
from
"react-dnd-html5-backend"
;
import
update
from
"immutability-helper"
;
import
Info
from
"./Info.jsx"
;
import
Addplan
from
"./Addplan.jsx"
;
import
AddactivityOption
from
"./Addactivity/Option.jsx"
;
import
intl
from
"react-intl-universal"
;
const
Option
=
Select
.
Option
;
const
Search
=
Input
.
Search
;
//计划
function
handleChange
(
value
)
{
console
.
log
(
`selected
${
value
}
`
);
}
function
handleBlur
()
{
console
.
log
(
"blur"
);
}
function
handleFocus
()
{
console
.
log
(
"focus"
);
}
function
dragDirection
(
dragIndex
,
hoverIndex
,
...
...
@@ -117,18 +94,11 @@ const rowTarget = {
const
dragIndex
=
monitor
.
getItem
().
index
;
const
hoverIndex
=
props
.
index
;
// Don't replace items with themselves
if
(
dragIndex
===
hoverIndex
)
{
return
;
}
// Time to actually perform the action
props
.
moveRow
(
dragIndex
,
hoverIndex
);
// Note: we're mutating the monitor item here!
// Generally it's better to avoid mutations,
// but it's good here for the sake of performance
// to avoid expensive index searches.
monitor
.
getItem
().
index
=
hoverIndex
;
},
};
...
...
@@ -379,7 +349,7 @@ class DragSortingTable extends React.Component {
showModal
()
{
this
.
setState
({
visible
:
true
,
title
:
"添加
活动
"
,
title
:
"添加
投票
"
,
});
}
// 关闭新活动对话框
...
...
@@ -522,8 +492,6 @@ class DragSortingTable extends React.Component {
};
render
()
{
const
{
visible
,
loading
}
=
this
.
state
;
const
{
title
}
=
this
.
props
;
let
usable
=
false
;
if
(
this
.
props
.
title
===
"查看项目"
)
{
usable
=
true
;
...
...
@@ -532,122 +500,10 @@ class DragSortingTable extends React.Component {
{
title
:
"活动类型"
,
dataIndex
:
"typenaem"
,
// key: 'typenaem',
// render: (text, record, index) => {
// //活动类型: 0课程 1考试 2调研 3直播 4投票 5作业 6证书 7外部链接 8 线下课程
// let typenaem = record.typenaem === 0 ? '课程' : record.typenaem === 1 ? '考试': record.typenaem === 2 ? '调研' : record.typenaem === 3 ? '直播' : record.typenaem === 4 ? '投票' : record.typenaem === 5 ? '作业': record.typenaem === 6 ? '证书' : record.typenaem === 7 ? '外部链接':record.typenaem == 8 ? '线下课程' : ''
// return (
// <div>
// <span >{typenaem}</span>
// </div>
// )
// },
filters
:
[
{
text
:
"课程"
,
value
:
"课程"
,
},
{
text
:
"考试"
,
value
:
"考试"
,
},
{
text
:
"调研"
,
value
:
"调研"
,
},
{
text
:
"直播"
,
value
:
"直播"
,
},
{
text
:
"投票"
,
value
:
"投票"
,
},
{
text
:
"作业"
,
value
:
"作业"
,
},
{
text
:
"证书"
,
value
:
"证书"
,
},
{
text
:
"外部链接"
,
value
:
"外部链接"
,
},
{
text
:
"原创活动"
,
value
:
"原创活动"
,
},
{
text
:
"精选作品"
,
value
:
"精选作品"
,
},
{
text
:
"资料"
,
value
:
"资料"
,
},
{
text
:
"线下课程"
,
value
:
"线下课程"
,
},
{
text
:
"帖子"
,
value
:
"帖子"
,
},
],
filterIcon
:
(
<
Icon
type=
"filter"
style=
{
{
color
:
this
.
props
.
title
!==
"查看项目"
?
"#108ee9"
:
"#aaa"
,
}
}
/>
),
onFilter
:
(
value
,
record
)
=>
record
.
typenaem
.
indexOf
(
value
)
===
0
,
},
{
title
:
"活动名称"
,
title
:
"投票名称"
,
dataIndex
:
"acname"
,
key
:
"acname"
,
filterDropdown
:
(
<
div
className=
"custom-filter-dropdown"
>
<
Input
ref=
{
ele
=>
(
this
.
searchInput
=
ele
)
}
placeholder=
"搜索关键字"
value=
{
this
.
state
.
searchText
}
onChange=
{
this
.
inputChange
}
onPressEnter=
{
this
.
search
}
/>
<
Button
type=
"primary"
onClick=
{
this
.
search
}
>
搜索
</
Button
>
</
div
>
),
filterIcon
:
(
<
Icon
type=
"search"
style=
{
{
color
:
this
.
props
.
title
!==
"查看项目"
?
"#108ee9"
:
"#aaa"
,
}
}
/>
),
filterDropdownVisible
:
this
.
state
.
filterDropdownVisible
,
onFilterDropdownVisibleChange
:
visible
=>
{
this
.
setState
(
{
filterDropdownVisible
:
visible
,
},
()
=>
this
.
searchInput
&&
this
.
searchInput
.
focus
()
);
},
render
:
text
=>
{
return
(
<
span
title=
{
text
}
>
{
text
.
length
>
30
?
text
.
substring
(
29
,
0
)
+
"..."
:
text
}
</
span
>
);
},
},
{
title
:
intl
.
get
(
"operate"
).
d
(
"操作"
),
...
...
@@ -724,7 +580,7 @@ class DragSortingTable extends React.Component {
onCancel=
{
this
.
onHideModal
}
destroyOnClose=
{
1
}
>
{
this
.
state
.
title
===
"添加
活动
"
?
(
{
this
.
state
.
title
===
"添加
投票
"
?
(
<
Addplan
title=
{
this
.
props
.
title
}
plantype=
{
this
.
props
.
plantype
}
...
...
@@ -732,6 +588,7 @@ class DragSortingTable extends React.Component {
tpPlanId=
{
this
.
props
.
tpPlanId
}
activityListSave=
{
this
.
activityListSave
}
activitylist=
{
this
.
state
.
activitylist
}
plansForTablePageData=
{
this
.
props
.
plansForTablePageData
}
onAcDelete=
{
this
.
props
.
onAcDelete
}
getList=
{
this
.
getList
}
/>
...
...
src/pages/TrainingPrograms/ProgeamsManage/Plan/Plan.jsx
View file @
7f08f57f
...
...
@@ -2,10 +2,9 @@
* 计划
*/
import
React
from
"react"
;
import
{
Table
,
Button
,
Collapse
,
message
,
Popconfirm
,
Anchor
}
from
"antd"
;
import
{
Table
,
Button
,
message
,
Popconfirm
}
from
"antd"
;
import
{
DragDropContext
,
DragSource
,
DropTarget
}
from
"react-dnd"
;
import
{
connect
}
from
"react-redux"
;
import
moment
from
"moment"
;
import
{
planlist
,
getPlanSeeting
,
setaclist
}
from
"../redux/acions"
;
import
{
saveplan
,
...
...
@@ -18,12 +17,7 @@ import {
import
HTML5Backend
from
"react-dnd-html5-backend"
;
import
update
from
"immutability-helper"
;
import
Info
from
"./Info.jsx"
;
import
Content
from
"./Content.jsx"
;
import
Before
from
"./Before.jsx"
;
import
Remind
from
"../../../../common/remind/trainindex.jsx"
;
import
MessageRemind
from
"../../../../common/MessageRemind"
;
const
Panel
=
Collapse
.
Panel
;
import
intl
from
"react-intl-universal"
;
function
dragDirection
(
dragIndex
,
...
...
@@ -201,6 +195,7 @@ class DragSortingTable extends React.Component {
pagePre
:
_this
.
props
.
planlist
.
slice
(
0
,
(
pageNo
-
1
)
*
pageSize
),
pageAfter
:
_this
.
props
.
planlist
.
slice
(
pageNo
*
pageSize
),
});
console
.
log
(
_this
.
props
.
planlist
,
'_this.props.planlist'
)
}
);
}
...
...
@@ -671,17 +666,7 @@ class DragSortingTable extends React.Component {
};
render
()
{
const
{
visible
,
loading
,
newData
}
=
this
.
state
;
const
{
title
,
newsList
,
planSeeting
}
=
this
.
props
;
const
formItemLayout
=
{
labelCol
:
{
span
:
4
,
},
wrapperCol
:
{
span
:
15
,
},
};
const
{
title
}
=
this
.
props
;
let
usable
=
false
;
if
(
title
===
"查看项目"
)
{
usable
=
true
;
...
...
@@ -693,7 +678,7 @@ class DragSortingTable extends React.Component {
render
:
(
text
,
record
,
index
)
=>
index
+
1
,
},
{
title
:
"
学习计划
名称"
,
title
:
"
投票
名称"
,
dataIndex
:
"name"
,
key
:
"name"
,
},
...
...
@@ -767,7 +752,7 @@ class DragSortingTable extends React.Component {
disabled=
{
usable
}
onClick=
{
()
=>
this
.
handleNew
()
}
>
添加
计划
添加
投票
</
Button
>
</
div
>
<
div
...
...
@@ -813,32 +798,12 @@ class DragSortingTable extends React.Component {
textAlign
:
"left"
,
}
}
>
{
/* <Collapse defaultActiveKey={["1"]}> */
}
{
/* <Panel header="计划信息" key="1">
{console.log(this.state)}
<Info
ref={c => (this.checkinfoplan = c)}
infoData={this.state.infoData}
palnName={this.state.palnName}
palnStartTime={this.state.palnStartTime}
palnEndTime={this.state.palnEndTime}
plantype={this.state.plantype}
title={title}
tpPlanId={this.state.tpPlanId}
onGetPlanSeeting={this.props.onGetPlanSeeting}
planSeeting={this.props.planSeeting}
aclist={this.props.aclist}
paramInfo={this.props.paramInfo}
planlist={this.props.planlist}
onGetAcList={this.props.onGetAcList}
/>
</Panel> */
}
{
/* <Panel forceRender={true} header="计划内容" key="2"> */
}
<
Content
ref=
{
c
=>
(
this
.
connectplan
=
c
)
}
trainId=
{
this
.
props
.
trainId
}
tpPlanId=
{
this
.
state
.
tpPlanId
}
plantype=
{
this
.
state
.
plantype
}
plansForTablePageData=
{
this
.
state
.
plansForTablePageData
}
title=
{
title
}
reset=
{
()
=>
this
.
reset
()
}
/>
...
...
src/pages/TrainingPrograms/ProgeamsManage/redux/trainingActivityListAction.js
View file @
7f08f57f
...
...
@@ -350,7 +350,7 @@ export function getSurveylist(param) {
//上架时间
releaseTime
:
com
.
fmtDateYYHHDD
(
temp
[
i
].
releaseTime
),
//活动类型: 0课程 1考试 2调研 3直播 4投票 5作业 6证书 7外部链接
typenaem
:
"
调研
"
,
typenaem
:
"
投票
"
,
type
:
2
,
//总条数
total
:
data
.
total
,
...
...
src/pages/TrainingPrograms/ProgeamsManage/redux/trainingPalnAction.js
View file @
7f08f57f
...
...
@@ -116,7 +116,7 @@ export function getAcList(param, callback) {
if
(
temp
&&
temp
!==
null
)
{
for
(
let
i
=
0
;
i
<
temp
.
length
;
i
++
)
{
//类型
temp
[
i
].
typenaem
=
temp
[
i
].
type
;
temp
[
i
].
typenaem
=
"投票"
;
//活动名称
temp
[
i
].
acname
=
temp
[
i
].
name
;
temp
[
i
].
conditions
=
temp
[
i
].
condition
;
...
...
@@ -126,34 +126,6 @@ export function getAcList(param, callback) {
temp
[
i
].
id
=
temp
[
i
].
relationId
;
// why ???
// temp[i].id =temp[i].id;
temp
[
i
].
relationId
=
temp
[
i
].
relationId
;
temp
[
i
].
typenaem
=
temp
[
i
].
type
===
0
?
"课程"
:
temp
[
i
].
type
===
1
?
"考试"
:
temp
[
i
].
type
===
2
?
"调研"
:
temp
[
i
].
type
===
3
?
"直播"
:
temp
[
i
].
type
===
4
?
"投票"
:
temp
[
i
].
type
===
5
?
"作业"
:
temp
[
i
].
type
===
6
?
"证书"
:
temp
[
i
].
type
===
7
?
"外部链接"
:
temp
[
i
].
type
===
10
?
"线下课程"
:
temp
[
i
].
type
===
11
?
"原创活动"
:
temp
[
i
].
type
===
12
?
"精选作品"
:
temp
[
i
].
type
===
13
?
"资料"
:
temp
[
i
].
type
===
14
?
"帖子"
:
""
;
if
(
temp
[
i
].
type
===
7
)
{
temp
[
i
].
address
===
temp
[
i
].
address
;
}
...
...
src/pages/TrainingTools/Question/Create/AddTest.jsx
View file @
7f08f57f
...
...
@@ -425,7 +425,7 @@ class AddTest extends Component {
const
{
tlist
,
jumptests
}
=
this
.
props
;
const
{
visible
,
confirmLoading
,
selectedRowKeys
,
testItem
}
=
this
.
state
;
const
uploadProps
=
{
uploadUtilName
:
"上传
图片/
文件"
,
uploadUtilName
:
"上传文件"
,
getUrl
:
fileUrl
=>
{
this
.
setState
({
fileUrl
,
...
...
src/pages/TrainingTools/Question/Create/TestModal.jsx
View file @
7f08f57f
This diff is collapsed.
Click to expand it.
src/pages/TrainingTools/Question/Details/index.jsx
View file @
7f08f57f
...
...
@@ -454,7 +454,7 @@ class Details extends Component {
const
{
details
,
tlist
,
newsList
,
jumptests
,
surid
}
=
this
.
props
;
const
uploadProps
=
{
uploadUtilName
:
"上传
图片/
文件"
,
uploadUtilName
:
"上传文件"
,
getUrl
:
(
fileUrl
)
=>
{
this
.
setState
({
fileUrl
,
...
...
src/pages/TrainingTools/Question/UpLoad/SystemUpload.js
0 → 100644
View file @
7f08f57f
import
React
,
{
Component
}
from
"react"
;
import
{
connect
}
from
"react-redux"
;
import
{
Upload
,
Icon
,
Button
,
message
}
from
"antd"
;
//上传阿里云action
import
{
gupList
,
gupfetch
}
from
"@/common/UpLoad/redux/actions"
;
class
SystemUpLoad
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
OSSData
:
{},
};
}
async
componentDidMount
()
{
//获取令牌
await
this
.
init
();
}
// 1
init
=
async
()
=>
{
try
{
const
OSSData
=
await
this
.
props
.
gupfetch
();
this
.
setState
({
OSSData
:
JSON
.
parse
(
OSSData
.
data
),
});
}
catch
(
error
)
{
message
.
error
(
error
);
}
};
// Mock get OSS api
// https://help.aliyun.com/document_detail/31988.html
onChange
=
info
=>
{
if
(
info
.
file
.
status
!==
"uploading"
)
{
console
.
log
(
info
.
file
,
info
.
fileList
);
}
if
(
info
.
file
.
status
===
"done"
)
{
info
.
fileList
.
pop
();
}
else
if
(
info
.
file
.
status
===
"error"
)
{
message
.
error
(
`
${
info
.
file
.
name
}
上传失败`
);
}
};
onRemove
=
file
=>
{
this
.
props
.
gupList
([]);
};
getExtraData
=
file
=>
{
const
{
OSSData
}
=
this
.
state
;
const
time
=
new
Date
().
getTime
();
const
fileUil
=
OSSData
.
host
+
"/"
+
OSSData
.
dir
+
"/"
+
time
+
"."
+
file
.
name
;
// 回调取值
if
(
this
.
props
.
getUrl
)
{
this
.
props
.
getUrl
(
fileUil
);
}
let
temp
=
[
{
uid
:
OSSData
.
dir
+
"/"
+
time
+
"."
+
file
.
name
,
name
:
file
.
name
,
status
:
"done"
,
url
:
fileUil
,
},
];
console
.
log
(
temp
);
this
.
props
.
gupList
(
temp
);
return
{
Filename
:
OSSData
.
dir
+
"/"
+
time
+
"."
+
file
.
name
,
key
:
OSSData
.
dir
+
"/"
+
time
+
"."
+
file
.
name
,
policy
:
OSSData
.
policy
,
OSSAccessKeyId
:
OSSData
.
accessid
,
success_action_status
:
"200"
,
signature
:
OSSData
.
signature
,
};
};
beforeUpload
=
async
file
=>
{
const
types1
=
[
"jpg"
,
"jpeg"
,
"png"
];
const
type1
=
file
.
type
.
split
(
"/"
)[
1
];
if
(
types1
.
indexOf
(
type1
)
===
-
1
)
{
this
.
props
.
gupList
([]);
return
false
;
}
const
{
OSSData
}
=
this
.
state
;
const
expire
=
OSSData
.
expire
*
1000
;
if
(
expire
<
Date
.
now
())
{
await
this
.
init
();
}
return
true
;
};
render
()
{
const
{
OSSData
}
=
this
.
state
;
const
props
=
{
name
:
"file"
,
fileList
:
this
.
props
.
fileList
,
action
:
OSSData
.
host
,
onChange
:
this
.
onChange
,
onRemove
:
this
.
onRemove
,
data
:
this
.
getExtraData
,
beforeUpload
:
this
.
beforeUpload
,
};
return
(
<
Upload
{...
props
}
>
<
Button
>
<
Icon
type
=
"upload"
/>
上传
<
/Button
>
<
/Upload
>
);
}
}
//所有状态
function
mapStateToProps
(
state
,
ownProps
)
{
return
{
param
:
state
.
uploadParam
.
param
,
fileList
:
state
.
uploadParam
.
fileList
,
};
}
function
mapDispatchToProps
(
dispatch
)
{
return
{
gupfetch
:
()
=>
dispatch
(
gupfetch
()),
gupList
:
fileList
=>
dispatch
(
gupList
(
fileList
)),
};
}
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
SystemUpLoad
);
/**
* 引入地址 import SystemUpLoad from "@/common/UpLoad/SystemUpload.js";
* 使用类
* <SystemUpLoad/>
* // 这是回显数据 [
// {
// "uid": "test/1594024164343. !1 .jpeg",
// "name": " !1 .jpeg",
// "status": "done",
// "url": "https://fulan-test.oss-cn-hangzhou.aliyuncs.com/test/1594024164343. !1 .jpeg"
// }
// ]
* 调用方法
<SystemUpLoad
fileList=[]//或者回显数据
/>
* */
src/pages/TrainingTools/Question/UpLoad/UploadUtil.jsx
0 → 100644
View file @
7f08f57f
import
React
,
{
Component
}
from
"react"
;
import
{
connect
}
from
"react-redux"
;
import
{
Upload
,
Icon
,
Form
,
Button
,
message
,
Progress
}
from
"antd"
;
//上传阿里云action
import
{
gupList
,
gupfetch
}
from
"./redux/actions"
;
import
"./index.less"
;
import
services
from
"@/services/serve"
;
// form Item
const
FormItem
=
Form
.
Item
;
class
UploadUtil
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
uploadAction
:
{},
originalFileName
:
""
,
fileList
:
[],
newFileList
:
[],
key
:
""
,
processNum
:
0
,
//进度条--liyuan
};
}
//修改一
componentDidMount
()
{}
beforeUpload
=
(
file
,
fileList
)
=>
{
if
(
file
.
size
>
200
*
1024
*
1024
)
{
message
.
info
(
"请上传小于200M的文件"
);
return
false
;
}
//默认
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
let
reg
=
""
;
//正则匹配格式
this
.
props
.
extra
===
"markeCardExtra"
?
(
reg
=
/
(
mp4|png|jpg|gif|mp3|pdf|jpeg|doc|docx|pdf|PDF|wps
)
$/g
)
:
(
reg
=
/
(
doc|docx|pdf|PDF|xls|xlsx
)
$/g
);
if
(
!
reg
.
test
(
file
.
name
))
{
message
.
error
(
"文件类型不对,请重新上传"
);
return
false
;
}
this
.
setState
({
fileList
:
fileList
});
this
.
setState
({
uploadAction
:
`
${
services
.
uploadApi
}
`
,
originalFileName
:
file
.
name
,
});
};
//上传
handleChange
=
info
=>
{
let
fileList
=
info
.
fileList
;
this
.
setState
({
processNum
:
info
.
file
.
percent
?
info
.
file
.
percent
:
0
,
});
console
.
log
(
info
,
"info"
);
if
(
info
.
file
.
status
===
"done"
)
{
fileList
.
map
(
item
=>
{
if
(
item
.
status
===
"done"
)
{
// 检查 item.response.data 是否存在且不为 undefined
if
(
item
?.
response
?.
data
&&
this
.
state
.
newFileList
.
indexOf
(
item
.
response
.
data
)
===
-
1
)
{
this
.
state
.
newFileList
.
push
(
item
.
response
.
data
);
}
// 检查 item.url 是否存在且不为 undefined
if
(
item
.
url
&&
this
.
state
.
newFileList
.
indexOf
(
item
.
url
)
===
-
1
)
{
this
.
state
.
newFileList
.
push
(
item
.
url
);
}
}
});
console
.
log
(
this
.
state
.
newFileList
,
"this.state.newFileList"
);
message
.
success
(
"上传成功"
);
}
else
if
(
info
.
file
.
status
===
"error"
)
{
message
.
error
(
"上传失败,请重新尝试"
);
}
if
(
this
.
props
.
getUrl
)
{
this
.
props
.
getUrl
(
this
.
state
.
newFileList
);
}
this
.
setState
({
fileList
});
};
normFile
=
e
=>
{
if
(
Array
.
isArray
(
e
))
{
return
e
;
}
return
e
&&
this
.
state
.
fileList
;
};
fnRemove
=
e
=>
{
if
(
this
.
props
.
defaultUrl
)
{
// 遍历 defaultUrl 数组,将每个对象的 url 合并到 newFileList 中,避免重复添加
this
.
props
.
defaultUrl
.
forEach
(
item
=>
{
if
(
item
.
url
&&
!
this
.
state
.
newFileList
.
includes
(
item
.
url
))
{
this
.
state
.
newFileList
.
push
(
item
.
url
);
}
});
}
if
(
e
.
url
)
{
this
.
state
.
newFileList
.
splice
(
this
.
state
.
newFileList
.
indexOf
(
e
.
url
),
1
);
}
else
{
this
.
state
.
newFileList
.
splice
(
this
.
state
.
newFileList
.
indexOf
(
e
.
response
.
data
),
1
);
}
this
.
props
.
getUrl
(
this
.
state
.
newFileList
);
};
render
()
{
const
{
uploadAction
}
=
this
.
state
;
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
return
(
<
Form
>
<
FormItem
extra=
{
this
.
props
.
extra
===
"markeCardExtra"
?
"请上传资源附件(附件格式:mp4、png、jpg、jpeg、gif、mp3、word、pdf)"
:
"请上传资源附件(附件格式:png、jpg、jpeg、gif、word、pdf、xls、xlsx)"
}
>
{
getFieldDecorator
(
"upload"
,
{
valuePropName
:
"fileList"
,
getValueFromEvent
:
this
.
normFile
,
initialValue
:
this
.
props
.
defaultUrl
,
})(
<
Upload
style=
{
{
display
:
"inline-block"
}
}
beforeUpload=
{
this
.
beforeUpload
}
action=
{
uploadAction
}
headers=
{
{
authorization
:
sessionStorage
.
getItem
(
"mgtk"
)
}
}
multiple=
{
true
}
onChange=
{
this
.
handleChange
}
onRemove=
{
this
.
fnRemove
}
>
<
Button
type=
{
"primary"
}
>
<
Icon
type=
"upload"
/>
{
" "
}
{
!
this
.
state
.
fileList
.
length
?
this
.
props
.
uploadUtilName
:
"修改"
}
</
Button
>
</
Upload
>
)
}
{
this
.
state
.
processNum
!=
0
&&
this
.
state
.
processNum
!=
100
&&
(
<
p
>
<
Progress
percent=
{
this
.
state
.
processNum
}
strokeWidth=
{
5
}
showInfo=
{
false
}
/>
</
p
>
)
}
</
FormItem
>
</
Form
>
);
}
}
//所有状态
function
mapStateToProps
(
state
,
ownProps
)
{
return
{
param
:
state
.
uploadParam
.
param
,
list
:
state
.
materialReducer
.
list
,
details
:
state
.
materialReducer
.
details
,
type
:
state
.
materialReducer
.
type
,
};
}
function
mapDispatchToProps
(
dispatch
)
{
return
{
gupfetch
:
()
=>
dispatch
(
gupfetch
()),
gupList
:
fileList
=>
dispatch
(
gupList
(
fileList
)),
};
}
export
default
Form
.
create
()(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Form
.
create
()(
UploadUtil
))
);
src/pages/TrainingTools/Question/UpLoad/api.js
0 → 100644
View file @
7f08f57f
/**
* anth: 陈万军
* time: 2020-05-1
* */
import
services
from
"@/services/serve"
;
export
default
{
common
:
{
// oss 上传
ossUrl
:
`GET
${
services
.
ossUrl
}
`
,
videoUpload
:
`POST
${
services
.
ossUrl
}
/video/upload`
,
videoPlay
:
`GET
${
services
.
ossUrl
}
/video/play`
,
ossPolicy
:
`GET
${
services
.
ossUrl
}
/upload/policy`
,
},
};
src/pages/TrainingTools/Question/UpLoad/buttonUpload.js
0 → 100644
View file @
7f08f57f
import
React
,
{
Component
}
from
"react"
;
import
{
connect
}
from
"react-redux"
;
import
{
gupList
,
gupfetch
}
from
"./redux/actions"
;
import
{
Upload
,
Icon
,
Form
,
Button
,
message
}
from
"antd"
;
// import Styles from "./index.less";
const
FormItem
=
Form
.
Item
;
class
buttonUpload
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
uploadParams
:
{},
uploadAction
:
""
,
};
}
componentDidMount
()
{
//上传阿里云
this
.
props
.
gupfetch
();
}
beforeUpload
=
(
file
,
fileList
)
=>
{
console
.
log
(
file
,
fileList
);
const
time
=
new
Date
().
getTime
();
// console.log('检测打印变量= "其他组件上传:"', "其他上传" );
if
(
file
.
size
>
1024
*
1024
)
{
message
.
error
(
"上传文件过大(不能大于1M)"
);
return
false
;
}
if
(
file
.
type
.
indexOf
(
"image"
)
===
-
1
)
{
message
.
info
(
"请上传图片文件"
);
// this.props.gupList([]);
return
false
;
}
// if (file.size >= 500 * 1024) {
// message.error("上传文件过大(不能大于500KB)");
// return false;
// }
// this.props.gupList([]);
const
types1
=
[
"jpg"
,
"jpeg"
,
"png"
];
const
type1
=
file
.
type
.
split
(
"/"
)[
1
];
// console.log(types1.indexOf(type1))
if
(
types1
.
indexOf
(
type1
)
===
-
1
)
{
this
.
setState
({
fileList
:
[]
});
// message.error("该图片文件格式不支持(支持jpg、ipeg、png)");
message
.
error
(
"该图片文件格式不支持(支持jpg、jpeg、png)"
);
//bug-12706-liyuan
// if (this.props.defaultUrl) {
// this.props.gupList(this.props.defaultUrl);
// } else {
// this.props.gupList([]);
// }
return
false
;
}
const
{
param
}
=
this
.
props
;
const
{
uploadParams
}
=
this
.
state
const
fileLength
=
file
.
name
.
split
(
"."
).
length
;
this
.
setState
({
uploadParams
:
{
Filename
:
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
],
key
:
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
],
policy
:
param
.
policy
,
OSSAccessKeyId
:
param
.
accessid
,
success_action_status
:
"200"
,
signature
:
param
.
signature
,
},
uploadAction
:
param
.
host
,
});
if
(
this
.
props
.
getUrl
)
{
this
.
props
.
getUrl
(
param
.
host
+
"/"
+
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
],
file
);
}
};
handleUploadChange
=
({
file
,
fileList
})
=>
{
// alert('1')
console
.
log
(
"wwwwwwwwww==============="
,
file
,
fileList
);
const
{
param
}
=
this
.
props
;
const
fileLength
=
file
.
name
.
split
(
"."
).
length
;
const
temp
=
[];
if
(
file
.
status
===
"done"
)
{
const
temp
=
[];
temp
.
push
(
fileList
.
pop
());
this
.
props
.
gupList
(
temp
);
message
.
success
(
file
.
name
+
" 上传成功"
)
if
(
this
.
props
.
UploadCallback
){
this
.
props
.
UploadCallback
(
file
,
param
,
this
.
state
.
uploadParams
.
Filename
)
}
if
(
this
.
props
.
UpCallback
)
// console.log(param.host + "/" + this.state.uploadParams.Filename);
// debugger
this
.
props
.
UpCallback
(
// param.host +
// "/" +
// param.dir +
// "/" +
// // time +
// this.state.uploadParams.Filename,
// "." +
// file.name.split(".")[fileLength - 1]
param
.
host
+
"/"
+
this
.
state
.
uploadParams
.
Filename
);
}
};
render
()
{
const
{
uploadAction
,
uploadParams
}
=
this
.
state
;
return
(
// <div>
<
Upload
headers
=
{{
"X-Requested-With"
:
null
}}
accept
=
"image"
action
=
{
uploadAction
}
data
=
{
uploadParams
}
// listType="text"
showUploadList
=
{
false
}
beforeUpload
=
{
this
.
beforeUpload
}
onChange
=
{
this
.
handleUploadChange
}
>
{
/* <Button type="primary">上传</Button> */
}
{
this
.
props
.
children
}
<
/Upload
>
// </div>
);
}
}
function
mapStateToProps
(
state
,
ownProps
)
{
return
{
param
:
state
.
uploadParam
.
param
,
};
}
function
mapDispatchToProps
(
dispatch
)
{
return
{
gupfetch
:
(
obj
,
callback
)
=>
dispatch
(
gupfetch
(
obj
,
callback
)),
gupList
:
(
obj
,
callback
)
=>
dispatch
(
gupList
(
obj
,
callback
)),
};
}
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
buttonUpload
);
src/pages/TrainingTools/Question/UpLoad/butupload.js
0 → 100644
View file @
7f08f57f
import
React
,
{
Component
}
from
"react"
;
import
{
connect
}
from
"react-redux"
;
import
{
Upload
,
Icon
,
Form
,
Button
,
message
}
from
"antd"
;
//上传阿里云action
import
{
gupList
,
gupfetch
}
from
"@/common/UpLoad/redux/actions"
;
import
"./index.less"
;
const
FormItem
=
Form
.
Item
;
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
10
},
sm
:
{
span
:
4
},
},
wrapperCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
16
},
},
};
class
Butupload
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
uploadParams
:
{},
uploadAction
:
{},
originalFile
:
""
,
originalFileUrl
:
""
,
fileList
:
[],
key
:
""
,
};
this
.
props
.
defaultUrl
&&
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
this
.
props
.
gupfetch
();
}
//修改一
componentDidMount
()
{
//上传阿里云
this
.
props
.
gupfetch
();
}
beforeUpload
=
(
file
,
fileList
)
=>
{
//默认
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
if
(
fileList
.
length
>
1
)
{
message
.
error
(
"一次只能导入一个文件"
);
this
.
setState
({
fileList
:
[]
});
return
;
}
//判断类型
const
reg
=
/
(
xls|xlsx
)
$/g
;
//正则匹配格式
// const reg = /(xls|xlsx)$/g;//正则匹配格式
if
(
!
reg
.
test
(
file
.
name
))
{
message
.
error
(
"文件类型不对"
);
return
false
;
}
this
.
setState
({
fileList
:
fileList
});
const
{
param
}
=
this
.
props
;
const
time
=
new
Date
().
getTime
();
this
.
setState
(
{
uploadParams
:
{
Filename
:
param
.
dir
+
"/"
+
time
+
file
.
name
,
key
:
param
.
dir
+
"/"
+
time
+
file
.
name
,
policy
:
param
.
policy
,
OSSAccessKeyId
:
param
.
accessid
,
success_action_status
:
"200"
,
signature
:
param
.
signature
,
},
uploadAction
:
param
.
host
,
originalFile
:
file
.
name
,
originalFileUrl
:
param
.
host
+
"/"
+
param
.
dir
+
"/"
+
file
.
name
,
},
()
=>
{
//如果传递的回调函数获取地址
if
(
this
.
props
.
getUrl
)
{
this
.
props
.
getUrl
(
param
.
host
+
"/"
+
param
.
dir
+
"/"
+
time
+
file
.
name
,
file
.
name
);
}
}
);
};
//上传
handleChange
=
info
=>
{
let
fileList
=
info
.
fileList
;
fileList
=
fileList
.
slice
(
-
1
);
if
(
fileList
.
status
===
"done"
)
{
this
.
setState
({
fileList
});
}
if
(
fileList
.
status
===
"error"
)
{
message
.
error
(
"上传失败,请重新尝试"
);
this
.
setState
({
fileList
:
[]
});
}
};
normFile
=
e
=>
{
if
(
Array
.
isArray
(
e
))
{
return
e
;
}
return
e
&&
this
.
state
.
fileList
;
};
down
(
e
)
{
e
.
stopPropagation
();
window
.
location
.
href
=
this
.
props
.
downurl
;
}
render
()
{
const
{
uploadAction
,
uploadParams
}
=
this
.
state
;
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
console
.
log
(
"sda"
,
this
.
props
.
defaultUrl
);
return
(
<
Form
>
<
FormItem
label
=
{
this
.
props
.
labname
}
{...
formItemLayout
}
>
{
getFieldDecorator
(
"upload"
,
{
valuePropName
:
"fileList"
,
getValueFromEvent
:
this
.
normFile
,
initialValue
:
this
.
props
.
defaultUrl
,
})(
<
Upload
style
=
{{
display
:
"inline-block"
}}
headers
=
{{
"X-Requested-With"
:
null
}}
beforeUpload
=
{
this
.
beforeUpload
}
action
=
{
uploadAction
}
data
=
{
uploadParams
}
listType
=
"text"
disabled
=
{
this
.
props
.
disabled
}
onChange
=
{
this
.
handleChange
}
onRemove
=
{()
=>
this
.
setState
({
fileList
:
[]
})}
>
<
Button
type
=
{
this
.
props
.
uploadUtilName
?
"primary"
:
""
}
style
=
{{
marginRight
:
"20px"
}}
disabled
=
{
this
.
props
.
disabled
}
>
{
this
.
props
.
uploadUtilName
?
(
this
.
props
.
uploadUtilName
)
:
(
<
Icon
type
=
"upload"
/>
)}
<
/Button
>
<
a
onClick
=
{
e
=>
this
.
down
(
e
)}
disabled
=
{
this
.
props
.
disabled
}
>
{
this
.
props
.
downname
}
<
/a
>
<
/Upload
>
)}
{
this
.
state
.
fileList
.
length
>
0
||
this
.
props
.
submitterAccessName
||
this
.
props
.
auditorAccessName
||
this
.
props
.
scorerAccessName
?
null
:
(
<
p
>
您还未上传任何数据哦
~<
/p
>
)}
<
/FormItem
>
<
/Form
>
);
}
}
//所有状态
function
mapStateToProps
(
state
,
ownProps
)
{
return
{
param
:
state
.
uploadParam
.
param
,
};
}
function
mapDispatchToProps
(
dispatch
)
{
return
{
gupfetch
:
()
=>
dispatch
(
gupfetch
()),
gupList
:
fileList
=>
dispatch
(
gupList
(
fileList
)),
};
}
export
default
Form
.
create
()(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Form
.
create
()(
Butupload
))
);
src/pages/TrainingTools/Question/UpLoad/index.js
0 → 100644
View file @
7f08f57f
import
React
,
{
Component
}
from
"react"
;
import
{
connect
}
from
"react-redux"
;
import
{
gupList
,
gupfetch
,
clearUpload
}
from
"./redux/actions"
;
import
{
Upload
,
Icon
,
Form
,
Button
,
message
}
from
"antd"
;
import
Styles
from
"./index.less"
;
const
FormItem
=
Form
.
Item
;
class
UpLoad
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
uploadParams
:
{},
uploadAction
:
""
,
cacheUrl
:
""
//bug-12388-liyuan
};
console
.
log
(
this
.
props
.
defaultUrl
);
this
.
props
.
defaultUrl
&&
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
this
.
props
.
gupfetch
();
this
.
beforeUpload
=
this
.
beforeUpload
.
bind
(
this
);
this
.
handleUploadChange
=
this
.
handleUploadChange
.
bind
(
this
);
}
beforeUpload
(
file
,
fileList
)
{
const
time
=
new
Date
().
getTime
();
// console.log('检测打印变量= "其他组件上传:"', "其他上传" );
if
(
file
.
size
>
1024
*
1024
)
{
message
.
error
(
"上传文件过大(不能大于1M)"
);
return
false
;
}
if
(
file
.
type
.
indexOf
(
"image"
)
===
-
1
)
{
message
.
info
(
"请上传图片文件"
);
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
return
false
;
}
if
(
this
.
props
.
bannerType
==
"banner"
)
{
if
(
file
.
size
>=
1024
*
1024
)
{
message
.
error
(
"上传文件过大(不能大于1M)"
);
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
return
false
;
}
}
else
{
if
(
file
.
size
>=
500
*
1024
)
{
message
.
error
(
"上传文件过大(不能大于500KB)"
);
return
false
;
}
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
}
const
types1
=
[
"jpg"
,
"jpeg"
,
"png"
];
const
type1
=
file
.
type
.
split
(
"/"
)[
1
];
// console.log(types1.indexOf(type1))
if
(
types1
.
indexOf
(
type1
)
===
-
1
)
{
this
.
setState
({
fileList
:
[]
});
// message.error("该图片文件格式不支持(支持jpg、ipeg、png)");
message
.
error
(
"该图片文件格式不支持(支持jpg、jpeg、png)"
);
//bug-12706-liyuan
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
return
false
;
}
const
{
param
}
=
this
.
props
;
const
fileLength
=
file
.
name
.
split
(
"."
).
length
;
this
.
setState
({
uploadParams
:
{
Filename
:
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
],
key
:
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
],
policy
:
param
.
policy
,
OSSAccessKeyId
:
param
.
accessid
,
success_action_status
:
"200"
,
signature
:
param
.
signature
,
},
uploadAction
:
param
.
host
,
cacheUrl
:
param
.
host
+
"/"
+
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
]
//bug-12388-liyuan
});
// if (this.props.getUrl) {
// this.props.getUrl(
// param.host +
// "/" +
// param.dir +
// "/" +
// time +
// "." +
// file.name.split(".")[fileLength - 1]
// );
// }
}
//测验上传
testCourseBeforeUpload
=
(
file
,
fileList
)
=>
{
// console.log('检测打印变量= "测验上传" ', "测验上传" );
const
time
=
new
Date
().
getTime
();
if
(
file
.
size
>
1024
*
1024
*
3
)
{
message
.
error
(
"上传图片过大(不能大于3M)"
);
return
false
;
}
if
(
file
.
type
.
indexOf
(
"image"
)
===
-
1
)
{
message
.
info
(
"请上传图片文件"
);
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
return
false
;
}
const
types1
=
[
"jpg"
,
"jpeg"
,
"png"
];
const
type1
=
file
.
type
.
split
(
"/"
)[
1
];
// console.log(types1.indexOf(type1))
if
(
types1
.
indexOf
(
type1
)
===
-
1
)
{
this
.
setState
({
fileList
:
[]
});
// message.error("该图片文件格式不支持(支持jpg、ipeg、png)");
message
.
error
(
"该图片文件格式不支持(支持jpg、jpeg、png)"
);
//bug-12706-liyuan
if
(
this
.
props
.
defaultUrl
)
{
this
.
props
.
gupList
(
this
.
props
.
defaultUrl
);
}
else
{
this
.
props
.
gupList
([]);
}
return
false
;
}
const
{
param
}
=
this
.
props
;
const
fileLength
=
file
.
name
.
split
(
"."
).
length
;
this
.
setState
({
uploadParams
:
{
Filename
:
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
],
key
:
param
.
dir
+
"/"
+
time
+
"."
+
file
.
name
.
split
(
"."
)[
fileLength
-
1
],
policy
:
param
.
policy
,
OSSAccessKeyId
:
param
.
accessid
,
success_action_status
:
"200"
,
signature
:
param
.
signature
,
},
uploadAction
:
param
.
host
,
});
// if (this.props.getUrl) {
// this.props.getUrl(
// param.host +
// "/" +
// param.dir +
// "/" +
// time +
// "." +
// file.name.split(".")[fileLength - 1]
// );
// }
};
handleUploadChange
({
file
,
fileList
})
{
const
temp
=
[];
const
{
param
}
=
this
.
props
;
const
{
Filename
}
=
this
.
state
.
uploadParams
;
const
fileLength
=
file
.
name
.
split
(
"."
).
length
;
if
(
file
.
status
===
"uploading"
)
{
const
temp
=
[];
temp
.
push
(
fileList
.
pop
());
this
.
props
.
gupList
(
temp
);
}
if
(
file
.
status
===
"done"
)
{
const
temp
=
[];
temp
.
push
(
fileList
.
pop
());
this
.
props
.
gupList
(
temp
);
if
(
this
.
props
.
getUrl
)
{
this
.
props
.
getUrl
(
param
.
host
+
"/"
+
Filename
);
}
}
}
componentWillUnmount
()
{
this
.
props
=
null
;
}
onRemove
=
()
=>
{
//bug-12388-liyuan
if
(
this
.
props
.
resetImgList
){
//bug-12705-liyuan
this
.
props
.
resetImgList
();
}
this
.
props
.
clearUpload
()
}
onPreview
=
(
flie
)
=>
{
//bug-12388-liyuan
const
{
cacheUrl
}
=
this
.
state
;
const
cache
=
cacheUrl
?
cacheUrl
:
flie
.
url
;
//bug-12705-liyuan
// window.open(cacheUrl)
window
.
open
(
cache
)
//bug-12705-liyuan
}
render
()
{
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
const
{
uploadParams
,
uploadAction
}
=
this
.
state
;
const
{
required
,
fileList
,
listType
}
=
this
.
props
;
const
formItemLayout
=
this
.
props
.
layout
?
this
.
props
.
layout
:
{
labelCol
:
{
span
:
6
},
wrapperCol
:
{
span
:
14
},
};
let
uploadStatus
=
""
;
if
(
fileList
.
length
===
0
)
{
uploadStatus
=
"newState"
;
}
else
{
uploadStatus
=
"editState"
;
}
const
uploadButton
=
()
=>
{
if
(
fileList
.
length
===
0
)
{
return
(
<
div
>
<
Icon
type
=
"plus"
/>
<
div
className
=
"ant-upload-text"
>
上传图片
<
/div
>
<
/div
>
);
}
else
{
return
(
<
div
className
=
"upload-btn"
>
<
Button
disabled
=
{
this
.
props
.
usable
?
this
.
props
.
usable
:
false
}
>
更换图片
<
/Button
>
<
/div
>
);
}
};
const
props
=
()
=>
{
if
(
listType
===
"spe"
)
{
return
{
className
:
"upload-list-inline"
,
};
}
else
{
return
{
listType
:
"picture-card"
,
};
}
};
return
(
<
Form
>
<
FormItem
{...
formItemLayout
}
//bug-11991-liyuan
//label={this.props.name ? this.props.name : "播放展示图:"}
extra
=
{
this
.
props
.
extra
}
label
=
{
this
.
props
.
name
?
this
.
props
.
name
:
"播放展示图:"
}
//bug-11991-liyuan
>
{
/* <span>{this.props.name ? this.props.name : "播放展示图:"}</span> */
}
{
/* bug-11991-liyuan */
}
{
getFieldDecorator
(
"logourl"
,
{
rules
:
[
{
required
:
required
?
true
:
false
,
message
:
"请上传缩略图"
,
},
],
})(
<
div
className
=
{
Styles
.
credEditLogo
}
data
-
status
=
{
uploadStatus
}
>
<
Upload
headers
=
{{
"X-Requested-With"
:
null
}}
accept
=
"image"
listType
=
"picture-card"
fileList
=
{
fileList
}
action
=
{
uploadAction
}
data
=
{
uploadParams
}
beforeUpload
=
{
this
.
props
.
testCourse
?
this
.
testCourseBeforeUpload
:
this
.
beforeUpload
}
onChange
=
{
this
.
handleUploadChange
}
onRemove
=
{
this
.
onRemove
}
//bug-12388-liyuan
onPreview
=
{
this
.
onPreview
}
//bug-12388-liyuan
>
{
this
.
props
.
disabled
?
null
:
uploadButton
()}
<
/Upload
>
<
/div
>
)}
<
/FormItem
>
<
/Form
>
);
}
}
function
mapStateToProps
(
state
,
ownProps
)
{
return
{
param
:
state
.
uploadParam
.
param
,
fileList
:
state
.
uploadParam
.
fileList
,
};
}
function
mapDispatchToProps
(
dispatch
)
{
return
{
gupfetch
:
()
=>
dispatch
(
gupfetch
()),
gupList
:
fileList
=>
dispatch
(
gupList
(
fileList
)),
clearUpload
:
()
=>
dispatch
(
clearUpload
()),
};
}
export
default
Form
.
create
()(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
UpLoad
)
);
src/pages/TrainingTools/Question/UpLoad/index.less
0 → 100644
View file @
7f08f57f
.credEditLogo{
>span{
display: flex !important;
}
.ant-upload-list-item-info{
display: flex;
align-items: center;
span{
flex: 1;
//background-color: #272222;
}
}
&[data-status="newState"] {
.ant-upload-select-picture-card{
border: 1px dashed #d9d9d9;
width: 104px;
height: 104px;
border-radius: 4px;
background-color: #fafafa;
text-align: center;
cursor: pointer;
transition: border-color 0.3s ease;
vertical-align: top;
margin-right: 8px;
margin-bottom: 8px;
display: table;
}
}
&[data-status="editState"] {
.ant-upload-select-picture-card{
border:none;
width: 0;
height: 0;
border-radius: 0;
background-color: red !important;
text-align: center;
cursor: pointer;
transition: border-color 0.3s ease;
vertical-align: bottom;
display: inline-block !important;
margin-top: 60px;
}
:global { //bug-上传组件样式-liyuan
.ant-upload-select-picture-card {
background: transparent;
border: none
}
}
}
}
.ant-upload-list-item-actions{
.anticon-eye-o{
display: none;
}
.anticon-delete{
display: none;
}
}
src/pages/TrainingTools/Question/UpLoad/plupload.js
0 → 100644
View file @
7f08f57f
const
defaultFileFilter
=
[
{
title
:
"Image files"
,
extensions
:
"jpg,png,jpeg,gif"
},
{
title
:
"video files"
,
extensions
:
"mp4"
},
{
title
:
"audio files"
,
extensions
:
"mp3"
},
{
title
:
"doc files"
,
extensions
:
"xls,xlsx,doc,docx,pdf,ppt,pptx"
},
{
title
:
"compression files"
,
extensions
:
"zip"
}
];
var
self
=
{
host
:
''
,
fileName
:
''
,
filePath
:
''
,
dir
:
""
,
uploader
:
null
,
init
:
function
(
selectFile
,
container
,
beforeUpload
,
progressFunc
,
completeFunc
,
initFileFilter
,
getOssUploader
)
{
//参数注释:1.上传按钮id 2.触发选择文件按钮id 3、4、5三个上传阶段回调函数
var
timer
=
setInterval
(
function
()
{
if
(
document
.
getElementById
(
selectFile
))
{
self
.
uploader
=
new
plupload
.
Uploader
({
runtimes
:
'html5,flash,silverlight'
,
//上传方式
multi_selection
:
false
,
browse_button
:
selectFile
,
unique_names
:
true
,
//触发选择文件按钮
filters
:
{
mime_types
:
initFileFilter
?
initFileFilter
:
defaultFileFilter
},
//headers:{"x-oss-meta-Content-Disposition":"test.zip"},
container
:
document
.
getElementById
(
container
),
//上传按钮DOM
flash_swf_url
:
location
.
host
+
'/lib/plupload-2.1.2/js/Moxie.swf'
,
//上传flash文件参数
silverlight_xap_url
:
location
.
host
+
'/lib/plupload-2.1.2/js/Moxie.xap'
,
url
:
self
.
host
,
init
:
{
PostInit
:
function
()
{},
FilesAdded
:
function
(
up
,
files
)
{
if
(
beforeUpload
)
{
beforeUpload
(
false
,
files
,
up
);
}
},
BeforeUpload
(
uploader
,
file
)
{
let
oldOption
=
uploader
.
getOption
();
console
.
log
(
oldOption
);
let
oldParams
=
oldOption
.
multipart_params
;
oldParams
.
key
=
self
.
dir
+
"/"
+
file
.
id
+
"."
+
file
.
name
.
split
(
"."
)[
file
.
name
.
split
(
"."
)
.
length
-
1
];
oldParams
.
Filename
=
self
.
dir
+
"/"
+
file
.
id
+
"."
+
file
.
name
.
split
(
"."
)[
file
.
name
.
split
(
"."
)
.
length
-
1
];
self
.
uploader
.
setOption
({
'multipart_params'
:
oldParams
});
},
UploadProgress
:
function
(
up
,
file
)
{
if
(
progressFunc
)
{
progressFunc
(
file
,
up
);
}
},
FileUploaded
:
function
(
up
,
file
,
info
)
{
if
(
completeFunc
)
{
completeFunc
(
info
,
up
,
file
);
}
},
QueueChanged
(
up
)
{
console
.
log
(
up
);
},
StateChanged
:
function
(
up
)
{
console
.
log
(
up
);
},
Error
:
function
(
up
,
error
)
{
console
.
log
(
error
)
if
(
beforeUpload
)
{
beforeUpload
(
true
,{},
up
,
error
);
}
}
}
});
self
.
uploader
.
init
();
if
(
getOssUploader
)
{
getOssUploader
(
self
.
uploader
);
}
clearInterval
(
timer
);
}
},
500
);
},
uploadFile
:
function
(
param
,
files
,
uploader
)
{
self
.
uploader
=
uploader
;
console
.
log
(
uploader
)
self
.
dir
=
param
.
dir
;
let
specialKey
=
param
.
host
+
"/"
+
param
.
dir
+
"/"
+
param
.
fileName
;
var
new_params
=
{
'Filename'
:
specialKey
,
'key'
:
specialKey
,
'policy'
:
param
.
policy
,
'OSSAccessKeyId'
:
param
.
accessid
,
'success_action_status'
:
'200'
,
//让服务端返回200,不然,默认会返回204
'signature'
:
param
.
signature
};
self
.
uploader
.
setOption
({
'url'
:
param
.
host
,
'multipart_params'
:
new_params
});
if
(
self
.
uploader
.
files
.
length
==
0
)
{
self
.
uploader
.
addFile
(
files
[
0
]);
}
self
.
uploader
.
start
();
},
removeFiles
()
{
let
files
=
self
.
uploader
.
files
;
if
(
files
.
length
>
0
){
self
.
uploader
.
removeFile
(
files
[
files
.
length
-
1
].
id
);
}
}
};
module
.
exports
=
self
;
\ No newline at end of file
src/pages/TrainingTools/Question/UpLoad/redux/actionTypes.js
0 → 100644
View file @
7f08f57f
export
const
GET_UPLOAD_PARAM
=
"GET_UPLOAD_PARAM"
;
export
const
GET_UPLOAD_LIST
=
"GET_UPLOAD_LIST"
;
export
const
GET_UPVIDEO_PARAM
=
"GET_UPVIDEO_PARAM"
;
export
const
CLEARUPLOAD
=
"CLEARUPLOAD"
;
export
const
UP_INFO
=
"UP_INFO"
;
export
const
VIDEO_INFO
=
"VIDEO_INFO"
;
//UploadUtilFile 常亮
export
const
GET_FILE_NAME_ADDRESS
=
"GET_FILE_NAME_ADDRESS"
;
src/pages/TrainingTools/Question/UpLoad/redux/actions.js
0 → 100644
View file @
7f08f57f
import
request
from
"@/util/request.js"
;
import
api
from
"../api"
;
import
*
as
Types
from
"./actionTypes"
;
const
{
common
}
=
api
;
const
{
ossUrl
,
videoUpload
,
videoPlay
}
=
common
;
export
function
gupList
(
fileList
)
{
return
dispatch
=>
{
dispatch
({
type
:
Types
.
GET_UPLOAD_LIST
,
data
:
fileList
});
};
}
//获取上传签名
export
function
gupfetch
(
data
,
callback
)
{
let
needTranscode
=
false
;
let
type
=
false
;
let
url
;
if
(
data
)
{
needTranscode
=
data
.
needTranscode
;
type
=
data
.
type
;
// url = `${ossUrl}/upload/policy?needTranscode=${needTranscode}&type=${type}&date=${new Date()}`;
url
=
`
${
ossUrl
}
/upload/policy`
;
}
else
{
// url = `${ossUrl}/upload/policy?date=${(new Date()).valueOf()}`;
url
=
`
${
ossUrl
}
/upload/policy`
;
}
// alert(url)
return
dispatch
=>
{
return
request
({
url
,
data
:
data
?
{
needTranscode
:
needTranscode
,
type
:
type
,
date
:
(
new
Date
()).
valueOf
()}
:
{
date
:
(
new
Date
()).
valueOf
()}
}).
then
(
res
=>
{
if
(
res
.
code
===
"1000"
)
{
const
temp
=
JSON
.
parse
(
res
.
data
);
dispatch
({
type
:
Types
.
GET_UPLOAD_PARAM
,
data
:
temp
});
if
(
callback
){
callback
();
}
}
return
res
;
});
};
}
//视频上传
export
function
upvideo
(
param
,
callback1
,
callback2
)
{
return
dispatch
=>
{
return
request
({
videoUpload
,
data
:
param
,
}).
then
(
res
=>
{
if
(
res
.
code
===
"1000"
)
{
dispatch
({
type
:
Types
.
UP_INFO
,
data
:
JSON
.
parse
(
res
.
data
)
});
if
(
callback1
)
{
callback1
();
}
}
});
};
}
//视频信息
export
function
videoInfo
(
param
,
callback
)
{
return
dispatch
=>
{
return
request
({
videoPlay
,
data
:
param
,
}).
then
(
res
=>
{
if
(
res
.
code
===
"1000"
)
{
dispatch
({
type
:
Types
.
VIDEO_INFO
,
data
:
res
.
data
});
if
(
callback
)
{
callback
();
}
}
});
};
}
//UploadUtil组件中 上传图片和视频得到的文件名和图片名
export
function
UploadUtilFile
(
fileAddress
)
{
return
{
type
:
Types
.
GET_FILE_NAME_ADDRESS
,
fileAddress
};
}
export
function
clearUpload
()
{
return
dispatch
=>
{
dispatch
({
type
:
Types
.
CLEARUPLOAD
,
});
};
}
src/pages/TrainingTools/Question/UpLoad/redux/reduter.js
0 → 100644
View file @
7f08f57f
/**
* anth: 陈万军
* time: 2020-05-1
* 上传 reducer
* */
import
*
as
Types
from
"./actionTypes"
;
// 获取上传参数
const
initialState
=
{
param
:
{
accessid
:
""
,
active
:
""
,
dir
:
""
,
expire
:
""
,
host
:
""
,
policy
:
""
,
signatur
:
""
,
},
fileList
:
[],
vedioInfo
:
null
,
upInfo
:
null
,
};
function
uploadParam
(
state
=
initialState
,
action
)
{
switch
(
action
.
type
)
{
case
Types
.
GET_UPLOAD_PARAM
:
return
{
...
state
,
param
:
action
.
data
};
case
Types
.
GET_UPLOAD_LIST
:
return
{
...
state
,
fileList
:
action
.
data
};
case
Types
.
VIDEO_INFO
:
return
{
...
state
,
vedioInfo
:
action
.
data
};
case
Types
.
UP_INFO
:
return
{
...
state
,
upInfo
:
action
.
data
};
case
Types
.
CLEARUPLOAD
:
return
{
...
state
,
fileList
:
[]
};
default
:
return
state
;
}
}
export
default
uploadParam
;
src/pages/TrainingTools/Question/index.jsx
View file @
7f08f57f
...
...
@@ -25,8 +25,6 @@ import {
import
Breadcrumb
from
"@/common/Breadcrumb"
;
const
TabPane
=
Tabs
.
TabPane
;
import
styles
from
"./style/index.less"
;
import
ExportBtn
from
"@/common/LinkUsers/exportUsers"
;
import
ImportUsers
from
"@/common/LinkUsers/importUsers"
;
var
companyCode
=
location
.
pathname
.
split
(
"/"
)[
1
];
var
siteCode
=
location
.
pathname
.
split
(
"/"
)[
2
];
...
...
@@ -363,19 +361,6 @@ class Survey extends Component {
{
action2
}
</
a
>
</
Popconfirm
>
{
record
.
visibleRange
===
2
?
(
<
span
>
<
ImportUsers
urlParameter=
"research"
scopeId=
{
record
&&
record
.
id
}
/>
<
ExportBtn
urlParameter=
"research"
scopeId=
{
record
&&
record
.
id
}
/>
</
span
>
)
:
null
}
{
key
==
2
?
(
<
div
>
<
Popconfirm
...
...
src/pages/TrainingTools/exam/questionBank/question/importBtn.jsx
View file @
7f08f57f
...
...
@@ -16,7 +16,7 @@ class ImportUsers extends Component {
originalFileUrl
:
""
,
fileList
:
[],
downUrl
:
"https://
fulan-test.oss-cn-hangzhou.aliyuncs.com/test/question_import
.xlsx"
,
"https://
hqjddj.shanghaiairport.com/api/v1/buckets/test/objects/download/?preview=true&prefix=question_import_1756864406157
.xlsx"
,
key
:
""
,
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment