<template>
  <div class="m-container">
    <h2>
      <div class="squrt"></div>
      申请机构
    </h2>
    <div class="m-core">
      <save-form
        :inline="true"
        class="searchForm"
        ref="searchForm"
        @submit="search"
        @reset="reset"
        :saveKey="'tenantApply'"
        :model.sync="searchForm"
      >
        <el-form-item prop="name">
          <el-input
            v-model="searchForm.name"
            clearable
            placeholder="机构名称"
          ></el-input>
        </el-form-item>
        <el-form-item prop="createTimer">
          <el-date-picker
            v-model.trim="searchForm.createTimer"
            clearable
            type="daterange"
            range-separator="至"
            start-placeholder="申请开始时间"
            end-placeholder="申请结束时间"
            :default-time="['00:00:00', '23:59:59']"
            :picker-options="{ firstDayOfWeek: 1 }"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button native-type="submit" type="danger">搜索</el-button>
          <el-button native-type="reset" type="primary">重置</el-button>
        </el-form-item>
      </save-form>
      <!-- 列表 -->
      <div class="tableWrap">
        <el-table
          :data="tableList"
          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
        >
          <el-table-column align="center" label="所在城市" prop="city">
          </el-table-column>
          <el-table-column align="center" label="机构名称" prop="name">
          </el-table-column>
          <el-table-column align="center" label="联系人" prop="linkman">
          </el-table-column>
          <el-table-column align="center" label="联系人电话" prop="mobileNo">
          </el-table-column>
          <el-table-column align="center" label="申请时间" prop="createTime">
          </el-table-column>
          <!-- <el-table-column align="center" label="推荐人姓名" prop="productName">
          </el-table-column>
          <el-table-column align="center" label="上次沟通时间" prop="productName">
          </el-table-column>
          <el-table-column align="center" label="沟通结果" prop="productName">
          </el-table-column>
          <el-table-column align="center" label="沟通人" prop="productName">
          </el-table-column> -->
          <!-- <el-table-column align="center" label="操作">
            <template slot-scope="scope">
              <el-button
                @click="openService('update', scope.row)"
                v-permission="'platformServe/update'"
                type="text"
                >修改
              </el-button>
              <el-button
                @click="delService(scope.row)"
                v-permission="'platformServe/delete'"
                type="text"
                >删除</el-button
              >
            </template>
          </el-table-column> -->
        </el-table>
        <pagination
          :saveKey="'tenantApply'"
          sync
          :total.sync="pageInfo.total"
          :page.sync="pageInfo.page"
          :limit.sync="pageInfo.limit"
          :page-sizes="pageInfo.page_size"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>
<script>
import pagination from "@/components/Pagination/index";
import {
  tenantApplyList
} from "./api";
import { getTimes } from "@/utils";
const initSearch = {
  name: null,
  createTimer: null,
};
export default {
  components: {
    pagination
  },
  data() {
    return {
      tableList: [],
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
      searchForm: {
        ...initSearch
      },
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    async getList() {
      try {
        const { name, createTimer } = this.searchForm
        const res = await tenantApplyList({
          name: name,
          ...getTimes(createTimer, ["startDateTime", "endDateTime"], "YYYY-MM-DD HH:mm:ss"),
          page: this.pageInfo.page,
          rows: this.pageInfo.limit,
        });
        this.pageInfo.total = res.data.total;
        this.tableList = res.data.rows;
      } catch (e) {}
    },
    search() {
      this.pageInfo.page = 1;
      this.$refs.searchForm.save(this.searchForm);
      this.$refs.searchForm.save(this.pageInfo, "page");
      this.getList();
    },
    reset() {
      this.searchForm = {
        ...initSearch
      };
      this.search();
    },
  },
};
</script>
<style lang="scss" scoped>
.courseMask .el-dialog__body {
  padding-bottom: 0;
}
</style>
