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