比如要增加审核、重置审核动作,要求有授权才能执行
给admin授权
需要加上@RequiresPermissions进行鉴权
@RequiresPermissions("smp:appr")
@PostMapping(value = "/resetAppr")
@ApiOperation("重置版单状态")
public Result<Boolean> resetAppr(@RequestBody SmpOrderMain smpOrderMain) {
smpOrderMainService.resetAppr(smpOrderMain.getId());
return Result.ok("重置成功");
}
@RequiresPermissions("smp:appr")
@PostMapping(value = "/appr")
@ApiOperation("审批版单")
public Result<Boolean> appr(@RequestBody SmpOrderMain smpOrderMain) {
smpOrderMainService.appr(smpOrderMain.getId());
return Result.ok("审批成功");
}
...
v-has判断是否有授权
v-if 满足条件才渲染
<a-menu-item v-has="'smp:appr'" v-if="record.approved==2" >
<a-popconfirm title="确定审核吗?" @confirm="()=>handleAppr(record)">
<a>审批</a>
</a-popconfirm>
</a-menu-item>
因为v-if是有渲染或没渲染,有时候需要用显示、不显示(主要是要保证位置不要变),则需要用到style动态控制 :
<a @click="handleEdit(record)" v-bind:style="{visibility:record.approved==1?'hidden':'visible'}">编辑</a>
另外要在methods加上审核调用:
handleAppr(record){
let that=this
postAction("/smp/smpOrderMain/appr", {id: record.id}).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.loadData()
that.onClearSelected()
} else {
that.$message.error(res.message)
}
})
},