mrr.sj.front/components/dynamic-form/FormItemSelect.vue

57 lines
1.1 KiB
Vue
Raw Normal View History

2026-06-09 17:49:15 +08:00
<template>
2026-06-10 10:15:10 +08:00
<picker :range="options" @change="onChange">
2026-06-09 17:49:15 +08:00
<view class="form-select">
2026-06-10 10:15:10 +08:00
<text :class="['select-text', value ? '' : 'placeholder']">
{{ value || placeholder }}
2026-06-09 17:49:15 +08:00
</text>
2026-06-10 10:15:10 +08:00
<image src="https://mrrplus.oss-cn-beijing.aliyuncs.com/wxstaic/images/arrow_right.png" class="arrow-right"
mode="aspectFit" />
2026-06-09 17:49:15 +08:00
</view>
</picker>
</template>
<script>
export default {
2026-06-10 10:15:10 +08:00
name: 'FormItemSelect',
2026-06-09 17:49:15 +08:00
props: {
2026-06-10 10:15:10 +08:00
value: { type: [String, Number], default: '' },
options: { type: Array, default: function () { return []; } },
placeholder: { type: String, default: '请选择' }
2026-06-09 17:49:15 +08:00
},
methods: {
2026-06-10 10:15:10 +08:00
onChange: function (e) {
2026-06-09 17:49:15 +08:00
var index = e.detail.value;
var selected = this.options[index];
2026-06-10 10:15:10 +08:00
if (selected !== undefined) {
this.$emit('input', selected);
2026-06-09 17:49:15 +08:00
}
}
}
};
</script>
<style scoped>
.form-select {
display: flex;
align-items: center;
justify-content: space-between;
}
2026-06-10 10:15:10 +08:00
2026-06-09 17:49:15 +08:00
.select-text {
font-size: 28rpx;
color: #333333;
2026-06-10 10:15:10 +08:00
margin-right: 16rpx;
2026-06-09 17:49:15 +08:00
}
2026-06-10 10:15:10 +08:00
2026-06-09 17:49:15 +08:00
.placeholder {
2026-06-10 10:15:10 +08:00
font-weight: 400;
font-size: 28rpx;
2026-06-09 17:49:15 +08:00
color: #999999;
}
2026-06-10 10:15:10 +08:00
2026-06-09 17:49:15 +08:00
.arrow-right {
2026-06-10 10:15:10 +08:00
width: 32rpx;
height: 32rpx;
2026-06-09 17:49:15 +08:00
}
</style>