<template>
  <div>
    <div class="nav-title">任务管理</div>
    <div class="search">
      <el-form
        class="search-form"
        :model="form"
        ref="form"
        :inline="true"
        size="mini"
      >
        <el-form-item label="执行器：">
          <el-select v-model="form.jobGroup" placeholder="请选择">
            <el-option
              v-for="item in groupList"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="">
          <el-select v-model="form.triggerStatus" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.label"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="负责人：">
          <el-input v-model="form.author" placeholder="请输入负责人"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="success" @click="toSearch">查询</el-button>
          <el-button type="primary" @click="handleEdit">新增</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div>
      <el-table
        :data="tableData"
        style="width: 100%"
        :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
      >
        <el-table-column prop="id" label="任务ID" align="center" />
        <el-table-column prop="jobDesc" label="任务描述" align="center" />
        <el-table-column prop="scheduleConf" label="调度类型" align="center" />
        <el-table-column prop="alarmType" label="运行模式" align="center">
          <template slot-scope="scope">
            {{ scope.row.glueType }}:{{ scope.row.executorHandler }}
          </template>
        </el-table-column>
        <el-table-column prop="author" label="负责人" align="center" />
        <el-table-column prop="triggerStatus" label="状态" align="center">
          <template slot-scope="scope">
            <el-tag
              :type="scope.row.triggerStatus === 1 ? 'success' : 'warning'"
              >{{ scope.row.triggerStatus === 1 ? "运行中" : "已停止" }}</el-tag
            >
          </template>
        </el-table-column>

        <el-table-column label="操作" align="center" width="100">
          <template slot-scope="scope">
            <el-dropdown trigger="click" @command="handleCommand">
              <span class="el-dropdown-link">
                操作<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item :command="{ name: 'a', data: scope.row }"
                  >执行一次</el-dropdown-item
                >
                <el-dropdown-item :command="{ name: 'c', data: scope.row }"
                  >注册节点</el-dropdown-item
                >
                <el-dropdown-item :command="{ name: 'd', data: scope.row }"
                  >下次执行时间</el-dropdown-item
                >
                <el-dropdown-item
                  divided
                  v-if="scope.row.triggerStatus == 0"
                  :command="{ name: 'e', data: scope.row }"
                  >启动</el-dropdown-item
                >
                <el-dropdown-item
                  divided
                  v-if="scope.row.triggerStatus == 1"
                  :command="{ name: 'e', data: scope.row }"
                  >停止</el-dropdown-item
                >
                <el-dropdown-item :command="{ name: 'f', data: scope.row }"
                  >编辑</el-dropdown-item
                >
                <el-dropdown-item :command="{ name: 'g', data: scope.row }"
                  >删除</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <Pagination
        :limit="params.size"
        :page="params.current"
        :total="total"
        class="pagination"
        @pagination="handlePageChange"
      />
    </div>
    <el-dialog
      title="执行一次"
      :visible.sync="aDialogVisible"
      width="600px"
      @close="handleClose"
      center
    >
      <el-form :model="manageFrom" ref="form" size="mini">
        <el-form-item label="任务参数：">
          <!-- disabled -->
          <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4 }"
            placeholder="请输入任务参数"
            v-model="manageFrom.executorParam"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="机器地址：">
          <el-input
            type="textarea"
            disabled
            :autosize="{ minRows: 2, maxRows: 4 }"
            placeholder="请输入本次执行的机器地址，为空则从执行器获取"
            v-model="manageFrom.addressList"
          >
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleTriggerJobinfo"
            >确定</el-button
          >
          <el-button @click="handleClose()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog
      title="注册节点"
      :visible.sync="cDialogVisible"
      width="600px"
      @close="handleClose"
      center
    >
      <div
        style="margin: 8px"
        v-for="(item, index) in showData && showData.registryList"
        :key="index"
      >
        {{ index + 1 }}. {{ item }}
      </div>
    </el-dialog>
    <el-dialog
      title="任务"
      :visible.sync="addDialogVisible"
      width="800px"
      @close="handleClose"
      center
    >
      <el-form
        class="add-form"
        :inline="true"
        :model="addFrom"
        :rules="rules"
        ref="form"
      >
        <div class="mini-title">基础配置</div>
        <el-form-item label="执行器" class="both" prop="jobGroup">
          <el-select v-model="addFrom.jobGroup" placeholder="请选择">
            <el-option
              v-for="item in resGroupList"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务描述" class="both" prop="jobDesc">
          <el-input placeholder="请输入任务描述" v-model="addFrom.jobDesc">
          </el-input>
        </el-form-item>
        <el-form-item label="负责人" class="both" prop="author">
          <el-input placeholder="请输入负责人" v-model="addFrom.author">
          </el-input>
        </el-form-item>
        <el-form-item label="报警邮件" class="both">
          <el-input
            placeholder="请输入报警邮件，多个邮件地址则逗号分隔"
            v-model="addFrom.alarmEmail"
          >
          </el-input>
        </el-form-item>
        <div class="mini-title">调度配置</div>
        <el-form-item label="调度类型" class="both">
          <!-- scheduleType 空：NONE 固定速度：FIX_RATE   CRON:CRON -->

          <el-select
            disabled
            v-model="addFrom.scheduleType"
            placeholder="请选择"
          >
            <el-option
              v-for="item in scheduleType"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item
          v-if="addFrom.scheduleType == 'FIX_RATE'"
          label="固定速度"
          class="both"
        >
          <el-input
            placeholder="请输入 （ Second ）"
            v-model="addFrom.scheduleConf"
          >
          </el-input>
        </el-form-item> -->
        <el-form-item prop="scheduleConf" label="CRON" class="both">
          <!-- scheduleConf 固定速度的值 -->
          <!-- schedule_conf_FIX_RATE 还有个这个 -->
          <el-popover
            placement="bottom"
            width="448"
            trigger="hover"
            v-model="visible"
          >
            <el-tabs v-model="activeName" type="card">
              <el-tab-pane label="秒" name="1">
                <pre>
