You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

91 regels
1.9 KiB

  1. <template>
  2. <view @click="click" class="tree-item">
  3. <!-- 用户头像 -->
  4. <image
  5. v-if="item.type === 'user'"
  6. class="tree-item-avatar"
  7. :src="avatar"
  8. :style="{ borderRadius: roundAvatar ? '50%' : '3px' }"
  9. mode="aspectFill"
  10. ></image>
  11. <!-- 名称 -->
  12. <text class="tree-item-title">{{ item.name }}</text>
  13. <!-- 用户标签 -->
  14. <l-tag :line="tagColor" size="sm" class="margin-left-sm">{{ tagName }}</l-tag>
  15. <!-- 如果开启选择按钮显示,并且级别符合,则显示按钮 -->
  16. <view v-if="button" class="tree-item-action">
  17. <l-button @click="$emit('buttonClick', item)" line="green" size="sm">选择</l-button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'l-organize-single-item',
  24. props: {
  25. item: {},
  26. button: {}
  27. },
  28. methods: {
  29. // 点击事件
  30. click(e) {
  31. this.$emit('click', e)
  32. }
  33. },
  34. computed: {
  35. // 获取用户头像
  36. avatar() {
  37. if (!Number.isNaN(this.item.img)) {
  38. return Number(this.item.img) === 1 ? '/static/img-avatar/chat-boy.jpg' : '/static/img-avatar/chat-girl.jpg'
  39. }
  40. return this.item.img
  41. },
  42. // 获取树形列表每一项后面 tag 的显示
  43. tagName() {
  44. return { user: '职员', department: '部门', company: '公司' }[this.item.type]
  45. },
  46. // 获取 tag 的颜色
  47. tagColor(item) {
  48. return { company: 'red', department: 'blue', user: 'green' }[this.item.type]
  49. },
  50. // 头像圆形/方形显示参数
  51. roundAvatar() {
  52. return this.CONFIG('pageConfig.roundAvatar')
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="less" scoped>
  58. .tree-item {
  59. background-color: #fff;
  60. display: flex;
  61. min-height: 65rpx;
  62. align-items: center;
  63. .tree-item-avatar {
  64. width: 60rpx;
  65. height: 60rpx;
  66. margin-top: 8rpx;
  67. margin-bottom: 8rpx;
  68. margin-left: 30rpx;
  69. margin-right: 16rpx;
  70. }
  71. .tree-item-action {
  72. position: absolute;
  73. right: 30rpx;
  74. }
  75. }
  76. </style>