WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2023-08-18 9ab038ff4cce6095c112378109c71bc706b9a702
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
/**
 * CFilterSwitchRadio - 筛选项目,单选
 * @author Tevin
 */
 
<template>
    <view
        class="c-filter-switch-radio"
        :class="'type-'+type"
    >
        <view
            class="label"
            v-if="type==='item'"
        >{{label}}</view>
        <CSwitchRadio
            :itemRes="{
                label: type==='bar' ? label : '',
                name: switchName,
                formData: switchData,
                onChange: evt => handleChange(evt),
            }"
            checkAlign="left"
            checkedLabel="在线"
            uncheckedLabel="离线"
        />
    </view>
</template>
 
<script>
import Taro from '@tarojs/taro';
import { CSwitchRadio } from '@components/forms/switch';
import './cFilterSwitchRadio.scss';
 
export default {
    name: 'CFilterSwitchRadio',
    components: {
        CSwitchRadio,
    },
    props: {
        type: String,
        label: String,
        value: Boolean,
        onChange: Function,
    },
    data() {
        return {
            switchName: 'radio',
            switchData: {
                radio: '',
            },
        };
    },
    computed: {},
    watch: {
        value(newVal, oldVal) {
            this.switchData.radio = newVal;
        },
    },
    methods: {
        handleChange(value) {
            this.onChange(value);
        },
    },
    mounted() {
        this.switchData.radio = this.value;
    },
};
</script>