<template>
  <div class="bg-transparent flex resumption">
    <el-row :gutter="20">
      <!--机构数据-->
      <el-col :span="4" :xs="24">
        <org-tree
          v-model="queryParams.orgId"
          @defaultKey="getDefaultKey"
          @checkChange="checkChange"
          @click="clickTreeNode"
        ></org-tree>
      </el-col>
      <el-col :span="20" :xs="24">
        <!--    搜索条件    -->
        <el-form
          :model="queryParams"
          ref="queryParams"
          size="small"
          :inline="true"
          v-show="showSearch"
          label-width="100px"
        >
          <el-form-item label="履职计划">
            <el-select
              v-model="queryParams.planId"
              filterable
              placeholder="请选择履职计划"
            >
              <el-option
                v-for="item in planList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="履职角色">
            <el-select
              v-model="queryParams.executeRole"
              placeHolder="请选择履职角色"
              clearable
            >
              <el-option
                v-for="item in roleList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="履职周期">
            <el-select
              v-model="queryParams.executeCycle"
              placeHolder="请选择履职周期"
              clearable
              @change="changeType($event)"
            >
              <el-option
                v-for="item in dict.type.plan_cycle"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="任务状态">
            <el-select
              v-model="queryParams.status"
              placeHolder="请选择任务状态"
              clearable
            >
              <el-option
                v-for="item in dict.type.resumption_status"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            class="searchTitle"
            label="计划时间"
            v-if="
              queryParams.executeCycle == 1 || queryParams.executeCycle == 2 || queryParams.executeCycle == null || queryParams.executeCycle==0
            "
          >
            <DataRangePicker
              v-model="queryParams.range"
              key="daterange"
              type="daterange"
              :clearable="timeClearable"
            />
          </el-form-item>
          <el-form-item
            class="searchTitle"
            label="计划时间"
            v-if="queryParams.executeCycle == 3"
          >
            <!-- :format='weekStart+" 到 "+weekEnd+ 第WW周'  format=" yyyy 第 WW 周"-->
            <el-date-picker
              :picker-options="{ firstDayOfWeek: 1 }"
              key="week"
              v-model="week"
              @change="weekChanged"
              :clearable="timeClearable"
              type="week"
              format=" yyyy 第 WW 周"
              placeholder="选择周"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item
            class="searchTitle"
            label="计划时间"
            v-if="queryParams.executeCycle == 4"
          >
            <el-date-picker
              v-model="monthRange"
              @change="monthChanged"
              type="monthrange"
              key="monthRange"
              align="right"
              :clearable="timeClearable"
              unlink-panels
              range-separator="-"
              start-placeholder="开始月份"
              end-placeholder="结束月份"
            />
          </el-form-item>

          <el-form-item
            class="searchTitle"
            label="计划时间"
            v-if="queryParams.executeCycle == 5"
          >
            <el-date-picker
              :clearable="timeClearable"
              type="year"
              align="right"
              key="quarterSyearS"
              v-model="yearS"
            />
            -
            <el-select v-model="quarterS" placeholder="请选择">
              <el-option
                v-for="item in optionsQS"
                :key="item.key"
                :label="item.text"
                :value="item.value"
                :clearable="timeClearable"
              />
            </el-select>

            <label
              class="el-form-item__label"
              style="margin: 0 10px; padding: 0"
              >至</label
            >
            <el-date-picker
              :clearable="timeClearable"
              type="year"
              v-model="yearE"
              key="quarterSyearE"
              align="right"
            />
            -
            <el-select v-model="quarterE" placeholder="请选择">
              <el-option
                v-for="item in optionsQE"
                :key="item.key"
                :label="item.text"
                :value="item.value"
                :clearable="timeClearable"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="计划时间" v-if="queryParams.executeCycle == 6">
            <el-date-picker
              :clearable="timeClearable"
              type="year"
              align="right"
              key="halfyearS"
              v-model="yearS"
            />
            -
            <el-select v-model="halfyearS" placeholder="请选择">
              <el-option
                v-for="item in optionsHS"
                :key="item.key"
                :label="item.text"
                :value="item.value"
                :clearable="timeClearable"
              />
            </el-select>

            <label
              class="el-form-item__label"
              style="margin: 0 10px; padding: 0"
              >至</label
            >
            <el-date-picker
              :clearable="timeClearable"
              type="year"
              v-model="yearE"
              key="halfyearE"
              align="right"
            />
            -
            <el-select v-model="halfyearE" placeholder="请选择">
              <el-option
                v-for="item in optionsHE"
                :key="item.key"
                :label="item.text"
                :value="item.value"
                :clearable="timeClearable"
              />
            </el-select>
          </el-form-item>

          <el-form-item
            class="searchTitle"
            label="计划时间"
            v-if="queryParams.executeCycle == 7"
          >
            <el-date-picker
              :clearable="timeClearable"
              type="year"
              align="right"
              v-model="yearS"
              key="yearS"
            />
            <label
              class="el-form-item__label"
              style="margin: 0 10px; padding: 0"
              >至</label
            >
            <el-date-picker
              :clearable="timeClearable"
              type="year"
              v-model="yearE"
              align="right"
              key="yearE"
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="getList"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
        <!--    按纽    -->
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-download"
              size="mini"
              @click="exportExcel()"
              v-hasPermi="['system:user:add']"
              >导出</el-button
            >
          </el-col>

          <right-toolbar
            :showSearch.sync="showSearch"
            @queryTable="getList"
            :columns="columns"
          ></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="pageData">
          <el-table-column
          type="index"
            min-width="4%"
            v-if="columns[0].visible"
          >
            <template slot-scope="r">{{ r.row.order }}</template>
          </el-table-column>
          <el-table-column
            prop="name"
            label="任务名称"
            min-width="20%"
            v-if="columns[1].visible"
          >
            <template slot-scope="r">{{ r.row.planName }}</template>
          </el-table-column>
          <el-table-column
            prop="planStartTime"
            label="任务开始时间"
            min-width="15%"
            v-if="columns[2].visible"
          />
          <el-table-column
            prop="planEndTime"
            label="任务结束时间"
            min-width="15%"
            v-if="columns[3].visible"
          />

          <el-table-column
            prop="status"
            label="上级机构"
            min-width="15%"
            v-if="columns[4].visible"
          >
            <template slot-scope="r">
              {{ r.row.parentOrgName }}
            </template>
          </el-table-column>
          <el-table-column
            prop="status"
            label="履职机构"
            min-width="15%"
            v-if="columns[5].visible"
          >
            <template slot-scope="r">
              {{ r.row.orgName }}
            </template>
          </el-table-column>
          <el-table-column
            prop="status"
            label="履职角色"
            min-width="10%"
            v-if="columns[6].visible"
          >
            <template slot-scope="r">
              {{ r.row.roleName }}
            </template>
          </el-table-column>
          <el-table-column
            prop="submitter"
            label="提交人"
            min-width="10%"
            v-if="columns[7].visible"
          ></el-table-column>
          <el-table-column
            label="提交时间"
            min-width="15%"
            v-if="columns[8].visible"
          >
            <template slot-scope="r">{{
              r.row.submitTime | dateTime
            }}</template>
          </el-table-column>
          <el-table-column
            prop="abnormalDataNums"
            label="异常个数"
            min-width="9%"
            v-if="columns[8].visible"
          >
            <template slot-scope="r">{{ r.row.abnormalDataNums }}</template>
          </el-table-column>
          <el-table-column
            prop="status"
            label="任务状态"
            min-width="8%"
            v-if="columns[9].visible"
          >
            <template slot-scope="r">
              <label :style="statusStyle(r.row.status)">
                {{ getLabel(dict.type.resumption_status, r.row.status) }}</label
              >
            </template>
          </el-table-column>
          <el-table-column label="操作" min-width="13%">
            <template slot-scope="r">
              <!-- <el-button v-if="
                            r.row.status == 'WAIT' &&
                            queryParams.type == 'QUARTER'
                        " type="text" @click="onEdit(r.row.id)">履职</el-button>
                        <el-button v-else-if="
                            r.row.status != 'NA' &&
                            r.row.status != 'NOT' &&
                            r.row.status != 'WAIT'
                        " type="text" @click="onEdit(r.row.id, { isRead: true })">查看</el-button> -->
              <el-button type="text" @click="showDetail(r.row)" v-show="r.row.status!=2 || r.row.status!=3">查看</el-button>
              <el-button type="text" @click="showscanRecord(r.row)" v-show="r.row.status!=2 || r.row.status!=3"
                >扫描记录</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
    <!-- 详情 -->
    <dialog-detail ref="detaildialog"></dialog-detail>
    <dialog-scan-record ref="scanrecorddialog"></dialog-scan-record>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
