<template>
  <div class="companyList">
    <div class="head-title">
      公司资料管理
    </div>
    <div class="content">
      <div>
        <div class="searchInput" style="width:250px">
          <el-input @keyup.enter.native="msg.pageIndex=1,getList()" @clear="msg.pageIndex=1,getList()"
            style="display:inline-block;width:225px;height:30px" placeholder="请输入公司名称" v-model="msg.CompanyName"
            size="small" clearable>
          </el-input>
          <span @click="msg.pageIndex=1,getList()" class="el-icon-search"
            style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
        </div>
      </div>
      <el-table :data="tableData" v-loading="loading" border style="width: 100%;margin:20px 0">
        <el-table-column prop="CompanyId" label="编号" width="100">
        </el-table-column>
        <el-table-column prop="CompanyName" label="公司名称">
        </el-table-column>
        <el-table-column prop="Principal" label="联系人">
        </el-table-column>
        <el-table-column prop="Mobile" width="150" label="联系电话">
        </el-table-column>
        <el-table-column prop="EMail" width="200" label="邮箱">
        </el-table-column>
        <el-table-column prop="Industry" width="150" label="行业">
        </el-table-column>
        <el-table-column prop="AnnualSales" width="150" label="年销售(万元)">
        </el-table-column>
        <el-table-column prop="AnnualImport" width="150" label="年进口额">
        </el-table-column>
        <el-table-column prop="address" width="200" label="操作">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="查看" placement="top">
              <img @click="EditgoUrl(scope.row)" src="../../assets/img/userman/icon-show.png" alt="">
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right" background @current-change="handleCurrentChange" :page-size="msg.pageSize"
        :current-page.sync="msg.pageIndex" layout="total,prev, pager, next" :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        msg: {
          pageIndex: 1,
          pageSize: 10,
          CompanyName: '',
        },
        total: 0,
        tableData: [], //数据列表
      };
    },
    created() {
      this.getList();
    },
    methods: {
      EditgoUrl(row) {
        this.$router.push({
          name: 'companyinfo',
          query: {
            Id: row.CompanyId,
            blank: "y"
          }
        });
      },
      getList() {
        this.loading = true;
        this.apipost("/api/Trade/GetCompanyPageList", this.msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.total = res.data.data.count;
            let pageData = res.data.data.pageData;
            this.tableData = pageData;
          }
        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      //删除公司资料
      delContactus(item) {
        let that = this;
        that.Confirm("是否删除?", function () {
          that.apipost(
            "/api/Trade/RemoveCompany", {
              CompanyId: item.CompanyId,
              Status: 1
            },
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });
      }
    },
    mounted() {}
  };

</script>
<style>
  .companyList .remark_name {
    color: #888888;
    font-size: 12px;
    margin-left: 10px;
    float: right;
  }

  .companyList .app-image {
    background-position: center center;
    width: 50px;
    height: 50px;
    border-radius: 0%;
    float: left;
    margin-right: 8px;
  }

  .companyList .blue {
    color: #409EFF;

  }

  .companyList .content .searchInput {
    border: 1px solid #DCDFE6;
    border-radius: 4px;
  }

  .companyList .content .searchInput .el-input__inner {
    border: none;
    outline: none;
    height: 30px;
    line-height: 30px;
  }

  .companyList .content .searchInput {
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width: 250px;
    margin-right: 20px;
  }

  .companyList .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    box-sizing: border-box;
  }
</style>
