TerminalInfoDialog.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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)">
  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 = (field) => {
  68. console.log(field)
  69. const { key,isEnum=false,enums={} } = field
  70. const value = props.form?.[key]
  71. console.log(value)
  72. console.log(enums[value])
  73. return isEnum?enums[value]:value ?? ''
  74. }
  75. // 复制文本到剪贴板
  76. const copyValue = (text) => {
  77. if (!text) {
  78. uni.showToast({ title: '无内容可复制', icon: 'none' })
  79. return
  80. }
  81. uni.setClipboardData({
  82. data: String(text),
  83. success: () => {
  84. uni.showToast({ title: t('card.Msg.m8'), icon: 'none' })
  85. },
  86. fail: () => {
  87. uni.showToast({ title: t('card.Msg.m9'), icon: 'none' })
  88. }
  89. })
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. @import "@/uni.scss";
  94. @media (min-width: 768px) {
  95. :deep(.cwg-dialog) {
  96. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  97. border-radius: px2rpx(8);
  98. width: px2rpx(500) !important;
  99. }
  100. }
  101. .account-number-row,
  102. .field-row {
  103. display: flex;
  104. align-items: center;
  105. padding: px2rpx(10) 0;
  106. width: 100%;
  107. font-size: px2rpx(14);
  108. &:last-child {
  109. border-bottom: none;
  110. }
  111. .label {
  112. min-width: px2rpx(30);
  113. color: var(--bs-heading-color);
  114. font-weight: normal;
  115. flex-shrink: 0;
  116. }
  117. .value-wrapper {
  118. flex: 1;
  119. display: flex;
  120. align-items: center;
  121. justify-content: space-between;
  122. }
  123. .value {
  124. color: var(--bs-heading-color);
  125. flex: 1;
  126. }
  127. .copy-btn {
  128. width: px2rpx(20);
  129. height: px2rpx(20);
  130. display: flex;
  131. align-items: center;
  132. justify-content: center;
  133. margin-left: px2rpx(12);
  134. cursor: pointer;
  135. color: var(--bs-heading-color);
  136. transition: color 0.2s;
  137. &:active {
  138. color: #007aff;
  139. }
  140. svg {
  141. width: px2rpx(20);
  142. height: px2rpx(20);
  143. }
  144. }
  145. }
  146. // 可复制行样式(仅用于视觉区分)
  147. .copyable-row {
  148. .value-wrapper {
  149. .value {
  150. // 可复制字段的值留出右侧空间
  151. margin-right: px2rpx(8);
  152. }
  153. }
  154. }
  155. </style>