<template>
  <div class="contactus">
    <div class="head-title">
      联系我们
      <el-button @click="addContact" style="float:right;margin-top: -5px;margin-right: 10px" size="small"
        type="primary">
        新增
      </el-button>
    </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.Name" 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="Id" label="ID" width="100">
        </el-table-column>
        <el-table-column prop="Name" width="280" label="头像/姓名">
          <template slot-scope="scope">
            <div class="app-image" :style="{backgroundImage:'url(' + scope.row.HeadIcon + ')',backgroundSize:'cover'}">
            </div>
            <div flex="dir:left cross:center">
              {{scope.row.Name}}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="Position" label="职位">
        </el-table-column>
        <el-table-column prop="BgImg" width="280" label="背景图">
          <template slot-scope="scope">
            <div class="app-image" :style="{backgroundImage:'url(' + scope.row.BgImg + ')',backgroundSize:'cover'}">
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="Tel" 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)" style="width:32px;height:32px" src="../../assets/img/userman/edit.png"
                alt="">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top-start">
              <img @click="delContactus(scope.row)" style="width:32px;height:32px;margin:0 10px"
                src="../../assets/img/userman/del.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,
          Name: '',
        },
        total: 0,
        tableData: [], //数据列表
      };
    },
    created() {
      this.getList();
    },
    methods: {
      EditgoUrl(row) {
        this.$router.push({
          name: 'addContact',
          query: {
            Id: row.Id,
            blank: "y"
          }
        });
      },
      //新增联系我们
      addContact() {
        this.$router.push({
          name: 'addContact',
        });
      },
      getList() {
        this.loading = true;
        this.apipost("/api/Trade/GetContractPageList", 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/RemoveContract", {
              Id: item.Id,
              Status: 1
            },
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });
      }
    },
    mounted() {}
  };

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

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

  .contactus .blue {
    color: #409EFF;

  }

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

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

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

  .contactus .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    box-sizing: border-box;
  }

</style>