<template>
  <div class="content-box">
    <div class="home" v-if="homeShow">
      <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="true"
                @clear="searchBtn"
                v-model="searchInput.keyWord"
                class="sel"
                placeholder="请输入任务名称"
              />
              <el-select v-model="value" class="sel" placeholder="执行方式">
                <el-option label="Mariadb 数据库" value="1" />
                <el-option label="MySQL6.0 及以下数据库" value="2" />
                <el-option label="MySQL8.0 及以下数据库" value="3" />
                <el-option label="Oracle 10g、11g 数据库" value="3" />
                <el-option label="PostgreSQL 数据库" value="3" />
              </el-select>
              <el-select v-model="value" class="sel" placeholder="任务状态">
                <el-option label="已启动" value="1" />
                <el-option label="停止" value="2" />
              </el-select>
              <el-input
                :clearable="true"
                @clear="searchBtn"
                v-model="searchInput.keyWord"
                class="sel"
                placeholder="请输入目的表名"
              />
            </div>
            <el-button
              color="rgba(0, 97, 255, 1)"
              type="primary"
              class="search"
              @click="searchBtn"
              ><el-icon>
                <Search />
              </el-icon>
              <span>查询</span></el-button
            >
          </div>
          <!-- 按钮列表 -->
          <div class="gongneng">
            <el-button
              type="primary"
              color="rgba(0, 97, 255, 1)"
              plain
              @click="addClick"
              >新增</el-button
            >
            <el-button
              type="primary"
              color="rgba(0, 97, 255, 1)"
              plain
              @click="editClick"
              >批量启动</el-button
            >
            <el-button
              type="primary"
              color="rgba(0, 97, 255, 1)"
              @click="delClick"
              plain
              >批量停止</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%"
            border
            :header-cell-style="{
              background: 'rgba(240, 243, 247, 1)',
              height: '50px',
            }"
          >
            <el-table-column align="center" type="selection" width="80" />
            <el-table-column
              align="center"
              prop="name"
              width="250"
              label="任务名称"
            />
            <el-table-column align="center" prop="source" label="来源数据表" />
            <el-table-column align="center" prop="target" label="目标数据表" />
            <el-table-column
              align="center"
              prop="department"
              label="业务部门"
            />
            <el-table-column
              align="center"
              prop="interchangerName"
              show-overflow-tooltip
              label="交换机名称"
            />
            <el-table-column align="center" prop="way" label="执行方式" />
            <el-table-column align="center" prop="status" label="任务状态" />
            <el-table-column
              align="center"
              prop="time"
              width="200"
              label="下次执行时间"
            />
            <el-table-column align="center" label="操作" width="200">
              <template #default="scope">
                <div class="edit">
                  <el-button link type="primary" @click="lookClick(scope.row)"
                    >查看</el-button
                  >
                  <el-button link type="primary" @click="editClick(scope.row)"
                    >编辑</el-button
                  >
                  <el-button link type="primary" @click="startClick(scope.row)"
                    >启动</el-button
                  >
                  <el-button
                    :disabled="true"
                    link
                    type="primary"
                    @click="editClick(scope.row)"
                    >停止</el-button
                  >
                  <el-button link type="primary" @click="editClick(scope.row)"
                    >执行一次</el-button
                  >
                  <el-popconfirm
                    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>
        <!-- 分页组件 -->
        <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>
      </div>
    </div>
    <!-- 编辑 -->
    <div class="taskEdit" v-if="editShow">
      <div class="left">
        <img src="@/assets/images/close.png" alt="" @click="cancelEdit" />
        <span class="add">{{ titleDialog }}</span>
      </div>
      <div class="content">
        <el-steps :active="stepInd" finish-status="success" simple>
          <el-step title="任务基本信息" />
          <el-step title="字段配置" />
          <el-step title="定时信息" />
        </el-steps>
        <div class="form" v-if="stepInd == 1">
          <el-form
            ref="editOneRef"
            :model="editRuleForm"
            :rules="editRules"
            label-width="180px"
            class="demo-ruleForm"
            :size="formSize"
            label-position="left"
            status-icon
          >
            <div class="block">
              <div class="title">任务属性</div>
              <el-form-item label="交换任务名称 :" prop="name">
                <el-input
                  v-model="editRuleForm.name"
                  placeholder="请输入交换任务名称"
                  clearable
                  style="width: 500px"
                />
              </el-form-item>
              <el-form-item label="业务部门 :" prop="department">
                <el-select
                  v-model="editRuleForm.department"
                  placeholder="请选择业务部门"
                  style="width: 500px"
                >
                  <el-option label="部门通用" value="1" />
                  <el-option label="未知" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item label="同步策略 :" prop="strategy">
                <el-select
                  v-model="editRuleForm.strategy"
                  placeholder="请选择同步策略"
                  style="width: 500px"
                >
                  <el-option label="插入更新" value="1" />
                  <el-option label="线上更新" value="2" />
                </el-select>
              </el-form-item>
            </div>
            <div class="block">
              <div class="title">来源库设置</div>
              <el-form-item label="来源数据源 :" prop="dataSource">
                <el-select
                  v-model="editRuleForm.dataSource"
                  placeholder="请选择来源数据源"
                  style="width: 500px"
                >
                  <el-option label="教务数据库" value="1" />
                  <el-option label="未知" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item label="交换方式 :" prop="way">
                <el-select
                  v-model="editRuleForm.way"
                  placeholder="请选择交换方式"
                  style="width: 500px"
                >
                  <el-option label="数据库视图" value="1" />
                  <el-option label="未知" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item label="来源数据视图 :" prop="dataView">
                <span class="text">[]</span>
                <el-button
                  color="rgba(41, 109, 227, 1)"
                  type="primary"
                  @click="dataViewClick(scope.row)"
                  >选取</el-button
                >
              </el-form-item>
            </div>
            <div class="block">
              <div class="title">目的库设置</div>
              <el-form-item label="目标数据源 :" prop="targetOrigin">
                <el-select
                  v-model="editRuleForm.targetOrigin"
                  placeholder="请选择目标数据源"
                  style="width: 500px"
                >
                  <el-option label="电子班牌" value="1" />
                  <el-option label="未知" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item label="目标数据表 :" prop="targetChart">
                <span class="text">[]</span>
                <el-button
                  color="rgba(41, 109, 227, 1)"
                  type="primary"
                  @click="targetChartClick(scope.row)"
                  >选取</el-button
                >
              </el-form-item>
            </div>
            <div class="block collapse">
              <el-collapse>
                <el-collapse-item name="1">
                  <template #title>
                    <span class="title">高级设置</span>
                  </template>
                  <el-form-item label="交换服务器 :" prop="exchangeServer">
                    <el-radio-group v-model="editRuleForm.exchangeServer">
                      <el-radio label="1">智能选择</el-radio>
                      <el-radio label="2">手动选择</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="运行参数配置 :" prop="configuration">
                    <el-radio-group v-model="editRuleForm.configuration">
                      <el-radio label="1">智能选择</el-radio>
                      <el-radio label="2">手动选择</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="是否记录错误数据 :" prop="errorData">
                    <el-radio-group v-model="editRuleForm.errorData">
                      <el-radio label="1">是</el-radio>
                      <el-radio label="2">否</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item
                    label="来源数据源字符集 :"
                    prop="sourceCharacter"
                  >
                    <el-select
                      v-model="editRuleForm.sourceCharacter"
                      placeholder="请选择来源数据源字符集"
                      style="width: 500px"
                    >
                      <el-option label="UTF8" value="1" />
                    </el-select>
                  </el-form-item>
                  <el-form-item
                    label="目的数据源字符集 :"
                    prop="purposeCharacter"
                  >
                    <el-select
                      v-model="editRuleForm.purposeCharacter"
                      placeholder="请选择目的数据源字符"
                      style="width: 500px"
                    >
                      <el-option label="UTF8" value="1" />
                    </el-select>
                  </el-form-item>
                </el-collapse-item>
              </el-collapse>
            </div>
            <el-form-item class="options">
              <el-button
                color="rgba(41, 109, 227, 1)"
                class="queding"
                type="primary"
                @click="nextOneEdit(editOneRef)"
              >
                下一步
              </el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="form" v-if="stepInd == 2">
          <el-table
            :row-class-name="tableRowClassName"
            :data="stepTwoData.list"
            @selection-change="handleSelectionChange"
            style="width: 100%"
            border
            :header-cell-style="{
              background: 'rgba(240, 243, 247, 1)',
              height: '50px',
            }"
          >
            <el-table-column align="center" prop="name" label="目标数据表">
              <el-table-column
                align="center"
                label="序号"
                type="index"
                width="120"
              />
              <el-table-column
                align="center"
                prop="city"
                label="字段"
                width="120"
              >
              </el-table-column>
              <el-table-column
                align="center"
                prop="address"
                label="类型"
                width="120"
              />
              <el-table-column
                align="center"
                prop="zip"
                label="长度"
                width="120"
              />
              <el-table-column
                align="center"
                prop="remark"
                label="备注"
                width="250"
              />
              <el-table-column
                align="center"
                prop="zip"
                label="是否非空"
                width="120"
              />
            </el-table-column>
            <el-table-column align="center" prop="name" label="来源数据表">
              <el-table-column
                align="center"
                prop="city"
                label="字段"
                width="202"
              >
                <template #default="scope">
                  <el-select
                    v-model="editRuleForm.dataSource"
                    placeholder="请选择源表字段"
                    style="width: 200px"
                  >
                    <el-option label="SFQY[SFQY]" value="1" />
                    <el-option label="ZGH[ZGH]" value="2" />
                    <el-option label="JGDM[JGDM]" value="3" />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                prop="address"
                label="类型"
                width="120"
              />
              <el-table-column
                align="center"
                prop="zip"
                label="长度"
                width="120"
              />
              <el-table-column
                align="center"
                prop="zip"
                label="智能转换"
                width="120"
              />
            </el-table-column>
            <el-table-column align="center" label="操作" width="200">
              <el-table-column
                align="center"
                prop="city"
                label="更新主键"
                width="120"
              >
                <template #default="scope">
                  <div class="edit">
                    <el-checkbox v-model="checked2"></el-checkbox>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                prop="address"
                label="是否交换"
                width="120"
              >
                <template #default="scope">
                  <div class="edit">
                    <el-checkbox v-model="checked2"></el-checkbox>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                prop="zip"
                label="是否更新"
                width="120"
              >
                <template #default="scope">
                  <div class="edit">
                    <el-checkbox v-model="checked2"></el-checkbox>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                prop="zip"
                label="增量标记"
                width="120"
              >
                <template #default="scope">
                  <div class="edit">
                    <el-checkbox v-model="checked2"></el-checkbox>
                  </div>
                </template>
              </el-table-column>
            </el-table-column>
          </el-table>
          <div class="options">
            <el-button class="queding" @click="lastOneEdit"> 上一步 </el-button>
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="nextTwoEdit"
            >
              下一步
            </el-button>
          </div>
        </div>
        <div class="form" v-if="stepInd == 3">
          <el-form
            ref="editThreeRef"
            :model="editThreeRuleForm"
            :rules="editThreeRules"
            label-width="180px"
            class="demo-ruleForm"
            :size="formSize"
            label-position="left"
            status-icon
          >
            <el-form-item label="是否定时 :" prop="timing">
              <el-radio-group v-model="editThreeRuleForm.timing">
                <el-radio label="1">手动执行</el-radio>
                <el-radio label="2">定时执行</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="执行方式 :" prop="executeWay">
              <el-select
                v-model="editThreeRuleForm.executeWay"
                placeholder="请选择执行方式"
                style="width: 500px"
              >
                <el-option label="间隔执行" value="1" />
              </el-select>
            </el-form-item>
            <el-form-item label="间隔周期 :" prop="intervalPeriod">
              <el-input
                v-model="editThreeRuleForm.intervalPeriod"
                placeholder="请输入间隔周期"
                clearable
                style="width: 240px; margin-right: 20px"
              />
              <el-select
                v-model="editThreeRuleForm.period"
                placeholder="请选择周期"
                style="width: 240px"
              >
                <el-option label="天" value="1" />
                <el-option label="周" value="2" />
                <el-option label="月" value="3" />
              </el-select>
            </el-form-item>
          </el-form>
          <div class="options">
            <el-button class="queding" @click="lastTwoEdit"> 上一步 </el-button>
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="configEdit"
            >
              保存
            </el-button>
          </div>
        </div>
      </div>
    </div>

    <!-- 编辑按钮 -->
    <el-dialog
      class="editDialog"
      v-model="editVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :title="titleDialog"
      align-center
      width="900"
      :before-close="cancelEdit"
    >
      <el-form
        ref="editRef"
        :model="editRuleForm"
        :rules="editRules"
        label-width="100px"
        class="demo-ruleForm"
        :size="formSize"
        label-position="right"
        status-icon
      >
        <el-form-item label="类型 :" prop="type">
          <el-select
            v-model="editRuleForm.type"
            multiple
            placeholder="请选择类型"
            style="width: 740px"
          >
            <el-option label="学生肖像" value="1" />
            <el-option label="车辆预约" value="2" />
            <el-option label="校园打卡" value="3" />
            <el-option label="校园报修" value="4" />
          </el-select>
        </el-form-item>
        <el-form-item label="名称 :" prop="yname">
          <el-input
            v-model="editRuleForm.yname"
            placeholder="数据源名称.如: xxx数据库"
            clearable
            style="width: 740px"
          />
        </el-form-item>
        <div v-if="titleDialog == '新增'">
          <span class="typeTitle">使用辅助选项请先选择类型</span>
          <el-form-item label="辅助选项 :">
            <el-input
              v-model="editRuleForm.location"
              placeholder="数据库服务IP地址"
              clearable
              style="width: 300px; margin-right: 10px"
            />
            <el-input
              v-model="editRuleForm.port"
              placeholder="数据库服务端口号"
              clearable
              style="width: 210px; margin-right: 10px"
            />
            <el-input
              v-model="editRuleForm.kname"
              placeholder="数据库名称"
              clearable
              style="width: 210px"
            />
          </el-form-item>
        </div>
        <el-form-item label="连接地址 :" prop="link">
          <el-input
            v-model="editRuleForm.link"
            placeholder="数据库连接地址"
            clearable
            style="width: 740px"
          />
        </el-form-item>
        <div class="account">
          <el-form-item label="数据库账号 :" prop="account">
            <el-input
              v-model="editRuleForm.account"
              placeholder="请输入数据库账号"
              clearable
            />
          </el-form-item>
          <el-form-item label="数据库密码 :" prop="password">
            <el-input
              v-model="editRuleForm.password"
              placeholder="请输入数据库密码"
              clearable
            />
          </el-form-item>
        </div>
        <el-form-item label="描述 :" prop="describe">
          <el-input
            v-model="editRuleForm.describe"
            placeholder="请输入该数据库相关简述"
            clearable
            type="textarea"
            :rows="5"
            style="width: 740px"
          />
        </el-form-item>
        <el-form-item class="options">
          <el-button
            color="rgba(41, 109, 227, 1)"
            class="queding"
            type="primary"
            @click="confirmEdit(editRef)"
          >
            确认
          </el-button>
          <el-button @click="cancelEdit(editRef)">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 查看按钮 -->
    <el-dialog
      class="lookDialog"
      v-model="lookVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="交换任务详情"
      align-center
      width="600"
      :before-close="cancelLook"
    >
      <ul>
        <li>交换任务名称 : <span>学院部门</span></li>
        <li>来源数据源 : <span>教务数据库</span></li>
        <li>交换方式 : <span>自定义SQL语句</span></li>
        <li>
          自定义SQL :
          <span>select jgdm bmdm, jgmc bmmc from zftal_xtgl_jgdmb</span>
        </li>
        <li>来源数据源 : <span>字符集UTF8</span></li>
        <li>目标数据源 : <span>学工数据库</span></li>
        <li>目的数据源字符集 : <span>UTF8</span></li>
        <li>交换机 : <span>auto</span></li>
        <li>执行方式 : <span>间隔执行</span></li>
        <li>间隔周期 : <span>1 天</span></li>
      </ul>
      <div class="options">
        <el-button @click="cancelLook">关闭</el-button>
      </div>
    </el-dialog>

    <!-- 勾选删除 -->
    <el-dialog
      class="closeAccount"
      v-model="selDelVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="勾选删除"
      align-center
      width="500"
      :before-close="cancelSelDel"
    >
      <div class="content">
        <img src="@/assets/images/warning.png" alt="" />
        <span>是否删除勾选的数据库？</span>
      </div>
      <div class="option">
        <el-button
          color="rgba(41, 109, 227, 1)"
          class="queding"
          type="primary"
          @click="confirmSelDel"
        >
          确认
        </el-button>
        <el-button @click="cancelSelDel">取消</el-button>
      </div>
    </el-dialog>
  </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 vidiconsApi from "@/api/vidicons.js";
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 loading = ref(false);
const tableData = reactive({
  list: [
    {
      name: "标准库教师-新认证", // 任务名称
      source: "SQL语句", //来源数据表
      target: "3.2.1用户账号表", //目标数据表
      department: "部门通用", //业务部门
      interchangerName: "auto", //交换机名称
      way: "间隔执行", //执行方式
      status: "已启动", //任务状态
      time: "2023-12-15 11:06:12", //下次执行时间
    },
    {
      name: "标准库教师个人信息-老OA", // 任务名称
      source: "SQL语句", //来源数据表
      target: "D教师个人信息表", //目标数据表
      department: "部门通用", //业务部门
      interchangerName: "auto", //交换机名称
      way: "间隔执行", //执行方式
      status: "已启动", //任务状态
      time: "2023-12-16 08:33:53", //下次执行时间
    },
    {
      name: "电子班牌", // 任务名称
      source: "SQL语句", //来源数据表
      target: "班级学生", //目标数据表
      department: "部门通用", //业务部门
      interchangerName: "auto", //交换机名称
      way: "auto", //执行方式
      status: "已启动", //任务状态
      time: "2023-12-15 11:06:12", //下次执行时间
    },
    {
      name: "教师授课信息表-创海中间库", // 任务名称
      source: "SQL语句", //来源数据表
      target: "tb_course_scheduling", //目标数据表
      department: "部门通用", //业务部门
      interchangerName: "auto", //交换机名称
      way: "auto", //执行方式
      status: "已启动", //任务状态
      time: "2023-12-15 11:06:12", //下次执行时间
    },
  ],
});

