<template>
  <div class="dialog-missed-call pl-16 pr-16 pt-16">
    <div class="flex-row justify-content-between align-items-center pb-16 border-b-solid-lighter-1"
         v-for="(item, index) in missedCallData.list" :key="index">
      <div class="width70">
        <div class="color-000 f-weight600 f16">{{item.contact}}</div>
        <div class="f12">来电时间:{{ formatDate(item.createAt, 'YYYY-MM-DD HH:mm:ss') }}</div>
      </div>
      <el-button size="small" type="primary" @click="handleMissedCallCase(item)">查看相关案件</el-button>
    </div>

    <!--  未接电话案件弹窗  -->
    <missedCallCaseDialog v-if="missedCallCaseVisible" :eventDialog.sync="missedCallCaseVisible" @handleSubmit="UpdatehandleSubmit" />
  </div>
</template>

<script>
import voiceCall from "@/services/voiceCall";
import moment from "moment/moment";
export default {
  components: {
    missedCallCaseDialog: () => import('./missedCallCaseDialog'),//未接来电案件弹窗
  },
  name: "missedCallPopover",
  props: {
    missedCallData: {
      type: Object,
      default: () => {
        return {}
      },
    },
  },
  data() {
    return{
      caseList: [],
      missedCallCaseVisible: null,
    }
  },
  mounted() {

  },
  methods: {
    formatDate(time, type) {
      return time ? moment(time).format(type) : ''
    },
    handleMissedCallCase(item) {
      this.missedCallCaseVisible = {phone: item.phone,id: item.id,traceId:item.traceId}
    },
    getCaseList(item) {
      voiceCall.caseMatchList({phone: item.phone}).then(res => {
        if (!res.code) {
          this.caseList = res;
        }
      })
    },
    UpdatehandleSubmit(){
      this.$emit('handleSubmit', null)
    }
  }
}
</script>

<style scoped lang="scss">
.dialog-missed-call{
  width: 395px;
}
</style>