<template>
  <div class="appointList">
    <div class="el-card__header">
      <span>相亲约会记录</span>
      <div style="display: flex;flex-direction: row;align-items: center">
        <el-button type="primary" class="el-button--small" @click="addAppoint">新增</el-button>
      </div>
    </div>
    <div class="content">
      <div style="display: flex;flex-direction: row;align-items: center">
        <div class="block">
          <div class="searchInput" style="width:200px">
            <el-input style="display:inline-block;width:170px;height:30px" placeholder="用户姓名"
              v-model="msg.UserName" size="small" @clear="getList" @keyup.enter.native="getList" clearable>
            </el-input>
            <span @click="getList" class="el-icon-search"
              style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
          </div>
        </div>
      </div>
    </div>
    <div style="padding: 20px;background: #fff;">
      <el-table :data="dataList" header-cell-class-name="headClass" style="width: 100%" border>
        <el-table-column prop="ManName" label="男方信息">
          <template slot-scope="scope">
            <div class="appointUserInfo">
              <div>
                <img :src="scope.row.ManPhoto" style="width:30px;height:30px;border-radius:50%;margin-right:5px;" />
              </div>
              <div style="margin-top:4px;">{{scope.row.ManName}}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="WoManName" label="女方信息">
          <template slot-scope="scope">
            <div class="appointUserInfo">
              <div>
                <img :src="scope.row.WoManPhoto" style="width:30px;height:30px;border-radius:50%;margin-right:5px;" />
              </div>
              <div style="margin-top:4px;">{{scope.row.WoManName}}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="Time" label="时间">
        </el-table-column>
        <el-table-column prop="Address" label="地点">
        </el-table-column>
        <el-table-column prop="Remark" label="备注">
        </el-table-column>
        <el-table-column prop="CreateDate" label="创建时间" width="200">
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="130">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="编辑" placement="top">
              <img src="../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="Edit(scope.row)">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top">
              <img src="../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b(scope.row)">
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right" background @current-change="handleCurrentChange" :page-size="msg.pageSize"
        layout="prev, pager, next" :current-page.sync="msg.pageIndex" :total="pageCount">
      </el-pagination>
    </div>
  </div>
</template>
<script>
  export default {
    name: "appointList",
    data() {
      return {
        msg: {
          pageIndex: 1,
          pageSize: 20,
          UserId: 0,
          UserName: '',
        },
        pageCount: 0,
        dataList: [],
      }
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.apipost(
          "/api/Miai/GetMiaiDatingPageList", this.msg,
          res => {
            if (res.data.resultCode == 1) {
              this.dataList = res.data.data.pageData;
              this.pageCount = res.data.data.pageCount;
            } else {
              this.Error(res.data.message);
            }
          },
        )
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      //新增
      addAppoint() {
        this.$router.push('/editAppoint');
      },
      //修改
      Edit(row) {
        let arr = encodeURIComponent(JSON.stringify(row))
        this.$router.push({
          name: 'editAppoint',
          query: {
            arr: arr,
            blank: "y"
          }
        });
      },
      //删除记录
      delete_b(item) {
        let that = this;
        that.Confirm("是否删除?", function () {
          that.apipost(
            "/api/Miai/DelMiaiDatingInfo", {
              DatingId: item.Id
            },
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });
      }
    },
  }

</script>

<style>
  .appointList .el-card__header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #fff;

  }

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

  .appointUserInfo {
    display: flex;
  }

</style>
