Browse Source

设计审核下架和上架接口按钮

master
ChaiNingQi 1 month ago
parent
commit
c24f58161a
  1. 39
      chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetQualificationController.java
  2. 2
      chenhai-system/src/main/java/com/chenhai/vet/domain/VetQualification.java
  3. 10
      chenhai-system/src/main/java/com/chenhai/vet/service/IVetQualificationService.java
  4. 67
      chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetQualificationServiceImpl.java
  5. 18
      chenhai-ui/src/api/vet/qualification.js
  6. 365
      chenhai-ui/src/views/vet/qualification/index.vue

39
chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetQualificationController.java

@ -481,4 +481,43 @@ public class VetQualificationController extends BaseController
vetQualificationService.manualCheckCertificates(userId);
return success("证书检查完成");
}
/**
* 下架资质
*/
@PreAuthorize("@ss.hasPermi('vet:qualification:unshelf')")
@Log(title = "兽医资质下架", businessType = BusinessType.UPDATE)
@PostMapping("/unshelf/{qualificationId}")
public AjaxResult unshelf(@PathVariable Long qualificationId,
@RequestParam(required = false) String reason) {
try {
int result = vetQualificationService.unshelfQualification(qualificationId, reason);
if (result > 0) {
return AjaxResult.success("下架成功");
} else {
return AjaxResult.error("下架失败");
}
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
/**
* 上架资质
*/
@PreAuthorize("@ss.hasPermi('vet:qualification:shelf')")
@Log(title = "兽医资质上架", businessType = BusinessType.UPDATE)
@PostMapping("/shelf/{qualificationId}")
public AjaxResult shelf(@PathVariable Long qualificationId) {
try {
int result = vetQualificationService.shelfQualification(qualificationId);
if (result > 0) {
return AjaxResult.success("上架成功");
} else {
return AjaxResult.error("上架失败");
}
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
}

2
chenhai-system/src/main/java/com/chenhai/vet/domain/VetQualification.java

@ -60,7 +60,7 @@ public class VetQualification extends BaseEntity
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date auditTime;
/** 审核状态(0待审核 1通过 2拒绝) */
/** 审核状态(0待审核 1通过 2拒绝 3下架) */
@Excel(name = "审核状态", dictType = "qualification_shenhe")
private String auditStatus;

10
chenhai-system/src/main/java/com/chenhai/vet/service/IVetQualificationService.java

@ -88,4 +88,14 @@ public interface IVetQualificationService
*/
Map<String, Object> getCertificateStatistics(Long userId);
/**
* 下架资质
*/
int unshelfQualification(Long qualificationId, String reason);
/**
* 上架资质
*/
int shelfQualification(Long qualificationId);
}

67
chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetQualificationServiceImpl.java

@ -1,6 +1,7 @@
package com.chenhai.vet.service.impl;
import com.chenhai.common.utils.DateUtils;
import com.chenhai.common.utils.SecurityUtils;
import com.chenhai.common.utils.StringUtils;
import com.chenhai.vet.domain.VetQualification;
import com.chenhai.vet.mapper.VetQualificationMapper;
@ -368,4 +369,70 @@ public class VetQualificationServiceImpl implements IVetQualificationService
return statistics;
}
@Override
public int unshelfQualification(Long qualificationId, String reason) {
// 1. 获取资质信息
VetQualification existing = selectVetQualificationByQualificationId(qualificationId);
if (existing == null) {
throw new RuntimeException("资质信息不存在");
}
// 2. 逻辑判断必须是已上架状态
if (!"1".equals(existing.getAuditStatus())) {
throw new RuntimeException("只有已上架的资质才能下架");
}
// 3. 执行下架
VetQualification update = new VetQualification();
update.setQualificationId(qualificationId);
update.setAuditStatus("3"); // 3=已下架
update.setAuditOpinion(reason != null ? "下架原因:" + reason : "管理员下架");
update.setAuditTime(new Date());
update.setUpdateTime(new Date());
// 记录操作人
try {
String username = SecurityUtils.getUsername();
update.setUpdateBy(username);
update.setAuditorId(SecurityUtils.getUserId());
} catch (Exception e) {
update.setUpdateBy("system");
}
return vetQualificationMapper.updateVetQualification(update);
}
@Override
public int shelfQualification(Long qualificationId) {
// 1. 获取资质信息
VetQualification existing = selectVetQualificationByQualificationId(qualificationId);
if (existing == null) {
throw new RuntimeException("资质信息不存在");
}
// 2. 逻辑判断必须是已下架状态
if (!"3".equals(existing.getAuditStatus())) {
throw new RuntimeException("只有已下架的资质才能上架");
}
// 3. 执行上架
VetQualification update = new VetQualification();
update.setQualificationId(qualificationId);
update.setAuditStatus("1"); // 1=已上架
update.setAuditOpinion("重新上架");
update.setAuditTime(new Date());
update.setUpdateTime(new Date());
// 记录操作人
try {
String username = SecurityUtils.getUsername();
update.setUpdateBy(username);
update.setAuditorId(SecurityUtils.getUserId());
} catch (Exception e) {
update.setUpdateBy("system");
}
return vetQualificationMapper.updateVetQualification(update);
}
}

