123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <template>
- <div>
- <el-alert
- title="训练规划"
- :closable="false"
- class="alert marginBtm22"
- type="info"
- >
- <template slot="title">
- <div class="alerTitle">
- <p>
- 师资安排
- <span style="color: red; font-weight: bold"
- >该乐团声部课剩余 2 课时、合奏课 4 课时未进行教学规划</span
- >
- </p>
- <el-button type="text" @click="addPlan">+新增训练规划</el-button>
- </div>
- </template>
- </el-alert>
- <save-form
- :inline="true"
- class="searchForm"
- save-key="teamTrainPlan"
- ref="searchForm"
- @submit="search"
- @reset="onReSet"
- :model.sync="searchForm"
- >
- <el-form-item prop="year" label="年份">
- <el-date-picker
- style="width: 180px !important"
- v-model="searchForm.year"
- type="year"
- value-format="yyyy"
- placeholder="选择年"
- :clearable="false"
- @change="changeYear"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item prop="term" label="学期">
- <el-select
- :disabled="!searchForm.year"
- class="multiple"
- filterable
- style="width: 180px !important"
- v-model.trim="searchForm.term"
- placeholder="请选择学期"
- @change="changeTerm"
- >
- <el-option value="0" label="上学期"></el-option>
- <el-option value="1" label="下学期"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="classGroupId" label="班级">
- <el-select
- :disabled="!searchForm.term || !searchForm.year"
- v-model.trim="searchForm.classGroupId"
- filterable
- placeholder="请选择班级"
- >
- <el-option
- v-for="(item, index) in classList"
- :key="index"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="课程类型"
- prop="courseType"
- :rules="[
- { required: true, message: '请选择课程类型', trigger: 'blur' },
- ]"
- >
- <el-select
- :disabled="
- !searchForm.term || !searchForm.year || !searchForm.classGroupId
- "
- style="width: 180px !important"
- class="multiple"
- v-model.trim="searchForm.courseScheduleType"
- filterable
- placeholder="课程类型"
- >
- <el-option
- v-for="(item, index) in courseTypeList"
- :key="index"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- </save-form>
- <div class="timerWrap">
- <div class="timerList">
- <el-timeline>
- <!-- timestamp="2018/4/12" :timestamp="item.timestamp" -->
- <!-- {timer:time,index:`第${index+1}次训练`,courseType:filterCourseType[val],timestamp:timestamp} -->
- <el-timeline-item
- v-for="item in planList"
- :key="item.timestamp"
- placement="top"
- :hide-timestamp="true"
- >
- {{ item.index }}
- <div class="timeline">
- <h4 class="time">{{ item.timer }}</h4>
- <p class="cuorseType">{{ item.courseType }}</p>
- <p class="concat"> <Tooltip :content="item.plan.value || '暂无规划'" /></p>
- <el-button
- class="button"
- :disabled="!item.plan.value || !item.timer"
- type="text"
- @click="resetPlan(item)"
- >修改</el-button
- >
- <el-button
- class="button"
- :disabled="Boolean(item.timer)"
- type="text"
- @click="detelePlan(item)"
- >删除</el-button
- >
- </div>
- </el-timeline-item>
- </el-timeline>
- </div>
- </div>
- <el-dialog
- :title="planTitle"
- :visible.sync="planVisible"
- width="1100px"
- v-if="planVisible"
- >
- <addplan
- ref="addPlan"
- :form="searchForm"
- :planList="planList"
- :currentIndex="currentIndex"
- :maxPlansNum="maxPlansNum"
- :courseTypeList="courseTypeList"
- :classList="classList"
- :isAdd="isAdd"
- :activeItem="activeItem"
- @close="close"
- />
- <span slot="footer" class="dialog-footer">
- <el-button @click="planVisible = false">取 消</el-button>
- <el-button type="primary" @click="submitPlan">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getMusicGroupAllClass } from "@/api/buildTeam";
- import { getCourseType, getPlanCourseNum, getMusicGroupTrainPlan } from "./api";
- import { filterCourseType } from "@/constant/index";
- import addplan from "./modals/addPlan";
- import Tooltip from '@/components/Tooltip/index'
- export default {
- components: { addplan ,Tooltip},
- data() {
- return {
- searchForm: {
- year: "",
- classGroupId: "",
- term: "",
- courseScheduleType: "",
- musicGroupId: "",
- },
- classList: [],
- courseTypeList: [],
- planList: [],
- planTitle: "",
- planVisible: false,
- currentIndex: 0,
- addIndex:0,
- resetIndex:0,
- maxPlansNum: 0,
- isAdd: false,
- activeItem:null
- };
- },
- created() {
- let date = new Date();
- this.searchForm.year = String(date.getFullYear());
- // console.log('year',date.getFullYear())
- let month = date.getMonth() + 1;
- if (month > 3 && month < 8) {
- this.searchForm.term = "0";
- } else {
- this.searchForm.term = "1";
- }
- },
- mounted() {
- this.teamid = this.$route.query.id;
- this.getMusicClass();
- },
- methods: {
- search() {},
- onReSet() {},
- getMusicClass() {
- getMusicGroupAllClass({ musicGroupId: this.teamid }).then((res) => {
- if (res.code == 200) {
- this.classList = res.data;
- if (this.classList.length < 1) {
- this.$message.error("当前乐团暂无班级");
- return;
- }
- this.searchForm.classGroupId = this.classList[0].id;
- }
- });
- },
- async getCourseList(obj) {
- try {
- this.searchForm.courseScheduleType = "";
- const res = await getCourseType(obj);
- if (!res.data || res.data.length <= 0) {
- this.$message.error("当前学期暂无课程类型");
- } else {
- this.courseTypeList = [];
- res.data.forEach((course) => {
- if (filterCourseType[course]) {
- this.courseTypeList.push({
- label: filterCourseType[course],
- value: course,
- });
- }
- });
- this.searchForm.courseScheduleType = this.courseTypeList[0].value;
- }
- } catch (e) {
- console.log(e);
- }
- },
- changeYear(val) {
- if (val) {
- if (this.searchForm.classGroupId && this.searchForm.term) {
- let obj = {
- classGroupId: this.searchForm.classGroupId,
- musicGroupId: this.teamid,
- term: this.searchForm.term,
- year: val,
- };
- this.getCourseList(obj);
- }
- } else {
- this.searchForm.courseScheduleType = "";
- }
- },
- changeTerm(val) {
- if (val) {
- if (this.searchForm.classGroupId && this.searchForm.year) {
- let obj = {
- classGroupId: this.searchForm.classGroupId,
- musicGroupId: this.teamid,
- term: val,
- year: this.searchForm.year,
- };
- this.getCourseList(obj);
- }
- } else {
- this.searchForm.courseScheduleType = "";
- }
- },
- addPlan() {
- if (this.maxPlansNum > 0) {
- this.planTitle = "新增训练规划";
- this.isAdd = true;
- this.activeItem = null;
- this.planVisible = true;
- this.currentIndex = this.addIndex;
- } else {
- this.$message.error("已添加所有课时规划");
- }
- },
- submitPlan() {
- this.$refs.addPlan.submit();
- },
- close() {
- this.planVisible = false;
- let obj = {
- classGroupId: this.searchForm.classGroupId,
- musicGroupId: this.teamid,
- term: this.searchForm.term,
- year: this.searchForm.year,
- courseScheduleType: this.searchForm.courseScheduleType,
- };
- console.log(obj);
- this.getList(obj);
- },
- async getList(obj) {
- try {
- const res2 = await getMusicGroupTrainPlan(obj);
- let dayjs = this.$helpers.dayjs;
- let timestamp;
- // 判断 是规划多 还是课多
- let classDates = res2.data.classDates;
- let musicGroupTrainPlans = res2.data.musicGroupTrainPlans;
- if (classDates.length < 1) {
- this.$message.error("当前学期该班级暂无此类型课程");
- return;
- }
- if (classDates.length >= musicGroupTrainPlans.length) {
- this.planList = res2.data.classDates.map((time, index) => {
- let dayStr = time.substring(0, 19);
- timestamp = dayjs(dayStr).valueOf();
- return {
- num:index + 1,
- timer: time,
- index: `第${index + 1}次训练`,
- courseType: filterCourseType[this.searchForm.courseScheduleType],
- timestamp: timestamp,
- plan: null,
- };
- });
- this.addIndex = musicGroupTrainPlans.length + 1;
- this.maxPlansNum = classDates.length - musicGroupTrainPlans.length;
- this.planList.forEach((item, index) => {
- item.plan = {
- id: res2.data.musicGroupTrainPlans[index]?.id,
- value: res2.data.musicGroupTrainPlans[index]?.plan,
- };
- });
- } else {
- // 规划多 课少
- this.planList = res2.data.musicGroupTrainPlans.map((item, index) => {
- return {
- num:index + 1,
- timer: null,
- index: `第${index + 1}次训练`,
- courseType: filterCourseType[this.searchForm.courseScheduleType],
- timestamp: null,
- plan: { id: item.id, value: item.plan },
- };
- });
- this.planList.forEach((item, index) => {
- let time = res2.data?.classDates[index];
- let timestamp;
- if (time) {
- let dayStr = time.substring(0, 19);
- timestamp = dayjs(dayStr).valueOf();
- }
- item.timer = res2.data?.classDates[index];
- item.timestamp = timestamp;
- });
- }
- } catch (e) {
- console.log(e);
- }
- },
- // 删除尚未接完
- detelePlan(item) {
- this.$confirm("确定删除该规划?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- orderDelete({ orderId: row.id }).then((res) => {
- if (res.code === 200) {
- this.$message.success("删除成功");
- this.getList();
- // this.routeOrderStatus = false;
- }
- });
- })
- .catch();
- },
- // 修改
- resetPlan(item){
- this.planTitle = "修改训练规划";
- this.isAdd = false;
- this.activeItem = item;
- this.currentIndex = item.num;
- this.planVisible = true;
- }
- },
- watch: {
- "searchForm.classGroupId"(val) {
- if (val) {
- if (this.searchForm.year && this.searchForm.term) {
- let obj = {
- classGroupId: val,
- musicGroupId: this.teamid,
- term: this.searchForm.term,
- year: this.searchForm.year,
- };
- this.getCourseList(obj);
- }
- } else {
- this.searchForm.courseScheduleType = "";
- }
- },
- "searchForm.courseScheduleType": {
- immediate: true,
- async handler(val) {
- if (
- val &&
- this.teamid &&
- this.searchForm.term &&
- this.searchForm.year &&
- this.searchForm.classGroupId
- ) {
- // 请求列表接口
- let obj = {
- classGroupId: this.searchForm.classGroupId,
- musicGroupId: this.teamid,
- term: this.searchForm.term,
- year: this.searchForm.year,
- courseScheduleType: val,
- };
- this.getList(obj);
- }
- },
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .marginBtm22 {
- margin-bottom: 22px;
- }
- .timerWrap {
- position: relative;
- // .topDot {
- // width: 30px;
- // height: 30px;
- // background-color: red;
- // position: absolute;
- // top: 0;
- // left: 50%;
- // margin-left: -15px;
- // }
- // .bottomDot {
- // position: absolute;
- // width: 30px;
- // height: 30px;
- // background-color: blue;
- // bottom: 0;
- // left: 50%;
- // margin-left: -15px;
- // }
- .timerList {
- padding: 30px 16px;
- overflow: auto;
- height: 300px;
- .timeline {
- display: flex;
- flex-direction: row;
- align-items: center;
- width: 100%;
- .time {
- width: 200px;
- }
- .cuorseType {
- width: 120px;
- text-align: center;
- }
- .concat {
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .button {
- width: 40px;
- }
- }
- }
- }
- /deep/.alerTitle {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- .el-button {
- padding: 0 20px !important;
- }
- }
- /deep/.el-alert__content {
- flex: 1;
- }
- .searchForm {
- padding: 0 16px;
- }
- </style>
|