<template>
	<div>
		<Button v-for="(action,index) in actions"  v-if="isRender(action)" :loading="action.loading" :type="action.type" :style="styleCss" :disabled="action.disabled?true:(action.notDisabled?!action.notDisabled:disabled)" :size="size" 
			:class="index==activeIndex?'active':''"	:icon="action.icon" @click='click(action.action,data,index,action)'>
			{{action.label}}
		</Button>
	</div>
</template>


<script lang="ts">
import { Component, Prop, Vue, Emit } from "vue-property-decorator";
import { State } from "vuex-class";
@Component
export default class CsButton extends Vue {
  @Prop(Array) actions ! : Array<any>;
  @Prop(String) styleCss !:string;
  @Prop(String) size !:string;
  @Prop(Function) click !:Function;
  @Prop(Boolean) disabled !: boolean;
  @Prop() data ! : any;
  @Prop(Number) activeIndex ! : number;
  @State isAdministrator!: boolean;

  isRender(obj){
    if(_.has(obj,'access')){
      return obj.access;
    }
    if(obj.isAdmin){
      return this.isAdministrator;
    }
    return true;
  }
}
</script>
