123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828 |
- <template>
- <div class="task">
- <step-bar :step-number="2" />
- <!-- 课程基本信息 -->
- <div class="task-course-info">
- <div class="cover"><el-image fit="contain" :src="picture_url" alt="封面" /></div>
- <div class="info">
- <div class="name">{{ name }}</div>
- <div class="date">{{ begin_date }}<span>-</span>{{ end_date }}</div>
- </div>
- </div>
- <!-- 按钮 -->
- <div class="task-button">
- <el-button class="prev-step" @click="preStep"><i class="el-icon-back" />选择教材</el-button>
- <el-button @click="$router.push(closeLink)">关闭</el-button>
- </div>
- <!-- 任务课节 -->
- <div class="task-item">
- <!-- 课节列表 -->
- <div class="task-item-list">
- <template v-if="cs_item_list.length > 0">
- <div
- v-for="item in cs_item_list"
- :key="item.id"
- :class="['task-item-list-title', { selected: item.id === curItemID }]"
- @click="curItemID = item.id"
- >
- <span class="nowrap-ellipsis task-item-name" :title="item.name">{{ item.name }}</span>
- <!-- 课节下拉框 -->
- <el-dropdown placement="bottom" trigger="click" @command="handleCSItem">
- <i class="el-icon-more" />
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item class="dropdown-menu" :command="{ id: item.id, type: 'edit' }">
- <span>编辑</span><svg-icon icon-class="edit" />
- </el-dropdown-item>
- <el-dropdown-item class="dropdown-menu" :command="{ id: item.id, type: 'delete' }">
- <span>删除</span><svg-icon icon-class="delete" />
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- <div v-else class="task-item-list-title">新课节</div>
- <el-button class="create-item selected" type="primary" @click="dialogVisible = true">
- <svg-icon icon-class="create-white" /> 创建新课节
- </el-button>
- </div>
- <!-- 课节信息 -->
- <div class="task-item-container">
- <div class="item-info">
- <div class="title">课节信息</div>
- <div class="item-info-name">
- <div>课节名称</div>
- <el-input v-model="itemInfoBox.name" readonly />
- </div>
- <div class="item-info-date">
- <div>时间</div>
- <el-date-picker
- v-model="itemInfoBox.date"
- readonly
- type="datetimerange"
- range-separator="~"
- value-format="yyyy-MM-dd HH:mm:ss"
- unlink-panels
- />
- </div>
- </div>
- <div class="item-task">
- <div class="title">
- <span class="number-tag">{{ taskLength }}</span>
- <span>课节任务</span>
- </div>
- <div class="item-task-pre task-container">
- <!-- 课前任务 -->
- <div class="item-task-pre-title">
- <span class="number-tag pre">{{ itemInfoBox.pre_task_list.length }}</span>
- <span>课前任务</span>
- </div>
- <div class="item-task-pre-list item-task-list">
- <el-card v-for="(item, i) in itemInfoBox.pre_task_list" :key="item.id">
- <el-collapse>
- <el-collapse-item>
- <template slot="title">
- <div class="card-title">
- <div class="name">{{ i + 1 }}. {{ item.name }}</div>
- <div class="info">
- {{ item.time_space_view_txt }}
- <!-- 任务下拉框 -->
- <el-dropdown placement="bottom" @command="handleTask">
- <i class="el-icon-more" />
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- class="dropdown-menu"
- :command="{ id: item.id, type: 'edit', time_type: 0 }"
- >
- <span>编辑</span><svg-icon icon-class="edit" />
- </el-dropdown-item>
- <el-dropdown-item
- class="dropdown-menu"
- :command="{ id: item.id, type: 'delete', time_type: 0 }"
- >
- <span>删除</span><svg-icon icon-class="delete" />
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- </template>
- <div class="task-info">
- <div>
- <span class="label">要求</span>
- <div>{{ item.content }}</div>
- </div>
- <div>
- <span class="label">课件</span>
- <div>
- <el-tag v-for="li in item.courseware_list" :key="li.courseware_id" color="#fff">
- {{ li.courseware_name }}
- </el-tag>
- </div>
- </div>
- <div>
- <span class="label">其他文件</span>
- <div>
- <el-tag v-for="li in item.accessory_list" :key="li.file_id" color="#fff">
- <a target="_blank" :href="li.file_url">
- {{ li.file_name }}
- </a>
- </el-tag>
- </div>
- </div>
- </div>
- </el-collapse-item>
- </el-collapse>
- </el-card>
- <el-button @click="newTask(0)"><i class="el-icon-plus" /> 新建任务</el-button>
- </div>
- </div>
- <!-- 课中任务 -->
- <div class="item-task-mid task-container">
- <div class="item-task-mid-title">
- <span class="number-tag mid">{{ itemInfoBox.mid_task_list.length }}</span>
- <span>课中任务</span>
- </div>
- <div class="item-task-mid-list item-task-list">
- <el-card v-for="(item, i) in itemInfoBox.mid_task_list" :key="item.id">
- <el-collapse>
- <el-collapse-item>
- <template slot="title">
- <div class="card-title">
- <div class="name">{{ itemInfoBox.pre_task_list.length + i + 1 }}. {{ item.name }}</div>
- <div class="info">
- {{ item.time_space_view_txt }}
- <el-dropdown placement="bottom" @command="handleTask">
- <i class="el-icon-more" />
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- class="dropdown-menu"
- :command="{ id: item.id, type: 'edit', time_type: 1 }"
- >
- <span>编辑</span><svg-icon icon-class="edit" />
- </el-dropdown-item>
- <el-dropdown-item
- class="dropdown-menu"
- :command="{ id: item.id, type: 'delete', time_type: 1 }"
- >
- <span>删除</span><svg-icon icon-class="delete" />
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- </template>
- <div class="task-info">
- <div>
- <span class="label">要求</span>
- <div>{{ item.content }}</div>
- </div>
- <div>
- <span class="label">课件</span>
- <div>
- <el-tag v-for="li in item.courseware_list" :key="li.courseware_id" color="#fff">
- {{ li.courseware_name }}
- </el-tag>
- </div>
- </div>
- <div>
- <span class="label">其他文件</span>
- <div>
- <el-tag v-for="li in item.accessory_list" :key="li.file_id" color="#fff">
- <a target="_blank" :href="li.file_url">
- {{ li.file_name }}
- </a>
- </el-tag>
- </div>
- </div>
- </div>
- </el-collapse-item>
- </el-collapse>
- </el-card>
- <el-button @click="newTask(1)"><i class="el-icon-plus" /> 新建任务</el-button>
- </div>
- </div>
- <!-- 课后任务 -->
- <div class="item-task-after task-container">
- <div class="item-task-after-title">
- <span class="number-tag after">{{ itemInfoBox.after_task_list.length }}</span>
- <span>课后任务</span>
- </div>
- <div class="item-task-after-list item-task-list">
- <el-card v-for="(item, i) in itemInfoBox.after_task_list" :key="item.id">
- <el-collapse>
- <el-collapse-item>
- <template slot="title">
- <div class="card-title">
- <div class="name">
- {{ itemInfoBox.pre_task_list.length + itemInfoBox.mid_task_list.length + i + 1 }}.
- {{ item.name }}
- </div>
- <div class="info">
- {{ item.time_space_view_txt }}
- <el-dropdown placement="bottom" @command="handleTask">
- <i class="el-icon-more" />
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- class="dropdown-menu"
- :command="{ id: item.id, type: 'edit', time_type: 2 }"
- >
- <span>编辑</span><svg-icon icon-class="edit" />
- </el-dropdown-item>
- <el-dropdown-item
- class="dropdown-menu"
- :command="{ id: item.id, type: 'delete', time_type: 2 }"
- >
- <span>删除</span><svg-icon icon-class="delete" />
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- </template>
- <div class="task-info">
- <div>
- <span class="label">要求</span>
- <div>{{ item.content }}</div>
- </div>
- <div>
- <span class="label">课件</span>
- <div>
- <el-tag v-for="li in item.courseware_list" :key="li.courseware_id" color="#fff">
- {{ li.courseware_name }}
- </el-tag>
- </div>
- </div>
- <div>
- <span class="label">其他文件</span>
- <div>
- <el-tag v-for="li in item.accessory_list" :key="li.file_id" color="#fff">
- <a target="_blank" :href="li.file_url">
- {{ li.file_name }}
- </a>
- </el-tag>
- </div>
- </div>
- </div>
- </el-collapse-item>
- </el-collapse>
- </el-card>
- <el-button @click="newTask(2)"><i class="el-icon-plus" /> 新建任务</el-button>
- </div>
- </div>
- </div>
- <div class="learning-materials">
- <div class="title">学习资料</div>
- <div>
- <el-upload action="no" :http-request="upload" multiple :show-file-list="false" accept="*">
- <el-button><svg-icon icon-class="upload" /> 上传文件</el-button>
- </el-upload>
- </div>
- <div class="tag-list">
- <el-tag
- v-for="(item, i) in itemInfoBox.learning_material_list"
- :key="item.file_id"
- color="#fff"
- closable
- :title="item.file_name"
- @close="deleteMaterialFile(i, item.file_id)"
- >
- <span>{{ item.file_name }}</span>
- </el-tag>
- </div>
- </div>
- </div>
- </div>
- <!-- 课节弹出页 -->
- <add-item
- :id="itemId"
- :course-id="id"
- :type="type"
- :dialog-visible="dialogVisible"
- @dialogClose="dialogClose"
- @dialogConfirm="dialogConfirm"
- />
- </div>
- </template>
- <script>
- import StepBar from '@/components/StepBar';
- import AddItem from './AddItem.vue';
- import { fileUpload } from '@/api/app';
- import {
- GetCourseInfo_ContainCSItem,
- GetCSItemInfoBox,
- DeleteCSItem,
- AddLearningMaterialToCSItem,
- DeleteLearningMaterialFromCSItem,
- DeleteTask
- } from '@/api/course';
- export default {
- name: 'CreateTask',
- components: {
- StepBar,
- AddItem
- },
- data() {
- let is_template = 'is_template' in this.$route.query ? this.$route.query.is_template === 'true' : false;
- return {
- id: this.$route.params.id,
- is_template,
- name: '',
- closeLink: JSON.parse(is_template) ? '/main?tab=TemplateList' : '/create_course',
- picture_url: '',
- begin_date: '',
- end_date: '',
- cs_item_list: [],
- curItemID: '',
- dialogVisible: false,
- type: 'add',
- itemId: '',
- itemInfoBox: {
- name: '',
- date: [],
- pre_task_list: [],
- mid_task_list: [],
- after_task_list: [],
- learning_material_list: []
- }
- };
- },
- computed: {
- taskLength() {
- return (
- this.itemInfoBox.pre_task_list.length +
- this.itemInfoBox.mid_task_list.length +
- this.itemInfoBox.after_task_list.length
- );
- }
- },
- watch: {
- curItemID() {
- this.getCSItemInfoBox();
- }
- },
- created() {
- this.getCourseInfo();
- },
- methods: {
- getCourseInfo() {
- GetCourseInfo_ContainCSItem({ id: this.id }).then(({ name, picture_url, begin_date, end_date, cs_item_list }) => {
- this.name = name;
- this.picture_url = picture_url;
- this.begin_date = begin_date;
- this.end_date = end_date;
- this.cs_item_list = cs_item_list;
- if (cs_item_list.length > 0) {
- this.curItemID = cs_item_list[cs_item_list.length - 1].id;
- }
- });
- },
- preStep() {
- this.$router.push({
- path: `/create_course_step_table/select_book/${this.id}?is_template=${this.is_template}`
- });
- },
- // 课节处理
- handleCSItem({ id, type }) {
- if (type === 'delete') {
- this.$confirm('您确定要删除该课节吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- DeleteCSItem({ id }).then(() => {
- this.$message.success('删除课节成功!');
- this.getCourseInfo();
- });
- });
- }
- if (type === 'edit') {
- this.dialogVisible = true;
- this.itemId = id;
- this.type = 'edit';
- }
- },
- dialogConfirm(type) {
- this.dialogVisible = false;
- this.type = 'add';
- if (type === 'add') {
- this.getCourseInfo();
- } else {
- this.getCSItemInfoBox();
- }
- },
- dialogClose() {
- this.dialogVisible = false;
- this.type = 'add';
- },
- getCSItemInfoBox() {
- GetCSItemInfoBox({ id: this.curItemID }).then(
- ({ name, begin_time, end_time, pre_task_list, mid_task_list, after_task_list, learning_material_list }) => {
- this.itemInfoBox.name = name;
- this.itemInfoBox.date = [begin_time, end_time];
- this.itemInfoBox.pre_task_list = pre_task_list;
- this.itemInfoBox.mid_task_list = mid_task_list;
- this.itemInfoBox.after_task_list = after_task_list;
- this.itemInfoBox.learning_material_list = learning_material_list;
- }
- );
- },
- upload(file) {
- fileUpload('Open', file).then(({ file_info_list }) => {
- if (file_info_list.length > 0) {
- AddLearningMaterialToCSItem({
- cs_item_id: this.curItemID,
- file_id: file_info_list[0].file_id
- }).then(({ file_id, file_name, file_url }) => {
- this.itemInfoBox.learning_material_list.push({ file_id, file_name, file_url });
- });
- }
- });
- },
- deleteMaterialFile(i, file_id) {
- this.$confirm('您确定要删除这个文件吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- DeleteLearningMaterialFromCSItem({ cs_item_id: this.curItemID, file_id }).then(() => {
- this.$message.success('删除文件成功');
- this.itemInfoBox.learning_material_list.splice(i, 1);
- });
- });
- },
- // 任务处理
- newTask(time_type) {
- if (!this.curItemID) {
- this.$message.warning('请先创建新课节');
- return;
- }
- this.$router.push({
- path: `/create_course_step_table/new_task/${time_type}/${this.id}/${this.curItemID}?is_template=${this.is_template}`
- });
- },
- handleTask({ id, type, time_type }) {
- if (type === 'edit') {
- this.$router.push({
- path: `/create_course_step_table/new_task/${time_type}/${this.id}/${this.curItemID}?is_template=${this.is_template}`,
- query: {
- task_id: id
- }
- });
- }
- if (type === 'delete') {
- DeleteTask({ id }).then(() => {
- this.$message.success('删除任务成功');
- this.getCSItemInfoBox();
- });
- }
- }
- }
- };
- </script>
- <style lang="scss">
- @import '~@/styles/mixin';
- .task {
- @include container;
- margin-top: $step-h;
- // 上部的课程信息
- &-course-info {
- display: flex;
- width: 100%;
- height: 120px;
- background-color: #fff;
- border-radius: 8px;
- .cover {
- width: 192px;
- height: 100%;
- border-right: 1px solid #e5e5e5;
- .el-image {
- width: 100%;
- height: 100%;
- }
- }
- .info {
- padding: 26px 32px;
- .name {
- font-size: 24px;
- }
- .date {
- margin-top: 16px;
- font-size: 14px;
- color: #6b6b6b;
- span {
- margin: 0 24px;
- }
- }
- }
- }
- // 中间的按钮
- &-button {
- display: flex;
- justify-content: flex-end;
- margin: 16px 0;
- .el-button + .el-button {
- margin-left: 16px;
- }
- .prev-step .el-icon-back {
- margin-right: 12px;
- }
- .preserve .svg-icon {
- margin-right: 8px;
- }
- }
- // 下部的课节
- &-item {
- display: flex;
- align-items: stretch;
- border-radius: 8px;
- &-list {
- flex: 3;
- background-color: #eee;
- &-title {
- display: flex;
- justify-content: space-between;
- height: 56px;
- padding: 16px 24px;
- line-height: 24px;
- cursor: pointer;
- background-color: #eee;
- &.selected {
- background-color: #fff;
- }
- > .task-item-name {
- width: 275px;
- }
- }
- .create-item {
- width: calc(100% - 48px);
- padding: 11px 20px;
- margin: 24px;
- font-size: 16px;
- }
- }
- &-container {
- flex: 7;
- background-color: #fff;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 12%), 0 0 6px rgba(0, 0, 0, 4%);
- // 学习资料
- %learning-materials,
- .learning-materials {
- padding: 24px 32px;
- .title {
- margin-bottom: 24px;
- font: {
- size: 18px;
- weight: 700;
- }
- }
- .tag-list {
- margin-top: 6px;
- .el-tag {
- margin-top: 6px;
- margin-right: 8px;
- }
- }
- }
- .item-info {
- @extend %learning-materials;
- border-bottom: 1px solid #d9d9d9;
- &-name,
- &-date {
- display: flex;
- margin-top: 16px;
- > :first-child {
- width: 110px;
- min-width: 120px;
- line-height: 40px;
- }
- .el-input {
- width: 600px;
- }
- }
- }
- // 课节任务
- .item-task {
- @extend %learning-materials;
- border-bottom: 1px solid #d9d9d9;
- .title {
- margin-bottom: 24px;
- }
- .number-tag {
- display: inline-block;
- padding: 12px 9px;
- margin-right: 8px;
- font-size: 12px;
- line-height: 0;
- color: #fff;
- vertical-align: bottom;
- background-color: #000;
- border-radius: 50%;
- }
- .task-container {
- .number-tag {
- padding: 10px 7px;
- }
- .item-task-list {
- .el-card {
- margin-bottom: 16px;
- border-radius: 8px;
- .card-title {
- display: flex;
- justify-content: space-between;
- width: 100%;
- .name {
- font-weight: 600;
- }
- .info {
- color: #929292;
- .el-dropdown {
- margin-left: 16px;
- }
- }
- }
- }
- .el-card,
- .el-collapse-item__wrap {
- background-color: #f7f7f7;
- .el-collapse-item__content {
- padding: 15px 24px 9px;
- color: #000;
- background-color: #fff;
- .task-info > div {
- display: flex;
- align-items: center;
- padding: 8px 0;
- span.label {
- width: 80px;
- min-width: 80px;
- margin-right: 16px;
- }
- .el-tag {
- max-width: 275px;
- margin-right: 16px;
- overflow: hidden;
- color: #000;
- text-overflow: ellipsis;
- white-space: nowrap;
- border-color: #dbdbdb;
- }
- }
- }
- }
- .el-card.is-always-shadow,
- .el-card.is-hover-shadow:focus,
- .el-card.is-hover-shadow:hover {
- box-shadow: 0 0;
- }
- .el-card__body {
- padding: 0;
- background-color: #f7f7f7;
- .el-collapse-item__header {
- height: 22px;
- line-height: 22px;
- background-color: #f9f9f9;
- border-bottom-width: 0;
- .el-collapse-item__arrow {
- display: none;
- }
- &.focusing:focus:not(:hover) {
- color: #000;
- }
- }
- .el-collapse-item > div:first-child {
- padding: 10px 20px;
- background-color: #f9f9f9;
- border-bottom: 1px solid #e7e7e7;
- }
- }
- }
- }
- // 课前任务
- &-pre {
- &-title {
- .pre {
- background-color: #4a99ea;
- }
- }
- &-list {
- padding-left: 19px;
- margin: 16px 9px;
- border-left: 2px solid #4a99ea;
- }
- }
- // 课中任务
- &-mid {
- &-title {
- .mid {
- background-color: $basic-color;
- }
- }
- &-list {
- padding-left: 19px;
- margin: 16px 9px;
- border-left: 2px solid $basic-color;
- }
- }
- // 课后任务
- &-after {
- &-title {
- .after {
- background-color: #2ece5b;
- }
- }
- &-list {
- padding-left: 19px;
- margin: 16px 9px;
- border-left: 2px solid #2ece5b;
- }
- }
- }
- }
- }
- }
- .el-dropdown-menu {
- padding: 1px;
- .dropdown-menu {
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 128px;
- }
- }
- </style>
|