diff --git a/element-vue/src/components/supManager/addLab.vue b/element-vue/src/components/supManager/addLab.vue index 41aa9c1..9d95a5a 100644 --- a/element-vue/src/components/supManager/addLab.vue +++ b/element-vue/src/components/supManager/addLab.vue @@ -1,129 +1,102 @@ diff --git a/element-vue/src/components/supManager/labManage.vue b/element-vue/src/components/supManager/labManage.vue index 36c901e..520cc9b 100644 --- a/element-vue/src/components/supManager/labManage.vue +++ b/element-vue/src/components/supManager/labManage.vue @@ -1,143 +1,118 @@ @@ -147,52 +122,84 @@ import {get, post} from "~/utils"; import {showDialog, showFail, showSuccess} from "~/utils/dialog"; + export default { - components:{addLab}, - data(){ - return{ - edit:"", - form:{ - type:'0', - position:'0', - status:'0', - }, - time:{ - year:'0', - week:'0', - day1:"0", - day2:"16", - semester:'0' + components: {addLab}, + data() { + return { + edit: false, + // form: { + // type: '0', + // position: '0', + // status: '0', + // }, + time: { + year: '0', + semester: '0' }, - - search:'', - tableData:[ - { name:"aaaa" , address:"509"} - ], + search: '', + tableData: [], } }, - methods:{ - showAddLab(){ + methods: { + async load() { + this.tableData = await get('/lb/lab/getLabList') + }, + // 编辑 + async editLab(item) { + // 判断是否为编辑模式 + this.edit = !!item + this.$refs.addLab.form = item ? item : { + position: '', + name: '', + capacity: '', + manager_id: '' + } + this.$refs.addLab.addLabDialog = true console.log(this.$refs.addLab) - this.$refs.addLab.addLabDialog=true - this.$router.push('/supManager/index/labManager') - + // 弹出编辑框 + this.dialogFormVisible = true }, - // 编辑用户 - // async editLab(item) { - // // 判断是否为编辑模式 - // this.edit = !!item - // this.userForm = item ? item : { - // nickname: "", - // tel: "", - // email: "", - // username: "", - // office: "", - // position: '' - // } - // // 弹出编辑框 - // this.dialogFormVisible = true + async submit() { + this.$refs.addLab.form.capacity = parseInt(this.$refs.addLab.form.capacity) + this.$refs.addLab.form.managerId = this.$refs.addLab.form.manager_id + if (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 this.load() + showSuccess('编辑成功', this) + }).catch(() => { + showFail('编辑失败', this) + }) + + } else { + // 新增 + await post('lb/lab/addLab', this.$refs.addLab.form).then(async () => { + await this.load() + showSuccess('新增成功', this) + }).catch(() => { + showFail('新增失败', this) + }) + + } + this.$refs.addLab.addLabDialog = false + }, + // async deleteLab(labId) { + // await showDialog("确定要删除吗?", this) + // await post('lb/lab/deleteLab', {labId}).then(async () => { + // await this.load() + // await showSuccess('删除成功', this) + // }).catch(err => { + // showFail('删除失败,实验室含有时间段时无法删除', this) + // }) // }, + async schedulePreview() { + await showFail('尚未开发', this) + }, + async editSchedule() { + + } }, computed: { // tableDataComputed() { @@ -207,7 +214,8 @@ }, - mounted() { + async mounted() { + await this.load() // this.tableData=get('/url') } } diff --git a/element-vue/src/utils/index.js b/element-vue/src/utils/index.js index 95c3843..15df463 100644 --- a/element-vue/src/utils/index.js +++ b/element-vue/src/utils/index.js @@ -38,6 +38,8 @@ async function request(url, method, data, params, header = {}) { } else { reject(res.data) } + }).catch(err=>{ + reject(err) }) }) }