ArtList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div class="content-container">
  3. <div class="list-group">
  4. <el-row class="title-bar">
  5. <p class="page-title">{{ title }}</p>
  6. </el-row>
  7. <vuescroll :ops="ops" style="height: calc(100% - 90px);">
  8. <el-tree
  9. :expand-on-click-node="false"
  10. :default-expand-all="true"
  11. :data="treeData"
  12. :props="defaultProps"
  13. @node-click="handleNodeClick"
  14. >
  15. <template v-slot="{ node, data }">
  16. <span class="custom-tree-node">
  17. <span class="label">{{ node.label }}</span>
  18. <span class="right-icon" @click="event => clickItem(event,data)">
  19. <i class="icon el-icon-caret-bottom" />
  20. </span>
  21. </span>
  22. </template>
  23. </el-tree>
  24. </vuescroll>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import { getArtByList } from '@/api/system/artApi'
  30. import { toTree } from '@/utils/build-tree'
  31. import Vuescroll from 'vuescroll'
  32. export default {
  33. name: 'ArtList',
  34. components: { Vuescroll },
  35. props: {
  36. artCatId: {
  37. type: Number,
  38. default: undefined
  39. },
  40. title: {
  41. type: String,
  42. default: ''
  43. }
  44. },
  45. data() {
  46. return {
  47. ops: {
  48. bar: {
  49. keepShow: false,
  50. background: 'rgba(144, 147, 153, 0.4)',
  51. onlyShowBarOnScroll: false
  52. }
  53. },
  54. treeData: [],
  55. defaultProps: {
  56. children: 'children',
  57. label: 'artTitle'
  58. },
  59. conditions: {
  60. artCatId: this.artCatId
  61. }
  62. }
  63. },
  64. mounted() {
  65. this.getData()
  66. },
  67. methods: {
  68. loadData() {},
  69. getData() {
  70. getArtByList(this.conditions).then((resp) => {
  71. const { code, data } = resp
  72. if (code === 200) {
  73. const temp = toTree(data, {
  74. value: 'artId',
  75. name: 'artTitle',
  76. pValue: 'parentId'
  77. }, {
  78. value: 'artId',
  79. name: 'artTitle',
  80. pValue: 'parentId'
  81. })
  82. this.treeData = temp
  83. if (temp.length > 0) { this.handleTreeInit(temp[0]) }
  84. }
  85. }).catch((error) => {
  86. console.log(error)
  87. })
  88. },
  89. handleNodeClick(data) {
  90. this.$emit('selectItem', data.artId)
  91. },
  92. handleTreeInit(data) {
  93. this.$emit('selectItem', data.artId)
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .content-container {
  100. margin: 10px 0 10px 10px;
  101. height: calc(100vh - 90px);
  102. .title-bar {
  103. position: relative;
  104. height: 40px;
  105. line-height: 40px;
  106. text-indent: 15px;
  107. background: #113849;
  108. margin-bottom: 0;
  109. .page-title {
  110. font-size: 16px;
  111. font-weight: bold;
  112. color: #FFF;
  113. margin: 0;
  114. background: linear-gradient(0deg, #FFFFFF 0%, #98A8B7 100%);
  115. -webkit-background-clip: text;
  116. -webkit-text-fill-color: transparent;
  117. }
  118. .right-icon {
  119. position: absolute;
  120. right: 15px;
  121. top: 14px;
  122. color: #5181A2;
  123. width: 14px;
  124. height: 14px;
  125. line-height: 14px;
  126. cursor: pointer;
  127. .icon {
  128. position: absolute;
  129. right: 0;
  130. top: 0;
  131. font-size: 14px;
  132. font-weight: bolder;
  133. }
  134. }
  135. }
  136. .btn-group {
  137. width: 100%;
  138. margin-bottom: 15px;
  139. .send-menu {
  140. width: 100%;
  141. background: #3D5F76;
  142. color: #FFF;
  143. border-color: #3D5F76;
  144. &:hover {
  145. background: #283c4c;
  146. color: #FFF;
  147. border-color: #283c4c;
  148. }
  149. }
  150. }
  151. .list-group {
  152. height: calc(100vh - 110px);
  153. background: #193142;
  154. .list-item {
  155. height: 40px;
  156. line-height: 40px;
  157. color: #FFF;
  158. padding: 0 30px;
  159. font-size: 14px;
  160. &.active {
  161. color: #08A6DC;
  162. position: relative;
  163. &::after {
  164. position: absolute;
  165. content: "";
  166. width: 0;
  167. height: 0;
  168. top: calc(50% - 3.5px);
  169. right: -3px;
  170. border-left: 7px solid transparent;
  171. border-right: 7px solid transparent;
  172. border-bottom: 7px solid #08A6DC;
  173. transform: rotate(270deg);
  174. }
  175. }
  176. }
  177. }
  178. .custom-tree-node {
  179. position: relative;
  180. width: 100%;
  181. .right-icon {
  182. position: absolute;
  183. right: 10px;
  184. top: 14px;
  185. background: #5181A2;
  186. color: #FFFFFF;
  187. width: 14px;
  188. height: 14px;
  189. border: 1px solid #3D6F91;
  190. line-height: 14px;
  191. font-size: 10px;
  192. display: none !important;
  193. cursor: pointer;
  194. .icon {
  195. position: relative;
  196. top: -2px;
  197. }
  198. }
  199. // &:hover {
  200. // .right-icon {
  201. // display: block;
  202. // }
  203. // }
  204. }
  205. }
  206. </style>