From 0b80b9268e52f0001abee267dee05fe6c5e6cd4b Mon Sep 17 00:00:00 2001
From: iczer <1126263215@qq.com>
Date: Sun, 5 Aug 2018 15:17:34 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84TagSelect=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
src/components/list/Search/SearchForm.vue | 27 ++++-----
src/components/list/Search/SearchLayout.vue | 22 +++-----
src/components/tool/TagSelect.vue | 62 +++++++++++++++++++--
src/components/tool/TagSelectOption.vue | 7 ++-
5 files changed, 82 insertions(+), 38 deletions(-)
diff --git a/README.md b/README.md
index ade7542..50ac6bf 100644
--- a/README.md
+++ b/README.md
@@ -2,4 +2,4 @@
**Ant Design Pro 的 Vue 实现(非官方)**
一个开箱即用的中后台前端/设计解决方案
-[预览地址](https://iczer.gitee.io/vue-antd-pro/#/login)(开发中...)
+[预览地址](https://iczer.gitee.io/vue-antd-pro)(开发中...)
diff --git a/src/components/list/Search/SearchForm.vue b/src/components/list/Search/SearchForm.vue
index 1f26b06..4b32320 100644
--- a/src/components/list/Search/SearchForm.vue
+++ b/src/components/list/Search/SearchForm.vue
@@ -3,21 +3,22 @@
- 科目一
- 科目一
- 科目一
- 科目一
- 科目一
- 科目一
- 科目一
- 科目一
- 科目一
- 科目一
- 科目一
+ 类目一
+ 类目二
+ 类目三
+ 类目四
+ 类目五
+ 类目六
+ 类目七
+ 类目八
+ 类目九
+ 类目十
+ 类目十一
+ 类目十二
+ 类目十三
+ 类目十四
diff --git a/src/components/list/Search/SearchLayout.vue b/src/components/list/Search/SearchLayout.vue
index 1f9b833..ee38b7e 100644
--- a/src/components/list/Search/SearchLayout.vue
+++ b/src/components/list/Search/SearchLayout.vue
@@ -30,25 +30,17 @@ const ATabPane = ATabs.TabPane
export default {
name: 'SearchLayout',
components: {ATabPane, ATabs, AInputSearch, AButton, AInputGroup, AInput},
- data () {
- return {
- activeKey: '1'
- }
- },
- watch: {
- '$route': function (val) {
- switch (val.path) {
+ computed: {
+ activeKey () {
+ switch (this.$route.path) {
case '/list/search/article':
- this.activeKey = '1'
- break
+ return '1'
case '/list/search/application':
- this.activeKey = '2'
- break
+ return '2'
case '/list/search/project':
- this.activeKey = '3'
- break
+ return '3'
default:
- this.activeKey = '2'
+ return '1'
}
}
},
diff --git a/src/components/tool/TagSelect.vue b/src/components/tool/TagSelect.vue
index 9297bed..98aa830 100644
--- a/src/components/tool/TagSelect.vue
+++ b/src/components/tool/TagSelect.vue
@@ -1,8 +1,8 @@
@@ -14,19 +14,69 @@ import AIcon from 'vue-antd-ui/es/icon/icon'
export default {
name: 'TagSelect',
Option: TagSelectOption,
- components: {AIcon, TagSelectOption, ACheckableTag, ASelect}
+ components: {AIcon, TagSelectOption, ACheckableTag, ASelect},
+ data () {
+ return {
+ showTrigger: false,
+ collapsed: true,
+ screenWidth: document.body.clientWidth,
+ checkAll: false
+ }
+ },
+ watch: {
+ screenWidth: function () {
+ this.showTrigger = this.needTrigger()
+ },
+ collapsed: function (val) {
+ this.$el.style.maxHeight = val ? '39px' : '78px'
+ }
+ },
+ mounted () {
+ let _this = this
+ // 此处延迟执行,是为解决mouted未完全完成情况下引发的trigger显示bug
+ setTimeout(() => {
+ _this.showTrigger = _this.needTrigger()
+ _this.$refs.trigger.style.display = _this.showTrigger ? 'inline' : 'none'
+ }, 1)
+ window.onresize = () => {
+ return (() => {
+ window.screenWidth = document.body.clientWidth
+ _this.screenWidth = window.screenWidth
+ })()
+ }
+ },
+ methods: {
+ needTrigger () {
+ return this.$el.clientHeight < this.$el.scrollHeight || this.$el.scrollHeight > 39
+ },
+ toggle () {
+ this.collapsed = !this.collapsed
+ },
+ getAllTags () {
+ const tagList = this.$children.filter((item) => {
+ return item.isTagSelectOption
+ })
+ return tagList
+ },
+ toggleCheck () {
+ this.checkAll = !this.checkAll
+ const tagList = this.getAllTags()
+ tagList.forEach((item) => {
+ item.checked = this.checkAll
+ })
+ }
+ }
}