提交 7b2c9d89 authored 作者: lihuihui's avatar lihuihui

新建课程

上级 a0a30a00
......@@ -57,7 +57,7 @@ export const menus: IMenuItem[] = [
tag: 'v1-course-create',
icon: Edit,
name: '新建课程',
path: '/course/course/update-course'
path: '/course/update-course'
}
]
},
......
......@@ -20,14 +20,24 @@ export function createCourse(data: any) {
return httpRequest.post('/api/resource/v1/course/course/create', data)
}
// 更新课件
export function updateCourse(data: any) {
return httpRequest.post('/api/resource/v1/course/course/update', data)
}
// 获取封面列表
export function getCoverList() {
return httpRequest.get('/api/resource/v1/util/get-cover-list')
}
// 获取视频详情
export function getVideoDetails(params: { id: string }) {
return httpRequest.get('/api/resource/v1/resource/video/view', { params })
// 获取课程详情
export function getCourseDetails(params: { id: string }) {
return httpRequest.get('/api/resource/v1/course/course/view', { params })
}
// 上下线
export function setStatus(data: { id: string }) {
return httpRequest.post('/api/resource/v1/course/course/set-status', data)
}
// 更新视频
......@@ -45,11 +55,6 @@ export function setPlatform(data: { id: string }) {
return httpRequest.post('/api/resource/v1/resource/video/set-platform', data)
}
// 上下线
export function setStatus(data: { id: string }) {
return httpRequest.post('/api/resource/v1/resource/video/set-status', data)
}
// 更改负责人
export function setBelong(data: { id: string; belong_operator: string }) {
return httpRequest.post('/api/resource/v1/resource/video/set-belong', data)
......
......@@ -3,7 +3,12 @@ import { searchExam } from '../api'
const emit = defineEmits(['change'])
let lecturerList: any = ref([])
const props = defineProps({
data: {
type: Array
}
})
const listOptions = computed(() => {
return {
columns: [
......@@ -31,7 +36,7 @@ const listOptions = computed(() => {
{ label: '及格分数', prop: 'pass_score', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center' }
],
data: lecturerList.value
data: allLecturers.value.filter((item: any) => lecturerValue.value.find((i: any) => i === item.id))
}
})
......@@ -56,15 +61,13 @@ const remoteMethod = (query: string) => {
paper_title: query,
limit: '100',
is_all: 1,
project_prefix: 'x1',
project_prefix: 'resourse_ci',
signature: 'UG7wBenexQhiuD2wpCwuxkU0jqcj006d',
timestamp: '32322323',
nonce: '3232'
}).then((res: any) => {
loading.value = false
options.value = res.data.data.filter((item: any) => {
return !lecturerValue.value.find((id: string) => id === item.id)
})
options.value = res.data.data
options.value.forEach((item: any) => {
const findItem = allLecturers.value.find((cItem: any) => cItem.id === item.id)
if (!findItem) {
......@@ -77,36 +80,37 @@ const remoteMethod = (query: string) => {
}
}
const changeValue = () => {
lecturerList.value = lecturerValue.value.reduce((a: any, b: any) => {
a.push(allLecturers.value.find((item: any) => item.id === b))
return a
}, [])
}
const changeLecturer = () => {
changeValue()
emit('change', lecturerValue.value)
dialogVisible.value = false
}
const dialogShow = () => {
options.value = []
dialogVisible.value = true
}
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 []
console.log(options.value, 1111)
}
},
{ immediate: true }
)
// 删除考试
const removeLectuter = (id: string) => {
const index = lecturerValue.value.findIndex((ids: string) => ids === id)
lecturerValue.value.splice(index, 1)
changeValue()
changeData()
}
const changeData = () => {
emit('change', lecturerValue.value)
}
</script>
<template>
<div>
<el-button type="primary" @click="dialogShow">添加课程考试</el-button>
<el-button type="primary" @click="dialogVisible = 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" />
......@@ -121,6 +125,7 @@ const removeLectuter = (id: string) => {
<el-dialog v-model="dialogVisible" width="400px" title="添加考试">
<div style="display: flex; justify-content: center">
<el-select
@change="changeData"
v-model="lecturerValue"
multiple
filterable
......@@ -133,12 +138,12 @@ const removeLectuter = (id: string) => {
<el-option v-for="item in options" :key="item.id" :label="item.paper_title" :value="item.id" />
</el-select>
</div>
<template #footer>
<!-- <template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="changeLecturer">确认</el-button>
</span>
</template>
</template> -->
</el-dialog>
</div>
</template>
......
......@@ -3,18 +3,25 @@ import { searchLecturer } from '../api'
const emit = defineEmits(['change'])
let lecturerList: any = ref([])
const props = defineProps({
data: {
type: Array
}
})
// table回显的值
// let lecturerList: any = ref([])
const listOptions = computed(() => {
return {
columns: [
{ label: '头像', slots: 'table-avatar', align: 'center' },
{ label: '姓名', prop: 'name', align: 'center' },
{ label: '职位', prop: 'title', align: 'center' },
{ label: '机构', prop: 'office', align: 'center' },
// { label: '职位', prop: 'title', align: 'center' },
// { label: '机构', prop: 'office', align: 'center' },
{ label: '简介', slots: 'table-summarize', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center' }
],
data: lecturerList.value
data: allLecturers.value.filter((item: any) => lecturerValue.value.find((i: any) => i === item.id))
}
})
......@@ -37,9 +44,7 @@ const remoteMethod = (query: string) => {
loading.value = true
searchLecturer({ name: query, 'per-page': '100' }).then((res: any) => {
loading.value = false
options.value = res.data.list.filter((item: any) => {
return !lecturerValue.value.find((id: string) => id === item.id)
})
options.value = res.data.list
options.value.forEach((item: any) => {
const findItem = allLecturers.value.find((cItem: any) => cItem.id === item.id)
if (!findItem) {
......@@ -52,36 +57,36 @@ const remoteMethod = (query: string) => {
}
}
const changeValue = () => {
lecturerList.value = lecturerValue.value.reduce((a: any, b: any) => {
a.push(allLecturers.value.find((item: any) => item.id === b))
return a
}, [])
}
const changeLecturer = () => {
changeValue()
emit('change', lecturerValue.value)
dialogVisible.value = false
}
const dialogShow = () => {
options.value = []
dialogVisible.value = true
}
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)
changeValue()
changeData()
}
const changeData = () => {
emit('change', lecturerValue.value)
}
</script>
<template>
<div>
<el-button type="primary" @click="dialogShow">添加讲师</el-button>
<el-button type="primary" @click="dialogVisible = 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" />
......@@ -96,6 +101,7 @@ const removeLectuter = (id: string) => {
<el-dialog v-model="dialogVisible" width="400px" title="添加讲师">
<div style="display: flex; justify-content: center">
<el-select
@change="changeData"
v-model="lecturerValue"
multiple
filterable
......@@ -108,12 +114,12 @@ const removeLectuter = (id: string) => {
<el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</div>
<template #footer>
<!-- <template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="changeLecturer">确认</el-button>
</span>
</template>
</template> -->
</el-dialog>
</div>
</template>
......
......@@ -3,17 +3,50 @@ import { searchLive } from '../api'
const emit = defineEmits(['change'])
let lecturerList: any = ref([])
const add0 = (m: number) => {
return m < 10 ? '0' + m : m
}
const format = (n: number) => {
const time = new Date(n)
const y = time.getFullYear()
const m = time.getMonth() + 1
const d = time.getDate()
const h = time.getHours()
const mm = time.getMinutes()
const s = time.getSeconds()
return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s)
}
const props = defineProps({
data: {
type: Array
}
})
const listOptions = computed(() => {
return {
columns: [
{ label: '会议code', prop: 'meeting_code', align: 'center' },
{ label: '主题', prop: 'subject', align: 'center' },
{ label: '开始时间', prop: 'start_time', align: 'center' },
{ label: '结束时间', prop: 'end_time', align: 'center' },
{
label: '开始时间',
prop: 'start_time',
align: 'center',
computed({ row }: any) {
return format(parseInt(row.start_time))
}
},
{
label: '结束时间',
prop: 'end_time',
align: 'center',
computed({ row }: any) {
return format(parseInt(row.end_time))
}
},
{ label: '操作', slots: 'table-operate', align: 'center' }
],
data: lecturerList.value
data: allLecturers.value.filter((item: any) => lecturerValue.value.find((i: any) => i === item.id))
}
})
......@@ -36,9 +69,7 @@ const remoteMethod = (query: string) => {
loading.value = true
searchLive({ name: query, 'per-page': '100' }).then((res: any) => {
loading.value = false
options.value = res.data.list.filter((item: any) => {
return !lecturerValue.value.find((id: string) => id === item.id)
})
options.value = res.data.list
options.value.forEach((item: any) => {
const findItem = allLecturers.value.find((cItem: any) => cItem.id === item.id)
if (!findItem) {
......@@ -51,36 +82,36 @@ const remoteMethod = (query: string) => {
}
}
const changeValue = () => {
lecturerList.value = lecturerValue.value.reduce((a: any, b: any) => {
a.push(allLecturers.value.find((item: any) => item.id === b))
return a
}, [])
}
const changeLecturer = () => {
changeValue()
emit('change', lecturerValue.value)
dialogVisible.value = false
}
const dialogShow = () => {
options.value = []
dialogVisible.value = true
}
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)
changeValue()
changeData()
}
const changeData = () => {
emit('change', lecturerValue.value)
}
</script>
<template>
<div>
<el-button type="primary" @click="dialogShow">添加周期性直播</el-button>
<el-button type="primary" @click="dialogVisible = 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" />
......@@ -95,6 +126,7 @@ const removeLectuter = (id: string) => {
<el-dialog v-model="dialogVisible" width="400px" title="添加直播">
<div style="display: flex; justify-content: center">
<el-select
@change="changeData"
v-model="lecturerValue"
multiple
filterable
......@@ -107,12 +139,12 @@ const removeLectuter = (id: string) => {
<el-option v-for="item in options" :key="item.id" :label="item.subject" :value="item.id" />
</el-select>
</div>
<template #footer>
<!-- <template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="changeLecturer">确认</el-button>
</span>
</template>
</template> -->
</el-dialog>
</div>
</template>
......
<script setup lang="ts">
import { setDepartment, setPlatform, setStatus, setBelong } from '../api'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useProjectList } from '@/composables/useGetProjectList'
const router = useRouter()
const route = useRoute()
const props = defineProps(['data'])
// 详情id
const id = route.query.id as string
// 设置部门共享
const handleDepartment = () => {
ElMessageBox.confirm(
`
${
parseInt(props.data.department_public) === 0
? `该操作将会使本视频资源在您所在的部门“${props.data.organ_id_name}”内部共享,管理者不变,其余人员只能共享使用该资源,确认部门共享吗?`
: `该操作将会取消本视频资源在您所在的部门“${props.data.organ_id_name}”内部共享,部门其余人员将不能再看到该共享资源,确认取消部门共享吗?`
}
`,
'提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
setDepartment({ id: id }).then((res: any) => {
if (res.code === 0) {
ElMessage({ message: '更改成功', type: 'success' })
setTimeout(() => {
router.go(0)
}, 500)
}
})
})
}
// 设置平台共享
const handlePlatform = () => {
ElMessageBox.confirm(
`
${
parseInt(props.data.platform_public) === 0
? '该操作将会使本视频资源在e-SaaS平台中公开共享供所有老师使用,资源的管理者不变,其余人员只能共享使用该资源,确认公开该资源吗?'
: '该操作将会取消本视频资源在e-SaaS平台中公开共享,平台所有人员将不能再看到该共享资源,确认取消平台共享吗?'
}
`,
'提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
setPlatform({ id: id }).then((res: any) => {
if (res.code === 0) {
ElMessage({ message: '更改成功', type: 'success' })
setTimeout(() => {
router.go(0)
}, 500)
}
})
})
}
// 上下线设置
const handleStatus = () => {
ElMessageBox.confirm(
`
${
parseInt(props.data.status) === 1
? '已下线的资源将不能被关联到课程使用,确认下线该资源吗?'
: '确认再次上线该资源吗?'
}
`,
'提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
setStatus({ id: id }).then((res: any) => {
if (res.code === 0) {
ElMessage({ message: '更改成功', type: 'success' })
setTimeout(() => {
router.go(0)
}, 500)
}
})
})
}
// 更该负责人
const form = reactive({
members: ''
})
const dialogFormVisible = ref(false)
// 人员列表
let members: any = ref([])
// 点击更改负责人按钮弹窗
const handleMembers = () => {
dialogFormVisible.value = true
members.value = useProjectList(props.data.organ_id).members
}
// 更改负责人确定
const handlesetBelong = () => {
setBelong({ id: id, belong_operator: form.members }).then((res: any) => {
if (res.code === 0) {
ElMessage({ message: '更改成功', type: 'success' })
setTimeout(() => {
dialogFormVisible.value = false
}, 500)
}
})
}
</script>
<template>
<div class="tool-btn-box" v-if="$route.query.id" style="margin-bottom: 20px">
<div v-if="props.data.auth_department" class="btn-item" @click="handleDepartment">
{{ props.data.department_public == 0 ? '部门共享' : '取消部门共享' }}
</div>
<div v-if="props.data.auth_platform" class="btn-item" @click="handlePlatform">
{{ props.data.platform_public == 0 ? '平台共享' : '取消平台共享' }}
</div>
<div
v-if="props.data.auth_status"
v-permission="'v1-resource-video-set-status'"
class="btn-item"
@click="handleStatus"
>
{{ props.data.status == 0 ? '资源上线' : '资源下线' }}
</div>
<div v-if="props.data.auth_belong" class="btn-item" @click="handleMembers">更改负责人</div>
</div>
<el-dialog v-model="dialogFormVisible" title="更改负责人" center>
<el-form :model="form">
<el-form-item>
<div style="width: 500px">
<el-row>
<el-col :span="12"
><div class="grid-content ep-bg-purple" />
资源创建人: {{ props.data.created_operator_name }}
</el-col>
<el-col :span="12"
><div class="grid-content ep-bg-purple-light" />
创建时间: {{ props.data.created_time }}
</el-col>
</el-row>
<el-row>
<el-col :span="12"
><div class="grid-content ep-bg-purple" />
资源负责人: {{ props.data.belong_operator_name }}
</el-col>
<el-col :span="12"
><div class="grid-content ep-bg-purple-light" />
更新时间: {{ props.data.updated_time }}
</el-col>
</el-row>
</div>
<el-select style="width: 500px; margin-top: 20px" v-model="form.members" placeholder="请选择新的资源负责人">
<el-option v-for="item in members.value" :label="item.name" :value="item.id" :key="item.id" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="handlesetBelong">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<style lang="scss" scoped>
.tool-btn-box {
display: flex;
justify-content: right;
.btn-item {
width: 127px;
line-height: 36px;
background: #aa1941;
border-radius: 20px;
margin-right: 10px;
font-size: 14px;
color: #ffffff;
text-align: center;
cursor: pointer;
}
}
</style>
<script setup lang="ts">
import { createCourse } from '../api'
import { createCourse, getCourseDetails, updateCourse, setStatus } from '../api'
import { useGetCategoryList } from '@/composables/useGetCategoryList'
import { useMapStore } from '@/stores/map'
import VEditor from '@/components/tinymce/Index.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
// import Operation from './Operation.vue'
// 课程封面
import AddCourseCover from './AddCourseCover.vue'
// 添加讲师
......@@ -14,8 +16,19 @@ import AddLive from './AddLive.vue'
const store = useMapStore()
const route = useRoute()
const router = useRouter()
const id = route.query.id as string
// is 编辑 新建
const isUpdate = $computed(() => {
return !!route.query.id
})
interface ICourseList {
label: string,
label: string
value: string
}
// 课程类型
......@@ -37,7 +50,7 @@ const defaultProps = {
}
// form
const form = reactive<Record<string, any>>({
let form = $ref<Record<string, any>>({
source: '2',
cover: 'https://webapp-pub.oss-cn-beijing.aliyuncs.com/center_resource/course-cover.png'
})
......@@ -76,15 +89,78 @@ const changeLive = (data: any) => {
form.live_id = data.toString()
}
// 讲师数据回显
const lecturerList: any = ref([])
// 考试数据回显
const examList: any = ref([])
// 考试数据回显
const liveList: any = ref([])
// 编辑数据回显
if (isUpdate) {
getCourseDetails({ id: id }).then((res: any) => {
form = res.data
lecturerList.value = res.data.lecturers
examList.value = res.data.examinations
liveList.value = res.data.meetings
form.lecturer_id = setDefaultData(lecturerList.value)
form.exam_id = setDefaultData(examList.value)
form.live_id = setDefaultData(liveList.value)
})
}
const setDefaultData = (data: object[]) => {
const container: any = []
data.forEach((item: any) => {
container.push(item.id)
})
return container.toString()
}
// 第一步保存后的id
const stepOneId = ref()
// 新建课件
const createCourseForm = () => {
createCourse(form).then((res: any) => {
if (res.code === 0) {
// 操作第二部
stepOneId.value = res.data.id
if (isUpdate) {
updateCourse(form).then((res: any) => {
if (res.code === 0) {
// 操作第二部
stepOneId.value = res.data.id
}
})
} else {
createCourse(form).then((res: any) => {
if (res.code === 0) {
// 操作第二部
stepOneId.value = res.data.id
}
})
}
}
// 上下线设置
const handleStatus = () => {
ElMessageBox.confirm(
`
${
parseInt(form.status) === 1
? '确认下线该资源吗?'
: '确认再次上线该资源吗?'
}
`,
'提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
setStatus({ id: id }).then((res: any) => {
if (res.code === 0) {
ElMessage({ message: '更改成功', type: 'success' })
setTimeout(() => {
router.go(0)
}, 500)
}
})
})
}
</script>
......@@ -92,6 +168,16 @@ const createCourseForm = () => {
<template>
<!-- 基本信息 -->
<div class="update-course-info">
<div class="tool-btn-box">
<div
v-if="form.auth_status"
v-permission="'v1-resource-video-set-status'"
class="btn-item"
@click="handleStatus"
>
{{ form.status == 0 ? '资源上线' : '资源下线' }}
</div>
</div>
<div style="display: flex">
<div class="cover" :style="`background-image: url(${form.cover})`">
<div class="upload-btn" @click="dialogVisible = true">添加封面</div>
......@@ -127,7 +213,7 @@ const createCourseForm = () => {
<el-form ref="ruleFormRef" label-position="top" :model="form" :rules="rules" style="width: 100%; margin-top: 30px">
<el-form-item label="课程讲师:" prop="lecturer_id">
<!-- 添加讲师 -->
<AddLecturer @change="changeLecturer" style="width: 100%"></AddLecturer>
<AddLecturer :data="lecturerList" @change="changeLecturer" style="width: 100%"></AddLecturer>
</el-form-item>
<el-form-item label="课程简介与描述:">
<v-editor v-model="form.represent" class="editor" :height="200"></v-editor>
......@@ -143,15 +229,15 @@ const createCourseForm = () => {
</el-form-item>
<el-form-item label="课程考试:" prop="exam_id">
<!-- 添加考试 -->
<AddExam @change="changeExam" style="width: 100%"></AddExam>
<AddExam :data="examList" @change="changeExam" style="width: 100%"></AddExam>
</el-form-item>
<el-form-item label="课程考试:" prop="live_id">
<!-- 添加直播 -->
<AddLive @change="changeLive" style="width: 100%"></AddLive>
<AddLive :data="liveList" @change="changeLive" style="width: 100%"></AddLive>
</el-form-item>
</el-form>
</div>
<div class="btn-box" style="display: flex;justify-content: center;">
<div class="btn-box" style="display: flex; justify-content: center">
<el-button type="primary" @click="createCourseForm">下一步</el-button>
</div>
<!-- 添加封面 -->
......@@ -179,5 +265,21 @@ const createCourseForm = () => {
cursor: pointer;
}
}
.tool-btn-box {
padding-bottom: 20px;
display: flex;
justify-content: right;
.btn-item {
width: 127px;
line-height: 36px;
background: #aa1941;
border-radius: 20px;
margin-right: 10px;
font-size: 14px;
color: #ffffff;
text-align: center;
cursor: pointer;
}
}
}
</style>
import httpRequest from '@/utils/axios'
// 获取视频列表
export function getVideoList(params: {
export function getCourseList(params: {
tab: string
status?: string
name?: string
authorized?: string
classification?: string
page?: number
page_size?: number
}) {
return httpRequest.get('/api/resource/v1/resource/video/list', { params })
return httpRequest.get('/api/resource/v1/course/course/list', { params })
}
// 获取课程统计
export function getCourseStatistics() {
return httpRequest.get('/api/resource/v1/course/course/statistics')
}
// 创建视频
......@@ -108,6 +112,6 @@ export function delCharacter(data: { id: string; course_id: string }) {
return httpRequest.post('/api/resource/v1/course/course/delete-chapter', data)
}
// 直播列表
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 })
}
<script setup lang="ts">
const prop = defineProps(['data'])
import { getCourseStatistics } from '../api'
// 统计数据
interface IList {
key: string
unit: string
number: number
text: string
}
let data = ref<IList[]>([
{ key: 'platform_course_count', unit: '门', number: 0, text: '平台课程总数' },
{ key: 'department_course_count', unit: '门', number: 0, text: '部门课程总数' },
{ key: 'my_course_count', unit: '门', number: 0, text: '我的课程总数' },
{ key: 'learn_times', unit: '万人次', number: 0, text: '总学习人次' },
{ key: 'learn_time_length', unit: '小时', number: 0, text: '总学习时长' }
])
onMounted(() => {
getCourseStatistics().then(res => {
data.value.map((item: any) => {
item.number = res.data[item.key] || 0
return item
})
})
})
const bytesToSize = (bytes: number) => {
if (bytes === 0) return { number: 0, unit: 'B' }
......@@ -12,7 +37,7 @@ const bytesToSize = (bytes: number) => {
</script>
<template>
<div class="statistics-list">
<div class="item" v-for="(item, index) in prop.data" :key="index">
<div class="item" v-for="(item, index) in data" :key="index">
<template v-if="item.key === 'memory_size'">
<div class="icon"></div>
<div class="num">
......
<script setup lang="ts">
import { getVideoList } from '../api'
import { getCourseList } from '../api'
import CardListItem from '../components/CardListItem.vue'
import { Expand, PictureFilled } from '@element-plus/icons-vue'
import { useGetCategoryList } from '@/composables/useGetCategoryList'
import { useProjectList } from '@/composables/useGetProjectList'
import { useMapStore } from '@/stores/map'
import { useUserStore } from '@/stores/user'
// 统计资源数据整合
......@@ -14,19 +12,9 @@ import Statistics from '../components/Statistics.vue'
const user = useUserStore().roles
const isAdmin = !!user.find((item: any) => item.name === '超级管理员')
const store = useMapStore()
// 筛选部门列表
const departmentList: any = useProjectList('', '79806610719731712').departmentList
// 筛选下拉选择tree 视频分类
let { list: selectTree } = useGetCategoryList()
const defaultProps = {
children: 'children',
label: 'category_name',
value: 'id'
}
// 资源出处 tab触发
const tabValue = ref('1')
const appList = ref()
......@@ -38,17 +26,17 @@ const tabChange = () => {
let isCard = $ref(true)
// table 数据
const listOptions = $computed(() => {
const listOptions = computed(() => {
const columns = [
{
label: '视频标题',
label: '课程标题',
prop: 'name',
align: 'center',
computed({ row }: any) {
return row.name?.length > 10 ? `${row.name.slice(0, 10)}...` : row.name
}
},
{ label: '视频分类', prop: 'classification_name', align: 'center' },
{ label: '课程分类', prop: 'classification_name', align: 'center' },
{ label: '知识点', prop: 'knowledge_points', align: 'center' },
{ label: '封面', slots: 'table-cover', width: 150, align: 'center' },
{ label: '资源状态', prop: 'status_name', align: 'center' },
......@@ -66,18 +54,11 @@ const listOptions = $computed(() => {
}
return {
remote: {
httpRequest: getVideoList,
httpRequest: getCourseList,
params: { tab: tabValue, status: '', authorized: '', name: '' }
},
filters: [
{
type: 'select',
prop: 'status',
label: '状态',
options: store.getMapValuesByKey('system_status')
},
{ prop: 'classification', label: '类别', slots: 'filter-type' },
{ type: 'input', prop: 'name', label: '标题' },
{ type: 'input', prop: 'name', label: '名称' },
{
prop: 'authorized',
slots: 'filter-department'
......@@ -94,19 +75,11 @@ const typeFilter = () => {
const changeCard = () => {
isCard = !isCard
}
const statisticsData = [
{ key: 'courseware_count', unit: '门', number: 0, text: '平台课程总数' },
{ key: 'other_information_count', unit: '门', number: 0, text: '部门课程总数' },
{ key: 'question_count', unit: '门', number: 0, text: '我的课程总数' },
{ key: 'learn_times', unit: '万人次', number: 0, text: '总学习人次' },
{ key: 'learn_time_length', unit: '小时', number: 0, text: '总学习时长' }
]
</script>
<template>
<AppCard title="资源统计">
<Statistics :data="statisticsData"></Statistics>
<Statistics></Statistics>
</AppCard>
<AppCard>
<div class="video-head">
......@@ -119,7 +92,7 @@ const statisticsData = [
</div>
<div class="video-tool-btn">
<router-link v-if="tabValue === '1'" to="/course/my/StepTwo" target="_blank">
<el-button type="primary" round>新建视频资源</el-button>
<el-button type="primary" round>新建课程</el-button>
</router-link>
</div>
<AppList v-bind="listOptions" ref="appList">
......@@ -139,15 +112,6 @@ const statisticsData = [
></div>
</div>
</template>
<template #filter-type="{ params }">
<el-tree-select
@change="typeFilter"
clearable
:props="defaultProps"
v-model="params.classification"
:data="selectTree"
/>
</template>
<template v-if="tabValue == '3' && isAdmin" #filter-department="{ params }">
<div class="name" style="font-size: 14px; color: #606266; padding-right: 12px">部门</div>
<el-select @change="typeFilter" clearable v-model="params.authorized">
......@@ -156,7 +120,7 @@ const statisticsData = [
</template>
<template #table-operate="{ row }">
<el-space>
<router-link v-if="row.auth_edit" :to="`/resource/video/update?id=${row.id}`">
<router-link v-if="row.auth_edit" :to="`/course/update-course?id=${row.id}`">
<el-button plain>编辑</el-button>
</router-link>
<router-link v-permission="'v1-resource-video-view'" :to="`/resource/video/view?id=${row.id}`">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论