Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
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
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
1aff56d2
Commit
1aff56d2
authored
Mar 07, 2021
by
zhangleyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:处理重命名问题
parent
7c14f866
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
63 deletions
+97
-63
src/domains/resource-disk/UploadFileService.ts
+1
-1
src/modules/plan-manage/AddPlan.jsx
+6
-1
src/modules/plan-manage/components/TrainingTask.jsx
+90
-61
No files found.
src/domains/resource-disk/UploadFileService.ts
View file @
1aff56d2
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*/
*/
import
OSS
from
'ali-oss'
;
import
OSS
from
'ali-oss'
;
import
{
UPLOAD_REGION
}
from
'@/domains/resource-disk/constants'
;
import
{
UPLOAD_REGION
}
from
'@/domains/resource-disk/constants'
;
import
{
getOssClient
}
from
'@/data-source/basic/basic-apis
.ts
'
;
import
{
getOssClient
}
from
'@/data-source/basic/basic-apis'
;
interface
IMultiPartUpload
{
interface
IMultiPartUpload
{
data
:
object
;
data
:
object
;
...
...
src/modules/plan-manage/AddPlan.jsx
View file @
1aff56d2
...
@@ -212,7 +212,12 @@ function AddPlan() {
...
@@ -212,7 +212,12 @@ function AddPlan() {
</
div
>
</
div
>
<
div
className=
"basic-info__wrap"
>
<
div
className=
"basic-info__wrap"
>
<
div
className=
"title"
>
培训任务
</
div
>
<
div
className=
"title"
>
培训任务
</
div
>
<
TrainingTask
data=
{
taskList
}
onChange=
{
handleChangeTaskInfo
}
/>
{
(
type
===
'edit'
&&
taskList
.
length
>
0
)
&&
<
TrainingTask
data=
{
taskList
}
onChange=
{
handleChangeTaskInfo
}
/>
}
{
type
===
'add'
&&
<
TrainingTask
data=
{
taskList
}
onChange=
{
handleChangeTaskInfo
}
/>
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
src/modules/plan-manage/components/TrainingTask.jsx
View file @
1aff56d2
...
@@ -21,23 +21,31 @@ const DragHandle = sortableHandle(() => (
...
@@ -21,23 +21,31 @@ const DragHandle = sortableHandle(() => (
<
span
>
移动
</
span
>
<
span
>
移动
</
span
>
</
span
>
</
span
>
));
));
const
SortableItem
=
sortableElement
(
props
=>
<
tr
{
...
props
}
/>);
const
SortableItem
=
sortableElement
(
props
=>
<
tr
{
...
props
}
/>);
const
SortableContainer
=
sortableContainer
(
props
=>
<
tbody
{
...
props
}
/>);
const
SortableContainer
=
sortableContainer
(
props
=>
<
tbody
{
...
props
}
/>);
class
TrainingTask
extends
React
.
Component
{
class
TrainingTask
extends
React
.
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
dataSource
:
[]
,
dataSource
:
this
.
props
.
data
,
selectedTaskIndex
:
0
,
selectedTaskIndex
:
0
,
relatedCourseModalVisible
:
false
relatedCourseModalVisible
:
false
};
};
}
}
componentDidMount
(){
componentWillMount
(){
// if (this.props.data) {
// const newData = [...this.props.data];
// this.setState({
// dataSource:newData,
// })
// }
}
console
.
log
(
'data'
,
this
.
props
.
data
);
componentWillReceiveProps
(
nextProps
)
{
}
}
parseTaskColumns
=
()
=>
{
parseTaskColumns
=
()
=>
{
const
columns
=
[
const
columns
=
[
{
{
...
@@ -64,8 +72,7 @@ class TrainingTask extends React.Component {
...
@@ -64,8 +72,7 @@ class TrainingTask extends React.Component {
:
:
<
span
>
{
val
}
</
span
>
<
span
>
{
val
}
</
span
>
}
}
</
div
>
</
div
>
)
)
}
}
...
@@ -81,7 +88,7 @@ class TrainingTask extends React.Component {
...
@@ -81,7 +88,7 @@ class TrainingTask extends React.Component {
<
DragHandle
/>
<
DragHandle
/>
<
span
className=
"operate__item"
>
<
span
className=
"operate__item"
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
onClick=
{
(
e
)
=>
{
const
{
data
}
=
this
.
props
;
record
.
type
=
"input"
;
this
.
props
.
onChange
(
data
);
}
}
>
重命名
</
span
>
<
span
onClick=
{
(
e
)
=>
{
const
{
data
Source
}
=
this
.
state
;
record
.
type
=
"input"
;
this
.
setState
({
dataSource
})
}
}
>
重命名
</
span
>
</
span
>
</
span
>
<
span
className=
"operate__item"
onClick=
{
()
=>
{
this
.
handleDeleteTask
(
index
)}
}
>
<
span
className=
"operate__item"
onClick=
{
()
=>
{
this
.
handleDeleteTask
(
index
)}
}
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
className=
"icon iconfont"
>

</
span
>
...
@@ -134,7 +141,7 @@ class TrainingTask extends React.Component {
...
@@ -134,7 +141,7 @@ class TrainingTask extends React.Component {
<
DragHandle
/>
<
DragHandle
/>
<
span
className=
"operate__item"
>
<
span
className=
"operate__item"
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
onClick=
{
(
e
)
=>
{
const
{
data
}
=
this
.
props
;
record
.
type
=
"input"
;
this
.
props
.
onChange
(
data
);
}
}
>
重命名
</
span
>
<
span
onClick=
{
(
e
)
=>
{
const
{
data
Source
}
=
this
.
state
;
record
.
type
=
"input"
;
this
.
setState
({
dataSource
})
}
}
>
重命名
</
span
>
</
span
>
</
span
>
<
span
className=
"operate__item"
onClick=
{
()
=>
{
this
.
handleDeleteCourse
(
parentIndex
,
index
)}
}
>
<
span
className=
"operate__item"
onClick=
{
()
=>
{
this
.
handleDeleteCourse
(
parentIndex
,
index
)}
}
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
className=
"icon iconfont"
>

</
span
>
...
@@ -148,88 +155,107 @@ class TrainingTask extends React.Component {
...
@@ -148,88 +155,107 @@ class TrainingTask extends React.Component {
return
coursecolumns
return
coursecolumns
}
}
// onSortEnd = ({ oldIndex, newIndex }) => {
onSortEnd
=
({
oldIndex
,
newIndex
})
=>
{
// const { dataSource } = this.state;
const
{
dataSource
}
=
this
.
state
;
// if (oldIndex !== newIndex) {
// const newData = arrayMove([].concat(dataSource), oldIndex, newIndex).filter(el => !!el);
console
.
log
(
"oldIndex"
,
oldIndex
);
// console.log('Sorted items: ', newData);
console
.
log
(
"newIndex"
,
newIndex
);
// this.setState({ dataSource: newData });
// }
if
(
oldIndex
!==
newIndex
)
{
// };
const
newData
=
arrayMove
([].
concat
(
dataSource
),
oldIndex
,
newIndex
).
filter
(
el
=>
!!
el
);
this
.
setState
({
dataSource
:
newData
});
}
};
//
DraggableContainer = props => (
DraggableContainer
=
props
=>
(
//
<SortableContainer
<
SortableContainer
//
useDragHandle
useDragHandle
//
disableAutoscroll
disableAutoscroll
//
helperClass="row-dragging"
helperClass=
"row-dragging"
//
onSortEnd={this.onSortEnd}
onSortEnd=
{
this
.
onSortEnd
}
//
{...props}
{
...
props
}
//
/>
/>
//
);
);
//
DraggableBodyRow = ({ className, style, ...restProps }) => {
DraggableBodyRow
=
({
className
,
style
,
...
restProps
})
=>
{
//
const { dataSource } = this.state;
const
{
dataSource
}
=
this
.
state
;
//
// function findIndex base on Table rowKey props and should always be a right array index
// function findIndex base on Table rowKey props and should always be a right array index
//
const index = dataSource.findIndex(x => x.index === restProps['data-row-key']);
const
index
=
dataSource
.
findIndex
(
x
=>
x
.
index
===
restProps
[
'data-row-key'
]);
//
return <SortableItem className={className} index={index} {...restProps} style={style}/>;
return
<
SortableItem
className=
{
className
}
index=
{
index
}
{
...
restProps
}
style=
{
style
}
/>;
//
};
};
addTask
=
()
=>
{
addTask
=
()
=>
{
const
{
data
}
=
this
.
props
;
const
{
data
Source
}
=
this
.
state
;
const
taskObj
=
{
const
taskObj
=
{
taskName
:
''
,
taskName
:
''
,
index
:
data
.
length
,
index
:
data
Source
.
length
,
type
:
'input'
,
type
:
'input'
,
courseList
:[
courseList
:[
]
]
}
}
const
newData
=
[...
data
,
taskObj
];
const
newData
=
[...
dataSource
,
taskObj
];
this
.
props
.
onChange
(
newData
);
this
.
setState
({
dataSource
:
newData
},()
=>
{
this
.
props
.
onChange
(
newData
);})
}
}
handleRenameTaskName
=
(
e
,
record
)
=>
{
handleRenameTaskName
=
(
e
,
record
)
=>
{
const
{
value
}
=
e
.
target
;
const
{
value
}
=
e
.
target
;
const
{
data
}
=
this
.
props
;
const
{
data
Source
}
=
this
.
state
;
record
.
taskName
=
value
;
record
.
taskName
=
value
;
this
.
props
.
onChange
(
data
);
this
.
setState
({
dataSource
,
},()
=>
{
this
.
props
.
onChange
(
dataSource
);})
}
}
handleTaskNameBlur
=
(
e
,
record
)
=>
{
handleTaskNameBlur
=
(
e
,
record
)
=>
{
const
{
value
}
=
e
.
target
;
const
{
value
}
=
e
.
target
;
const
{
data
}
=
this
.
props
;
const
{
dataSource
}
=
this
.
state
;
if
(
value
){
if
(
value
){
record
.
type
=
"text"
;
record
.
type
=
"text"
;
this
.
props
.
onChange
(
data
);
this
.
setState
({
dataSource
,
},()
=>
{
this
.
props
.
onChange
(
dataSource
);})
}
}
}
}
handleRenameCourseName
=
(
e
,
record
)
=>
{
handleRenameCourseName
=
(
e
,
record
)
=>
{
const
{
value
}
=
e
.
target
;
const
{
value
}
=
e
.
target
;
const
{
data
}
=
this
.
props
;
const
{
data
Source
}
=
this
.
state
;
record
.
courseName
=
value
;
record
.
courseName
=
value
;
this
.
props
.
onChange
(
data
);
this
.
setState
({
dataSource
,
},()
=>
{
this
.
props
.
onChange
(
dataSource
);})
}
}
handleCourseNameBlur
=
(
e
,
record
)
=>
{
handleCourseNameBlur
=
(
e
,
record
)
=>
{
const
{
value
}
=
e
.
target
;
const
{
value
}
=
e
.
target
;
const
{
data
}
=
this
.
props
;
const
{
data
Source
}
=
this
.
state
;
if
(
value
){
if
(
value
){
record
.
type
=
"text"
;
record
.
type
=
"text"
;
this
.
setState
({
data
});
this
.
setState
({
dataSource
,
},()
=>
{
this
.
props
.
onChange
(
dataSource
);})
}
}
}
}
handleDeleteTask
=
(
index
)
=>
{
handleDeleteTask
=
(
index
)
=>
{
const
{
data
}
=
this
.
props
;
const
{
data
Source
}
=
this
.
state
;
const
newData
=
[...
data
];
const
newData
=
[...
data
Source
];
newData
.
splice
(
index
,
1
);
newData
.
splice
(
index
,
1
);
this
.
props
.
onChange
(
newData
);
this
.
setState
({
dataSource
:
newData
,
},()
=>
{
this
.
props
.
onChange
(
newData
);})
}
}
handleDeleteCourse
=
(
parentIndex
,
index
)
=>
{
handleDeleteCourse
=
(
parentIndex
,
index
)
=>
{
const
{
data
}
=
this
.
props
;
const
{
data
Source
}
=
this
.
state
;
const
newData
=
[...
data
];
const
newData
=
[...
data
Source
];
const
selectData
=
[...
newData
[
parentIndex
].
courseList
]
const
selectData
=
[...
newData
[
parentIndex
].
courseList
]
selectData
.
splice
(
index
,
1
)
selectData
.
splice
(
index
,
1
)
newData
[
parentIndex
].
courseList
=
selectData
;
newData
[
parentIndex
].
courseList
=
selectData
;
this
.
props
.
onChange
(
newData
);
this
.
setState
({
dataSource
:
newData
,
},()
=>
{
this
.
props
.
onChange
(
newData
);})
}
}
showRelatedCourseModal
=
(
index
)
=>
{
showRelatedCourseModal
=
(
index
)
=>
{
...
@@ -245,13 +271,14 @@ class TrainingTask extends React.Component {
...
@@ -245,13 +271,14 @@ class TrainingTask extends React.Component {
}
}
confirmSelectCourse
=
(
selectList
)
=>
{
confirmSelectCourse
=
(
selectList
)
=>
{
const
{
selectedTaskIndex
}
=
this
.
state
;
const
{
selectedTaskIndex
}
=
this
.
state
;
const
{
data
}
=
this
.
props
const
{
data
Source
}
=
this
.
state
const
newData
=
[...
data
];
const
newData
=
[...
data
Source
];
const
selectData
=
[...
newData
[
selectedTaskIndex
].
courseList
]
const
selectData
=
[...
newData
[
selectedTaskIndex
].
courseList
]
const
_selectData
=
[...
selectData
,...
selectList
];
const
_selectData
=
[...
selectData
,...
selectList
];
newData
[
selectedTaskIndex
].
courseList
=
_selectData
;
newData
[
selectedTaskIndex
].
courseList
=
_selectData
;
this
.
setState
({
this
.
setState
({
relatedCourseModalVisible
:
false
,
relatedCourseModalVisible
:
false
,
dataSource
:
newData
,
},()
=>
{
},()
=>
{
this
.
props
.
onChange
(
newData
);
this
.
props
.
onChange
(
newData
);
})
})
...
@@ -259,12 +286,15 @@ class TrainingTask extends React.Component {
...
@@ -259,12 +286,15 @@ class TrainingTask extends React.Component {
render
()
{
render
()
{
const
{
dataSource
,
selectedTaskIndex
,
relatedCourseModalVisible
}
=
this
.
state
;
const
{
dataSource
,
selectedTaskIndex
,
relatedCourseModalVisible
}
=
this
.
state
;
console
.
log
(
"dataSource"
,
dataSource
);
const
{
data
}
=
this
.
props
;
const
{
data
}
=
this
.
props
;
return
(
return
(
<
div
className=
"training-task"
>
<
div
className=
"training-task"
>
<
Table
<
Table
pagination=
{
false
}
pagination=
{
false
}
dataSource=
{
data
}
dataSource=
{
data
Source
}
columns=
{
this
.
parseTaskColumns
()
}
columns=
{
this
.
parseTaskColumns
()
}
rowKey=
"index"
rowKey=
"index"
expandedRowRender=
{
(
record
,
index
)
=>
{
expandedRowRender=
{
(
record
,
index
)
=>
{
...
@@ -274,7 +304,7 @@ class TrainingTask extends React.Component {
...
@@ -274,7 +304,7 @@ class TrainingTask extends React.Component {
pagination=
{
false
}
pagination=
{
false
}
dataSource=
{
record
.
courseList
}
dataSource=
{
record
.
courseList
}
columns=
{
this
.
parseCoursecolumns
(
index
)
}
columns=
{
this
.
parseCoursecolumns
(
index
)
}
rowKey=
"index"
//
rowKey="index"
// components=
{{
// components=
{{
// body:
{
// body:
{
// wrapper: this.DraggableContainer,
// wrapper: this.DraggableContainer,
...
@@ -287,20 +317,19 @@ class TrainingTask extends React.Component {
...
@@ -287,20 +317,19 @@ class TrainingTask extends React.Component {
}
else
{
}
else
{
return
<
div
><
Button
onClick=
{
()
=>
{
this
.
showRelatedCourseModal
(
index
)}
}
><
span
>
+
</
span
><
span
>
关联课程
</
span
></
Button
></
div
>;
return
<
div
><
Button
onClick=
{
()
=>
{
this
.
showRelatedCourseModal
(
index
)}
}
><
span
>
+
</
span
><
span
>
关联课程
</
span
></
Button
></
div
>;
}
}
}
}
}
}
//
components={{
components=
{
{
//
body: {
body
:
{
//
wrapper: this.DraggableContainer,
wrapper
:
this
.
DraggableContainer
,
//
row: this.DraggableBodyRow,
row
:
this
.
DraggableBodyRow
,
//
},
},
//
}}
}
}
/>
/>
<
div
><
Button
onClick=
{
()
=>
this
.
addTask
()
}
><
span
>
+
</
span
><
span
>
添加任务
</
span
></
Button
></
div
>
<
div
><
Button
onClick=
{
()
=>
this
.
addTask
()
}
><
span
>
+
</
span
><
span
>
添加任务
</
span
></
Button
></
div
>
{
relatedCourseModalVisible
&&
{
relatedCourseModalVisible
&&
<
RelatedCourseModal
<
RelatedCourseModal
selectedTaskIndex=
{
selectedTaskIndex
}
selectedTaskIndex=
{
selectedTaskIndex
}
data=
{
data
}
data=
{
data
Source
}
visible=
{
relatedCourseModalVisible
}
visible=
{
relatedCourseModalVisible
}
onClose=
{
this
.
closeRelatedCourseModal
}
onClose=
{
this
.
closeRelatedCourseModal
}
onSelect=
{
this
.
confirmSelectCourse
}
onSelect=
{
this
.
confirmSelectCourse
}
...
...
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