gjj
2023-02-07 de2588137749cc83dc0df2377a6c2e38074be91a
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<template>
  <div class="cr-contianer">
      <div class="title" v-show="!isProduct">{{ getTitle() }}
        <img
          class="t-close"
          src="@/assets/img/close.png"
          @click="closeView" >
      </div>
    <div style="height: 100%;position: relative;">
      <div
        v-if="crmType === 'product'"
        class="cr-body-side">
        <el-tree
          ref="tree"
          :data="treeData"
          :expand-on-click-node="false"
          node-key="TypeName"
          :props="defaultProps"
          highlight-current
          @node-click="changeDepClick">
          <flexbox
            slot-scope="{ node, data }"
            class="node-data">
            <el-tooltip :content="data.TypeName" placement="top">
              <div class="node-label">{{ data.TypeName }}</div>
            </el-tooltip>
          </flexbox>
        </el-tree>
        <!--<div
          v-for="(item, index) in leftSides"
          :key="index"
          :class="leftType===item.type? 'side-item-select' : 'side-item-default'"
          class="side-item"
          @click="sideClick(item)">{{ item.name }}</div>-->
      </div>
      <div :style="{ 'padding-left': crmType === 'product' ? '220px' : '0'}">
        <crm-relative-table
          v-for="(item, index) in leftSides"
          v-show="item.type === leftType"
          :isProduct="isProduct"
          :key="index"
          :ref="'crm'+item.type"
          :show="show && item.type === leftType"
          :radio="radio"
          :crm-type="item.type"
          :selected-data="currentSelectedData"
          :action="action"
          @closeView="closeView"
          @changeCheckout="checkCrmTypeInfos"/>
 
          <!--<div class="handle-bar">
            <el-button @click="closeView">取消</el-button>
            <el-button
              type="primary"
              @click="confirmClick">确定</el-button>
          </div>-->
      </div>
    </div>
  </div>
</template>
 
<script type="text/javascript">
import { GetAutoProductTypeList } from '@/api/customermanagement/product'
import CrmRelativeTable from './CrmRelativeTable'
import { objDeepCopy } from '@/utils'
 
