<template>
  <div class="data-list">


      <el-table :data="dataList" style="width: 100%" header-row-class-name="headerBg" empty-text="没有客户信息">
        <el-table-column prop="id" label="ID" align="center" width="80"/>
        <!-- <el-table-column prop="code" label="客户代码" align="left" min-width="180"/> -->
        <el-table-column prop="name" label="客户名称" align="left" min-width="180"/>
        <el-table-column prop="enName" label="英文名称" align="left" min-width="180"/>
<!--
        <el-table-column prop="mobile" label="手机号码" align="center" width="180"/>
        <el-table-column prop="contact" label="联系人" align="center" width="180"/>
        <el-table-column prop="address" label="联系地址" align="left" min-width="180"/>
-->
        <el-table-column prop="createTime" label="创建时间" align="center" width="180"/>
        <el-table-column prop="status" label="客户状态" align="center" width="180">
           <template #default="scope">
              <div v-if="scope.row.status==5">启用</div>
              <div v-if="scope.row.status==6">停用</div>
          </template>
        </el-table-column>
      </el-table>


      <div class="page-info">
      	<el-pagination
      	v-model:currentPage="queryForm.page"
      	:page-size="queryForm.pageSize"
      	:total="recordCount"
      	:page-count="pageTotal"
      	 background
      	 layout="prev, pager, next"
      	 @current-change="ChangePage"
      	 >
      	 </el-pagination>
      </div>

     <el-dialog  :visible.sync="dialogVisible" append-to-body v-el-drag-dialog  width="80%" custom-class="prod-verify" title="创建项目信息">

          <dataInfo ></dataInfo>
      </el-dialog>

  </div>


</template>

<script>
  import{searchCustomer} from'@/api/customer';
  import dataInfo from './dataInfo.vue';
  import elDragDialog from '@/directive/el-drag-dialog'
  export default{
    components:{
      dataInfo,
    },
    directives: { elDragDialog },
    props:{
      queryForm:{
        type:Object,
        default:()=>{
          return {
            page:1,
            pageSize:10,
            name:'',
            status:'',
          }
        }
      }
    },
    watch:{

        'queryForm': {
          handler: function(val) {

            this.search();
          },
          // immediate: true,//立即执行
          deep: true

        },
    },
    data(){
      return{
        dialogVisible:false,//控制产品审核
        currentDataId:0,
        recordCount:0,
        pageTotal:1,
        dataList:[],
        currentData:{},
      }
    },
    mounted() {
      this.search();
    },
    methods:{

      onFocusVal(e){
        let _this=this;
        _this.currentDataId=e.target.dataset.id;
      },

      onChangeVal(e){
        let _this=this;
        let par={
          id:_this.currentDataId,
          val:e,
        };

      },

      searchData(){
        let _this=this;
        _this.dialogVisible=false;
        _this.search();
      },


      //编辑
      btnEdit(e){
        let _this=this;
        _this.currentDataId=e.id
        _this.dialogVisible=true;
      },

      onClose(){
        let _this=this;
        _this.currentDataId=0;
        _this.dialogVisible=false;
      },

      //搜索
      search(){
        let _this=this;
        searchCustomer(_this.queryForm).then(res=>{
          // if(!res)return;
          _this.dataList=res.data.dataList;
          _this.recordCount=res.data.totalRecord;
          _this.pageTotal=res.data.totalPage;
        })
      },
      //修改分页
      ChangePage(e){
      	let _this=this;
      	_this.queryForm.page=e;
      	_this.search();
      },
    }
  }
</script>

<style lang="scss">
@import './dataList.scss';
</style>
