zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<template>
  <div class="bank-selector-main">
    <div class="selector-condtion">
      <el-input
        class="cond-input"
        placeholder="请输入内容"
        v-model="bankName"
        clearable
        size="small"
      >
      </el-input>
      <el-button size="small" type="primary" @click="getSelectSubBranch"
        >查询</el-button
      >
    </div>
    <ProTable
      :pageInfo="pageInfo"
      @doAction="doAction"
      @handleRowCurrentChange="handleRowCurrentChange"
      @handleCurrentChange="handleCurrentChange"
      @handleSizeChange="handleSizeChange"
      :isRadio="true"
      :isAutoIndex="false"
      :list="bankList"
      :header="tableHeader"
      :loading="loading"
    />
    <div class="selector-button">
      <el-button size="small" @click="$emit('handleSelectorCancel')"
        >取消</el-button
      >
      <el-button size="small" type="primary" @click="handleSelectorSubmit"
        >确定</el-button
      >
    </div>
  </div>
</template>
 
<script>
import { selectSubBranch } from '../../../../api/productManage.api';
import ProTable from '../../../../components/ProTable.vue';
export default {
  props: {
    defBankList: {
      type: Array,
      default: () => {
        return []
      }
    },
    branchName: {
      type: String,
      default: ''
    },
    bankCode: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      bankName: this.branchName,
      bankList: [],
      loading: false,
      tableHeader: [
        {
          prop: 'checked',
          type: 'radio',
          label: '',
          width: '50px'
        },
        {
          prop: 'value',
          label: '银行代码',
          width: '150px'
        },
        {
          prop: 'label',
          label: '银行名称',
          width: 'auto'
        },
        {
          prop: 'bankCode',
          label: '总行代码',
          width: '150'
        }
      ],
      pageInfo: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      checkedBank: ''
    }
  },
  computed: {},
  created() {},
  mounted() {
    this.getSelectSubBranch()
  },
  watch: {},
  methods: {
    doAction() {
      console.log('sss')
    },
    handleSelectorSubmit() {
      const { checkedBank } = this
      if (checkedBank && checkedBank.value) {
        this.$emit('handleSelectorSubmit', checkedBank)
      } else {
        this.$message.info('请选择支行!')
      }
    },
    handleRowCurrentChange(selRow) {
      if (!selRow) {
        return
      }
      const { bankList } = this
      console.log('selRow====', selRow)
      const newList = bankList.map(item => {
        const newItem = { ...item }
        newItem.checked = newItem.value === selRow.value
        return newItem
      })
      this.checkedBank = selRow
      this.$set(this, 'bankList', newList)
    },
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val
      this.getSelectSubBranch()
    },
    handleSizeChange(val) {
      this.pageInfo.pageSize = val
      this.getSelectSubBranch()
    },
    // 获取支行options
    async getSelectSubBranch() {
      const { bankCode, bankName } = this
      const { currentPage, pageSize } = this.pageInfo
      const params = {
        bankcode: bankCode,
        bankname: bankName,
        subBranchCode: '',
        currentPage,
        pageSize
      }
      const subBranchRes = await selectSubBranch(params)
      if (!subBranchRes || subBranchRes.code !== '00') {
        return '';
      }
      const records = subBranchRes.result.records
      this.bankList = records.map(rec => {
        const newRec = { ...rec }
        newRec.checked = false
        newRec.bankCode = this.bankCode
        return newRec
      })
      this.pageInfo.total = subBranchRes.result.total
    }
  },
  components: {
    ProTable
  }
}
</script>
 
<style scoped lang="postcss">
.bank-selector-main {
  & .pro_create_table {
    padding-bottom: 0px;
  }
  & .selector-condtion {
    display: flex;
    justify-content: left;
    padding-bottom: 30px;
    & .el-button--small {
      height: 30px;
      padding: 5px 15px;
    }
    & .cond-input {
      width: 350px;
      margin-right: 20px;
    }
  }
  & .selector-button {
    display: flex;
    justify-content: center;
    & .el-button--small {
      height: 32px;
      line-height: 10px;
      padding: 10px 15px;
    }
  }
}
</style>