vue+springboot实现审核功能,有打回和通过,未通过3种选项具体代码
时间: 2023-06-15 19:04:12 浏览: 508
前端Vue代码:
```
<template>
<div>
<h3>审核列表</h3>
<table>
<thead>
<tr>
<th>申请人</th>
<th>申请时间</th>
<th>申请内容</th>
<th>审核状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="item in list" :key="item.id">
<td>{{ item.applicant }}</td>
<td>{{ item.applyTime }}</td>
<td>{{ item.applyContent }}</td>
<td>{{ item.status }}</td>
<td>
<button v-if="item.status === '待审核'" @click="pass(item)">通过</button>
<button v-if="item.status === '待审核'" @click="reject(item)">驳回</button>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
data() {
return {
list: []
}
},
mounted() {
this.getList()
},
methods: {
getList() {
// 发送请求获取审核列表
// axios.get('/api/audit/list').then(res => {
// this.list = res.data
// })
this.list = [
{
id: 1,
applicant: '小明',
applyTime: '2021-01-01 10:00:00',
applyContent: '申请加入开发团队',
status: '待审核'
},
{
id: 2,
applicant: '小红',
applyTime: '2021-01-02 11:00:00',
applyContent: '申请加入测试团队',
status: '待审核'
},
{
id: 3,
applicant: '小王',
applyTime: '2021-01-03 12:00:00',
applyContent: '申请加入产品团队',
status: '待审核'
}
]
},
pass(item) {
// 发送请求将审核状态改为通过
// axios.post(`/api/audit/${item.id}/pass`).then(res => {
// item.status = '已通过'
// })
item.status = '已通过'
},
reject(item) {
// 发送请求将审核状态改为未通过
// axios.post(`/api/audit/${item.id}/reject`).then(res => {
// item.status = '未通过'
// })
item.status = '未通过'
}
}
}
</script>
```
后端Spring Boot代码:
```
@RestController
@RequestMapping("/api/audit")
public class AuditController {
@Autowired
private AuditService auditService;
@GetMapping("/list")
public List<Audit> getAuditList() {
return auditService.getAuditList();
}
@PostMapping("/{id}/pass")
public void passAudit(@PathVariable Long id) {
auditService.passAudit(id);
}
@PostMapping("/{id}/reject")
public void rejectAudit(@PathVariable Long id) {
auditService.rejectAudit(id);
}
}
```
其中AuditService是一个Service层的接口,具体实现可以根据业务需求自行编写。
阅读全文