|
|
@@ -1,16 +1,29 @@
|
|
|
<script setup lang="ts">
|
|
|
import type { SelectValue } from 'ant-design-vue/es/select';
|
|
|
|
|
|
-import { type PropType } from 'vue';
|
|
|
+import { computed, type PropType, ref, unref } from 'vue';
|
|
|
+
|
|
|
+import { cn } from '@vben/utils';
|
|
|
|
|
|
import { useVModel } from '@vueuse/core';
|
|
|
import { Input } from 'ant-design-vue';
|
|
|
|
|
|
+import { Icon } from '#/components/icon';
|
|
|
+// import FormQuery from '#/views/system/design/table/components/preview.vue';
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
+ class: {
|
|
|
+ type: Object as PropType<any>,
|
|
|
+ default: undefined,
|
|
|
+ },
|
|
|
value: {
|
|
|
type: [String, Number, Array] as PropType<SelectValue>,
|
|
|
default: undefined,
|
|
|
},
|
|
|
+ placeholder: {
|
|
|
+ type: String as PropType<string>,
|
|
|
+ default: '请选择',
|
|
|
+ },
|
|
|
api: {
|
|
|
type: String as PropType<string>,
|
|
|
default: '',
|
|
|
@@ -20,30 +33,90 @@ const props = defineProps({
|
|
|
default: () => ({ label: 'label', value: 'value', options: null }),
|
|
|
},
|
|
|
});
|
|
|
+
|
|
|
const emit = defineEmits(['update:value']);
|
|
|
+
|
|
|
+// const [FormQueryModal, formQueryApi] = useVbenModal({
|
|
|
+// connectedComponent: FormQuery,
|
|
|
+// });
|
|
|
+
|
|
|
const modelValue = useVModel(props, 'value', emit, {
|
|
|
defaultValue: props.value,
|
|
|
passive: true,
|
|
|
});
|
|
|
-// const options = ref<BasicOptionResult[]>([]);
|
|
|
+
|
|
|
+const options = ref<Record<string, any>[]>([]);
|
|
|
+
|
|
|
+const displays = computed(() => {
|
|
|
+ const { fieldNames } = props;
|
|
|
+ return unref(options).map((item: any) => item[fieldNames.value]);
|
|
|
+});
|
|
|
+
|
|
|
+const handleSelect = () => {
|
|
|
+ // formQueryApi.setData({
|
|
|
+ // isPreview: true,
|
|
|
+ // isSelect: true,
|
|
|
+ // baseData: { name: props.placeholder, code: props.api },
|
|
|
+ // });
|
|
|
+ // formQueryApi.open();
|
|
|
+};
|
|
|
|
|
|
// const isFirstLoad = ref(true);
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="bc-popup w-full">
|
|
|
- <div class="bc-popup-selector">
|
|
|
- <div class="bc-popup-selection-overflow">
|
|
|
- <div class="bc-popup-selection-item">
|
|
|
- <div class="bc-popup-selection-item-content">asdfasdf</div>
|
|
|
- </div>
|
|
|
- <div class="bc-popup-selection-item">
|
|
|
- <div class="bc-popup-selection-item-content">bbb</div>
|
|
|
- </div>
|
|
|
- <div class="bc-popup-selection-placeholder">请选择</div>
|
|
|
- <div class="bc-popup-selection-item">
|
|
|
- <div style="width: 4px">
|
|
|
- <Input v-model="modelValue" stype="opacity: 0; " />
|
|
|
+ <div v-if="false">
|
|
|
+ <!-- <FormQueryModal v-if="false" :close-on-click-modal="false" /> -->
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ :class="
|
|
|
+ cn(
|
|
|
+ 'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-border relative z-[1000] max-h-96 min-w-32 overflow-hidden rounded-md border',
|
|
|
+ props.class,
|
|
|
+ )
|
|
|
+ "
|
|
|
+ class="bc-popup-selector"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ :class="
|
|
|
+ cn(
|
|
|
+ 'p-1',
|
|
|
+ 'h-[--radix-select-trigger-height] w-full min-w-[--radix-select-trigger-width]',
|
|
|
+ )
|
|
|
+ "
|
|
|
+ class="bc-popup-selector-overflow"
|
|
|
+ >
|
|
|
+ <div class="flex flex-1 items-center justify-between">
|
|
|
+ <div cclass="flex-1 mr-3">
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in displays"
|
|
|
+ :key="index"
|
|
|
+ class="bc-popup-selector-item"
|
|
|
+ >
|
|
|
+ <div class="bc-popup-selector-item-content">{{ item }}</div>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-if="displays.length === 0"
|
|
|
+ class="bc-popup-selector-placeholder text-muted-foreground"
|
|
|
+ style="opacity: 0.5"
|
|
|
+ >
|
|
|
+ {{ placeholder }}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="bc-popup-selector-item"
|
|
|
+ style="width: 0; height: 0; opacity: 0"
|
|
|
+ >
|
|
|
+ <div style="width: 4px">
|
|
|
+ <Input v-model="modelValue" style="height: 0" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div @click="handleSelect">
|
|
|
+ <Icon
|
|
|
+ class="icon-more bc-popup-selector-btn size-5"
|
|
|
+ icon="ic:twotone-more-horiz"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -55,68 +128,33 @@ const modelValue = useVModel(props, 'value', emit, {
|
|
|
.bc-popup {
|
|
|
margin: 0;
|
|
|
padding: 0;
|
|
|
- color: rgba(0, 0, 0, 0.88);
|
|
|
- font-size: 14px;
|
|
|
- list-style: none;
|
|
|
- position: relative;
|
|
|
- display: inline-block;
|
|
|
cursor: pointer;
|
|
|
|
|
|
&-selector {
|
|
|
- cursor: text;
|
|
|
-
|
|
|
&-overflow {
|
|
|
position: relative;
|
|
|
display: flex;
|
|
|
flex: auto;
|
|
|
- flex-wrap: wrap;
|
|
|
max-width: 100%;
|
|
|
+ padding: 4px 11px;
|
|
|
+ }
|
|
|
|
|
|
- &-placeholder {
|
|
|
- position: absolute;
|
|
|
- top: 50%;
|
|
|
- inset-inline-start: 11px;
|
|
|
- inset-inline-end: 11px;
|
|
|
- transform: translateY(-50%);
|
|
|
- transition: all 0.3s;
|
|
|
- }
|
|
|
+ &-item {
|
|
|
+ border: 1px solid hsl(var(--border));
|
|
|
+ border-radius: 4px;
|
|
|
|
|
|
- &-item {
|
|
|
- flex: none;
|
|
|
- align-self: center;
|
|
|
- max-width: 100%;
|
|
|
- display: inline-flex;
|
|
|
- position: relative;
|
|
|
- display: flex;
|
|
|
- flex: none;
|
|
|
- box-sizing: border-box;
|
|
|
- max-width: 100%;
|
|
|
- height: 24px;
|
|
|
- margin-top: 2px;
|
|
|
- margin-bottom: 2px;
|
|
|
- line-height: 22px;
|
|
|
- background: rgba(0, 0, 0, 0.06);
|
|
|
- border: 1px solid rgba(5, 5, 5, 0.06);
|
|
|
- border-radius: 4px;
|
|
|
- cursor: default;
|
|
|
- transition:
|
|
|
- font-size 0.3s,
|
|
|
- line-height 0.3s,
|
|
|
- height 0.3s;
|
|
|
- user-select: none;
|
|
|
+ &-content {
|
|
|
+ display: inline-block;
|
|
|
margin-inline-end: 4px;
|
|
|
- padding-inline-start: 8px;
|
|
|
- padding-inline-end: 4px;
|
|
|
-
|
|
|
- &-content {
|
|
|
- display: inline-block;
|
|
|
- margin-inline-end: 4px;
|
|
|
- overflow: hidden;
|
|
|
- white-space: pre;
|
|
|
- text-overflow: ellipsis;
|
|
|
- }
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: pre;
|
|
|
+ text-overflow: ellipsis;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ &-btn {
|
|
|
+ color: hsl(var(--border));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|