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
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
<template>
  <div style="position: relative;">
    <flexbox class="t-section">
      <!--<img
        :src="crmIcon"
        class="t-img" >
      <div class="t-name">{{titleName}}:{{ name }}</div>-->
      <div class="t-name">{{ name }}</div>
      <!--<el-button
        v-if="showCancel"
        class="head-handle-button"
        type="primary"
        @click.native="handleTypeClick('discard')">作废</el-button>
      <el-button
        v-if="showTransfer"
        class="head-handle-button"
        type="primary"
        @click.native="handleTypeClick('transfer')">转移</el-button>
      <el-button
        v-if="showEdit"
        class="head-handle-button"
        type="primary"
        @click.native="handleTypeClick('edit')">编辑</el-button>
      <el-dropdown
        trigger="click"
        @command="handleTypeClick">
        <flexbox class="t-more">
          <div>更多</div>
          <i
            class="el-icon-arrow-down el-icon--right"
            style="color:#ccc;"/>
        </flexbox>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            v-for="(item, index) in moreTypes"
            v-if="whetherTypeShowByPermision(item.type)"
            :key="index"
            :command="item.type">{{ item.name }}</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>-->
      <img
        class="t-close"
        src="@/assets/img/close.png"
        @click="hideView" >
    </flexbox>
    <!--<flexbox
      class="h-section"
      align="stretch">
      <flexbox-item
        v-for="(item, index) in headDetails"
        :key="index"
        class="h-item"
        span="200">
        <div class="h-title">{{ item.title }}</div>
        <div class="h-value text-one-line" >{{ item.value }}</div>
      </flexbox-item>
    </flexbox>-->
    <slot/>
    <transfer-handle
      :crm-type="crmType"
      :selection-list="[detail]"
      :dialog-visible.sync="transferDialogShow"
      @handle="handleCallBack"/>
    <alloc-handle
      :crm-type="crmType"
      :selection-list="[detail]"
      :dialog-visible.sync="allocDialogShow"
      @handle="handleCallBack"/>
    <deal-status-handle
      :crm-type="crmType"
      :selection-list="[detail]"
      :visible.sync="dealStatusShow"
      @handle="handleCallBack"/>
  </div>
</template>
<script type="text/javascript">
import { mapGetters } from 'vuex'
// import {
//   crmLeadsTransform,
//   crmLeadsDelete
// } from '@/api/clients/clue'
// import {
//   crmCustomerLock,
//   crmCustomerPutInPool,
//   crmCustomerDelete,
//   crmCustomerReceive
// } from '@/api/customermanagement/customerManage'
// import { crmContactsDelete } from '@/api/clients/contacts'
// import { crmBusinessDelete } from '@/api/clients/business'
// import { crmContractDelete, CrmContractContractDiscard } from '@/api/clients/contract'
// import { crmReceivablesDelete } from '@/api/clients/money'
// import { crmProductStatus } from '@/api/clients/product'
import TransferHandle from './selectionHandle/TransferHandle' // 转移
import AllocHandle from './selectionHandle/AllocHandle' // 公海分配操作
import DealStatusHandle from './selectionHandle/DealStatusHandle' // 客户状态修改操作
 
