RecommendItem.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div style="height: 100%">
  3. <div class="menu-title">
  4. 洞悉({{ gorseQo.userId }})
  5. <div class="icon icon-back" @click="backBtn">
  6. <i title="返回"></i>
  7. </div>
  8. </div>
  9. <div class="block_box" style="margin-top: 20px">
  10. <div class="title">推荐</div>
  11. <el-form :inline="true" class="demo-form-inline">
  12. <el-form-item>
  13. <el-select v-model="gorseQo.recommendation" @change="getRecommendItem">
  14. <el-option :key="item.value" :value="item.value" :label="item.label"
  15. v-for="item in recommendList"></el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="种类">
  19. <el-select v-model="gorseQo.category" @change="getRecommendItem">
  20. <el-option value="" label="无"></el-option>
  21. <el-option :key="item.id" :value="item.name" :label="item.name"
  22. v-for="item in categoryList"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. </el-form>
  26. <div class="line-item-box">
  27. <div class="line-item" v-for="item in list" :key="item.id">
  28. <div class="title-time">
  29. <div>{{ item.ItemId }}</div>
  30. <div>{{ item.Timestamp }}</div>
  31. </div>
  32. <div class="description">{{ item.Comment }}</div>
  33. <div class="labels">
  34. <el-tag v-for="la in item.Labels">{{ la }}</el-tag>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import request from '@/utils/request';
  43. var _this;
  44. export default {
  45. name: "RecommendItem",
  46. data() {
  47. return {
  48. qo: "",
  49. gorseQo: {
  50. userId: '',
  51. n: 10,
  52. recommendation: '_',
  53. category: ''
  54. },
  55. user: {},
  56. categoryList: [],
  57. recommendList: [{
  58. label: '默认推荐',
  59. value: '_'
  60. }, {
  61. label: '离线推荐',
  62. value: 'offline'
  63. }, {
  64. label: '协同推荐',
  65. value: 'collaborative'
  66. }, {
  67. label: '基于物品推荐',
  68. value: 'item_based'
  69. }, {
  70. label: '基于用户推荐',
  71. value: 'user_based'
  72. }],
  73. list: []
  74. }
  75. },
  76. mounted() {
  77. _this = this;
  78. _this.qo = _this.$route.query.qo;
  79. _this.gorseQo.userId = _this.$route.query.userId;
  80. _this.queryCategoryList();
  81. _this.getRecommendItem();
  82. },
  83. methods: {
  84. queryCategoryList() {
  85. request({
  86. url: '/category/query_list',
  87. method: 'post',
  88. data: {}
  89. }).then(res => {
  90. _this.categoryList = res.data;
  91. });
  92. },
  93. getRecommendItem() {
  94. request({
  95. url: '/gorse/get_recommend_by_user',
  96. method: 'post',
  97. data: _this.gorseQo
  98. }).then(res => {
  99. res.data.forEach(row => {
  100. row.labelsArr = row.labels ? row.labels.split(',') : [];
  101. });
  102. _this.list = res.data;
  103. });
  104. },
  105. backBtn() {
  106. _this.$router.back();
  107. },
  108. }
  109. }
  110. </script>
  111. <style src="../../../css/back.css" scoped></style>
  112. <style scoped lang="scss">
  113. .block_box {
  114. margin: 25px;
  115. background: #FFFFFF;
  116. border-radius: 3px;
  117. height: calc(100% - 160px);
  118. .title {
  119. border-bottom: 1px solid #ccc;
  120. padding: 15px 25px;
  121. }
  122. }
  123. .demo-form-inline {
  124. padding: 25px 25px 0 25px;
  125. }
  126. .line-item-box {
  127. height: calc(100% - 140px);
  128. overflow-y: auto;
  129. .line-item {
  130. font-size: 14px;
  131. line-height: 32px;
  132. padding: 0 25px 10px 25px;
  133. margin: 20px 0;
  134. border-bottom: 1px solid #dee0e2;
  135. .title-time {
  136. display: flex;
  137. div:first-child {
  138. font-weight: bold;
  139. font-size: 18px;
  140. color: #9da2a8;
  141. }
  142. div:last-child {
  143. margin-left: auto;
  144. color: #bbbcbd;
  145. }
  146. }
  147. .description {
  148. color: #bbbcbd;
  149. }
  150. .labels {
  151. color: #9da2a8;
  152. .el-tag {
  153. margin: 0 10px 10px 0;
  154. }
  155. }
  156. }
  157. }
  158. </style>