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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<template>
  <div
    v-empty="!canShowIndex"
    class="container"
    xs-empty-icon="nopermission"
    xs-empty-text="暂无权限">
    <flexbox class="header">
      <div class="name">{{ data.row.customerName }}</div>
      <div class="detail">商机({{ list.length }})</div>
      <img
        class="close"
        src="@/assets/img/task_close.png"
        @click="hidenView" >
    </flexbox>
    <el-table
      v-loading="loading"
      :data="list"
      :cell-style="cellStyle"
      :header-cell-style="headerCellStyle"
      height="250"
      style="margin-right:3px;"
      highlight-current-row
      @row-click="handleRowClick">
      <el-table-column
        v-for="(item, index) in fieldList"
        :key="index"
        :prop="item.prop"
        :label="item.label"
        align="center"
        header-align="center"
        show-overflow-tooltip/>
    </el-table>
  </div>
</template>
 
<script>
import { mapGetters } from 'vuex'
// import { crmCustomerQueryBusiness } from '@/api/customermanagement/customerManage'
 
export default {
  /** 客户管理 的 客户列表  相关商机列表 */
  name: 'BusinessCheck',
  components: {},
  props: {
    show: Boolean,
    data: {
      type: Object,
      default: () => {
        return {
          row: {
            name: ''
          }
        }
      }
    }
  },
  data () {
    return {
      loading: false,
      list: [],
      fieldList: []
    }
  },
  computed: {
    ...mapGetters(['crm']),
    canShowIndex () {
      // return this.crm.business && this.crm.business.index
      return 2
    }
  },
  watch: {
    show: {
      handler (val) {
        if (
          this.canShowIndex &&
          val &&
          this.data.row &&
          this.data.row.businessCount > 0 &&
          this.list.length === 0
        ) {
          this.getDetail()
        }
      },
      deep: true,
      immediate: true
    }
  },
  mounted () {
    this.fieldList.push({
      prop: 'businessName',
      width: '200',
      label: '商机名称'
    })
    this.fieldList.push({
      prop: 'money',
      width: '200',
      label: '商机金额'
    })
    this.fieldList.push({
      prop: 'customerName',
      width: '200',
      label: '客户名称'
    })
    this.fieldList.push({ prop: 'typeName', width: '200', label: '商机状态组' })
    this.fieldList.push({ prop: 'statusName', width: '200', label: '状态' })
  },
  methods: {
    getDetail () {
      this.loading = true
      // crmCustomerQueryBusiness({
      //   pageType: 0,
      //   customerId: this.data.row.customerId
      // })
      //   .then(res => {
      //     this.loading = false
      //     this.list = res.data
      //   })
      //   .catch(() => {
      //     this.loading = false
      //   })
    },
    hidenView () {
      document.querySelector('#app').click()
      this.$emit('close', this.$el, this.data)
    },
    // 当某一行被点击时会触发该事件
    handleRowClick (row, column, event) {
      this.$emit('click', row)
    },
    /** 通过回调控制style */
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      return { fontSize: '12px', textAlign: 'center', cursor: 'pointer' }
    },
    headerCellStyle ({ row, column, rowIndex, columnIndex }) {
      return { fontSize: '12px', textAlign: 'center' }
    }
  }
}
</script>
 
<style lang="scss" scoped>
.container {
  position: relative;
}
 
.header {
  height: 40px;
  padding: 0 10px;
  flex-shrink: 0;
  .name {
    font-size: 13px;
    padding: 0 10px;
    color: #333;
  }
  .detail {
    font-size: 12px;
    padding: 0 10px;
    color: #aaaaaa;
    border-left: 1px solid #aaaaaa;
  }
  .close {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 0;
    right: 10px;
    padding: 10px;
  }
}
</style>