field-pane-ra.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="field-pane-container">
  3. <view class="title">{{ title }}</view>
  4. <view v-for="item in fields" :key="item.label">
  5. <view v-if="item.field === 'id'"></view>
  6. <view v-else-if="item.field === 'bank'">
  7. <view class="item">
  8. <view
  9. class="input-wrapper" :style="{
  10. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  11. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  12. }"
  13. >
  14. <view class="sub-title">{{ item.label }}</view>
  15. <view
  16. v-if="item.type === 'select' && item.field === 'bank'" style="flex: 1" :style="{
  17. color: form.bank ? '' : '#999'
  18. }" @click="isShowBankListSelect = true"
  19. >
  20. {{ bankName || (form.bank ? `已选 ID:${form.bank}` : "请选择所属银行") }}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view v-else-if="item.field === 'phone'" class="item">
  26. <template>
  27. <view
  28. class="input-wrapper" :style="{
  29. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  30. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  31. }"
  32. >
  33. <view class="sub-title">{{ item.label }}</view>
  34. <view class="input" style="display: flex;justify-content: space-between;align-items: center;">
  35. <input
  36. v-if="item.type === 'input'" :value="form[item.field]" :disabled="false"
  37. type="number"
  38. :placeholder="item.placeholder" @input="handleInput(item.field, $event)"
  39. />
  40. <tui-countdown-verify ref="refBindBankVerify" width="144upx" @send="handleSendVerify"></tui-countdown-verify>
  41. </view>
  42. </view>
  43. </template>
  44. </view>
  45. <view v-else class="item">
  46. <template>
  47. <view
  48. class="input-wrapper" :style="{
  49. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  50. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  51. }"
  52. >
  53. <view class="sub-title">{{ item.label }}</view>
  54. <input
  55. v-if="item.type === 'input'" :value="form[item.field]" class="input" :disabled="false"
  56. :type="item.field === 'cardNumber' || item.field === 'code' ? 'number' : 'text'"
  57. :placeholder="item.placeholder" @input="handleInput(item.field, $event)"
  58. />
  59. </view>
  60. </template>
  61. </view>
  62. </view>
  63. <!-- 银行 -->
  64. <tui-select
  65. :list="bankList" reverse :show="isShowBankListSelect" @confirm="handleSelectBankList"
  66. @close="isShowBankListSelect = false"
  67. ></tui-select>
  68. </view>
  69. </template>
  70. <script>
  71. import { getSelectDictApi, getCodeBusinessApi } from '../../../../api/anotherTFInterface'
  72. export default {
  73. name: 'FieldPaneRA',
  74. props: {
  75. fields: {
  76. type: Array,
  77. required: true
  78. },
  79. value: {
  80. type: Object,
  81. required: true
  82. },
  83. title: String
  84. },
  85. data() {
  86. return {
  87. form: {},
  88. bankList: [],
  89. isShowBankListSelect: false,
  90. checkCard: {
  91. bankLog: '',
  92. cardName: '',
  93. abbreviation: ''
  94. },
  95. bankName: ''
  96. }
  97. },
  98. watch: {
  99. fields: {
  100. handler(value) {
  101. if (value) {
  102. const form = {}
  103. for (const item of value) {
  104. form[item.field] = this.value[item.field]
  105. if (item.type === 'select' && item.field === 'bank') this.getBankList()
  106. }
  107. this.form = form
  108. }
  109. },
  110. immediate: true,
  111. deep: true
  112. },
  113. form: {
  114. handler(value) {
  115. this.$emit('input', value)
  116. },
  117. immediate: true,
  118. deep: true
  119. }
  120. },
  121. created() {
  122. },
  123. mounted() {
  124. // console.log(this.$refs)
  125. },
  126. methods: {
  127. getBankList() {
  128. getSelectDictApi({ dictName: '所属银行' })
  129. .then((res) => {
  130. this.bankList = res.data.map((item) => ({
  131. ...item,
  132. value: item.dictId,
  133. text: `${item.dictName}${item.dictDescribe ? '(' + item.dictDescribe + ')' : ''}`
  134. }))
  135. })
  136. .catch(() => {
  137. this.$showToast('银行列表获取失败')
  138. })
  139. },
  140. handleSelectBankList(e) {
  141. this.isShowBankListSelect = false
  142. this.bankName = e.options.text
  143. this.form.bank = e.options.dictId
  144. },
  145. handleInput(field, e) {
  146. console.log(field, e)
  147. if (field === 'cardName' || field === 'cardNumber' || field === 'phone' || field === 'code') {
  148. this.form[field] = e.detail.value
  149. }
  150. },
  151. handleSendVerify() {
  152. if (!this.form.phone) {
  153. this.$refs.refBindBankVerify[0].reset()
  154. return this.$showToast('请填写手机号')
  155. }
  156. if (!/^1[3-9]\d{9}$/.test(this.form.phone)) {
  157. this.$refs.refBindBankVerify[0].reset()
  158. return this.$showToast('请输入正确的手机号')
  159. }
  160. getCodeBusinessApi({ phone: this.form.phone })
  161. .then((res) => {
  162. this.$refs.refBindBankVerify[0].success()
  163. this.$showToast('发送成功,请注意查看手机短信')
  164. })
  165. .catch(() => {
  166. this.$refs.refBindBankVerify[0].reset()
  167. })
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="less" scoped>
  173. @import "../../../../style/var.less";
  174. @import "../../../../style/mixin.less";
  175. .field-pane-container {
  176. margin-top: 30upx;
  177. .title {
  178. font-size: @f14;
  179. color: #fa5151;
  180. font-weight: bold;
  181. }
  182. .item {
  183. padding: 20upx 0;
  184. border-bottom: 1upx solid #d8d8d8;
  185. margin-top: 20upx;
  186. .input-wrapper {
  187. .flex();
  188. font-size: @f12;
  189. color: @c3d;
  190. .sub-title {
  191. margin-right: 20upx;
  192. }
  193. /deep/ .uni-input-placeholder,
  194. /deep/ .uni-textarea-placeholder {
  195. font-size: @f12;
  196. color: @c9;
  197. }
  198. .input {
  199. flex: 1;
  200. font-size: @f12;
  201. }
  202. .textarea {
  203. margin-top: 20upx;
  204. width: 100%;
  205. height: 100px;
  206. font-size: 24upx;
  207. }
  208. }
  209. }
  210. }
  211. </style>