<!--
 * @Author: wanglj 471442253@qq.com
 * @Date: 2022-12-29 18:00:08
 * @LastEditors: wanglj
 * @LastEditTime: 2022-12-30 09:03:39
 * @Description: file content
 * @FilePath: \opms_frontend\src\views\customer\components\FollowDetail.vue
-->
<template>
  <el-dialog title="跟进详情" :visible.sync="visible">
    <el-descriptions
      border
      class="margin-top"
      :column="1"
      :content-style="{ width: '85%', 'word-break': 'break-all' }"
      :label-style="{ width: '15%' }"
      size="medium">
      <el-descriptions-item label="跟进类型">
        {{ formatType(form.followType) }}
      </el-descriptions-item>
      <el-descriptions-item label="跟进对象">
        {{ form.targetName }}
      </el-descriptions-item>
      <el-descriptions-item label="跟进时间">
        {{ form.followDate }}
      </el-descriptions-item>
      <el-descriptions-item label="本次跟进内容">
        {{ form.followContent }}
      </el-descriptions-item>
      <el-descriptions-item label="达成效果">
        {{ form.effect }}
      </el-descriptions-item>
      <el-descriptions-item label="问题或困难">
        {{ form.issue }}
      </el-descriptions-item>
      <el-descriptions-item label="下一步跟进计划和目标">
        {{ form.furtherPlan }}
      </el-descriptions-item>
      <el-descriptions-item label="客户名称">
        {{ form.custName }}
      </el-descriptions-item>
      <el-descriptions-item label="联系人">
        {{ form.contactsName }}
      </el-descriptions-item>
      <el-descriptions-item label="渠道">
        {{ form.distName }}
      </el-descriptions-item>
      <el-descriptions-item label="协访人员">
        {{ form.visitorName }}
      </el-descriptions-item>
      <el-descriptions-item label="相关附件">
        <a v-for="item in form.files" :key="item.id" :href="item.fileUrl">
          {{ item.fileName }}
          <br />
        </a>
      </el-descriptions-item>
      <el-descriptions-item label="评论数量">
        {{ form.commentNumber }}
      </el-descriptions-item>
      <el-descriptions-item label="跟进人">
        {{ form.createdName }}
      </el-descriptions-item>
      <el-descriptions-item label="创建时间">
        {{ form.createdTime }}
      </el-descriptions-item>
    </el-descriptions>
    <span slot="footer">
      <!-- <el-button>编辑跟进</el-button>
        <el-button>删除跟进</el-button> -->
      <el-button @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import api from '@/api/customer/follow'
  import to from 'await-to-js'

  export default {
    data() {
      return {
        visible: false,
        form: {
          id: '',
          followType: '',
          followDate: '',
          followContent: '',
          targetId: '',
          targetType: '',
          targetName: '',
          custId: '',
          custName: '',
          contactsId: 0,
          contactsName: '',
          reminders: '',
          nextTime: '',
          files: [],
          remark: '',
          createdBy: '',
          createdName: '',
          createdTime: '',
          updatedBy: '',
          updatedName: '',
          updatedTime: '',
          deletedTime: '',
        },
      }
    },
    methods: {
      init(form) {
        form.files = []
        this.form = form
        this.visible = true
        this.getFollowupFileList()
      },
      async getFollowupFileList() {
        const [err, res] = await to(api.getFollowupFileList({ followId: this.form.id + '' }))
        if (err) return
        this.form.files = res.data.list || []
      },

      formatType(val) {
        let str = ''
        if (val == 10) str = '电话'
        else if (val == 20) str = '邮件'
        else if (val == 30) str = '拜访'
        return str
      },
    },
  }
</script>

<style></style>
