<template>
  <div class="content-box">
    <div class="left">
      <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
      <div class="cameratxt" @click="getList(1)" :class="themeIndex == 1 ? 'is_active' : ''">黑名单管理</div>
      <div class="cameratxt" @click="getList(2)" :class="themeIndex == 2 ? 'is_active' : ''">爽约记录</div>
    </div>
    <div v-if="themeIndex == 1">
      <div class="middle">
        <div class="filter">
          <div class="condition">
            <span>关键字 : </span>
            <el-input clearable @clear="searchBtn" v-model="searchInput.carnumber" class="w-50 m-2" placeholder="请输入关键字查询"
              style="width: 150px" />
          </div>
          <div class="condition">
            <span>创建时间 : </span>
            <el-date-picker v-model="searchInput.createTime" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD"
              :prefix-icon="Calendar" placeholder="请选择时间" />
          </div>


          <el-button style="margin-left: 20px" color="rgba(61, 81, 232, 1)" type="primary" class="search"
            @click="searchBtn"><el-icon>
              <Search />
            </el-icon> <span>查询</span></el-button>
          <el-button style="margin-left: 20px !important" color="rgba(61, 81, 232, 1)" type="primary" class="search"
            @click="searchRefresh"><el-icon>
              <Refresh />
            </el-icon><span>重置</span></el-button>
        </div>
      </div>
      <div class="footer">
        <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="150" align="center" label="序号" type="index" index="1" />
          <el-table-column align="center" prop="user_name" label="姓名" />
          <el-table-column align="center" prop="user_phone" label="手机" />
          <el-table-column align="center" prop="contain" label="爽约次数" />
          <el-table-column align="center" prop="yy_time" label="创建时间" width="250" />

          <el-table-column align="center" label="操作" width="220">
            <template #default="scope">
              <el-button type="primary" plain @click="edit(scope.row)">
                <div class="look">详情</div>
              </el-button>
              <el-button type="danger" plain @click="del(scope.row)">
                <div class="look">移出</div>
              </el-button>
            </template>
          </el-table-column>
        </el-table>

        <!-- 添加车辆弹窗 -->
        <!-- <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="100px"
          class="demo-ruleForm"
          :size="formSize"
          label-position="left"
          status-icon
        >
          <el-form-item label="账号 :" prop="account">
            <el-input
              v-model="ruleForm.account"
              placeholder="请输入账号"
              clearable
            />
          </el-form-item>
          <el-form-item label="密码 :" prop="pass">
            <el-input
              v-model="ruleForm.pass"
              placeholder="请输入密码"
              clearable
            />
          </el-form-item>
          <el-form-item
            label="昵称 :"
            prop="name"
            style="
              padding-bottom: 40px;
              border-bottom: 1px solid rgba(230, 230, 230, 1);
            "
          >
            <el-input
              v-model="ruleForm.name"
              placeholder="请输入昵称"
              clearable
            />
          </el-form-item>

          <el-form-item class="options">
            <el-button class="congzhi" @click="cancelAdd()">取消</el-button>
            <el-button
              color="rgba(61, 81, 232, 1)"
              class="queding"
              type="primary"
              @click="submitAdd(ruleFormRef)"
            >
              确定
            </el-button>
          </el-form-item>
        </el-form>
      </el-dialog> -->
      </div>
    </div>
    <div v-if="themeIndex == 2">
      <div class="middle">
        <div class="filter">
          <div class="condition">
            <span>姓名 : </span>
            <el-input @clear="searchBtn" @input="searchBtn" clearable v-model="searchInput2.user_name" class="w-50 m-2"
              placeholder="请输入姓名" style="width: 150px" />
          </div>
          <div class="condition">
            <span>电话 : </span>
            <el-input @clear="searchBtn" @input="searchBtn" clearable v-model="searchInput2.user_phone" class="w-50 m-2"
              placeholder="请输入号码" style="width: 150px" />
          </div>
          <div class="condition">
            <span>车牌号 : </span>
            <el-select clearable @clear="searchBtn" @change="changeCarNum" v-model="searchInput2.carnumber" class="m-2"
              placeholder="请选择车牌号">
              <el-option v-for="item in busNum.list" :label="item.car_number" :value="item.car_number" />
            </el-select>
            <!-- <el-input @clear="searchBtn" clearable v-model="searchInput2.carnumber" class="w-50 m-2" placeholder="请输入车牌号"
              style="width: 150px" /> -->
          </div>
          <div class="condition">
            <span>发车日期 : </span>
            <el-date-picker @change="changeCarNum" v-model="searchInput2.yy_date" type="date" format="YYYY-MM-DD"
              value-format="YYYY-MM-DD" :prefix-icon="Calendar" placeholder="请选择发车日期" />
          </div>
          <div class="condition">
            <span>路线 : </span>
            <!-- <el-date-picker v-model="searchInput2.yy_date" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD"
              :prefix-icon="Calendar" placeholder="请选择发车日期" /> -->
            <el-select clearable @clear="searchBtn" @change="changeCarNum" v-model="searchInput2.route" class="m-2"
              placeholder="请选择车牌号">
              <el-option label="墨轩湖校区-黄家湖校区" value="墨轩湖校区-黄家湖校区" />
              <el-option label="黄家湖校区-墨轩湖校区" value="黄家湖校区-墨轩湖校区" />
            </el-select>
          </div>
          <div class="condition">
            <span>车次 : </span>
            <el-time-picker @change="changeCarNum" :prefix-icon="Calendar" v-model="searchInput2.ci_time" format="HH:mm"
              value-format="HH:mm" placeholder="请选择车次时间" />
          </div>
          <!-- <div class="condition button">
            <el-button color="rgba(61, 81, 232, 1)" type="primary" @click="searchBtn"><el-icon>
                <Search />
              </el-icon> <span>查询</span></el-button>
          </div> -->
          <div class="condition button">
            <el-button color="rgba(61, 81, 232, 1)" type="primary" @click="searchRefresh"><el-icon>
                <Refresh />
              </el-icon><span>重置</span></el-button>
          </div>
          <div class="condition button">
            <el-tooltip class="box-item" effect="dark" content="根据筛选条件批量移除，如无筛选条件将移除全部违约" placement="top">
              <el-button color="rgba(61, 81, 232, 1)" type="primary" @click="allReast">批量移出</el-button>
            </el-tooltip>
          </div>
        </div>

      </div>
      <div class="footer">
        <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 align="center" label="序号" type="index" index="1" width="80" />
          <el-table-column align="center" prop="user_name" label="姓名" />
          <el-table-column align="center" prop="user_phone" label="手机" />
          <el-table-column align="center" prop="car_number" label="车牌号" />
          <el-table-column align="center" prop="route" label="路线" width="200" />
          <el-table-column align="center" prop="yy_date" label="发车日期" />
          <el-table-column align="center" prop="ci_time" label="车次" width="120" />
          <!-- <el-table-column align="center" prop="contain" label="爽约次数" width="80" /> -->
          <el-table-column align="center" prop="yy_time" label="创建时间" width="220" />

          <el-table-column align="center" label="操作" width="150">
            <template #default="scope">
              <!-- <el-button type="primary" plain @click="edit(scope.row)">
                <div class="look">详情</div>
              </el-button> -->
              <el-button type="danger" plain @click="delOne(scope.row)">
                <div class="look">移出</div>
              </el-button>
            </template>
          </el-table-column>
        </el-table>

        <!-- 添加车辆弹窗 -->
        <!-- <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="100px"
          class="demo-ruleForm"
          :size="formSize"
          label-position="left"
          status-icon
        >
          <el-form-item label="账号 :" prop="account">
            <el-input
              v-model="ruleForm.account"
              placeholder="请输入账号"
              clearable
            />
          </el-form-item>
          <el-form-item label="密码 :" prop="pass">
            <el-input
              v-model="ruleForm.pass"
              placeholder="请输入密码"
              clearable
            />
          </el-form-item>
          <el-form-item
            label="昵称 :"
            prop="name"
            style="
              padding-bottom: 40px;
              border-bottom: 1px solid rgba(230, 230, 230, 1);
            "
          >
            <el-input
              v-model="ruleForm.name"
              placeholder="请输入昵称"
              clearable
            />
          </el-form-item>

          <el-form-item class="options">
            <el-button class="congzhi" @click="cancelAdd()">取消</el-button>
            <el-button
              color="rgba(61, 81, 232, 1)"
              class="queding"
              type="primary"
              @click="submitAdd(ruleFormRef)"
            >
              确定
            </el-button>
          </el-form-item>
        </el-form>
      </el-dialog> -->
      </div>
    </div>
    <!-- 黑名单详情 -->
    <el-dialog class="addStaff particulars" v-model="blackDialog" :close-on-click-modal="false"
      :close-on-press-escape="false" title="黑名单爽约记录详情" align-center width="1200" :before-close="particularsCancel">
      <el-table :row-class-name="tableRowClassName" :data="blackData.list"
        style="width: 100%; height: 490px; margin-bottom: 20px" :header-cell-style="{
          background: 'rgba(240, 243, 247, 1)',
          height: '50px',
          border: 0,
        }">
        <el-table-column width="150" align="center" prop="user_name" label="姓名" />
        <el-table-column width="150" align="center" prop="yy_time" label="下单日期" />
        <el-table-column width="150" align="center" prop="yy_date" label="发车日期" />
        <el-table-column width="100" align="center" prop="ci_time" label="发车时间" />

        <el-table-column align="center" width="150" prop="car_number" label="车牌号" />
        <el-table-column align="center" prop="route" label="线路名称" />
        <el-table-column align="center" width="250" prop="route_end" label="站点" />
      </el-table>
    </el-dialog>
    <!-- 分页组件 黑名单管理-->
    <el-pagination v-if="themeIndex == 1" background :current-page="currentPage" :page-size="pageSize"
      layout="total, prev, pager, next, jumper, slot" :total="total" @update:current-page="handleCurrentChange" />
    <!-- 分页组件 爽约记录-->
    <el-pagination v-if="themeIndex == 2" background :current-page="currentPage2" :page-size="pageSize2"
      layout="total, prev, pager, next, jumper, slot" :total="total2" @update:current-page="handleCurrentChange2" />
  </div>
