Skip to content

Commit

Permalink
perf(cascader): 优化级联选择器交互
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Feb 4, 2021
1 parent aafc965 commit f9e8638
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-pro-crud",
"version": "0.8.7-1",
"version": "0.8.7-2",
"author": "BoBo<[email protected]>",
"main": "lib/ProCrud.umd.min.js",
"files": [
Expand Down
25 changes: 25 additions & 0 deletions src/component/form-designer/src/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@
</template>
<template v-if="widget.type == 'cascader'">
<el-cascader
ref="cascader"
@visible-change="elCascaderOnlick"
@expand-change="elCascaderOnlick"
v-model="dataModel"
:disabled="readOnly || widget.options.disabled"
:clearable="widget.options.clearable"
Expand Down Expand Up @@ -373,6 +376,7 @@ import AvatarUpload from './components/AvatarUpload/AvatarUpload.vue';
export default class GenerateFormItem extends Vue {
$refs!: {
table: HTMLFormElement
cascader: HTMLFormElement
}

@Prop({
Expand Down Expand Up @@ -668,6 +672,27 @@ export default class GenerateFormItem extends Vue {
});
}

elCascaderOnlick() {
const that = this;
setTimeout(() => {
document.querySelectorAll('.el-cascader-node__label').forEach((el) => {
// eslint-disable-next-line func-names
(el as any).onclick = function () {
this.previousElementSibling.click();
that.$refs.cascader.dropDownVisible = false;
};
});
document
.querySelectorAll('.el-cascader-panel .el-radio')
.forEach((el) => {
// eslint-disable-next-line func-names
(el as any).onclick = function () {
that.$refs.cascader.dropDownVisible = false;
};
});
}, 100);
}

// 按钮点击
btnOnClick(widget) {
this.$emit('btnOnClick', widget.options.eventName);
Expand Down

0 comments on commit f9e8638

Please sign in to comment.