|
|
@@ -0,0 +1,387 @@
|
|
|
+<template>
|
|
|
+ <div class="planner-course-manage">
|
|
|
+ <el-tabs v-model="activeTab" type="border-card">
|
|
|
+ <!-- ========== 认证类别 ========== -->
|
|
|
+ <el-tab-pane label="认证类别" name="category">
|
|
|
+ <div class="pane-toolbar">
|
|
|
+ <el-button type="primary" icon="el-icon-plus" @click="openCategoryDialog()">新增类别</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table :data="categories" v-loading="catLoading" border stripe>
|
|
|
+ <el-table-column prop="id" label="ID" width="70" />
|
|
|
+ <el-table-column prop="code" label="编码" width="130" />
|
|
|
+ <el-table-column prop="name" label="名称" width="150" />
|
|
|
+ <el-table-column prop="description" label="描述" min-width="180" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="requiredHours" label="要求课时" width="100" />
|
|
|
+ <el-table-column label="基础类" width="90">
|
|
|
+ <template slot-scope="{ row }">{{ row.isBase === 1 ? '是' : '否' }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="状态" width="90">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tag size="small" :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '停用' }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="orderIndex" label="排序" width="70" />
|
|
|
+ <el-table-column label="操作" width="160">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-button type="text" size="small" @click="openCategoryDialog(row)">编辑</el-button>
|
|
|
+ <el-button type="text" size="small" style="color:#F56C6C" @click="onCategoryDelete(row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-tab-pane>
|
|
|
+
|
|
|
+ <!-- ========== 线上课程 ========== -->
|
|
|
+ <el-tab-pane label="线上课程" name="course">
|
|
|
+ <div class="pane-toolbar">
|
|
|
+ <el-select v-model="courseFilterCategory" placeholder="选择认证类别" clearable style="width:200px" @change="loadCourses">
|
|
|
+ <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
|
|
|
+ </el-select>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" @click="openCourseDialog()">新增课程</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table :data="courses" v-loading="courseLoading" border stripe>
|
|
|
+ <el-table-column prop="id" label="ID" width="70" />
|
|
|
+ <el-table-column label="类别" width="130">
|
|
|
+ <template slot-scope="{ row }">{{ categoryName(row.categoryId) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="xiaoeResourceId" label="小鹅通资源ID" width="150" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="title" label="课程标题" min-width="200" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="requiredHours" label="课时" width="90" />
|
|
|
+ <el-table-column label="必修" width="80">
|
|
|
+ <template slot-scope="{ row }">{{ row.isRequired === 1 ? '是' : '否' }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="状态" width="90">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tag size="small" :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '停用' }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="160">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-button type="text" size="small" @click="openCourseDialog(row)">编辑</el-button>
|
|
|
+ <el-button type="text" size="small" style="color:#F56C6C" @click="onCourseDelete(row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-tab-pane>
|
|
|
+
|
|
|
+ <!-- ========== 线下课映射 ========== -->
|
|
|
+ <el-tab-pane label="线下课映射" name="offline">
|
|
|
+ <div class="pane-toolbar">
|
|
|
+ <el-button type="primary" icon="el-icon-plus" @click="openOfflineDialog()">新增映射</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table :data="offlineList" v-loading="offlineLoading" border stripe>
|
|
|
+ <el-table-column prop="id" label="ID" width="70" />
|
|
|
+ <el-table-column label="类别" width="130">
|
|
|
+ <template slot-scope="{ row }">{{ categoryName(row.categoryId) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="activityId" label="活动ID" width="110" />
|
|
|
+ <el-table-column prop="durationHours" label="课时(小时)" width="120" />
|
|
|
+ <el-table-column label="必修" width="80">
|
|
|
+ <template slot-scope="{ row }">{{ row.isRequired === 1 ? '是' : '否' }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="状态" width="90">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tag size="small" :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '停用' }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="160">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-button type="text" size="small" @click="openOfflineDialog(row)">编辑</el-button>
|
|
|
+ <el-button type="text" size="small" style="color:#F56C6C" @click="onOfflineDelete(row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+
|
|
|
+ <!-- 类别 dialog -->
|
|
|
+ <el-dialog :title="catForm.id ? '编辑类别' : '新增类别'" :visible.sync="catDialogVisible" width="480px">
|
|
|
+ <el-form label-width="110px">
|
|
|
+ <el-form-item label="编码"><el-input v-model="catForm.code" placeholder="如 planner" /></el-form-item>
|
|
|
+ <el-form-item label="名称"><el-input v-model="catForm.name" /></el-form-item>
|
|
|
+ <el-form-item label="描述"><el-input v-model="catForm.description" type="textarea" /></el-form-item>
|
|
|
+ <el-form-item label="要求课时"><el-input-number v-model="catForm.requiredHours" :min="0" :step="0.5" /></el-form-item>
|
|
|
+ <el-form-item label="基础类">
|
|
|
+ <el-switch v-model="catForm.isBase" :active-value="1" :inactive-value="0" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序"><el-input-number v-model="catForm.orderIndex" :min="0" /></el-form-item>
|
|
|
+ <el-form-item label="状态">
|
|
|
+ <el-switch v-model="catForm.status" :active-value="1" :inactive-value="0" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer">
|
|
|
+ <el-button @click="catDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="catSaving" @click="onCategorySave">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 课程 dialog -->
|
|
|
+ <el-dialog :title="courseForm.id ? '编辑课程' : '新增课程'" :visible.sync="courseDialogVisible" width="480px">
|
|
|
+ <el-form label-width="110px">
|
|
|
+ <el-form-item label="认证类别">
|
|
|
+ <el-select v-model="courseForm.categoryId" placeholder="选择类别" style="width:100%">
|
|
|
+ <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="小鹅通资源ID"><el-input v-model="courseForm.xiaoeResourceId" /></el-form-item>
|
|
|
+ <el-form-item label="课程标题"><el-input v-model="courseForm.title" /></el-form-item>
|
|
|
+ <el-form-item label="课时(小时)"><el-input-number v-model="courseForm.requiredHours" :min="0" :step="0.5" /></el-form-item>
|
|
|
+ <el-form-item label="排序"><el-input-number v-model="courseForm.orderIndex" :min="0" /></el-form-item>
|
|
|
+ <el-form-item label="必修">
|
|
|
+ <el-switch v-model="courseForm.isRequired" :active-value="1" :inactive-value="0" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态">
|
|
|
+ <el-switch v-model="courseForm.status" :active-value="1" :inactive-value="0" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer">
|
|
|
+ <el-button @click="courseDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="courseSaving" @click="onCourseSave">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 线下课映射 dialog -->
|
|
|
+ <el-dialog :title="offlineForm.id ? '编辑映射' : '新增映射'" :visible.sync="offlineDialogVisible" width="480px">
|
|
|
+ <el-form label-width="110px">
|
|
|
+ <el-form-item label="认证类别">
|
|
|
+ <el-select v-model="offlineForm.categoryId" placeholder="选择类别" style="width:100%">
|
|
|
+ <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="活动ID"><el-input-number v-model="offlineForm.activityId" :min="1" /></el-form-item>
|
|
|
+ <el-form-item label="课时(小时)"><el-input-number v-model="offlineForm.durationHours" :min="0" :step="0.5" /></el-form-item>
|
|
|
+ <el-form-item label="必修">
|
|
|
+ <el-switch v-model="offlineForm.isRequired" :active-value="1" :inactive-value="0" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态">
|
|
|
+ <el-switch v-model="offlineForm.status" :active-value="1" :inactive-value="0" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer">
|
|
|
+ <el-button @click="offlineDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="offlineSaving" @click="onOfflineSave">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ plannerCertCategoryList,
|
|
|
+ plannerCertCategoryCreate,
|
|
|
+ plannerCertCategoryUpdate,
|
|
|
+ plannerCertCategoryDelete,
|
|
|
+ plannerCourseList,
|
|
|
+ plannerCourseCreate,
|
|
|
+ plannerCourseUpdate,
|
|
|
+ plannerCourseDelete,
|
|
|
+ plannerOfflineCourseList,
|
|
|
+ plannerOfflineCourseCreate,
|
|
|
+ plannerOfflineCourseUpdate,
|
|
|
+ plannerOfflineCourseDelete
|
|
|
+} from '@/api/plannerCert'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'PlannerCourseManage',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ activeTab: 'category',
|
|
|
+ // 类别
|
|
|
+ catLoading: false,
|
|
|
+ catSaving: false,
|
|
|
+ categories: [],
|
|
|
+ catDialogVisible: false,
|
|
|
+ catForm: {},
|
|
|
+ // 课程
|
|
|
+ courseLoading: false,
|
|
|
+ courseSaving: false,
|
|
|
+ courseFilterCategory: null,
|
|
|
+ courses: [],
|
|
|
+ courseDialogVisible: false,
|
|
|
+ courseForm: {},
|
|
|
+ // 线下课映射
|
|
|
+ offlineLoading: false,
|
|
|
+ offlineSaving: false,
|
|
|
+ offlineList: [],
|
|
|
+ offlineDialogVisible: false,
|
|
|
+ offlineForm: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.loadCategories()
|
|
|
+ this.loadCourses()
|
|
|
+ this.loadOffline()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ categoryName(id) {
|
|
|
+ const c = this.categories.find(x => x.id === id)
|
|
|
+ return c ? c.name : (id || '-')
|
|
|
+ },
|
|
|
+ async loadCategories() {
|
|
|
+ this.catLoading = true
|
|
|
+ try {
|
|
|
+ const res = await plannerCertCategoryList()
|
|
|
+ this.categories = (res && res.data) || []
|
|
|
+ } catch (e) {
|
|
|
+ this.categories = []
|
|
|
+ } finally {
|
|
|
+ this.catLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async loadCourses() {
|
|
|
+ this.courseLoading = true
|
|
|
+ try {
|
|
|
+ const res = await plannerCourseList(this.courseFilterCategory)
|
|
|
+ this.courses = (res && res.data) || []
|
|
|
+ } catch (e) {
|
|
|
+ this.courses = []
|
|
|
+ } finally {
|
|
|
+ this.courseLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async loadOffline() {
|
|
|
+ this.offlineLoading = true
|
|
|
+ try {
|
|
|
+ const res = await plannerOfflineCourseList()
|
|
|
+ this.offlineList = (res && res.data) || []
|
|
|
+ } catch (e) {
|
|
|
+ this.offlineList = []
|
|
|
+ } finally {
|
|
|
+ this.offlineLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // ---- 类别 ----
|
|
|
+ openCategoryDialog(row) {
|
|
|
+ this.catForm = row
|
|
|
+ ? Object.assign({}, row, { isBase: row.isBase == null ? 0 : row.isBase, status: row.status == null ? 1 : row.status })
|
|
|
+ : { code: '', name: '', description: '', requiredHours: 1, isBase: 0, orderIndex: 0, status: 1 }
|
|
|
+ this.catDialogVisible = true
|
|
|
+ },
|
|
|
+ async onCategorySave() {
|
|
|
+ this.catSaving = true
|
|
|
+ try {
|
|
|
+ if (this.catForm.id) {
|
|
|
+ await plannerCertCategoryUpdate(this.catForm)
|
|
|
+ } else {
|
|
|
+ await plannerCertCategoryCreate(this.catForm)
|
|
|
+ }
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ this.catDialogVisible = false
|
|
|
+ this.loadCategories()
|
|
|
+ } catch (e) {
|
|
|
+ // 拦截器已提示
|
|
|
+ } finally {
|
|
|
+ this.catSaving = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onCategoryDelete(row) {
|
|
|
+ try {
|
|
|
+ await this.$confirm('确认删除该类别?', '提示', { type: 'warning' })
|
|
|
+ } catch (e) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await plannerCertCategoryDelete({ id: row.id })
|
|
|
+ this.$message.success('删除成功')
|
|
|
+ this.loadCategories()
|
|
|
+ } catch (e) {
|
|
|
+ // 拦截器已提示
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // ---- 课程 ----
|
|
|
+ openCourseDialog(row) {
|
|
|
+ this.courseForm = row
|
|
|
+ ? Object.assign({}, row, { isRequired: row.isRequired == null ? 1 : row.isRequired, status: row.status == null ? 1 : row.status })
|
|
|
+ : { categoryId: this.courseFilterCategory, xiaoeResourceId: '', title: '', requiredHours: 1, orderIndex: 0, isRequired: 1, status: 1 }
|
|
|
+ this.courseDialogVisible = true
|
|
|
+ },
|
|
|
+ async onCourseSave() {
|
|
|
+ if (!this.courseForm.categoryId) {
|
|
|
+ this.$message.warning('请选择认证类别')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.courseSaving = true
|
|
|
+ try {
|
|
|
+ if (this.courseForm.id) {
|
|
|
+ await plannerCourseUpdate(this.courseForm)
|
|
|
+ } else {
|
|
|
+ await plannerCourseCreate(this.courseForm)
|
|
|
+ }
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ this.courseDialogVisible = false
|
|
|
+ this.loadCourses()
|
|
|
+ } catch (e) {
|
|
|
+ // 拦截器已提示
|
|
|
+ } finally {
|
|
|
+ this.courseSaving = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onCourseDelete(row) {
|
|
|
+ try {
|
|
|
+ await this.$confirm('确认删除该课程?', '提示', { type: 'warning' })
|
|
|
+ } catch (e) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await plannerCourseDelete(row.id)
|
|
|
+ this.$message.success('删除成功')
|
|
|
+ this.loadCourses()
|
|
|
+ } catch (e) {
|
|
|
+ // 拦截器已提示
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // ---- 线下课映射 ----
|
|
|
+ openOfflineDialog(row) {
|
|
|
+ this.offlineForm = row
|
|
|
+ ? Object.assign({}, row, { isRequired: row.isRequired == null ? 1 : row.isRequired, status: row.status == null ? 1 : row.status })
|
|
|
+ : { categoryId: null, activityId: null, durationHours: 1, isRequired: 1, status: 1 }
|
|
|
+ this.offlineDialogVisible = true
|
|
|
+ },
|
|
|
+ async onOfflineSave() {
|
|
|
+ if (!this.offlineForm.categoryId || !this.offlineForm.activityId) {
|
|
|
+ this.$message.warning('请选择类别并填写活动ID')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.offlineSaving = true
|
|
|
+ try {
|
|
|
+ if (this.offlineForm.id) {
|
|
|
+ await plannerOfflineCourseUpdate(this.offlineForm)
|
|
|
+ } else {
|
|
|
+ await plannerOfflineCourseCreate(this.offlineForm)
|
|
|
+ }
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ this.offlineDialogVisible = false
|
|
|
+ this.loadOffline()
|
|
|
+ } catch (e) {
|
|
|
+ // 拦截器已提示
|
|
|
+ } finally {
|
|
|
+ this.offlineSaving = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onOfflineDelete(row) {
|
|
|
+ try {
|
|
|
+ await this.$confirm('确认删除该映射?', '提示', { type: 'warning' })
|
|
|
+ } catch (e) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await plannerOfflineCourseDelete(row.id)
|
|
|
+ this.$message.success('删除成功')
|
|
|
+ this.loadOffline()
|
|
|
+ } catch (e) {
|
|
|
+ // 拦截器已提示
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.planner-course-manage {
|
|
|
+ padding: 16px;
|
|
|
+}
|
|
|
+.pane-toolbar {
|
|
|
+ display: flex;
|
|
|
+ gap: 12px;
|
|
|
+ margin-bottom: 16px;
|
|
|
+}
|
|
|
+</style>
|