| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <script setup>
- import { ref, computed } from 'vue'
- import { onLoad, onShow } from '@dcloudio/uni-app'
- import {
- getAdvance,
- submitAdvance,
- approveAdvance,
- rejectAdvance,
- getAdvanceApprovalHistory
- } from '@/api/bx'
- import { bxStatusLabel, formatMoney, dash } from '@/utils/bxLabels'
- import { PAGE_PATHS } from '@/config/api'
- const id = ref('')
- const detail = ref(null)
- const history = ref([])
- const acting = ref(false)
- const isDraft = computed(() => detail.value?.status === 'draft')
- const isPending = computed(() => detail.value?.status === 'pending')
- const goBack = () => {
- uni.navigateBack({
- fail: () => uni.navigateTo({ url: PAGE_PATHS.bxAdvanceList })
- })
- }
- const load = async () => {
- if (!id.value) return
- try {
- detail.value = await getAdvance(id.value)
- history.value = await getAdvanceApprovalHistory(id.value)
- } catch (e) {
- uni.showToast({ title: e.message || '加载失败', icon: 'none' })
- }
- }
- const onSubmit = () => {
- uni.showModal({
- title: '提交审批',
- content: '确认提交该借款单?',
- success: async (r) => {
- if (!r.confirm) return
- acting.value = true
- try {
- await submitAdvance(id.value)
- uni.showToast({ title: '已提交', icon: 'success' })
- load()
- } catch (e) {
- uni.showToast({ title: e.message || '提交失败', icon: 'none' })
- } finally {
- acting.value = false
- }
- }
- })
- }
- const doApprove = (pass) => {
- uni.showModal({
- title: pass ? '审批通过' : '审批驳回',
- editable: true,
- placeholderText: '审批意见(可选)',
- success: async (r) => {
- if (!r.confirm) return
- acting.value = true
- try {
- const op = r.content || (pass ? '同意' : '驳回')
- if (pass) await approveAdvance(id.value, op)
- else await rejectAdvance(id.value, op)
- uni.showToast({ title: '操作成功', icon: 'success' })
- load()
- } catch (e) {
- uni.showToast({ title: e.message || '操作失败', icon: 'none' })
- } finally {
- acting.value = false
- }
- }
- })
- }
- onLoad((q) => {
- id.value = q?.id || ''
- })
- onShow(() => load())
- </script>
- <template>
- <view class="mp-page mp-page--sub mp-page--with-bottom">
- <view class="mp-header mp-header--bx">
- <text class="mp-subpage-back" @click="goBack">← 返回</text>
- <text class="mp-header__title" style="margin-top: 16rpx">借款详情</text>
- </view>
- <view v-if="detail" class="mp-detail-hero">
- <view class="mp-detail-hero__top">
- <view>
- <text class="mp-detail-hero__title">{{ dash(detail.applyCode) }}</text>
- <text class="mp-detail-hero__sub">{{ dash(detail.reason) }}</text>
- </view>
- <text class="mp-tag" :class="'mp-tag--' + bxStatusLabel(detail.status).tag">
- {{ bxStatusLabel(detail.status).text }}
- </text>
- </view>
- <view class="mp-detail-hero__meta">
- <text class="mp-detail-hero__chip">{{ formatMoney(detail.amount) }}</text>
- <text class="mp-detail-hero__chip">{{ dash(detail.applicantName) }}</text>
- </view>
- </view>
- <view class="mp-block">
- <text class="mp-block__title">基本信息</text>
- <view class="mp-block__panel">
- <view class="mp-kv"><text class="mp-kv__label">用途</text><text class="mp-kv__value">{{ dash(detail?.purpose) }}</text></view>
- <view class="mp-kv"><text class="mp-kv__label">申请时间</text><text class="mp-kv__value">{{ dash(detail?.applyTime) }}</text></view>
- <view class="mp-kv"><text class="mp-kv__label">当前节点</text><text class="mp-kv__value">{{ dash(detail?.currentNode) }}</text></view>
- <view class="mp-kv"><text class="mp-kv__label">发放状态</text><text class="mp-kv__value">{{ dash(detail?.issueStatus) }}</text></view>
- <view class="mp-kv"><text class="mp-kv__label">备注</text><text class="mp-kv__value">{{ dash(detail?.remark) }}</text></view>
- </view>
- </view>
- <view v-if="history.length" class="mp-block">
- <text class="mp-block__title">审批记录</text>
- <view class="mp-block__panel">
- <view v-for="h in history" :key="h.id" class="mp-kv">
- <text class="mp-kv__label">{{ dash(h.approverName || h.nodeName) }}</text>
- <text class="mp-kv__value">{{ dash(h.approvalStatus) }} · {{ dash(h.approvalOpinion) }}</text>
- </view>
- </view>
- </view>
- <view class="mp-bottom-bar">
- <view v-if="isDraft" class="mp-btn mp-btn--primary" @click="onSubmit">
- {{ acting ? '…' : '提交审批' }}
- </view>
- <template v-if="isPending">
- <view class="mp-btn mp-btn--danger" @click="doApprove(false)">驳回</view>
- <view class="mp-btn mp-btn--primary" @click="doApprove(true)">通过</view>
- </template>
- </view>
- </view>
- </template>
|