<template>
  <div>
    <at-table
      @load="loadData"
      :data="data"
      :page-result="pageResult"
      ref="AtTable"
      @select-all="handleSelect"
      @select="handleSelect"
      @row-dblclick="handleRowDBClick"
      :justShowSearch="justShowSearch"
    >
      <template v-slot:searchInput>
        <el-form
          ref="searchForm"
          :model="searchForm"
          label-width="80px"
          class="search-top"
          @submit.native.prevent
        >
          <el-select
            v-if="isShow"
            v-model="searchForm.createTime"
            clearable
            placeholder="请选择年份"
            @change="handleSearchProject"
          >
            <el-option
              v-for="item in optionYears"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <dict-select
            v-if="isShow"
            v-model="searchForm.projectType"
            dictCode="xmgl-xmlx"
            validate="required"
            placeholder="请选择项目类型"
            :clearable="true"
            @input="handleSearch"
          />
          <el-input placeholder="请输入项目名称"
            v-if="isShow"
            ref="projectInfo"
            v-model="searchForm.projectName"
            @input="handleSearch"
          ></el-input>

          <!-- <el-input
            v-model="searchForm.year"
            placeholder="请输入年度"
            clearable
            @keyup.enter.native="handleSearch"
          ></el-input> -->
          <!-- <el-date-picker
            v-model="searchForm.year"
            type="year"
            placeholder="选择年度"
            value-format="yyyy"
            format="yyyy"
          >
          </el-date-picker> -->
          <el-button
            v-if="isShow"
            size="small"
            @click="handleSearch"
            type="primary"
            class="el-icon-search search-btn"
            >查询</el-button
          >
          <el-button
            v-if="isShow"
            size="small"
            @click="handleReset"
            type="primary"
            plain
            class="el-icon-refresh"
            >重置</el-button
          >
          <el-button
            size="small"
            type="primary"
            @click="handleExport"
            icon="el-icon-download"
            :loading="loading"
            plain
            style="margin-left: 10px"
            >导出</el-button
          >
        </el-form>
      </template>
      <template v-slot:seacrhMoreInput v-if="justShowSearch">
        <div class="moreInput">
          <!-- <el-date-picker
            v-model="searchForm.yearMonth"
            type="month"
            placeholder="选择年月"
            value-format="yyyy-MM-dd"
            @change="handleSearch"
          ></el-date-picker> -->
          <el-date-picker
            unlink-panels
            v-model="searchForm.yearMonth"
            value-format="yyyy-MM"
            type="monthrange"
            range-separator="至"
            start-placeholder="开始月份"
            end-placeholder="结束月份"
            @change="handleSearch"
          >
          </el-date-picker>
        </div>
      </template>
      <template>
        <!-- <el-table-column type="selection" width="55" align="center">
        </el-table-column> -->
        <el-table-column type="index" label="序号" width="55" align="center">
        </el-table-column>
        <el-table-column
          prop="projectName"
          label="项目名称"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="currentProcedure"
          label="项目状态"
          align="center"
          width="130"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column label="立项/核准/备案" align="center">
          <el-table-column
            prop="establishDT"
            label="批复文号及时间"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <!-- <el-table-column label="可研" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="feasiblePlanDT"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="批复规模、总投资及建设安投资(万元)"
            prop="feasiblePlanInfo"
            align="center"
            width="290"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column> -->
        <el-table-column label="规划许可" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="porjectPlanningDT"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="批复规模"
            prop="porjectPlanningScale"
            align="center"
            width="100"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column label="初步设计" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="preliminaryDesignDT"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column label="概算" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="estimateDT"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="批复规模、总投资及建设安投资(万元)"
            prop="estimateInfo"
            align="center"
            width="290"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <!-- <el-table-column label="用地预审与选址意见书" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="siteDT"
            align="center"
            width="150"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column label="用地手续" align="center">
          <el-table-column
            label="类型、批文号及时间"
            prop="useLandDT"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column label="规划用地许可" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="useLandCode"
            align="center"
            width="110"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column> 
        
      
         <el-table-column
          label="专项审查(轨道、环保、消防、人防、园林、行洪等)"
          align="center"
        >
        <el-table-column
            v-for="(item, index) in specialReview"
            :key="index"
            label="类别、批复文号及时间"
            :prop="item"
            align="center"
            width="150"
            :show-overflow-tooltip="true"
          >
          </el-table-column> -->
        <!-- <el-table-column
            label="类别、批复文号及时间"
            prop="specialReview"
            align="center"
            width="150"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div>{{ scope.row.specialReview[0] }}</div>
            </template>
          </el-table-column>
          <el-table-column
            label="类别、批复文号及时间"
            prop="specialReview"
            align="center"
            width="150"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div>{{ scope.row.specialReview[1] }}</div>
            </template>
          </el-table-column>
          <el-table-column
            label="类别、批复文号及时间"
            prop="specialReview"
            align="center"
            width="150"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div>{{ scope.row.specialReview[2] }}</div>
            </template>
          </el-table-column>
          <el-table-column
            label="类别、批复文号及时间"
            prop="specialReview"
            align="center"
            width="150"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div>{{ scope.row.specialReview[3] }}</div>
            </template>
          </el-table-column> -->
        <!-- </el-table-column> -->
        <el-table-column label="施工图审查备案" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="constructionDrawingDT"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column label="施工许可" align="center">
          <el-table-column
            label="施工许可名称"
            prop="constructionPermitName"
            align="center"
            width="120"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="批复文号及时间"
            prop="constructionPermitDT"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column label="竣工验收备案" align="center">
          <el-table-column
            label="批复文号及时间"
            prop="recordAcceptanceDT"
            align="center"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
      </template>
      <!-- 弹框 -->
      <!-- <template v-slot:dialogContent> </template> -->
    </at-table>
    <el-dialog
      title="详情"
      :visible.sync="dialogVisible"
      width="1200px"
      top="8vh"
    >
      <div class="mainBox">
        <table align="center">
          <tr>
            <td class="bgColor" colspan="2">项目名称</td>
            <td
              class="bias"
              v-if="!details.projectName || details.projectName.length == 0"
            >
              /
            </td>
            <td v-else style="width: 320px">{{ details.projectName }}</td>
            <td class="bgColor" colspan="2">项目状态</td>
            <td
              class="bias"
              v-if="
                !details.currentProcedure ||
                details.currentProcedure.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.currentProcedure }}</td>
          </tr>
          <tr>
            <td class="bgColor" style="width: 110px" rowspan="2">
              立项/核准/备案
            </td>
            <td class="bgColor" style="width: 120px" rowspan="2">
              批复文号及时间
            </td>
            <td
              class="bias"
              v-if="!details.establishDT || details.establishDT.length == 0"
              rowspan="2"
            >
              /
            </td>
            <td v-else rowspan="2">{{ details.establishDT }}</td>
            <td class="bgColor" rowspan="2" style="width: 110px">可研</td>
            <td class="bgColor" style="width: 120px">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.feasiblePlanDT || details.feasiblePlanDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.feasiblePlanDT }}</td>
          </tr>
          <tr>
            <td class="bgColor">批复规模、总投资及建安投资（万元）</td>
            <td
              class="bias"
              v-if="
                !details.feasiblePlanInfo ||
                details.feasiblePlanInfo.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.feasiblePlanInfo }}</td>
          </tr>
          <tr>
            <td class="bgColor" style="width: 90px">用地预审与选址意见书</td>
            <td class="bgColor" style="width: 120px">批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.siteDT || details.siteDT.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.siteDT }}</td>
            <td class="bgColor">用地手续</td>
            <td class="bgColor">类型、批文号及时间</td>
            <td
              class="bias"
              v-if="!details.useLandDT || details.useLandDT.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.useLandDT }}</td>
          </tr>
          <tr>
            <td class="bgColor">规划用地许可</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.useLandCode || details.useLandCode.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.useLandCode }}</td>
            <td class="bgColor">
              专项审查（轨道、环保、消防、人防、园林、行洪等）
            </td>
            <td class="bgColor">类别、批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.specialReview || details.specialReview.length == 0"
            >
              /
            </td>
            <td class="textStyle" v-else>
              <div v-for="(item, index) in details.specialReview" :key="index">
                {{ item }}
              </div>
            </td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="2">规划许可</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.porjectPlanningDT ||
                details.porjectPlanningDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.porjectPlanningDT }}</td>
            <td class="bgColor" rowspan="2">初步设计</td>
            <td class="bgColor" rowspan="2">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.preliminaryDesignDT ||
                details.preliminaryDesignDT.length == 0
              "
              rowspan="2"
            >
              /
            </td>
            <td v-else rowspan="2">{{ details.preliminaryDesignDT }}</td>
          </tr>
          <tr>
            <td class="bgColor">批复规模</td>
            <td
              class="bias"
              v-if="
                !details.porjectPlanningScale ||
                details.porjectPlanningScale.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.porjectPlanningScale }}</td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="2">概算</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.estimateDT || details.estimateDT.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.estimateDT }}</td>
            <td class="bgColor" rowspan="2">施工图审查备案</td>
            <td class="bgColor" rowspan="2">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.constructionDrawingDT ||
                details.constructionDrawingDT.length == 0
              "
              rowspan="2"
            >
              /
            </td>
            <td v-else rowspan="2">{{ details.constructionDrawingDT }}</td>
          </tr>
          <tr>
            <td class="bgColor">批复总投资及建安投资（万元）</td>
            <td
              class="bias"
              v-if="!details.estimateInfo || details.estimateInfo.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.estimateInfo }}</td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="2">施工许可</td>
            <td class="bgColor">施工许可名称</td>
            <td
              class="bias"
              v-if="
                !details.constructionPermitName ||
                details.constructionPermitName.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.constructionPermitName }}</td>
            <td class="bgColor" rowspan="2">竣工验收备案</td>
            <td class="bgColor" rowspan="2">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.recordAcceptanceDT ||
                details.recordAcceptanceDT.length == 0
              "
              rowspan="2"
            >
              /
            </td>
            <td v-else rowspan="2">
              {{ details.recordAcceptanceDT }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.constructionPermitDT ||
                details.constructionPermitDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.constructionPermitDT }}</td>
          </tr>

          <!-- <tr>
            <td class="bgColor" colspan="2">项目名称</td>
            <td
              class="bias"
              v-if="!details.projectName || details.projectName.length == 0"
            >
              /
            </td>
            <td v-else style="width: 320px">{{ details.projectName }}</td>
            <td class="bgColor" colspan="2">项目状态</td>
            <td
              class="bias"
              v-if="
                !details.currentProcedure ||
                details.currentProcedure.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.currentProcedure }}</td>
          </tr>
          <tr>
            <td class="bgColor" style="width: 110px">立项/核准/备案</td>
            <td class="bgColor" style="width: 120px">批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.establishDT || details.establishDT.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.establishDT }}</td>
            <td class="bgColor" style="width: 90px">用地预审与选址意见书</td>
            <td class="bgColor" style="width: 120px">批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.siteDT || details.siteDT.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.siteDT }}</td>
          </tr>
          <tr>
            <td class="bgColor">用地手续</td>
            <td class="bgColor">类型、批文号及时间</td>
            <td
              class="bias"
              v-if="!details.useLandDT || details.useLandDT.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.useLandDT }}</td>
            <td class="bgColor">规划用地许可</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.useLandCode || details.useLandCode.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.useLandCode }}</td>
          </tr>
          <tr>
            <td class="bgColor">初步设计</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.preliminaryDesignDT ||
                details.preliminaryDesignDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.preliminaryDesignDT }}</td>
            <td class="bgColor">施工图审查备案</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.constructionDrawingDT ||
                details.constructionDrawingDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.constructionDrawingDT }}</td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="2">概算</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.estimateDT || details.estimateDT.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.estimateDT }}</td>
            <td class="bgColor" rowspan="2">可研</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.feasiblePlanDT || details.feasiblePlanDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.feasiblePlanDT }}</td>
          </tr>
          <tr>
            <td class="bgColor">批复总投资及建安投资（万元）</td>
            <td
              class="bias"
              v-if="!details.estimateInfo || details.estimateInfo.length == 0"
            >
              /
            </td>
            <td v-else>{{ details.estimateInfo }}</td>
            <td class="bgColor">批复规模、总投资及建安投资（万元）</td>
            <td
              class="bias"
              v-if="
                !details.feasiblePlanInfo ||
                details.feasiblePlanInfo.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.feasiblePlanInfo }}</td>
          </tr>

          <tr>
            <td class="bgColor" rowspan="2">规划许可</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.porjectPlanningDT ||
                details.porjectPlanningDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.porjectPlanningDT }}</td>
            <td class="bgColor" rowspan="2">施工许可</td>
            <td class="bgColor">施工许可名称</td>
            <td
              class="bias"
              v-if="
                !details.constructionPermitName ||
                details.constructionPermitName.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.constructionPermitName }}</td>
          </tr>

          <tr>
            <td class="bgColor">批复规模</td>
            <td
              class="bias"
              v-if="
                !details.porjectPlanningScale ||
                details.porjectPlanningScale.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.porjectPlanningScale }}</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.constructionPermitDT ||
                details.constructionPermitDT.length == 0
              "
            >
              /
            </td>
            <td v-else>{{ details.constructionPermitDT }}</td>
          </tr>
          <tr>
            <td class="bgColor">
              专项审查（轨道、环保、消防、人防、园林、行洪等）
            </td>
            <td class="bgColor">类别、批复文号及时间</td>
            <td
              class="bias"
              v-if="!details.specialReview || details.specialReview.length == 0"
            >
              /
            </td>
            <td class="textStyle" v-else>
              <div v-for="(item, index) in details.specialReview" :key="index">
                {{ item }}
              </div>
            </td>
            <td class="bgColor">竣工验收备案</td>
            <td class="bgColor">批复文号及时间</td>
            <td
              class="bias"
              v-if="
                !details.recordAcceptanceDT ||
                details.recordAcceptanceDT.length == 0
              "
            >
              /
            </td>
            <td v-else>
              {{ details.recordAcceptanceDT }}
            </td>
          </tr> -->
        </table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false"
          >关闭</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import req from '@/request.js'
