|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<el-dialog :visible="setLabTimeDialog" @close="setLabTimeDialog=false">
|
|
|
|
|
<el-form :model="form">
|
|
|
|
|
<el-form-item label="学年:">
|
|
|
|
|
<el-select v-model="form.year" size="small" >
|
|
|
|
|
<el-select v-model="form.year" size="small">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in selectOptions1"
|
|
|
|
|
:key="item.value"
|
|
|
|
@ -13,7 +14,7 @@
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="学期:">
|
|
|
|
|
<el-select v-model="form.semester" size="small" >
|
|
|
|
|
<el-select v-model="form.semester" size="small">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in selectOptions2"
|
|
|
|
|
:key="item.value"
|
|
|
|
@ -25,12 +26,14 @@
|
|
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="星期:">
|
|
|
|
|
<el-input v-model="form.time" @focus="showCourseDialog" placeholder="点我设置" style="width: 200px" >点击设置</el-input>
|
|
|
|
|
<el-input v-model="form.time" @focus="showCourseDialog" placeholder="点我设置" style="width: 200px">点击设置
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 表格:节数选择-->
|
|
|
|
|
<el-dialog :visible.sync="courseDialog" append-to-body :close-on-click-modal="false" v-if="tableAlive" >
|
|
|
|
|
<el-dialog :visible.sync="courseDialog" append-to-body :close-on-click-modal="false" v-if="tableAlive">
|
|
|
|
|
<tb_course :cClick="cellClick" :cStyle="cellStyle" table-label="点击相应的位置选取时间段" ref="times"></tb_course>
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="cancelSetWeeks">取 消</el-button>
|
|
|
|
@ -38,9 +41,11 @@
|
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
<!-- checkbox:周次选择-->
|
|
|
|
|
<el-dialog :visible.sync="weekDialog" title="请选择周数" width="400px" :close-on-click-modal="false" append-to-body>
|
|
|
|
|
<week-selection @add="addWeek" @cancel="cancelSelection" ref="weekSelection" ></week-selection>
|
|
|
|
|
<el-dialog :visible.sync="weekDialog" title="请选择周数" width="400px" :close-on-click-modal="false" append-to-body>
|
|
|
|
|
<week-selection @add="addWeek" @cancel="cancelSelection" ref="weekSelection"
|
|
|
|
|
:able-list="ableList"></week-selection>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
@ -49,33 +54,39 @@
|
|
|
|
|
import tb_course from "~/components/tb_course";
|
|
|
|
|
import {get, post, stop} from "~/utils";
|
|
|
|
|
import {showDialog, showFail, showSuccess} from "~/utils/dialog";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "setLabTime",
|
|
|
|
|
components:{weekSelection,tb_course},
|
|
|
|
|
data(){
|
|
|
|
|
return{
|
|
|
|
|
form:{
|
|
|
|
|
year:2019,
|
|
|
|
|
semester:2,
|
|
|
|
|
time:"",
|
|
|
|
|
components: {weekSelection, tb_course},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
form: {
|
|
|
|
|
year: '2019',
|
|
|
|
|
semester: 2
|
|
|
|
|
},
|
|
|
|
|
allWeeksValue:[],
|
|
|
|
|
aWeekValue:[],
|
|
|
|
|
courseDialog:false,
|
|
|
|
|
tableAlive:false, //用于重载表格
|
|
|
|
|
weekDialog:false,
|
|
|
|
|
setLabTimeDialog: false,
|
|
|
|
|
ableList: [],
|
|
|
|
|
weekDisable:[],
|
|
|
|
|
allWeeksValue: [],
|
|
|
|
|
aWeekValue: [],
|
|
|
|
|
courseDialog: false,
|
|
|
|
|
tableAlive: false, //用于重载表格
|
|
|
|
|
weekDialog: false,
|
|
|
|
|
selectOptions1: [
|
|
|
|
|
{
|
|
|
|
|
value: 2017,
|
|
|
|
|
value: '2017',
|
|
|
|
|
label: '2017-2018年'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 2018,
|
|
|
|
|
value: '2018',
|
|
|
|
|
label: '2018-2019年'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 2019,
|
|
|
|
|
value: '2019',
|
|
|
|
|
label: '2019-2020年'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: '2020',
|
|
|
|
|
label: '2020-2021年'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
selectOptions2: [
|
|
|
|
@ -90,90 +101,108 @@
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
methods: {
|
|
|
|
|
//设置周次与节次
|
|
|
|
|
showCourseDialog(){
|
|
|
|
|
console.log('嘿')
|
|
|
|
|
this.tableAlive=true
|
|
|
|
|
this.courseDialog=true
|
|
|
|
|
async showCourseDialog() {
|
|
|
|
|
this.tableAlive = true
|
|
|
|
|
this.courseDialog = true
|
|
|
|
|
},
|
|
|
|
|
//表格中每个格子的风格
|
|
|
|
|
cellStyle:function({row, column, rowIndex, columnIndex}){
|
|
|
|
|
if (column.label!=''){
|
|
|
|
|
cellStyle: function ({row, column, rowIndex, columnIndex}) {
|
|
|
|
|
if (column.label != '') {
|
|
|
|
|
return 'cursor:pointer'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//点击格子促发的函数
|
|
|
|
|
cellClick(row, column, cell, event) {
|
|
|
|
|
console.log(row.index)
|
|
|
|
|
if (column.label!='') {
|
|
|
|
|
this.weekDialog=true
|
|
|
|
|
this.perTargetValue=event.target //用target对表格进行定位并保存致target对象
|
|
|
|
|
console.log(this.aWeekValue,this.allWeeksValue)
|
|
|
|
|
this.aWeekValue.push(row.index,column.index)
|
|
|
|
|
}
|
|
|
|
|
async cellClick(row, column, cell, event) {
|
|
|
|
|
this.form.weeks = null
|
|
|
|
|
this.form.day = column.index
|
|
|
|
|
this.form.time = row.index
|
|
|
|
|
this.form.uc_id = 0
|
|
|
|
|
console.log(this.form)
|
|
|
|
|
const weekAll = await get('lb/labTime/getWeeks', this.form)
|
|
|
|
|
const weekAble = await get("lb/labTime/getWeeksAbleBook", this.form)
|
|
|
|
|
this.weekDisable = weekAll.filter(elem => !(weekAble.indexOf(elem) > -1))
|
|
|
|
|
this.ableList = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18].filter(elem=> !(this.weekDisable.indexOf(elem) > -1))
|
|
|
|
|
this.weekDialog = true
|
|
|
|
|
// if (column.label != '') {
|
|
|
|
|
// this.weekDialog = true
|
|
|
|
|
// this.perTargetValue = event.target //用target对表格进行定位并保存致target对象
|
|
|
|
|
// // console.log(this.aWeekValue, this.allWeeksValue)
|
|
|
|
|
// this.aWeekValue.push(row.index, column.index)
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
//添加已选择的的周数
|
|
|
|
|
async addWeek() {
|
|
|
|
|
this.weekDialog=false
|
|
|
|
|
console.log(this.form)
|
|
|
|
|
this.weekDialog = false
|
|
|
|
|
var targetValue = this.$refs.weekSelection.checkedValue
|
|
|
|
|
if(targetValue.length!==0){
|
|
|
|
|
this.perTargetValue.textContent='【'+targetValue+'】周'
|
|
|
|
|
this.aWeekValue.push(targetValue) //单个节数时间段添加完成,包括[rowIndex,column,targetValue]
|
|
|
|
|
this.allWeeksValue.push(this.aWeekValue) //把单个格子选择的时间段添加到allWeeksValue中
|
|
|
|
|
this.perTargetValue.style.backgroundColor='lightyellow'
|
|
|
|
|
for (let i=0;i<this.allWeeksValue.length;i++){
|
|
|
|
|
for (let j=i+1;j<this.allWeeksValue.length;j++){
|
|
|
|
|
if (this.allWeeksValue[i][0]===this.allWeeksValue[j][0]&&this.allWeeksValue[i][1]===this.allWeeksValue[j][1]){
|
|
|
|
|
this.allWeeksValue.splice(i,1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.form.weeks = targetValue
|
|
|
|
|
//提交
|
|
|
|
|
await showDialog("确认设置此时间段可预约吗?", this)
|
|
|
|
|
for(let i in this.weekDisable){
|
|
|
|
|
this.form.weeks.push(this.weekDisable[i])
|
|
|
|
|
}
|
|
|
|
|
this.aWeekValue=[]
|
|
|
|
|
console.log(this.form)
|
|
|
|
|
await post('lb/labTime/updateLabTime', this.form)
|
|
|
|
|
await showSuccess("设置成功",this)
|
|
|
|
|
// if (targetValue.length !== 0) {
|
|
|
|
|
// this.perTargetValue.textContent = '【' + targetValue + '】周'
|
|
|
|
|
// this.aWeekValue.push(targetValue) //单个节数时间段添加完成,包括[rowIndex,column,targetValue]
|
|
|
|
|
// this.allWeeksValue.push(this.aWeekValue) //把单个格子选择的时间段添加到allWeeksValue中
|
|
|
|
|
// this.perTargetValue.style.backgroundColor = 'lightyellow'
|
|
|
|
|
// for (let i = 0; i < this.allWeeksValue.length; i++) {
|
|
|
|
|
// for (let j = i + 1; j < this.allWeeksValue.length; j++) {
|
|
|
|
|
// if (this.allWeeksValue[i][0] === this.allWeeksValue[j][0] && this.allWeeksValue[i][1] === this.allWeeksValue[j][1]) {
|
|
|
|
|
// this.allWeeksValue.splice(i, 1)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// this.aWeekValue = []
|
|
|
|
|
// this.$refs.weekSelection.checkedValue=[] //将周数选择器已选择选项置空
|
|
|
|
|
// console.log(this.allWeeksValue)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//取消一个格子已选择这些周数
|
|
|
|
|
async cancelSelection() {
|
|
|
|
|
for (let i=0;i<this.allWeeksValue.length;i++){
|
|
|
|
|
if (this.aWeekValue[0]===this.allWeeksValue[i][0] && this.aWeekValue[1]===this.allWeeksValue[i][1]){
|
|
|
|
|
this.allWeeksValue.splice(i,1)
|
|
|
|
|
for (let i = 0; i < this.allWeeksValue.length; i++) {
|
|
|
|
|
if (this.aWeekValue[0] === this.allWeeksValue[i][0] && this.aWeekValue[1] === this.allWeeksValue[i][1]) {
|
|
|
|
|
this.allWeeksValue.splice(i, 1)
|
|
|
|
|
console.log(this.allWeeksValue)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.aWeekValue=[]
|
|
|
|
|
this.perTargetValue.style.backgroundColor=''
|
|
|
|
|
this.perTargetValue.textContent=''
|
|
|
|
|
this.aWeekValue = []
|
|
|
|
|
this.perTargetValue.style.backgroundColor = ''
|
|
|
|
|
this.perTargetValue.textContent = ''
|
|
|
|
|
//此处再设置将allWeeksValue里边减去这个表格原本的内容,要怎么删去呢,思考一下。
|
|
|
|
|
// if (this.perTargetValue!=''){
|
|
|
|
|
// this.allWeeksValue.pop()
|
|
|
|
|
// }
|
|
|
|
|
this.weekDialog=false
|
|
|
|
|
this.weekDialog = false
|
|
|
|
|
},
|
|
|
|
|
//确定所有格子已选择的周数
|
|
|
|
|
async setWeeks () {
|
|
|
|
|
async setWeeks() {
|
|
|
|
|
console.log(this.$refs.times)
|
|
|
|
|
console.log(this.allWeeksValue)
|
|
|
|
|
// this.form.schedule=this.allWeeksValue.toString()
|
|
|
|
|
this.courseDialog=false
|
|
|
|
|
this.courseDialog = false
|
|
|
|
|
// console.log(this.$refs.times)
|
|
|
|
|
this.tableAlive=false
|
|
|
|
|
if (this.allWeeksValue.length!==0){
|
|
|
|
|
this.form.time='已设置,点击修改'
|
|
|
|
|
this.tableAlive = false
|
|
|
|
|
if (this.allWeeksValue.length !== 0) {
|
|
|
|
|
this.form.time = '已设置,点击修改'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//取消所有已选择的周数
|
|
|
|
|
cancelSetWeeks:function () {
|
|
|
|
|
this.allWeeksValue=[]
|
|
|
|
|
this.form.schedule=""
|
|
|
|
|
this.courseDialog=false
|
|
|
|
|
this.formDialog=true
|
|
|
|
|
cancelSetWeeks: function () {
|
|
|
|
|
this.allWeeksValue = []
|
|
|
|
|
this.form.schedule = ""
|
|
|
|
|
this.courseDialog = false
|
|
|
|
|
this.formDialog = true
|
|
|
|
|
console.log(this.allWeeksValue)
|
|
|
|
|
this.tableAlive=false //表格失活
|
|
|
|
|
this.tableAlive = false //表格失活
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|