| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <template>
- <div class="content-container">
- <div class="list-group">
- <el-row class="title-bar">
- <p class="page-title">{{ title }}</p>
- </el-row>
- <vuescroll :ops="ops" style="height: calc(100% - 90px);">
- <el-tree
- :expand-on-click-node="false"
- :default-expand-all="true"
- :data="treeData"
- :props="defaultProps"
- @node-click="handleNodeClick"
- >
- <template v-slot="{ node, data }">
- <span class="custom-tree-node">
- <span class="label">{{ node.label }}</span>
- <span class="right-icon" @click="event => clickItem(event,data)">
- <i class="icon el-icon-caret-bottom" />
- </span>
- </span>
- </template>
- </el-tree>
- </vuescroll>
- </div>
- </div>
- </template>
- <script>
- import { getArtByList } from '@/api/system/artApi'
- import { toTree } from '@/utils/build-tree'
- import Vuescroll from 'vuescroll'
- export default {
- name: 'ArtList',
- components: { Vuescroll },
- props: {
- artCatId: {
- type: Number,
- default: undefined
- },
- title: {
- type: String,
- default: ''
- }
- },
- data() {
- return {
- ops: {
- bar: {
- keepShow: false,
- background: 'rgba(144, 147, 153, 0.4)',
- onlyShowBarOnScroll: false
- }
- },
- treeData: [],
- defaultProps: {
- children: 'children',
- label: 'artTitle'
- },
- conditions: {
- artCatId: this.artCatId
- }
- }
- },
- mounted() {
- this.getData()
- },
- methods: {
- loadData() {},
- getData() {
- getArtByList(this.conditions).then((resp) => {
- const { code, data } = resp
- if (code === 200) {
- const temp = toTree(data, {
- value: 'artId',
- name: 'artTitle',
- pValue: 'parentId'
- }, {
- value: 'artId',
- name: 'artTitle',
- pValue: 'parentId'
- })
- this.treeData = temp
- if (temp.length > 0) { this.handleTreeInit(temp[0]) }
- }
- }).catch((error) => {
- console.log(error)
- })
- },
- handleNodeClick(data) {
- this.$emit('selectItem', data.artId)
- },
- handleTreeInit(data) {
- this.$emit('selectItem', data.artId)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content-container {
- margin: 10px 0 10px 10px;
- height: calc(100vh - 90px);
- .title-bar {
- position: relative;
- height: 40px;
- line-height: 40px;
- text-indent: 15px;
- background: #113849;
- margin-bottom: 0;
- .page-title {
- font-size: 16px;
- font-weight: bold;
- color: #FFF;
- margin: 0;
- background: linear-gradient(0deg, #FFFFFF 0%, #98A8B7 100%);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- }
- .right-icon {
- position: absolute;
- right: 15px;
- top: 14px;
- color: #5181A2;
- width: 14px;
- height: 14px;
- line-height: 14px;
- cursor: pointer;
- .icon {
- position: absolute;
- right: 0;
- top: 0;
- font-size: 14px;
- font-weight: bolder;
- }
- }
- }
- .btn-group {
- width: 100%;
- margin-bottom: 15px;
- .send-menu {
- width: 100%;
- background: #3D5F76;
- color: #FFF;
- border-color: #3D5F76;
- &:hover {
- background: #283c4c;
- color: #FFF;
- border-color: #283c4c;
- }
- }
- }
- .list-group {
- height: calc(100vh - 110px);
- background: #193142;
- .list-item {
- height: 40px;
- line-height: 40px;
- color: #FFF;
- padding: 0 30px;
- font-size: 14px;
- &.active {
- color: #08A6DC;
- position: relative;
- &::after {
- position: absolute;
- content: "";
- width: 0;
- height: 0;
- top: calc(50% - 3.5px);
- right: -3px;
- border-left: 7px solid transparent;
- border-right: 7px solid transparent;
- border-bottom: 7px solid #08A6DC;
- transform: rotate(270deg);
- }
- }
- }
- }
- .custom-tree-node {
- position: relative;
- width: 100%;
- .right-icon {
- position: absolute;
- right: 10px;
- top: 14px;
- background: #5181A2;
- color: #FFFFFF;
- width: 14px;
- height: 14px;
- border: 1px solid #3D6F91;
- line-height: 14px;
- font-size: 10px;
- display: none !important;
- cursor: pointer;
- .icon {
- position: relative;
- top: -2px;
- }
- }
- // &:hover {
- // .right-icon {
- // display: block;
- // }
- // }
- }
- }
- </style>
|