123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <template>
- <view class="tm-search fulled py-12"
- :class="[
- black_tmeme?'grey-darken-5':bgColor,
- `shadow-${shadow}`
- ]"
- >
- <view @click="$emit('click')" class="tm-search-body flex-around">
- <view v-if="showLeft" class="flex-shrink pl-32 flex-center">
- <slot name="left">
- <tm-icons @click="$emit('cancel')" :black="black_tmeme" :color="color_tmeme" dense :name="leftIcon"></tm-icons>
- </slot>
- </view>
- <view class="flex-between fulled py-10 mx-32" :class="[
- black_tmeme?' grey-darken-5':'grey-lighten-4',
- `round-${round}`
- ]">
- <view v-if="prefixText" class="px-16 flex-shrink flex-center text-size-n text-grey">
- {{prefixText}}
- </view>
- <view v-if="prefixIcon" class="pl-16 flex-shrink flex-center">
- <tm-icons :black="black_tmeme" :color="insertColor_thmeme" dense :name="prefixIcon"></tm-icons>
- </view>
- <input @focus="$emit('focus',$event)" @blur="$emit('blur',$event)" confirm-type="search" type="search" @confirm="confirm" v-model="valData" :disabled="disabled" :placeholder="placeholder" class="flat fulled text-size-n pl-16 py-4 tm-search-body-searc" :class="[`text-align-${align}`]" />
- <view v-if="clear&&valData.length>0" class="px-16 flex-shrink flex-center">
- <tm-icons @click="valData='';$emit('clear',valData)" :size="24" :black="black_tmeme" :color="insertColor_thmeme" dense name="icon-times"></tm-icons>
- </view>
- <view v-if="suffixIcon" class="px-16 flex-shrink flex-center">
- <slot name="suffixIcon">
- <tm-icons @click="confirm" :black="black_tmeme" :color="insertColor_thmeme" dense :name="suffixIcon"></tm-icons>
- </slot>
- </view>
-
- </view>
- <view @click="confirm" v-if="showRight" class="flex-shrink mr-32 text-size-n" :class="[
- `text-${color_tmeme}`
- ]">
- <slot name="right">
- <text class="text-size-n">{{confirmText}}</text>
- </slot>
- </view>
- </view>
- </view>
- </template>
- <script>
-
- import tmIcons from "@/tm-vuetify/components/tm-icons/tm-icons.vue"
- export default {
- components:{tmIcons},
- name:"tm-search",
- model:{
- prop:'value',
- event:'input'
- },
- props:{
- clear:{
- type:Boolean,
- default:false
- },
- value:{
- type:String,
- default:''
- },
- disabled:{
- type:Boolean|String,
- default:false
- },
- leftIcon:{
- type:String,
- default:'icon-angle-left'
- },
-
- prefixText:{
- type:String,
- default:''
- },
-
- prefixIcon:{
- type:String,
- default:'icon-search'
- },
-
- insertColor:{
- type:String,
- default:'primary'
- },
-
- suffixIcon:{
- type:String,
- default:''
- },
- showLeft:{
- type:Boolean,
- default:false
- },
- confirmText:{
- type:String,
- default:'搜索'
- },
- showRight:{
- type:Boolean,
- default:true
- },
- color:{
- type:String,
- default:'primary'
- },
-
- bgColor:{
- type:String,
- default:'white'
- },
- black:{
- type:Boolean|String,
- default:null
- },
- round:{
- type:Number,
- default:2
- },
- shadow:{
- type:Number,
- default:4
- },
- placeholder:{
- type:String,
- default:"请输入"
- },
- align:{
- type:String,
- default:'left'
- },
-
- fllowTheme:{
- type:Boolean|String,
- default:true
- }
- },
- computed:{
- black_tmeme: function() {
- if (this.black !== null) return this.black;
- return this.$tm.vx.state().tmVuetify.black;
- },
- color_tmeme:function(){
- if(this.$tm.vx.state().tmVuetify.color!==null&&this.$tm.vx.state().tmVuetify.color && this.fllowTheme){
- return this.$tm.vx.state().tmVuetify.color;
- }
- return this.color;
- },
- insertColor_thmeme:function(){
- if(this.$tm.vx.state().tmVuetify.color!==null&&this.$tm.vx.state().tmVuetify.color && this.fllowTheme){
- return this.$tm.vx.state().tmVuetify.color;
- }
- return this.insertColor;
- },
- valData:{
- get:function(){
- return this.value;
- },
- set:function(val){
- this.$emit('input',val)
- }
- }
- },
- data() {
- return {
-
- };
- },
- methods: {
- confirm(e) {
- this.$emit('confirm',this.value)
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .tm-search-body-searc{
- -webkit-appearance: none !important;
- }
- </style>
|