输入内容为【秒 分 时 日 月 周 年】中间空格隔开
如【* * * * * ? 2016-2017】为 
2016-2017年的所有日期的每秒都执行一次

1. 每秒 【*】允许的通配符[, - * /]
例：【* * * * * ? 2016-2017】
2. 周期 从1-2秒为 【1-2】  
例：【1-2 * * * * ? 2016-2017】
3. 从1秒开始 每2秒执行一次 【1/2】
例：【1/2 * * * * ? 2016-2017】
4. 指定 如 0s 1s 3s执行为：【0,1,3】 可选值为0-59
例：【0,1,3 * * * * ? 2016-2017】
                </pre>
              </el-tab-pane>
              <el-tab-pane label="分钟" name="2">
                <pre>

1. 每分钟 【*】允许的通配符[, - * /]
2. 周期 从1-2分钟为 【1-2】
3. 从1分钟开始 每2分钟执行一次 【1/2】
4. 指定 如 0分钟 1分钟 3分钟执行为：【0,1,3】 可选值为0-59

例见秒的说明
                </pre>
              </el-tab-pane>
              <el-tab-pane label="小时" name="3">
                <pre>

1. 每秒小时 【*】允许的通配符[, - * /]
2. 周期 从1-2天为 【1-2】
3. 从1小时开始 每2小时执行一次 【1/2】
4. 指定 如 0小时 1小时 3小时执行为：【0,1,3】 可选值为0-23

例见秒的说明
                </pre>
              </el-tab-pane>
              <el-tab-pane label="日" name="4">
                <pre>

1. 每天 【*】允许的通配符[, - * / L W]
2. 不指定【?】
例：【* * * ? * ? 2016-2017】
3. 周期 从1-2日为 【1-2】
4. 从1日开始 每1日执行一次 【1/1】
5. 每月1号最近的那个工作日 【1W】
例：【* * * 1W * ? 2016-2017】
6. 本月最后一天 【L】
例：【* * * L * ? 2016-2017】
6. 指定 如 1号、2号、3号执行为：【1,2,3】可选值为1-31

其他例见秒的说明
                </pre>
              </el-tab-pane>
              <el-tab-pane label="月" name="5">
                <pre>
1. 每月 【*】允许的通配符[, - * /]
2. 不指定【?】
3. 周期 从1-2月为 【1-2】
4. 从1月开始 每2月执行一次 【1/2】
5. 指定 如 1月、2月、3月执行为：【1,2,3】可选值为1-12
                </pre>
              </el-tab-pane>
              <el-tab-pane label="周" name="6">
                <pre>
