[feat][V]:完善实验室管理页面并对接完成

master
Romesum 5 years ago
parent c60fc16cdc
commit 9670802c4c

@ -55,13 +55,9 @@
</template> </template>
<script> <script>
import setLabTime from "~/components/supManager/setLabTime";
import {get} from "~/utils"; import {get} from "~/utils";
export default { export default {
components: {
setLabTime
},
data() { data() {
return { return {
setLabTimeDialog: false, setLabTimeDialog: false,

@ -1,19 +1,20 @@
<template> <template>
<div style="width: 100%;padding: 20px"> <div style="width: 100%;padding: 20px">
<el-form :model="time" :inline="true" style="width: 100%;margin-top: 30px"> <el-form :model="time" :inline="true" style="width: 100%">
<!-- <span style="width: 10% ;:-20px">可预约时间段:--> <!-- <span style="width: 10% ;:-20px">可预约时间段:-->
<!-- </span>--> <!-- </span>-->
<el-form-item label="学年" style="width: 20% ;"> <el-form-item label="学年" style="width: 20% ;">
<el-select v-model="time.year" style=""> <el-select v-model="time.year" style="">
<el-option label="2017-2018" value="0"></el-option> <el-option label="2017-2018" value="2017"></el-option>
<el-option label="2018-2019" value="1"></el-option> <el-option label="2018-2019" value="2018"></el-option>
<el-option label="2019-2020" value="2"></el-option> <el-option label="2019-2020" value="2019"></el-option>
<el-option label="2020-2021" value="2020"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="学期" style="width: 20%"> <el-form-item label="学期" style="width: 20%">
<el-select v-model="time.semester" style=""> <el-select v-model="time.semester" style="">
<el-option label="第一学期" value="0"></el-option> <el-option label="第一学期" :value="1"></el-option>
<el-option label="第二学期" value="1"></el-option> <el-option label="第二学期" :value="2"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- <el-form-item label="周次" style="width: 5%">--> <!-- <el-form-item label="周次" style="width: 5%">-->
@ -107,12 +108,14 @@
<!-- icon="el-icon-delete">删除--> <!-- icon="el-icon-delete">删除-->
<!-- </el-button>--> <!-- </el-button>-->
<el-button @click="schedulePreview(scope.row.lab_id)" size="mini" plain>查看课表</el-button> <el-button @click="schedulePreview(scope.row.lab_id)" size="mini" plain>查看课表</el-button>
<el-button @click="editSchedule(scope.row.lab_id)" type="primary" size="mini" icon="el-icon-edit" plain>修改可预约时间段 <el-button @click="editSchedule(scope.row.lab_id)" type="primary" size="mini" icon="el-icon-edit"
plain>修改可预约时间段
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<add-lab ref="addLab" @confirm="submit"></add-lab> <add-lab ref="addLab" @confirm="submit"></add-lab>
<set-lab-time ref="setLabTime"></set-lab-time>
</div> </div>
</template> </template>
@ -121,21 +124,19 @@
import addLab from "~/components/supManager/addLab" ; import addLab from "~/components/supManager/addLab" ;
import {get, post} from "~/utils"; import {get, post} from "~/utils";
import {showDialog, showFail, showSuccess} from "~/utils/dialog"; import {closeLoading, showDialog, showDialogWithReject, showFail, showLoading, showSuccess} from "~/utils/dialog";
import setLabTime from "~/components/supManager/setLabTime";
export default { export default {
components: {addLab}, components: {addLab, setLabTime},
data() { data() {
return { return {
edit: false, edit: false,
// form: { setLabTimeDialog: false,
// type: '0', form: {},
// position: '0',
// status: '0',
// },
time: { time: {
year: '0', year: '2019',
semester: '0' semester: 2
}, },
search: '', search: '',
tableData: [], tableData: [],
@ -165,6 +166,7 @@
this.$refs.addLab.form.managerId = this.$refs.addLab.form.manager_id this.$refs.addLab.form.managerId = this.$refs.addLab.form.manager_id
if (this.$refs.addLab.form.lab_id) { if (this.$refs.addLab.form.lab_id) {
// //
await showDialog('确认要编辑吗?',this)
this.$refs.addLab.form.labId = this.$refs.addLab.form.lab_id this.$refs.addLab.form.labId = this.$refs.addLab.form.lab_id
await post('lb/lab/updateLab', this.$refs.addLab.form).then(async () => { await post('lb/lab/updateLab', this.$refs.addLab.form).then(async () => {
await this.load() await this.load()
@ -175,15 +177,30 @@
} else { } else {
// //
await post('lb/lab/addLab', this.$refs.addLab.form).then(async () => { await showDialog('确认要新增吗?',this)
await showDialogWithReject('是否需要为该实验室添加'+parseInt(this.time.year)+'-'+(parseInt(this.time.year)+1)+'学年第'+this.time.semester+'学期16周的所有时间段',this).then(async()=>{
this.$refs.addLab.form.fastInsert = true
this.$refs.addLab.form.year = this.time.year
this.$refs.addLab.form.semester = this.time.semester
console.log(this.$refs.addLab.form)
await this.addLab()
}).catch(async()=>{
this.$refs.addLab.form.fastInsert = false
await this.addLab()
})
}
this.$refs.addLab.addLabDialog = false
},
async addLab(){
const loading = showLoading('正在新增...', this)
const newLab = await post('lb/lab/addLab', this.$refs.addLab.form).then(async () => {
await this.load() await this.load()
showSuccess('新增成功', this) showSuccess('新增成功', this)
closeLoading(loading)
}).catch(() => { }).catch(() => {
closeLoading(loading)
showFail('新增失败', this) showFail('新增失败', this)
}) })
}
this.$refs.addLab.addLabDialog = false
}, },
// async deleteLab(labId) { // async deleteLab(labId) {
// await showDialog("", this) // await showDialog("", this)
@ -197,8 +214,10 @@
async schedulePreview() { async schedulePreview() {
await showFail('尚未开发', this) await showFail('尚未开发', this)
}, },
async editSchedule() { async editSchedule(lab_id) {
console.log(this.$refs.setLabTime)
this.$refs.setLabTime.form.labId = lab_id
this.$refs.setLabTime.setLabTimeDialog = true
} }
}, },
computed: { computed: {

@ -1,5 +1,6 @@
<template> <template>
<div> <div>
<el-dialog :visible="setLabTimeDialog" @close="setLabTimeDialog=false">
<el-form :model="form"> <el-form :model="form">
<el-form-item label="学年:"> <el-form-item label="学年:">
<el-select v-model="form.year" size="small"> <el-select v-model="form.year" size="small">
@ -25,9 +26,11 @@
</el-form-item> </el-form-item>
<el-form-item label="星期:"> <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-item>
</el-form> </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">
@ -39,8 +42,10 @@
</el-dialog> </el-dialog>
<!-- checkbox:周次选择--> <!-- checkbox:周次选择-->
<el-dialog :visible.sync="weekDialog" title="请选择周数" width="400px" :close-on-click-modal="false" append-to-body> <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> <week-selection @add="addWeek" @cancel="cancelSelection" ref="weekSelection"
:able-list="ableList"></week-selection>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -49,16 +54,18 @@
import tb_course from "~/components/tb_course"; import tb_course from "~/components/tb_course";
import {get, post, stop} from "~/utils"; import {get, post, stop} from "~/utils";
import {showDialog, showFail, showSuccess} from "~/utils/dialog"; import {showDialog, showFail, showSuccess} from "~/utils/dialog";
export default { export default {
name: "setLabTime",
components: {weekSelection, tb_course}, components: {weekSelection, tb_course},
data() { data() {
return { return {
form: { form: {
year:2019, year: '2019',
semester:2, semester: 2
time:"",
}, },
setLabTimeDialog: false,
ableList: [],
weekDisable:[],
allWeeksValue: [], allWeeksValue: [],
aWeekValue: [], aWeekValue: [],
courseDialog: false, courseDialog: false,
@ -66,16 +73,20 @@
weekDialog: false, weekDialog: false,
selectOptions1: [ selectOptions1: [
{ {
value: 2017, value: '2017',
label: '2017-2018年' label: '2017-2018年'
}, },
{ {
value: 2018, value: '2018',
label: '2018-2019年' label: '2018-2019年'
}, },
{ {
value: 2019, value: '2019',
label: '2019-2020年' label: '2019-2020年'
},
{
value: '2020',
label: '2020-2021年'
} }
], ],
selectOptions2: [ selectOptions2: [
@ -92,8 +103,7 @@
}, },
methods: { methods: {
// //
showCourseDialog(){ async showCourseDialog() {
console.log('嘿')
this.tableAlive = true this.tableAlive = true
this.courseDialog = true this.courseDialog = true
}, },
@ -104,34 +114,53 @@
} }
}, },
// //
cellClick(row, column, cell, event) { async cellClick(row, column, cell, event) {
console.log(row.index) this.form.weeks = null
if (column.label!='') { 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 this.weekDialog = true
this.perTargetValue=event.target //targettarget // if (column.label != '') {
console.log(this.aWeekValue,this.allWeeksValue) // this.weekDialog = true
this.aWeekValue.push(row.index,column.index) // this.perTargetValue = event.target //targettarget
} // // console.log(this.aWeekValue, this.allWeeksValue)
// this.aWeekValue.push(row.index, column.index)
// }
}, },
// //
async addWeek() { async addWeek() {
console.log(this.form)
this.weekDialog = false this.weekDialog = false
var targetValue = this.$refs.weekSelection.checkedValue var targetValue = this.$refs.weekSelection.checkedValue
if(targetValue.length!==0){ this.form.weeks = targetValue
this.perTargetValue.textContent='【'+targetValue+'】周' //
this.aWeekValue.push(targetValue) //[rowIndex,column,targetValue] await showDialog("确认设置此时间段可预约吗?", this)
this.allWeeksValue.push(this.aWeekValue) //allWeeksValue for(let i in this.weekDisable){
this.perTargetValue.style.backgroundColor='lightyellow' this.form.weeks.push(this.weekDisable[i])
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)
} }
} console.log(this.form)
} await post('lb/labTime/updateLabTime', this.form)
await showSuccess("设置成功",this)
} // if (targetValue.length !== 0) {
this.aWeekValue=[] // 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=[] // // this.$refs.weekSelection.checkedValue=[] //
// console.log(this.allWeeksValue) // console.log(this.allWeeksValue)

Loading…
Cancel
Save