CaseAudit.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <template>
  2. <div class="case-audit-container">
  3. <h2 class="page-title">案例审核</h2>
  4. <el-card shadow="never" class="toolbar-card">
  5. <el-space wrap>
  6. <el-input
  7. v-model="filters.maleRealName"
  8. placeholder="按男方姓名模糊搜索"
  9. clearable
  10. style="width: 200px"
  11. @keyup.enter="loadList"
  12. >
  13. <template #append>
  14. <el-button icon="Search" @click="loadList" />
  15. </template>
  16. </el-input>
  17. <el-input
  18. v-model="filters.femaleRealName"
  19. placeholder="按女方姓名模糊搜索"
  20. clearable
  21. style="width: 200px"
  22. @keyup.enter="loadList"
  23. >
  24. <template #append>
  25. <el-button icon="Search" @click="loadList" />
  26. </template>
  27. </el-input>
  28. <el-select
  29. v-model="filters.auditStatus"
  30. placeholder="审核状态"
  31. clearable
  32. style="width: 150px"
  33. @change="loadList"
  34. >
  35. <el-option label="待审核" :value="0" />
  36. <el-option label="审核通过" :value="1" />
  37. <el-option label="审核失败" :value="2" />
  38. </el-select>
  39. <el-button
  40. type="primary"
  41. :disabled="selectedRows.length === 0"
  42. @click="handleBatchAudit"
  43. style="margin-left: 10px"
  44. >
  45. 批量审核{{ selectedRows.length > 0 ? ` (${selectedRows.length})` : '' }}
  46. </el-button>
  47. <el-button icon="Refresh" @click="resetFilters">重置</el-button>
  48. </el-space>
  49. </el-card>
  50. <el-card shadow="never" class="table-card">
  51. <el-table
  52. v-loading="loading"
  53. :data="list"
  54. stripe
  55. @selection-change="handleSelectionChange"
  56. >
  57. <template #empty>
  58. <div class="custom-empty-state">
  59. <el-icon class="empty-icon"><Document /></el-icon>
  60. <div class="empty-text">暂无案例记录</div>
  61. <div class="empty-hint">等待红娘上传成功案例后在此审核</div>
  62. </div>
  63. </template>
  64. <el-table-column type="selection" width="55" :selectable="row => !isAudited(row)" />
  65. <el-table-column type="index" label="序号" width="60" />
  66. <el-table-column prop="maleRealName" label="男方姓名" min-width="120">
  67. <template #default="{ row }">
  68. <span class="data-highlight">{{ row.maleRealName || '-' }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column prop="femaleRealName" label="女方姓名" min-width="120">
  72. <template #default="{ row }">
  73. <span class="data-highlight">{{ row.femaleRealName || '-' }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop="caseType" label="案例类型" width="100" align="center">
  77. <template #default="{ row }">
  78. <el-tag size="small" :type="row.caseType === 1 ? 'success' : 'warning'">
  79. {{ row.caseType === 1 ? '订婚' : row.caseType === 2 ? '领证结婚' : '-' }}
  80. </el-tag>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="caseDate" label="成功日期" width="120" align="center">
  84. <template #default="{ row }">
  85. <span class="text-muted">{{ formatDate(row.caseDate) }}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column prop="auditStatus" label="审核状态" width="120" align="center">
  89. <template #default="{ row }">
  90. <el-tag
  91. size="small"
  92. :type="getAuditStatusType(row.auditStatus)"
  93. effect="light"
  94. >
  95. {{ getAuditStatusText(row.auditStatus) }}
  96. </el-tag>
  97. </template>
  98. </el-table-column>
  99. <el-table-column prop="auditRemark" label="审核备注" min-width="200" show-overflow-tooltip>
  100. <template #default="{ row }">
  101. <span class="text-muted">{{ row.auditRemark || '-' }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column prop="createdAt" label="上传时间" width="180">
  105. <template #default="{ row }">
  106. <span class="text-muted">{{ formatDateTime(row.createdAt) }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column prop="updatedAt" label="更改时间" width="180">
  110. <template #default="{ row }">
  111. <span class="text-muted">{{ formatDateTime(row.updatedAt) }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column prop="auditedAt" label="审核时间" width="180">
  115. <template #default="{ row }">
  116. <span class="text-muted">{{ formatDateTime(row.auditedAt) }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column prop="auditDuration" label="审核耗时" width="120" align="center">
  120. <template #default="{ row }">
  121. <span v-if="row.auditDuration" class="data-highlight">{{ row.auditDuration }}</span>
  122. <span v-else style="color: #999;">-</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="操作" width="180" fixed="right">
  126. <template #default="{ row }">
  127. <el-button
  128. type="info"
  129. size="small"
  130. @click="handleDetail(row)"
  131. >
  132. 详情
  133. </el-button>
  134. <el-button
  135. type="primary"
  136. size="small"
  137. @click="handleAudit(row)"
  138. :disabled="row.auditStatus === 1 || row.auditStatus === 2"
  139. >
  140. 审核
  141. </el-button>
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. <div class="pagination-container">
  146. <el-pagination
  147. v-model:current-page="currentPage"
  148. v-model:page-size="pageSize"
  149. :total="total"
  150. :page-sizes="[10, 20, 50, 100]"
  151. layout="total, sizes, prev, pager, next, jumper"
  152. @size-change="loadList"
  153. @current-change="loadList"
  154. />
  155. </div>
  156. </el-card>
  157. <!-- 详情弹框 -->
  158. <el-dialog
  159. v-model="detailDialogVisible"
  160. title="案例详情"
  161. width="900px"
  162. :close-on-click-modal="false"
  163. >
  164. <el-descriptions :column="2" border v-if="detailData">
  165. <el-descriptions-item label="案例ID">{{ detailData.id }}</el-descriptions-item>
  166. <el-descriptions-item label="红娘ID">{{ detailData.matchmakerId || '-' }}</el-descriptions-item>
  167. <el-descriptions-item label="男方用户ID">{{ detailData.maleUserId || '-' }}</el-descriptions-item>
  168. <el-descriptions-item label="女方用户ID">{{ detailData.femaleUserId || '-' }}</el-descriptions-item>
  169. <el-descriptions-item label="男方姓名">{{ detailData.maleRealName || '-' }}</el-descriptions-item>
  170. <el-descriptions-item label="女方姓名">{{ detailData.femaleRealName || '-' }}</el-descriptions-item>
  171. <el-descriptions-item label="案例类型">
  172. <el-tag size="small" :type="detailData.caseType === 1 ? 'success' : 'warning'">
  173. {{ detailData.caseType === 1 ? '订婚' : detailData.caseType === 2 ? '领证结婚' : '-' }}
  174. </el-tag>
  175. </el-descriptions-item>
  176. <el-descriptions-item label="成功日期">{{ formatDate(detailData.caseDate) }}</el-descriptions-item>
  177. <el-descriptions-item label="审核状态">
  178. <el-tag
  179. size="small"
  180. :type="getAuditStatusType(detailData.auditStatus)"
  181. effect="light"
  182. >
  183. {{ getAuditStatusText(detailData.auditStatus) }}
  184. </el-tag>
  185. </el-descriptions-item>
  186. <el-descriptions-item label="审核备注" :span="2" v-if="detailData.auditRemark">
  187. {{ detailData.auditRemark }}
  188. </el-descriptions-item>
  189. <el-descriptions-item label="积分奖励">{{ detailData.pointsReward || '-' }}</el-descriptions-item>
  190. <el-descriptions-item label="现金奖励">
  191. {{ detailData.cashReward ? '¥' + detailData.cashReward : '-' }}
  192. </el-descriptions-item>
  193. <el-descriptions-item label="奖励状态">
  194. {{ detailData.rewardStatus === 1 ? '已发放' : detailData.rewardStatus === 0 ? '未发放' : '-' }}
  195. </el-descriptions-item>
  196. <el-descriptions-item label="是否发布">
  197. {{ detailData.isPublished === 1 ? '是' : detailData.isPublished === 0 ? '否' : '-' }}
  198. </el-descriptions-item>
  199. <el-descriptions-item label="关联案例ID">{{ detailData.publishedCaseId || '-' }}</el-descriptions-item>
  200. <el-descriptions-item label="审核耗时">{{ detailData.auditDuration || '-' }}</el-descriptions-item>
  201. <el-descriptions-item label="成功凭证图片" :span="2" v-if="proofImageList.length > 0">
  202. <div class="proof-images">
  203. <el-image
  204. v-for="(img, index) in proofImageList"
  205. :key="index"
  206. :src="img"
  207. :preview-src-list="proofImageList"
  208. :initial-index="index"
  209. fit="cover"
  210. class="proof-image-item"
  211. :preview-teleported="true"
  212. />
  213. </div>
  214. </el-descriptions-item>
  215. <el-descriptions-item label="上传时间">{{ formatDateTime(detailData.createdAt) }}</el-descriptions-item>
  216. <el-descriptions-item label="更新时间">{{ formatDateTime(detailData.updatedAt) }}</el-descriptions-item>
  217. <el-descriptions-item label="审核时间">{{ formatDateTime(detailData.auditedAt) }}</el-descriptions-item>
  218. </el-descriptions>
  219. <template #footer>
  220. <el-button @click="detailDialogVisible = false">关闭</el-button>
  221. </template>
  222. </el-dialog>
  223. <!-- 审核弹框 -->
  224. <el-dialog
  225. v-model="auditDialogVisible"
  226. :title="auditDialogTitle"
  227. width="600px"
  228. :close-on-click-modal="false"
  229. >
  230. <!-- 批量审核进度显示 -->
  231. <div v-if="isBatchAudit && batchAuditList.length > 0" class="batch-audit-progress">
  232. 进度:{{ currentBatchIndex }} / {{ batchAuditList.length }}
  233. </div>
  234. <!-- 当前审核数据信息 -->
  235. <div v-if="isBatchAudit && currentBatchRow" class="current-audit-info">
  236. <el-descriptions :column="2" border size="small">
  237. <el-descriptions-item label="男方姓名">{{ currentBatchRow.maleRealName || '-' }}</el-descriptions-item>
  238. <el-descriptions-item label="女方姓名">{{ currentBatchRow.femaleRealName || '-' }}</el-descriptions-item>
  239. <el-descriptions-item label="案例类型">
  240. {{ currentBatchRow.caseType === 1 ? '订婚' : currentBatchRow.caseType === 2 ? '领证结婚' : '-' }}
  241. </el-descriptions-item>
  242. <el-descriptions-item label="成功日期">{{ formatDate(currentBatchRow.caseDate) }}</el-descriptions-item>
  243. </el-descriptions>
  244. </div>
  245. <el-form :model="auditForm" :rules="auditRules" ref="auditFormRef" label-width="100px" style="margin-top: 20px">
  246. <el-form-item v-if="!isBatchAudit" label="男方姓名">
  247. <span>{{ currentRow?.maleRealName || '-' }}</span>
  248. </el-form-item>
  249. <el-form-item v-if="!isBatchAudit" label="女方姓名">
  250. <span>{{ currentRow?.femaleRealName || '-' }}</span>
  251. </el-form-item>
  252. <el-form-item label="审核操作" prop="action">
  253. <el-radio-group v-model="auditForm.action">
  254. <el-radio :label="1">审核通过</el-radio>
  255. <el-radio :label="2">审核不通过</el-radio>
  256. </el-radio-group>
  257. </el-form-item>
  258. <el-form-item label="审核备注" prop="auditRemark">
  259. <el-input
  260. v-model="auditForm.auditRemark"
  261. type="textarea"
  262. :rows="4"
  263. :placeholder="auditForm.action === 1 ? '请输入审核备注(可选)' : '请输入审核不通过的原因(必填)'"
  264. maxlength="500"
  265. show-word-limit
  266. />
  267. </el-form-item>
  268. </el-form>
  269. <template #footer>
  270. <el-button @click="handleCancelBatchAudit">取消</el-button>
  271. <el-button
  272. type="primary"
  273. @click="submitAudit"
  274. :loading="auditSubmitting"
  275. :disabled="auditForm.action === 2 && !auditForm.auditRemark?.trim()"
  276. >
  277. {{ isBatchAudit && currentBatchIndex < batchAuditList.length ? '提交并继续' : '确定' }}
  278. </el-button>
  279. </template>
  280. </el-dialog>
  281. </div>
  282. </template>
  283. <script setup>
  284. import { ref, reactive, onMounted } from 'vue'
  285. import { ElMessage, ElMessageBox } from 'element-plus'
  286. import { Document } from '@element-plus/icons-vue'
  287. import request from '@/utils/request'
  288. import { API_ENDPOINTS } from '@/config/api'
  289. const loading = ref(false)
  290. const list = ref([])
  291. const total = ref(0)
  292. const currentPage = ref(1)
  293. const pageSize = ref(10)
  294. const auditing = ref(false)
  295. const auditSubmitting = ref(false)
  296. const auditDialogVisible = ref(false)
  297. const currentRow = ref(null)
  298. const selectedRows = ref([])
  299. const auditFormRef = ref(null)
  300. const isBatchAudit = ref(false)
  301. const batchAuditList = ref([]) // 批量审核的列表
  302. const currentBatchIndex = ref(1) // 当前审核的索引(从1开始)
  303. const currentBatchRow = ref(null) // 当前审核的行数据
  304. const auditDialogTitle = ref('案例审核') // 弹框标题
  305. const detailDialogVisible = ref(false)
  306. const detailData = ref(null)
  307. const proofImageList = ref([])
  308. const filters = reactive({
  309. maleRealName: '',
  310. femaleRealName: '',
  311. auditStatus: null
  312. })
  313. const auditForm = reactive({
  314. action: 1, // 1-通过, 2-不通过
  315. auditRemark: ''
  316. })
  317. const auditRules = {
  318. action: [
  319. { required: true, message: '请选择审核操作', trigger: 'change' }
  320. ],
  321. auditRemark: [
  322. {
  323. validator: (rule, value, callback) => {
  324. if (auditForm.action === 2 && (!value || !value.trim())) {
  325. callback(new Error('审核不通过时,必须填写审核备注'))
  326. } else {
  327. callback()
  328. }
  329. },
  330. trigger: 'blur'
  331. },
  332. { max: 500, message: '审核备注长度不能超过 500 个字符', trigger: 'blur' }
  333. ]
  334. }
  335. const loadList = async () => {
  336. loading.value = true
  337. try {
  338. const params = {
  339. page: currentPage.value,
  340. pageSize: pageSize.value
  341. }
  342. if (filters.maleRealName && filters.maleRealName.trim()) {
  343. params.maleRealName = filters.maleRealName.trim()
  344. }
  345. if (filters.femaleRealName && filters.femaleRealName.trim()) {
  346. params.femaleRealName = filters.femaleRealName.trim()
  347. }
  348. if (filters.auditStatus !== null && filters.auditStatus !== undefined) {
  349. params.auditStatus = filters.auditStatus
  350. }
  351. const res = await request.get(API_ENDPOINTS.SUCCESS_CASE_UPLOAD_LIST, { params })
  352. if (res.code === 200) {
  353. const data = res.data || {}
  354. list.value = data.list || data.records || []
  355. total.value = data.total || list.value.length
  356. }
  357. } catch (error) {
  358. console.error('加载案例列表失败:', error)
  359. ElMessage.error('加载案例列表失败')
  360. } finally {
  361. loading.value = false
  362. }
  363. }
  364. const resetFilters = () => {
  365. filters.maleRealName = ''
  366. filters.femaleRealName = ''
  367. filters.auditStatus = null
  368. currentPage.value = 1
  369. loadList()
  370. }
  371. const getAuditStatusText = (status) => {
  372. const statusMap = {
  373. 0: '待审核',
  374. 1: '审核通过',
  375. 2: '审核失败'
  376. }
  377. return statusMap[status] || '未知'
  378. }
  379. const getAuditStatusType = (status) => {
  380. const typeMap = {
  381. 0: 'warning',
  382. 1: 'success',
  383. 2: 'danger'
  384. }
  385. return typeMap[status] || ''
  386. }
  387. const formatDate = (date) => {
  388. if (!date) return '-'
  389. const d = new Date(date)
  390. return d.toLocaleDateString('zh-CN')
  391. }
  392. const formatDateTime = (date) => {
  393. if (!date) return '-'
  394. const d = new Date(date)
  395. return d.toLocaleString('zh-CN', {
  396. year: 'numeric',
  397. month: '2-digit',
  398. day: '2-digit',
  399. hour: '2-digit',
  400. minute: '2-digit'
  401. })
  402. }
  403. // 判断是否已审核(auditStatus=1或2都表示已审核)
  404. const isAudited = (row) => {
  405. return row.auditStatus === 1 || row.auditStatus === 2
  406. }
  407. // 表格选择变化
  408. const handleSelectionChange = (selection) => {
  409. selectedRows.value = selection
  410. }
  411. const handleDetail = async (row) => {
  412. try {
  413. const response = await request.get(`${API_ENDPOINTS.SUCCESS_CASE_UPLOAD_DETAIL}/${row.id}`)
  414. if (response.code === 200) {
  415. detailData.value = response.data
  416. // 解析成功凭证图片(JSON数组格式)
  417. proofImageList.value = []
  418. if (response.data.proofImages) {
  419. try {
  420. const images = JSON.parse(response.data.proofImages)
  421. if (Array.isArray(images)) {
  422. proofImageList.value = images
  423. }
  424. } catch (e) {
  425. console.error('解析图片JSON失败:', e)
  426. }
  427. }
  428. detailDialogVisible.value = true
  429. } else {
  430. ElMessage.error(response.message || response.msg || '获取详情失败')
  431. }
  432. } catch (error) {
  433. console.error('获取详情失败:', error)
  434. ElMessage.error('获取详情失败: ' + (error.message || '未知错误'))
  435. }
  436. }
  437. const handleAudit = (row) => {
  438. if (row.auditStatus === 1 || row.auditStatus === 2) {
  439. ElMessage.warning('该案例已审核,无需重复操作')
  440. return
  441. }
  442. currentRow.value = row
  443. isBatchAudit.value = false
  444. auditForm.action = 1
  445. auditForm.auditRemark = ''
  446. auditDialogTitle.value = `案例审核 - ${row.maleRealName || ''} & ${row.femaleRealName || ''}`
  447. auditDialogVisible.value = true
  448. }
  449. // 批量审核
  450. const handleBatchAudit = () => {
  451. if (selectedRows.value.length === 0) {
  452. ElMessage.warning('请至少选择一条记录')
  453. return
  454. }
  455. // 过滤掉已审核的记录
  456. const unapprovedRows = selectedRows.value.filter(row => !isAudited(row))
  457. if (unapprovedRows.length === 0) {
  458. ElMessage.warning('所选记录均已审核,无需重复操作')
  459. return
  460. }
  461. // 初始化批量审核列表
  462. batchAuditList.value = unapprovedRows
  463. currentBatchIndex.value = 1
  464. currentRow.value = null
  465. isBatchAudit.value = true
  466. auditForm.action = 1
  467. auditForm.auditRemark = ''
  468. // 设置标题
  469. const count = unapprovedRows.length
  470. auditDialogTitle.value = count > 0 ? `批量审核 (${count}条)` : '批量审核'
  471. // 设置当前审核的行数据
  472. updateCurrentBatchRow()
  473. auditDialogVisible.value = true
  474. }
  475. // 更新当前批量审核的行数据
  476. const updateCurrentBatchRow = () => {
  477. if (isBatchAudit.value && batchAuditList.value.length > 0) {
  478. const index = currentBatchIndex.value - 1
  479. if (index >= 0 && index < batchAuditList.value.length) {
  480. currentBatchRow.value = batchAuditList.value[index]
  481. } else {
  482. currentBatchRow.value = null
  483. }
  484. }
  485. }
  486. // 取消批量审核
  487. const handleCancelBatchAudit = () => {
  488. if (isBatchAudit.value && batchAuditList.value.length > 0) {
  489. ElMessageBox.confirm(
  490. `还有 ${batchAuditList.value.length - currentBatchIndex.value + 1} 条记录未审核,确定要取消吗?`,
  491. '确认取消',
  492. {
  493. confirmButtonText: '确定取消',
  494. cancelButtonText: '继续审核',
  495. type: 'warning'
  496. }
  497. ).then(() => {
  498. auditDialogVisible.value = false
  499. resetBatchAudit()
  500. }).catch(() => {
  501. // 用户选择继续审核,不做任何操作
  502. })
  503. } else {
  504. auditDialogVisible.value = false
  505. resetBatchAudit()
  506. }
  507. }
  508. // 重置批量审核状态
  509. const resetBatchAudit = () => {
  510. batchAuditList.value = []
  511. currentBatchIndex.value = 1
  512. currentBatchRow.value = null
  513. isBatchAudit.value = false
  514. auditDialogTitle.value = '案例审核'
  515. auditForm.action = 1
  516. auditForm.auditRemark = ''
  517. }
  518. const submitAudit = async () => {
  519. if (!auditFormRef.value) return
  520. try {
  521. await auditFormRef.value.validate()
  522. auditing.value = true
  523. auditSubmitting.value = true
  524. if (isBatchAudit.value) {
  525. // 批量审核 - 逐条审核
  526. const row = currentBatchRow.value
  527. if (!row) {
  528. ElMessage.error('当前审核数据不存在')
  529. return
  530. }
  531. let res
  532. if (auditForm.action === 1) {
  533. // 审核通过
  534. const requestBody = auditForm.auditRemark?.trim()
  535. ? { auditRemark: auditForm.auditRemark.trim() }
  536. : {}
  537. res = await request.post(
  538. `${API_ENDPOINTS.SUCCESS_CASE_UPLOAD_APPROVE}/${row.id}`,
  539. Object.keys(requestBody).length > 0 ? requestBody : null
  540. )
  541. } else {
  542. // 审核不通过
  543. res = await request.post(
  544. `${API_ENDPOINTS.SUCCESS_CASE_UPLOAD_REJECT}/${row.id}`,
  545. {
  546. auditRemark: auditForm.auditRemark.trim()
  547. }
  548. )
  549. }
  550. if (res.code === 200) {
  551. ElMessage.success(
  552. `${row.maleRealName || ''} & ${row.femaleRealName || ''} ${auditForm.action === 1 ? '审核通过' : '审核不通过'}成功`
  553. )
  554. // 从批量审核列表中移除已审核的项
  555. const index = currentBatchIndex.value - 1
  556. batchAuditList.value.splice(index, 1)
  557. // 如果还有未审核的记录,自动跳转到下一条
  558. if (batchAuditList.value.length > 0) {
  559. // 删除后,如果当前索引超出范围(说明删除的是最后一条),则跳转到新的最后一条
  560. // 否则保持当前索引不变,因为后面的记录会前移,当前索引对应的就是下一条
  561. if (currentBatchIndex.value > batchAuditList.value.length) {
  562. currentBatchIndex.value = batchAuditList.value.length
  563. }
  564. // 更新标题
  565. const count = batchAuditList.value.length
  566. auditDialogTitle.value = count > 0 ? `批量审核 (${count}条)` : '批量审核'
  567. updateCurrentBatchRow()
  568. // 重置表单
  569. auditForm.action = 1
  570. auditForm.auditRemark = ''
  571. // 清除表单验证状态
  572. if (auditFormRef.value) {
  573. auditFormRef.value.clearValidate()
  574. }
  575. } else {
  576. // 所有记录都已审核完成
  577. ElMessage.success('批量审核完成')
  578. auditDialogVisible.value = false
  579. selectedRows.value = []
  580. resetBatchAudit()
  581. loadList()
  582. }
  583. } else {
  584. ElMessage.error(res.msg || '审核失败')
  585. // 审核失败时,不自动跳转,让用户可以修改后重试
  586. }
  587. } else {
  588. // 单个审核
  589. if (!currentRow.value) {
  590. ElMessage.error('请选择要审核的案例')
  591. return
  592. }
  593. let res
  594. if (auditForm.action === 1) {
  595. // 审核通过
  596. const requestBody = auditForm.auditRemark?.trim()
  597. ? { auditRemark: auditForm.auditRemark.trim() }
  598. : {}
  599. res = await request.post(
  600. `${API_ENDPOINTS.SUCCESS_CASE_UPLOAD_APPROVE}/${currentRow.value.id}`,
  601. Object.keys(requestBody).length > 0 ? requestBody : null
  602. )
  603. } else {
  604. // 审核不通过
  605. res = await request.post(
  606. `${API_ENDPOINTS.SUCCESS_CASE_UPLOAD_REJECT}/${currentRow.value.id}`,
  607. {
  608. auditRemark: auditForm.auditRemark.trim()
  609. }
  610. )
  611. }
  612. if (res.code === 200) {
  613. ElMessage.success(auditForm.action === 1 ? '审核通过成功' : '审核不通过操作成功')
  614. auditDialogVisible.value = false
  615. loadList()
  616. } else {
  617. ElMessage.error(res.msg || '审核操作失败')
  618. }
  619. }
  620. } catch (error) {
  621. if (error !== false) { // validate 失败会返回 false
  622. console.error('审核操作失败:', error)
  623. ElMessage.error(error.response?.data?.msg || error.message || '审核操作失败')
  624. }
  625. } finally {
  626. auditing.value = false
  627. auditSubmitting.value = false
  628. }
  629. }
  630. onMounted(loadList)
  631. </script>
  632. <style scoped>
  633. @import '@/assets/list-common.css';
  634. .case-audit-container {
  635. padding: 0;
  636. }
  637. .proof-images {
  638. display: flex;
  639. flex-wrap: wrap;
  640. gap: 10px;
  641. }
  642. .proof-image-item {
  643. width: 100px;
  644. height: 100px;
  645. border-radius: 4px;
  646. cursor: pointer;
  647. border: 1px solid #dcdfe6;
  648. }
  649. .batch-audit-progress {
  650. font-size: 14px;
  651. color: #606266;
  652. font-weight: 500;
  653. margin-bottom: 20px;
  654. padding: 10px 15px;
  655. background-color: #f5f7fa;
  656. border-radius: 4px;
  657. text-align: center;
  658. }
  659. .current-audit-info {
  660. margin-bottom: 20px;
  661. }
  662. .current-audit-info :deep(.el-descriptions__label) {
  663. font-weight: 500;
  664. }
  665. </style>