</template>

<script setup>
import { ref, reactive, watch, 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 from "lodash";
import axios from "axios";
import { useStore } from "vuex";
const store = useStore();
const api = ref("");
const router = useRouter();
// 表格数据
const themeIndex = ref(2)
const tableData = reactive({ list: [] });
const blackData = reactive({ list: [] });
const activeIndex = ref(); // 默认跳转路由
// const dialongTitle = ref("新增账号"); // 弹窗标题

const searchInput = reactive({
  carnumber: "",
  createTime: "",
}); // 搜索按钮数据

// 黑名单管理（---------------------------------）
const currentPage = ref(1); // 当前页
const pageSize = ref(10);
const total = ref(); // 当前总数
const blackDialog = ref(false); // 黑名单爽约次数详情弹窗
// const selectData = reactive({ list: [] }); // 多选框选择的数据

// 爽约记录（------------------------------------）
const currentPage2 = ref(1); // 当前页
const pageSize2 = ref(10);
const total2 = ref(); // 当前总数
const busNum = reactive({ list: [] }) // 车牌号

const searchInput2 = reactive({
  user_name: "",// 姓名
  user_phone: "",
  carnumber: "", // 车牌号
  yy_date: "", // 发车日期
  ci_time: "", // 车次
  route: "",// 路线
}); // 搜索按钮数据

// 表单数据
const formSize = ref("default");
const ruleFormRef = ref();
const ruleForm = reactive({
  name: "",
  account: "",
  pass: "",
  id: "",
});
watch(
  () => searchInput.createTime,
  (newVal, oldVal) => {
    // console.log("监听时间:", newVal);
    if (newVal == null) {
      searchBtn();
    }
  }
);

watch(
  () => searchInput2.yy_date,
  (newVal, oldVal) => {
    // console.log("监听时间:", newVal);
    if (newVal == null) {
      searchBtn();
    }
  }
);
watch(
  () => searchInput2.ci_time,
  (newVal, oldVal) => {
    // console.log("监听时间:", newVal);
    if (newVal == null) {
      searchBtn();
    }
  }
);

// 表单验证
// const rules = reactive({
//   account: [
//     { required: true, message: "账号不能为空", trigger: "blur" },
//     // { min: 3, max: 5, message: "Length should be 3 to 5", trigger: "blur" },
//     // {
//     //   pattern: /^[a-zA-z]\w{3,15}$/,
//     //   message: "请输入合法账号",
//     //   trigger: "blur",
//     // },
//   ],
//   // /^[a-zA-z]\w{3,15}$/
//   pass: [
//     {
//       required: true,
//       message: "密码不能为空",
//       trigger: "blur",
//     },
//   ],
//   name: [
//     {
//       required: true,
//       message: "昵称不能为空",
//       trigger: "blur",
//     },
//   ],

//   // desc: [{ required: true, message: "Please input activity form", trigger: "blur" }],
// });

// 获取账户列表
const getList = async (flag) => {
  if (flag == 1) {
    themeIndex.value = 1
    let data = new FormData();
    if (searchInput.createTime == null) {
      searchInput.createTime = "";
    }
    data.set("user_name", searchInput.carnumber);
    data.set("yy_date", searchInput.createTime); //前面的key记得对应！
    data.set("page", currentPage.value);
    data.set("rows", pageSize.value); //前面的key记得对应！
    // let res = await adminApi.adminLogin(data);
    let res = await axios({
      method: "post",
      url: api.value + "/carBook/breclist.action",
      headers: {
        token: sessionStorage.getItem("token"),
      },
      data: data,
    });
    console.log(res, "黑名单管理");
    if (res.status == 200) {
      // ElMessage({
      //   type: "success",
      //   showClose: true,
      //   message: "请求数据成功",
      //   center: true,
      // });
      tableData.list = res.data.rows;
      // currentPage.value = res.data.currentPage;
      total.value = res.data.total;
    } else {
      tableData.list = res.data.rows;
      currentPage.value = 1;
      total.value = res.data.total;
      ElMessage({
        type: "error",
        showClose: true,
        message: "暂无数据",
        center: true,
      });
      if (res.data.message == "token错误") {
        router.push({
          path: `/login`,
        });
      }
    }
  } else if (flag == 2) {
    themeIndex.value = 2
    let data = new FormData();
    if (searchInput2.yy_date) {
      data.set("yy_date", searchInput2.yy_date);// 发车日期
    }
    if (searchInput2.ci_time) {
      data.set("ci_time", searchInput2.ci_time);// 车次
    }
    if (searchInput2.route) {
      data.set("route", searchInput2.route);// 路线
    }
    data.set("car_number", searchInput2.carnumber);// 车牌号
    data.set("user_name", searchInput2.user_name);// 名字
    data.set("user_phone", searchInput2.user_phone);// 号码
    data.set("page", currentPage2.value);
    data.set("rows", pageSize2.value); //前面的key记得对应！
    let res = await axios({
      method: "post",
      url: api.value + "/brecbreach_list.action",
      headers: {
        token: sessionStorage.getItem("token"),
      },
      data: data,
    });
    console.log(res, "爽约记录");
    if (res.status == 200) {
      // ElMessage({
      //   type: "success",
      //   showClose: true,
      //   message: "请求数据成功",
      //   center: true,
      // });
      tableData.list = res.data.rows;
      total2.value = res.data.total;
    } else {
      tableData.list = res.data.rows;
      currentPage2.value = 1;
      total2.value = res.data.total;
      ElMessage({
        type: "error",
        showClose: true,
        message: "暂无数据",
        center: true,
      });
      if (res.data.message == "token错误") {
        router.push({
          path: `/login`,
        });
      }
    }
  }
};
// 黑名单管理（--------------------------------------------------------------）
// 搜索功能
const searchBtn = lodash.debounce(async () => {
  getList(themeIndex.value);
}, 300);

// 重置搜索 黑名单管理
const searchRefresh = lodash.debounce(async () => {
  if (themeIndex.value == 1) {
    searchInput.carnumber = "";
    searchInput.createTime = "";
    currentPage.value = 1;
    getList(1);
  } else if (themeIndex.value == 2) {
    searchInput2.carnumber = "";
    searchInput2.yy_date = "";
    searchInput2.ci_time = "";
    searchInput2.user_name = "";
    searchInput2.user_phone = "";
    searchInput2.route = "";
    currentPage2.value = 1;
    getList(2);
  }
}, 300);

// //导出功能
// const importExcel = async () => {
//   if (searchInput.createTime == null) {
//     searchInput.createTime = "";
//   }
//   let data = new FormData();
//   data.set("number", searchInput.carnumber);
//   data.set("create_time", searchInput.createTime);
//   let res = await axios({
//     method: "post",
//     url: api.value + "/carBook/admintoExcel.action",
//     headers: {
//       token: sessionStorage.getItem("token"),
//     },
//     data: data,
//   });
//   // console.log(res, "导出账号");
//   if (res.data.code == 200) {
//     const elt = document.createElement("a");
//     elt.setAttribute(
//       "href",
//       "https://chtech.ncjti.edu.cn/carstop" + res.data.downurl
//     );
//     elt.setAttribute("download", "file.png");
//     elt.style.display = "none";
//     document.body.appendChild(elt);
//     elt.click();
//     ElMessage({
//       type: "success",
//       showClose: true,
//       message: res.data.message,
//       center: true,
//     });
//   } else {
//     ElMessage({
//       type: "error",
//       showClose: true,
//       message: res.data.message,
//       center: true,
//     });
//   }
// };
// 添加员工
// const addlist = () => {
//   dialongTitle.value = "新增账号";
//   addDialogVisible.value = true;
//   ruleForm.name = "";
//   ruleForm.account = "";
//   ruleForm.pass = "";
// };
// // 取消添加员工
// const cancelAdd = () => {
//   addDialogVisible.value = false;
//   ruleFormRef.value.resetFields();
// };
// // 确认添加员工
// const submitAdd = async (formEl) => {
//   if (!formEl) return;
//   await formEl.validate(async (valid, fields) => {
//     if (valid) {
//       if (dialongTitle.value == "新增账号") {
//         let data = {
//           name: ruleForm.name,
//           number: ruleForm.account,
//           password: ruleForm.pass,
//         };
//         // let res = await admin.adminAdd(data);
//         let res = await axios({
//           method: "post",
//           url: api.value + "/carBook/admininsert.action",
//           headers: {
//             "Content-Type": "application/json;charset=utf-8",
//             token: sessionStorage.getItem("token"),
//           },
//           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 = {
//           name: ruleForm.name,
//           number: ruleForm.account,
//           password: ruleForm.pass,
//           id: ruleForm.id,
//         };
//         // let res = await admin.adminAdd(data);
//         let res = await axios({
//           method: "post",
//           url: api.value + "/carBook/adminupdate.action",
//           headers: {
//             "Content-Type": "application/json;charset=utf-8",
//             token: sessionStorage.getItem("token"),
//           },
//           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);
//     }
//   });
// };

//  黑名单爽约详情 
const edit = async (row) => {
  blackDialog.value = true;
  console.log(row);
  let data = new FormData();
  data.set("card_number", row.card_number);
  let res = await axios({
    method: "post",
    url: api.value + "/carBook/brecblack_detail.action",
    headers: {
      token: sessionStorage.getItem("token"),
    },
    data: data,
  });
  console.log(res);
  if (res.status == 200) {
    blackData.list = res.data.data;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: "暂无数据",
      center: true,
    });
  }
};
//删除按钮 黑名单管理
const del = (row) => {
  console.log(row);
  ElMessageBox.confirm(`是否将 ${row.user_name} 移出黑名单?`, "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(async () => {
      let data = new FormData();
      data.set("card_number", row.card_number);
      // let res = await adminApi.adminLogin(data);
      let res = await axios({
        method: "post",
        url: api.value + "/carBook/brecremoveBlack.action",
        headers: {
          token: sessionStorage.getItem("token"),
        },
        data: data,
      });
      if (res.data.code == 200) {
        if (tableData.list.length == 1 && currentPage.value != 1) {
          currentPage.value = currentPage.value - 1;
        }
        getList(1);
        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);
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "已取消删除",
      });
    });
};
// 分页 黑名单管理
const handleCurrentChange = (value) => {
  // console.log(value);
  currentPage.value = value;
  getList(1);
};
// 分页 黑名单管理
const handleCurrentChange2 = (value) => {
  // console.log(value);
  currentPage2.value = value;
  getList(2);
};
// 爽约记录（----------------------------------------------------------）
const changeCarNum = (val) => {
  searchBtn()
}
//删除按钮 黑名单管理
const delOne = (row) => {
  console.log(row);
  ElMessageBox.confirm(`是否将 ${row.user_name} 移出黑名单?`, "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(async () => {
      let data = new FormData();
      data.set("id", row.id);
      let res = await axios({
        method: "post",
        url: api.value + "/brecupdateStateById.action",
        headers: {
          token: sessionStorage.getItem("token"),
        },
        data: data,
      });
      console.log(res, "移除单个爽约");
      if (res.data.code == 200) {
        if (tableData.list.length == 1 && currentPage2.value != 1) {
          currentPage2.value = currentPage2.value - 1;
        }
        getList(2);
        ElMessage({
          type: "success",
          showClose: true,
          message: res.data.message,
          center: true,
        });
      } else {
        ElMessage({
          type: "error",
          showClose: true,
          message: res.data.message,
          center: true,
        });
      }
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "已取消删除",
      });
    });
};
// 批量移除违约
const allReast = () => {
  ElMessageBox.confirm(`是否批量移出黑名单?`, "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(async () => {
      let data = new FormData();
      if (searchInput2.yy_date) {
        data.set("yy_date", searchInput2.yy_date);// 发车日期
      }
      if (searchInput2.ci_time) {
        data.set("ci_time", searchInput2.ci_time);// 车次
      }
      if (searchInput2.route) {
        data.set("route", searchInput2.route);// 路线
      }
      data.set("car_number", searchInput2.carnumber);// 车牌号
      data.set("user_name", searchInput2.user_name);// 名字
      data.set("user_phone", searchInput2.user_phone);// 号码
      let res = await axios({
        method: "post",
        url: api.value + "/brecremoveBreach.action",
        headers: {
          token: sessionStorage.getItem("token"),
        },
        data: data,
      });
      console.log(res, "批量移除爽约");
      if (res.data.code == 200) {
        if (tableData.list.length == 1 && currentPage2.value != 1) {
          currentPage2.value = currentPage2.value - 1;
        }
        getList(2);
        ElMessage({
          type: "success",
          showClose: true,
          message: res.data.message,
          center: true,
        });
      } else {
        ElMessage({
          type: "error",
          showClose: true,
          message: res.data.message,
          center: true,
        });
      }
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "已取消删除",
      });
    });
}
// 多选框功能
// 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 "";
};