const searchInput = reactive({
  keyWord: "",
  createTime: "",
}); // 搜索按钮数据
const homeShow = ref(true); // 主页面默认显示
const currentPage = ref(1); // 当前页
const pageSize = ref(10);
const total = ref(5); // 当前总数
const selectData = reactive({ list: [] }); // 表格勾选的数据

// 查看功能 （-------------------------------------------------------------------）
const lookVisible = ref(false);

// 编辑功能 （--------------------------------------------------------------------）
const titleDialog = ref();
const editShow = ref(false);
const stepInd = ref(1);
const editOneRef = ref();
const editRuleForm = reactive({
  name: "", // 交换任务名称
  department: "", // 业务部门
  strategy: "", // 同步策略
  dataSource: "", // 来源数据源
  way: "", // 交换方式
  dataView: "", // 来源数据视图
  targetOrigin: "", // 目标数据源
  targetChart: "", // 目标数据表
  exchangeServer: "1", // 交换服务器
  configuration: "1", // 运行参数配置
  errorData: "1", // 是否记录错误数据
  sourceCharacter: "1", // 来源数据源字符集
  purposeCharacter: "1", // 目的数据源字符集
  id: "",
});
// 表单验证
const editRules = reactive({
  name: [{ required: true, message: "交换任务名称不能为空", trigger: "blur" }],
  department: [
    {
      required: true,
      message: "业务部门不能为空",
      trigger: "blur",
    },
  ],
  strategy: [
    {
      required: true,
      message: "同步策略不能为空",
      trigger: "blur",
    },
  ],
  dataSource: [
    {
      required: true,
      message: "来源数据源不能为空",
      trigger: "blur",
    },
  ],
  way: [
    {
      required: true,
      message: "交换方式不能为空",
      trigger: "blur",
    },
  ],
  dataView: [
    {
      required: true,
      message: "来源数据视图不能为空",
      trigger: "blur",
    },
  ],
  targetOrigin: [
    {
      required: true,
      message: "目标数据源不能为空",
      trigger: "blur",
    },
  ],
  targetChart: [
    {
      required: true,
      message: "目标数据表不能为空",
      trigger: "blur",
    },
  ],
  exchangeServer: [
    {
      required: true,
      message: "交换服务器不能为空",
      trigger: "blur",
    },
  ],
  configuration: [
    {
      required: true,
      message: "运行参数配置不能为空",
      trigger: "blur",
    },
  ],
  errorData: [
    {
      required: true,
      message: "记录错误数据不能为空",
      trigger: "blur",
    },
  ],
  sourceCharacter: [
    {
      required: true,
      message: "来源数据源字符集不能为空",
      trigger: "blur",
    },
  ],
  purposeCharacter: [
    {
      required: true,
      message: "目的数据源字符集不能为空",
      trigger: "blur",
    },
  ],
});
// 第二步
const stepTwoData = reactive({
  list: [{ city: "1111", remark: "课程类型（课设、实验、临时课程相关）" }],
});
// 第三步
const editThreeRef = ref();
const editThreeRuleForm = reactive({
  timing: "1", // 是否定时
  executeWay: "", // 执行方式
  intervalPeriod: "", // 间隔周期
  period: "1", // 周期
});
const editThreeRules = reactive({
  timing: [{ required: true, message: "定时不能为空", trigger: "blur" }],
  executeWay: [
    {
      required: true,
      message: "执行方式不能为空",
      trigger: "blur",
    },
  ],
  intervalPeriod: [
    {
      required: true,
      message: "间隔周期不能为空",
      trigger: "blur",
    },
  ],
  period: [
    {
      required: true,
      message: "周期不能为空",
      trigger: "blur",
    },
  ],
});
// (--------------------------------------------------------------------------------------)

