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
<template>
  <div class="fl-c">
    <!--<flexbox class="fl-h">
      <div
        v-photo="{img: item.userImg, realname: item.realname}"
        v-lazy:background-image="$options.filters.filterUserLazyImg(item.userImg)"
        class="div-photo fl-h-img"/>
      <div class="fl-h-b">
        <div class="fl-h-name">{{ item.Title }}</div>
        <div class="fl-h-time">{{ item.FollowTime }}</div>
      </div>
      <flexbox class="fl-h-mark">
        <img
          class="fl-h-mark-img"
          src="@/assets/img/person_dot.png" v-if=
        "crmType === 'customer'">
        <img
          class="fl-h-mark-img"
          src="@/assets/img/follow_record.png" v-if=
        "crmType === 'contacts'">
        <img
          class="fl-h-mark-img"
          src="@/assets/img/business_dot.png" v-if=
        "crmType === 'business'">
        <div class="fl-h-mark-name">跟进记录</div>
      </flexbox>
      <el-dropdown
        trigger="click"
        @command="handleCommand">
        <i
          style="color:#CDCDCD;margin-left: 8px;"
          class="el-icon-arrow-down el-icon-more"/>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item :command="beforeHandleCommand(item.Id,'edit')">编辑</el-dropdown-item>
          <el-dropdown-item :command="beforeHandleCommand(item.Id,'delete')">删除</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </flexbox>
    <div class="fl-b">
      <div class="fl-b-content">{{ item.Content }}</div>
      <flexbox
        v-if="item.img && item.img.length > 0"
        class="fl-b-images"
        wrap="wrap">
        <div
          v-lazy:background-image="file.filePath"
          v-for="(file, index) in item.img"
          :key="file.filePath"
          class="fl-b-img-item"
          @click="previewImg(item.img, index)"/>
      </flexbox>
      <div
        v-if="item.file && item.file.length > 0"
        class="fl-b-files">
        <flexbox
          v-for="(file, index) in item.file"
          :key="index"
          class="cell">
          <img
            class="cell-head"
            src="@/assets/img/relevance_file.png" >
          <div class="cell-body">{{ file.name }}<span style="color: #ccc;">({{ file.size }})</span></div>
          <el-button
            type="primary"
            icon="el-icon-download"
            @click="downloadFile(file)">下载</el-button>
        </flexbox>
      </div>
      <div
        v-if="item.FollowWay || item.FollowTime || item.CompletedTime"
        class="follow">
        <span
          v-if="item.FollowWay"
          class="follow-info">跟进方式:{{ item.FollowWay | typeFollowWay }}</span>
        <span
          v-if="item.FollowTime"
          class="follow-info">下次跟进时间:{{ item.FollowTime }}</span>
          <span
          v-if="item.CompletedTime"
          class="follow-info">跟进完成时间:{{ item.CompletedTime }}</span>
      </div>
      <div
        v-if="item.contactsList && item.contactsList.length > 0"
        class="fl-b-other">
        <div class="fl-b-other-name">关联联系人</div>
        <div>
          <flexbox
            v-for="(item, index) in item.contactsList"
            :key="index"
            class="cell"
            @click.native="checkRelationDetail('contacts', item.contactsId)">
            <i
              :style="{'opacity': index === 0 ? 1 : 0}"
              class="wukong wukong-contacts cell-head crm-type"/>
            <div
              class="cell-body"
              style="color: #6394E5;cursor: pointer;">{{ item.name }}</div>
          </flexbox>
        </div>
      </div>
      <div
        v-if="item.businessList && item.businessList.length > 0"
        class="fl-b-other">
        <div class="fl-b-other-name">关联商机</div>
        <div>
          <flexbox
            v-for="(item, index) in item.businessList"
            :key="index"
            class="cell"
            @click.native="checkRelationDetail('business', item.businessId)">
            <i
              :style="{'opacity': index === 0 ? 1 : 0}"
              class="wukong wukong-business cell-head crm-type"/>
            <div
              class="cell-body"
              style="color: #6394E5;cursor: pointer;">{{ item.businessName }}</div>
          </flexbox>
        </div>
      </div>
      <slot/>
    </div>-->
 
    <el-table
      :data="list"
      :height="tableHeight"
      :header-cell-style="headerRowStyle"
      :cell-style="cellStyle"
      style="width: 100%;border: 1px solid #E6E6E6;"
      @row-click="handleRowClick"
      @selection-change="selectionList = $event">
      <el-table-column
        v-for="(item, index) in fieldList"
        :key="index"
        :prop="item.prop"
        :label="item.label"
        :formatter="fieldFormatter"
        show-overflow-tooltip/>
    </el-table>
    <div class="p-contianer" v-show='item.length>0'>
      <el-pagination
        :current-page="currentPage"
        :page-sizes="pageSizes"
        :page-size.sync="pageSize"
        :total="item.length"
        class="p-bar"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"/>
    </div>
    <!--跟进 -->
    <el-dialog
      v-loading="followLoading"
      v-if="isFollowDialog"
      title="编辑跟进记录"
      :visible.sync="isFollowDialog"
      :close-on-click-modal="false"
      :modal-append-to-body="true"
      :append-to-body="true"
      :before-close="followHandleClose"
      width="60%">
        <mix-add
          ref="mixadd"
          :crm-type="crmType"
          :id="id"
          :isEdit='true'
          :show-relative-business="true"
          :show-relative-contacts="true"
          @mixadd-info="submitInfo"/>
      <span
        slot="footer"
        class="dialog-footer">
        <el-button
          type="primary"
          @click="followDialogSubmit">保 存</el-button>
        <el-button @click="followHandleClose">取 消</el-button>
      </span>
    </el-dialog>
 
    <c-r-m-full-screen-detail
      :visible.sync="showFullDetail"
      :crm-type="relationCrmType"
      :id="relationID"/>
  </div>
