zjf
2023-03-03 bafa9dff4d9880c562f4d3a7b83bd4c1129240c5
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
  <div
    v-show="visible"
    class="full-container">
    <component
      v-if="id&&showDetail"
      :is="tabName"
      :crm-type="crmType"
      :id="id"
      class="d-view"
      @handle="detailHandle"
      @hide-view="hiddenView"/>
  </div>
</template>
 
<script type="text/javascript">
import { getMaxIndex } from '@/utils/index'
import ClueDetail from '../clue/ClueDetail'
import CustomerDetail from '../customer/CustomerDetail'
import ContactsDetail from '../contacts/ContactsDetail'
import BusinessDetail from '../business/BusinessDetail'
import BusinessCustomerDetail from '../businessCustomer/BusinessCustomerDetail'
import BusinessChancesDetail from '../businessChances/BusinessChancesDetail'
// import ContractDetail from '../contract/ContractDetail'
// import ProductDetail from '../product/ProductDetail'
// import MoneyDetail from '../money/MoneyDetail'
// import ExamineDetail from '@/views/OAManagement/examine/components/examineDetail'
 
export default {
  name: 'CRMFullScreenDetail', // 客户管理下 重要提醒 回款计划提醒
  components: {
    ClueDetail,
    CustomerDetail,
    ContactsDetail,
    BusinessDetail,
    BusinessCustomerDetail,
    BusinessChancesDetail
    // ContractDetail,
    // ProductDetail,
    // MoneyDetail,
    // ExamineDetail
  },
  props: {
    /** 模块ID */
    id: [String, Number],
    /** 没有值就是全部类型 有值就是当个类型 */
    crmType: {
      type: String,
      default: ''
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      showDetail: false
    }
  },
  computed: {
    tabName () {
      if (this.crmType === 'leads') {
        return 'clue-detail'
      } else if (this.crmType === 'customer') {
        return 'customer-detail'
      } else if (this.crmType === 'contacts') {
        return 'contacts-detail'
      } else if (this.crmType === 'business') {
        return 'business-detail'
      } else if (this.crmType === 'contract') {
        return 'contract-detail'
      } else if (this.crmType === 'product') {
        return 'product-detail'
      } else if (this.crmType === 'receivables') {
        return 'money-detail'
      } else if (this.crmType === 'examine') {
        return 'examine-detail'
      } else if (this.crmType === 'businessCustomer') {
        return 'business-customer-detail'
      } else if (this.crmType === 'businessChances') {
        return 'business-chances-detail'
      }
      return ''
    }
  },
  watch: {
    visible (val) {
      this.showDetail = val
      if (val) {
        document.body.appendChild(this.$el)
        this.$el.addEventListener('click', this.handleDocumentClick, false)
        this.$el.style.zIndex = getMaxIndex()
      }
    },
    showDetail (val) {
      if (!val) {
        setTimeout(() => {
          this.$emit('update:visible', false)
        }, 350)
      }
    }
  },
  mounted () {
    if (this.visible) {
      document.body.appendChild(this.$el)
      this.$el.addEventListener('click', this.handleDocumentClick, false)
      this.$el.style.zIndex = getMaxIndex()
    }
  },
 
  beforeDestroy () {
    // remove DOM node after destroy
    if (this.$el && this.$el.parentNode) {
      this.$el.parentNode.removeChild(this.$el)
      this.$el.removeEventListener('click', this.handleDocumentClick, false)
    }
  },
  methods: {
    hiddenView () {
      this.showDetail = false
    },
    handleDocumentClick (e) {
      e.stopPropagation()
      if (this.$el === e.target) {
        this.showDetail = false
      }
    },
 
    /**
     * 详情操作
     */
    detailHandle (data) {
      if (data.type === 'alloc' || data.type === 'get' || data.type === 'transfer' || data.type === 'transform' || data.type === 'delete' || data.type === 'put_seas') {
        this.showDetail = false
      }
      this.$emit('handle', data)
    }
  }
}
</script>
<style lang="scss" scoped>
.full-container {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: auto;
  margin: 0;
  background-color: rgba(0, 0, 0, 0.3);
}
 
.d-view {
  position: fixed;
  width: 1000px;
  top: 0px;
  bottom: 0px;
  right: 0px;
}
</style>