index.js 1.8 KB

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