<script lang="ts" setup>
/**
 * 总仓售价列：已入库可点开调价；未入库提示并可触发入库
 */
defineProps<{
  row: Record<string, any>;
}>();

const emit = defineEmits<{
  adjust: [row: Record<string, any>];
  stockIn: [row: Record<string, any>];
}>();

function formatPrice(v: unknown) {
  const n = Number(v);
  if (!(n >= 0) || Number.isNaN(n)) return '-';
  return `￥${n.toFixed(2)}`;
}
</script>
<template>
  <div>
    <a
      v-if="row.in_central_warehouse"
      class="text-primary cursor-pointer hover:underline"
      @click.stop="emit('adjust', row)"
    >
      {{ formatPrice(row.central_price) }}
    </a>
    <a
      v-else
      class="cursor-pointer"
      style="color: hsl(var(--muted-foreground))"
      @click.stop="emit('stockIn', row)"
    >
      未入库
    </a>
  </div>
</template>
