GrowthRecords.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="growth-records admin-page">
  3. <el-card>
  4. <div slot="header">
  5. <span>成长记录</span>
  6. <el-input v-model="keyword" placeholder="搜索成长记录..." prefix-icon="el-icon-search" style="width:200px" clearable @keyup.enter.native="handleSearch" @clear="handleSearch" />
  7. <el-select v-model="sourceFilter" placeholder="来源筛选" clearable size="small" style="float: right; width: 140px; margin-left: 10px;" @change="loadRecords">
  8. <el-option label="全部" value="" />
  9. <el-option label="手动创建" value="manual" />
  10. <el-option label="测评录入" value="assessment" />
  11. <el-option label="报告上传" value="upload" />
  12. <el-option label="补充材料" value="supplement" />
  13. </el-select>
  14. </div>
  15. <el-table :data="filteredRecords" v-loading="loading" border stripe :max-height="tableHeight">
  16. <el-table-column prop="id" label="ID" width="70" />
  17. <el-table-column prop="childName" label="孩子" width="100" />
  18. <el-table-column prop="sourceType" label="来源" width="100">
  19. <template slot-scope="scope">
  20. <el-tag size="mini" :type="sourceTagType(scope.row.sourceType)">{{ sourceLabel(scope.row.sourceType) }}</el-tag>
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="recordTitle" label="标题" min-width="140" show-overflow-tooltip />
  24. <el-table-column prop="reportDate" label="报告日期" width="110" />
  25. <el-table-column prop="overallScore" label="综合得分" width="90" />
  26. <el-table-column prop="parentRecordId" label="主记录ID" width="90">
  27. <template slot-scope="scope">
  28. <span v-if="scope.row.parentRecordId">{{ scope.row.parentRecordId }}</span>
  29. <span v-else>-</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column prop="isLatest" label="最新" width="60">
  33. <template slot-scope="scope">
  34. <span v-if="scope.row.isLatest === 1">&#10003;</span>
  35. <span v-else>-</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="createdAt" label="创建时间" width="170" />
  39. </el-table>
  40. </el-card>
  41. </div>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'GrowthRecords',
  46. data() {
  47. return {
  48. loading: false,
  49. records: [],
  50. sourceFilter: '',
  51. keyword: ''
  52. }
  53. },
  54. computed: {
  55. tableHeight() {
  56. return window.innerHeight - 300
  57. },
  58. filteredRecords() {
  59. if (!this.keyword) return this.records
  60. var kw = this.keyword.toLowerCase()
  61. return this.records.filter(function(r) {
  62. return (r.recordTitle && r.recordTitle.toLowerCase().indexOf(kw) !== -1) ||
  63. (r.childName && r.childName.toLowerCase().indexOf(kw) !== -1)
  64. })
  65. }
  66. },
  67. created() {
  68. this.loadRecords()
  69. },
  70. methods: {
  71. sourceLabel(type) {
  72. var map = { manual: '手动创建', assessment: '测评录入', upload: '报告上传', supplement: '补充材料' }
  73. return map[type] || (type || '-')
  74. },
  75. sourceTagType(type) {
  76. var map = { manual: 'info', assessment: 'success', upload: 'warning', supplement: '' }
  77. return map[type] || 'info'
  78. },
  79. handleSearch() {},
  80. async loadRecords() {
  81. this.loading = true
  82. try {
  83. var baseURL = process.env.VUE_APP_BASE_API || ''
  84. var token = localStorage.getItem('token')
  85. var axios = this.$axios || (await import('axios')).default
  86. var params = {}
  87. if (this.sourceFilter) {
  88. params.sourceType = this.sourceFilter
  89. }
  90. var res = await axios.post(baseURL + '/api/growth/record/list', params, {
  91. headers: { Authorization: 'Bearer ' + token }
  92. })
  93. this.records = res.data && res.data.data ? res.data.data : (res.data || [])
  94. } catch (e) {
  95. this.$message && this.$message.error && this.$message.error('加载成长记录失败')
  96. } finally {
  97. this.loading = false
  98. }
  99. }
  100. }
  101. }
  102. </script>