Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-learn
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-learn
Commits
8ba26b13
提交
8ba26b13
authored
10月 26, 2022
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: #3200
上级
a593ff3f
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
6 行删除
+14
-6
useGetCourseList.ts
src/composables/useGetCourseList.ts
+2
-1
PostForm.vue
src/modules/bbs/components/PostForm.vue
+12
-5
没有找到文件。
src/composables/useGetCourseList.ts
浏览文件 @
8ba26b13
...
...
@@ -18,13 +18,14 @@ interface Chapter {
id
:
string
name
:
string
}
const
courses
=
ref
<
Course
[]
>
([])
export
function
useGetCourseList
()
{
const
courseValue
=
ref
(
''
)
const
courses
=
ref
<
Course
[]
>
([])
const
chapters
=
ref
<
Chapter
[]
>
([])
// 获取课程列表
function
getCourses
()
{
if
(
courses
.
value
.
length
)
return
getCourseList
().
then
(
res
=>
{
courses
.
value
=
res
.
data
.
items
})
...
...
src/modules/bbs/components/PostForm.vue
浏览文件 @
8ba26b13
...
...
@@ -6,6 +6,7 @@ import { createPost } from '../api'
import
{
useMapStore
}
from
'@/stores/map'
import
{
useGetCourseList
}
from
'@/composables/useGetCourseList'
import
{
isVideo
}
from
'@/utils/index'
import
{
useStorage
}
from
'@vueuse/core'
interface
Props
{
courseId
?:
string
...
...
@@ -23,7 +24,8 @@ const { courses, courseValue, chapters } = useGetCourseList()
const
types
=
useMapStore
().
getMapValuesByKey
(
'learning_discussion_type'
)
const
formRef
=
$ref
<
FormInstance
>
()
const
form
=
reactive
({
const
form
=
$
(
useStorage
(
'bbsPost'
,
{
semester_id
:
props
.
semesterId
||
''
,
course_id
:
props
.
courseId
||
''
,
chapter_id
:
''
,
...
...
@@ -31,7 +33,8 @@ const form = reactive({
title
:
''
,
content
:
''
,
files
:
[]
})
})
)
const
rules
=
ref
<
FormRules
>
({
course_id
:
[{
required
:
true
,
message
:
'请选择课程'
,
trigger
:
'change'
}],
chapter_id
:
[{
required
:
true
,
message
:
'请选择章节'
,
trigger
:
'change'
}],
...
...
@@ -42,9 +45,11 @@ const rules = ref<FormRules>({
watchEffect
(()
=>
{
courseValue
.
value
=
form
.
course_id
const
course
=
courses
.
value
.
find
(
item
=>
item
.
course_id
===
form
.
course_id
)
form
.
chapter_id
=
''
form
.
semester_id
=
course
?
course
.
semester
.
id
:
''
})
function
handleCourseChange
()
{
form
.
chapter_id
=
''
}
// 提交
function
handleSubmit
()
{
formRef
?.
validate
().
then
(
create
)
...
...
@@ -56,6 +61,8 @@ const create = () => {
ElMessage
({
message
:
'发布成功'
,
type
:
'success'
})
emit
(
'update'
)
emit
(
'update:modelValue'
,
false
)
// 清空本地存储
localStorage
.
removeItem
(
'bbsPost'
)
})
}
...
...
@@ -84,10 +91,10 @@ function onChange(file: any, files: any, uploadRef: any) {
width=
"800px"
:close-on-click-modal=
"false"
@
update:modelValue=
"$emit('update:modelValue')"
>
<el-form
ref=
"formRef"
:model=
"form"
:rules=
"rules"
hide-required-asterisk
label-position=
"top"
>
<el-form
ref=
"formRef"
:model=
"form"
:rules=
"rules"
label-position=
"top"
>
<el-row
justify=
"space-between"
>
<el-form-item
label=
"相关课程"
prop=
"course_id"
v-if=
"!courseId"
>
<el-select
filterable
v-model=
"form.course_id"
>
<el-select
filterable
v-model=
"form.course_id"
@
change=
"handleCourseChange"
>
<el-option
v-for=
"item in courses"
:key=
"item.id"
:label=
"item.name"
:value=
"item.course_id"
></el-option>
</el-select>
</el-form-item>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论