// 删除弹窗
const selDelVisible = ref(false);

// 查看房型列表
const getList = async () => {
  //   loading.value = true;
  //   let data = {
  //     page: currentPage.value,
  //     rows: pageSize.value,
  //     hName: searchInput.keyWord, // 房型名称
  //     managerId: sessionStorage.getItem("token"),
  //   };
  //   let res = await axios({
  //     method: "post",
  //     url: api.value + "/mhotel/housequeryPage.action",
  //     headers: {
  //       // token: sessionStorage.getItem("token"),
  //       // user_head: sessionStorage.getItem("userhead"),
  //     },
  //     params: data,
  //   });
  //   console.log(res, "房型管理");
  //   if (res.data.code == 200) {
  //     loading.value = false;
  //     tableData.list = res.data.data.pageList;
  //     total.value = res.data.data.total;
  //     // 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 lookClick = (row) => {
  lookVisible.value = true;
};
const cancelLook = () => {
  lookVisible.value = false;
};

// 搜索功能
const searchBtn = lodash.debounce(async () => {
  getList();
}, 300);
// 添加按钮 （-------------------------------------------）
const addClick = async () => {
  titleDialog.value = "新增任务";
  homeShow.value = false;
  editShow.value = true;
  stepInd.value = 1;
  // editVisible.value = true;
  //   let data = {
  //     linkId: row.id,
  //   };
  //   let res = await axios({
  //     method: "post",
  //     url: api.value + "/mhotel/uploadgetByLinkId.action",
  //     headers: {},
  //     params: data,
  //   });
  //   console.log(res, "编辑中查找图片");
  //   if (res.data.code == 200) {
  //     // res.data.data.fileInfoList.forEach((item) => {
  //     //   item.uid = item.id;
  //     // });
  //     // fileList.list = res.data.data.fileInfoList;
  //     // ruleForm.fileListJson = fileList.list;
  //     res.data.data.forEach((item) => {
  //       item.uid = item.id;
  //     });
  //     fileList.list = res.data.data;
  //     ruleForm.fileListJson = fileList.list;
  //     // ElMessage({
  //     //   type: "success",
  //     //   showClose: true,
  //     //   message: res.data.message,
  //     //   center: true,
  //     // });
  //   } else {
  //     ElMessage({
  //       type: "error",
  //       showClose: true,
  //       message: res.data.message,
  //       center: true,
  //     });
  //   }
};

