普兆健康管家前端代码仓库
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.

129 lines
3.4 KiB

  1. <template>
  2. <view class="card card-detect">
  3. <view class="flex card-header">
  4. <view class="title">检测项目</view>
  5. </view>
  6. <view class="section">
  7. <view class="table">
  8. <view class="table-cell table-th" v-for="item in headers" :key="item.key">
  9. {{ item.label }}
  10. </view>
  11. <template v-for="(row, index) in list">
  12. <view :class="['table-cell', index % 2 ? 'is-double-row' : '']" v-for="item in headers" :key="getKey(row.id, item.key)" :style="item.style">
  13. <template v-if="item.key === 'weight'">
  14. <uv-rate :value="row.weight" size="48rpx" gutter="16rpx" activeColor="#F7BA1E" :allowHalf="true" :minCount="0.5" readonly></uv-rate>
  15. </template>
  16. <template v-else-if="item.key === 'done'">
  17. {{ row.done ? '是' : '否' }}
  18. </template>
  19. <template v-else>
  20. {{ row[item.key] }}
  21. </template>
  22. </view>
  23. </template>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. list: {
  32. type: Array,
  33. default() {
  34. return []
  35. }
  36. }
  37. },
  38. data() {
  39. return {
  40. headers: [
  41. { key: 'name', label: '医学检测项目' },
  42. { key: 'significance', label: '检测意义', style: 'justify-content: flex-start;' },
  43. { key: 'sampling', label: '采样' },
  44. { key: 'weight', label: '权重' },
  45. { key: 'done', label: '是否检测' },
  46. ],
  47. }
  48. },
  49. methods: {
  50. getKey(id, key) {
  51. return `${id}-${key}`
  52. },
  53. onDownload(result) {
  54. console.log('onDownload')
  55. // todo
  56. uni.downloadFile({
  57. url: result, // 请求地址
  58. success: (response) => {
  59. if (response.statusCode === 200) {
  60. console.log('下载成功');
  61. // 继续处理文件保存
  62. const fileManager = wx.getFileSystemManager();
  63. fileManager.saveFile({
  64. tempFilePath: response.tempFilePath,
  65. success: (res) => {
  66. console.log(res, '下载成功');
  67. uni.hideLoading();
  68. },
  69. fail: (err) => {
  70. console.error('保存文件失败', err);
  71. }
  72. });
  73. }
  74. }
  75. });
  76. },
  77. },
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. @import './style.scss';
  82. .table {
  83. width: auto;
  84. overflow-x: auto;
  85. display: grid;
  86. grid-template-columns: 385rpx 385rpx auto auto auto;
  87. border: 2rpx solid #E6E6E6;
  88. border-radius: 24rpx;
  89. &-cell {
  90. display: inline-flex;
  91. align-items: center;
  92. justify-content: center;
  93. padding: 53rpx 8rpx;
  94. box-sizing: border-box;
  95. font-family: PingFang SC;
  96. font-weight: 400;
  97. font-size: 28rpx;
  98. line-height: 1.5;
  99. color: #080808;
  100. background: #FCFBFF;
  101. border-right: 2rpx solid #E6E6E6;
  102. border-bottom: 2rpx solid #E6E6E6;
  103. &:nth-child(5n) {
  104. border-right: none;
  105. }
  106. &:nth-last-child(-n+5) {
  107. border-bottom: none;
  108. }
  109. &.is-double-row {
  110. background: #F7F4FF;
  111. }
  112. }
  113. &-th {
  114. white-space: nowrap;
  115. padding: 24rpx 32rpx;
  116. color: #252545;
  117. background: #E6E6E6;
  118. }
  119. }
  120. </style>