Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
c392e6b8
提交
c392e6b8
authored
11月 07, 2024
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 关联知识图谱对接接口
上级
a7fb05b3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
72 行增加
和
49 行删除
+72
-49
api.js
src/pages/books/section/api.js
+10
-0
BindKnowledgeGraph.jsx
src/pages/books/section/components/BindKnowledgeGraph.jsx
+61
-48
axios.js
src/utils/axios.js
+1
-1
没有找到文件。
src/pages/books/section/api.js
浏览文件 @
c392e6b8
...
...
@@ -44,3 +44,13 @@ export function getChapterEditors(data) {
export
function
updateChapterEditors
(
data
)
{
return
axios
.
post
(
'/api/book/teacher/chapter/saveEditors'
,
data
)
}
// 知识图谱列表
export
function
getTagList
(
params
)
{
return
axios
.
get
(
'/api/resource/v1/course/course/tag-list'
,
{
params
})
}
// 知识图谱关联书籍章节
export
function
bindTag
(
data
)
{
return
axios
.
post
(
'/api/resource/v1/course/course/tag-add-book'
,
data
)
}
src/pages/books/section/components/BindKnowledgeGraph.jsx
浏览文件 @
c392e6b8
import
{
useState
,
useEffect
}
from
'react'
import
{
Modal
,
Tree
Select
,
App
}
from
'antd'
import
{
get
ChapterEditors
,
updateChapterEditors
}
from
'../api'
import
{
useState
,
useEffect
,
useCallback
}
from
'react'
import
{
Modal
,
Tree
,
App
,
Button
,
Flex
}
from
'antd'
import
{
get
TagList
,
bindTag
}
from
'../api'
const
EditChapterEditors
=
({
chapter
=
{},
onOk
,
...
props
})
=>
{
function
getIds
(
nodes
)
{
let
ids
=
[]
nodes
.
forEach
(
node
=>
{
ids
.
push
(
node
.
id
)
if
(
node
.
children
&&
node
.
children
.
length
>
0
)
{
ids
=
ids
.
concat
(
getIds
(
node
.
children
))
}
})
return
ids
}
const
BindKnowledgeGraph
=
({
chapter
=
{},
...
props
})
=>
{
const
{
message
}
=
App
.
useApp
()
const
[
value
,
setValue
]
=
useState
(
''
)
const
[
treeData
,
setTreeData
]
=
useState
([
{
id
:
'1'
,
name
:
'项目一:初识商务数据分析'
,
children
:
[
{
id
:
'1-1'
,
name
:
'任务一:人人都需要商务数据分析'
,
children
:
[
{
id
:
'1-1-1'
,
name
:
' 商务数据分析就业情况'
,
children
:
[
{
id
:
'1-1-1-1'
,
name
:
' 商务数据分析师岗位'
},
{
id
:
'1-1-1-2'
,
name
:
' 商务数据分析师的市场优势'
},
{
id
:
'1-1-1-3'
,
name
:
' 商务数据分析师的工作职责'
}
]
}
]
}
]
}
])
useEffect
(()
=>
{
getChapterEditors
({
book_id
:
chapter
.
book_id
,
chapter_id
:
chapter
.
id
}).
then
(
res
=>
{
const
value
=
res
.
data
.
selected_editor_ids
[
0
]
||
''
setValue
(
value
)
const
[
treeData
,
setTreeData
]
=
useState
([])
const
[
expandedKeys
,
setExpandedKeys
]
=
useState
([])
const
fetchList
=
useCallback
(()
=>
{
getTagList
({
type
:
2
,
parent_id
:
chapter
.
book_id
,
chapter_id
:
chapter
.
id
}).
then
(
res
=>
{
setTreeData
(
res
.
data
)
setExpandedKeys
(
getIds
(
res
.
data
))
})
},
[
chapter
])
const
handleSubmit
=
async
()
=>
{
message
.
success
(
'关联成功'
)
onOk
?.()
useEffect
(()
=>
{
fetchList
()
},
[
fetchList
])
const
toggleBind
=
async
node
=>
{
await
bindTag
({
tag_id
:
node
.
id
,
book_id
:
chapter
.
book_id
,
chapter_id
:
chapter
.
id
,
option_type
:
node
.
is_checked
?
'delete'
:
'add'
})
message
.
success
(
'操作成功'
)
fetchList
()
}
const
titleRender
=
node
=>
{
return
(
<
Flex
justify=
"space-between"
>
<
span
>
{
node
.
name
}
</
span
>
<
Button
color=
"primary"
variant=
"link"
size=
"small"
onClick=
{
()
=>
toggleBind
(
node
)
}
>
{
node
.
is_checked
?
'取消关联'
:
'关联'
}
</
Button
>
</
Flex
>
)
}
return
(
<
Modal
title=
"关联知识图谱"
centered
{
...
props
}
onOk=
{
handleSubmit
}
>
<
TreeSelect
<
Modal
title=
"关联知识图谱"
centered
{
...
props
}
footer=
{
null
}
>
<
Tree
blockNode
selectable=
{
false
}
treeData=
{
treeData
}
fieldNames=
{
{
title
:
'name'
,
key
:
'id'
}
}
expandedKeys=
{
expandedKeys
}
titleRender=
{
titleRender
}
/>
{
/* <TreeSelect
multiple
showSearch
treeDefaultExpandAll
value={value}
treeData={treeData}
fieldNames={{ label: 'name', value: 'id' }}
style=
{
{
width
:
'100%'
}
}
></
TreeSelect
>
onChange={setValue}
style={{ width: '100%' }}></TreeSelect> */
}
</
Modal
>
)
}
export
default
EditChapterEditors
export
default
BindKnowledgeGraph
src/utils/axios.js
浏览文件 @
c392e6b8
...
...
@@ -90,7 +90,7 @@ httpRequest.interceptors.response.use(
}
return
Promise
.
reject
(
data
)
}
if
(
data
.
code
!==
200
)
{
if
(
data
.
code
!==
200
&&
data
.
code
!==
0
)
{
notification
.
error
({
message
:
data
.
message
||
'请求错误'
})
return
Promise
.
reject
(
data
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论