<template>
  <div class="select-people">
    <el-tab-pane label="设定人员" name="fourth">
      <el-form :inline="true" :model="formPerson" class="demo-form-inline">
        <el-form-item label>
          <el-input
            size="small"
            v-model="formPerson.hospitalName"
            placeholder="请输入机构名称"
          ></el-input>
        </el-form-item>
        <el-form-item label>
          <el-input
            size="small"
            v-model="formPerson.doctorName"
            placeholder="请输入人员名称"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="searchPeople"
            >搜索</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button
            size="small"
            type="primary"
            @click="resetOrgOrPerson('person')"
            >重置</el-button
          >
        </el-form-item>
        <el-form-item style="float: right">
          <el-upload
            v-if="idType == 1 && status4Flag != 1"
            class="upload-excel"
            action="#"
            accept=".xlsx"
            multiple
            :limit="1"
            :before-upload="uploadPerson"
          >
            <el-button size="small">导入人员名单</el-button>
            <template v-slot:tip>
              <el-button
                class="down-button"
                size="small"
                @click="download('person')"
                >下载导入模板</el-button
              >
            </template>
          </el-upload>
          <div v-if="idType == 1 && status4Flag == 1">
            <el-button size="small" @click="dialogUpload = true"
              >导入人员名单</el-button
            >
            <template v-slot:tip>
              <el-button
                class="down-button"
                size="small"
                @click="download('person')"
                >下载导入模板</el-button
              >
            </template>
          </div>
        </el-form-item>
      </el-form>
      <el-table
        class="rim"
        ref="multiplePerson"
        :data="tablePerson"
        tooltip-effect="dark"
        style="width: 100%"
        @select-all="selectAllPerson"
        @select="selectPerson"
      >
        <el-table-column
          type="selection"
          width="55"
          :selectable="selectableTableList"
        ></el-table-column>
        <el-table-column
          prop="name"
          label="人员名称"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="hospitalName"
          label="所属医院"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="departmentName"
          label="所属科室"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="provinceName"
          label="所属省份"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="cityName"
          label="所属城市"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="countyName"
          label="所属区县"
          align="center"
        ></el-table-column>
        <template v-slot:empty>
          <div>
            <div class="table-empty">
              <img src="../../assets/image/no-content1.png" />
              <p>没有人员信息</p>
            </div>
          </div>
        </template>
      </el-table>
      <div class="pagination">
        <el-pagination
          background
          @size-change="handleSizePerson"
          @current-change="handleCurrentPerson"
          :current-page="formPerson.pageNum"
          :page-sizes="[10, 20, 40]"
          :page-size="formPerson.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalPerson"
        ></el-pagination>
      </div>
    </el-tab-pane>
  </div>
</template>

<script>
export default {
  data() {
    return {
      getRowKeysPerson(row) {
        return row.id
      },
      formPerson: {
        hospitalId: 0,
        departmentId: -1,
        doctorName: '',
        hospitalName: '',
        pageNum: 1,
        pageSize: 10,
      },
      hospitalList: [],
      departmentList: [],
      tablePerson: new Array(),
      multipleSelectionPerson: [],
      currentPerson: 1,
      pageSizePerson: 2,
      totalPerson: 10,
      updatedPerson: false,
      lookedPerson: [],
      changedPerson: [],
      changedPerson2: [],
    }
  },
  created() {},
  methods: {
    //选择搜索机构方式
    searchPeople() {
      this.formPerson.pageNum = 1
      let searchForm = this.formPerson
      if (searchForm.hospitalName === '' && searchForm.doctorName === '') {
        this.searchPeopleType = ''
        this.getPeople()
      } else {
        this.searchPeopleType = 'choose'
        this.getPeopleChoose()
      }
    },
  },
}
</script>
