调整 el-popover 显示方式

This commit is contained in:
icssoa 2022-05-17 11:02:02 +08:00
parent 5945fb80ba
commit fdfd2d8ea5
4 changed files with 30 additions and 89 deletions

View File

@ -1,10 +1,5 @@
<template> <template>
<el-popover <el-popover placement="bottom-start" width="660px" popper-class="icon-check" trigger="click">
v-model:visible="visible"
placement="bottom-start"
width="660px"
popper-class="icon-check"
>
<el-row :gutter="10" class="list scroller1"> <el-row :gutter="10" class="list scroller1">
<el-col v-for="(item, index) in list" :key="index" :span="2" :xs="4"> <el-col v-for="(item, index) in list" :key="index" :span="2" :xs="4">
<el-button :class="{ 'is-active': item === name }" @click="onChange(item)"> <el-button :class="{ 'is-active': item === name }" @click="onChange(item)">
@ -14,13 +9,7 @@
</el-row> </el-row>
<template #reference> <template #reference>
<el-input <el-input v-model="name" placeholder="请选择" clearable @input="onChange" />
v-model="name"
placeholder="请选择"
clearable
@click="open"
@input="onChange"
/>
</template> </template>
</el-popover> </el-popover>
</template> </template>
@ -42,9 +31,6 @@ export default defineComponent({
emits: ["update:modelValue"], emits: ["update:modelValue"],
setup(props, { emit }) { setup(props, { emit }) {
//
const visible = ref<boolean>(false);
// //
const list = ref<any[]>(iconList()); const list = ref<any[]>(iconList());
@ -58,14 +44,6 @@ export default defineComponent({
} }
); );
function open() {
visible.value = true;
}
function close() {
visible.value = false;
}
function onChange(val: string) { function onChange(val: string) {
emit("update:modelValue", val); emit("update:modelValue", val);
close(); close();
@ -74,7 +52,6 @@ export default defineComponent({
return { return {
name, name,
list, list,
visible,
open, open,
close, close,
onChange onChange

View File

@ -1,7 +1,6 @@
<template> <template>
<div class="menu-check__wrap"> <div class="menu-check__wrap">
<el-popover <el-popover
v-model:visible="visible"
placement="bottom-start" placement="bottom-start"
width="660px" width="660px"
popper-class="menu-check" popper-class="menu-check"
@ -27,7 +26,7 @@
</div> </div>
<template #reference> <template #reference>
<el-input v-model="name" readonly placeholder="请选择" @click="visible = true" /> <el-input v-model="name" readonly placeholder="请选择" />
</template> </template>
</el-popover> </el-popover>
</div> </div>
@ -55,8 +54,6 @@ export default defineComponent({
// //
const keyword = ref<string>(""); const keyword = ref<string>("");
const visible = ref<boolean>(false);
// //
const list = ref<any[]>([]); const list = ref<any[]>([]);
@ -69,7 +66,6 @@ export default defineComponent({
// //
function onCurrentChange({ id }: any) { function onCurrentChange({ id }: any) {
emit("update:modelValue", id); emit("update:modelValue", id);
visible.value = false;
} }
// //
@ -111,7 +107,6 @@ export default defineComponent({
}); });
return { return {
visible,
keyword, keyword,
list, list,
expandedKeys, expandedKeys,
@ -136,7 +131,7 @@ export default defineComponent({
} }
&__scroller { &__scroller {
max-height: 400px; max-height: 300px;
overflow: hidden auto; overflow: hidden auto;
} }
} }

View File

@ -447,11 +447,6 @@
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<div class="vue-cron__footer">
<el-button @click="close">{{ text.Close }}</el-button>
<el-button type="success" @click="save">{{ text.Save }}</el-button>
</div>
</div> </div>
</template> </template>
@ -469,7 +464,7 @@ export default {
showYear: Boolean showYear: Boolean
}, },
emits: ["update:modelValue", "change", "close"], emits: ["update:modelValue", "change"],
data() { data() {
return { return {
@ -718,20 +713,14 @@ export default {
watch: { watch: {
data() { data() {
this.rest(this.$data); this.rest(this.$data);
},
cron(val) {
this.$emit("update:modelValue", val);
this.$emit("change", val);
} }
}, },
methods: { methods: {
save() {
this.$emit("update:modelValue", this.cron);
this.$emit("change", this.cron);
this.close();
},
close() {
this.$emit("close");
},
rest(data) { rest(data) {
for (const i in data) { for (const i in data) {
if (data[i] instanceof Object) { if (data[i] instanceof Object) {
@ -754,6 +743,8 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.vue-cron { .vue-cron {
margin-top: 10px;
:deep(.el-tabs) { :deep(.el-tabs) {
box-shadow: none; box-shadow: none;
@ -764,10 +755,15 @@ export default {
.el-tabs__header { .el-tabs__header {
margin-bottom: 0; margin-bottom: 0;
} }
.el-tabs__item {
height: 30px;
line-height: 30px;
}
} }
&__item { &__item {
max-height: 300px; max-height: 250px;
overflow: auto; overflow: auto;
padding: 10px; padding: 10px;
border: 1px solid #eee; border: 1px solid #eee;
@ -777,11 +773,14 @@ export default {
.el-row { .el-row {
min-height: 32px; min-height: 32px;
line-height: 32px; line-height: 32px;
margin-bottom: 10px;
.el-radio { .el-radio {
line-height: 32px; line-height: 32px;
} }
:deep(.el-radio__label) {
font-size: 12px;
}
} }
} }

View File

@ -25,15 +25,6 @@ export default defineComponent({
setup(props, { emit }) { setup(props, { emit }) {
const cron = ref<string>(""); const cron = ref<string>("");
const visible = ref<boolean>(false);
function open() {
visible.value = true;
}
function close() {
visible.value = false;
}
watch(cron, (val: string) => { watch(cron, (val: string) => {
emit("update:modelValue", val); emit("update:modelValue", val);
@ -52,44 +43,23 @@ export default defineComponent({
return { return {
cron, cron,
visible,
open, open,
close close
}; };
}, },
render(ctx: any) { render(ctx: any) {
const ElPopover = (
<el-popover
v-model:visible={ctx.visible}
disabled={ctx.disabled || ctx.readonly}
width="600px"
></el-popover>
);
return ( return (
<div class="cl-cron"> <div class="cl-cron">
{h(
ElPopover,
{},
{
default() {
return <cron v-model={ctx.cron} onClose={ctx.close}></cron>;
},
reference() {
return (
<el-input <el-input
clearable clearable
disabled={ctx.disabled} disabled={ctx.disabled}
readonly={ctx.readonly} readonly={ctx.readonly}
v-model={ctx.cron} v-model={ctx.cron}
placeholder={ctx.placeholder} placeholder={ctx.placeholder}
onClick={ctx.open}
></el-input> ></el-input>
);
} <cron v-model={ctx.cron} onClose={ctx.close}></cron>
}
)}
</div> </div>
); );
} }