<script setup lang="ts">
import { IActionParam, IParam, deepCopy, ILayoutOpts } from '@core';
interface IProps {
  name: string;
  tooltip: string;
  caption?: string;
  visible?: boolean;
  showCaption?: boolean;
  disabled?: boolean;
  uIAction: IParam;
  layoutOpts: ILayoutOpts;
}
const props = withDefaults(defineProps<IProps>(), {
  visible: true,
  showCaption: true,
  disabled: false
});

interface EmitEvents {
  (name: 'onPanelItemEvents', value: IActionParam): void
}
const emit = defineEmits<EmitEvents>();

//  按钮点击
const click = (event: MouseEvent) => {
  const params = deepCopy(props.uIAction);
  Object.assign(params, { event: event });
  emit('onPanelItemEvents', { tag: props.name, action: 'PanelButton', data: params });
}
</script>

<template>
  <AppCol :visible="visible" :layoutOpts="layoutOpts">
    <a-button type="primary" :disabled="disabled" @click.stop="click" block>
      <slot></slot>
    </a-button>
  </AppCol>
</template>