Item.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = void 0;
  5. var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));
  6. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  7. var _utils = require("../utils");
  8. var _functional = require("../utils/functional");
  9. var _tag = _interopRequireDefault(require("../tag"));
  10. var _icon = _interopRequireDefault(require("../icon"));
  11. var _cell = _interopRequireDefault(require("../cell"));
  12. var _radio = _interopRequireDefault(require("../radio"));
  13. // Utils
  14. // Components
  15. var _createNamespace = (0, _utils.createNamespace)('address-item'),
  16. createComponent = _createNamespace[0],
  17. bem = _createNamespace[1];
  18. function AddressItem(h, props, slots, ctx) {
  19. var disabled = props.disabled,
  20. switchable = props.switchable;
  21. function onClick() {
  22. if (switchable) {
  23. (0, _functional.emit)(ctx, 'select');
  24. }
  25. (0, _functional.emit)(ctx, 'click');
  26. }
  27. var genRightIcon = function genRightIcon() {
  28. return h(_icon.default, {
  29. "attrs": {
  30. "name": "edit"
  31. },
  32. "class": bem('edit'),
  33. "on": {
  34. "click": function click(event) {
  35. event.stopPropagation();
  36. (0, _functional.emit)(ctx, 'edit');
  37. (0, _functional.emit)(ctx, 'click');
  38. }
  39. }
  40. });
  41. };
  42. function genTag() {
  43. if (slots.tag) {
  44. return slots.tag((0, _extends2.default)({}, props.data));
  45. }
  46. if (props.data.isDefault && props.defaultTagText) {
  47. return h(_tag.default, {
  48. "attrs": {
  49. "type": "danger",
  50. "round": true
  51. },
  52. "class": bem('tag')
  53. }, [props.defaultTagText]);
  54. }
  55. }
  56. function genContent() {
  57. var data = props.data;
  58. var Info = [h("div", {
  59. "class": bem('name')
  60. }, [data.name + " " + data.tel, genTag()]), h("div", {
  61. "class": bem('address')
  62. }, [data.address])];
  63. if (switchable && !disabled) {
  64. return h(_radio.default, {
  65. "attrs": {
  66. "name": data.id,
  67. "iconSize": 18
  68. }
  69. }, [Info]);
  70. }
  71. return Info;
  72. }
  73. return h("div", {
  74. "class": bem({
  75. disabled: disabled
  76. }),
  77. "on": {
  78. "click": onClick
  79. }
  80. }, [h(_cell.default, (0, _babelHelperVueJsxMergeProps.default)([{
  81. "attrs": {
  82. "border": false,
  83. "valueClass": bem('value')
  84. },
  85. "scopedSlots": {
  86. default: genContent,
  87. 'right-icon': genRightIcon
  88. }
  89. }, (0, _functional.inherit)(ctx)])), slots.bottom == null ? void 0 : slots.bottom((0, _extends2.default)({}, props.data, {
  90. disabled: disabled
  91. }))]);
  92. }
  93. AddressItem.props = {
  94. data: Object,
  95. disabled: Boolean,
  96. switchable: Boolean,
  97. defaultTagText: String
  98. };
  99. var _default = createComponent(AddressItem);
  100. exports.default = _default;