TerminalInfoDialog.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <cwg-popup :title="displayTitle" v-model:visible="props.visible" :showFooters="false"
  3. @update:visible="$emit('update:visible', $event)">
  4. <view class="account-detail-content">
  5. <!-- 账户编号独立显示(如果需要,也可以作为 fieldList 中的一项) -->
  6. <view v-if="accountNumber" class="account-number-row">
  7. <text class="label">{{ displayAccountLabel }}</text>
  8. <text class="value">{{ accountNumber }}</text>
  9. <text class="value">{{ form.fwq }}</text>
  10. </view>
  11. <!-- 动态字段列表 -->
  12. <view v-for="(field, index) in fieldList" :key="index" class="field-row">
  13. <cwg-label-line-value :label="field.label" :value="getFieldValue(field.key)">
  14. <template #operation v-if="field.copyable">
  15. <view class="copy-btn" @click="copyValue(getFieldValue(field.key))">
  16. <cwg-icon name="copy" :size="20" color="#999" />
  17. </view>
  18. </template>
  19. </cwg-label-line-value>
  20. </view>
  21. </view>
  22. </cwg-popup>
  23. </template>
  24. <script setup>
  25. import { computed } from 'vue'
  26. import { useI18n } from 'vue-i18n'
  27. const { t } = useI18n()
  28. const props = defineProps({
  29. // 是否显示弹窗
  30. visible: {
  31. type: Boolean,
  32. default: false
  33. },
  34. // 弹窗标题(空则使用 i18n 默认文案)
  35. title: {
  36. type: String,
  37. default: ''
  38. },
  39. // 账户编号(若单独展示)
  40. accountNumber: {
  41. type: String,
  42. default: ''
  43. },
  44. // 账户编号标签(空则使用 i18n 默认文案)
  45. accountLabel: {
  46. type: String,
  47. default: ''
  48. },
  49. // 表单数据对象
  50. form: {
  51. type: Object,
  52. default: () => ({})
  53. },
  54. // 字段配置列表,每项包含:
  55. // - label: 字段显示名称
  56. // - key: 在 form 中对应的键名
  57. // - copyable: 是否显示复制按钮,默认 false
  58. fieldList: {
  59. type: Array,
  60. default: () => []
  61. }
  62. })
  63. const emit = defineEmits(['update:visible'])
  64. const displayTitle = computed(() => props.title || t('Documentary.tradingCenter.item80'))
  65. const displayAccountLabel = computed(() => props.accountLabel || `${t('Documentary.tradingCenter.item29')}:`)
  66. // 获取字段值
  67. const getFieldValue = (key) => {
  68. return props.form?.[key] ?? ''
  69. }
  70. // 复制文本到剪贴板
  71. const copyValue = (text) => {
  72. if (!text) {
  73. uni.showToast({ title: '无内容可复制', icon: 'none' })
  74. return
  75. }
  76. uni.setClipboardData({
  77. data: String(text),
  78. success: () => {
  79. uni.showToast({ title: t('card.Msg.m8'), icon: 'none' })
  80. },
  81. fail: () => {
  82. uni.showToast({ title: t('card.Msg.m9'), icon: 'none' })
  83. }
  84. })
  85. }
  86. </script>
  87. <style scoped lang="scss">
  88. @import "@/uni.scss";
  89. @media (min-width: 768px) {
  90. :deep(.cwg-dialog) {
  91. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  92. border-radius: px2rpx(8);
  93. width: px2rpx(500) !important;
  94. }
  95. }
  96. .account-number-row,
  97. .field-row {
  98. display: flex;
  99. align-items: center;
  100. padding: px2rpx(10) 0;
  101. width: 100%;
  102. font-size: px2rpx(14);
  103. &:last-child {
  104. border-bottom: none;
  105. }
  106. .label {
  107. min-width: px2rpx(30);
  108. color: var(--bs-heading-color);
  109. font-weight: normal;
  110. flex-shrink: 0;
  111. }
  112. .value-wrapper {
  113. flex: 1;
  114. display: flex;
  115. align-items: center;
  116. justify-content: space-between;
  117. }
  118. .value {
  119. color: var(--bs-heading-color);
  120. flex: 1;
  121. }
  122. .copy-btn {
  123. width: px2rpx(20);
  124. height: px2rpx(20);
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. margin-left: px2rpx(12);
  129. cursor: pointer;
  130. color: var(--bs-heading-color);
  131. transition: color 0.2s;
  132. &:active {
  133. color: #007aff;
  134. }
  135. svg {
  136. width: px2rpx(20);
  137. height: px2rpx(20);
  138. }
  139. }
  140. }
  141. // 可复制行样式(仅用于视觉区分)
  142. .copyable-row {
  143. .value-wrapper {
  144. .value {
  145. // 可复制字段的值留出右侧空间
  146. margin-right: px2rpx(8);
  147. }
  148. }
  149. }
  150. </style>