parent
f2e15d2287
commit
7af90798ae
@ -0,0 +1,98 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 弹出层-->
|
||||||
|
<el-dialog :title="edit ? '编辑用户' : '新增用户'" :visible.sync="dialogVisible" width="40rem" @close="cancel"
|
||||||
|
style="text-align: left">
|
||||||
|
<el-form :model="userForm">
|
||||||
|
<el-form-item label="职位" label-width="80px">
|
||||||
|
<el-select v-model="userForm.position" placeholder="请选择职位">
|
||||||
|
<el-option label="教师" value="1"></el-option>
|
||||||
|
<el-option label="实验室管理员" value="2"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="工号" label-width="80px">
|
||||||
|
<el-input v-model="userForm.username" autocomplete="off" :disabled="edit"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="密码" label-width="80px" v-if="!edit">
|
||||||
|
<el-input v-model="password" type="password" autocomplete="off" :disabled="edit"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="姓名" label-width="80px">
|
||||||
|
<el-input v-model="userForm.nickname" autocomplete="off"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="联系电话" label-width="80px">
|
||||||
|
<el-input v-model="userForm.tel" autocomplete="off"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="办公室" label-width="80px">
|
||||||
|
<el-input v-model="userForm.office" autocomplete="off"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮箱" label-width="80px">
|
||||||
|
<el-input v-model="userForm.email" autocomplete="off"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="confirm">确 定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {get, post} from "~/utils";
|
||||||
|
import {showDialog, showFail, showSuccess} from "~/utils/dialog";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
dialogFormVisible: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
userForm: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
edit: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
password: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async confirm() {
|
||||||
|
if (this.edit) {
|
||||||
|
await post('lb/user/updateUser', {
|
||||||
|
nickname: this.userForm.nickname,
|
||||||
|
tel: this.userForm.tel,
|
||||||
|
email: this.userForm.email,
|
||||||
|
username: this.userForm.username,
|
||||||
|
office: this.userForm.office,
|
||||||
|
position: parseInt(this.userForm.position),
|
||||||
|
uid: this.userForm.uid
|
||||||
|
})
|
||||||
|
showSuccess('编辑完成',this)
|
||||||
|
} else {
|
||||||
|
await post('lb/user/addUser', {
|
||||||
|
nickname: this.userForm.nickname,
|
||||||
|
tel: this.userForm.tel,
|
||||||
|
email: this.userForm.email,
|
||||||
|
username: this.userForm.username,
|
||||||
|
office: this.userForm.office,
|
||||||
|
position: parseInt(this.userForm.position),
|
||||||
|
password: this.password
|
||||||
|
})
|
||||||
|
showSuccess('新增完成',this)
|
||||||
|
}
|
||||||
|
this.$emit('confirm')
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
this.$emit('cancel')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
dialogFormVisible(val) {
|
||||||
|
this.dialogVisible = val
|
||||||
|
this.password = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in new issue