index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { createNamespace } from '../utils';
  3. import { route, routeProps } from '../utils/router';
  4. import { ChildrenMixin } from '../mixins/relation';
  5. import Button from '../button';
  6. var _createNamespace = createNamespace('goods-action-button'),
  7. createComponent = _createNamespace[0],
  8. bem = _createNamespace[1];
  9. export default createComponent({
  10. mixins: [ChildrenMixin('vanGoodsAction')],
  11. props: _extends({}, routeProps, {
  12. type: String,
  13. text: String,
  14. icon: String,
  15. color: String,
  16. loading: Boolean,
  17. disabled: Boolean
  18. }),
  19. computed: {
  20. isFirst: function isFirst() {
  21. var prev = this.parent && this.parent.children[this.index - 1];
  22. return !prev || prev.$options.name !== this.$options.name;
  23. },
  24. isLast: function isLast() {
  25. var next = this.parent && this.parent.children[this.index + 1];
  26. return !next || next.$options.name !== this.$options.name;
  27. }
  28. },
  29. methods: {
  30. onClick: function onClick(event) {
  31. this.$emit('click', event);
  32. route(this.$router, this);
  33. }
  34. },
  35. render: function render() {
  36. var h = arguments[0];
  37. return h(Button, {
  38. "class": bem([{
  39. first: this.isFirst,
  40. last: this.isLast
  41. }, this.type]),
  42. "attrs": {
  43. "size": "large",
  44. "type": this.type,
  45. "icon": this.icon,
  46. "color": this.color,
  47. "loading": this.loading,
  48. "disabled": this.disabled
  49. },
  50. "on": {
  51. "click": this.onClick
  52. }
  53. }, [this.slots() || this.text]);
  54. }
  55. });