<template>
  <div>
    <div class="member-list">
      <!-- 筛选条件 -->
      <div class="screen-container">
        <div class="top clearfix">
          <div class="title fl">条件筛选</div>
        </div>
        <el-form
          ref="screenForm"
          :model="screenForm"
          label-width="100px"
          size="small"
          label-position="left"
        >
          <el-row :gutter="20">
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="手机号">
                <el-input
                  v-model="screenForm.mobile"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="网点编号">
                <el-input
                  v-model="screenForm.websitId"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="网点名称">
                <el-input
                  v-model="screenForm.websitName"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="职位">
                <el-input
                  v-model="screenForm.position"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="姓名">
                <el-input
                  v-model="screenForm.workName"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="账号">
                <el-input
                  v-model="screenForm.workUserId"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :lg="6" class="tr">
              <el-form-item label="">
                <el-button size="small" @click="resetScreenForm"
                  >清空</el-button
                >
                <el-button size="small" type="primary" @click="submitScreenForm"
                  >搜索</el-button
                >
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="mymain-container">
        <div class="table">
          <el-table
            v-loading="listLoading"
            :data="dataList"
            element-loading-text="Loading"
            border
            fit
            highlight-current-row
            stripe
          >
            <el-table-column
              align="center"
              label="手机号"
              prop="mobile"
              min-width="140"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              align="center"
              label="网点编码"
              prop="websitId"
              min-width="120"
            ></el-table-column>
            <el-table-column
              align="center"
              label="网点名称"
              prop="websitName"
              min-width="160"
            ></el-table-column>
            <el-table-column
              align="center"
              label="职位"
              prop="position"
              min-width="160"
            ></el-table-column>
            <el-table-column
              align="center"
              label="姓名"
              prop="name"
              min-width="160"
            ></el-table-column>
            <el-table-column
              align="center"
              label="账号"
              prop="workerId"
              min-width="160"
            ></el-table-column>
            <el-table-column align="center" label="是否绑定" prop="isBind">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.isBind ? "是" : "否" }}
                </div>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="导入时间"
              prop="createTime"
              min-width="160"
            ></el-table-column>
          </el-table>
        </div>

        <div class="pagination clearfix">
          <div class="fr">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[10, 20, 30, 50]"
              :page-size="10"
              layout="total, sizes, prev, pager, next, jumper"
              :total="listTotal"
            >
            </el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { memberImportMemberList } from "@/api/member";
export default {
  components: {},
  data() {
    return {
      baseURL: process.env.VUE_APP_BASE_API,
      dataList: null, // 列表数据
      listLoading: true, // 列表加载loading
      screenForm: {
        mobile: "",
        position: "",
        websitId: "",
        websitName: "",
        workName: "",
        workUserId: "",
      },
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页数量
      listTotal: 0, // 列表总数
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.listLoading = true;

      let params = {
        ...this.screenForm,
        pageNum: this.currentPage,
        pageSize: this.pageSize,
      };

      memberImportMemberList(params).then((res) => {
        this.dataList = res.data.records;
        this.listTotal = res.data.total;
        this.listLoading = false;
      });
    },
    // 提交筛选表单
    submitScreenForm() {
      this.currentPage = 1;
      this.getList();
    },
    // 重置筛选表单
    resetScreenForm() {
      this.$refs.screenForm.resetFields();
      this.currentPage = 1;
      this.getList();
    },

    // 更改每页数量
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.getList();
    },

    // 更改当前页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getList();
    },
  },
};
</script>

<style lang="scss" scoped>
.el-image-viewer__wrapper .el-icon-circle-close {
  color: #ffffff !important;
  font-size: 60px;
}
.table ::v-deep .el-button {
  padding: 6px 0;
}
</style>
