|
@@ -1,10 +1,7 @@
|
|
|
<template>
|
|
<template>
|
|
|
<cl-select-trigger
|
|
<cl-select-trigger
|
|
|
v-if="showTrigger"
|
|
v-if="showTrigger"
|
|
|
- :pt="{
|
|
|
|
|
- className: pt.trigger?.className,
|
|
|
|
|
- icon: pt.trigger?.icon
|
|
|
|
|
- }"
|
|
|
|
|
|
|
+ :pt="ptTrigger"
|
|
|
:placeholder="placeholder"
|
|
:placeholder="placeholder"
|
|
|
:disabled="disabled"
|
|
:disabled="disabled"
|
|
|
:focus="popupRef?.isOpen"
|
|
:focus="popupRef?.isOpen"
|
|
@@ -13,18 +10,7 @@
|
|
|
@clear="clear"
|
|
@clear="clear"
|
|
|
></cl-select-trigger>
|
|
></cl-select-trigger>
|
|
|
|
|
|
|
|
- <cl-popup
|
|
|
|
|
- ref="popupRef"
|
|
|
|
|
- v-model="visible"
|
|
|
|
|
- :title="title"
|
|
|
|
|
- :pt="{
|
|
|
|
|
- className: pt.popup?.className,
|
|
|
|
|
- header: pt.popup?.header,
|
|
|
|
|
- container: pt.popup?.container,
|
|
|
|
|
- mask: pt.popup?.mask,
|
|
|
|
|
- draw: pt.popup?.draw
|
|
|
|
|
- }"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <cl-popup ref="popupRef" v-model="visible" :title="title" :pt="ptPopup">
|
|
|
<view class="cl-select-popup" @touchmove.stop>
|
|
<view class="cl-select-popup" @touchmove.stop>
|
|
|
<slot name="prepend"></slot>
|
|
<slot name="prepend"></slot>
|
|
|
|
|
|
|
@@ -67,8 +53,8 @@
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { ref, computed, type PropType, watch } from "vue";
|
|
import { ref, computed, type PropType, watch } from "vue";
|
|
|
-import type { ClSelectOption } from "../../types";
|
|
|
|
|
-import { isEmpty, isNull, parsePt } from "@/cool";
|
|
|
|
|
|
|
+import type { ClSelectOption, ClSelectValue } from "../../types";
|
|
|
|
|
+import { isEmpty, isNull, parsePt, parseToObject } from "@/cool";
|
|
|
import type { ClSelectTriggerPassThrough } from "../cl-select-trigger/props";
|
|
import type { ClSelectTriggerPassThrough } from "../cl-select-trigger/props";
|
|
|
import type { ClPopupPassThrough } from "../cl-popup/props";
|
|
import type { ClPopupPassThrough } from "../cl-popup/props";
|
|
|
import { t } from "@/locale";
|
|
import { t } from "@/locale";
|
|
@@ -82,9 +68,6 @@ defineSlots<{
|
|
|
append(): any;
|
|
append(): any;
|
|
|
}>();
|
|
}>();
|
|
|
|
|
|
|
|
-// 值类型
|
|
|
|
|
-type Value = string[] | number[] | number | string | null;
|
|
|
|
|
-
|
|
|
|
|
// 组件属性定义
|
|
// 组件属性定义
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
// 透传样式配置
|
|
// 透传样式配置
|
|
@@ -94,7 +77,7 @@ const props = defineProps({
|
|
|
},
|
|
},
|
|
|
// 选择器的值
|
|
// 选择器的值
|
|
|
modelValue: {
|
|
modelValue: {
|
|
|
- type: [Array, Number, String] as PropType<Value>,
|
|
|
|
|
|
|
+ type: [Array, Number, String] as PropType<ClSelectValue>,
|
|
|
default: null
|
|
default: null
|
|
|
},
|
|
},
|
|
|
// 选择器标题
|
|
// 选择器标题
|
|
@@ -169,6 +152,12 @@ type PassThrough = {
|
|
|
// 解析透传样式配置
|
|
// 解析透传样式配置
|
|
|
const pt = computed(() => parsePt<PassThrough>(props.pt));
|
|
const pt = computed(() => parsePt<PassThrough>(props.pt));
|
|
|
|
|
|
|
|
|
|
+// 解析触发器透传样式配置
|
|
|
|
|
+const ptTrigger = computed(() => parseToObject(pt.value.trigger));
|
|
|
|
|
+
|
|
|
|
|
+// 解析弹窗透传样式配置
|
|
|
|
|
+const ptPopup = computed(() => parseToObject(pt.value.popup));
|
|
|
|
|
+
|
|
|
// 当前选中的值
|
|
// 当前选中的值
|
|
|
const value = ref<any[]>([]);
|
|
const value = ref<any[]>([]);
|
|
|
|
|
|
|
@@ -248,7 +237,7 @@ function getValue() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 解析值
|
|
// 解析值
|
|
|
-function setValue(val: Value) {
|
|
|
|
|
|
|
+function setValue(val: ClSelectValue) {
|
|
|
// 声明选中值数组
|
|
// 声明选中值数组
|
|
|
let _value: any[];
|
|
let _value: any[];
|
|
|
|
|
|
|
@@ -348,10 +337,10 @@ function onChange(a: number[]) {
|
|
|
const visible = ref(false);
|
|
const visible = ref(false);
|
|
|
|
|
|
|
|
// 选择回调函数
|
|
// 选择回调函数
|
|
|
-let callback: ((value: Value) => void) | null = null;
|
|
|
|
|
|
|
+let callback: ((value: ClSelectValue) => void) | null = null;
|
|
|
|
|
|
|
|
// 打开选择器
|
|
// 打开选择器
|
|
|
-function open(cb: ((value: Value) => void) | null = null) {
|
|
|
|
|
|
|
+function open(cb: ((value: ClSelectValue) => void) | null = null) {
|
|
|
visible.value = true;
|
|
visible.value = true;
|
|
|
|
|
|
|
|
// 设置值
|
|
// 设置值
|
|
@@ -400,7 +389,7 @@ function confirm() {
|
|
|
// 监听modelValue变化
|
|
// 监听modelValue变化
|
|
|
watch(
|
|
watch(
|
|
|
computed(() => props.modelValue),
|
|
computed(() => props.modelValue),
|
|
|
- (val: Value) => {
|
|
|
|
|
|
|
+ (val: ClSelectValue) => {
|
|
|
setValue(val);
|
|
setValue(val);
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|