Item.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. import { use } from '../utils';
  3. import { emit, inherit } from '../utils/functional';
  4. import Icon from '../icon';
  5. import Cell from '../cell';
  6. import Radio from '../radio'; // Types
  7. var _use = use('address-item'),
  8. sfc = _use[0],
  9. bem = _use[1];
  10. function AddressItem(h, props, slots, ctx) {
  11. var disabled = props.disabled,
  12. switchable = props.switchable;
  13. var onSelect = function onSelect() {
  14. if (props.switchable) {
  15. emit(ctx, 'select');
  16. }
  17. };
  18. var renderRightIcon = function renderRightIcon() {
  19. return h(Icon, {
  20. "attrs": {
  21. "name": "edit"
  22. },
  23. "class": bem('edit'),
  24. "on": {
  25. "click": function click(event) {
  26. event.stopPropagation();
  27. emit(ctx, 'edit');
  28. }
  29. }
  30. });
  31. };
  32. var renderContent = function renderContent() {
  33. var data = props.data;
  34. var Info = [h("div", {
  35. "class": bem('name')
  36. }, [data.name + "\uFF0C" + data.tel]), h("div", {
  37. "class": bem('address')
  38. }, [data.address])];
  39. return props.switchable ? h(Radio, {
  40. "attrs": {
  41. "name": data.id
  42. },
  43. "on": {
  44. "click": onSelect
  45. }
  46. }, [Info]) : Info;
  47. };
  48. return h(Cell, _mergeJSXProps([{
  49. "class": bem({
  50. disabled: disabled,
  51. unswitchable: !switchable
  52. }),
  53. "attrs": {
  54. "valueClass": bem('value'),
  55. "isLink": !disabled && switchable
  56. },
  57. "scopedSlots": {
  58. "default": renderContent,
  59. 'right-icon': renderRightIcon
  60. },
  61. "on": {
  62. "click": onSelect
  63. }
  64. }, inherit(ctx)]));
  65. }
  66. AddressItem.props = {
  67. data: Object,
  68. disabled: Boolean,
  69. switchable: Boolean
  70. };
  71. export default sfc(AddressItem);