//编辑按钮  （-------------------------------------------）
const editClick = async () => {
  titleDialog.value = "编辑任务";
  homeShow.value = false;
  editShow.value = true;
  stepInd.value = 1;
};

const cancelEdit = () => {
  homeShow.value = true;
  editShow.value = false;
  // editRef.value.resetFields();
};

// 确定编辑
const confirmEdit = (formEl) => {
  if (!formEl) return;
  formEl.validate(async (valid, fields) => {
    if (valid) {
    }
  });
};
// 第一步
const nextOneEdit = (formEl) => {
  // if (!formEl) return;
  // formEl.validate(async (valid, fields) => {
  //   if (valid) {
  //   }
  // });
  stepInd.value = 2;
};
// 第二步
const lastOneEdit = () => {
  stepInd.value = 1;
};
const nextTwoEdit = () => {
  stepInd.value = 3;
};
// 第三步
const lastTwoEdit = () => {
  stepInd.value = 2;
};
const configEdit = () => {};
// (-------------------------------------------------------------------)

//删除按钮
const delClick = async () => {
  // if (selectData.list.length >= 1) {
  //   selDelVisible.value = true;
  // } else {
  //   ElMessage({
  //     type: "warning",
  //     showClose: true,
  //     message: "请先选定所需要删除的数据库!",
  //     center: true,
  //   });
  // }
  // let data = {
  //   id: row.id,
  // };
  //   let res = await axios({
  //     method: "post",
  //     url: api.value + "/mhotel/housedelHouser.action",
  //     headers: {
  //       // token: sessionStorage.getItem("token"),
  //       // user_head: sessionStorage.getItem("userhead"),
  //     },
  //     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 cancelSelDel = () => {
  selDelVisible.value = false;
};

