CommonInfoRow.vue 2.7 KB

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