CommonInfoRow.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view
  3. class="ui-info-row"
  4. :class="{
  5. 'info-column': isColumn || (value && String(value).length > 50),
  6. 'no-border': noBorder
  7. }"
  8. >
  9. <view class="item-label" :class="{ 'bold-label': isBold }">
  10. {{ label }}
  11. </view>
  12. <view class="item-value" :class="{ 'amount-text': isAmount, 'text-left': forceLeft }">
  13. <slot>
  14. <text v-if="value">{{ value }}</text>
  15. <text v-else class="empty-placeholder">-</text>
  16. </slot>
  17. </view>
  18. </view>
  19. </template>
  20. <script setup lang="ts">
  21. /**
  22. * UI 通用组件 - 详情行渲染
  23. * 提供左 Lable、右 Value 的通用排版。
  24. * 自动处理长文本自动切换上下排版。
  25. */
  26. defineProps<{
  27. /** 字段标题 */
  28. label: string;
  29. /** 字段数值 */
  30. value?: string | number;
  31. /** 是否强制上下排版 */
  32. isColumn?: boolean;
  33. /** 是否红色金额显示 */
  34. isAmount?: boolean;
  35. /** 是否标题文字加粗 */
  36. isBold?: boolean;
  37. /** 是否显示左对齐(默认数值右对齐) */
  38. forceLeft?: boolean;
  39. /** 去除底部边框 */
  40. noBorder?: boolean;
  41. }>();
  42. </script>
  43. <style lang="scss" scoped>
  44. .ui-info-row {
  45. display: flex;
  46. justify-content: space-between;
  47. padding: 24rpx 0;
  48. border-bottom: 2rpx dashed #f5f5f5;
  49. font-size: 28rpx;
  50. line-height: 1.5;
  51. &:last-child, &.no-border {
  52. border-bottom: none;
  53. }
  54. /* 标签样式 */
  55. .item-label {
  56. color: #343a3f;
  57. width: 200rpx;
  58. flex-shrink: 0;
  59. margin-right: 20rpx;
  60. display: -webkit-box;
  61. // -webkit-line-clamp: 1;
  62. // -webkit-box-orient: vertical;
  63. // line-clamp: 1;
  64. // overflow: hidden;
  65. &.bold-label {
  66. font-weight: 600;
  67. color: #1a1e21;
  68. }
  69. }
  70. /* 数值表现 */
  71. .item-value {
  72. color: #585858;
  73. flex: 1;
  74. text-align: right;
  75. word-break: break-all;
  76. font-weight: 400;
  77. &.text-left {
  78. text-align: left;
  79. }
  80. /* 金额专用展现风格 */
  81. &.amount-text {
  82. color: #ff4d4f;
  83. font-weight: 600;
  84. font-family: 'DIN-Medium', sans-serif;
  85. }
  86. .empty-placeholder {
  87. color: #c0c4cc;
  88. }
  89. }
  90. /**
  91. * 上下结构(针对长文本,如备注、简介)
  92. */
  93. &.info-column {
  94. flex-direction: column;
  95. align-items: flex-start;
  96. .item-label {
  97. width: 100%;
  98. margin-bottom: 16rpx;
  99. color: #909399; /* 二级标题弱化 */
  100. }
  101. .item-value {
  102. text-align: left;
  103. width: 100%;
  104. background-color: #f8fafc;
  105. padding: 16rpx;
  106. border-radius: 12rpx;
  107. min-height: 80rpx;
  108. display: -webkit-box;
  109. -webkit-line-clamp: 2;
  110. -webkit-box-orient: vertical;
  111. line-clamp: 2;
  112. overflow: hidden;
  113. }
  114. }
  115. }
  116. </style>