1. 每周 【*】允许的通配符[, - * / L #]
2. 不指定【?】
3. 周期 从星期一到星期二为 【1-2】
4. 从1周开始的星期一 【1/2】
5. 本月最后一个星期 【L】
6. 指定 如 周一、周二、周三执行为：【1,2,3】可选值为1-7
                </pre>
              </el-tab-pane>
              <el-tab-pane label="年" name="7">
                <pre>
1. 不指定 【?】
2. 每年 【*】
3. 周期从2016-2017年 【2016-2017】
                </pre>
              </el-tab-pane>
            </el-tabs>
            <el-input
              slot="reference"
              placeholder="请输入 CRON"
              v-model="addFrom.scheduleConf"
            >
              <i
                slot="suffix"
                style="cursor: pointer"
                @click="visible = !visible"
                class="el-input__icon el-icon-date"
              ></i>
            </el-input>
          </el-popover>
        </el-form-item>
        <div class="mini-title">任务配置</div>

        <el-form-item label="运行模式" class="both">
          <!-- 运行模式 BEAN -->
          <el-select disabled v-model="addFrom.glueType" placeholder="请选择">
            <el-option
              v-for="item in glueType"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="JobHandler" class="both">
          <el-input
            disabled
            placeholder="请输入负责人"
            v-model="addFrom.executorHandler"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="任务设备及参数" class="one" prop="executorParam">
          <el-select
            v-model="addFrom.executorParam.equipId"
            placeholder="请选择"
            v-loadmore="loadMore"
          >
            <el-option
              v-for="item in equipTableData"
              :key="item.id"
              :label="item.equipName"
              :value="item.id"
            >
            </el-option>
          </el-select>
          <div>
          </div>
          <el-checkbox-group
            v-model="addFrom.executorParam.params"
            :min="1"
            :max="6"
          >
            <el-checkbox
              v-for="city in itemOptions"
              :disabled="city=='轮询标识'"
              :label="city"
              :key="city"
              >{{ city }}</el-checkbox
            >
          </el-checkbox-group>
        </el-form-item>
        <!-- <el-form-item label="任务参数" class="one" prop="executorParam2"> -->

        <!-- </el-form-item> -->
        <div class="mini-title">高级配置</div>
        <el-form-item label="路由策略" class="both">
          <el-select
            disabled
            v-model="addFrom.executorRouteStrategy"
            placeholder="请选择"
          >
            <el-option
              v-for="item in executorRouteStrategy"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="调度过期策略" class="both">
          <el-select
            disabled
            v-model="addFrom.misfireStrategy"
            placeholder="请选择"
          >
            <el-option
              v-for="item in misfireStrategy"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="阻塞处理策略" class="both">
          <el-select
            disabled
            v-model="addFrom.executorBlockStrategy"
            placeholder="请选择"
          >
            <el-option
              v-for="item in executorBlockStrategy"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务超时时间" class="both">
          <el-input
            placeholder="任务超时时间，单位秒，大于零时生效"
            disabled
            v-model="addFrom.executorTimeout"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="失败重试次数" class="both">
          <el-input
            disabled
            placeholder="失败重试次数，大于零时生效"
            v-model="addFrom.executorFailRetryCount"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="" class="both">
          <!-- <el-input
            placeholder="请输入子任务的任务ID,如存在多个则逗号分隔"
            v-model="addFrom.childJobId"
          >
          </el-input> -->
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('form')">确定</el-button>
          <el-button @click="handleClose()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import {
  jobinfoList,
  triggerJobinfo,
  loadByIdJobinfo,
  jobgroupList,
  nextTriggerTime,
  start,
  stop,
  remove,
  add,
  update,
} from "@/api/job.js";
import { monitorEquiplist } from "../../setting/api.js";
import { successAlert, warningAlert } from "@/utils/alert";
export default {
  data() {
    var validatePass2 = (rule, value, callback) => {
      console.log("value", value);
      if (value.equipId === "") {
        // equipId
        callback(new Error("请选择设备"));
      } else if (value.params.length < 1) {
        callback(new Error("任务参数不能为空"));
      } else {
        callback();
      }
    };
    return {
      rules: {
        jobGroup: [
          { required: true, message: "请选择执行器", trigger: "blur" },
        ],
        jobDesc: [{ required: true, message: "请填写描述", trigger: "blur" }],
        author: [{ required: true, message: "请填写负责人", trigger: "blur" }],
        scheduleConf: [
          { required: true, message: "请填写CRON", trigger: "blur" },
        ],
        executorParam: [
          { validator: validatePass2, required: true, trigger: "blur" },
        ],
      },
      visible: false,
      itemOptions: [
        "轮询标识",
        "测量周期",
        "漏缆一般告警门限",
        "漏缆重要告警门限",
        "漏缆紧急告警门限",
        "监测服务器IP地址",
        "设备输出功率",
        "设备的起始频率",
        "设备的终止频率",
        "上行漏缆1起始位置",
        "上行漏缆1终止位置",
        "上行漏缆1百米损耗",
        "上行漏缆1相对传播速度",
        "下行漏缆1起始位置",
        "下行漏缆1终止位置",
        "下行漏缆1百米损耗",
        "下行漏缆1相对传播速度",
        "上行漏缆2起始位置",
        "上行漏缆2终止位置",
        "上行漏缆2百米损耗",
        "上行漏缆2相对传播速度",
        "下行漏缆2起始位置",
        "下行漏缆2终止位置",
        "下行漏缆2百米损耗",
        "下行漏缆2相对传播速度",
      ],
      scheduleType: [
        {
          value: "NONE",
          label: "空",
        },
        {
          value: "FIX_RATE",
          label: "固定速度",
        },
        {
          value: "CRON",
          label: "CRON",
        },
      ],
      glueType: [
        {
          value: "BEAN",
          label: "BEAN",
        },
        {
          value: "GLUE_GROOVY",
          label: "GLUE(Java)",
        },
        {
          value: "GLUE_SHELL",
          label: "GLUE(Shell)",
        },
        {
          value: "GLUE_PYTHON",
          label: "GLUE(Python)",
        },
        {
          value: "GLUE_PHP",
          label: "GLUE(PHP)",
        },
        {
          value: "GLUE_NODEJS",
          label: "GLUE(Nodejs)",
        },
        {
          value: "GLUE_POWERSHELL",
          label: "GLUE(PowerShell)",
        },
      ],
      executorRouteStrategy: [
        {
          value: "FIRST",
          label: "第一个",
        },
        {
          value: "LAST",
          label: "最后一个",
        },
        {
          value: "ROUND",
          label: "轮询",
        },
        {
          value: "RANDOM",
          label: "随机",
        },
        {
          value: "CONSISTENT_HASH",
          label: "一致性HASH",
        },
        {
          value: "LEAST_FREQUENTLY_USED",
          label: "最不经常使用",
        },
        {
          value: "LEAST_RECENTLY_USED",
          label: "最近最久未使用",
        },
        {
          value: "FAILOVER",
          label: "故障转移",
        },
        {
          value: "BUSYOVER",
          label: "忙碌转移",
        },
        {
          value: "SHARDING_BROADCAST",
          label: "分片广播",
        },
      ],
      misfireStrategy: [
        {
          value: "DO_NOTHING",
          label: "忽略",
        },
        {
          value: "FIRE_ONCE_NOW",
          label: "立即执行一次",
        },
      ],
      executorBlockStrategy: [
        {
          value: "SERIAL_EXECUTION",
          label: "单机串行",
        },
        {
          value: "DISCARD_LATER",
          label: "丢弃后续调度",
        },
        {
          value: "COVER_EARLY",
          label: "覆盖之前调度",
        },
      ],
      manageFrom: {},
      tableData: [],
      groupList: [],
      showData: {
        timeList: [],
      },
      addDialogVisible: false,
      aDialogVisible: false,
      cDialogVisible: false,
      dDialogVisible: false,
      form: {
        jobGroup: 0,
        triggerStatus: -1,
        jobDesc: "",
        executorHandler: "",
        author: "",
      },
      addFrom: {
        scheduleType: "CRON",
        executorRouteStrategy: "FIRST",
        executorBlockStrategy: "SERIAL_EXECUTION",
        misfireStrategy: "DO_NOTHING",
        glueType: "BEAN",
        executorHandler: "pollingHandler",
        executorTimeout: "0",
        executorFailRetryCount: "0",
        executorParam: {
          equipId: "",
          params: ['轮询标识'],
        },
      },
      params: {
        current: 1,
        size: 10,
      },
      resGroupList: [],
      total: 0,
      activeName: "1",
      options: [
        {
          id: -1,
          label: "全部",
        },
        {
          id: 1,
          label: "启动",
        },
        {
          id: 0,
          label: "停止",
        },
      ],
      equipTableData: [],
      page: {
        currents: 1,
        size: 10,
        total: 100,
      },
    };
  },
  mounted() {
    this.handleJobGroupList();
    this.getTableData();
  },
  methods: {
    handleChange(value) {
      console.log(value);
      this.addFrom.executorParam.params = value; // 直接更新数据模型
    },
    loadMore() {
      if (this.page.currents * this.page.size >= this.page.total) return;
      this.page.currents++;
      this.getTableData();
    },
    getTableData() {
      monitorEquiplist({
        current: this.page.currents,
        size: this.page.size,
      }).then((res) => {
        let list = this.equipTableData.concat(res.records);
        this.equipTableData = list;
        this.page.total = res.total;
      });
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.handleAdd();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    async handleAdd() {
      delete this.addFrom.addTime;
      delete this.addFrom.updateTime;
      delete this.addFrom.glueUpdatetime;
      console.log("----------1***********--------------");

      let params1 = JSON.parse(
        JSON.stringify(this.addFrom.executorParam.params)
      ).toString();
      let datas = JSON.parse(JSON.stringify(this.addFrom));
      datas.executorParam = `equipId:${this.addFrom.executorParam.equipId};\nparams:${params1}`;
      if (!datas.childJobId) {
        delete datas.childJobId;
      }
      let data = {
        ...datas,
      };
      const params = new URLSearchParams(data).toString();
      console.log("----------2***********--------------");

      let res;
      if (this.addFrom.id) {
        res = await update(params);
      } else {
        res = await add(params);
      }
      console.log("----------3***********--------------");

      if (res.code == 200) {
        this.addDialogVisible = false;
        this.addFrom = {
          executorParam: {
            equipId: "",
            params: [],
          },
        };
        this.handleJobinfoList();
        this.handleClose();
      }
    },
    handleRemove() {
      let data = {
        id: this.manageFrom.id,
      };
      const queryParams = new URLSearchParams(data).toString();
      this.$confirm("继续操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          remove(queryParams).then((res) => {
            this.$message.success("操作成功！");
            this.handleJobGroupList();
          });
        })
        .catch(() => {});
    },
    async handleStop() {
      let data = {
        id: this.manageFrom.id,
      };
      const queryParams = new URLSearchParams(data).toString();
      let res = await stop(queryParams);
      if (res.code == 200) {
        successAlert("操作成功");
        this.handleJobinfoList();
      }
    },
    async handleStart() {
      let data = {
        id: this.manageFrom.id,
      };
      const queryParams = new URLSearchParams(data).toString();
      let res = await start(queryParams);
      if (res.code == 200) {
        successAlert("操作成功");
        this.handleJobinfoList();
      }
    },
    async handleNextTriggerTime() {
      let data = {
        scheduleType: this.manageFrom.scheduleType,
        scheduleConf: this.manageFrom.scheduleConf,
      };
      const queryParams = new URLSearchParams(data).toString();
      let res = await nextTriggerTime(queryParams);
      this.showData.timeList = res.content;
      this.dDialogVisible = true;
    },
    // 查询节点
    async handleLoadByIdJobinfo() {
      let data = {
        id: this.manageFrom.jobGroup,
      };
      const queryParams = new URLSearchParams(data).toString();
      let res = await loadByIdJobinfo(queryParams);
      this.showData = res.content;
      this.cDialogVisible = true;
    },
    handleClose() {
      this.manageFrom = {};
      this.addFrom = {
        executorParam: {
          equipId: "",
          params: [],
        },
      };
      this.aDialogVisible = false;
      this.cDialogVisible = false;
      this.addDialogVisible = false;
    },
    // 执行一次
    async handleTriggerJobinfo() {
      let data = {
        id: this.manageFrom.id,
        executorParam: this.manageFrom.executorParam,
        addressList: this.manageFrom.addressList,
      };
      const queryParams = new URLSearchParams(data).toString();
      let res = await triggerJobinfo(queryParams);
      if (res.code == 200) {
        successAlert("操作成功");
        this.handleClose();
      }
    },
    handleCommand(e) {
      this.manageFrom = e.data;
      this.manageFrom.addressList = "http://127.0.0.1:9998";
      // jobgroup/loadById
      // /jobinfo/nextTriggerTime
      switch (e.name) {
        case "a":
          this.aDialogVisible = true;
          break;
        case "c":
          this.handleLoadByIdJobinfo();
          break;
        case "d":
          this.handleNextTriggerTime();
          break;
        case "e":
          if (e.data.triggerStatus == 0) {
            this.handleStart();
          } else {
            this.handleStop();
          }
          break;
        case "f":
          let datas = JSON.parse(JSON.stringify(e.data));
          let str = datas.executorParam;
          let equipId = "";
          let params = "";
          if (datas.executorParam) {
            console.log(str);

            // 使用 split 方法分割字符串
            let parts = str.split(";");
            datas.executorParam = {};

            // 遍历分割后的数组，提取 equipId 和 params

            parts.forEach((part) => {
              if (part.startsWith("equipId:")) {
                equipId = part.split(":")[1];
              } else if (part.startsWith("\nparams:")) {
                params = part.split(":")[1].split(",");
              }
            });
          }

          this.addDialogVisible = true;
          this.addFrom = datas;
          this.$set(this.addFrom.executorParam, "equipId", equipId);
          this.$set(this.addFrom.executorParam, "params", params);
          break;
        case "g":
          this.handleRemove();
          break;
        // loadByIdJobinfo;
        default:
          break;
      }
      console.log(e);
    },
    handlePageChange(pageData) {
      this.params.size = pageData.size;
      this.params.current = pageData.page;
      this.handleJobinfoList();
    },
    async handleJobinfoList() {
      let data = {
        jobGroup: this.form.jobGroup,
        triggerStatus: this.form.triggerStatus,
        jobDesc: this.form.jobDesc,
        executorHandler: this.form.executorHandler,
        author: this.form.author,
        start: (this.params.current - 1) * this.params.size,
        length: this.params.size,
      };
      const queryParams = new URLSearchParams(data).toString();
      let res = await jobinfoList(queryParams);
      this.tableData = res.data;
      this.total = res.recordsTotal;
    },
    toSearch() {
      this.handleJobinfoList();
    },
    handleEdit(e) {
      this.addDialogVisible = true;
    },

    async handleJobGroupList() {
      let data = {
        start: 0,
        length: 999,
      };
      const queryParams = new URLSearchParams(data).toString();
      const res = await jobgroupList(queryParams);
      this.resGroupList = res.data;

      this.groupList = JSON.parse(JSON.stringify(res.data));
      this.groupList.unshift({
        id: 0,
        title: "全部",
      });

      this.form.jobGroup = res.data[0].id;
      this.handleJobinfoList();
    },
  },
};
</script>

