zhengyiming
3 天以前 1e77f7e375d797f96e384a9b769df966ee0c52be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<template>
  <ProFormPaginationSelect
    v-model="bank_alias"
    :proTableProps="proTableProps"
    @change="handleAccountBankChange"
    enum-label-key="bank_alias"
    enum-value-key="bank_alias"
  >
  </ProFormPaginationSelect>
</template>
 
<script setup lang="ts">
import { useTable } from '@bole-core/components';
import * as enterpriseWalletServices from '@/services/api/enterpriseWallet';
 
defineOptions({
  name: 'WeChatPayWalletBanksSelect',
});
 
type Props = {
  bank_account_type?: EnumWeChatPayApplymentBankAccountType;
};
 
const props = withDefaults(defineProps<Props>(), {});
 
const bank_alias = defineModel<string>('bank_alias');
const account_bank = defineModel<string>('account_bank');
const account_bank_code = defineModel<number>('account_bank_code');
const bank_alias_code = defineModel<string>('bank_alias_code');
const need_bank_branch = defineModel<boolean>('need_bank_branch');
 
onMounted(() => {
  if (props.bank_account_type !== ('' as any)) {
    getList();
  }
});
 
watch(
  () => props.bank_account_type,
  (newVal) => {
    bank_alias.value = '';
    account_bank.value = '';
    account_bank_code.value = '' as any as number;
    bank_alias_code.value = '';
    need_bank_branch.value = false;
    if (newVal !== ('' as any)) {
      getList();
    }
  }
);
 
const {
  getDataSource: getList,
  proTableProps,
  paginationState,
  extraParamState,
  reset,
} = useTable(
  async ({ pageIndex, pageSize }, extraParamState) => {
    try {
      let params: API.GetEnterpriseWeChatPayWalletBanksQuery = {
        pageModel: {
          rows: pageSize,
          page: pageIndex,
        },
        bank_account_type: props.bank_account_type,
      };
 
      let res = await enterpriseWalletServices.getEnterpriseWeChatPayWalletBanks(params, {
        showLoading: true,
      });
      return res;
    } catch (error) {
      console.log('error: ', error);
    }
  },
  {
    defaultExtraParams: {
      keywords: '',
    },
    queryKey: ['enterpriseWalletServices/getEnterpriseWeChatPayWalletBanks'],
    initialPageSize: 200,
  }
);
 
function handleAccountBankChange(bank_alias: string) {
  const bank = proTableProps.value.tableData.find((item) => item.bank_alias === bank_alias);
  if (bank) {
    account_bank.value = bank.account_bank;
    account_bank_code.value = bank.account_bank_code;
    bank_alias_code.value = bank.bank_alias_code;
    need_bank_branch.value = bank.need_bank_branch;
  }
}
</script>