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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<template>
  <div class="checkbox-action-sheet">
    <div class="checkbox-action-sheet-title">{{ title }}</div>
    <nut-checkbox-group v-model="model" :max="max">
      <nut-checkbox v-for="item in columns" :key="item.id" :label="item.id" icon-size="16">
        {{ item.name }}</nut-checkbox
      >
    </nut-checkbox-group>
    <div class="checkbox-action-sheet-footer">
      <nut-button type="primary" plain @click="handleCancel">取消</nut-button>
      <nut-button type="primary" @click="handleConfirm">确定</nut-button>
    </div>
  </div>
</template>
 
<script setup lang="ts">
defineOptions({
  name: 'CheckboxActionSheet',
});
 
type Props = {
  max?: number;
  title?: string;
  columns?: API.GetTypeSearchSettingList[];
};
 
const props = withDefaults(defineProps<Props>(), {});
 
const emit = defineEmits<{
  (e: 'update:modelValue', value: Array<string | number>): void;
  (e: 'update:visible', value: boolean): void;
}>();
 
const model = defineModel<Array<string | number>>();
const visible = defineModel<boolean>('visible');
 
function handleCancel() {
  model.value = [];
  emit('update:visible', false);
}
 
function handleConfirm() {
  emit('update:visible', false);
  emit('update:modelValue', model.value);
}
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
 
.checkbox-action-sheet {
  padding: 30px 30px 0;
 
  .checkbox-action-sheet-title {
    font-size: 32px;
    text-align: center;
    margin-bottom: 30px;
    color: #2878ff;
  }
 
  .nut-checkbox-group {
    padding-bottom: 30rpx;
    max-height: 400px;
    min-height: 200px;
 
    .nut-checkbox {
      margin-bottom: 20rpx;
 
      .nut-checkbox__label {
        margin-left: 10rpx;
      }
    }
  }
 
  .checkbox-action-sheet-footer {
    --nut-button-default-padding: 0 80px;
 
    display: flex;
    justify-content: space-around;
 
    .nut-button--primary {
      border-width: 1px;
    }
  }
}
</style>