relevance-section.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="relevance">
  3. <view v-if="!isAdd" class="relevance-title">
  4. 关联业务
  5. </view>
  6. <template v-for="key in optionsKeys">
  7. <view
  8. v-if="relevanceData[key] && relevanceData[key].length > 0"
  9. :key="key"
  10. class="relevance-content">
  11. <view
  12. v-for="(item, index) in relevanceData[key]"
  13. :key="index"
  14. class="relevance-box"
  15. @click.stop="handlerTo(key, item)">
  16. <image
  17. :src="options[key].icon"
  18. alt=""
  19. class="type-icon" />
  20. <text class="text">
  21. {{ options[key].label }} - {{ item[options[key].key] || item.name || '' }}
  22. </text>
  23. <text
  24. v-if="isAdd"
  25. class="wk wk-close delete-icon"
  26. @click.stop="$emit('delete', options[key].type, index)" />
  27. </view>
  28. </view>
  29. </template>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'RelevanceSection',
  35. props: {
  36. relevanceData: {
  37. type: Object,
  38. default: () => {}
  39. },
  40. isAdd: {
  41. type: Boolean,
  42. default: false
  43. }
  44. },
  45. data() {
  46. return {
  47. options: {
  48. customerList: {
  49. label: '客户',
  50. type: 'customer',
  51. key: 'customerName',
  52. icon: this.$static('images/relevance/customer.png')
  53. },
  54. contactsList: {
  55. label: '联系人',
  56. type: 'contacts',
  57. key: 'contactsName',
  58. icon: this.$static('images/relevance/contacts.png')
  59. },
  60. businessList: {
  61. label: '商机',
  62. type: 'business',
  63. key: 'businessName',
  64. icon: this.$static('images/relevance/business.png')
  65. },
  66. contractList: {
  67. label: '合同',
  68. type: 'contract',
  69. key: 'name',
  70. icon: this.$static('images/relevance/customer.png')
  71. },
  72. }
  73. }
  74. },
  75. computed: {
  76. optionsKeys() {
  77. return Object.keys(this.options)
  78. }
  79. },
  80. methods: {
  81. handlerTo(key, item) {
  82. const map = {
  83. customerList: {url: '/pages_crm/customer/detail', key: 'customerId'},
  84. contactsList: {url: '/pages_crm/contacts/detail', key: 'contactsId'},
  85. businessList: {url: '/pages_crm/business/detail', key: 'businessId'},
  86. contractList: {url: '/pages_crm/contract/detail', key: 'contractId'},
  87. }
  88. let obj = map[key]
  89. this.$Router.navigateTo({
  90. url: obj.url,
  91. query: {
  92. id: item[obj.key] || item.id
  93. }
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. .relevance {
  101. margin: 30rpx 0;
  102. .relevance-title {
  103. font-size: 26rpx;
  104. color: $dark;
  105. margin-bottom: 10rpx;
  106. }
  107. .relevance-content {
  108. margin-bottom: 30rpx;
  109. .relevance-box {
  110. width: 100%;
  111. background-color: #F5F5F5;
  112. border-radius: 5rpx;
  113. display: flex;
  114. padding: 10rpx 20rpx;
  115. margin-bottom: 15rpx;
  116. @include left;
  117. .type-icon {
  118. width: 36rpx;
  119. height: 36rpx;
  120. margin-right: 15rpx;
  121. }
  122. .text {
  123. flex: 1;
  124. font-size: $wk-font-sm;
  125. color: $theme-color;
  126. @include ellipsis;
  127. }
  128. .delete-icon {
  129. font-size: $wk-font-base;
  130. font-weight: bold;
  131. color: $light;
  132. }
  133. }
  134. }
  135. }
  136. </style>