export default {
  name: 'projectApprovalAccount',
  props: {
    pid: {
      type: String,
      default: '',
    },
    isShow: {
      type: Boolean,
      default: true,
    },
    alias: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      justShowSearch:this.isShow,
      loading: false,
      searchForm: {
        projectName: '', //项目名称
        createTime: new Date().getFullYear(), //当前年份
        projectType: '', //项目类型
      },
      optionYears: [], //顶部搜索年份选择数组
      details: {},
      data: [],
      pageResult: {
        page: 1,
        pageSize: 20,
        total: 0,
      },
      form: {},
      dialogVisible: false,
    }
  },
  computed: {
    deleteUrl: function () {
      return (
        window.context.cqxy + '/biz/projectApproval/decisionBasis/v1/delete'
      )
    },
  },
  created() {
    this.getYear()
  },
  mounted() {
    if(this.isShow){
    this.$refs.projectInfo.getProjectData(this.searchForm.createTime)
    }
  },
  methods: {
    //获取顶部搜索的年份区间
    getYear() {
      const myDate = new Date()
      const startYear = 2006 //起始年份
      const endYear = myDate.getFullYear() //结束年份
      for (let i = endYear; i >= startYear; i--) {
        this.optionYears.push({
          label: i + '年',
          value: i,
        })
      }
    },
    handleReset() {
      this.searchForm.projectName = ''
      this.searchForm.projectType = ''
      this.searchForm.createTime = null
      this.$refs.projectInfo.getProjectData()
      this.$refs['searchForm'].resetFields()
      this.pageResult = {
        page: 1,
        pageSize: 20,
        total: 0,
      }
      this.$nextTick(() => {
        this.$refs.AtTable.load()
      })
    },
    //导出
    handleExport() {
      this.loading = true
      let query = []
      let search = {
        projectName: this.searchForm.projectName,
        project_type_: this.searchForm.projectType,
        CREATE_TIME_: this.searchForm.createTime,
        year_month_: this.searchForm.yearMonth,
      }
      if (!this.isShow) {
        search.projectName = this.searchForm.projectName
        delete search.CREATE_TIME_
      }
      for (let i in search) {
        if (search[i]) {
          if (i == 'CREATE_TIME_') {
            query.push(
              {
                group: 'createTimeGroup',
                operation: 'BETWEEN',
                parentGroup: '',
                property: 'commencement_time_',
                relation: 'OR',
                value: [
                  `${search[i]}-01-01 00:00:00`,
                  `${search[i]}-12-31 23:59:59`,
                ],
              },
              // {
              //   group: 'createTimeSubGroup',
              //   operation: 'LESS_EQUAL',
              //   parentGroup: 'createTimeGroup',
              //   property: 'commencement_time_',
              //   relation: 'AND',
              //   value: `${search[i]}-12-31 23:59:59`,
              // },
              // {
              //   group: 'createTimeSubGroup',
              //   operation: 'LESS',
              //   parentGroup: 'createTimeGroup',
              //   property: 'PROJECT_STATUS_',
              //   relation: 'AND',
              //   value: '12',
              // }
            )
          } else if (i == 'year_month_') {
            let lastDate=search[i][1]
            let str=lastDate.split('-')
            let year=parseInt(str[0])
            let month=parseInt(str[1])
            let date = new Date(year, month, 0).getDate()
            let arr = [
              `${search[i][0]}-01 00:00:00`,
              `${search[i][1]}-${date} 23:59:59`,
            ]
            query.push(
              {
                group: 'createTimeGroup',
                operation: 'BETWEEN',
                parentGroup: '',
                property: 'commencement_time_',
                relation: 'OR',
                value: arr,
              },
              {
                group: 'createTimeSubGroup',
                operation: 'LESS_EQUAL',
                parentGroup: 'createTimeGroup',
                property: 'commencement_time_',
                relation: 'AND',
                value: arr[1],
              },
              {
                group: 'createTimeSubGroup',
                operation: 'LESS',
                parentGroup: 'createTimeGroup',
                property: 'PROJECT_STATUS_',
                relation: 'AND',
                value: '12',
              }
            )
          } else {
            query.push({
              group: 'advance',
              operation: 'LIKE',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          }
        }
      }
      let param = {
        pageBean: {
          page: 1,
          pageSize: -1,
          showTotal: true,
        },
        querys: query,
        sorter: [],
      }
      req
        .downloadPostCopy(
          '${cqxy}/biz/ledger/approvalLedger/v1/exportDataToExcel',
          param
        )
        .then((res) => {
          if (res.status == 200) {
            this.loading = false
            this.$message.success('导出成功')
          } else {
            this.loading = false
            this.$message.error('导出失败')
          }
        })
    },
    //查询
    handleSearch() {
      this.$refs.AtTable.load()
    },
    handleSearchProject(year) {
      if (year) {
        this.$refs.projectInfo.getProjectData(year)
      } else {
        this.$refs.projectInfo.getProjectData()
      }
      this.$refs.AtTable.load()
    },
    handleRowDBClick(data) {
      this.dialogVisible = true
      this.details = data
    },

    handleSelect(selection) {},
    loadData(param, cb) {
      let query = []
      let search = {
        projectName: this.searchForm.projectName,
        project_type_: this.searchForm.projectType,
        CREATE_TIME_: this.searchForm.createTime,
        year_month_: this.searchForm.yearMonth,
      }
      if (!this.isShow) {
        search.projectName = this.searchForm.projectName
        delete search.CREATE_TIME_
      }
      for (let i in search) {
        if (search[i]) {
          if (i == 'CREATE_TIME_') {
            query.push(
              {
                group: 'createTimeGroup',
                operation: 'BETWEEN',
                parentGroup: '',
                property: 'commencement_time_',
                relation: 'OR',
                value: [
                  `${search[i]}-01-01 00:00:00`,
                  `${search[i]}-12-31 23:59:59`,
                ],
              },
              // {
              //   group: 'createTimeSubGroup',
              //   operation: 'LESS_EQUAL',
              //   parentGroup: 'createTimeGroup',
              //   property: 'commencement_time_',
              //   relation: 'AND',
              //   value: `${search[i]}-12-31 23:59:59`,
              // },
              // {
              //   group: 'createTimeSubGroup',
              //   operation: 'LESS',
              //   parentGroup: 'createTimeGroup',
              //   property: 'PROJECT_STATUS_',
              //   relation: 'AND',
              //   value: '12',
              // }
            )
          } else if (i == 'year_month_') {
            let lastDate=search[i][1]
            let str=lastDate.split('-')
            let year=parseInt(str[0])
            let month=parseInt(str[1])
            let date = new Date(year, month, 0).getDate()
            let arr = [
              `${search[i][0]}-01 00:00:00`,
              `${search[i][1]}-${date} 23:59:59`,
            ]
            query.push(
              {
                group: 'createTimeGroup',
                operation: 'BETWEEN',
                parentGroup: '',
                property: 'commencement_time_',
                relation: 'OR',
                value: arr,
              },
              {
                group: 'createTimeSubGroup',
                operation: 'LESS_EQUAL',
                parentGroup: 'createTimeGroup',
                property: 'commencement_time_',
                relation: 'AND',
                value: arr[1],
              },
              {
                group: 'createTimeSubGroup',
                operation: 'LESS',
                parentGroup: 'createTimeGroup',
                property: 'PROJECT_STATUS_',
                relation: 'AND',
                value: '12',
              }
            )
          } else if(i=='projectName'){
            query.push({
              group: 'advance',
              operation: 'LIKE',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          }else{
            query.push({
              group: 'advance',
              operation: 'EQUAL',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          }
        }
      }
      if (param.querys && param.querys.length) {
        param.querys.push(...query)
      } else {
        param.querys = query
      }
      this.$http
        .post('${cqxy}/biz/ledger/approvalLedger/v1/page', param)
        .then(
          (res) => {
            let resp = res.data.value
            this.data = resp.data
            this.pageResult = {
              page: resp.page,
              pageSize: resp.pageSize,
              total: resp.total,
            }
          },
          (error) => {
            reject(error)
          }
        )
        .finally(() => {
          if (cb) {
            cb()
          }
        })
    },
  },
}
</script>
<style lang="scss" scoped>
@import '@/assets/css/common.scss';

/deep/ .el-input__suffix > .el-input__icon {
  display: none;
}
/deep/ .el-table--border th .cell {
  color: #000;
}

/deep/ .el-dialog__body {
  padding-top: 20px;
  padding-bottom: 20px;
}
table {
  width: 100%;
  border-collapse: collapse;
}

table,
table tr td {
  border: 1px solid #ebeef5;
}

table tr td {
  padding: 15px 10px;
  // text-align: center;
}

.bgColor {
  background: #fafafa;
  color: #909399;
  // font-weight: bold;
}
/deep/ .el-table thead.is-group th {
  border-color: #ebeef5;
}
.textStyle > div {
  margin-bottom: 5px;
}
.textStyle > div:last-child {
  margin-bottom: 0;
}
.bias {
  color: #ced0d3;
}
.moreInput {
  display: flex;
  align-items: center;
  // height: 100%;
  overflow: hidden;
  padding: 10px;
}
.open {
  padding: 10px;
  animation: slideContentUp 0.3s linear both;
}
.close {
  animation: slideContentDown 0.3s linear both;
}

/* 动态设置高度 */
@keyframes slideContentUp {
  from {
    height: 0;
  }

  to {
    height: 36px;
  }
}

@keyframes slideContentDown {
  from {
    height: 36px;
  }

  to {
    height: 0;
  }
}
</style>
