|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <template>
- <view @touchmove.stop @touch.stop>
- <myCell v-show="cellVisible" :title="title_" isLink :border="false" :hasValue="value?true:false"
- @click="cellClick" :align="align"></myCell>
- <u-popup :show="show" mode="center" :round="10" @close="close" @open="open">
- <view style="max-height: 800rpx;overflow-y: auto;">
- <u-radio-group v-model="value_" iconPlacement="right" placement="column" @change="change" borderBottom>
- <u-radio v-for="(item,index) in options" :key="index" :label="item.label"
- :name="item.value"></u-radio>
- </u-radio-group>
- </view>
- </u-popup>
- </view>
- </template>
-
- <script>
- import myCell from "@/components/cell.vue"
- export default {
- name: "selectRadio",
- components: {
- myCell
- },
- props: {
- value: {
- default: "",
- },
- options: {
- default: [],
- type: Array
- },
- title: {
- default: "",
- },
- placeholder: {
- default: "请选择",
- },
- cellVisible: {
- default: true,
- },
- align: {
- default: "left",
- },
- },
- data() {
- return {
- show: false,
- title_: this.title || this.placeholder,
- value_: this.value,
- };
- },
- mounted() {
- this.value_ = this.value
- if (this.value_) {
- let obj = this.options.find(e1 => e1.value == this.value_)
- this.title_ = obj?obj.label:''
- this.$emit("update:title", this.title_)
- }else{
- this.$emit("update:title", '')
- }
- },
- methods: {
- cellClick() {
- if (!this.options.length) {
- this.TOAST('暂无数据')
- return
- }
- this.show = true
- },
- close() {
- this.show = false
- },
- open() {
- this.show = true
- },
- change(e) {
- this.$emit("input", e)
- this.$emit("change", e)
- let obj = this.options.find(e1 => e1.value == e)
- this.title_ = obj.label
- this.$emit("update:title", this.title_)
- this.close()
- },
- }
- }
- </script>
-
- <style scoped lang="scss">
- .u-radio-group {
- width: 560rpx;
- overflow-y: auto;
- padding: 12rpx 32rpx 24rpx 32rpx;
-
- .u-cell {
- background-color: #fff;
- border-radius: 20rpx;
- padding: 24rpx 0;
- }
- }
-
- .u-border-bottom {
- border-color: #F6F6F6 !important;
- }
-
- .u-radio {
- margin-top: 26rpx;
- padding-bottom: 28rpx !important;
- }
-
- .u-radio:last-child {
- border-bottom: none;
- padding-bottom: 14rpx !important;
- }
- </style>
|