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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
| <template>
| <BaseCard :direction="direction" :borderless="borderlessDirection">
| <template #content>
| <el-checkbox-group
| :model-value="modelValue"
| size="default"
| :min="1"
| @update:model-value="handleChange"
| >
| <div :class="vertical ? 'vertical-class' : ''">
| <el-checkbox
| v-for="item in options"
| :key="item.label"
| :value="item.value"
| >{{ item.label }}</el-checkbox
| >
| </div>
| </el-checkbox-group>
| </template>
| </BaseCard>
| </template>
|
| <script>
| // 监测因子单选框
| import { checkboxOptions } from '@/constant/checkbox-options';
| import { TYPE0 } from '@/constant/device-type';
|
| export default {
| props: {
| // 复选框值
| modelValue: Array,
| deviceType: {
| type: String,
| // type0: 车载或无人机; type1:无人船
| default: TYPE0
| },
| /**
| *
| * 样式朝向
| * top-left | left
| */
| direction: {
| type: String,
| default: 'top-left'
| },
| /**
| * 无边框的方向
| * t | r
| */
| borderlessDirection: {
| type: String,
| default: 't'
| },
| /**
| * 内容是否垂直排布
| */
| vertical: Boolean,
| // 默认选中的个数(从第一个选项开始)
| defaultNum: {
| type: Number,
| default: 1
| }
| },
| emits: ['update:modelValue'],
| data() {
| return {
| checkbox: [checkboxOptions(TYPE0)[0].value]
| };
| },
| computed: {
| options() {
| return checkboxOptions(this.deviceType);
| }
| },
| watch: {
| deviceType(nV, oV) {
| if (nV != oV) {
| const res = [];
| const array = checkboxOptions(nV);
| for (let i = 0; i < this.defaultNum; i++) {
| const e = array[i];
| res.push(e.value);
| }
| this.$emit('update:modelValue', res);
| }
| }
| },
| methods: {
| handleChange(value) {
| this.$emit('update:modelValue', value);
| }
| }
| };
| </script>
| <style scoped>
| .el-checkbox {
| --el-checkbox-text-color: white;
| margin-right: 6px;
| /* height: initial; */
| }
|
| .vertical-class {
| display: flex;
| flex-direction: column;
| }
| </style>
|
|