km-fullsearch-rate.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div :class="$style.searchrate">
  3. <a-card :bordered="false" title="个人常用">
  4. <a-list item-layout="horizontal" :data-source="hotListData">
  5. <a-list-item slot="renderItem" slot-scope="item, index" @click="click(item)">
  6. <span :class="$style.num">{{ index + 1 }}</span>
  7. <span>{{ item }}</span>
  8. </a-list-item>
  9. </a-list>
  10. </a-card>
  11. </div>
  12. </template>
  13. <script>
  14. import KmKnowledageService from '../km-knowledage-service'
  15. import components from './_import-components/km-fullsearch-rate-import'
  16. export default {
  17. name: 'KmFullsearchRate',
  18. components,
  19. data() {
  20. return {
  21. hotListData: [],
  22. }
  23. },
  24. mounted() {
  25. this.getHotList()
  26. },
  27. methods: {
  28. getHotList() {
  29. KmKnowledageService.getHotserch().then((res) => {
  30. if (res.data.length > 0) {
  31. res.data.forEach((item, index) => {
  32. if (item === '请输入搜索内容') {
  33. res.data.splice(index, 1)
  34. }
  35. })
  36. this.hotListData = res.data
  37. }
  38. })
  39. },
  40. click(item) {
  41. this.$emit('onSearch', item, 'searchText')
  42. },
  43. },
  44. }
  45. </script>
  46. <style module lang="scss">
  47. @use '@/common/design' as *;
  48. $color-a: #9094a2;
  49. $color-b: #f82b44;
  50. $color-c: #f96300;
  51. $color-d: #fac572;
  52. .searchrate {
  53. width: 210px;
  54. max-width: 230px;
  55. margin-right: 1rem;
  56. margin-left: 1rem;
  57. .num {
  58. display: inline-block;
  59. width: 20px;
  60. height: 20px;
  61. margin-right: 10px;
  62. line-height: 1.125;
  63. color: $color-a;
  64. text-align: center;
  65. border: 1px solid $color-a;
  66. border-radius: 10px;
  67. }
  68. :global(.ant-list) {
  69. :global(.ant-list-item) {
  70. justify-content: flex-start;
  71. cursor: pointer;
  72. &:first-child {
  73. .num {
  74. color: $color-b;
  75. border-color: $color-b;
  76. }
  77. }
  78. &:nth-child(2) {
  79. .num {
  80. color: $color-c;
  81. border-color: $color-c;
  82. }
  83. }
  84. &:nth-child(3) {
  85. .num {
  86. color: $color-d;
  87. border-color: $color-d;
  88. }
  89. }
  90. }
  91. }
  92. }
  93. </style>