<template>
  <div class="content-box">
    <div class="left">
      <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
      <span class="cameratxt">房间列表</span>
    </div>
    <div class="scroll">
      <div class="middle">
        <div class="filter">
          <div class="condition">
            <el-input
              clearable
              v-model.trim="searchInput.keyWord"
              class="w-50 m-2"
              placeholder="请输入关键字"
              style="width: 180px"
              @clear="searchBtn"
            />
          </div>
          <el-button
            style="margin: 0 30px 0 0"
            color="rgba(0, 97, 255, 1)"
            type="primary"
            class="search"
            @click="searchBtn"
            ><el-icon><Search /></el-icon> <span>查询</span></el-button
          >
          <div class="condition">
            <span>楼栋单元 </span>
            <el-select
              v-model="searchInput.buildingId"
              placeholder="请选择楼栋单元"
              style="width: 200px"
              @change="searchBtn"
              :clearable="true"
            >
              <el-option
                v-for="item in buildData"
                :key="item.id"
                :label="`${item.building}${item.element}`"
                :value="item.id"
              />
            </el-select>
            <!-- <el-cascader
              v-model="searchInput.buildingId"
              :options="buildData"
              :props="defaultProps"
              clearable
              @change="searchBtn"
            /> -->
          </div>
          <div class="condition">
            <span>房型 </span>
            <el-select
              style="width: 180px"
              v-model="searchInput.houseId"
              class="m-2"
              placeholder="请选择房型"
              :clearable="true"
              @change="searchBtn"
            >
              <el-option
                :label="`${i.roomName}(${i.roomType == 1 ? '全' : '钟'})`"
                :value="i.id"
                v-for="i in roomTypeData"
              />
            </el-select>
          </div>
        </div>
        <!-- 按钮列表 -->
        <div class="gongneng">
          <el-button
            type="primary"
            v-if="flagBtn.tianjia == 1"
            color="rgba(0, 97, 255, 1)"
            @click="addlist"
            >添加</el-button
          >
          <el-button
            v-if="flagBtn.daoru == 1"
            color="rgba(41, 109, 227, 1)"
            type="primary"
            class="search"
            @click="bulkImportClick"
            >批量导入</el-button
          >
        </div>
      </div>
      <div class="footer" v-loading="loading">
        <el-table
          :row-class-name="tableRowClassName"
          :data="tableData.list"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          :header-cell-style="{
            background: 'rgba(240, 243, 247, 1)',
            height: '50px',
            border: 0,
          }"
        >
          <!-- <el-table-column align="center" type="selection" width="80" /> -->
          <el-table-column
            width="120"
            align="center"
            label="序号"
            type="index"
            index="1"
          />
          <el-table-column align="center" prop="element" label="单元">
            <template #default="{ row }">
              <span>{{ row.building }}</span
              ><span>{{ row.element }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="roomNumber" label="房号" />
          <el-table-column align="center" prop="houseName" label="房型名称">
            <template #default="{ row }">
              <span>{{ row.roomName }}</span
              ><span style="color: #1e7dfb"
                >({{ row.roomType == 1 ? "全" : "钟" }})</span
              >
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="doorLock"
            label="门锁设备型号"
          />
          <el-table-column
            align="center"
            prop="waterEquipmentMeterName"
            label="水表编码"
          />
          <el-table-column
            align="center"
            prop="electricEquipmentMeterName"
            label="电表编码"
          />

          <el-table-column align="center" label="操作" width="180">
            <template #default="scope">
              <div class="options">
                <div
                  v-if="flagBtn.bianji == 1"
                  class="look"
                  @click="edit(scope.row)"
                >
                  编辑
                </div>
                <el-popconfirm
                  v-if="flagBtn.shanchu == 1"
                  width="220"
                  confirm-button-text="确认"
                  cancel-button-text="取消"
                  :icon="InfoFilled"
                  icon-color="#f89626"
                  title="是否删除此房间?"
                  @confirm="del(scope.row)"
                  @cancel="cancelEvent"
                >
                  <template #reference>
                    <div class="del">删除</div>
                  </template>
                </el-popconfirm>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页组件 -->
        <div class="pageSize">
          <span></span>
          <el-pagination
            background
            :current-page="currentPage"
            :page-size="pageSize"
            layout="total, prev, pager, next, jumper, slot"
            :total="total"
            @update:current-page="handleCurrentChange"
          />
        </div>
        <!-- 添加账号弹窗 -->
        <el-dialog
          class="addStaff"
          v-model="addDialogVisible"
          :close-on-click-modal="false"
          :close-on-press-escape="false"
          :title="dialongTitle"
          align-center
          width="609"
          :before-close="cancelAdd"
        >
          <el-form
            ref="ruleFormRef"
            :model="ruleForm"
            :rules="rules"
            label-width="120px"
            class="demo-ruleForm"
            :size="formSize"
            label-position="left"
            status-icon
          >
            <el-form-item label="房型名称 :" prop="status">
              <el-select
                style="width: 200px"
                v-model="ruleForm.status"
                class="m-2"
                placeholder="请选择房型"
              >
                <el-option
                  :label="`${i.roomName}(${i.roomType == 1 ? '全' : '钟'})`"
                  :value="i.id"
                  v-for="i in roomTypeData"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="楼栋单元 :" prop="building">
              <el-select
                v-model="ruleForm.building"
                placeholder="请选择楼栋单元"
                style="width: 200px"
                :clearable="true"
              >
                <el-option
                  v-for="item in buildData"
                  :key="item.id"
                  :label="`${item.building}${item.element}`"
                  :value="item.id"
                />
              </el-select>
              <!-- <el-cascader
                v-model="ruleForm.building"
                :options="buildData"
                :props="buildProps"
                clearable
                filterable
              /> -->
            </el-form-item>
            <el-form-item label="房号 :" prop="roomNum">
              <el-input
                v-model.trim="ruleForm.roomNum"
                placeholder="请输入房号"
                clearable
              />
            </el-form-item>
            <el-form-item label="门锁设备型号 :" prop="doorLock">
              <el-input
                v-model.trim="ruleForm.doorLock"
                placeholder="请输入门锁设备型号"
                clearable
              />
            </el-form-item>
            <el-form-item label="水表编码 :" prop="water">
              <el-input
                v-model.trim="ruleForm.water"
                placeholder="请输入水表编码"
                clearable
              />
            </el-form-item>
            <el-form-item label="电表编码 :" prop="electric">
              <el-input
                v-model.trim="ruleForm.electric"
                placeholder="请输入电表编码"
                clearable
              />
            </el-form-item>
            <!-- <el-form-item label="角色 :" prop="adminMenuId">
              <el-tree
                style="max-width: 600px"
                :data="roleData"
                ref="editMemberTree"
                show-checkbox
                default-expand-all
                check-strictly
                node-key="id"
                :props="defaultProps"
                @check="editMemberCheckChange"
              />
            </el-form-item> -->
            <el-form-item class="options">
              <el-button
                color="rgba(0, 97, 255, 1)"
                class="queding"
                type="primary"
                @click="submitAdd(ruleFormRef)"
              >
                确认
              </el-button>
              <el-button @click="cancelAdd(ruleFormRef)">取消</el-button>
            </el-form-item>
          </el-form>
        </el-dialog>

        <!-- 批量导入 -->
        <el-dialog
          class="bulkImportDialog"
          v-model="bulkImportVisible"
          :close-on-click-modal="false"
          :close-on-press-escape="false"
          title="批量导入"
          align-center
          width="570"
          :before-close="cancelBulkImport"
        >
          <div class="middle">
            <el-upload
              style="width: 500px"
              class="upload-demo"
              ref="bulkImportref"
              drag
              action="#"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :on-change="handleChange"
              :http-request="handleUpload"
              :before-upload="beforeAvatarUpload"
              :limit="1"
              :on-exceed="handleExceed"
            >
              <el-icon class="el-icon--upload"><upload-filled /></el-icon>
              <div class="el-upload__text">
                <span style="font-size: 20px">点击上传或拖拽文件</span><br />
                <em>请按照标准模板填写信息</em><br />
                <em>&nbsp;</em>
              </div>
              <!-- <template #tip>
            <div class="el-upload__tip">
              jpg/png files with a size less than 500kb
            </div>
          </template> -->
            </el-upload>
            <div class="startImport">
              <el-button
                v-if="bulkImportFile"
                type="primary"
                color="rgba(0, 97, 255, 1)"
                style="width: 200px"
                @click="bulkImportConfig"
                plain
                >开始导入</el-button
              >
              <span
                v-else
                type="primary"
                color="rgba(236, 245, 255, 1)"
                style="
                  display: inline-block;
                  width: 200px;
                  height: 42px;
                  text-align: center;
                  line-height: 42px;
                  color: rgb(160, 207, 255);
                  border: 1px solid #dcdfe6;
                  border-radius: 4px;
                "
                plain
                >开始导入</span
              >
              <span
                style="
                  width: 120px;
                  margin-left: 20px;
                  cursor: pointer;
                  color: rgba(0, 97, 255, 1);
                "
                @click="resetImport"
                >重置</span
              >
              <span class="downLoad" @click="downbulkImport">下载模板</span>
            </div>
            <!-- <div class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="bulkImportConfig"
            >
              确定
            </el-button>
            <el-button @click="cancelBulkImport">取消</el-button>
          </div> -->
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script setup>
import {
  ref,
  watch,
  reactive,
  nextTick,
  onBeforeMount,
  onUnmounted,
} from "vue";
import { useRouter } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import { Calendar } from "@element-plus/icons-vue";
import { dayjs } from "element-plus";
import lodash, { reduce } from "lodash";
import axios from "axios";
import { useStore } from "vuex";
const store = useStore();
const router = useRouter();
// 表格数据
const loading = ref(false);
const tableData = reactive({
  list: [],
});
const activeIndex = ref(); // 默认跳转路由
const dialongTitle = ref("新增账号"); // 弹窗标题

const searchInput = reactive({
  keyWord: "", // 房型
  buildingId: "", // 房型
  houseId: "", // 楼栋
}); // 搜索按钮数据
const defaultProps = {
  children: "buildings",
  label: "element",
  value: "id",
  // checkStrictly: true,
};
const buildProps = {
  children: "buildings",
  label: "element",
  value: "id",
};
const roomTypeData = ref(); // 房型数据
const buildData = ref(); // 楼栋数据
const flagBtn = ref(); // 按钮权限

watch(
  () => searchInput.createTime,
  (newVal, oldVal) => {
    console.log("监听时间:", newVal);
    if (newVal == null) {
      getList();
    }
  }
);

const api = ref("");
const currentPage = ref(1); // 当前页
const pageSize = ref(10);
const total = ref(); // 当前总数

// 批量导入 (--------------------------------------------------------）
const bulkImportVisible = ref(false);
const uploadFileShow=ref(false)
const bulkImportref=ref()
const bulkImportFile=ref()

// 控制添加账号弹窗--------------------------------------------------
const addDialogVisible = ref(false); // 控制添加账号弹窗
const editMemberTree = ref(); // 角色ref
const roleData = ref(); // 角色列表

// 表单数据
const formSize = ref("default");
const ruleFormRef = ref();
const ruleForm = reactive({
  status: "", // 房型
  building: "", // 楼栋单元
  roomNum: "", // 房号
  doorLock: "", // 门锁型号
  water: "", // 水表
  electric: "", // 电表
  id: "",
});
var checkFullName = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入姓名"));
  }

  var reg = /^[\u4e00-\u9fa5]{2,6}$/;
  if (!reg.test(value)) {
    callback(new Error("必须为2-6个汉字！"));
  } else {
    callback();
  }
};
var checkPhone = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入手机号"));
  }
  setTimeout(() => {
    var reg = /^1[3456789]\d{9}$/;
    if (!reg.test(value)) {
      callback(new Error("手机号格式不对"));
    } else {
      callback();
    }
  }, 100);
};
// 表单验证
const rules = reactive({
  status: [{ required: true, message: "房型不能为空", trigger: "blur" }],
  building: [{ required: true, message: "楼栋单元不能为空", trigger: "blur" }],
  roomNum: [{ required: true, message: "房号不能为空", trigger: "blur" }],
  // ^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\._\+(){}])[0-9a-zA-Z!@#$%^&*,\\._\+(){}]{8,20}$
  // doorLock: [
  //   {
  //     required: true,
  //     message: "门锁型号不能为空",
  //     trigger: "blur",
  //   },
  // ],
  water: [
    {
      required: true,
      message: "水表不能为空",
      trigger: "blur",
    },
  ],
  electric: [
    {
      required: true,
      message: "电表不能为空",
      trigger: "blur",
    },
  ],
  // desc: [{ required: true, message: "Please input activity form", trigger: "blur" }],
});