18
chenhai-ui/src/api/vet/qualification.js

@ -105,3 +105,21 @@ export function submitQualification(data) {
})
}
// 下架资质
export function unshelfQualification(qualificationId, reason) {
return request({
url: '/vet/qualification/unshelf/' + qualificationId,
method: 'post',
params: { reason: reason }
})
}
// 上架资质
export function shelfQualification(qualificationId) {
return request({
url: '/vet/qualification/shelf/' + qualificationId,
method: 'post'
})
}

365
chenhai-ui/src/views/vet/qualification/index.vue

@ -148,130 +148,77 @@
</el-table-column>
<el-table-column label="审核状态" align="center" prop="auditStatus" width="100">
<template slot-scope="scope">
<!-- 使用 qualification_shenhe 字典显示审核状态 -->
<dict-tag :options="dict.type.qualification_shenhe" :value="scope.row.auditStatus"/>
<el-tag :type="getAuditStatusType(scope.row.auditStatus)" size="small">
{{ getDictLabel('qualification_shenhe', scope.row.auditStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="250">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="300">
<template slot-scope="scope">
<!-- 调试信息查看实际状态值 -->
<!-- <span style="color: red; font-size: 10px; margin-right: 5px;">状态:{{ scope.row.auditStatus }}</span> -->
<!-- 情况1没有审核状态nullundefined或状态为3待提交 -->
<template v-if="!scope.row.auditStatus || scope.row.auditStatus === '' || scope.row.auditStatus === '3'">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
style="color: #42B983"
@click="handleUpdate(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-s-check"
style="color: #409EFF"
@click="handleSubmitAudit(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>提交审核</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
style="color: #f56c6c"
@click="handleDelete(scope.row)"
v-hasPermi="['vet:qualification:remove']"
>删除</el-button>
</template>
<!-- 情况2审核状态为待审核(0) -->
<template v-else-if="scope.row.auditStatus === '0'">
<span style="color: #E6A23C; font-size: 12px;">
<i class="el-icon-time" style="margin-right: 3px;"></i>审核中
</span>
<!-- <el-button
size="mini"
type="text"
style="color: #909399; margin-left: 10px;"
disabled
>不可操作</el-button>-->
</template>
<!-- 情况3审核状态为通过(1) -->
<template v-else-if="scope.row.auditStatus === '1'">
<span style="color: #67C23A; font-size: 12px;">
<i class="el-icon-success" style="margin-right: 3px;"></i>已通过
</span>
<el-button
size="mini"
type="text"
icon="el-icon-view"
style="color: #909399; margin-left: 10px;"
@click="handleView(scope.row)"
v-hasPermi="['vet:qualification:query']"
>查看</el-button>
</template>
<!-- 情况4审核状态为拒绝(2) -->
<template v-else-if="scope.row.auditStatus === '2'">
<span style="color: #F56C6C; font-size: 12px;">
<i class="el-icon-error" style="margin-right: 3px;"></i>已拒绝
</span>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
style="color: #42B983; margin-left: 10px;"
@click="handleUpdate(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-s-check"
style="color: #409EFF"
@click="handleSubmitAudit(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>重新提交</el-button>
</template>
<!-- 情况5其他未知状态 -->
<template v-else>
<span style="color: #909399; font-size: 12px; margin-right: 10px;">
状态: {{ scope.row.auditStatus }}
</span>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
style="color: #42B983"
@click="handleUpdate(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-s-check"
style="color: #409EFF"
@click="handleSubmitAudit(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>提交</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
style="color: #f56c6c"
@click="handleDelete(scope.row)"
v-hasPermi="['vet:qualification:remove']"
>删除</el-button>
</template>
<!-- 查看按钮 -->
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleView(scope.row)"
v-hasPermi="['vet:qualification:query']"
>查看</el-button>
<!-- 修改按钮 -->
<el-button
v-if="!scope.row.auditStatus || scope.row.auditStatus === '0' || scope.row.auditStatus === '2'"
size="mini"
type="text"
icon="el-icon-edit"
style="color: #42B983"
@click="handleUpdate(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>修改</el-button>
<!-- 提交/重新提交按钮 -->
<el-button
v-if="!scope.row.auditStatus || scope.row.auditStatus === '2'"
size="mini"
type="text"
icon="el-icon-s-check"
style="color: #409EFF"
@click="handleSubmitAudit(scope.row)"
v-hasPermi="['vet:qualification:edit']"
>{{ !scope.row.auditStatus ? '提交审核' : '重新提交' }}</el-button>
<!-- 下架按钮已上架状态显示 -->
<el-button
v-if="scope.row.auditStatus === '1'"
size="mini"
type="text"
icon="el-icon-bottom"
style="color: #E6A23C"
@click="handleUnshelf(scope.row)"
v-hasPermi="['vet:qualification:unshelf']"
>下架</el-button>
<!-- 上架按钮已下架状态显示 -->
<el-button
v-if="scope.row.auditStatus === '3'"
size="mini"
type="text"
icon="el-icon-top"
style="color: #67C23A"
@click="handleShelf(scope.row)"
v-hasPermi="['vet:qualification:shelf']"
>上架</el-button>
<!-- 删除按钮 -->
<el-button
v-if="!scope.row.auditStatus || scope.row.auditStatus === '2'"
size="mini"
type="text"
icon="el-icon-delete"
style="color: #f56c6c"
@click="handleDelete(scope.row)"
v-hasPermi="['vet:qualification:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
@ -352,11 +299,11 @@
<script>
import { listQualification, getQualification, delQualification, addQualification, updateQualification } from "@/api/vet/qualification"
import { submitQualification } from "@/api/vet/qualification"
import { submitQualification, unshelfQualification, shelfQualification } from "@/api/vet/qualification"
export default {
name: "Qualification",
dicts: ['qualification_shenhe', 'expert_type'], // qualification_shenhe
dicts: ['qualification_shenhe', 'expert_type'],
data() {
return {
//
@ -386,7 +333,6 @@ export default {
qualificationType: null,
certificateNo: null,
auditStatus: null,
//
certName: null,
issueOrg: null,
expireDate: null,
@ -419,7 +365,6 @@ export default {
getList() {
this.loading = true
listQualification(this.queryParams).then(response => {
console.log('资质列表数据:', response.rows) //
this.qualificationList = response.rows
this.total = response.total
this.loading = false
@ -446,24 +391,13 @@ export default {
return map[status] || 'info'
},
/** 获取审核状态标签(备用方法,主要用字典) */
getAuditStatusLabel(status) {
const map = {
'0': '待审核',
'1': '通过',
'2': '拒绝',
'3': '待提交'
}
return map[status] || status || '-'
},
/** 获取审核状态标签类型(备用方法) */
/** 获取审核状态标签类型 */
getAuditStatusType(status) {
const map = {
'0': 'info',
'1': 'success',
'2': 'danger',
'3': 'warning'
'0': 'info', // -
'1': 'success', // - 绿
'2': 'danger', // -
'3': 'warning' // -
}
return map[status] || 'info'
},
@ -475,6 +409,65 @@ export default {
return value
},
/** 下架操作 */
handleUnshelf(row) {
this.$prompt('请输入下架原因', '下架确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPlaceholder: '请输入下架原因(如:证书过期、违规操作等)',
inputValidator: (value) => {
if (!value || value.trim().length < 2) {
return '下架原因不能少于2个字'
}
if (value.trim().length > 200) {
return '下架原因不能超过200字'
}
return true
}
}).then(({ value }) => {
this.loading = true
unshelfQualification(row.qualificationId, value).then(response => {
this.loading = false
if (response.code === 200) {
this.$modal.msgSuccess('下架成功')
this.getList() //
} else {
this.$modal.msgError(response.msg || '下架失败')
}
}).catch(error => {
this.loading = false
this.$modal.msgError(error.msg || '下架失败')
})
}).catch(() => {
//
})
},
/** 上架操作 */
handleShelf(row) {
this.$confirm('确认要上架此资质吗?', '上架确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.loading = true
shelfQualification(row.qualificationId).then(response => {
this.loading = false
if (response.code === 200) {
this.$modal.msgSuccess('上架成功')
this.getList() //
} else {
this.$modal.msgError(response.msg || '上架失败')
}
}).catch(error => {
this.loading = false
this.$modal.msgError(error.msg || '上架失败')
})
}).catch(() => {
//
})
},
/** 提交审核操作 */
handleSubmitAudit(row) {
this.$modal.confirm('确认提交 "' + row.realName + '" 的资质进行审核?').then(() => {
@ -507,22 +500,63 @@ export default {
}).catch(() => {})
},
/** 查看详情 - 极简版 */
/** 查看详情 */
handleView(row) {
// 使 this.$alert
this.$alert(`
<table style="width:100%;">
<tr><td style="padding:5px;">姓名</td><td>${row.realName || '-'}</td></tr>
<tr><td style="padding:5px;">身份证</td><td>${row.idCard || '-'}</td></tr>
<tr><td style="padding:5px;">证书编号</td><td>${row.certificateNo || '-'}</td></tr>
<tr><td style="padding:5px;">审核状态</td><td>${this.getDictLabel('qualification_shenhe', row.auditStatus) || '-'}</td></tr>
</table>
`, '资质详情', {
//
let detailContent = `
<table style="width:100%; border-collapse: collapse;">
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">姓名</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${row.realName || '-'}</td>
</tr>
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">身份证</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${row.idCard || '-'}</td>
</tr>
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">证书编号</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${row.certificateNo || '-'}</td>
</tr>
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">证书名称</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${row.certName || '-'}</td>
</tr>
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">发证机构</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${row.issueOrg || '-'}</td>
</tr>
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">到期日期</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${row.expireDate ? this.parseTime(row.expireDate, '{y}-{m}-{d}') : '-'}</td>
</tr>
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">证书状态</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${this.getCertStatusLabel(row.certStatus)}</td>
</tr>
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">审核状态</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${this.getDictLabel('qualification_shenhe', row.auditStatus) || '-'}</td>
</tr>`
//
if (row.auditOpinion) {
detailContent += `
<tr>
<td style="padding:8px 5px; border-bottom: 1px solid #eee; color: #666;">审核意见</td>
<td style="padding:8px 5px; border-bottom: 1px solid #eee;">${row.auditOpinion}</td>
</tr>`
}
detailContent += `</table>`
this.$alert(detailContent, '资质详情', {
dangerouslyUseHTMLString: true,
confirmButtonText: '关闭',
width: '450px'
width: '550px',
customClass: 'qualification-detail-dialog'
})
},
//
cancel() {
this.open = false
@ -541,11 +575,10 @@ export default {
certificateFiles: null,
applyTime: null,
auditTime: null,
auditStatus: null, // null
auditStatus: null,
auditOpinion: null,
auditorId: null,
remark: null,
//
certName: null,
certType: null,
issueOrg: null,
@ -576,7 +609,7 @@ export default {
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.qualificationId)
this.single = selection.length!==1
this.single = selection.length !== 1
this.multiple = !selection.length
},
@ -585,7 +618,6 @@ export default {
this.reset()
this.open = true
this.title = "添加兽医资质"
// null
this.form.auditStatus = null
},
@ -606,16 +638,13 @@ export default {
if (valid) {
if (this.form.qualificationId != null) {
updateQualification(this.form).then(response => {
console.log('修改返回数据:', response) //
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
// null
this.form.auditStatus = null
addQualification(this.form).then(response => {
console.log('新增返回数据:', response) //
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
@ -661,5 +690,25 @@ export default {
.el-button--text {
padding: 6px 10px;
margin: 0 2px;
min-width: 50px;
}
/* 状态标签样式 */
.el-tag {
margin: 2px;
}
/* 详情对话框样式 */
::v-deep .qualification-detail-dialog .el-message-box__content {
max-height: 400px;
overflow-y: auto;
}
::v-deep .qualification-detail-dialog table {
width: 100%;
}
::v-deep .qualification-detail-dialog table tr:last-child td {
border-bottom: none;
}
</style>
Loading…
Cancel
Save