zjf
2023-02-24 3f9bad03f4fbca2d5c5be86e904ae832475634d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<template>
  <div>
    <el-popover
      v-model="showPopover"
      placement="bottom"
      width="800"
      popper-class="no-padding-popover"
      trigger="click">
      <crm-relative
        v-if="showRelative"
        ref="crmrelative"
        :radio="false"
        :selected-data="selectedData"
        :show-types="showTypes"
        @close="crmrelativeClose"
        @changeCheckout="checkInfos"/>
      <p
        slot="reference"
        class="add-file"
        @click="showRelative = true">
        <img
          src="@/assets/img/relevance_business.png"
          alt="">
        关联业务
      </p>
    </el-popover>
    <div class="related-business">
      <div
        v-for="(items, key) in selectedData"
        :key="key">
        <related-business-cell
          v-for="(item, itemIndex) in items"
          :data="item"
          :cell-index="itemIndex"
          :type="key"
          :key="itemIndex"
          :cursor-pointer="false"
          @unbind="delRelevance"/>
      </div>
    </div>
  </div>
</template>
<script type="text/javascript">
import CrmRelative from '@/components/CreateCom/CrmRelative'
import RelatedBusinessCell from '@/views/OAManagement/components/relatedBusinessCell'
import { objDeepCopy } from '@/utils'
 
export default {
  name: 'RelatedBusiness', // 关联业务
  components: {
    CrmRelative,
    RelatedBusinessCell
  },
  props: {
    /** 已选信息 */
    selectedInfos: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data () {
    return {
      showTypes: ['customer', 'contacts', 'business', 'contract'],
      // 业务弹窗
      showRelative: false,
      showPopover: false,
      // 编辑时勾选
      selectedData: {}
    }
  },
  computed: {},
  watch: {
    selectedInfos: function (data) {
      this.selectedData = data
    }
  },
  mounted () {},
  methods: {
    delRelevance (field, index) {
      this.$confirm('确认取消关联?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        customClass: 'is-particulars'
      })
        .then(() => {
          this.selectedData[field].splice(index, 1)
          this.selectedData = objDeepCopy(this.selectedData)
          this.submitValueChange()
        })
        .catch(() => {
          this.$message.info('已取消操作')
        })
    },
    getTypeName (type) {
      if (type === 'customer') {
        return '客户'
      } else if (type === 'contacts') {
        return '联系人'
      } else if (type === 'business') {
        return '商机'
      } else if (type === 'contract') {
        return '合同'
      }
    },
    crmrelativeClose () {
      this.showPopover = false
    },
    checkInfos (val) {
      this.showPopover = false
      this.selectedData = val.data
      this.submitValueChange()
    },
    submitValueChange () {
      this.$emit('value-change', {
        index: this.index,
        value: this.selectedData
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.add-file {
  margin: 5px 0;
  font-size: 13px;
  color: #4D88FF;
  cursor: pointer;
  display: inline-block;
  img {
    vertical-align: middle;
    width: 15px;
  }
}
 
.related-business {
  margin-top: 10px;
}
</style>