<template>
  <div v-loading="loading" >
    <el-table :data="dataLists" border stripe>
      <el-table-column type="index" label="编号" align="center" fixed width="80"/>
      <el-table-column label="工单编号" align="center" min-width="140">
        <template slot-scope="scope">
          <!-- <el-tooltip content="点击查看工单详情" placement="top"> -->
          <el-button type="text" @click="btn_detail(scope.row.ordercode)">{{ scope.row.ordercode }}</el-button>
          <!-- </el-tooltip> -->
        </template>
      </el-table-column>
      <el-table-column label="工单状态" align="center" min-width="">
        <template slot-scope="scope">
          <el-tag
            :color="scope.row.state | orderStateTypeFilter"
            style="color: #ffffff"
            size="mini"
            disable-transitions>
            {{ scope.row.state | orderStateFilter }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="name" label="姓名" align="center"/>
      <el-table-column prop="phone" label="电话" align="center" min-width="120" />
      <el-table-column prop="callintel" label="来电电话" align="center" min-width="120"/>
      <el-table-column prop="typename" label="工单类型" align="center" min-width=""/>
      <el-table-column prop="deptname" label="咨询/投诉部门" align="center" min-width="120" />
      <el-table-column label="工单内容" prop="content" align="center" width="200">
        <template slot-scope="scope">
          {{ scope.row.content | formatterContent }}
        </template>
      </el-table-column>
      <el-table-column prop="sourcename" label="工单来源" align="center" min-width="120" />
      <el-table-column prop="provincename" label="所在省" align="center" />
      <el-table-column prop="cityname" label="所在市" align="center" />
      <el-table-column prop="address" label="具体地址" align="center" />
      <el-table-column prop="createuser" label="创建人" align="center"/>
      <el-table-column prop="createtime" label="创建时间" align="center" min-width="140"/>
    </el-table>
    <pagination
      v-show="pageParams.total > 0"
      :total="pageParams.total"
      :pageindex.sync="pageParams.pageindex"
      :pagesize.sync="pageParams.pagesize"
      :auto-scroll="false"
      class="pagination"
      @pagination="getOrderRecord" />
  </div>
</template>
<script>

import { orderStateFilter, orderStateTypeFilter, formatterContent } from '@/filters'
import { getOrderLists } from '@/api/order/orderSearchHY'
// import detail from '@/views/order/components/detail'
import Pagination from '@/components/Pagination' // 对el-pagination 二次封装

export default {
  name: 'OrderRecord',
  components: {
    Pagination
  },
  filters: {},
  props: {
    callinNum: {
      type: String,
      default: ''
    },
    callid: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      pageParams: {
        pageindex: 1, // 当前第几页
        pagesize: Number(this.$store.getters.serverConfig.PAGESIZE), // 每页几条数据
        total: 0 // 总共多少数据
      },
      dataLists: [] // 列表数据
    }
  },
  created() {
    this.getOrderRecord()
  },
  methods: {
    getOrderRecord() {
      this.loading = true
      return new Promise(resolve => {
        const params = {
          pageindex: this.pageParams.pageindex, // int 第几页
          pagesize: this.pageParams.pagesize, // int 每页几条信息
          phone: this.callinNum //	否	string	模糊查询（号码）
        }
        getOrderLists(params).then(response => {
          this.loading = false
          if (response.state.toLowerCase() === 'success') {
            this.pageParams.total = response.data.total
            this.dataLists = response.data.rows
          }
        })
        resolve()
      })
    },
    // btn_detail(editId) {
    //   this.$layer.iframe({
    //     content: {
    //       content: detail, // 传递的组件对象
    //       parent: this, // 当前的vue对象
    //       data: { 'rowid': editId, 'isCallin': true, 'callid': this.callid }// props
    //     },
    //     area: ['65%', '70%'],
    //     title: '工单详情',
    //     cancel: () => {
    //       this.getOrderRecord()
    //     }
    //   })
    // }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>

</style>