onBeforeMount(() => {
  api.value = store.state.user.api;
  busNum.list = JSON.parse(sessionStorage.getItem("busSelect"));
  getList(themeIndex.value);
});
onUnmounted(() => {
  // document.removeEventListener("keyup", Enters);
});
</script>

<style scoped lang="scss">
.content-box {
  width: 97.5%;
  height: 89%;
  margin: 20px auto;
  background-color: #fff;
  color: #fff;
  display: flex;
  flex-direction: column;

  .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;

    .cameratxt {
      display: flex;
      align-items: center;
      height: 60px;
      margin-right: 15px;
      cursor: pointer;
    }

    .is_active {
      color: rgba(61, 81, 232, 1);
    }
  }

  .middle {
    width: 96%;
    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;
      }

      .condition {
        display: flex;
        align-items: center;
        margin: 10px 30px 10px 0;

        :deep(.el-input .el-input__inner) {
          font-size: 16px;
        }

        span {
          margin: 0 10px 0 0;
        }
      }

      .button {
        margin: 0;

        .el-button {
          margin-right: 20px;
        }
      }
    }

    .gongneng {
      margin: 10px 0;
    }

    :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: 96%;
    height: 550px;
    margin: 10px auto 30px;

    .el-table--fit {
      height: 100%;

      :deep(.el-table__header-wrapper) {
        background-color: #000;
        font-size: 16px;
        color: #000;
      }

      :deep(.el-table__row) {
        height: 50px;
        font-size: 16px;
        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(.el-button) {
        width: 60px;
        height: 28px;
        border-radius: 40px;
        font-size: 15px;
      }
    }

    // 添加员工弹窗样式
    :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: 30px 20px 10px 20px;

        .el-input {
          width: 200px;

          .el-input__suffix-inner {
            color: rgba(61, 81, 232, 1);
          }
        }

        .options {
          margin-left: 320px;
        }
      }
    }
  }

  .el-pagination {
    // width: 1600px;
    width: 96%;
    margin: 0 auto 18px;
    justify-content: flex-end;

    :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(30, 125, 251, 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;
    }
  }

  :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;
      padding-bottom: 16px;

      .el-dialog__headerbtn {
        outline: none;
      }
    }

    .el-dialog__body {
      padding: 30px 20px 10px 20px;

      .el-input {
        width: 200px;
      }

      .options {
        margin-left: 120px;
      }
    }
  }

  :deep(.particulars) {
    .el-dialog__body {
      padding: 30px 20px 30px 20px;
    }
  }
}

.el-input {
  width: 192px;
}
</style>
