TerminalInfoDialog.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <cwg-popup :title="title" v-model:visible="props.visible" :showFooter="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. </view>
  10. <!-- 动态字段列表 -->
  11. <view v-for="(field, index) in fieldList" :key="index" class="field-row">
  12. <cwg-label-line-value :label="field.label" :value="getFieldValue(field.key)">
  13. <template #operation v-if="field.copyable">
  14. <view class="copy-btn" @click="copyValue(getFieldValue(field.key))">
  15. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"
  16. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
  17. stroke-linejoin="round">
  18. <path
  19. d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" />
  20. <path
  21. d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" />
  22. </svg>
  23. </view>
  24. </template>
  25. </cwg-label-line-value>
  26. <!-- <text class="label">{{ field.label }}</text>
  27. <view class="value-wrapper">
  28. <text class="value">{{ getFieldValue(field.key) || '--' }}</text>
  29. <view v-if="field.copyable" class="copy-btn" @click="copyValue(getFieldValue(field.key))">
  30. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none"
  31. stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  32. <path
  33. d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" />
  34. <path
  35. d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" />
  36. </svg>
  37. </view>
  38. </view> -->
  39. </view>
  40. </view>
  41. </cwg-popup>
  42. </template>
  43. <script setup>
  44. import { computed } from 'vue'
  45. const props = defineProps({
  46. // 是否显示弹窗
  47. visible: {
  48. type: Boolean,
  49. default: false
  50. },
  51. // 弹窗标题
  52. title: {
  53. type: String,
  54. default: '账户详情'
  55. },
  56. // 账户编号(若单独展示)
  57. accountNumber: {
  58. type: String,
  59. default: ''
  60. },
  61. // 账户编号标签
  62. accountLabel: {
  63. type: String,
  64. default: '账户:'
  65. },
  66. // 表单数据对象
  67. form: {
  68. type: Object,
  69. default: () => ({})
  70. },
  71. // 字段配置列表,每项包含:
  72. // - label: 字段显示名称
  73. // - key: 在 form 中对应的键名
  74. // - copyable: 是否显示复制按钮,默认 false
  75. fieldList: {
  76. type: Array,
  77. default: () => []
  78. }
  79. })
  80. const emit = defineEmits(['update:visible'])
  81. // 获取字段值
  82. const getFieldValue = (key) => {
  83. return props.form?.[key] ?? ''
  84. }
  85. // 复制文本到剪贴板
  86. const copyValue = (text) => {
  87. if (!text) {
  88. uni.showToast({ title: '无内容可复制', icon: 'none' })
  89. return
  90. }
  91. uni.setClipboardData({
  92. data: String(text),
  93. success: () => {
  94. uni.showToast({ title: '复制成功', icon: 'success' })
  95. },
  96. fail: () => {
  97. uni.showToast({ title: '复制失败', icon: 'none' })
  98. }
  99. })
  100. }
  101. </script>
  102. <style scoped lang="scss">
  103. @import "@/uni.scss";
  104. @media (min-width: 768px) {
  105. :deep(.cwg-dialog) {
  106. background-color: var(--color-white);
  107. border-radius: px2rpx(8);
  108. width: px2rpx(500) !important;
  109. }
  110. }
  111. .account-number-row,
  112. .field-row {
  113. display: flex;
  114. align-items: center;
  115. padding: px2rpx(10) 0;
  116. width: 100%;
  117. font-size: px2rpx(14);
  118. &:last-child {
  119. border-bottom: none;
  120. }
  121. .label {
  122. min-width: px2rpx(30);
  123. color: #666;
  124. font-weight: normal;
  125. flex-shrink: 0;
  126. }
  127. .value-wrapper {
  128. flex: 1;
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. }
  133. .value {
  134. color: #333;
  135. flex: 1;
  136. }
  137. .copy-btn {
  138. width: px2rpx(20);
  139. height: px2rpx(20);
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. margin-left: px2rpx(12);
  144. cursor: pointer;
  145. color: #999;
  146. transition: color 0.2s;
  147. &:active {
  148. color: #007aff;
  149. }
  150. svg {
  151. width: px2rpx(20);
  152. height: px2rpx(20);
  153. }
  154. }
  155. }
  156. // 可复制行样式(仅用于视觉区分)
  157. .copyable-row {
  158. .value-wrapper {
  159. .value {
  160. // 可复制字段的值留出右侧空间
  161. margin-right: px2rpx(8);
  162. }
  163. }
  164. }
  165. </style>