Index.vue 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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="showComponent('edit')"
  24. v-if="[SignStatus.Unsigned, SignStatus.Refuse, SignStatus.Signed, SignStatus.Rescinded].includes(bankInfo.signstatus)">修改</Button>
  25. </div>
  26. </template>
  27. <component ref="componentRef" v-bind="{ isedit }" :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. import { useErrorInfoStore } from '@/stores'
  39. import { shallowRef } from 'vue'
  40. const componentMap = new Map<string, unknown>([
  41. ['edit', defineAsyncComponent(() => import('./components/edit/Index.vue'))],
  42. ])
  43. const { componentRef, componentId, openComponent, closeComponent } = useComponent()
  44. const { cancelSubmit, bankInfo, formRefresh } = useDoCancelBankSign()
  45. const { router } = useNavigation()
  46. /// 是否为编辑
  47. const isedit = shallowRef(false)
  48. const formSubmit = () => {
  49. dialog({
  50. message: '确认解约?',
  51. showCancelButton: true
  52. }).then(() => {
  53. fullloading((hideLoading) => {
  54. cancelSubmit().then(() => {
  55. hideLoading()
  56. dialog('解约提交成功,请耐心等待审核。').then(() => {
  57. router.back()
  58. })
  59. }).catch((err) => {
  60. const { getErrorInfoByCode } = useErrorInfoStore()
  61. showFailToast(getErrorInfoByCode(Number(err)) ?? '')
  62. })
  63. })
  64. })
  65. }
  66. const showComponent = (code: string) => {
  67. isedit.value = true
  68. openComponent(code)
  69. }
  70. onActivated(() => formRefresh())
  71. </script>
  72. <style lang="less">
  73. @import './index.less';
  74. </style>