RelatedBusiness.vue 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div
  3. :style="{'margin-left': marginLeft}"
  4. class="related-business">
  5. <!-- 新建- 相关信息 -->
  6. <el-popover
  7. v-if="showAdd"
  8. v-model="showPopover"
  9. placement="right-end"
  10. width="800"
  11. popper-class="no-padding-popover"
  12. trigger="click">
  13. <crm-relative
  14. v-if="showRelative"
  15. ref="crmrelative"
  16. :show="showPopover"
  17. :radio="false"
  18. :selected-data="relatedListData"
  19. :show-types="showTypes"
  20. @close="crmrelativeClose"
  21. @changeCheckout="checkInfos"/>
  22. <span
  23. v-if="showCRMPermission" slot="reference"
  24. class="add-btn" @click="showRelative = true">
  25. <i class="wk wk-l-plus" />
  26. <span class="label">关联业务</span>
  27. </span>
  28. </el-popover>
  29. <div
  30. v-for="(items, key) in relatedListData"
  31. :key="key"
  32. style="margin-top: 10px;">
  33. <related-business-cell
  34. v-for="(item, itemIndex) in items"
  35. :data="item"
  36. :cell-index="itemIndex"
  37. :type="key"
  38. :key="itemIndex"
  39. :show-foot="showFoot"
  40. @unbind="delRelevance"
  41. @detail="checkRelatedDetail(key, item)"/>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. // 相关信息 - 弹出框
  47. import CrmRelative from '@/components/CreateCom/CrmRelative'
  48. import RelatedBusinessCell from '@/views/oa/components/RelatedBusinessCell'
  49. import { mapGetters } from 'vuex'
  50. export default {
  51. name: 'RelatedBusiness',
  52. components: {
  53. CrmRelative,
  54. RelatedBusinessCell
  55. },
  56. props: {
  57. marginLeft: {
  58. type: String,
  59. default: '20px'
  60. },
  61. // 编辑时传递所有关联数据 关联联系人-contacts 关联客户-customer 商机-business 合同-contract
  62. allData: {
  63. type: Object,
  64. default: () => {
  65. return {
  66. contacts: [],
  67. customer: [],
  68. business: [],
  69. contract: []
  70. }
  71. }
  72. },
  73. // 展示取消关联
  74. showFoot: {
  75. type: Boolean,
  76. default: true
  77. },
  78. showAdd: {
  79. type: Boolean,
  80. default: true
  81. }
  82. },
  83. data() {
  84. return {
  85. showTypes: ['customer', 'contacts', 'business', 'contract'],
  86. showPopover: false,
  87. relevanceAll: {
  88. customerIds: [],
  89. contractIds: [],
  90. contactsIds: [],
  91. businessIds: []
  92. },
  93. // 相关信息信息
  94. relatedListData: {},
  95. showRelative: false
  96. }
  97. },
  98. computed: {
  99. ...mapGetters(['crm']),
  100. showCRMPermission() {
  101. return this.crm
  102. }
  103. },
  104. watch: {
  105. allData: function() {
  106. this.relatedListData = this.allData
  107. }
  108. },
  109. mounted() {
  110. // 编辑时勾选
  111. this.relatedListData = this.allData
  112. },
  113. methods: {
  114. crmrelativeClose() {
  115. this.showPopover = false
  116. },
  117. checkInfos(val) {
  118. this.showPopover = false
  119. this.relatedListData = val.data
  120. for (const key in val.data) {
  121. const list = val.data[key]
  122. this.relevanceAll[key + 'Ids'] = list.map(item => item[key + '_id'])
  123. }
  124. this.$emit('checkInfos', this.relevanceAll, val.data)
  125. },
  126. // 任务页面取消关联
  127. delRelevance(field, index, item) {
  128. this.$emit('unbind', field, item, index)
  129. },
  130. checkRelatedDetail(field, val) {
  131. val.key = val[field + 'Id'] || val.id
  132. this.$emit('checkRelatedDetail', field, val)
  133. }
  134. }
  135. }
  136. </script>
  137. <style scoped lang="scss">
  138. .related-business {
  139. color: #777;
  140. font-size: 12px;
  141. margin: 10px 0;
  142. }
  143. // 添加btm
  144. $btn-b-color: #f8faff;
  145. $btn-color: #333333;
  146. $btn-b-hover-color: #eff4ff;
  147. .add-btn {
  148. margin-top: 8px;
  149. font-size: 12px;
  150. color: $btn-color;
  151. background-color: $btn-b-color;
  152. border-radius: $xr-border-radius-base;
  153. display: inline-block;
  154. padding: 3px 10px;
  155. cursor: pointer;
  156. .wk-l-plus {
  157. font-size: 12px;
  158. }
  159. }
  160. .add-btn:hover {
  161. color: $xr-color-primary;
  162. background-color: $btn-b-hover-color;
  163. }
  164. </style>