风险测评小程序前端代码仓库
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.

145 lines
3.1 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. }
  88. }
  89. &-cell {
  90. min-width: 0;
  91. display: inline-flex;
  92. align-items: center;
  93. justify-content: center;
  94. padding: 13rpx;
  95. box-sizing: border-box;
  96. font-family: PingFang SC;
  97. font-weight: 400;
  98. font-size: 24rpx;
  99. line-height: 1.5;
  100. color: #080808;
  101. background: #FFFEEE;
  102. border-right: 2rpx solid #DADADA;
  103. border-bottom: 2rpx solid #DADADA;
  104. // &:nth-last-child(-n+5) {
  105. // border-bottom: none;
  106. // }
  107. }
  108. &-th {
  109. white-space: nowrap;
  110. padding: 20rpx;
  111. font-size: 26rpx;
  112. color: #014FA2;
  113. background: rgba($color: #014FA2, $alpha: 0.11);
  114. }
  115. }
  116. .level {
  117. &-0 {
  118. color: #014FA2;
  119. }
  120. &-1 {
  121. color: #FFA800;
  122. }
  123. &-2 {
  124. color: #FF0000;
  125. }
  126. &-3 {
  127. color: #B81C1C;
  128. }
  129. }
  130. </style>