1、普通用户可以新增申请
<el-button @click="add">申请</el-button>
<el-dialog :visble.sync="dialogFormVisble">
<el-form>
<!-- 页面更新后显示出来除了这两个还有其他数据 比如审核状态 都是后端传来的
所以需要在前端页面需要编辑好多少个el-table-column -->
<el-form-item label="请假理由">
<el-input v-model="form.reason"></el-input>
</el-form-item>
<el-form-item label="目的地">
<el-input v-model="form.toaddress"></el-input>
</el-form-item>
</el-form>
<div>
<el-button @click="dialogFormVisble=flase">取消</el-button>
<el-button @click="save">确定</el-button>
</div>
</el-dialog>
methods:
add(){
this.dialogFormVisble = true
},
//传数据到后台进行更新
save(){
this.request.post("/xxx",this.form).then(res=>{
if(res.code === '200'){
this.$message.success('保存成功')
this.dialogFormVisble = false
//重新加载页面
this.load()
}else{
this.$message.error("保存失败")
}
})
}
表格显示的审核信息
<!-- 角色是管理员才看到审核的列 -->
<el-table-column label="审核" v-if="user.role==='ROLE_ADMIN'">
<!-- 只有操作的人是自己才有编辑和删除操作 -->
<template slot-scope="scope" >
<el-button @click="changState(scope.row,'审核通过')" :disabled="scope.row.state!=='待审核'">审核通过</el-button>
<el-button @click="changState(scope.row,'审核不通过')" :disabled="scope.row.state!=='待审核'">审核不通过</el-button>
</template>
</el-table-column>
方法:
methods:{
changState(row,state){
this.form = JSON.parse(JSON.stringify(row))
this.form.state = state;
//传数据到后台进行更新
this.save()
},
save(){
this.request.post("/xxx",this.form).then(res=>{
if(res.code === '200'){
this.$message.success('保存成功')
this.dialogFormVisble = false
//重新加载页面
this.load()
}else{
this.$message.error("保存失败")
}
})
}
}