From 7ae2a9894e438e3ab01b4cacc42942b7596d0f27 Mon Sep 17 00:00:00 2001 From: Romesum Date: Mon, 25 May 2020 19:41:22 +0800 Subject: [PATCH] =?UTF-8?q?[feat][V]:=E5=AE=8C=E5=96=84=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E5=AE=A4=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/supManager/addLab.vue | 191 +++++----- .../src/components/supManager/labManage.vue | 346 +++++++++--------- element-vue/src/utils/index.js | 2 + 3 files changed, 261 insertions(+), 278 deletions(-) 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) }) }) }