XhSelect.vue 1.16 KB
<!-- *******************  单个下拉选择  *******************  -->
<template>
	<view>
		<u-input :value="text" readOnly @click="show=true" type="select" />
		<u-action-sheet :list="settings" v-model="show" @click="actionSheetCallback"></u-action-sheet>
	</view>
</template>

<script>
	import stringMixin from './stringMixin'
	export default {
		name: 'XhSelect',
		components: {},
		mixins: [stringMixin],
		props: {},
		data() {
			return {
				show: false
			}
		},
		computed: {
			type() {
				if (this.item && this.item.fieldsType == 'password') {
					return this.item.fieldsType
				} else {
					return 'text'
				}
			},
			settings() {
				let result = []
				let settings = this.item.fieldsOptions || []
				result = settings.map(item => {
					return {
						text: item.label,
						id: item.key
					}
				})
				return result
			},
			text(){
				let option = this.item.fieldsOptions.find(a=>{return a.key === this.dataValue}) 
				return option?option.label:''
			}
		},
		watch: {},
		mounted() {},
		methods: {
			actionSheetCallback(index) {
				let id = this.settings[index].id;
				this.dataValue = id
				this.valueChange(id)
			}
		}
	}
</script>

<style>
</style>