Skip to content

Commit

Permalink
feat: dict-select支持select的插槽配置,支持页面内打开对话框,支持路由缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Sep 15, 2021
1 parent d4c4fb4 commit e5c0fc0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
7 changes: 4 additions & 3 deletions packages/fast-crud/src/components/crud/fs-form-wrapper.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.fs-dialog-inner{
position: absolute !important;
}

.fs-form-wrapper{
&.fs-dialog-inner{
position: absolute;
}

.fs-form-footer-btns{
display: flex;
margin-top:20px;
Expand Down
39 changes: 26 additions & 13 deletions packages/fast-crud/src/components/extends/fs-dict-select.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<template>
<component :is="$fsui.select.name" :placeholder="computedPlaceholder">
<template v-for="item of computedOptions" :key="getValue(item)">
<component :is="$fsui.option.name" v-bind="item" :value="getValue(item)" :label="getLabel(item)">
{{ getLabel(item) }}
</component>
</template>
</component>
</template>
<script>
import { computed } from "vue";
<script lang="jsx">
import { computed, resolveDynamicComponent } from "vue";
import { useDict } from "../../use/use-dict";
import { useI18n } from "../../locale";
import { useUi } from "../../use";
import _ from "lodash-es";
/**
* 字典选择框
* 支持el-select|a-select的属性配置
Expand All @@ -31,7 +22,11 @@ export default {
/**
* placeholder
*/
placeholder: { type: String }
placeholder: { type: String },
/**
* select组件的插槽
*/
slots: {}
},
// render () {
// return this.renderFunc({ data: this.data, dataMap: this.dataMap, scope: this.scope, attrs: this.$attrs })
Expand All @@ -47,6 +42,24 @@ export default {
computedPlaceholder,
...useDict(props, ctx, ui.select.modelValue)
};
},
render() {
const selectComp = resolveDynamicComponent(this.$fsui.select.name);
const options = [];
const optionComp = resolveDynamicComponent(this.$fsui.option.name);
for (const item of this.computedOptions) {
const option = (
<optionComp {...item} value={this.getValue(item)} label={this.getLabel(item)}>
{this.getLabel(item)}
</optionComp>
);
options.push(option);
}
return (
<selectComp placeholder={this.computedPlaceholder} v-slots={this.slots}>
{options}
</selectComp>
);
}
};
</script>
Expand Down

0 comments on commit e5c0fc0

Please sign in to comment.