提交 ac3ddde5 authored 作者: matian's avatar matian

updates

上级 144a3b74
...@@ -64,11 +64,11 @@ const fetchList = (isReset = false) => { ...@@ -64,11 +64,11 @@ const fetchList = (isReset = false) => {
if (beforeRequest) { if (beforeRequest) {
requestParams = beforeRequest(requestParams, isReset) requestParams = beforeRequest(requestParams, isReset)
} }
// for (const key in params) { for (const key in params) {
// if (params[key] === '' || params[key] === undefined || params[key] === undefined) { if (params[key] === '' || params[key] === undefined || params[key] === undefined) {
// delete params[key] delete params[key]
// } }
// } }
loading.value = true loading.value = true
return ( return (
httpRequest(requestParams) httpRequest(requestParams)
......
...@@ -2,11 +2,10 @@ import { getQuestionCategory } from '@/api/base' ...@@ -2,11 +2,10 @@ import { getQuestionCategory } from '@/api/base'
export function useQuestionList() { export function useQuestionList() {
const list = ref([]) const list = ref([])
const params = { project_tag: 'resourse_ci' } getQuestionCategory({ project_tag: 'resourse_ci' }).then((res: any) => {
getQuestionCategory(params).then((res: any) => {
list.value = res.data.filter((item: any) => { list.value = res.data.filter((item: any) => {
item.children = detailChild(item.children) item.children = detailChild(item.children)
// return parseInt(item.status) return item.children
}) })
}) })
...@@ -14,7 +13,7 @@ export function useQuestionList() { ...@@ -14,7 +13,7 @@ export function useQuestionList() {
if (!child) return [] if (!child) return []
return child.filter((item: any) => { return child.filter((item: any) => {
item.children = detailChild(item.children) item.children = detailChild(item.children)
// return parseInt(item.status) return item.children
}) })
} }
return { list } return { list }
......
...@@ -23,7 +23,7 @@ export function searchExam(params: { ...@@ -23,7 +23,7 @@ export function searchExam(params: {
page?: string page?: string
limit?: string limit?: string
}) { }) {
return httpRequest.get(`/api/qbs/admin/v2/question-papers/${params.project_tag}`, { params }) return httpRequest.get(`/api/qbs/admin/v2/question-papers/resourse_ci`, { params })
} }
// 新建课件 // 新建课件
...@@ -204,4 +204,3 @@ export function delCharacter(data: { id: string; course_id: string }) { ...@@ -204,4 +204,3 @@ export function delCharacter(data: { id: string; course_id: string }) {
export function getLiveList(params: { name: string; page?: number; ['page_size']?: number }) { export function getLiveList(params: { name: string; page?: number; ['page_size']?: number }) {
return httpRequest.get('/api/resource/v1/course/course/search-live', { params }) return httpRequest.get('/api/resource/v1/course/course/search-live', { params })
} }
<script setup lang="ts"> <script setup lang="ts">
import { searchExam } from '../../api' import AddExamDialog from './AddExamDialog.vue'
const emit = defineEmits(['change'])
const props = defineProps({ const props = defineProps({
data: { data: {
type: Array type: Array
} }
}) })
const emit = defineEmits(['change'])
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
columns: [ columns: [
// { label: '', slots: 'table-avatar', align: 'center' },
{ label: '试卷名称', prop: 'paper_title', align: 'center' }, { label: '试卷名称', prop: 'paper_title', align: 'center' },
{ {
label: '组卷模式', label: '组卷模式',
...@@ -36,81 +33,27 @@ const listOptions = computed(() => { ...@@ -36,81 +33,27 @@ const listOptions = computed(() => {
{ label: '及格分数', prop: 'pass_score', align: 'center' }, { label: '及格分数', prop: 'pass_score', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center' } { label: '操作', slots: 'table-operate', align: 'center' }
], ],
data: allLecturers.value.filter((item: any) => lecturerValue.value.find((i: any) => i === item.id)) data: props.data
} }
}) })
const addExam = ref([])
const isShowExamDialog = ref(false)
// 试卷弹窗 // // 删除考试
const dialogVisible = ref(false)
interface ListItem {
paper_title: string
id: string
}
const options = ref<ListItem[]>([])
const loading = ref(false)
// 所有被搜索出来的值
const allLecturers: any = ref([])
// 考试选中的值
const lecturerValue = ref([])
// 远程搜索
const remoteMethod = (query: string) => {
if (query) {
loading.value = true
searchExam({
project_tag: 'resourse_ci',
id: '',
paper_title: '',
permission: '1',
paper_type: '',
paper_labels: '',
paper_category: '',
paper_categories: ''
}).then((res: any) => {
loading.value = false
options.value = res.data.data
options.value.forEach((item: any) => {
const findItem = allLecturers.value.find((cItem: any) => cItem.id === item.id)
if (!findItem) {
allLecturers.value.push(item)
}
})
})
} else {
options.value = []
}
}
watch(
() => props.data,
value => {
if (value?.length) {
const list: any = value.map((item: any) => {
return item.id
})
lecturerValue.value = list
allLecturers.value = value
options.value = value as []
}
},
{ immediate: true }
)
// 删除考试
const removeLectuter = (id: string) => { const removeLectuter = (id: string) => {
const index = lecturerValue.value.findIndex((ids: string) => ids === id) const index = addExam.value.findIndex((ids: string) => ids === id)
lecturerValue.value.splice(index, 1) addExam.value.splice(index, 1)
changeData() handleAddExam('')
} }
const handleAddExam = (val: any) => {
const changeData = () => { addExam.value = val
emit('change', lecturerValue.value) emit('change', val)
} }
</script> </script>
<template> <template>
<div> <div>
<el-button type="primary" @click="dialogVisible = true">添加课程考试</el-button> <el-button type="primary" @click="isShowExamDialog = true">添加课程考试</el-button>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList">
<template #table-avatar="{ row }"> <template #table-avatar="{ row }">
<img :src="row.avatar" style="width: 50px; height: 50px; display: block; margin: 0 auto" /> <img :src="row.avatar" style="width: 50px; height: 50px; display: block; margin: 0 auto" />
...@@ -122,29 +65,10 @@ const changeData = () => { ...@@ -122,29 +65,10 @@ const changeData = () => {
<el-button plain @click="removeLectuter(row.id)">删除</el-button> <el-button plain @click="removeLectuter(row.id)">删除</el-button>
</template> </template>
</AppList> </AppList>
<el-dialog v-model="dialogVisible" width="400px" title="添加考试"> <AddExamDialog
<div style="display: flex; justify-content: center"> v-if="isShowExamDialog === true"
<el-select v-model:isShowExamDialog="isShowExamDialog"
@change="changeData" @create="handleAddExam"
v-model="lecturerValue" />
multiple
filterable
remote
reserve-keyword
placeholder="请输入试卷名称"
:remote-method="remoteMethod"
:loading="loading"
>
<el-option v-for="item in options" :key="item.id" :label="item.paper_title" :value="item.id" />
</el-select>
</div>
<template #footer>
<span class="dialog-footer">
<!-- <el-button @click="dialogVisible = false">取消</el-button> -->
<el-button type="primary" @click="dialogVisible = false">确认</el-button>
</span>
</template>
</el-dialog>
</div> </div>
</template> </template>
<style lang="scss"></style>
<script setup lang="ts">
import { searchExam } from '../../api'
import { useQuestionList } from '@/composables/useQuestionList'
const appList = ref()
let { list: selectTree } = useQuestionList()
const tabValue = ref('1')
const multipleSelection: any = ref([])
const emit = defineEmits<Emits>()
defineProps({
isShowExamDialog: {
type: Boolean,
required: true
}
})
interface Emits {
(e: 'update:isShowExamDialog', isShowExamDialog: boolean): void
(e: 'create', multipleSelection: any): void
}
const listOptions = {
remote: {
httpRequest: searchExam,
beforeRequest(params: any) {
params.paper_categories = [params.paper_categories]
return params
},
callback(data: any) {
return { list: data.data }
},
params: {
project_tag: 'resourse_ci',
id: '',
paper_title: '',
permission: tabValue,
paper_type: '',
paper_labels: '',
paper_category: '',
paper_categories: ''
}
},
filters: [
{ prop: 'classification', label: '类别:', slots: 'filter-type' },
{ type: 'input', prop: 'paper_title', label: '标题:' }
],
columns: [
{ type: 'selection', fixed: 'left' },
{ type: 'index', label: '序号', fixed: 'left' },
{
label: '组卷模式',
prop: 'paper_type',
computed: (row: any) => {
return row.row.paper_type === 1 ? '选题组卷' : '自动组卷'
}
},
{
label: '试卷用途',
prop: 'paper_uses',
computed: (row: any) => {
const map = { 1: '考试', 2: '课后作业', 3: '课程测试' }
return map[row.row.paper_uses] || row.row.paper_uses
}
},
{ label: '试卷分类', prop: 'paper_category.name', minWidth: 200 },
{ label: '试卷名称', prop: 'paper_title', minWidth: 200 },
{ label: '总分', prop: 'paper_total_score' },
{ label: '及格分数', prop: 'pass_score' },
{ label: '更新时间', prop: 'updated_at' }
]
}
// 资源出处 tab触发
const tabChange = () => {
appList.value?.refetch()
}
const handleCancel = () => {
emit('update:isShowExamDialog', false)
}
// 保存
const handleSave = () => {
emit('update:isShowExamDialog', false)
emit('create', multipleSelection)
}
// 筛选下拉选择tree 视频分类
const defaultProps = {
children: 'children',
label: 'category_name',
value: 'id'
}
// 刷新
const typeFilter = () => {
appList.value.refetch()
}
const handleSelectionChange = (val: any) => {
multipleSelection.value = val
}
</script>
<template>
<el-drawer :model-value="isShowExamDialog" draggable :before-close="handleCancel" size="60%" title="添加考试">
<div class="video-head">
<el-tabs @tab-change="tabChange" v-model="tabValue">
<el-tab-pane label="我的资源" name="1"></el-tab-pane>
<el-tab-pane label="公开资源" name="2"></el-tab-pane>
</el-tabs>
</div>
<AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #filter-type="{ params }">
<el-tree-select
@change="typeFilter"
clearable
:props="defaultProps"
v-model="params.paper_categories"
:data="selectTree"
/>
</template>
</AppList>
<div class="btn-box" style="display: flex; justify-content: center">
<el-button type="primary" @click="handleSave">保存</el-button>
</div>
</el-drawer>
</template>
<style lang="scss">
.card-list {
display: flex;
flex-direction: column;
}
.card-list-con {
background: #fafafa;
padding: 20px;
display: flex;
flex-wrap: wrap;
}
.video-head {
position: relative;
.video-head-icon {
position: absolute;
top: 0;
right: 0;
font-size: 30px;
color: #666;
cursor: pointer;
}
}
.video-tool-btn {
padding: 10px 0 30px 0;
}
</style>
...@@ -35,6 +35,10 @@ interface Emits { ...@@ -35,6 +35,10 @@ interface Emits {
const listOptions = { const listOptions = {
remote: { remote: {
httpRequest: searchExam, httpRequest: searchExam,
beforeRequest(params: any) {
params.paper_categories = [params.paper_categories]
return params
},
callback(data: any) { callback(data: any) {
return { list: data.data } return { list: data.data }
}, },
...@@ -50,7 +54,7 @@ const listOptions = { ...@@ -50,7 +54,7 @@ const listOptions = {
} }
}, },
filters: [ filters: [
{ prop: 'classification', label: '类别:', slots: 'filter-type' }, { prop: 'paper_categories', label: '类别:', slots: 'filter-type' },
{ type: 'input', prop: 'paper_title', label: '标题:' } { type: 'input', prop: 'paper_title', label: '标题:' }
], ],
columns: [ columns: [
...@@ -71,7 +75,7 @@ const listOptions = { ...@@ -71,7 +75,7 @@ const listOptions = {
return map[row.row.paper_uses] || row.row.paper_uses return map[row.row.paper_uses] || row.row.paper_uses
} }
}, },
{ label: '试卷分类', prop: 'paper_category', minWidth: 200 }, { label: '试卷分类', prop: 'paper_category.name', minWidth: 200 },
{ label: '试卷名称', prop: 'paper_title', minWidth: 200 }, { label: '试卷名称', prop: 'paper_title', minWidth: 200 },
{ label: '总分', prop: 'paper_total_score' }, { label: '总分', prop: 'paper_total_score' },
{ label: '及格分数', prop: 'pass_score' }, { label: '及格分数', prop: 'pass_score' },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
const props: any = defineProps<{ data: object; tabIndex: string }>() const props: any = defineProps<{ data: object; tabIndex: string }>()
</script> </script>
<template> <template>
<div>{{ props.data }}</div> <!-- <div>{{ props.data }}</div> -->
<div class="card-item"> <div class="card-item">
<div class="card-item-top"> <div class="card-item-top">
<div class="title">{{ props.data.name }}</div> <div class="title">{{ props.data.name }}</div>
...@@ -10,14 +10,14 @@ const props: any = defineProps<{ data: object; tabIndex: string }>() ...@@ -10,14 +10,14 @@ const props: any = defineProps<{ data: object; tabIndex: string }>()
<div class="cover-img" :style="`background-image:url(${props.data.cover})`"></div> <div class="cover-img" :style="`background-image:url(${props.data.cover})`"></div>
<div class="tool-pop-btn"> <div class="tool-pop-btn">
<div style="min-width: 100%"> <div style="min-width: 100%">
<router-link v-if="props.data.auth_view" :to="`/resource/video/view?id=${props.data.id}`"> <router-link v-if="props.data.auth_edit" :to="`/resource/video/update?id=${props.data.id}`">
<div class="view-btn">查看</div> <div class="edit-btn">编辑</div>
</router-link> </router-link>
</div> </div>
<div style="min-width: 100%"> <div style="min-width: 100%">
<!-- <router-link v-if="props.data.auth_view" :to="`/resource/video/view?id=${props.data.id}`"> --> <router-link v-if="props.data.auth_view" :to="`/resource/video/view?id=${props.data.id}`">
<div class="view-btn">选择</div> <div class="view-btn">查看</div>
<!-- </router-link> --> </router-link>
</div> </div>
</div> </div>
</div> </div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论