export default {
  methods: {
    knowledgeResolver() {
      // 知识兴趣的数据解析
      const dimensionA = { name: '得分' }
      const tableDefines = { name: { label: '专业' } }
      const resolveKeys = []
      const matchedKeys = []
      const sortedData = this.source.datas
        .sort((left, right) => {
          const lWeight = left.matched ? 100 : 1
          const rWeight = right.matched ? 100 : 1
          return right.total * rWeight - left.total * lWeight // 以此保证matched项一定进入列表
        })
        .slice(0, 6) // 限制显示6个
      for (const data of this.source.datas) {
        if (!sortedData.includes(data)) continue
        const key = data.name
        resolveKeys.push(key)
        dimensionA[key] = data.total
        tableDefines[key] = { label: data.name }
        if (data.matched) matchedKeys.push(key)
      }
      this.dataList = [dimensionA]
      this.reportConfig.matchedKeys = matchedKeys
      this.reportConfig.resolveKeys = resolveKeys
      this.reportConfig.tableDefines = tableDefines
      this.reportConfig.resolveConfig = null
      this.reportConfig.categoryDescription = ''
      this.reportConfig.chartSubtext = `红色为推荐专业，系统仅展示最靠前${sortedData.length}项`
    }
  }
}
