CustomerCard.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template lang="pug">
  2. .customer-card(@click="selectCustomer(item)" v-bind:class="{ 'selected-customer': isSelectedCustomer() }")
  3. h2.customer-name {{ item.name }}
  4. img.customer-photo(:src="this.item.image_medium ? 'data:image/png;base64,' + this.item.image_medium : '/base/static/src/img/avatar.png'")
  5. </template>
  6. <script>
  7. import { mapActions, mapGetters } from 'vuex'
  8. export default {
  9. props: {
  10. item: {
  11. type: Object,
  12. default: () => {
  13. return {}
  14. }
  15. }
  16. },
  17. computed: mapGetters({
  18. selectedCustomer: 'getSelectedCustomer',
  19. hasSelectedCustomer: 'hasSelectedCustomer'
  20. }),
  21. methods: {
  22. isSelectedCustomer() {
  23. return this.hasSelectedCustomer ? this.item.id === this.selectedCustomer.id : false
  24. },
  25. ...mapActions([
  26. 'selectCustomer'
  27. ])
  28. }
  29. }
  30. </script>
  31. <style lang="sass">
  32. .customer-card
  33. width: 130px
  34. height: 160px
  35. margin: 5px
  36. border: 1px solid #d3d3d3
  37. display: inline-block
  38. position: relative
  39. &.selected-customer
  40. transition-duration: 0.3s
  41. border-bottom: 3px solid #7c7bad
  42. &:hover
  43. cursor: pointer
  44. .customer-name
  45. width: 100%
  46. height: 30px
  47. font-size: 9pt
  48. text-align: center
  49. margin-top: 10px
  50. position: absolute
  51. top: 0
  52. .customer-photo
  53. width: 80px
  54. height: 80px
  55. margin: 0
  56. border: none
  57. position: absolute;
  58. top: 50%
  59. left: 50%
  60. margin-right: -50%
  61. transform: translate(-50%, -50%)
  62. </style>