</template>
 
<script>
import MixAdd from '../../../components/MixAdd'
import { downloadFile } from '@/utils'
// import { crmRecordDelete } from '@/api/clients/common'
 
export default {
  /** 客户管理 的 客户详情 的 跟进记录cell */
  name: 'FollowRecordCell',
  components: {
    MixAdd,
    CRMFullScreenDetail: () =>
      import('@/views/clients/components/CRMFullScreenDetail.vue')
  },
  filters: {
    /** 根据type 找到组件 */
    typeFollowWay (formType) {
      switch (formType) {
        case 0:
          return '暂无'
        case 1:
          return '电话'
        case 2:
          return '在线沟通'
        case 3:
          return '邮件或短信'
        case 4:
          return '上门拜访'
      }
    }
  },
  props: {
    item: {
      type: Object,
      default: () => {
        return {}
      }
    },
    /** 没有值就是全部类型 有值就是当个类型 */
    crmType: {
      type: String,
      default: ''
    },
    index: [String, Number]
  },
  data () {
    return {
      showFullDetail: false, // 查看相关客户管理详情
      relationID: '', // 相关ID参数
      relationCrmType: '', // 相关类型
      isFollowDialog: false,
      followLoading: false,
      id: '',
      list: [],
      fieldList: [],
      tableHeight: '400px',
      total: 0,
      currentPage: 1,
      pageSize: 10,
      pageSizes: [10, 30, 60, 100]
    }
  },
  computed: {
  },
  mounted () {
    this.fieldList.push(
      { prop: 'SalesChanceName', label: '商机名称', width: '300' },
      { prop: 'Contacter', label: '联系人', width: '400' },
      { prop: 'FollowTime', label: '下次跟进时间', width: '400' },
      { prop: 'CompletedTime', label: '跟进完成时间', width: '400' },
      { prop: 'FollowWay', label: '跟进方式', width: '400' },
      { prop: 'DocumentType', label: '销售负责人', width: '200' },
      { prop: 'Content', label: '跟进内容', width: '100' },
      { prop: 'Files', label: '附件', width: '200' }
    )
 
    console.log(this.item)
  },
  methods: {
    /** 通过回调控制表头style */
    headerRowStyle ({ row, column, rowIndex, columnIndex }) {
      return { textAlign: 'left' }
    },
    /** 通过回调控制style */
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      return { textAlign: 'left' }
    },
    // 当某一行被点击时会触发该事件
    handleRowClick (row, column, event) {},
    /** 格式化字段 */
    fieldFormatter (row, column) {
      // 如果需要格式化
      if (column.property === 'FileType') {
        return this.getStatusName(row.FileType)
      }
      return row[column.property] || '--'
    },
    handleSizeChange (newSize) {
      this.$emit('on-handle', {size: newSize})
      // this.queryInfo.pagesize = newSize
    },
    handleCurrentChange (newPage) {
      this.$emit('on-handle', {page: newPage})
      // this.queryInfo.pagenum = newPage
    },
    previewImg (list, index) {
      this.$bus.emit('preview-image-bus', {
        index: index,
        data: list.map(function (item, index, array) {
          item.url = item.filePath
          return item
        })
      })
    },
    downloadFile (file) {
      downloadFile({ path: file.filePath, name: file.name })
    },
    /**
     * 删除跟进记录
     */
    beforeHandleCommand (id, command) { // index我这里是遍历的角标,即你需要传递的额外参数
      return {
        'id': id,
        'command': command
      }
    },
 
    handleCommand (command) {
      console.log(command)
      if (command.command === 'delete') {
        this.$confirm('确定删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
          // crmRecordDelete({
          //   recordId: this.item.recordId
          // })
          //   .then(res => {
          //     this.$emit('on-handle', {
          //       type: command,
          //       data: { item: this.item, index: this.index }
          //     })
          //     this.$message.success('操作成功')
          //   })
          //   .catch(() => {})
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            })
          })
      } else if (command.command === 'edit') {
        this.id = command.id
        this.isFollowDialog = true
      }
    },
    followDialogSubmit () {
      this.isFollowDialog = false
      this.$refs.mixadd.resetInfo()
    },
    followHandleClose () {
      this.isFollowDialog = false
      this.$refs.mixadd.resetInfo()
    },
    /** 快捷添加框内 返回的数据用于上传 */
    submitInfo (data) {
      console.log(data)
      if (data.isEvent && !data.nextTime) {
        this.$message.error('请选择下次联系时间')
        return
      } else if (!data.content) {
        this.$message.error('请输入跟进内容')
        return
      }
 
      var params = {}
      params.SourceId = this.id
      params.Title = data.title
      params.Content = data.content
      params.FollowType = data.followTypeId
      params.FollowWay = data.wayTypeId
      // var businessIds = data.business.map(function (element, index, array) {
      //   return element.businessId
      // })
      // var contactsIds = data.contacts.map(function (element, index, array) {
      //   return element.contactsId
      // })
 
      // params.batchId = data.batchId
      // params.businessIds = businessIds.join(',')
      // params.contactsIds = contactsIds.join(',')
 
      params.IsCompleted = data.isEvent
      params.FollowTime = data.nextTime || ''
 
      this.sendLoading = true
      if (data.isEvent) {
        // MakeFollowRecordCompleted({'Id': this.id}).then(res => {
        //   this.$message.success('完成跟进')
        // })
      }
      // AddFollowRecord(params)
      //   .then(res => {
      this.sendLoading = false
      //     this.$message.success('发布成功')
      //     // 重置页面
      this.$refs.mixadd.resetInfo()
      //     // this.isEvent = false
      //     // this.nextTime = ''
      //     // 刷新数据
      //     this.$bus.emit('follow-log-refresh', { type: 'record-log' })
      //   })
      //   .catch(() => {
      //     this.sendLoading = false
      //   })
    },
    /**
     * 查看相关客户管理详情
     */
    checkRelationDetail (type, id) {
      // this.relationID = id
      // this.relationCrmType = type
      // this.showFullDetail = true
    }
  }
}
</script>
 
<style lang="scss" scoped>
@import '../styles/followcell.scss';
@import '../../../styles/relativecrm.scss';
@import '../../../styles/table.scss';
.follow {
  .follow-info {
    padding: 5px 10px;
    background-color: #f5f7fa;
    color: #999;
    height: 40px;
    line-height: 40px;
    border-radius: 28px;
    font-size: 12px;
    margin-right: 10px;
  }
}
 
.crm-type {
  color: rgb(99, 148, 229);
  font-size: 14px;
}
</style>