

<template>
    <div class="ProgreStatistics_Contain">
        <el-radio-group v-model="currentMenu" style="margin-bottom: 20px;" @input="toModule">
            <el-radio-button label="0">用料统计</el-radio-button>
            <el-radio-button label="1">进度统计</el-radio-button>
          <el-radio-button label="2">可视化统计</el-radio-button>
          <el-radio-button label="3">可视化进度</el-radio-button>
        </el-radio-group>
        <div class="topContain">
          <el-form :model="queryParams" ref="queryForm" :rules="searchRules" size="small" :inline="true"  v-show="showSearch" label-width="68px">
            <el-form-item label="行政区" prop="district">
              <el-select v-model="queryParams.district" placeholder="请选择行政区" clearable
                         @change="queryParams.areaId = undefined;getAreaList(queryParams.district)"
                         @clear="queryParams.areaId = undefined;areaList=[];
                   queryParams.buildingId = undefined;buildingList=[];
                   queryParams.unitId = undefined;unitList=[]">
                <el-option
                  v-for="dict in dict.type.district"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="小区名称" prop="areaId" label-width="80px">
              <el-select v-model="queryParams.areaId" filterable clearable placeholder="请选择小区">
                <el-option
                  v-for="item in areaList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="工程周期" prop="enginCycle" label-width="80px">
              <el-select v-model="queryParams.enginCycle" filterable clearable placeholder="请选择规格">
                <el-option
                  v-for="dict in dict.type.engin_cycle"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </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-select-->
<!--                v-model="currentType"-->
<!--                placeholder="请选择"-->
<!--                class="projectSelect"-->
<!--                popper-class="projectDropDown"-->
<!--                :popper-append-to-body="false"-->
<!--                >-->
<!--            <el-option-->
<!--                v-for="e in typeOptions"-->
<!--                :key="e.value"-->
<!--                :label="e.label"-->
<!--                :value="e.value">-->
<!--                </el-option>-->
<!--            </el-select>-->
<!--            <el-button class="searchBtn">查询</el-button>-->
        </div>
        <el-table
            class="materialStatisticsTable"
            :data="tableData"
            border
            :cell-style="tableRowClassName"
            style="width: 100%">
            <el-table-column
            prop="areaName"
            width="250"
            label="小区名称"
            >
            </el-table-column>
            <el-table-column
            prop="notstart"
            label="未施工（户）"
            >
            </el-table-column>
            <el-table-column
            prop="willDone"
            label="施工中（户）">
            </el-table-column>
            <el-table-column
            prop="done"
            label="竣工（户）">
            </el-table-column>

        </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
</template>

<script>
import  {
  getAreaCompletionInformationList
} from '@/api/zdsz/overhead'
import {getAreaList, getBuildingList} from "@/api/zdsz/enginee";
import {getUnits} from "@/api/zdsz/unit";
export default {
    name:'ProgreStatistics',
   dicts:['engin_cycle','district'],
    data(){
        return {
          showSearch: true,
          buildingList: [],
          areaList:[],
          unitList: [],
          total:0,
          queryParams:{pageNum:1,pageSize:10, areaId:undefined,enginCycle:"0"},
            currentMenu:1,   // 0:用料管理 1:进度统计 2:可视化进度
            typeOptions:[

            ],
            tableData: [

            ],
            currentType:'管',
            searchRules:{
                district: [
                    {required: true, message: "行政区不能为空", trigger: ['change']}
                ],
                areaId: [
                    {required: true, message: "小区不能为空", trigger: ['change']}
                ],
                enginCycle: [
                    {required: true, message: "工程周期不能为空", trigger: ['change']}
                ],
            }
        }
    },
  mounted() {
      this.getList()
  },
  methods:{
    getAreaList(district) {
      if (district === undefined || district == null || district === '')
        return
      getAreaList({district: district}).then(res => this.areaList = res.data)
    },
    getBuildingList1(areaId) {
      if (areaId === undefined || areaId == null || areaId === '')
        return
      getBuildingList({areaId: areaId}).then(res => this.buildingList = res.data)
    },
    getUnitList1(buildingId) {
      if (buildingId === undefined || buildingId == null || buildingId === '')
        return
      getUnits(this.queryParams.areaId, buildingId).then(res => this.unitList = res.data)
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.$refs.queryForm.validate(valid => {
          if(valid){
              // 校验 pass
              this.getList();
          } else {
              this.$message.error('请填写必填项!')
          }
      })
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.tableData=[]
      this.queryParams = {pageNum:1,pageSize:10, areaId:undefined,enginCycle:"0"};
      this.handleQuery();
    },
      getList()
      {
        getAreaCompletionInformationList(this.queryParams).then(res=>{
          this.total=res.total
          this.tableData=res.rows
          })
      },
        tableRowClassName(){
            // return "background:#FFFFFF;border: 1px solid #000066"
        },
    toModule(){
      console.log(this.$router)
      const currentPage = this.currentMenu == 0 ? 'material_statistics' : this.currentMenu == 1 ? 'progres_statistics' :this.currentMenu == 2 ? 'echarts_statistics': 'progres_visual'
      this.$router.push({
        path:`/${currentPage}`
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.ProgreStatistics_Contain{
    width: 100%;
    height: 100%;
    padding: 1%;
    .topContain{
        display: flex;
        justify-content: space-between;
        width: 100%;
        .searchBtn{
            width: 11%;
            background: linear-gradient(to right , #2197F2, #0BB0DE);
            color: #fff;
        }
        ::v-deep .projectSelect{
            .el-input__inner{
                 background: linear-gradient(to right , #2197F2, #0BB0DE);
                color: #fff;
            }
        }
        .projectDropDown{
            background: linear-gradient(to right , #2197F2, #0BB0DE);
            .el-select-dropdown__item{
                background: linear-gradient(to right , #2197F2, #0BB0DE);
                color: #fff;
            }
            ::v-deep .el-select-dropdown__list {
                padding-top: 0 !important;
                padding-bottom: 0;
            }

        }
    }
    .materialStatisticsTable{
        margin-top: 1%;
        // border: 2px solid #000066 !important;
        cursor: pointer;
        ::v-deep .el-table__row{
            // background-color: #2F4280;
        }
        // ::v-deep tbody tr:hover>td {
        //     transform: translateX(3px) translateY(-3px);
        //     z-index: 100;
        //     box-shadow: 3px 3px 3px 3px rgba(82, 82, 82, 0.5);
        //     background-color: rgba(98, 98, 98, 0.52);
        //   font-size: 15px;
        //     color: #ea0404;
        // }
    }
    .materialStatisticsTable::before{
        background-color:#000066 ;
    }
    .materialStatisticsTable::after{
        background-color:#000066 ;
    }
}
</style>