export default {
  name: 'CRMDetailHead',
  components: {
    TransferHandle,
    AllocHandle,
    DealStatusHandle
  },
  props: {
    /** 模块ID */
    id: [String, Number],
    /** 没有值就是全部类型 有值就是当个类型 */
    crmType: {
      type: String,
      default: ''
    },
    // 辅助 使用
    isSeas: {
      type: Boolean,
      default: false
    },
    /** 联系人人下 新建商机 需要联系人里的客户信息  合同下需要客户和商机信息 */
    detail: {
      type: Object,
      default: () => {
        return {}
      }
    },
    headDetails: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      moreTypes: [], // 更多操作
      transferDialogShow: false, // 转移操作
      allocDialogShow: false, // 公海分配操作提示框
      dealStatusShow: false // 成交状态修改框
    }
  },
  computed: {
    ...mapGetters(['crm', 'CRMConfig']),
    crmIcon () {
      if (this.crmType === 'customer') {
        return require('@/assets/img/customer_detail.png')
      } else if (this.crmType === 'leads') {
        return require('@/assets/img/clue_detail.png')
      } else if (this.crmType === 'business') {
        return require('@/assets/img/business_detail.png')
      } else if (this.crmType === 'contacts') {
        return require('@/assets/img/contacts_detail.png')
      } else if (this.crmType === 'contract') {
        return require('@/assets/img/contract_detail.png')
      } else if (this.crmType === 'receivables') {
        return require('@/assets/img/money_detail.png')
      } else if (this.crmType === 'product') {
        return require('@/assets/img/product_detail.png')
      }
      return ''
    },
    name () {
      if (this.crmType === 'receivables') {
        return this.detail.number
      } else if (this.crmType === 'customer') {
        return this.detail.CustomerName
      } else if (this.crmType === 'business') {
        return this.detail.ChanceName
      } else if (this.crmType === 'contacts') {
        return this.detail.RealName
      }
      return this.detail.Name
    },
    titleName () {
      if (this.crmType === 'contacts') {
        return '联系人名称'
      } else if (this.crmType === 'customer') {
        return '客户名称'
      } else if (this.crmType === 'business') {
        return '商机名称'
      }
      return '名称'
    },
    // 展示转移
    showTransfer () {
      if (
        this.crmType === 'receivables' ||
        this.crmType === 'product' ||
        this.isSeas
      ) {
        return false
      }
      // return this.crm[this.crmType].transfer
      return true
    },
    showEdit () {
      // return this.isSeas ? false : this.crm[this.crmType].update
      return !this.isSeas
    },
    // 展示作废
    showCancel () {
      if (this.crmType === 'contract') {
        if (this.crm.contract.discard) {
          if (this.detail.checkStatus === 1) {
            return true
          }
          return false
        }
        return false
      }
      return false
    }
  },
  watch: {
    isSeas () {
      this.moreTypes = this.getSelectionHandleItemsInfo()
    }
  },
  mounted () {
    console.log(this.detail)
    this.moreTypes = this.getSelectionHandleItemsInfo()
  },
  methods: {
    /** 更多操作 */
    handleTypeClick (type) {
      if (type === 'edit') {
        // 编辑
        this.$emit('handle', { type: 'edit' })
      } else if (type === 'transfer') {
        // 转移
        this.transferDialogShow = true
      } else if (
        type === 'transform' ||
        type === 'put_seas' ||
        type === 'delete' ||
        type === 'lock' ||
        type === 'unlock' ||
        type === 'start' ||
        type === 'disable' ||
        type === 'get' ||
        type === 'discard'
      ) {
        var message = ''
        if (type === 'transform') {
          message = '确定将这些线索转换为客户吗?'
        } else if (type === 'put_seas') {
          message = '确定转移到公海吗?'
        } else if (type === 'delete') {
          message = '确定要删除这些数据吗?'
        } else if (type === 'lock') {
          message = '确定要锁定这些客户吗?锁定后将不会掉入公海。'
        } else if (type === 'unlock') {
          message = '确定要解锁这些客户吗?'
        } else if (type === 'start') {
          message = '确定要上架这些产品吗?'
        } else if (type === 'disable') {
          message = '确定要下架这些产品吗?'
        } else if (type === 'get') {
          message = '确定要领取该客户吗?'
        } else if (type === 'discard') {
          message = '确定要作废此合同吗?'
          if (this.detail.receivablesCount) {
            message = '合同下有相关回款,确定要作废吗?'
          }
        }
        this.$confirm(message, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.confirmHandle(type)
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            })
          })
      } else if (type === 'alloc') {
        // 公海分配操作
        this.allocDialogShow = true
      } else if (type === 'deal_status') {
        // 客户成交状态操作
        this.dealStatusShow = true
      }
    },
    confirmHandle (type) {
      if (type === 'lock' || type === 'unlock') {
        // crmCustomerLock({
        //   isLock: type === 'lock' ? '1' : '0', // 1锁0不锁
        //   ids: this.id
        // })
        //   .then(res => {
        //     this.$message({
        //       type: 'success',
        //       message: '操作成功'
        //     })
        //     this.$emit('handle', { type: type })
        //   })
        //   .catch(() => {})
      } else if (type === 'put_seas') {
        // crmCustomerPutInPool({
        //   ids: this.id
        // })
        //   .then(res => {
        //     this.$message({
        //       type: 'success',
        //       message: '操作成功'
        //     })
        //     this.$emit('handle', { type: type })
        //   })
        //   .catch(() => {})
      } else if (type === 'transform') {
        // crmLeadsTransform({
        //   leadsIds: this.id
        // })
        //   .then(res => {
        //     this.$message({
        //       type: 'success',
        //       message: '转化成功'
        //     })
        //     this.$emit('handle', { type: type })
        //   })
        //   .catch(() => {})
      } else if (type === 'discard') {
        // CrmContractContractDiscard({
        //   contractId: this.id
        // }).then(res => {
        //   this.$message.success('合同作废成功')
        //   this.$emit('handle', { type })
        // }).catch(() => {})
      } else if (type === 'start' || type === 'disable') {
        // crmProductStatus({
        //   ids: this.id,
        //   status: type === 'start' ? '1' : '0'
        // })
        //   .then(res => {
        //     this.$message({
        //       type: 'success',
        //       message: '操作成功'
        //     })
        //     this.$emit('handle', { type: type })
        //   })
        //   .catch(() => {})
      } else if (type === 'delete') {
        const request = {
          // leads: crmLeadsDelete,
          // customer: crmCustomerDelete,
          // contacts: crmContactsDelete,
          // business: crmBusinessDelete,
          // contract: crmContractDelete,
          // receivables: crmReceivablesDelete
        }[this.crmType]
        request({
          [this.crmType + 'Ids']: this.id
        })
          .then(res => {
            this.$message({
              type: 'success',
              message: '删除成功'
            })
            this.$emit('handle', { type: type })
          })
          .catch(() => {})
      } else if (type === 'get') {
        // 领取
        // crmCustomerReceive({
        //   ids: this.id
        // })
        //   .then(res => {
        //     this.$message({
        //       type: 'success',
        //       message: '操作成功'
        //     })
        //     this.$emit('handle', { type: type })
        //   })
        //   .catch(() => {})
      }
    },
    hideView () {
      this.$emit('close')
    },
    // 子组件 回调的 结果
    handleCallBack (data) {
      this.$emit('handle', { type: data.type })
    },
 
    /** 更多操作 */
    /** 获取展示items */
    getSelectionHandleItemsInfo () {
      const handleInfos = {
        transfer: {
          name: '转移',
          type: 'transfer',
          icon: require('@/assets/img/selection_transfer.png')
        },
        transform: {
          name: '转化为客户',
          type: 'transform',
          icon: require('@/assets/img/selection_convert_customer.png')
        },
        delete: {
          name: '删除',
          type: 'delete',
          icon: require('@/assets/img/selection_delete.png')
        },
        put_seas: {
          name: '放入公海',
          type: 'put_seas',
          icon: require('@/assets/img/selection_putseas.png')
        },
        lock: {
          name: '锁定',
          type: 'lock',
          icon: require('@/assets/img/selection_lock.png')
        },
        unlock: {
          name: '解锁',
          type: 'unlock',
          icon: require('@/assets/img/selection_unlock.png')
        },
        alloc: {
          name: '分配',
          type: 'alloc',
          icon: require('@/assets/img/selection_alloc.png')
        },
        get: {
          name: '领取',
          type: 'get',
          icon: require('@/assets/img/selection_get.png')
        },
        start: {
          name: '上架',
          type: 'start',
          icon: require('@/assets/img/selection_start.png')
        },
        disable: {
          name: '下架',
          type: 'disable',
          icon: require('@/assets/img/selection_disable.png')
        },
        deal_status: {
          name: '更改成交状态',
          type: 'deal_status',
          icon: require('@/assets/img/selection_deal_status.png')
        }
      }
      if (this.crmType === 'leads') {
        return this.forSelectionHandleItems(handleInfos, [
          'transform',
          'delete'
        ])
      } else if (this.crmType === 'customer') {
        if (this.isSeas) {
          return this.forSelectionHandleItems(handleInfos, [
            'alloc',
            'get',
            'delete'
          ])
        } else {
          return this.forSelectionHandleItems(handleInfos, [
            // 'put_seas',
            'deal_status',
            'lock',
            'unlock',
            'delete'
          ])
        }
      } else if (this.crmType === 'contacts') {
        return this.forSelectionHandleItems(handleInfos, ['delete'])
      } else if (this.crmType === 'business') {
        return this.forSelectionHandleItems(handleInfos, ['delete'])
      } else if (this.crmType === 'contract') {
        return this.forSelectionHandleItems(handleInfos, ['delete'])
      } else if (this.crmType === 'receivables') {
        return this.forSelectionHandleItems(handleInfos, ['delete'])
      } else if (this.crmType === 'product') {
        return this.forSelectionHandleItems(handleInfos, ['start', 'disable'])
      }
    },
    forSelectionHandleItems (handleInfos, array) {
      var tempsHandles = []
      for (let index = 0; index < array.length; index++) {
        tempsHandles.push(handleInfos[array[index]])
      }
      return tempsHandles
    },
    // 判断是否展示
    whetherTypeShowByPermision: function (type) {
      console.log(type)
      // if (type === 'transfer') {
      //   return this.crm[this.crmType].transfer
      // } else if (type === 'transform') {
      //   return this.crm[this.crmType].transform
      // } else if (type === 'export') {
      //   if (this.isSeas) {
      //     return this.crm.pool.excelexport
      //   }
      //   return this.crm[this.crmType].excelexport
      // } else if (type === 'delete') {
      //   if (this.crmType === 'contract') {
      //     if (this.detail.checkStatus === 6) {
      //       if (this.detail.isAdmin === 1) {
      //         return true
      //       }
      //       return false
      //     } else {
      //       // this.crm[this.crmType].delete
      //     }
      //   }
      //   return this.crm[this.crmType].delete
      // } else if (type === 'put_seas') {
      //   // 放入公海(客户)
      //   return this.crm[this.crmType].putinpool
      // } else if (type === 'lock' || type === 'unlock') {
      //   // 锁定解锁(客户)
      //   return this.crm[this.crmType].lock && this.CRMConfig.customerConfig === 1
      // } else if (type === 'add_user' || type === 'delete_user') {
      //   // 添加 移除团队成员
      //   return this.crm[this.crmType].teamsave
      // } else if (type === 'alloc') {
      //   // 分配(公海)
      //   return this.crm.pool.distribute
      // } else if (type === 'get') {
      //   // 领取(公海)
      //   return this.crm.pool.receive
      // } else if (type === 'start' || type === 'disable') {
      //   // 上架 下架(产品)
      //   return this.crm[this.crmType].status
      // } else if (type === 'deal_status') {
      //   // 客户状态修改
      //   return this.crm[this.crmType].dealStatus
      // }
 
      return true
    }
  }
}
</script>
<style lang="less" scoped>
.t-section {
  position: relative;
  padding: 24px 40px;
  min-height: 60px;
  .t-img {
    display: block;
    width: 35px;
    height: 35px;
    margin-right: 10px;
  }
  .t-name {
    flex: 1;
    font-size: 18px; /*no*/
    font-weight: 550;
    color: #333333;
  }
  .t-more {
    border: 1px solid #dcdfe6;
    font-size: 12px;
    color: #606266;
    padding: 0 10px 0 12px;
    border-radius: 2px;
    font-weight: 500;
    height: 25px;
    cursor: pointer;
  }
  .t-close {
    display: block;
    width: 50px;
    height: 50px;
    margin-left: 20px;
    padding: 10px;
    cursor: pointer;
  }
}
 
.h-section {
  position: relative;
  padding: 10px 0;
  min-height: 58px;
  .h-item {
    .h-title {
      font-size: 12px;
      color: #777;
    }
    .h-value {
      min-height: 14px;
      margin-top: 8px;
      font-size: 13px;
      color: #333333;
    }
  }
}
.head-handle-button {
  padding: 5px 15px;
  margin-right: 10px;
}
</style>