<template>
  <div class="item-shield">
    <bread-crumb :curmbFirst="curmbFirst" :curmbSecond="curmbSecond"></bread-crumb>
    <div class="component-content screenSet" id="screenSet">
      <el-radio-group v-model="shieldType">
        <el-radio-button label="1">屏蔽机构</el-radio-button>
        <el-radio-button label="2">屏蔽人员</el-radio-button>
      </el-radio-group>
      <el-button type="primary" size="small">完成</el-button>
      <el-row :gutter="30" class="row" type="flex" style="margin-top: 10px;">
        <el-form :model="formInline" ref="formInline" label-width="75px" class="form-inline">
          <el-col :span="6">
            <el-form-item label="所属机构：">
              <el-input size="small" v-model="formInline.organizationName" placeholder="请输入机构名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="姓名：">
              <el-input size="small" v-model="formInline.userName" placeholder="请输入人员名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="状态：">
              <el-select size="small" v-model="formInline.status" placeholder="请选择状态">
                <el-option
                  v-for="(item, index) in statusList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" style="padding:0;text-align:right;padding-right:10px;">
            <el-button type="primary" size="small" @click="searchList()">搜索</el-button>
          </el-col>
        </el-form>
      </el-row>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="userName" label="人员名称" min-width="100" align="center"></el-table-column>
        <el-table-column prop="hospitalName" label="所属医院" align="center"></el-table-column>
        <el-table-column prop="departmentName" label="所属科室" align="center" min-width="100"></el-table-column>
        <el-table-column prop="province" label="所属省份" align="center"></el-table-column>
        <el-table-column prop="city" label="所属城市" align="center"></el-table-column>
        <el-table-column prop="county" label="所属区县" align="center"></el-table-column>
        <el-table-column fixed="right" label="状态" width="200" align="center">
          <template slot-scope="scope">{{ scope.row.status | shieldStatus }}</template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="200" align="center">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="changeStatus(scope.row)"
            >{{ scope.row.status | shieldButton }}</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import BreadCrumb from "../../components/breadcrumb.vue";
import { mapGetters } from "vuex";
import { openLoading, closeLoading } from "../../utils/utils";
import * as commonUtil from "../../utils/utils";
let vm = null;
export default {
  components: {
    BreadCrumb
  },
  data() {
    return {
      curmbFirst: "教培项目",
      curmbSecond: "屏蔽",
      shieldType: 1,
      formInline: {
        organizationName: "",
        userName: "",
        status: "",
        pageNo: 1,
        pageSize: 10
      },
      statusList: [
        {
          label: "屏蔽",
          value: 0
        },
        {
          label: "取消屏蔽",
          value: 1
        }
      ],
      tableData: []
    };
  },
  computed: {
    ...mapGetters(["_token"])
  },
  created() {
    vm = this;
    this.search();
  },
  // 挂载到Dom完成时
  mounted: function() {
    commonUtil.resizeHeight();
    window.onbeforeunload = function(e) {
      return "";
    };
  },
  beforeRouteLeave(to, from, next) {
    console.log(from);
    next(false)
    this.$confirm('您将离开本页面，是否进行数据保存？', '提示', {
      distinguishCancelAndClose: true,
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      this.sure();
      next()
    }).catch(() => {
      next()
    });
  },
  beforeDestory() {
    if (this.progressVisible) {
      this.$confirm("系统可能不会保存您所做的更改。", "离开此页面？", {
        confirmButtonText: "离开",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        next();
      });
    } else {
      next();
    }
  },
  methods: {
    searchList() {
      this.formInline.pageNo = 1;
      this.search();
    },
    search() {
      vm.tableData = [
        {
          userName: "云小鹊",
          hospitalName: "测试医院",
          departmentName: "呼吸科",
          province: "上海市",
          city: "上海市",
          county: "浦东新区",
          status: 0
        }
      ];
    },
    changeStatus() {
      vm.tableData[0].status = 1;
    }
  }
};
</script>
<style lang="scss">
.item-shield {
  .component-content {
    padding: 10px;
    background: #fff;
  }
}
</style>