<template>
    <div class="app-container">
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="68px"
      >
        <el-form-item label="项目名称" prop="projectName">
          <el-input
            v-model="queryParams.projectName"
            placeholder="请输入项目名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="项目分类" prop="projectType">
          <el-select
            v-model="queryParams.projectType"
            placeholder="请选择项目分类"
            clearable
          >
            <el-option
              v-for="dict in dict.type.project_category"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="建设类型" prop="projectNature">
          <el-select
            v-model="queryParams.projectNature"
            placeholder="请选择项目建设类型"
            clearable
          >
            <el-option
              v-for="dict in dict.type.project_build_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="责任主体" prop="deptId" v-hasPermi="['project:project:zgs']">
          <el-select v-model="queryParams.deptId" placeholder="请选择责任主体" clearable>
            <el-option
              v-for="dict in depts"
              :key="dict.deptId"
              :label="dict.deptName"
              :value="dict.deptId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="汇总时间">
            <el-date-picker
            v-model="daterangeTime"
            style="width: 240px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
        ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"
            >搜索</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="warning"
          plain
          icon="el-icon-download"
          size="mini"
          v-hasPermi="['statistics:project:export']"
          @click="handleExport"
          >导出</el-button
        >
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
      <el-table
        v-loading="loading"
        :data="dataList"
        height="700"
        stripe border
      >
        <el-table-column
          label="项目名称"
          align="left"
          prop="projectName"
          width="200"
          class-name="small-padding fixed-width"
          fixed="left"
          show-overflow-tooltip
        />
        <el-table-column label="监理单位" align="left" fixed="left" prop="unitName" width="210" show-overflow-tooltip/>
        <el-table-column label="安全管理" align="center">
          <el-table-column label="隐患排查" align="center" prop="aqyhpc_jldw" width="90" show-overflow-tooltip/>
          <el-table-column label="应急演练" align="center" prop="yjyl" width="90" show-overflow-tooltip/>
          <el-table-column label="教育培训" align="center" prop="zxpx" width="90" show-overflow-tooltip/>
        </el-table-column>
        <el-table-column label="质量管理" align="center">
          <el-table-column label="隐患排查" align="center" prop="zlyhpc_jldw" width="90" show-overflow-tooltip/>
          <el-table-column label="取样复试审批中" align="center" prop="clqyfs" width="90" show-overflow-tooltip/>
          <el-table-column label="取样复试已审批" align="center" prop="clqyfswc" width="90" show-overflow-tooltip/>
          <el-table-column label="材料封样审批中" align="center" prop="clfy" width="90" show-overflow-tooltip/>
          <el-table-column label="材料封样已审批" align="center" prop="clfywc" width="90" show-overflow-tooltip/>
          <el-table-column label="实测实量审批中" align="center" prop="cscl" width="90" show-overflow-tooltip/>
          <el-table-column label="实测实量已审批" align="center" prop="csclwc" width="90" show-overflow-tooltip/>
          <el-table-column label="举牌验收审批中" align="center" prop="jpys" width="90" show-overflow-tooltip/>
          <el-table-column label="举牌验收已审批" align="center" prop="jpyswc" width="90" show-overflow-tooltip/>
        </el-table-column>
        <el-table-column label="工程管理" align="center">
          <el-table-column label="申请审批中" align="center" prop="gcsq" width="90" show-overflow-tooltip/>
          <el-table-column label="申请已审批" align="center" prop="gcsp" width="90" show-overflow-tooltip/>
        </el-table-column>
      </el-table>
    </div>
  </template>
  
  <script>
  import { selectStatisticsJlProjectList } from "@/api/statistics/statisticsProject";
  import axios from 'axios';
  
  export default {
    name: "statisticsJlProject",
    components: {},
    dicts: [
      "project_build_type",
      "project_category",
    ],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 查询参数
        queryParams: {
          projectName: null,
          projectType: "1",
          projectNature: null,
          deptId: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        depts: [],
        dataList:[],
        daterangeTime:[],
      };
    },
    created() {
      this.getList();
      this.$api.publics.getZgsDeptList().then((d) => {
        this.depts = d?.data || [];
      });
    },
    methods: {
      /** 查询项目管理列表 */
      getList() {
        this.loading = true;
        this.queryParams.params = {};
        if (null != this.daterangeTime && "" != this.daterangeTime) {
          this.queryParams.params["beginTime"] = this.daterangeTime[0];
          this.queryParams.params["endTime"] = this.daterangeTime[1];
        }
        selectStatisticsJlProjectList(this.queryParams).then((response) => {
          this.dataList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('/statistics/project/exportviewJl', {
          ...this.queryParams
        }, `config_${new Date().getTime()}.xlsx`)
      },
    },
  };
  </script>
  