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

master
Romesum 5 years ago
parent c60fc16cdc
commit 9670802c4c

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

@ -1,19 +1,20 @@
<template>
<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>-->
<el-form-item label="学年" style="width: 20% ;">
<el-select v-model="time.year" style="">
<el-option label="2017-2018" value="0"></el-option>
<el-option label="2018-2019" value="1"></el-option>
<el-option label="2019-2020" value="2"></el-option>
<el-option label="2017-2018" value="2017"></el-option>
<el-option label="2018-2019" value="2018"></el-option>
<el-option label="2019-2020" value="2019"></el-option>
<el-option label="2020-2021" value="2020"></el-option>
</el-select>
</el-form-item>
<el-form-item label="学期" style="width: 20%">
<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-form-item>
<!-- <el-form-item label="周次" style="width: 5%">-->
@ -103,16 +104,18 @@
<template slot-scope="scope">
<el-button @click="editLab(scope.row)" type="primary" size="mini" plain icon="el-icon-edit">编辑
</el-button>
<!-- <el-button @click="deleteLab(scope.row.lab_id)" type="danger" size="mini" plain-->
<!-- icon="el-icon-delete">删除-->
<!-- </el-button>-->
<!-- <el-button @click="deleteLab(scope.row.lab_id)" type="danger" size="mini" plain-->
<!-- icon="el-icon-delete">删除-->
<!-- </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>
</template>
</el-table-column>
</el-table>
<add-lab ref="addLab" @confirm="submit"></add-lab>
<set-lab-time ref="setLabTime"></set-lab-time>
</div>
</template>
@ -121,21 +124,19 @@
import addLab from "~/components/supManager/addLab" ;
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 {
components: {addLab},
components: {addLab, setLabTime},
data() {
return {
edit: false,
// form: {
// type: '0',
// position: '0',
// status: '0',
// },
setLabTimeDialog: false,
form: {},
time: {
year: '0',
semester: '0'
year: '2019',
semester: 2
},
search: '',
tableData: [],
@ -165,6 +166,7 @@
this.$refs.addLab.form.managerId = this.$refs.addLab.form.manager_id
if (this.$refs.addLab.form.lab_id) {
//
await showDialog('确认要编辑吗?',this)
this.$refs.addLab.form.labId = this.$refs.addLab.form.lab_id
await post('lb/lab/updateLab', this.$refs.addLab.form).then(async () => {
await this.load()
@ -175,16 +177,31 @@
} else {
//
await post('lb/lab/addLab', this.$refs.addLab.form).then(async () => {
await this.load()
showSuccess('新增成功', this)
}).catch(() => {
showFail('新增失败', this)
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()
showSuccess('新增成功', this)
closeLoading(loading)
}).catch(() => {
closeLoading(loading)
showFail('新增失败', this)
})
},
// async deleteLab(labId) {
// await showDialog("", this)
// await post('lb/lab/deleteLab', {labId}).then(async () => {
@ -197,8 +214,10 @@
async schedulePreview() {
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: {

@ -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 //targettarget
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 //targettarget
// // 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 //
}
}
}

Loading…
Cancel
Save