风险测评小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.2 KiB

  1. <template>
  2. <view class="table">
  3. <view class="table-header">
  4. <view class="table-cell table-th">风险</view>
  5. <view class="table-cell table-th">风险原因</view>
  6. <view class="table-cell table-th">风险等级</view>
  7. <view class="table-cell table-th">可能导致的结果</view>
  8. </view>
  9. <view class="table-row" v-for="row in list" :key="row.id">
  10. <view class="table-cell">{{ row.title }}</view>
  11. <view class="table-row-cols">
  12. <template v-for="child in row.children">
  13. <view class="table-cell" :key="getKey(child.id, 'reason')">{{ child.reason || '' }}</view>
  14. <view :class="['table-cell', `level-${child.level}`]" :key="getKey(child.id, 'level')">{{ getLevelDesc(child.level) }}</view>
  15. <view class="table-cell" :key="getKey(child.id, 'result')">{{ child.result || '' }}</view>
  16. </template>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. const LEVEL_AND_DESC_MAPPING = {
  23. '0': '低风险',
  24. '1': '中风险',
  25. '2': '高风险',
  26. '3': '合规',
  27. }
  28. export default {
  29. props: {
  30. list: {
  31. type: Array,
  32. default() {
  33. return []
  34. }
  35. }
  36. },
  37. data() {
  38. return {
  39. }
  40. },
  41. methods: {
  42. getKey(id, key) {
  43. return `${id}-${key}`
  44. },
  45. getLevelDesc(level) {
  46. return LEVEL_AND_DESC_MAPPING[level]
  47. },
  48. },
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .table {
  53. width: 100%;
  54. // overflow-x: auto;
  55. // display: grid;
  56. // // 148.5 184 146 244.5
  57. // grid-template-columns: 148rpx 184rpx 146rpx auto;
  58. border: 1rpx solid #DADADA;
  59. &-header {
  60. display: grid;
  61. grid-template-columns: 148rpx 184rpx 146rpx auto;
  62. .table-th {
  63. &:nth-child(4n) {
  64. border-right: none;
  65. }
  66. }
  67. }
  68. &-row {
  69. display: grid;
  70. // 148.5 184 146 244.5
  71. // grid-template-columns: 148rpx 184rpx 146rpx auto;
  72. grid-template-columns: 148rpx auto;
  73. &-cols {
  74. min-width: 0;
  75. display: grid;
  76. grid-template-columns: 184rpx 146rpx auto;
  77. .table-cell {
  78. &:nth-child(3n) {
  79. border-right: none;
  80. }
  81. }
  82. }
  83. &:last-child {
  84. & > .table-cell {
  85. border-bottom: none;
  86. }
  87. & > .table-row-cols {
  88. .table-cell:nth-last-child(-n+3) {
  89. border-bottom: none;
  90. }
  91. }
  92. }
  93. }
  94. &-cell {
  95. min-width: 0;
  96. display: inline-flex;
  97. align-items: center;
  98. justify-content: center;
  99. padding: 13rpx;
  100. box-sizing: border-box;
  101. font-family: PingFang SC;
  102. font-weight: 400;
  103. font-size: 24rpx;
  104. line-height: 1.5;
  105. color: #080808;
  106. background: #FFFEEE;
  107. border-right: 2rpx solid #DADADA;
  108. border-bottom: 2rpx solid #DADADA;
  109. // &:nth-last-child(-n+5) {
  110. // border-bottom: none;
  111. // }
  112. }
  113. &-th {
  114. white-space: nowrap;
  115. padding: 20rpx;
  116. font-size: 26rpx;
  117. color: #014FA2;
  118. background: rgba($color: #014FA2, $alpha: 0.11);
  119. }
  120. }
  121. .level {
  122. &-0 {
  123. color: #014FA2;
  124. }
  125. &-1 {
  126. color: #FFA800;
  127. }
  128. &-2 {
  129. color: #FF0000;
  130. }
  131. &-3 {
  132. color: #5AC725;
  133. }
  134. }
  135. </style>