export default {
  name: 'CrmRelatieve', // 相关
  components: {
    CrmRelativeTable
  },
  props: {
    /** 多选框 只能选一个 */
    radio: {
      type: Boolean,
      default: true
    },
    isProduct: {
      type: Boolean,
      default: true
    },
    /** 没有值就是全部类型 有值就是当个类型 */
    crmType: {
      type: String,
      default: ''
    },
    /** 需要展示哪些类型 默认关键字数组 */
    showTypes: {
      type: Array,
      default: () => {
        return [
          'customer',
          'contacts',
          'leads',
          'business',
          'contract',
          'product'
        ]
      }
    },
    /** 已选信息 */
    selectedData: {
      type: Object,
      default: () => {
        return {}
      }
    },
    /** true 的时候 发请求 */
    show: {
      type: Boolean,
      default: true
    },
    /**
     * default 默认  condition 固定条件筛选 moduleType 下的
     * relative: 相关 添加
     */
    action: {
      type: Object,
      default: () => {
        return {
          type: 'default',
          data: {}
        }
      }
    }
  },
  data () {
    return {
      leftType: 'customer',
      leftSides: [],
      treeData: [],
      /** 各类型选择的值 */
      currentSelectedData: {},
      defaultProps: {
        children: 'ProductResultList',
        label: 'TypeName'
      }
    }
  },
  computed: {},
  watch: {
    selectedData: function (data) {
      this.currentSelectedData = objDeepCopy(data)
    },
    // 刷新标记
    show (val) {
      if (val) {
        this.currentSelectedData = objDeepCopy(this.selectedData)
      }
    }
  },
  mounted () {
    var leftItems = {
      customer: {
        name: '客户',
        type: 'customer'
      },
      contacts: {
        name: '联系人',
        type: 'contacts'
      },
      leads: {
        name: '线索',
        type: 'leads'
      },
      business: {
        name: '商机',
        type: 'business'
      },
      contract: {
        name: '合同',
        type: 'contract'
      },
      product: {
        name: '产品',
        type: 'product'
      }
    }
    if (this.crmType) {
      this.leftType = this.crmType
      this.leftSides.push(leftItems[this.crmType])
    } else {
      for (let index = 0; index < this.showTypes.length; index++) {
        const element = this.showTypes[index]
        this.leftSides.push(leftItems[element])
      }
    }
    this.currentSelectedData = objDeepCopy(this.selectedData)
    this.getTreeList()
  },
  methods: {
    /**
     * 刷新列表
     */
    refreshList () {
      this.$refs['crm' + this.crmType][0].refreshList()
    },
    getTreeList () {
      GetAutoProductTypeList().then(res => {
        console.log(res)
        if (res.data.ErrorCode === 200) {
          this.treeData = res.data.Result || []
        }
      })
    },
    changeDepClick (data) {
      console.log(data)
      this.$refs['crm' + this.crmType][0].getFieldList(data.ParameterLink)
    },
    sideClick (item) {
      this.leftType = item.type
    },
    clearAll () {
      if (this.crmType) {
        this.$refs['crm' + this.crmType][0].clearAll()
      }
    },
    // 当用户手动勾选全选 Checkbox 时触发的事件
    selectAll () {},
    // 关闭操作
    closeView () {
      this.$emit('close')
    },
    checkCrmTypeInfos (data) {
      this.currentSelectedData[data.type] = data.data
      if (this.crmType) {
        // 以单类型传值
        this.$emit('changeVal', this.currentSelectedData[this.crmType])
      } else {
        this.$emit('changeVal', this.currentSelectedData)
      }
 
      this.$emit('close')
    },
    // 根据类型获取标题展示名称
    getTitle () {
      if (this.crmType === 'leads') {
        return '关联线索'
      } else if (this.crmType === 'customer') {
        return '关联客户'
      } else if (this.crmType === 'contacts') {
        return '关联联系人'
      } else if (this.crmType === 'business') {
        return '关联商机'
      } else if (this.crmType === 'product') {
        return '关联产品'
      } else if (this.crmType === 'contract') {
        return '关联合同'
      } else {
        return '关联业务'
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.cr-contianer {
  // height: 600px;
  position: relative;
  // padding: 50px 0 50px 0;
}
 
.title {
  padding: 0 30px;
  font-size: 16px;
  line-height: 50px;
  font-weight: 550;
  color: #333333;
  height: 50px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  // border-bottom: 1px solid #e6e6e6;
  .t-close{
    position: absolute;
    right: 30px;
    top: 12px;
    cursor: pointer;
  }
}
 
.handle-bar {
  height: 50px;
  // position: absolute;
  // bottom: 0;
  // left: 0;
  // right: 40%;
  z-index: 2;
  display: flex;
  align-items: center;
  align-content: center;
  justify-content: center;
  width: 100%;
  button {
    float: right;
    margin-top: 10px;
    margin-right: 10px;
  }
}
 
.cr-body-side {
  flex-shrink: 0;
  z-index: 3;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 220px;
  font-size: 12px;
  background-color: #F8F8F8;
  border-right: 1px solid #e6e6e6;
  height: 650px;
  overflow: auto;
  /deep/ .el-tree{
    background-color: #F8F8F8;
  }
  .side-item {
    height: 35px;
    line-height: 35px;
    padding: 0 20px;
    cursor: pointer;
  }
}
 
.side-item-default {
  color: #333;
}
 
.side-item-select {
  color: #409eff;
  background-color: #ecf5ff;
}
.el-dialog /deep/ .el-dialog__headerbtn{
  padding: 10px;
}
// tree
.el-tree /deep/ .el-tree-node__content {
  height: 30px;
   &:hover{
    color: #4D88FF;
    background-color: #EBF1FF;
  }
  .node-data {
    .node-label {
      margin-right: 8px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      width: 150px;
    }
    .node-label-set {
      display: none;
    }
  }
 
  .node-data:hover .node-label-set {
    display: block;
  }
}
.el-tree /deep/ .el-tree-node.is-current > .el-tree-node__content {
  background-color: #4D88FF;
  color: #fff;
  // border-right: 2px solid #4D88FF;
  .node-label-set {
    display: block;
  }
}
.system-view-nav /deep/ .el-tree-node > .el-tree-node__children {
  overflow: visible;
}
.system-view-nav /deep/ .el-tree > .el-tree-node {
  min-width: 100%;
  display: inline-block !important;
}
</style>