| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <div class="down-item" ref="layout">
- <h3 @click="parentClickHandle" :class="{active: showContent}" v-show="!key">
- <div>
- <span :class="{aactive: aaaactive}">{{title}}</span>
- <a>{{children.length}}</a>
- </div>
- <span>
- <i class="iconfont" :class="showContent ? 'icon-shouqi' : 'icon-xl'"></i>
- </span>
- </h3>
- <ul v-show="showContent && children.length > 0">
- <li v-for="(item, key) in children" :key="key" @click.stop="clickHandle(item)" :class="{active: item.name === active}">
- <p>• {{item.name}} <i class="iconfont icon-wancheng1" v-if="item.link || item.data"></i> </p>
- </li>
- </ul>
- </div>
- </template>
- <script>
- export default {
- props: ['setting', 'keyword', 'show', 'aaaactive'],
- data () {
- return {
- key: this.keyword,
- showAll: false,
- title: this.setting.title,
- showContent: false,
- active: null,
- isReq: false
- }
- },
- methods: {
- clickHandle (item) {
- this.$emit('checkItem', item)
- },
- parentClickHandle () {
- this.showContent = !this.showContent
- if (this.showContent) {
- this.$emit('showcontent')
- }
- }
- },
- computed: {
- children () {
- let children = [...this.setting.children]
- let title = this.setting.title
- if (title === '全部' && this.key) {
- return []
- }
- if (this.key) {
- children = children.filter(item => {
- return ~item.name.indexOf(this.keyword)
- })
- }
- return children
- }
- },
- watch: {
- show (newVal) {
- if (newVal === this.title) {
- this.showContent = true
- // this.parentClickHandle()
- }
- },
- '$route': {
- deep: true,
- immediate: true,
- handler (newVal) {
- this.active = newVal.params.show
- }
- },
- keyword (newVal) {
- this.key = newVal
- this.showContent = !!this.key
- },
- async showAll (newVal) {
- if (newVal) {
- if (!this.isReq) {
- await this.getData()
- }
- this.content.forEach(item => {
- if (!~this.actives.indexOf(item)) {
- this.actives.push(item)
- this.$emit('selected', item)
- }
- })
- } else {
- this.actives.forEach(item => {
- this.$emit('cancel', item)
- })
- this.actives = []
- }
- },
- showContent: {
- immediate: true,
- handler: function (newVal) {
- if (newVal) {
- setTimeout(() => {
- this.$refs.layout.parentNode.scrollTop = this.$refs.layout.offsetTop
- }, 50)
- }
- }
- }
- },
- mounted () {
- this.quxiaoHandle = () => {
- this.showAll = false
- }
- this.$bus.$on('quxiao', this.quxiaoHandle)
- this.$bus.$on('closeitem', (data) => {
- this.showContent = false
- })
- },
- beforeDestroy () {
- this.$bus.$off('quxiao', this.quxiaoHandle)
- }
- }
- </script>
- <style scoped>
- .down-item {
- margin-top: 10px;
- }
- .down-item > h3 {
- background-color: #ffffff;
- /* padding: 8px 20px; */
- height: 30px;
- display: flex;
- color: #fff;
- font-size: 16px;
- align-items: center;
- font-weight: normal;
- cursor: pointer;
- }
- .down-item > h3 input {
- -webkit-appearance: checkbox;
- cursor: pointer;
- }
- .down-item > h3 div {
- flex: 1;
- color: #2b2521;
- font-size: 14px;
- flex: 0 0 'auto';
- }
- .down-item > h3 i {
- color: #eac1a3;
- font-size: 16px;
- }
- .down-item > h3 div span {
- font-weight: bold;
- }
- .down-item > ul > li {
- margin: 16px 0;
- display: flex;
- align-items: center;
- cursor: pointer;
- }
- .down-item > ul > li img {
- flex: 0 0 auto;
- height: 20px;
- margin-right: 10px;
- }
- .down-item > ul > li p {
- flex: 1;
- color: #2b2521;
- font-size: 14px;
- }
- .down-item > ul > li.active p {
- color: #f13800;
- }
- .aactive {
- color: #f13800 !important;
- }
- .down-item > h3 a {
- background-color: #f13800;
- color: #fff;
- font-size: 12px;
- text-align: center;
- border-radius: 9px;
- width: 24px;
- height: 18px;
- line-height: 18px;
- display: inline-block;
- margin-left: 5px;
- }
- </style>
|