Index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <app-view class="bank-sign g-form">
  3. <template #header>
  4. <app-navbar title="签约账户管理" />
  5. </template>
  6. <div class="bank-sign__container" v-if="bankInfo">
  7. <CellGroup>
  8. <Cell title="开户银行" :value="bankInfo.bankname" />
  9. <Cell title="银行卡号" :value="bankInfo.bankaccountno" />
  10. <Cell title="姓名" :value="bankInfo.bankaccountname" />
  11. <Cell title="支行名称" :value="bankInfo.branchbankname" />
  12. <Cell title="状态" :value="getSignStatusName(bankInfo.signstatus)" />
  13. </CellGroup>
  14. </div>
  15. <div class="bank-sign__empty" v-else>
  16. <Empty description="您还未添加签约账户" />
  17. <Button type="danger" @click="openComponent('edit')" round>添加签约账户</Button>
  18. </div>
  19. <template #footer>
  20. <div class="g-form__footer" v-if="bankInfo">
  21. <Button type="warning" round block @click="formSubmit"
  22. v-if="bankInfo.signstatus === SignStatus.Signed">解约</Button>
  23. <Button type="danger" round block @click="openComponent('edit')"
  24. v-if="[SignStatus.Unsigned, SignStatus.Refuse, SignStatus.Signed].includes(bankInfo.signstatus)">修改</Button>
  25. </div>
  26. </template>
  27. <component ref="componentRef" :is="componentMap.get(componentId)" @closed="closeComponent" v-if="componentId" />
  28. </app-view>
  29. </template>
  30. <script lang="ts" setup>
  31. import { defineAsyncComponent, onActivated } from 'vue'
  32. import { CellGroup, Cell, Button, Empty, showFailToast } from 'vant'
  33. import { fullloading, dialog } from '@/utils/vant'
  34. import { useComponent } from '@/hooks/component'
  35. import { getSignStatusName, SignStatus } from '@/constants/bank'
  36. import { useDoCancelBankSign } from '@/business/bank'
  37. import { useNavigation } from '../../../router/navigation'
  38. const componentMap = new Map<string, unknown>([
  39. ['edit', defineAsyncComponent(() => import('./components/edit/Index.vue'))],
  40. ])
  41. const { componentRef, componentId, openComponent, closeComponent } = useComponent()
  42. const { cancelSubmit, bankInfo, formRefresh } = useDoCancelBankSign()
  43. const { router } = useNavigation()
  44. const formSubmit = () => {
  45. dialog({
  46. message: '确认解约?',
  47. showCancelButton: true
  48. }).then(() => {
  49. fullloading((hideLoading) => {
  50. cancelSubmit().then(() => {
  51. hideLoading()
  52. dialog('签约提交成功,请耐心等待审核。').then(() => {
  53. router.back()
  54. })
  55. }).catch((err) => {
  56. showFailToast(err)
  57. })
  58. })
  59. })
  60. }
  61. onActivated(() => formRefresh())
  62. </script>
  63. <style lang="less">
  64. @import './index.less';
  65. </style>