// import { Message } from "element-ui";
import DialogDetail from "./dialog.detail";
import DialogScanRecord from "./dialog.scanrecord";
import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
import OrgTree from "@/components/orgTree";
import * as api from "@/api/resumption/taskManger.js";
import { getLabel } from "@/views/commonOption.js";

export default {
  name: "overviewDetialList",
  dicts: ["plan_cycle", "resumption_status"],
  components: { DialogDetail, DialogScanRecord, DataRangePicker, OrgTree },
  data() {
    // const { params, query } = this.$route;
    let sDate = new Date();
    let eDate = new Date();
    // if (query.startDate != undefined) {
    //   sDate = new Date(query.startDate);
    // }
    // if (query.endDate != undefined) {
    //   eDate = new Date(query.endDate);
    // }
    // let tempType = 1;
    // let tempOrgId = 1;
    // let tempRole = null;
    // let tempstatus = null;
    // if (query.executeCycle != undefined) tempType = query.executeCycle;
    // if (query.orgId != undefined) tempOrgId = parseInt(query.orgId);
    // else {
    //   if (
    //     this.loginUser != undefined &&
    //     this.loginUser.org != undefined &&
    //     this.loginUser.org.id != undefined
    //   )
    //     tempOrgId = parseInt(this.loginUser.org.id);
    // }
    // if (query.executeRole != undefined && query.executeRole != "all")
    //   tempRole = query.executeRole;
    // if (query.status != undefined && query.status != "all")
    //   tempstatus = query.status;

    let temphalfyearE = 1;
    let temphalfyearS = 1;
    let tempquarterE = 1;
    let tempquarterS = 1;

    // if (query.halfyearE != undefined) temphalfyearE = parseInt(query.halfyearE);
    // if (query.halfyearS != undefined) temphalfyearS = parseInt(query.halfyearS);
    // if (query.quarterE != undefined) tempquarterE = parseInt(query.quarterE);
    // if (query.quarterS != undefined) tempquarterS = parseInt(query.quarterS);
    return {
      loading: false,
      showSearch: true,
      total: 0,
      timeClearable: false,
      options: [],
      roleList: [],
      planList: [],
      yearS: sDate,
      yearE: eDate,
      halfyearE: temphalfyearE,
      halfyearS: temphalfyearS,
      quarterE: tempquarterE,
      quarterS: tempquarterS,
      monthRange: [sDate, eDate],
      week: sDate,
      weekStart: null,
      weekEnd: null,
      optionsHS: [
        { key: "1", value: 1, text: "上半年" },
        { key: "2", value: 2, text: "下半年" },
      ],
      optionsHE: [
        { key: "1", value: 1, text: "上半年" },
        { key: "2", value: 2, text: "下半年" },
      ],
      optionsQS: [
        { key: "1", value: 1, text: "第一季度" },
        { key: "2", value: 2, text: "第二季度" },
        { key: "3", value: 3, text: "第三季度" },
        { key: "4", value: 4, text: "第四季度" },
      ],
      optionsQE: [
        { key: "1", value: 1, text: "第一季度" },
        { key: "2", value: 2, text: "第二季度" },
        { key: "3", value: 3, text: "第三季度" },
        { key: "4", value: 4, text: "第四季度" },
      ],
      queryParams: {
        executeCycle: "1",
        checkSub: false,
        orgId: null,
        range: [sDate, eDate],
        executeRole: null,
        status: null,
        planId: null,
        pageNum: 1,
        pageSize: 10,
      },
      pageData: [],
      columns: [
        { key: 0, label: `序号`, visible: true },
        { key: 1, label: `计划名称`, visible: true },
        { key: 2, label: `开始时间`, visible: true },
        { key: 3, label: `结束时间`, visible: true },
        { key: 4, label: `上级机构`, visible: true },
        { key: 5, label: `履职机构`, visible: true },
        { key: 6, label: `履职角色`, visible: true },
        { key: 2, label: `提交人`, visible: true },
        { key: 3, label: `提交时间`, visible: true },
        { key: 4, label: `异常个数`, visible: true },
        { key: 5, label: `任务状态`, visible: true },
      ],
    };
  },
  props: {},
  watch: {
    // org: {
    //   deep: true,
    //   immediate: true,
    //   handler(nOrg) {
    //     if (nOrg.id) {
    //       this.queryParams.orgId = nOrg.id;
    //     } else {
    //       this.queryParams.orgId = this.loginUser.org.id;
    //     }
    //     this.roleVal = "all";
    //     this.planVal = -1;
    //     this.loadRoles(this.queryParams.orgId);
    //   },
    // },
    statusVal(value) {
      if (value == undefined) return;
      if (value == "all") this.queryParams.status = null;
      else this.queryParams.status = value;
    },
    planVal(value) {
      if (value == undefined) return;
      if (value == -1) this.queryParams.planId = null;
      else this.queryParams.planId = value;
    },
    $route(v) {
      //this.queryParams.type = this.$route.params.type.toUpperCase();
    },
    // 0每日；1每周；2每月；3每季度；4每半年；5每年
    yearS(val) {
      if (this.yearE < val) {
        this.yearE = val;
        if (this.queryParams.executeCycle == 3) {
          if (this.quarterS > this.quarterE) {
            this.quarterS = this.quarterE;
          } else this.resetRangeParam();
        } else if (this.queryParams.executeCycle == 4) {
          if (this.halfyearS > this.halfyearE) {
            this.halfyearS = this.quarterE;
          } else this.resetRangeParam();
        }
      } else this.resetRangeParam();
    },
    yearE(val) {
      if (val < this.yearS) {
        this.yearS = val;
        if (this.queryParams.executeCycle == 3) {
          if (this.quarterS > this.quarterE) {
            this.quarterS = this.quarterE;
          } else this.resetRangeParam();
        } else if (this.queryParams.executeCycle == 4) {
          if (this.halfyearS > this.halfyearE) {
            this.halfyearS = this.halfyearE;
          } else this.resetRangeParam();
        }
      } else this.resetRangeParam();
    },
    quarterS(val) {
      if (this.yearS == this.yearE) {
        if (val > this.quarterE) this.quarterE = val;
        else this.resetRangeParam();
      } else this.resetRangeParam();
    },
    quarterE(val) {
      if (this.yearS == this.yearE) {
        if (val < this.quarterS) this.quarterS = val;
        else this.resetRangeParam();
      } else this.resetRangeParam();
    },
    halfyearS(val) {
      console.log("ccccccccc", val);
      if (this.yearS == this.yearE) {
        if (val > this.halfyearE) this.halfyearE = val;
        else this.resetRangeParam();
      } else this.resetRangeParam();
    },
    halfyearE(val) {
      console.log("dddddddddd", val);
      if (this.yearS == this.yearE) {
        if (val < this.halfyearS) this.halfyearS = val;
        else this.resetRangeParam();
      } else this.resetRangeParam();
    },
    monthRange(val) {
      this.resetRangeParam();
    },
  },
  computed: {
    ...mapState(["org", "loginUser"]),
  },
  methods: {
    ...mapMutations([]),
    getLabel,
    toName(row) {
      // const ymd = row.ymd;
      const ymd = new Date(row.ymdDate);
      switch (row.executeCycle) {
        case 0:
          return `${ymd.year}年${ymd.month}月${ymd.day}日-${row.formTypeText}`;
        case 1:
          return `${ymd.year}年第${ymd.week}周-${row.formTypeText}`;
        case 2:
          return `${ymd.year}年第${ymd.month}月`;
        case 3:
          return `${ymd.year}年第${ymd.quarter}季`;
        case 4:
          let text = ymd.halfyear == 1 ? "上" : "下";
          return `${ymd.year}年${text}每半年`;
        case 5:
          return `${ymd.year}年`;
        case 6:
          return `${ymd.year}年${ymd.month}月${ymd.day}日${ymd.hour}小时${ymd.minute}分钟-${row.formTypeText}`;
      }
    },

    async exportExcel() {
      if (!this.isTableHaveData) {
        Message.error({
          message: `暂无可用数据导出！`,
          type: "error",
          duration: 2000,
        });
        return;
      }
      await api.exportResumptionRecord(this.queryParams);
    },
    showDetail(row) {
      this.$refs.detaildialog.show(row.resumptionId, row.name,row.ymd);
      //this.$refs.detaildialog.show("75246a09eba74e018b60ade0b1f336f8", row.planName);
    },
    showscanRecord(row) {
      this.$refs.scanrecorddialog.show(row.resumptionId, row.orgId);
    },

    getDefaultKey(key) {
      this.queryParams.orgId = key;
      this.getList();
      this.loadRoles(key);
      this.loadPlanList();
    },
    //单选框状态改变
    checkChange(state) {
      this.queryParams.checkSub = state;
      
      this.getList();
    },
    // 节点单击事件
    clickTreeNode(data) {
      this.queryParams.orgId = data.id;
      this.loadPlanList();
      this.loadRoles();
      this.getList();
    },
    resetQuery() {
      this.resetForm("queryParams");
      this.queryParams.orgId = undefined;
      this.queryParams.checkSub = false;
      this.$refs.tree.setCurrentKey(null);
      this.getList();
    },
    async getList() {
      this.loading = true;
      console.log("this.queryParams", this.queryParams);
      api
        .page(this.queryParams)
        .then((r) => {
          this.pageData = r.rows;
          this.total = r.total;
          this.loading = false;
        })
        .catch((e) => {
          this.loading = false;
        });
    },
    loadRoles() {
      api
        .getRoles({
          orgId: this.queryParams.orgId,
          planCycle: Number(this.queryParams.executeCycle),
        })
        .then((r) => (this.roleList = r.data));
    },

    loadPlanList() {
      api
        .getPlans({
          orgId: this.queryParams.orgId,
          // checkSub: this.queryParams.checkSub,
        })
        .then((r) => {
          this.planList = r.data;
        });
    },
    async changeType(selectValue) {
      // console.log("selectValue",selectValue.target.value)
      // this.planVal = -1;
      this.queryParams.executeCycle = selectValue;

      let nowDate = new Date();
      let nowMonth = nowDate.getMonth();
      if (nowMonth <= 2) {
        this.quarterS = 1;
        this.quarterE = 1;
        this.halfyearS = 1;
        this.halfyearE = 1;
      } else if (nowMonth <= 5) {
        this.quarterS = 2;
        this.quarterE = 2;
        this.halfyearS = 1;
        this.halfyearE = 1;
      } else if (nowMonth <= 8) {
        this.quarterS = 3;
        this.quarterE = 3;
        this.halfyearS = 2;
        this.halfyearE = 2;
      } else if (nowMonth <= 11) {
        this.quarterS = 4;
        this.quarterE = 4;
        this.halfyearS = 2;
        this.halfyearE = 2;
      }
      // 1每小时；2每天.......；3每月；4每季度；4每半年；5每年
      if (this.queryParams.executeCycle == 3) {
        if (!this.week) this.week = new Date();
        
        let oneDayLong = 24*60*60*1000
        let c_day = this.week.getDay()
        let monday=this.week-(c_day==0?6:(c_day-1))*oneDayLong;
        let sunday=this.week+(c_day==0?0:(7-c_day))*oneDayLong;

        this.weekStart =`${monday.getYear()}-${monday.getMonth()}-${monday.getDate()}`;
        this.weekEnd = `${sunday.getYear()}-${sunday.getMonth()}-${sunday.getDate()}`;
        // this.weekChanged();
      }
      this.resetRangeParam();
    },

    weekChanged() {

      var date = this.$moment(this.week).isoWeekday(1);
      this.weekStart = date.weekday(1).format("YYYY-MM-DD");
      this.weekEnd = date.weekday(7).format("YYYY-MM-DD");
      this.resetRangeParam();
    },
    monthChanged() {
      this.resetRangeParam();
    },
    async resetRangeParam() {  
      if (this.queryParams.executeCycle == 3) {
        let yearSval = this.yearS.getFullYear();
        let yearEval = this.yearE.getFullYear();
        let sQDate = yearSval + "-";
        let eQData = yearEval + "-";

        switch (this.quarterS) {
          case 1:
            sQDate += "01-01";
            break;
          case 2:
            sQDate += "04-01";
            break;
          case 3:
            sQDate += "07-01";
            break;
          case 4:
            sQDate += "10-01";
            break;
        }

        switch (this.quarterE) {
          case 1:
            eQData += "03-31";
            break;
          case 2:
            eQData += "06-30";
            break;
          case 3:
            eQData += "09-30";
            break;
          case 4:
            eQData += "12-31";
            break;
        }

        this.queryParams.range = [new Date(sQDate), new Date(eQData)];
      } else if (this.queryParams.executeCycle == 4) {
        let yearSval = this.yearS.getFullYear();
        let yearEval = this.yearE.getFullYear();
        let sHDate = yearSval + "-";
        let eHData = yearEval + "-";

        switch (this.halfyearS) {
          case 1:
            sHDate += "01-01";
            break;
          case 2:
            sHDate += "07-01";
            break;
        }

        switch (this.halfyearE) {
          case 1:
            eHData += "06-30";
            break;
          case 2:
            eHData += "12-31";
            break;
        }
        this.queryParams.range = [new Date(sHDate), new Date(eHData)];
      } else if (this.queryParams.executeCycle == 5) {
        let yearSval = this.yearS.getFullYear();
        let yearEval = this.yearE.getFullYear();
        let sYDate = yearSval + "-01-01";
        let eYData = yearEval + "-12-31";

        this.queryParams.range = [new Date(sYDate), new Date(eYData)];
      } else if (this.queryParams.executeCycle == 2) {
        if (!this.monthRange || this.monthRange.length != 2) {
          this.queryParams.range = null;
        } else {
          let dateObjS = this.monthRange[0];
          let dateObjE = this.monthRange[1];
          if (dateObjS.getFullYear == undefined) {
            dateObjS = new Date(dateObjS);
            dateObjE = new Date(dateObjE);
          }
          let sMDate =
            dateObjS.getFullYear() + "-" + (dateObjS.getMonth() + 1) + "-1";
          let eMData =
            dateObjE.getFullYear() + "-" + (dateObjE.getMonth() + 1) + "-1";

          let tempDate = new Date(
            dateObjE.getFullYear(),
            dateObjE.getMonth(),
            29
          );
          if (dateObjE.getMonth() == 1 && tempDate.getDate() === 29) {
            eMData =
              dateObjE.getFullYear() + "-" + (dateObjE.getMonth() + 1) + "-29";
          } else {
            switch (dateObjE.getMonth()) {
              case 0:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-31";
                break;
              case 1:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-28";
                break;
              case 2:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-31";
                break;
              case 3:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-30";
                break;
              case 4:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-31";
                break;
              case 5:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-30";
                break;
              case 6:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-31";
                break;
              case 7:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-31";
                break;
              case 8:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-30";
                break;
              case 9:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-31";
                break;
              case 10:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-30";
                break;
              case 11:
                eMData =
                  dateObjE.getFullYear() +
                  "-" +
                  (dateObjE.getMonth() + 1) +
                  "-31";
                break;
            }
          }
          this.queryParams.range = [new Date(sMDate), new Date(eMData)];
        }
      } else if (this.queryParams.executeCycle == 1) {
        this.queryParams.range = [
          new Date(this.weekStart),
          new Date(this.weekEnd),
        ];
      } else if (
        this.queryParams.executeCycle === 0 ||
        this.queryParams.executeCycle == 6
      ) {
        this.queryParams.range = this.$dateRange.before(0);
      }
    },
    statusStyle(status) {
      let color = "";
      switch (status) {
        case "1":
          color = "#BFBFBF";
        case "2":
          color = "1890FF";
        case "3":
          color = "52C41A";
        case "4":
          color = "F5222D";
      }

      return "list-style-type:disc;color:" + color;
    },
  },
  async mounted() {
    // const { params, query } = this.$route;
    // if (this.loginUser && this.loginUser.org && this.loginUser.org.id) {
    //   if (query == undefined || query.orgId == undefined) {
    //     this.queryParams.orgId = this.loginUser.org.id;
    //   }
    // }
    // this.loadRoles(this.queryParams.orgId);
    // await this.loadtypes();
    // this.loadPlanList();
    // await this.refresh();
  },
};
</script>

<style lang="scss">
// .searchItem {
//   margin-right: 10px;
//   margin-top: 5px;
//   margin-bottom: 5px;
// }

// .searchTitle {
//   margin-right: 10px !important;
//   margin-bottom: 0 !important;
//   margin-top: 0 !important;
// }
</style>
