| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <style scoped lang="scss">
- .text {
- display: inline-block;
- padding: 3px 6px;
- font-size: 11px;
- font-weight: 600;
- line-height: 1;
- height: 20px;
- text-align: center;
- white-space: nowrap;
- vertical-align: baseline;
- border-radius: 10px;
- margin-top: 3px;
- width: auto;
- color: #FF5722;
- border: 1px solid #FF5722;
- }
- .true-text {
- color: #5FB878;
- border: 1px solid #5FB878;
- }
- </style>
- <template>
- <div>
- <span v-if="disabled" class="text" :class="{'true-text':props.modelValue==true}">{{ props.modelValue ? '是' : '否' }}</span>
- <el-select v-else
- transfer
- :multiple="false"
- clearable
- @change="handleChange"
- style="width: 100%"
- :placeholder="placeholder"
- v-model="state.model">
- <el-option label="是" :value="true"><el-text type="success">是</el-text></el-option>
- <el-option label="否" :value="false"><el-text type="danger">否</el-text></el-option>
- </el-select>
- </div>
- </template>
- <script setup lang="ts" name="ExtBoolean">
- import {reactive, onMounted, watch} from 'vue';
- //数据字典的布尔值类型的下拉选择组件
- const props = defineProps({
- modelValue: {
- type: Boolean
- },
- disabled: {
- type: Boolean,
- default: false
- },
- placeholder: {
- type: String,
- default: '请选择'
- },
- tips: {
- type: String
- }
- })
- const state = reactive({
- model: false,
- })
- onMounted(() => {
- state.model = props.modelValue;
- })
- watch(() => props.modelValue, (val, oldVal) => {
- console.log('ExtBoolean watch modelValue', val, oldVal)
- state.model = props.modelValue;
- })
- const emit = defineEmits(['on-change', 'update:modelValue']);
- const handleChange = () => {
- console.log(state.model)
- emit('update:modelValue', state.model)
- emit('on-change', state.model)
- }
- </script>
|