index.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { use } from '../utils';
  2. import Button, { ButtonEvents } from '../button';
  3. import { emit, inherit } from '../utils/functional';
  4. import { functionalRoute, routeProps, RouteProps } from '../utils/router';
  5. // Types
  6. import { CreateElement, RenderContext } from 'vue/types';
  7. import { DefaultSlots } from '../utils/use/sfc';
  8. export type GoodsActionBigBtnProps = RouteProps & {
  9. text?: string;
  10. primary?: boolean;
  11. loading?: boolean;
  12. disabled?: boolean;
  13. };
  14. const [sfc, bem] = use('goods-action-big-btn');
  15. function GoodsActionBigBtn(
  16. h: CreateElement,
  17. props: GoodsActionBigBtnProps,
  18. slots: DefaultSlots,
  19. ctx: RenderContext<GoodsActionBigBtnProps>
  20. ) {
  21. const onClick = (event: Event) => {
  22. emit(ctx, 'click', event);
  23. functionalRoute(ctx);
  24. };
  25. return (
  26. <Button
  27. square
  28. class={bem()}
  29. size="large"
  30. loading={props.loading}
  31. disabled={props.disabled}
  32. type={props.primary ? 'danger' : 'warning'}
  33. onClick={onClick}
  34. {...inherit(ctx)}
  35. >
  36. {slots.default ? slots.default() : props.text}
  37. </Button>
  38. );
  39. }
  40. GoodsActionBigBtn.props = {
  41. ...routeProps,
  42. text: String,
  43. primary: Boolean,
  44. loading: Boolean,
  45. disabled: Boolean
  46. };
  47. export default sfc<GoodsActionBigBtnProps, ButtonEvents>(GoodsActionBigBtn);