SkuRowPropItem.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 _createNamespace = (0, _utils.createNamespace)('sku-row-prop-item'),
  8. createComponent = _createNamespace[0];
  9. var _default = createComponent({
  10. props: {
  11. skuValue: Object,
  12. skuKeyStr: String,
  13. skuEventBus: Object,
  14. selectedProp: Object,
  15. multiple: Boolean,
  16. disabled: Boolean
  17. },
  18. computed: {
  19. choosed: function choosed() {
  20. var selectedProp = this.selectedProp,
  21. skuKeyStr = this.skuKeyStr,
  22. skuValue = this.skuValue;
  23. if (selectedProp && selectedProp[skuKeyStr]) {
  24. return selectedProp[skuKeyStr].indexOf(skuValue.id) > -1;
  25. }
  26. return false;
  27. }
  28. },
  29. methods: {
  30. onSelect: function onSelect() {
  31. if (this.disabled) return;
  32. this.skuEventBus.$emit('sku:propSelect', (0, _extends2.default)({}, this.skuValue, {
  33. skuKeyStr: this.skuKeyStr,
  34. multiple: this.multiple
  35. }));
  36. }
  37. },
  38. render: function render() {
  39. var h = arguments[0];
  40. return h("span", {
  41. "class": ['van-sku-row__item', {
  42. 'van-sku-row__item--active': this.choosed
  43. }, {
  44. 'van-sku-row__item--disabled': this.disabled
  45. }],
  46. "on": {
  47. "click": this.onSelect
  48. }
  49. }, [h("span", {
  50. "class": "van-sku-row__item-name"
  51. }, [this.skuValue.name])]);
  52. }
  53. });
  54. exports.default = _default;