提交 4b374cd5 authored 作者: lihuihui's avatar lihuihui
......@@ -2,21 +2,30 @@ import type { IMenuItem } from '@/types'
import { VideoCamera, Suitcase, Collection, Files, Monitor, Edit, User, Filter, Coordinate, Notebook, Picture } from '@element-plus/icons-vue'
export const menus: IMenuItem[] = [
{
tag: 'v1-resource',
name: '资源管理',
path: '/resource',
children: [
{
tag: 'v1-resource-video-list',
icon: VideoCamera,
name: '视频',
path: '/resource/video'
},
{ icon: Suitcase, name: '课件', path: '/resource/courseware' },
{
tag: 'v1-resource-courseware-list',
icon: Suitcase,
name: '课件',
path: '/resource/courseware'
},
{
tag: 'v1-resource-lesson-plan-list',
icon: Collection,
name: '教案',
path: '/resource/lessonplan'
},
{
tag: 'v1-resource-other-information-list',
icon: Files,
name: '其他资料',
path: '/resource/other'
......@@ -32,15 +41,18 @@ export const menus: IMenuItem[] = [
]
},
{
tag: 'v1-course',
name: '课程管理',
path: '/course',
children: [
{
tag: 'v1-course-list',
icon: Monitor,
name: '我的课程',
path: '/course/my'
},
{
tag: 'v1-course-create',
icon: Edit,
name: '新建课程',
path: '/course/create'
......@@ -48,15 +60,18 @@ export const menus: IMenuItem[] = [
]
},
{
tag: 'v1-backend',
name: '后台管理',
path: '/admin',
children: [
{
tag: 'v1-backend-lecturer-list',
icon: User,
name: '讲师管理',
path: '/admin/teacher'
},
{
tag: 'v1-backend-category-list',
icon: Filter,
name: '类别管理',
path: '/admin/category'
......@@ -69,15 +84,18 @@ export const menus: IMenuItem[] = [
]
},
{
tag: 'v1-backend',
name: '系统管理',
path: '/system',
children: [
{
tag: 'v1-backend-data-dictionary-list',
icon: Notebook,
name: '数据字典',
path: '/system/dictionary'
},
{
tag: 'v1-backend-cover-list',
icon: Picture,
name: '封面管理',
path: '/system/cover'
......
......@@ -173,7 +173,14 @@ defineExpose({ refetch, tableRef })
<!-- 主体 -->
<div class="table-list-bd">
<slot name="body" v-bind="{ data: dataList }">
<el-table :data="dataList" v-loading="loading" v-bind="$attrs" style="height: 100%" ref="tableRef">
<el-table
:data="dataList"
v-loading="loading"
v-bind="$attrs"
style="height: 100%"
ref="tableRef"
:header-cell-style="{ background: '#EFEFEF' }"
>
<el-table-column v-bind="item" v-for="item in columns" :key="item.prop">
<template #default="scope" v-if="item.slots || item.computed">
<slot :name="item.slots" v-bind="scope" v-if="item.slots"></slot>
......@@ -213,6 +220,7 @@ defineExpose({ refetch, tableRef })
// flex-direction: column;
// box-sizing: border-box;
// }
.table-list-hd {
display: flex;
margin-bottom: 10px;
......
......@@ -34,15 +34,15 @@ const defaultActive = computed(() => {
<nav class="nav">
<el-menu :default-active="defaultActive" :router="true" class="app-menu">
<template v-for="item in menuList" :key="item.path">
<el-sub-menu :index="item.path" v-if="item.children">
<el-sub-menu :index="item.path" v-permission="item.tag" v-if="item.children">
<template #title>
<el-icon><component :is="item.icon"></component></el-icon>{{ item.name }}
</template>
<el-menu-item :index="subitem.path" v-for="subitem in item.children" :key="subitem.path">
<el-menu-item :index="subitem.path" v-for="subitem in item.children" :key="subitem.path" v-permission="subitem.tag">
{{ subitem.name }}
</el-menu-item>
</el-sub-menu>
<el-menu-item :index="item.path" v-else>
<el-menu-item :index="item.path" v-permission="item.tag" v-else>
<el-icon><component :is="item.icon"></component></el-icon>{{ item.name }}
</el-menu-item>
</template>
......
......@@ -35,7 +35,7 @@ function genNavClassName(data: IMenuItem) {
<h1 class="app-name">统一资源管理平台</h1>
</div>
<div class="app-header-nav">
<div class="app-header-nav-item" v-for="(item, index) in menus" :key="index" :class="genNavClassName(item)">
<div class="app-header-nav-item" v-for="(item, index) in menus" :key="index" :class="genNavClassName(item)" v-permission="item.tag">
<router-link :to="item.path">{{ item.name }}</router-link>
</div>
</div>
......
......@@ -78,8 +78,9 @@ const handleCancel = () => {
}
// 确认提交表单
const handleConfirm = () => {
console.log(props.isEdit, '00000')
if (props.isEdit) {
const params = Object.assign({ id: props.editData.idd }, categoryForm)
const params = Object.assign({ id: props.editData.id }, categoryForm)
updateCategory(params).then(() => {
ElMessage.success('更新类别成功')
emit('update:dialogVisible', false)
......@@ -96,7 +97,7 @@ const handleConfirm = () => {
}
onMounted(() => {
console.log(props.prevCategoryName, 'props.prevCategoryName')
console.log(props.editData.id, '0000')
categoryForm.depth = parseInt(props.editData?.depth) + 1 || 0
categoryForm.parent_id = props.editData?.id
categoryName.value = props.prevCategoryName
......
<script setup lang="ts">
import Sortable from 'sortablejs'
import type { MoveEvent, SortableEvent } from 'sortablejs'
import AddDialog from '../components/AddDialog.vue'
import { getCategoryList, delCategory, moveCategory } from '../api'
import { ElMessage, ElMessageBox } from 'element-plus'
import { checkPermission } from '@/utils/permission'
import AddDialog from '../components/AddDialog.vue'
import AppList from '@/components/base/AppList.vue'
const appList = $ref<null | InstanceType<typeof AppList>>(null)
const prevCategoryName = ref('')
......@@ -179,7 +179,6 @@ const rebuildData = (value: any, arr: any) => {
}
let newArr: any = []
arr.forEach((element: any) => {
console.log(element, 'element')
// indexOf用来判读当前节点name字段是否包含所搜索的字符串value
// 返回值:包含则返回索引值,反之返回-1
if (element.category_name.indexOf(value) > -1) {
......@@ -207,7 +206,7 @@ const rebuildData = (value: any, arr: any) => {
}
onMounted(() => {
useSortable()
checkPermission('v1-backend-category-drag') && useSortable()
})
</script>
<template>
......@@ -222,11 +221,29 @@ onMounted(() => {
border
stripe
>
<el-button type="primary" @click="handleAddCategory" style="margin-bottom: 20px">新增类别</el-button>
<el-button
type="primary"
@click="handleAddCategory"
style="margin-bottom: 20px"
v-permission="'v1-backend-category-create'"
>新增类别</el-button
>
<template #table-operate="{ row }">
<el-link type="primary" style="margin-right: 5px" @click="handleEdit(row)">编辑</el-link>
<el-link type="primary" style="margin-right: 5px" @click="handleAddRow(row)">新增</el-link>
<el-link type="primary" @click="handleDelete(row)">删除</el-link>
<el-link
type="primary"
style="margin-right: 5px"
@click="handleEdit(row)"
v-permission="'v1-backend-category-update'"
>编辑</el-link
>
<el-link
type="primary"
style="margin-right: 5px"
@click="handleAddRow(row)"
v-permission="'v1-backend-category-create'"
>新增</el-link
>
<el-link type="primary" @click="handleDelete(row)" v-permission="'v1-backend-category-delete'">删除</el-link>
</template>
</AppList>
</AppCard>
......
......@@ -42,6 +42,14 @@ const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate(valid => {
if (valid) {
if (ruleForm.education !== '') {
ruleForm.education = store
.getMapValuesByKey('teacher_level')
.filter(item => item.value === ruleForm.education)[0].label
}
// if (ruleForm.avatar === '') {
// ruleForm.avatar = 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png'
// }
const params = Object.assign({}, ruleForm)
createTeacher(params).then(() => {
ElMessage.success('创建讲师成功')
......@@ -56,28 +64,28 @@ const submitForm = async (formEl: FormInstance | undefined) => {
<AppCard title="添加讲师">
<el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm">
<el-row>
<el-col :span="6">
<el-col :span="8">
<el-form-item label="讲师姓名:" prop="name">
<el-input v-model="ruleForm.name" style="width: 250px" placeholder="请输入讲师姓名" />
<el-input v-model="ruleForm.name" style="width: 300px" placeholder="请输入讲师姓名" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-col :span="8">
<el-form-item label="讲师职位:" prop="title">
<el-input v-model="ruleForm.title" style="width: 250px" placeholder="请输入讲师职位" />
<el-input v-model="ruleForm.title" style="width: 300px" placeholder="请输入讲师职位" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="6">
<el-col :span="8">
<el-form-item label="讲师学历:" prop="education">
<el-select v-model="ruleForm.education" clearable style="width: 250px" placeholder="请选择讲师学历">
<el-select v-model="ruleForm.education" clearable style="width: 300px" placeholder="请选择讲师学历">
<el-option v-for="(item, index) in levelList" :key="index" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-col :span="8">
<el-form-item label="讲师任职机构:" prop="office">
<el-input v-model="ruleForm.office" style="width: 250px" placeholder="请输入讲师任职机构" />
<el-input v-model="ruleForm.office" style="width: 300px" placeholder="请输入讲师任职机构" />
</el-form-item>
</el-col>
</el-row>
......
......@@ -4,9 +4,14 @@ import { ElMessage } from 'element-plus'
import type { FormRules, FormInstance } from 'element-plus'
import VEditor from '@/components/tinymce/Index.vue'
import AppUpload from '@/components/base/AppUpload.vue'
import { useMapStore } from '@/stores/map'
const store = useMapStore()
const router = useRouter()
const route = useRoute()
const appList = ref()
const levelList = store.getMapValuesByKey('teacher_level')
const imgDefault = $ref('https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png')
const id = route.query.id as string
const title = route.query.title as string
......@@ -50,20 +55,26 @@ const handleDelete = (row: any) => {
}
const getTeacherInfo = () => {
getTeacherDetail({ id: id }).then(res => {
console.log(res.data)
Object.keys(ruleForm).forEach(key => {
ruleForm[key] = res.data[key]
})
if (ruleForm.avatar === '') {
ruleForm.avatar = imgDefault
}
})
}
// 更新讲师
const handleUpdate = async (formEl: FormInstance | undefined) => {
console.log('0000')
if (!formEl) return
await formEl.validate(valid => {
if (valid) {
const params = Object.assign({}, ruleForm)
params.education = store
.getMapValuesByKey('teacher_level')
.filter(item => item.label === ruleForm.education)[0].label
updateTeacher(params).then(() => {
ElMessage.success('创建讲师成功')
ElMessage.success('更新讲师成功')
router.push('/admin/teacher')
})
}
......@@ -82,8 +93,7 @@ onMounted(() => {
<el-row>
<el-col :span="8">
<el-form-item label="讲师图片:" prop="avatar">
<img v-if="isEdit === '1' && ruleForm.avatar !== ''" :src="ruleForm.avatar" class="avatar_box1" />
<div class="avatar_box" v-else-if="isEdit === '1' && ruleForm.avatar === ''">暂无讲师图片</div>
<el-image v-if="isEdit === '1'" :src="ruleForm.avatar || imgDefault" class="avatar_box1" fit="contain" />
<AppUpload v-model="ruleForm.avatar" v-else />
</el-form-item>
</el-col>
......@@ -95,7 +105,15 @@ onMounted(() => {
<el-input v-model="ruleForm.title" :disabled="isEdit === '1'" />
</el-form-item>
<el-form-item label="讲师学历:" prop="education">
<el-input v-model="ruleForm.education" :disabled="isEdit === '1'" />
<el-select
v-model="ruleForm.education"
clearable
style="width: 250px"
placeholder="请选择讲师学历"
:disabled="isEdit === '1'"
>
<el-option v-for="(item, index) in levelList" :key="index" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="讲师任职机构:" prop="office">
<el-input v-model="ruleForm.office" :disabled="isEdit === '1'" />
......@@ -143,6 +161,7 @@ onMounted(() => {
border: 1px dashed #ccc;
}
.avatar_box1 {
width: 150px;
max-width: 150px;
height: 200px;
}
</style>
......@@ -20,7 +20,8 @@ const listOptions = $computed(() => {
prop: 'education',
label: '讲师学历:',
placeholder: '请选择讲师学历',
options: store.getMapValuesByKey('teacher_level')
options: store.getMapValuesByKey('teacher_level'),
valueKey: 'label'
}
],
columns: [
......@@ -29,7 +30,11 @@ const listOptions = $computed(() => {
{ label: '讲师姓名', prop: 'name', align: 'center' },
{ label: '讲师任职机构', prop: 'office', align: 'center' },
{ label: '讲师职位', prop: 'title', align: 'center' },
{ label: '讲师学历', prop: 'education', align: 'center' },
{
label: '讲师学历',
prop: 'education',
align: 'center'
},
{ label: '创建时间', prop: 'created_time', align: 'center' },
{ label: '操作', slots: 'table-operate', width: 230, align: 'center' }
]
......@@ -67,30 +72,40 @@ const handleDetail = (row: any) => {
}
})
}
const imgDefault = ref('https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png')
</script>
<template>
<AppCard title="讲师管理">
<AppList v-bind="listOptions" ref="appList" border stripe>
<router-link to="/admin/teacher/add">
<el-button type="primary" round style="margin-bottom: 20px">添加讲师</el-button>
<el-button type="primary" round style="margin-bottom: 20px" v-permission="'v1-backend-lecturer-create'"
>添加讲师</el-button
>
</router-link>
<template #header-aside> </template>
<template #table-img="{ row }">
<el-image
:src="row.avatar"
:src="row.avatar || imgDefault"
alt=""
style="width: 50px; height: 50px"
:preview-src-list="[row.avatar]"
:preview-src-list="[row.avatar] || [imgDefault]"
:initial-index="4"
fit="contain"
:preview-teleported="true"
/></template>
/>
</template>
<template #table-operate="{ row }">
<el-space>
<el-link type="primary" plain @click="handleDetail(row)">查看</el-link>
<el-link type="primary" plain @click="handleUpdate(row)">更新</el-link>
<el-link type="primary" plain @click="handleDelete(row)">删除</el-link>
<el-link type="primary" plain @click="handleDetail(row)" v-permission="'v1-backend-lecturer-view'"
>查看</el-link
>
<el-link type="primary" plain @click="handleUpdate(row)" v-permission="'v1-backend-lecturer-update'"
>更新</el-link
>
<el-link type="primary" plain @click="handleDelete(row)" v-permission="'v1-backend-lecturer-delete'"
>删除</el-link
>
</el-space>
</template>
</AppList>
......
......@@ -79,7 +79,7 @@ const listOptions = $computed(() => {
<el-icon class="video-head-icon" @click="isCard = !isCard"><Expand /></el-icon>
</div>
<div class="video-tool-btn">
<router-link to="/resource/video/update">
<router-link to="/resource/video/update" v-permission="'v1-resource-video-create'">
<el-button type="primary" round>新建视频资源</el-button>
</router-link>
</div>
......
......@@ -75,7 +75,14 @@ const handleEdit = (row: any) => {
<AppCard title="封面管理">
<AppList v-bind="listOptions" ref="appList" border stripe>
<template #header-aside> </template>
<el-button type="primary" round @click="handleAdd" style="margin-bottom: 20px">新增封面</el-button>
<el-button
type="primary"
round
@click="handleAdd"
style="margin-bottom: 20px"
v-permission="'v1-backend-cover-create'"
>新增封面</el-button
>
<template #table-cover="{ row }">
<el-image
......@@ -89,8 +96,10 @@ const handleEdit = (row: any) => {
</template>
<template #table-operate="{ row }">
<el-space>
<el-link type="primary" plain @click="handleEdit(row)">编辑</el-link>
<el-link type="primary" plain @click="handleDelete(row)">删除</el-link>
<el-link type="primary" plain @click="handleEdit(row)" v-permission="'v1-backend-cover-update'">编辑</el-link>
<el-link type="primary" plain @click="handleDelete(row)" v-permission="'v1-backend-cover-delete'"
>删除</el-link
>
</el-space>
</template>
<template v-if="isShowDialog === true">
......
......@@ -100,7 +100,13 @@ const handleUpdate = () => {
<AppCard title="数据字典">
<AppList v-bind="listOptions" ref="appList" border stripe>
<el-row>
<el-button type="primary" @click="handleAdd" style="margin-bottom: 20px" v-permission="'test1'">新增字典</el-button>
<el-button
type="primary"
@click="handleAdd"
style="margin-bottom: 20px"
v-permission="'v1-backend-data-dictionary-create'"
>新增字典</el-button
>
</el-row>
<template v-slot:created_time_start="{ params }">
<el-date-picker v-model="params.created_time_start" type="date" placeholder="开始时间"> </el-date-picker>
......@@ -111,9 +117,16 @@ const handleUpdate = () => {
</template>
<template #table-operate="{ row }">
<el-space>
<el-link type="primary" plain @click="handleEdit(row)">编辑</el-link>
<el-link type="primary" plain @click="handleList(row)">列表</el-link>
<el-link type="primary" plain @click="handleDelete(row)">删除</el-link>
<el-link type="primary" plain @click="handleEdit(row)" v-permission="'v1-backend-data-dictionary-update'"
>编辑</el-link
>
<el-link type="primary" plain @click="handleList(row)" v-permission="'v1-backend-data-dictionary-value-list'"
>列表</el-link
>
<el-link type="primary" plain @click="handleDelete(row)" v-permission="'v1-backend-data-dictionary-delete'"
>删除</el-link
>
</el-space>
</template>
<template v-if="isShowDialog === true">
......
......@@ -63,12 +63,26 @@ const handleUpdate = () => {
<AppCard title="字典列表">
<AppList v-bind="listOptions" ref="appList">
<el-row>
<el-button type="primary" @click="handleAdd">新增</el-button>
<el-button type="primary" @click="handleAdd" v-permission="'v1-backend-data-dictionary-value-create'"
>新增</el-button
>
</el-row>
<template #table-operate="{ row }">
<el-space>
<el-link type="primary" plain @click="handleEdit(row)">编辑</el-link>
<el-link type="primary" plain @click="handleDelete(row)">删除</el-link>
<el-link
type="primary"
plain
@click="handleEdit(row)"
v-permission="'v1-backend-data-dictionary-value-update'"
>编辑</el-link
>
<el-link
type="primary"
plain
@click="handleDelete(row)"
v-permission="'v1-backend-data-dictionary-value-delete'"
>删除</el-link
>
</el-space>
</template>
</AppList>
......
import type { Component } from 'vue'
export interface IMenuItem {
tag?: string
name: string
path: string
icon?: Component
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论