From aa66f586cf3546e3700c3b0a10dc66888d55ccd9 Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Fri, 24 Jul 2020 14:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=91=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=20=E5=8D=95=E6=8D=AE=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=9D=A1=E4=BF=AE=E6=94=B9=20=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=9A=84el-select=E7=A7=BB=E9=99=A4collapse-tag=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Select/Select.vue | 55 ++--- vue/src/bizComponents/document/DocSteps.vue | 4 +- .../RegionSelector/Tree/TreeDialog.vue | 6 +- vue/src/components/TreeSelect/index.vue | 214 ++++++++++++++++++ vue/src/router/constant/modules/example.js | 6 + vue/src/router/util.js | 2 +- .../components/regionSelectorExample.vue | 2 +- .../example/components/treeSelectExample.vue | 31 +++ .../order/components/CategorySelector.vue | 61 +++-- 9 files changed, 315 insertions(+), 66 deletions(-) create mode 100644 vue/src/components/TreeSelect/index.vue create mode 100644 vue/src/views/example/components/treeSelectExample.vue diff --git a/vue/element-ui-personal/components/Select/Select.vue b/vue/element-ui-personal/components/Select/Select.vue index 80dffd4..49f1a92 100644 --- a/vue/element-ui-personal/components/Select/Select.vue +++ b/vue/element-ui-personal/components/Select/Select.vue @@ -12,28 +12,7 @@ :style="{ 'max-width': inputWidth - 32 + 'px', width: '100%' }" > - - - {{ selected[0].currentLabel }} - - - + {{ selected.length - 1 }} - - - + { - const length = this.$refs.input.value.length * 15 + 20 - this.inputLength = this.collapseTags ? Math.min(50, length) : length + this.inputLength = this.$refs.input.value.length * 15 + 20 this.managePlaceholder() this.resetInputHeight() }) @@ -483,25 +460,21 @@ }, getOption(value) { - let option - const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]' - const isNull = Object.prototype.toString.call(value).toLowerCase() === '[object null]' - const isUndefined = Object.prototype.toString.call(value).toLowerCase() === '[object undefined]' + const type = v => Object.prototype.toString.call(v).toLowerCase() + const isObject = type(value) === '[object object]' + const isNull = type(value) === '[object null]' + const isUndefined = type(value) === '[object undefined]' for (let i = this.cachedOptions.length - 1; i >= 0; i--) { const cachedOption = this.cachedOptions[i] const isEqual = isObject ? getValueByPath(cachedOption.value, this.valueKey) === getValueByPath(value, this.valueKey) : cachedOption.value === value - if (isEqual) { - option = cachedOption - break - } + if (isEqual) return cachedOption } - if (option) return option - const label = (!isObject && !isNull && !isUndefined) - ? value : '' - let newOption = { + + const label = (!isObject && !isNull && !isUndefined) ? value : '' + const newOption = { value: value, currentLabel: label } @@ -533,9 +506,7 @@ }) } this.selected = result - this.$nextTick(() => { - this.resetInputHeight() - }) + this.$nextTick(() => this.resetInputHeight()) }, handleFocus(event) { @@ -618,7 +589,7 @@ }, resetInputHeight() { - if (this.collapseTags && !this.filterable) return + if (!this.filterable) return this.$nextTick(() => { if (!this.$refs.reference) return let inputChildNodes = this.$refs.reference.$el.childNodes @@ -747,7 +718,7 @@ }, deleteTag(event, tag) { - let index = this.selected.indexOf(tag) + const index = this.selected.indexOf(tag) if (index > -1 && !this.selectDisabled) { const value = this.value.slice() value.splice(index, 1) diff --git a/vue/src/bizComponents/document/DocSteps.vue b/vue/src/bizComponents/document/DocSteps.vue index 786b79e..a277034 100644 --- a/vue/src/bizComponents/document/DocSteps.vue +++ b/vue/src/bizComponents/document/DocSteps.vue @@ -11,9 +11,9 @@ render(h, context) { const {status, finish} = context.props - const active = status === 2 && (finish === undefined || finish === 1) ? 3 : status + const active = status === 2 && (finish === undefined || finish === 2) ? 4 : status return ( - + diff --git a/vue/src/components/RegionSelector/Tree/TreeDialog.vue b/vue/src/components/RegionSelector/Tree/TreeDialog.vue index ecf7733..79a94be 100644 --- a/vue/src/components/RegionSelector/Tree/TreeDialog.vue +++ b/vue/src/components/RegionSelector/Tree/TreeDialog.vue @@ -1,5 +1,5 @@ + + diff --git a/vue/src/router/constant/modules/example.js b/vue/src/router/constant/modules/example.js index 135e53a..f62e6c0 100644 --- a/vue/src/router/constant/modules/example.js +++ b/vue/src/router/constant/modules/example.js @@ -77,6 +77,12 @@ const router = { name: 'regionSelectorExample', component: lazyLoadView(import('@/views/example/components/regionSelectorExample')), meta: {title: '行政区划选择'} + }, + { + path: 'treeSelectExample', + name: 'treeSelectExample', + component: lazyLoadView(import('@/views/example/components/treeSelectExample')), + meta: {title: '树选择'} } ] }, diff --git a/vue/src/router/util.js b/vue/src/router/util.js index 3547796..fc6c5bd 100644 --- a/vue/src/router/util.js +++ b/vue/src/router/util.js @@ -6,7 +6,7 @@ import PageSkeleton from "@/components/Skeleton/PageSkeleton" //拼接页面标题 export function setPageTitle(route) { const pageTitle = route.meta.title - document.title= pageTitle ? `${pageTitle} - ${title}` : title + document.title = pageTitle ? `${pageTitle} - ${title}` : title } //确定路由的标题 diff --git a/vue/src/views/example/components/regionSelectorExample.vue b/vue/src/views/example/components/regionSelectorExample.vue index 4971012..ebd400b 100644 --- a/vue/src/views/example/components/regionSelectorExample.vue +++ b/vue/src/views/example/components/regionSelectorExample.vue @@ -1,5 +1,5 @@