<template>
  <a-breadcrumb>
    <a-breadcrumb-item v-for="(bItem, bIndex) in props.record.formItemBreadcrumbList" :key="bIndex">
      <a v-if="bItem.linkUrl" @click="breadcrumbClick(bItem)">{{ bItem.title }}</a>
      <span v-if="!bItem.linkUrl">{{ bItem.title }}</span>
    </a-breadcrumb-item>
  </a-breadcrumb>
</template>

<script setup name="FormBreadcrumb">
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

const props = defineProps({
  record: {
    type: Object,
    default: {}
  },
  //是否禁用
  disabled: {
    type: Boolean,
    default: false
  },
  // 是否只读
  readonly: {
    type: Boolean,
    default: false
  }
});

onMounted(() => {});

// 面包屑点击
const breadcrumbClick = item => {
  if (props.readonly || props.disabled) return;
  const { href } = router.resolve({
    path: item.linkUrl,
  });
  window.open(href, '_blank');
};
</script>

<style scoped lang="less"></style>