// 获取账户列表
const getList = async () => {
  loading.value = true;
  let data = {
    page: currentPage.value, // 当前页
    size: pageSize.value, // 一页数据条数
    keyWord: searchInput.keyWord,
    houseId: searchInput.houseId,
  };
  if (searchInput.buildingId) {
    data.buildingId = searchInput.buildingId;
  }
  let res = await axios({
    method: "get",
    url: api.value + "/house-number/listHouseNumber",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("user_head"),
    },
    params: data,
  });
  console.log(res, "房间列表");
  if (res.data.code == 200) {
    tableData.list = res.data.data.list;
    total.value = res.data.data.totalCount;
    loading.value = false;
    // ElMessage({
    //   type: "success",
    //   showClose: true,
    //   message: res.data.message,
    //   center: true,
    // });
  } else {
    loading.value = false;
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 楼栋单元数据
const schoolData = async () => {
  let res = await axios({
    method: "get",
    url: api.value + "/building/beDisplayBar",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("user_head"),
    },
  });
  console.log(res, "楼栋单元下拉框");
  if (res.data.code == 200) {
    buildData.value = res.data.data;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 房型列表数据
const roomTypeList = async () => {
  let res = await axios({
    method: "get",
    url: api.value + "/house/displayBar",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("user_head"),
    },
  });
  console.log(res, "房型列表数据");
  if (res.data.code == 200) {
    roomTypeData.value = res.data.data;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 搜索功能
const searchBtn = lodash.debounce(async () => {
  getList();
}, 300);

// 批量导入(-----------------------------------------------------------------)
const bulkImportClick = () => {
  bulkImportVisible.value = true;
  bulkImportFile.value = "";
  nextTick(()=>{
    bulkImportref.value.clearFiles();
  })
};
// 移出照片
const handleRemove = (uploadFile, uploadFiles) => {
  bulkImportFile.value = "";
};
// 点击图片的查看按钮
const handlePreview = (file) => {
  console.log(file);
};
// 限制上传图片的大小
const beforeAvatarUpload = (rawFile) => {
  console.log(rawFile.type, "文件类型");
  if (
    rawFile.type !==
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  ) {
    ElMessage.error("文件格式必须为xlsx格式!");
    return false;
  } else if (rawFile.size / 1024 / 1024 > 100) {
    ElMessage.error("文件的大小不能超过100MB!");
    return false;
  }
  return true;
};
// 添加照片时往fileList列表中添加图片信息
const handleChange = async (file, fileLists) => {
  console.log(file, "1111");
  // fileList.list.push(file);
  bulkImportFile.value = file.raw;
  uploadFileShow.value=true
};
// 可以获取图片参数
const handleUpload = async (file) => {
  // if (fileList.list.length >= 6) {
  //   ElMessage.error("最多可上传6张图片!");
  //   return false;
  // }
  console.log(file, "22222222");
  // let data = new FormData();
  // data.set("files", file.file);
  // let res = await axios({
  //   method: "post",
  //   url: api.value + "/file/cos/upload",
  //   headers: {},
  //   data: data,
  // });
  // console.log(res, "图片上传成功详情图");
  // if (res.data.code == 1) {
  //   // res.data.data.uid = file.file.uid;
  //   // console.log([res.data.data]);
  //   let arr = {
  //     uid: file.file.uid,
  //     url: res.data.data,
  //   };

  //   fileList.list = fileList.list.concat([arr]);
  //   ruleForm.fileListJson = fileList.list;
  // }
};
// 上传文件时覆盖上一个文件
const handleExceed = (files) => {
  bulkImportref.value.clearFiles();
  const file = files[0];
  file.uid = genFileId();
  bulkImportref.value.handleStart(file);
};
// 重置按钮 重置上传文件
const resetImport = () => {
  bulkImportFile.value = "";
  bulkImportref.value.clearFiles();
};
// 下载模板
const downbulkImport=async ()=>{
  let res = await axios({
      method: "get",
      url: api.value + "/house-number/houseNumberExport",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      responseType: "blob",
    });
    console.log(
      res,
      "批量导入模板下载"
    );
    if (res.status == 200) {
      let name = `房间列表模板`;
      var content = res.data;
      var datas = new Blob([content]);
      var downloadUrl = window.URL.createObjectURL(datas);
      var anchor = document.createElement("a");
      anchor.href = downloadUrl;
      anchor.download = name + ".xlsx";
      anchor.click();
      window.URL.revokeObjectURL(datas);
      ElMessage({
        type: "success",
        showClose: true,
        message: "下载成功",
        center: true,
      });
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
}
// 确定导入 
const bulkImportConfig=async () =>{
  let data=new FormData();
  data.append('file',bulkImportFile.value)
  let res = await axios({
    method: "post",
    url: api.value + "/house-number/importHouseNumbers",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data:data
  });
  console.log(
    res,
    "确定导入"
  );
  if (res.data.code == 200) {
    getList()
    bulkImportVisible.value = false;
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
}
const cancelBulkImport = () => {
  bulkImportVisible.value = false;
};

// 添加账号 --------------------------------------
const addlist = () => {
  dialongTitle.value = "新增房间号";
  addDialogVisible.value = true;
  ruleForm.status = "";
  ruleForm.building = "";
  ruleForm.roomNum = "";
  ruleForm.doorLock = "";
  ruleForm.water = "";
  ruleForm.electric = "";
  ruleForm.id = "";
};

// 取消添加员工
const cancelAdd = () => {
  addDialogVisible.value = false;
  ruleForm.id = "";
  ruleFormRef.value.resetFields();
};
//编辑按钮
const edit = (row) => {
  dialongTitle.value = "编辑房间号";
  addDialogVisible.value = true;
  ruleForm.status = Number(row.houseId);
  ruleForm.building = row.buildingId;
  ruleForm.roomNum = row.roomNumber;
  ruleForm.doorLock = row.doorLock;
  ruleForm.water = row.waterEquipmentMeterName;
  ruleForm.electric = row.electricEquipmentMeterName;
  ruleForm.id = row.id;
  // nextTick(() => {
  //   editMemberTree.value.setCheckedKeys([row.adminMenu.id]);
  // });
};
// 确认添加房间列表
const submitAdd = lodash.debounce(async (formEl) => {
  if (!formEl) return;
  await formEl.validate(async (valid, fields) => {
    if (valid) {
      if (ruleForm.id) {
        let data = {
          id: ruleForm.id,
          buildingId: ruleForm.building, //楼栋单元id
          houseId: ruleForm.status, //房型id
          roomNumber: ruleForm.roomNum, //房间号
          electricEquipmentMeterName: ruleForm.electric, //电表编码
          waterEquipmentMeterName: ruleForm.water, //水表编码
          doorLock: ruleForm.doorLock, //门锁
        };
        let res = await axios({
          method: "post",
          url: api.value + "/house-number/updateHouseNumber",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("user_head"),
          },
          data: data,
        });
        console.log(res, "编辑账号");
        if (res.data.code == 200) {
          getList();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
          addDialogVisible.value = false;
          ruleFormRef.value.resetFields();
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      } else {
        let data = {
          buildingId: ruleForm.building, //楼栋单元id
          houseId: ruleForm.status, //房型id
          roomNumber: ruleForm.roomNum, //房间号
          electricEquipmentMeterName: ruleForm.electric, //电表编码
          waterEquipmentMeterName: ruleForm.water, //水表编码
          doorLock: ruleForm.doorLock, //门锁
        };
        console.log(data);
        let res = await axios({
          method: "post",
          url: api.value + "/house-number/saveHouseNumber",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("user_head"),
          },
          data: data,
        });
        console.log(res, "添加房间列表");
        if (res.data.code == 200) {
          getList();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
          addDialogVisible.value = false;
          ruleFormRef.value.resetFields();
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    } else {
      console.log("error submit!", fields);
    }
  });
}, 1000);

//删除按钮
const del = async (row) => {
  // console.log(row);
  let data = {
    houseNumberId: row.id,
  };
  let res = await axios({
    method: "get",
    url: api.value + "/house-number/deleteHouseNumber",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("user_head"),
    },
    params: data,
  });
  if (res.data.code == 200) {
    if (tableData.list.length == 1 && currentPage.value != 1) {
      currentPage.value = currentPage.value - 1;
    }
    getList();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
  // console.log(res);
};
// 取消删除
const cancelEvent = () => {
  ElMessage({
    type: "info",
    showClose: true,
    message: "取消删除",
    center: true,
  });
};
// 重置密码
const reset = async (row) => {
  // console.log(row);
  let data = {
    id: row.id,
  };
  let res = await axios({
    method: "post",
    url: api.value + "/mhotel/managerAdminremovePwd.action",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  if (res.data.code == 200) {
    getList();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 多选框功能
// const handleSelectionChange = (val) => {
//   console.log(val);
//   selectData.list = val;
// };

// 表格斑马纹颜色修改
const tableRowClassName = ({ row, rowIndex }) => {
  if (rowIndex % 2 === 0) {
    return "even";
  } else if (rowIndex % 2 !== 0) {
    return "odd";
  }
  return "";
};
// 分页
const handleCurrentChange = (value) => {
  // console.log(value);
  currentPage.value = value;
  getList();
};

onBeforeMount(() => {
  api.value = store.state.user.api;
  const btnflag = JSON.parse(sessionStorage.getItem("btnflag"));
  flagBtn.value = btnflag.roomList;
  console.log(flagBtn.value, "按钮权限");

  getList();
  roomTypeList();
  schoolData();
});
onUnmounted(() => {
  // document.removeEventListener("keyup", Enters);
});
</script>

<style scoped lang="scss">
.content-box {
  width: calc(100% - 40px);
  height: calc(100% - 105px);
  margin: 20px auto;
  background-color: #fff;
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0px 3px 10px rgba(0, 97, 255, 0.2);

  .left {
    // width: calc(100wh - 40px);
    display: flex;
    align-items: center;
    height: 60px;
    margin: 0 30px;
    border-bottom: 1px solid #ccc;
    color: #000;
    font-size: 18px;
    font-weight: 600;
    .camera {
      margin-right: 15px;
      color: #4392f7;
    }
  }
  .scroll {
    width: calc(100%);
    height: calc(100% - 61px);
    display: flex;
    flex-direction: column;
    overflow: auto;
  }
  .middle {
    width: calc(100% - 60px);
    margin: 0 auto;

    color: #000;
    // border-bottom: 1px solid rgb(231, 231, 231);
    .filter {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      // margin: 10px 0 0 0;
      .search {
        margin-left: 0 !important;
        color: #fff;
      }
      .condition {
        display: flex;
        align-items: center;
        margin: 10px 30px 10px 0;
        :deep(.el-input .el-input__inner) {
          font-size: 14px;
        }
        span {
          margin: 0 10px 0 0;
        }
      }
    }
    .gongneng {
      margin: 10px 0;
      .el-button {
        color: #fff;
        margin-right: 15px;
      }
    }
    :deep(.cont) {
      width: 60%;
      margin: 20px auto;
    }
    :deep(.download) {
      display: flex;
      align-items: center;
      margin: 10px;
    }
    :deep(.download span) {
      font-size: 16px;
      margin-left: 20px;
    }
    :deep(.cont .el-button) {
      margin-left: 60px;
      margin-bottom: 30px;
    }

    :deep(.cont .accomplish) {
      width: 100%;
      display: flex;
      justify-content: center;
    }
    :deep(.cont .accomplish .el-button) {
      width: 50%;
      margin: 0;
    }
  }
  .footer {
    width: calc(100% - 60px);
    flex: 1;
    margin: 0 auto;
    overflow:auto;
    .el-table--fit {
      height: calc(100% - 60px);
      :deep(.el-table__header-wrapper) {
        background-color: #000;
        font-size: 15px;
        color: #000;
        .cell {
          color: #000;
        }
      }
      :deep(.el-table__row) {
        height: 50px;
        font-size: 15px;
        color: #000;
      }
      :deep(.el-table__row td) {
        padding: 0;
        border: 0;
      }

      .el-button--primary {
        margin-left: 5px;
      }
      :deep(.el-table__body .even) {
        background-color: #fff;
      }
      :deep(.el-table__body .odd) {
        background-color: rgba(240, 243, 247, 1);
      }
      :deep(.options) {
        display: flex;
        justify-content: center;
        align-items: center;
        .reset {
          color: rgba(9, 101, 98, 1);
          cursor: pointer;
        }
        .look {
          margin: 0 15px;
          color: rgba(30, 125, 251, 1);
          cursor: pointer;
        }
        .del {
          color: rgba(212, 48, 48, 1);
          cursor: pointer;
        }
      }
    }

    // 添加员工弹窗样式
    :deep(.addStaff) {
      //   height: 420px;
      border-radius: 11px;
      .el-dialog__header {
        border-radius: 11px 11px 0 0;
        background: rgba(237, 241, 245, 1);
        font-weight: 600;
        margin: 0;
        .el-dialog__headerbtn {
          outline: none;
        }
      }
      .el-dialog__body {
        padding: 20px 20px 10px 20px;
        .el-input {
          width: 200px;
          .el-input__suffix-inner {
            color: rgba(61, 81, 232, 1);
          }
        }

        .options {
          margin: 10px 20px 20px 0;
          width: 100%;
          .el-form-item__content {
            display: flex;
            flex-direction: row-reverse;
          }
          .queding {
            color: #fff;
            margin-left: 15px;
          }
        }
      }
    }
    // 批量导入
    :deep(.bulkImportDialog) {
      // height: 600px;
      overflow: hidden;
      border-radius: 11px;

      .el-dialog__header {
        border-radius: 11px 11px 0 0;
        background: rgba(245, 249, 255, 1);
        font-weight: 600;
        height: 60px;
        padding: 0 20px;
        line-height: 60px;
        margin: 0;
        border-bottom: 1px solid rgba(230, 230, 230, 1);

        .el-dialog__headerbtn {
          outline: none;
        }
      }

      .el-dialog__body {
        padding: 20px 0 30px 0;
        // height: 200px;
        // display: flex;
        // flex-direction: column-reverse;

        .middle {
          width: calc(100% - 40px);
          color: #000;
          .content {
            height: 100px;
            padding: 50px 0 0 20px;
            font-size: 16px;
            letter-spacing: 1px;
          }
          .options {
            display: flex;
            flex-direction: row-reverse;
            align-items: center;
            margin: 10px 0;

            .queding {
              margin-left: 20px;
            }
          }
          .startImport {
            .el-button {
              width: 500px;
              height: 42px;
            }
            .downLoad {
              color: rgba(0, 97, 255, 1);
              font-size: 14px;
              margin-left: 15px;
              cursor: pointer;
            }
          }
        }
      }
    }
  }

  .pageSize {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 30px;
    height: 60px;

    span {
      color: #000;
    }

    .el-pagination {
      // width: 1600px;
      :deep(.el-pagination__total) {
        color: #000;
      }

      :deep(.el-pagination__goto) {
        color: #000;
      }

      :deep(.el-pagination__classifier) {
        color: #000;
      }

      :deep(.el-input__wrapper) {
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        box-shadow: none;
      }

      :deep(.el-pager li) {
        margin: 0 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.el-pager li.is-active) {
        // background-color: rgba(0, 97, 255, 0.8);
        border: 1px solid rgba(0, 97, 255, 1);
        color: rgba(0, 97, 255, 1);
      }

      :deep(.btn-prev) {
        margin-right: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.btn-next) {
        margin-left: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }
    }
  }
}
.el-input {
  width: 192px;
}
</style>
<style lang="scss">
//添加成员 联系人下拉框样式
.more-tag-data {
  // border: 1px solid red;
  .el-select-dropdown__wrap {
    height: 200px;
  }
}
.el-popper {
  .addStudentMore {
    text-align: center;
  }
}
</style>