// 多选框功能
const handleSelectionChange = (val) => {
  console.log(val);
  selectData.list = val;
};
//导出功能
// const importExcel = async () => {
//   if (searchInput.createTime == null) {
//     searchInput.createTime = "";
//   }
//   let data = new FormData();
//   data.set("car_number", searchInput.carnumber);
//   data.set("create_time", searchInput.createTime);
//   let res = await axios({
//     method: "post",
//     url: api.value + "/carBook/cinfotoExcel.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();
//     var downloadPath = "https://chtech.ncjti.edu.cn/carstop" + res.data.downurl;
//     console.log("获得地址数据:", downloadPath);
//     var downloadLink = document.createElement("a");
//     downloadLink.style.display = "none"; // 使其隐藏
//     downloadLink.href = downloadPath;
//     downloadLink.download = "";
//     downloadLink.click();
//     document.body.appendChild(downloadLink);
//     document.body.removeChild(downloadLink);
//     ElMessage({
//       type: "success",
//       showClose: true,
//       message: res.data.message,
//       center: true,
//     });
//   } else {
//     ElMessage({
//       type: "error",
//       showClose: true,
//       message: res.data.message,
//       center: true,
//     });
//   }
// };
// 表格斑马纹颜色修改
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(async () => {
  api.value = store.state.user.api;
  getList();
});
onUnmounted(() => {
  // document.removeEventListener("keyup", Enters);
});
</script>

