wujingjing
2025-04-09 c669cad587e0f7121f8dc42b65ee820583c7f8de
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
<template>
    <div class="flex flex-col gap-1">
        <span class="text-gray-600 font-normal">{{ `${item?.label}` }}</span>
        <div v-if="item?.options?.length > 0" class="flex-items-center gap-5">
            <span
                @click="select(subItem)"
                v-for="(subItem, index) in item?.options"
                :key="index"
                class="flex w-fit items-center cursor-pointer border-solid border px-3 border-gray-300 hover:text-white rounded-lg"
                :class="{
                    'cursor-not-allowed': disabled,
                    'bg-blue-400': subItem.value === item.value,
                    'text-white': subItem.value === item.value,
                }"
                >{{ subItem.label }}</span
            >
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { ref, watch } from 'vue';
import { ParentRegister } from '/@/stores/global';
const props = defineProps(['item', 'disabled']);
 
let hasExecute = false;
 
const select = (option) => {
    if (hasExecute) return;
    props.item.value = option.value;
    hasExecute = true;
 
    ParentRegister.notify?.({
        type: 'msg_callback',
        value: {
            type: props.item.type,
            value: option.value,
            event: props.item.event,
        },
    });
};
</script>
<style scoped lang="scss"></style>