123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <template>
- <view class="tm-grid ">
- <tm-row :custom-class="border ? ' border-grey-lighten-4-a-1 round-5 overflow ' +(black_tmeme?' bk ':'') : ''">
- <tm-col
- :maxCol="maxGrid"
- :custom-class="(border ? ((index+1)<=(colNum-1)*grid?'border-grey-lighten-4-b-1 ':'') + ((index + 1) % grid ? 'border-grey-lighten-4-r-1 ' : ' ') : '') + (black_tmeme?' bk ':'')"
- v-for="(item, index) in listData" :key="index" :grid="col" justify="center"
- align="middle"
- :color="bgColor"
- >
- <view @click.stop="onclick(index,item)" class="tm-grid-hover flex-center flex-col " :style="{height:height_s+'px'}">
-
- <view class=" pb-6 flex-shrink px-10 " style="">
- <view class="tm-grid-icon flex-shrink" v-if="item.dot" >
-
- <tm-badges :color="item.color?item.color:color_tmeme" @click="clickDot(index,item)" v-if="item.dotIcon" :offset="[10,0]" :dot="false" :icon="item.dotIcon" ></tm-badges>
- <tm-badges @click="clickDot(index,item)" v-if="!item.dotIcon" :offset="[10,0]" :dot="true" ></tm-badges>
-
-
- </view>
- <tm-icons :prefx="item['prefx']?item['prefx']:''" :color="item.color?item.color:color_tmeme" :size="item.iconSize?item.iconSize:iconSize"
- :name="item.icon?item.icon:''"></tm-icons>
- </view>
- <view class="flex-center fulled">
- <text class="text-size-s text-align-center"
- :class="[item.fontColor?'text-'+item.fontColor:'text-'+fontColor]">{{ item.text?item.text:'' }}</text>
- </view>
- </view>
- </tm-col>
- </tm-row>
- </view>
- </template>
- <script>
-
-
- import tmRow from "@/tm-vuetify/components/tm-row/tm-row.vue"
- import tmCol from "@/tm-vuetify/components/tm-col/tm-col.vue"
- import tmBadges from "@/tm-vuetify/components/tm-badges/tm-badges.vue"
- import tmIcons from "@/tm-vuetify/components/tm-icons/tm-icons.vue"
- export default {
- components:{tmRow,tmCol,tmBadges,tmIcons},
- name: 'tm-grid',
- props: {
- black:{
- type:String|Boolean,
- default:null
- },
-
-
- border: {
- type: Boolean,
- default: false
- },
-
- color: {
- type: String,
- default: 'primary'
- },
-
- bgColor: {
- type: String,
- default: ''
- },
- fontColor: {
- type: String,
- default: 'grey-darken-1'
- },
-
- grid: {
- type: Number,
- default: 4
- },
- iconSize: {
- type: Number,
- default: 40
- },
- height: {
- type: Number,
- default: 140
- },
- list: {
- type: Array,
- default: () => {
- return [];
- }
- },
-
- fllowTheme:{
- type:Boolean|String,
- default:true
- },
-
- maxGrid:{
- type:Number,
- default:12
- }
- },
- 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;
- },
- col: function() {
- return isNaN(this.maxGrid / this.grid) ? 4 : this.maxGrid / this.grid;
- },
- listData: function() {
- let gs = this.grid - Math.floor(this.list.length / this.grid);
- return this.list;
- },
- gridNum:function(){
- return this.grid;
- },
- colNum:function(){
- let ts = parseInt(this.listData.length/this.grid);
- ts = this.listData.length/this.grid>ts?ts+1:ts;
- return ts;
- },
- height_s:function(){
- return uni.upx2px(this.height)||70
- }
- },
- data() {
- return {
- hoverClass: ''
- };
- },
- methods: {
- onclick(index, item) {
- this.$emit('change', {
- index: index,
- data: item
- })
- },
- clickDot(index, item) {
- this.$emit('click-dot', {
- index: index,
- data: item
- })
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .tm-grid{
- .tm-grid-icon{
-
-
- }
- }
- </style>
|