<style scoped lang="scss">
.content-box {
  min-width: 1000px;
  width: calc(100vw - 260px);
  height: calc(100vh - 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);
  // 主页面
  .home {
    height: 100%;
    .left {
      // width: calc(100wh - 40px);
      display: flex;
      align-items: center;
      height: 60px;
      margin: 0 30px;
      border-bottom: 1px solid #ccc;
      color: rgb(0, 0, 0);
      font-size: 18px;
      font-weight: 600;

      span {
        height: 60px;
        line-height: 60px;
        margin-right: 20px;
      }

      .is_active {
        color: rgba(111, 182, 184, 1);
      }
    }
    .scroll {
      height: calc(100% - 61px);
      overflow: auto;
    }
    .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 {
          color: #fff;
        }

        .condition {
          display: flex;
          align-items: center;
          margin: 10px 30px 10px 0;
          .sel {
            margin-right: 10px;
          }
          :deep(.el-input .el-input__inner) {
            font-size: 14px;
          }
        }
      }

      .gongneng {
        margin: 10px 0 20px 0;

        span {
          color: #fff;
        }
        .el-button {
          margin-right: 10px;
        }
      }

      :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: 14px;

          tr {
            // color: #000;
          }
        }

        :deep(.el-table__row) {
          height: 50px;
          font-size: 14px;
          // color: #000;

          &:hover {
            td {
              background-color: rgba(223, 236, 254, 1);
            }
          }
        }

        :deep(.el-table__row td) {
          padding: 0;
          // border: 0;
          .normal {
            background-color: rgba(139, 195, 74, 1);
            color: #fff;
            padding: 4px;
          }
        }

        .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(.edit) {
          display: flex;
          align-items: center;
          // justify-content: center;
          flex-wrap: wrap;
          color: rgba(111, 182, 184, 1);
          .is-disabled {
            color: #ccc;
          }
        }

        :deep(.look) {
          padding: 0 10px;
          cursor: pointer;
          color: rgba(30, 125, 251, 1);
        }

        .del {
          padding: 0 10px;
          color: rgba(212, 48, 48, 1);
          cursor: pointer;
        }

        // :deep(.look):hover {
        //   color: red;
        // }
        // :deep(.del):hover {
        //   color: red;
        // }
      }
    }
    .pageSize {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 0 30px;

      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;
        }
      }
    }
  }
  // 编辑页面
  .taskEdit {
    width: 100%;
    height: 100%;
    .left {
      // width: calc(100wh - 40px);
      display: flex;
      align-items: center;
      height: 60px;
      padding: 0 30px;
      border-bottom: 1px solid #ccc;
      color: rgb(0, 0, 0);
      font-size: 20px;
      font-weight: 600;
      img {
        width: 18px;
        height: 18px;
        cursor: pointer;
      }
      .add {
        margin-left: 20px !important;
        font-size: 20px !important;
        color: rgba(0, 0, 0, 1) !important;
      }
    }
    .content {
      padding: 0 30px;
      height: calc(100% - 71px);
      .el-steps {
        height: 40px;
        margin-bottom: 20px;
        background: transparent;
        border-bottom: 1px solid #e3e3e3;
        :deep(.el-step__title) {
          font-size: 20px;
        }
      }
      .form {
        height: calc(100% - 87px);
        overflow: auto;
        .block {
          margin: 18px 0 0 0;
          border-bottom: 1px solid #e3e3e3;
          .title {
            font-size: 18px;
            color: #2b425b;
            font-weight: 600;
            margin: 0 0 10px 0;
          }
        }
        .collapse {
          margin: 10px 0 18px 0;
          border-bottom: none;
          .el-collapse {
            border: none;
            .title {
              font-size: 18px;
              color: #2b425b;
              font-weight: 600;
              margin: 0;
            }
            :deep(.el-collapse-item) {
              .el-collapse-item__header {
                width: 180px;
                border: none;
              }
              .el-collapse-item__wrap {
                border: none !important;
              }
            }
          }
        }
        .text {
          color: #f69721;
        }
        .options {
          margin-top: 15px;
          :deep(.el-form-item__content) {
            margin-left: 0 !important;
          }
        }
        .el-table--fit {
          height: 580px;

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

            tr {
              // color: #000;
            }
          }

          :deep(.el-table__row) {
            height: 45px;
            font-size: 14px;
            // color: #000;

            &:hover {
              td {
                background-color: rgba(223, 236, 254, 1);
              }
            }
          }

          :deep(.el-table__row td) {
            padding: 0;
            // border: 0;
            .normal {
              background-color: rgba(139, 195, 74, 1);
              color: #fff;
              padding: 4px;
            }
            .el-input {
              height: 40px;
            }
          }

          .el-button--primary {
            margin-left: 5px;
          }

          :deep(.edit) {
            display: flex;
            align-items: center;
            justify-content: center;
            color: rgba(111, 182, 184, 1);
          }

          :deep(.look) {
            padding: 0 10px;
            cursor: pointer;
            color: rgba(30, 125, 251, 1);
          }

          .del {
            padding: 0 10px;
            color: rgba(212, 48, 48, 1);
            cursor: pointer;
          }
        }
      }
      // 整个滚动条
      .form::-webkit-scrollbar-track {
        background-color: #daeeff;
      }
      // 滚动条的滚动区域（轨道）
      .form::-webkit-scrollbar {
        background-color: #0888f8;
        height: 3px;
        width: 4px;
      }
      // 滚动条的可拖拽部分（滑块）
      // .form::-webkit-scrollbar-thumb {
      //   background: #57b2ff;
      //   border-radius: 4px;
      //   height: 3px;
      //   width: 4px;
      // }
    }
  }
  // 编辑按钮
  :deep(.editDialog) {
    //   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 30px 10px 30px;
      .el-form-item__content {
        width: 200px;
        .el-input-group__append {
          background-color: rgba(222, 234, 252, 1);
          color: rgba(0, 97, 255, 1);
          cursor: pointer;
          user-select: none;
        }
      }
      .el-form {
        .typeTitle {
          display: block;
          color: red;
          margin: 0 0 6px 100px;
        }
        .account {
          display: flex;
          justify-content: space-between;
          .el-form-item {
            .el-form-item__content {
              width: 300px;
            }
            .el-input {
              width: 300px;
            }
          }
        }
      }

      .options {
        margin: 50px 20px 20px 0;
        width: 100%;
        .el-form-item__content {
          display: flex;
          flex-direction: row-reverse;
        }

        .queding {
          color: #fff;
          margin-left: 15px;
        }
      }
    }
  }
  // 查看按钮
  :deep(.lookDialog) {
    //   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 30px;
      ul {
        margin: 0;
        padding: 0;
        li {
          list-style: none;
          // color: #000;
          // font-weight: 600;
          font-size: 14px;
          margin-bottom: 10px;
          span {
            color: #f69721;
            // font-weight: 600;
          }
        }
      }
      .options {
        margin: 30px 20px 20px 0;
        width: 100%;
        display: flex;
        flex-direction: row-reverse;
        .queding {
          color: #fff;
          margin-left: 15px;
        }
      }
    }
  }

  // 删除数据库
  :deep(.closeAccount) {
    // 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: 0px 20px 20px 20px;
      // display: flex;
      // flex-direction: column-reverse;
      .content {
        height: 80px;
        font-size: 16px;
        padding: 20px 30px;
        display: flex;
        img {
          width: 25px;
          height: 25px;
          margin: 0 8px 0 0;
        }
      }
      .option {
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        margin: 10px 0;

        .queding {
          margin-left: 20px;
        }
      }
    }
  }
}

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