detail.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <script setup>
  2. import { ref, computed } from 'vue'
  3. import { onLoad, onShow } from '@dcloudio/uni-app'
  4. import {
  5. getAdvance,
  6. submitAdvance,
  7. approveAdvance,
  8. rejectAdvance,
  9. getAdvanceApprovalHistory
  10. } from '@/api/bx'
  11. import { bxStatusLabel, formatMoney, dash } from '@/utils/bxLabels'
  12. import { PAGE_PATHS } from '@/config/api'
  13. const id = ref('')
  14. const detail = ref(null)
  15. const history = ref([])
  16. const acting = ref(false)
  17. const isDraft = computed(() => detail.value?.status === 'draft')
  18. const isPending = computed(() => detail.value?.status === 'pending')
  19. const goBack = () => {
  20. uni.navigateBack({
  21. fail: () => uni.navigateTo({ url: PAGE_PATHS.bxAdvanceList })
  22. })
  23. }
  24. const load = async () => {
  25. if (!id.value) return
  26. try {
  27. detail.value = await getAdvance(id.value)
  28. history.value = await getAdvanceApprovalHistory(id.value)
  29. } catch (e) {
  30. uni.showToast({ title: e.message || '加载失败', icon: 'none' })
  31. }
  32. }
  33. const onSubmit = () => {
  34. uni.showModal({
  35. title: '提交审批',
  36. content: '确认提交该借款单?',
  37. success: async (r) => {
  38. if (!r.confirm) return
  39. acting.value = true
  40. try {
  41. await submitAdvance(id.value)
  42. uni.showToast({ title: '已提交', icon: 'success' })
  43. load()
  44. } catch (e) {
  45. uni.showToast({ title: e.message || '提交失败', icon: 'none' })
  46. } finally {
  47. acting.value = false
  48. }
  49. }
  50. })
  51. }
  52. const doApprove = (pass) => {
  53. uni.showModal({
  54. title: pass ? '审批通过' : '审批驳回',
  55. editable: true,
  56. placeholderText: '审批意见(可选)',
  57. success: async (r) => {
  58. if (!r.confirm) return
  59. acting.value = true
  60. try {
  61. const op = r.content || (pass ? '同意' : '驳回')
  62. if (pass) await approveAdvance(id.value, op)
  63. else await rejectAdvance(id.value, op)
  64. uni.showToast({ title: '操作成功', icon: 'success' })
  65. load()
  66. } catch (e) {
  67. uni.showToast({ title: e.message || '操作失败', icon: 'none' })
  68. } finally {
  69. acting.value = false
  70. }
  71. }
  72. })
  73. }
  74. onLoad((q) => {
  75. id.value = q?.id || ''
  76. })
  77. onShow(() => load())
  78. </script>
  79. <template>
  80. <view class="mp-page mp-page--sub mp-page--with-bottom">
  81. <view class="mp-header mp-header--bx">
  82. <text class="mp-subpage-back" @click="goBack">← 返回</text>
  83. <text class="mp-header__title" style="margin-top: 16rpx">借款详情</text>
  84. </view>
  85. <view v-if="detail" class="mp-detail-hero">
  86. <view class="mp-detail-hero__top">
  87. <view>
  88. <text class="mp-detail-hero__title">{{ dash(detail.applyCode) }}</text>
  89. <text class="mp-detail-hero__sub">{{ dash(detail.reason) }}</text>
  90. </view>
  91. <text class="mp-tag" :class="'mp-tag--' + bxStatusLabel(detail.status).tag">
  92. {{ bxStatusLabel(detail.status).text }}
  93. </text>
  94. </view>
  95. <view class="mp-detail-hero__meta">
  96. <text class="mp-detail-hero__chip">{{ formatMoney(detail.amount) }}</text>
  97. <text class="mp-detail-hero__chip">{{ dash(detail.applicantName) }}</text>
  98. </view>
  99. </view>
  100. <view class="mp-block">
  101. <text class="mp-block__title">基本信息</text>
  102. <view class="mp-block__panel">
  103. <view class="mp-kv"><text class="mp-kv__label">用途</text><text class="mp-kv__value">{{ dash(detail?.purpose) }}</text></view>
  104. <view class="mp-kv"><text class="mp-kv__label">申请时间</text><text class="mp-kv__value">{{ dash(detail?.applyTime) }}</text></view>
  105. <view class="mp-kv"><text class="mp-kv__label">当前节点</text><text class="mp-kv__value">{{ dash(detail?.currentNode) }}</text></view>
  106. <view class="mp-kv"><text class="mp-kv__label">发放状态</text><text class="mp-kv__value">{{ dash(detail?.issueStatus) }}</text></view>
  107. <view class="mp-kv"><text class="mp-kv__label">备注</text><text class="mp-kv__value">{{ dash(detail?.remark) }}</text></view>
  108. </view>
  109. </view>
  110. <view v-if="history.length" class="mp-block">
  111. <text class="mp-block__title">审批记录</text>
  112. <view class="mp-block__panel">
  113. <view v-for="h in history" :key="h.id" class="mp-kv">
  114. <text class="mp-kv__label">{{ dash(h.approverName || h.nodeName) }}</text>
  115. <text class="mp-kv__value">{{ dash(h.approvalStatus) }} · {{ dash(h.approvalOpinion) }}</text>
  116. </view>
  117. </view>
  118. </view>
  119. <view class="mp-bottom-bar">
  120. <view v-if="isDraft" class="mp-btn mp-btn--primary" @click="onSubmit">
  121. {{ acting ? '…' : '提交审批' }}
  122. </view>
  123. <template v-if="isPending">
  124. <view class="mp-btn mp-btn--danger" @click="doApprove(false)">驳回</view>
  125. <view class="mp-btn mp-btn--primary" @click="doApprove(true)">通过</view>
  126. </template>
  127. </view>
  128. </view>
  129. </template>