WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2021-03-25 a2cf4b10434ab7633f023346550801a85837c55e
forms/select/CSelect.vue
@@ -6,6 +6,7 @@
<template>
    <view class="c-select">
        <picker
            v-if="!selectByPage"
            mode="selector"
            :range="options"
            :value="current"
@@ -24,10 +25,24 @@
                <view class="at-icon at-icon-chevron-right" />
            </AtInput>
        </picker>
        <view v-else-if="selectByPage.length > 5">
            <AtInput
                :name="itemRes.name"
                :title="itemRes.label"
                :required="itemRes.required"
                :error="itemRes.error"
                :placeholder="placeholder"
                :value="selected"
                :onFocus="evt=>onGoToSelectorPage()"
            >
                <view class="at-icon at-icon-chevron-right" />
            </AtInput>
        </view>
    </view>
</template>
<script>
import Taro from '@tarojs/taro';
import { AtInput } from 'taro-ui-vue';
import './cSelect.scss';
@@ -40,6 +55,8 @@
        options: Array,
        placeholder: String,
        itemRes: Object,
        selectByPage: String,
        onSelectFromPage: Function,
    },
    data() {
        return {};
@@ -72,6 +89,16 @@
            const item = this.options[evt.value];
            this.itemRes.onChange(item[this.optionKey]);
        },
        onGoToSelectorPage() {
            Taro.navigateTo({
                url: this.selectByPage,
                events: {
                    'CSelect:onSelected': data => {
                        this.onSelectFromPage(data);
                    },
                },
            });
        },
    },
    mounted() {},
};