<!--
 * @Author: zhangtq 2452618307@qq.com
 * @Date: 2024-12-02 15:16:35
 * @LastEditors: zhangtq 2452618307@qq.com
 * @LastEditTime: 2025-01-20 18:30:17
 * @FilePath: src/views/IndexPage/myToDoList.vue
 * @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
 -->
<template>
  <div class="container">
    <div class="header">
      <el-form :model="queryParams" ref="queryForm" inline  size="small">
        <el-form-item label="关键字" prop="title">
          <el-input v-model="queryParams.title" placeholder="请输入关键字" clearable v-no-whitespace></el-input>
        </el-form-item>
        <el-form-item label="时间" prop="timeRange">
          <el-date-picker
            v-model="queryParams.timeRange"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            format="yyyy-MM-dd"
            clearable
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearch">查询</el-button>
          <el-button @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="content">
      <el-table :data="tableList" fit highlight-current-row style="width: 100%">
        <el-table-column
          type="index"
          width="85"
          label="序号"
          align="center"
          :index="indexContinuous(queryParams.pageNum, queryParams.pageSize)"
        />
        <el-table-column
          v-for="(column, index) in tableColumns"
          show-overflow-tooltip
          :key="column.prop"
          :label="column.label"
          :prop="column.prop"
          align="center"
        >
          <!-- 插槽 -->
          <!-- <template v-slot="scope" v-if="column.prop == 'checkingInStatus'">
            <span>
              <el-switch v-model="scope.row.checkingInStatus" @change="changeSwitch(scope.row)"></el-switch>
            </span>
          </template> -->
        </el-table-column>
        <!-- 操作 -->
        <el-table-column label="操作" align="center" width="150">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="handler(scope.row)">处理</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"
        />

    </div>
  </div>
</template>

<script>
import { indexContinuous, parseTime } from '@/utils/bonus'
import { getMyToDoList } from '@/api/system/notice'

export default {
  name: 'myToDoList',
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        title: '',
        timeRange: [],
      },
      tableList: [],
      total: 0,
      tableColumns: [
        { label: '待办任务', prop: 'title' },
        { label: '待办数量', prop: 'num' },
      ],
      auditType: {
        1 : '/project/worksUnderConstruction/pro/supervisor/supervisedAdmission/index',
        2 : '/project/worksUnderConstruction/ContractorAdmissionQualification',
        3 : '/project/project_approval_during_construction/pro/apply/list/subEnterList',
        4 : '/project/worksUnderConstruction/pro/approval/list/consStartWorkApprovalList',
        5 : '/project/project_approval_during_construction/pro/approval/list/consPersonEnterApprovalList',
        6 : '/project/project_approval_during_construction/pro/approval/list/consPersonOutApprovalList',
        7 : '/project/project_approval_during_construction/pro/approval/list/consMaterialApprovalList',
        8 : '/project/project_approval_during_construction/pro/approval/list/consEquipApproval',
        9 : '/project/project_approval_during_construction/pro/approval/list/completeApplyList',
        10 : '/project/subManagement/pro/apply/list/subPersonEnterList',
        11 : '/project/project_approval_during_construction/pro/apply/list/subPersonOutList',
        12 : '/project/project_approval_during_construction/pro/apply/list/subOutList',
        13 : '/violationManagenment/violation/violationApprovalList',
        14 : '/hiddenDangerManagement/hazardRectificationManagement/hazardRectificationApproval/index',
        15 : '/hiddenDangerManagement/hazardRectificationManagement/hazardRectificationApproval/index',
        16 : '/hiddenDangerManagement/hazardRectificationManagement/hazardRectificationApproval/index',
        17 : '/hiddenDangerManagement/hazardRectificationManagement/extensionRequestApproval/index',
      }
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    indexContinuous,
    handleSearch() {
      this.getList()
    },
    handleReset() {
      this.$refs.queryForm.resetFields()
      this.getList()
    },
    handler(row) {
      this.$router.push({ path: this.auditType[Number(row.type)], query: { } })
    },
    getList() {
      const param = {
        ...this.queryParams,
        startTime: parseTime(this.queryParams.timeRange[0], '{y}-{m}-{d}'),
        endTime: parseTime(this.queryParams.timeRange[1], '{y}-{m}-{d}'),
      }
      getMyToDoList(param).then(response => {
        this.tableList = response.rows
        this.total = response.total
      })
    },
  },
}
</script>

<style scoped lang="scss">
.container{
  padding: 20px;
}
.content{
  padding: 10px;
}
</style>
