<template>
  <el-tag
    v-if="type === 'tag'"
    type="primary"
    @click="handleClick"
    :style="{cursor: id == null ? 'not-allow' : 'pointer'}"
  >
    {{text | defaultValue}}
  </el-tag>
  <el-link v-else type="primary" @click="handleClick" :disabled="id == null">{{text | defaultValue}}</el-link>
</template>

<script>
export default {
  name: 'BaseLink',
  props: {
    id: {
      type: String,
      default: null
    },
    text: {
      type: String,
      default: null,
    },
    query: {
      type: Object,
      default: () =>{
        return {}
      }
    },
    path: {
      type: String,
      default: null,
    },
    // 类型
    type: {
      type: String,
      default: 'link'
    }
  },
  methods: {
    handleClick() {
      this.$router.push({path: this.path, query: this.query})
    }
  }
}
</script>
