2025-02-26 16:55:15 +08:00
|
|
|
<template>
|
|
|
|
<el-select v-model="val" @change="change">
|
2025-02-27 11:34:43 +08:00
|
|
|
<el-option v-for="item in options" :key="`land_type_${item.value}`" :value="item.value" :label="item.label" :placeholder="props.placeholder">
|
2025-02-26 16:55:15 +08:00
|
|
|
{{ item.label }}
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref, watch } from 'vue';
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
// 父组件传过来的值
|
|
|
|
value: {
|
2025-02-28 16:45:42 +08:00
|
|
|
type: String || Number || null,
|
2025-02-26 16:55:15 +08:00
|
|
|
default: null,
|
|
|
|
},
|
2025-02-27 11:34:43 +08:00
|
|
|
placeholder: {
|
|
|
|
type: String,
|
|
|
|
default: '请选择',
|
|
|
|
},
|
2025-02-26 16:55:15 +08:00
|
|
|
});
|
|
|
|
const emit = defineEmits(['update:value']);
|
|
|
|
/* --------------- data --------------- */
|
|
|
|
// #region
|
|
|
|
|
|
|
|
const val = ref(null);
|
|
|
|
watch(
|
|
|
|
() => props.value,
|
|
|
|
() => {
|
2025-02-28 16:45:42 +08:00
|
|
|
val.value = props.value || props.value == 0 ? String(props.value) : null;
|
2025-02-26 16:55:15 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
deep: true,
|
|
|
|
immediate: true,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
const options = ref([
|
|
|
|
{ label: '是', value: '0' },
|
|
|
|
{ label: '否', value: '1' },
|
|
|
|
]);
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
/* --------------- methods --------------- */
|
|
|
|
// #region
|
|
|
|
function change(val_) {
|
|
|
|
val.value = val_;
|
|
|
|
emit('update:value', val_);
|
|
|
|
}
|
|
|
|
// #endregion
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|