<style lang="scss" scoped>
.nav-title {
  color: #02a7f0;
  font-size: 20px;
  position: relative;
  padding-left: 16px;
  font-weight: bold;
  line-height: 28px;
}
.nav-title::before {
  content: "";
  position: absolute;
  left: 0px;
  top: 1px;
  width: 5px;
  height: 100%;
  background-color: #02a7f0;
  border-radius: 4px;
}
.search {
  margin: 16px 0;
  .search-form {
    padding: 10px;
    background-color: #eaf1fe;
    margin-bottom: 20px;
    border-radius: 8px;
    .el-form-item--mini.el-form-item,
    .el-form-item--small.el-form-item {
      margin-bottom: 0;
    }
  }
}
.el-dropdown-menu {
  background: #fff;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.add-form {
  .mini-title {
    color: #02a7f0;
    font-size: 16px;
    position: relative;
    padding-left: 12px;
    font-weight: bold;
    line-height: 28px;
  }
  .mini-title::before {
    content: "";
    position: absolute;
    left: 0px;
    top: 1px;
    width: 3px;
    height: 90%;
    background-color: #02a7f0;
    border-radius: 4px;
  }

  .both {
    width: 360px;
  }
  .one {
    width: 730px;
  }
  ::v-deep .el-form-item__content {
    width: 100%;
  }
  .el-select {
    width: 100%;
  }
}
</style>