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

updates

上级 144a3b74
......@@ -64,11 +64,11 @@ const fetchList = (isReset = false) => {
if (beforeRequest) {
requestParams = beforeRequest(requestParams, isReset)
}
// for (const key in params) {
// if (params[key] === '' || params[key] === undefined || params[key] === undefined) {
// delete params[key]
// }
// }
for (const key in params) {
if (params[key] === '' || params[key] === undefined || params[key] === undefined) {
delete params[key]
}
}
loading.value = true
return (
httpRequest(requestParams)
......
......@@ -2,11 +2,10 @@ import { getQuestionCategory } from '@/api/base'
export function useQuestionList() {
const list = ref([])
const params = { project_tag: 'resourse_ci' }
getQuestionCategory(params).then((res: any) => {
getQuestionCategory({ project_tag: 'resourse_ci' }).then((res: any) => {
list.value = res.data.filter((item: any) => {
item.children = detailChild(item.children)
// return parseInt(item.status)
return item.children
})
})
......@@ -14,7 +13,7 @@ export function useQuestionList() {
if (!child) return []
return child.filter((item: any) => {
item.children = detailChild(item.children)
// return parseInt(item.status)
return item.children
})
}
return { list }
......
......@@ -23,7 +23,7 @@ export function searchExam(params: {
page?: 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 }) {
export function getLiveList(params: { name: string; page?: number; ['page_size']?: number }) {
return httpRequest.get('/api/resource/v1/course/course/search-live', { params })
}
<script setup lang="ts">
import { searchExam } from '../../api'
const emit = defineEmits(['change'])
import AddExamDialog from './AddExamDialog.vue'
const props = defineProps({
data: {
type: Array
}
})
const emit = defineEmits(['change'])
const listOptions = computed(() => {
return {
columns: [
// { label: '', slots: 'table-avatar', align: 'center' },
{ label: '试卷名称', prop: 'paper_title', align: 'center' },
{
label: '组卷模式',
......@@ -36,81 +33,27 @@ const listOptions = computed(() => {
{ label: '及格分数', prop: 'pass_score', 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 index = lecturerValue.value.findIndex((ids: string) => ids === id)
lecturerValue.value.splice(index, 1)
changeData()
const index = addExam.value.findIndex((ids: string) => ids === id)
addExam.value.splice(index, 1)
handleAddExam('')
}
const changeData = () => {
emit('change', lecturerValue.value)
const handleAddExam = (val: any) => {
addExam.value = val
emit('change', val)
}
</script>
<template>
<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">
<template #table-avatar="{ row }">
<img :src="row.avatar" style="width: 50px; height: 50px; display: block; margin: 0 auto" />
......@@ -122,29 +65,10 @@ const changeData = () => {
<el-button plain @click="removeLectuter(row.id)">删除</el-button>
</template>
</AppList>
<el-dialog v-model="dialogVisible" width="400px" title="添加考试">
<div style="display: flex; justify-content: center">
<el-select
@change="changeData"
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>
<AddExamDialog
v-if="isShowExamDialog === true"
v-model:isShowExamDialog="isShowExamDialog"
@create="handleAddExam"
/>
</div>
</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 {
const listOptions = {
remote: {
httpRequest: searchExam,
beforeRequest(params: any) {
params.paper_categories = [params.paper_categories]
return params
},
callback(data: any) {
return { list: data.data }
},
......@@ -50,7 +54,7 @@ const listOptions = {
}
},
filters: [
{ prop: 'classification', label: '类别:', slots: 'filter-type' },
{ prop: 'paper_categories', label: '类别:', slots: 'filter-type' },
{ type: 'input', prop: 'paper_title', label: '标题:' }
],
columns: [
......@@ -71,7 +75,7 @@ const listOptions = {
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_total_score' },
{ label: '及格分数', prop: 'pass_score' },
......
......@@ -2,7 +2,7 @@
const props: any = defineProps<{ data: object; tabIndex: string }>()
</script>
<template>
<div>{{ props.data }}</div>
<!-- <div>{{ props.data }}</div> -->
<div class="card-item">
<div class="card-item-top">
<div class="title">{{ props.data.name }}</div>
......@@ -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="tool-pop-btn">
<div style="min-width: 100%">
<router-link v-if="props.data.auth_view" :to="`/resource/video/view?id=${props.data.id}`">
<div class="view-btn">查看</div>
<router-link v-if="props.data.auth_edit" :to="`/resource/video/update?id=${props.data.id}`">
<div class="edit-btn">编辑</div>
</router-link>
</div>
<div style="min-width: 100%">
<!-- <router-link v-if="props.data.auth_view" :to="`/resource/video/view?id=${props.data.id}`"> -->
<div class="view-btn">选择</div>
<!-- </router-link> -->
<router-link v-if="props.data.auth_view" :to="`/resource/video/view?id=${props.data.id}`">
<div class="view-btn">查看</div>
</router-link>
</div>
</div>
</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论