Files

83 lines
2.1 KiB
Vue
Raw Permalink Normal View History

2024-04-12 17:57:52 +08:00
<template>
<view style="width: 100%">
<u--input :value="valueEnum[value]" disabledColor="#ffffff" :placeholder="placeholder"></u--input>
<u-picker :show="visibel" :keyName="labelName" :columns="columns" @confirm="skillConfirm" @cancel="skillClose"
@close="skillClose"></u-picker>
</view>
</template>
<script>
2024-05-11 16:13:50 +08:00
import {
keys
} from 'lodash'
2024-04-12 17:57:52 +08:00
export default {
data() {
return {
valueEnum: {}
}
},
props: {
valueName: {
type: String,
default: 'value'
},
labelName: {
type: String,
default: 'label'
},
placeholder: {
type: String,
require: ''
},
visibel: {
type: Boolean,
default: false,
},
columns: {
type: Array,
require: true
},
value: {
type: String,
require: ''
},
},
created() {
2024-05-11 16:13:50 +08:00
if (Array.isArray(this.columns)) {
this.init(this.columns)
}
2024-05-06 18:01:43 +08:00
},
watch: {
columns(val) {
if (Array.isArray(val)) {
2024-05-11 16:13:50 +08:00
this.init(val)
2024-05-06 18:01:43 +08:00
}
2024-04-12 17:57:52 +08:00
}
},
methods: {
2024-05-11 16:13:50 +08:00
init(val) {
val.map((item) => {
item.map((child) => {
this.valueEnum[child[this.valueName]] = child[this.labelName]
})
})
},
2024-04-12 17:57:52 +08:00
skillConfirm({
index,
value,
values
}) {
2024-05-11 16:13:50 +08:00
console.log(String(value[0][this.valueName]))
2024-04-12 17:57:52 +08:00
this.$emit("input", String(value[0][this.valueName]));
this.$emit("cancel");
},
skillClose() {
this.$emit("cancel");
}
},
}
</script>
<style>
</style>