diff --git a/src/components/cascader/cascader.vue b/src/components/cascader/cascader.vue
index 42d18e73..cfb23b52 100644
--- a/src/components/cascader/cascader.vue
+++ b/src/components/cascader/cascader.vue
@@ -92,7 +92,8 @@
return [
`${prefixCls}`,
{
- [`${prefixCls}-show-clear`]: this.showCloseIcon
+ [`${prefixCls}-show-clear`]: this.showCloseIcon,
+ [`${prefixCls}-visible`]: this.visible
}
]
},
@@ -105,28 +106,42 @@
label.push(this.selected[i].label);
}
- return this.renderFormat(label);
+ return this.renderFormat(label, this.selected);
}
},
methods: {
clearSelect () {
-
+ const oldVal = JSON.stringify(this.value);
+ this.value = this.selected = this.tmpSelected = [];
+ this.handleClose();
+ this.emitValue(this.value, oldVal);
+ this.$broadcast('on-clear');
},
handleClose () {
this.visible = false;
},
onFocus () {
this.visible = true;
+ if (!this.value.length) {
+ this.$broadcast('on-clear');
+ }
},
updateResult (result) {
this.tmpSelected = result;
},
- updateSelected () {
- this.$broadcast('on-find-selected', this.value);
+ updateSelected (init = false) {
+ if (!this.changeOnSelect || init) {
+ this.$broadcast('on-find-selected', this.value);
+ }
+ },
+ emitValue (val, oldVal) {
+ if (JSON.stringify(val) !== oldVal) {
+ this.$emit('on-change', this.value, JSON.parse(JSON.stringify(this.selected)));
+ }
}
},
ready () {
- this.updateSelected();
+ this.updateSelected(true);
},
events: {
// lastValue: is click the final val
@@ -140,10 +155,10 @@
this.selected.forEach((item) => {
newVal.push(item.value);
});
- this.value = newVal;
- if (JSON.stringify(this.value) !== oldVal) {
- this.$emit('on-change', this.value);
+ if (!fromInit) {
+ this.value = newVal;
+ this.emitValue(this.value, oldVal);
}
}
if (lastValue && !fromInit) {
diff --git a/src/components/cascader/casitem.vue b/src/components/cascader/casitem.vue
index 44b1ddb8..b9eb1401 100644
--- a/src/components/cascader/casitem.vue
+++ b/src/components/cascader/casitem.vue
@@ -18,9 +18,6 @@
}
]
}
- },
- ready () {
-
}
}
\ No newline at end of file
diff --git a/src/components/cascader/caspanel.vue b/src/components/cascader/caspanel.vue
index 45cfea92..4bc86553 100644
--- a/src/components/cascader/caspanel.vue
+++ b/src/components/cascader/caspanel.vue
@@ -105,6 +105,10 @@
}
}
}
+ },
+ 'on-clear' () {
+ this.sublist = [];
+ this.tmpItem = {};
}
}
}
diff --git a/src/styles/components/cascader.less b/src/styles/components/cascader.less
index a87d4ee9..c87ebba5 100644
--- a/src/styles/components/cascader.less
+++ b/src/styles/components/cascader.less
@@ -24,14 +24,10 @@
}
&-arrow {
- position: absolute;
- top: 50%;
- right: 8px;
- line-height: 1;
- margin-top: -6px;
- font-size: @font-size-base;
- color: @subsidiary-color;
- .transition(all @transition-time @ease-in-out);
+ .inner-arrow();
+ }
+ &-visible &-arrow:nth-of-type(2){
+ .transform(rotate(180deg));
}
.@{select-dropdown-prefix-cls} {
@@ -78,7 +74,7 @@
&-active{
background-color: @background-color-select-hover;
- font-weight: bold;
+ color: @primary-color;
}
}
}
diff --git a/src/styles/components/select.less b/src/styles/components/select.less
index 2bca4f74..cbbca26d 100644
--- a/src/styles/components/select.less
+++ b/src/styles/components/select.less
@@ -41,13 +41,7 @@
}
&-arrow {
- position: absolute;
- top: 50%;
- right: 8px;
- line-height: 1;
- margin-top: -6px;
- color: @subsidiary-color;
- .transition(all @transition-time @ease-in-out);
+ .inner-arrow();
}
&-visible{
diff --git a/src/styles/mixins/common.less b/src/styles/mixins/common.less
index e93b9983..ddac4f1e 100644
--- a/src/styles/mixins/common.less
+++ b/src/styles/mixins/common.less
@@ -18,4 +18,16 @@
-webkit-user-select: @type;
-moz-user-select: @type;
user-select: @type;
+}
+
+// for select and input like component's arrow
+.inner-arrow() {
+ position: absolute;
+ top: 50%;
+ right: 8px;
+ line-height: 1;
+ margin-top: -7px;
+ font-size: @font-size-base;
+ color: @subsidiary-color;
+ .transition(all @transition-time @ease-in-out);
}
\ No newline at end of file
diff --git a/test/routers/cascader.vue b/test/routers/cascader.vue
index 080c9c43..9256f873 100644
--- a/test/routers/cascader.vue
+++ b/test/routers/cascader.vue
@@ -1,6 +1,7 @@
-
+ {{ value | json }}
+