TerminalInfoDialog.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <cwg-popup :title="title" 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">{{ accountLabel }}</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. const props = defineProps({
  27. // 是否显示弹窗
  28. visible: {
  29. type: Boolean,
  30. default: false
  31. },
  32. // 弹窗标题
  33. title: {
  34. type: String,
  35. default: '账户详情'
  36. },
  37. // 账户编号(若单独展示)
  38. accountNumber: {
  39. type: String,
  40. default: ''
  41. },
  42. // 账户编号标签
  43. accountLabel: {
  44. type: String,
  45. default: '账户:'
  46. },
  47. // 表单数据对象
  48. form: {
  49. type: Object,
  50. default: () => ({})
  51. },
  52. // 字段配置列表,每项包含:
  53. // - label: 字段显示名称
  54. // - key: 在 form 中对应的键名
  55. // - copyable: 是否显示复制按钮,默认 false
  56. fieldList: {
  57. type: Array,
  58. default: () => []
  59. }
  60. })
  61. const emit = defineEmits(['update:visible'])
  62. // 获取字段值
  63. const getFieldValue = (key) => {
  64. return props.form?.[key] ?? ''
  65. }
  66. // 复制文本到剪贴板
  67. const copyValue = (text) => {
  68. if (!text) {
  69. uni.showToast({ title: '无内容可复制', icon: 'none' })
  70. return
  71. }
  72. uni.setClipboardData({
  73. data: String(text),
  74. success: () => {
  75. uni.showToast({ title: '复制成功', icon: 'none' })
  76. },
  77. fail: () => {
  78. uni.showToast({ title: '复制失败', icon: 'none' })
  79. }
  80. })
  81. }
  82. </script>
  83. <style scoped lang="scss">
  84. @import "@/uni.scss";
  85. @media (min-width: 768px) {
  86. :deep(.cwg-dialog) {
  87. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  88. border-radius: px2rpx(8);
  89. width: px2rpx(500) !important;
  90. }
  91. }
  92. .account-number-row,
  93. .field-row {
  94. display: flex;
  95. align-items: center;
  96. padding: px2rpx(10) 0;
  97. width: 100%;
  98. font-size: px2rpx(14);
  99. &:last-child {
  100. border-bottom: none;
  101. }
  102. .label {
  103. min-width: px2rpx(30);
  104. color: var(--bs-heading-color);
  105. font-weight: normal;
  106. flex-shrink: 0;
  107. }
  108. .value-wrapper {
  109. flex: 1;
  110. display: flex;
  111. align-items: center;
  112. justify-content: space-between;
  113. }
  114. .value {
  115. color: var(--bs-heading-color);
  116. flex: 1;
  117. }
  118. .copy-btn {
  119. width: px2rpx(20);
  120. height: px2rpx(20);
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. margin-left: px2rpx(12);
  125. cursor: pointer;
  126. color: var(--bs-heading-color);
  127. transition: color 0.2s;
  128. &:active {
  129. color: #007aff;
  130. }
  131. svg {
  132. width: px2rpx(20);
  133. height: px2rpx(20);
  134. }
  135. }
  136. }
  137. // 可复制行样式(仅用于视觉区分)
  138. .copyable-row {
  139. .value-wrapper {
  140. .value {
  141. // 可复制字段的值留出右侧空间
  142. margin-right: px2rpx(8);
  143. }
  144. }
  145. }
  146. </style>