<template>
  <div>
    <CustomSubHeader>
      <CBreadcrumb class="border-0 mb-0"> شکایات </CBreadcrumb>
      
    </CustomSubHeader>
    <CCard>
      <CCardHeader>
        <slot name="header">
          <CIcon name="cil-grid" />
           شکایات 
        </slot>
      </CCardHeader>

      <CCardBody>
        <el-table :data="complaint" style="width: 100%">
          <el-table-column type="index" label="#"> </el-table-column>

          <el-table-column prop="fullName" label="نام" width="">
           
          </el-table-column>

          <el-table-column  label="کد ملی" width="">
            <template slot-scope="scope">
              <span class="singleLineTxt" :title="scope.row.national"> {{ scope.row.national }} </span>
            </template>
          </el-table-column>

          <el-table-column  label="متن" width="">
            <template slot-scope="scope">
              <span class="singleLineTxt" :title="scope.row.caption"> {{ scope.row.caption }} </span>
            </template>
          </el-table-column>

          <el-table-column  label="تاریخ ایجاد" width="">
            <template slot-scope="scope">
              <span> {{ $jDate(scope.row.created_at) }} </span>

            </template>
          </el-table-column>


          <el-table-column  label="شماره تماس" width="">
            <template slot-scope="scope">
              <span class="singleLineTxt" :title="scope.row.phoneNumber"> {{ scope.row.phoneNumber }} </span>
            </template>
          </el-table-column>

          <el-table-column  label="ایمیل" width="">
            <template slot-scope="scope">
              <span class="singleLineTxt" :title="scope.row.email"> {{ scope.row.email }} </span>
            </template>
          </el-table-column>

          <el-table-column  label="پیگیری شکایت" width="">
            <template slot-scope="scope">
              <span :class="{  'text-success': scope.row.complete , 'text-danger': !scope.row.complete }" class="singleLineTxt" :title="scope.row.email"> {{ scope.row.complete ? "پیگیری شده" : "پیگیری نشده" }} </span>
            </template>
          </el-table-column>

          <el-table-column label="نمایش" width="110" align="center">
            <template slot-scope="scope">
              <CButton
                :key="scope.row._id + type"
                color="success"
                variant="outline"
                :to="{ name: 'admin-complaint-item', params: { item: scope.row._id } }"
              >
                <i class="fal fa-eye"></i>
              </CButton>
            </template>
          </el-table-column>
        </el-table>
      </CCardBody>
    </CCard>
  </div>
</template>

<script>
export default {
  name: 'AdminComplaintsList',
  layout: 'admin',
  async asyncData({ $axios, error }) {
    
  },
  data() {
    return {
      complaint:null
     
    }
  },
 
  computed: {

  },
  beforeMount(){

    this.$axios.get('/api/admin/complaint').then(res=>{
      this.complaint = res.data


    }).catch(err=>{
      console.log(err)
    })


  },
  methods: {
  
   
     
      
     
  }
  
  }

</script>
