TerminalInfoDialog.vue 4.5 KB

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