wupengfei
2025-03-11 286f1b727856d6b32a8d237f353ae008f3076deb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
  <ChooseInput :modelValue="inputValue" @click="handleOpen()"></ChooseInput>
</template>
 
<script setup lang="ts">
import { Portal } from 'senin-mini/components';
import ChooseInput from './ChooseInput.vue';
import { computed, h } from 'vue';
import { Popup, DatePicker, Picker } from '@nutui/nutui-taro';
import CheckboxActionSheet from '../ActionSheet/CheckboxActionSheet.vue';
import _ from 'lodash';
 
defineOptions({
  name: 'ChooseInputWithCheckbox',
});
 
type Props = {
  columns: API.GetTypeSearchSettingList[];
  modelValue: Array<string | number>;
  title?: string;
  max?: number;
};
 
const props = withDefaults(defineProps<Props>(), {});
const inputValue = computed(() =>
  props.modelValue.map((x) => props.columns.find((y) => y.id === x)?.name).join(',')
);
 
const emit = defineEmits<{
  (e: 'update:modelValue', val: Array<string | number>): void;
}>();
 
function handleOpen() {
  Portal.add((key) => {
    return h(
      Portal.Container,
      { keyNumber: key, delayOpen: true },
      {
        default: ({ open, onClose }) =>
          h(
            Popup,
            {
              visible: open.value,
              'onUpdate:visible': (value) => !value && onClose(),
              position: 'bottom',
              closeOnClickOverlay: false,
            },
            {
              default: () =>
                h(CheckboxActionSheet, {
                  modelValue: props.modelValue,
                  columns: props.columns,
                  title: props.title,
                  visible: open.value,
                  'onUpdate:visible': (value) => !value && onClose(),
                  'onUpdate:modelValue': (value) => {
                    emit('update:modelValue', value);
                  },
                }),
            }
          ),
      }
    );
  });
}
</script>