<template>
  <div>
    <at-table
      @load="loadData"
      :data="data"
      :page-result="pageResult"
      ref="AtTable"
      :cellClassNameFn="cellClassNameFn"
      @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="handleSearch"
          >
            <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
            ref="projectInfo"
            v-if="isShow"
            placeholder="请输入项目名称"
            v-model="searchForm.projectName"
            @input="handleSearch"
          ></el-input>
          <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"
            :loading="loading"
            icon="el-icon-download"
            plain
            style="margin-left: 10px"
            >导出</el-button
          >
        </el-form>

        <!-- <div class="search-checkbox">
          <el-checkbox
            :indeterminate="isIndeterminate"
            v-model="checkAll"
            @change="handleCheckAllChange"
            >全选</el-checkbox
          >
          <div style="margin: 15px 0"></div>
          <el-checkbox-group
            v-model="checkedMonths"
            @change="handleCheckedMonthsChange"
          >
            <el-checkbox v-for="month in months" :label="month" :key="month">{{
              month + '月'
            }}</el-checkbox>
          </el-checkbox-group>
        </div> -->
      </template>
      <template v-slot:seacrhMoreInput v-if="isShow">
        <div class="moreInput">
          <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 v-slot:operationBtn>
        <!-- <el-button
          size="small"
          type="primary"
          @click="() => {}"
          icon="el-icon-setting"
          v-methodauth="'land_manage'"
          disabled
        >土地费管理</el-button> -->
        <div class="yearTotal">
          <div>
            {{ currentYear }}年度总投资：<span class="textRed">{{
              (payTotal / 10000).toFixed(2)
            }}</span
            >万元
          </div>
          <!-- <div>年度总支付：<span class="textRed">{{investTotal}}</span>万元</div> -->
        </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="projectManager"
          label="项目负责人"
          align="center"
          width="120"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="projectStatus"
          label="形象进度"
          align="center"
          width="100"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="projectType"
          label="项目类型"
          align="center"
          width="100"
          :show-overflow-tooltip="true"
        >
          <template v-slot="{row}">
            <span v-if="row.projectType !== '----'">
              {{ getDictName('xmgl-xmlx', row.projectType) }}
            </span>
            <span v-else>----</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="totalEstimate"
          label="总投资额(万元)"
          align="center"
          width="130"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="completedEstimate"
          label="累计完成总投资(万元)"
          align="center"
          width="140"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <!-- <el-table-column
          prop="beforeEstimate"
          :label="beforeYear + '年年度总投资(万元)'"
          align="center"
          width="155"
          :show-overflow-tooltip="true"
        >
        </el-table-column> -->
        <el-table-column
          prop="currentEstimate"
          :label="currentYear + '年年度总投资(万元)'"
          align="center"
          width="155"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="engineeringCost"
          label="建安费用(万元)"
          align="center"
          width="130"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="twoTypePrice"
          label="地堪、设计费，监理、检测费及人防配套费等二类费用(万元)"
          align="center"
          width="180"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <!-- <el-table-column
          prop="actualSettlementAmount"
          label="安全文明施工费(万元)"
          align="center"
          width="180"
          :show-overflow-tooltip="true"
        >
        </el-table-column> -->
        <el-table-column
          prop="landPrice"
          label="土地费用(万元)"
          align="center"
          width="130"
          :show-overflow-tooltip="true"
        >
          <template v-slot="{row}">
            <el-link
              v-if="row.projectName !== '合计'"
              class="link"
              type="primary"
              @click="landManager(row.id)"
            >
              {{ row.landPrice }}
            </el-link>
            <span v-else> {{ row.landPrice }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="adminPaymentAmount"
          label="行政缴费总额(万元)"
          align="center"
          width="130"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          v-for="month in checkedMonthsList"
          :key="month"
          :label="month + '月'"
          align="center"
        >
          <el-table-column
            label="本月投资(万元)"
            :prop="`monthCount[${month - 1}].currentInvestment`"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            :prop="`monthCount[${month - 1}].progress`"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            :prop="`monthCount[${month - 1}].totalInvestment`"
            width="120"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <!-- <el-table-column
          label="2月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("2月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[1].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[1].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[1].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="3月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("3月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[2].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[2].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[2].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="4月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("4月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[3].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[3].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[3].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="5月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("5月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[4].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[4].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[4].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="6月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("6月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[5].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[5].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[5].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="7月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("7月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[6].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[6].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[6].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="8月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("8月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[7].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[7].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[7].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="9月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("9月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[8].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[8].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[8].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="10月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("10月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[9].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[9].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[9].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="11月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("11月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[10].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[10].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[10].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          label="12月"
          align="center"
          v-if='getIsShowMonth(checkedMonthsList).includes("12月")'
        >
          <el-table-column
            label="本月投资(万元)"
            prop="monthCount[11].currentInvestment"
            align="center"
            width="130"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="进度"
            prop="monthCount[11].progress"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="累计工程投资"
            prop="monthCount[11].totalInvestment"
            width="110"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column> -->
        <!-- <el-table-column
          label="年度累计"
          align="center"
        >
          <el-table-column
            label="总投资额"
            prop="ztze"
            align="center"
            width="110"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="备注"
            prop="remakers"
            align="center"
            :show-overflow-tooltip="true"
          ></el-table-column>
        </el-table-column> -->
        <!-- <el-table-column
          label="操作"
          align="center"
          width="150px"
          fixed="right"
        >
          <template v-slot={row}>
            <el-button
              size="small"
              type="primary"
              @click='landManager(row.id)'
            >土地费用管理</el-button>
          </template>
        </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 style="width: 320px">{{ details.projectName }}</td>
            <td class="bgColor" colspan="2">项目负责人</td>
            <td>{{ details.projectManager }}</td>
          </tr>
          <tr>
            <td class="bgColor" colspan="2">形象进度</td>
            <td style="width: 320px">{{ details.projectStatus }}</td>
            <td class="bgColor" colspan="2">项目类型</td>
            <td>{{ getDictName('xmgl-xmlx', details.projectType) }}</td>
          </tr>
          <tr>
            <td class="bgColor" colspan="2">总投资额(万元)</td>
            <td>{{ details.totalEstimate }}</td>
            <td class="bgColor" colspan="2">建安费用(万元)</td>
            <td style="width: 320px">
              {{ details.engineeringCost }}
            </td>
          </tr>
          <tr>
            <td class="bgColor" colspan="2">二类费用(万元)</td>
            <td style="width: 320px">
              {{ details.twoTypePrice }}
            </td>
            <td class="bgColor" colspan="2">土地费用(万元)</td>
            <td class="editLand">
              {{ details.landPrice }}
              <!-- <el-link
                class="link"
                type="primary"
                @click='landManager(details.id)'
              >
                修改土地费
              </el-link> -->
            </td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="3">一月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[0] &&
                details.monthCount[0].currentInvestment
              }}
            </td>
            <td class="bgColor" rowspan="3">二月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[1] &&
                details.monthCount[1].currentInvestment
              }}
            </td>
          </tr>

          <tr>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[0] &&
                details.monthCount[0].progress
              }}
            </td>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[1] &&
                details.monthCount[1].progress
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[0] &&
                details.monthCount[0].totalInvestment
              }}
            </td>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[1] &&
                details.monthCount[1].totalInvestment
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="3">三月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[2] &&
                details.monthCount[2].currentInvestment
              }}
            </td>
            <td class="bgColor" rowspan="3">四月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[3] &&
                details.monthCount[3].currentInvestment
              }}
            </td>
          </tr>

          <tr>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[2] &&
                details.monthCount[2].progress
              }}
            </td>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[3] &&
                details.monthCount[3].progress
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[2] &&
                details.monthCount[2].totalInvestment
              }}
            </td>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[3] &&
                details.monthCount[3].totalInvestment
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="3">五月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[4] &&
                details.monthCount[4].currentInvestment
              }}
            </td>
            <td class="bgColor" rowspan="3">六月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[5] &&
                details.monthCount[5].currentInvestment
              }}
            </td>
          </tr>

          <tr>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[4] &&
                details.monthCount[4].progress
              }}
            </td>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[5] &&
                details.monthCount[5].progress
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[4] &&
                details.monthCount[4].totalInvestment
              }}
            </td>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[5] &&
                details.monthCount[5].totalInvestment
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="3">七月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[6] &&
                details.monthCount[6].currentInvestment
              }}
            </td>
            <td class="bgColor" rowspan="3">八月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[7] &&
                details.monthCount[7].currentInvestment
              }}
            </td>
          </tr>

          <tr>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[6] &&
                details.monthCount[6].progress
              }}
            </td>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[7] &&
                details.monthCount[7].progress
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[6] &&
                details.monthCount[6].totalInvestment
              }}
            </td>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[7] &&
                details.monthCount[7].totalInvestment
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="3">九月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[8] &&
                details.monthCount[8].currentInvestment
              }}
            </td>
            <td class="bgColor" rowspan="3">十月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[9] &&
                details.monthCount[9].currentInvestment
              }}
            </td>
          </tr>

          <tr>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[8] &&
                details.monthCount[8].progress
              }}
            </td>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[9] &&
                details.monthCount[9].progress
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[8] &&
                details.monthCount[8].totalInvestment
              }}
            </td>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[9] &&
                details.monthCount[9].totalInvestment
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor" rowspan="3">十一月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[10] &&
                details.monthCount[10].currentInvestment
              }}
            </td>
            <td class="bgColor" rowspan="3">十二月</td>
            <td class="bgColor">本月投资(万元)</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[11] &&
                details.monthCount[11].currentInvestment
              }}
            </td>
          </tr>

          <tr>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[10] &&
                details.monthCount[10].progress
              }}
            </td>
            <td class="bgColor">进度</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[11] &&
                details.monthCount[11].progress
              }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[10] &&
                details.monthCount[10].totalInvestment
              }}
            </td>
            <td class="bgColor">累计工程投资</td>
            <td style="width: 320px">
              {{
                details.monthCount &&
                details.monthCount[11] &&
                details.monthCount[11].totalInvestment
              }}
            </td>
          </tr>
          <!-- <tr>
            <td
              class="bgColor"
              rowspan="2"
            >年度累计</td>
            <td class="bgColor">总投资额</td>
            <td colspan="4">{{ details.ztze }}</td>
          </tr> -->
          <!-- <tr>
            <td class="bgColor">备注</td>
            <td colspan="4">{{ details.remakers }}</td>
          </tr> -->
        </table>
        <!-- <div class="flexEnd">
          <div class="end">
            <span>项目名称：{{details.projectInfo.projectName}}</span>
            <span>创建负责人：{{details.projectInfo.projectManager}}</span>
            <span>创建时间：{{details.projectInfo.commencementTime}}</span>
          </div>
        </div> -->
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false"
          >关闭</el-button
        >
      </span>
    </el-dialog>

    <!-- 土地费用管理弹层 -->
    <el-dialog
      title="土地费用管理"
      :visible.sync="landManagerDialog.show"
      width="500px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :show-close="false"
      v-loading="landManagerDialog.loading"
    >
      <el-form
        :model="landManagerDialog.form"
        label-width="80px"
        ref="landManagerForm"
      >
        <el-row>
          <el-row>
            <el-form-item label="单位">
              <dict-select
                dictCode="xmgl-tdfydw"
                :hasDefaultOption="true"
                clearable
                v-model="landManagerDialog.form.landUnit"
                style="width: 100%"
                placeholder="请输入单位"
              />
            </el-form-item>
          </el-row>
          <el-form-item label="面积">
            <el-input
              v-model="landManagerDialog.form.landArea"
              placeholder="请输入面积"
              clearable
            >
              <i slot="suffix">
                {{
                  getDictName('xmgl-tdfydw', landManagerDialog.form.landUnit)
                }}
              </i>
            </el-input>
          </el-form-item>
        </el-row>
        <!-- <el-row>
          <el-form-item label='单价'>
            <el-input
              v-model="landManagerDialog.form.landPrice"
              placeholder="请输入单价"
              clearable
            ></el-input>
          </el-form-item>
        </el-row> -->

        <el-row>
          <el-form-item label="总价">
            <el-input
              v-model="landManagerDialog.form.landTotalPrice"
              placeholder="请输入总价"
              clearable
            >
              <i slot="suffix"> 万元 </i>
            </el-input>
          </el-form-item>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="landManagerDialog.show = false">取 消</el-button>
        <el-button type="primary" @click="handleLandManagerSubmit"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import req from '@/request.js'
const BigNumber = require('bignumber.js')
const monthOptions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
export default {
  name: 'investmentProgressAccount',
  props: {
    pid: {
      type: String,
      default: '',
    },
    isShow: {
      type: Boolean,
      default: true,
    },
    alias: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      total: {
        projectName: '合计',
        projectManager: '----',
        projectStatus: '----',
        projectType: '----',
        totalEstimate: 0,
        completedEstimate: 0,
        currentEstimate: 0,
        engineeringCost: 0,
        twoTypePrice: 0,
        landPrice: 0,
        adminPaymentAmount: 0,
      },
      justShowSearch: this.isShow,
      loading: false,
      searchForm: {
        projectName: '',
        type: '',
        createTime: new Date().getFullYear(), //当前年份
      },
      optionYears: [], //顶部搜索年份选择数组
      details: {},
      data: [],
      year: 2023,
      pageResult: {
        page: 1,
        pageSize: 20,
        total: 0,
      },
      form: {},
      dialogVisible: false,
      landManagerDialog: {
        show: false,
        form: {
          landUnit: 1,
        },
        loading: false,
      },
      checkAll: false,
      checkedMonths: [new Date().getMonth(), new Date().getMonth() + 1],
      months: monthOptions,
      isIndeterminate: true,
      checkedMonthsList: [new Date().getMonth(), new Date().getMonth() + 1],
      payTotal: 0,
      investTotal: 0,
    }
  },
  computed: {
    deleteUrl: function () {
      return (
        window.context.cqxy + '/biz/projectApproval/decisionBasis/v1/delete'
      )
    },
  },
  created() {
    this.year = 2023
    this.getYear()
    this.getYearTotal()
  },
  methods: {
    getYearTotal() {
      if (this.searchForm.createTime && this.searchForm.createTime != '') {
        let formData = new FormData()
        formData.append('year', this.searchForm.createTime)
        this.$http
          .post('${cqxy}/biz/ledger/investment/v1/totalInvestByYear', formData)
          .then((res) => {
            let data = res.data.value
            this.payTotal = res.data.value
            this.investTotal = data.investTotal
          })
      } else {
        let formData = new FormData()
        formData.append('year', 0)
        this.$http
          .post('${cqxy}/biz/ledger/investment/v1/totalInvestByYear', formData)
          .then((res) => {
            console.log(res, 'wwwww')
            let data = res.data.value
            this.payTotal = res.data.value
            this.investTotal = data.investTotal
          })
        this.investTotal = 0
        this.currentYear = null
      }
    },
    //获取顶部搜索的年份区间
    getYear() {
      const myDate = new Date()
      this.currentYear = myDate.getFullYear()
      this.beforeYear = this.currentYear - 1
      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 = ''
      this.searchForm.yearMonth = ''
      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.pid
        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],
            })
          }
        }
      }
      let param = {
        pageBean: {
          page: 1,
          pageSize: -1,
          showTotal: true,
        },
        querys: query,
      }
      req
        .downloadPostCopy(
          '${cqxy}/biz/ledger/investment/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()
    },
    handleRowDBClick(data) {
      this.dialogVisible = true
      this.details = data
    },

    handleSelect(selection) {},
    loadData(param, cb) {
      if (this.isShow) {
        // this.$refs.projectInfo.getProjectData(this.searchForm.createTime)
      }
      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.ID_ = this.pid
        delete search.CREATE_TIME_
      }
      for (let i in search) {
        if (search[i]) {
          if (i == 'CREATE_TIME_') {
            this.currentYear = this.searchForm.createTime
            this.beforeYear = this.currentYear - 1
            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/investment/v1/page', param)
        .then(
          (resp) => {
            //  <!-- engineeringCost建安费用(万元)  twoTypePrice二类费用(万元)  landPrice土地费用(万元) actualSettlementAmount安全文明施工费-->
            let response = resp.data.value
            // response.data.forEach(item => {
            //   if(item.engineeringCost && item.engineeringCost!=='0'){
            //     item.engineeringCost= FormMath.tofixed(
            //       FormMath.toNumber(item.engineeringCost) / 10000,
            //       2
            //     )
            //   }
            //   // if(item.twoTypePrice && item.twoTypePrice!=='0'){
            //   //   item.twoTypePrice= FormMath.tofixed(
            //   //     FormMath.toNumber(item.twoTypePrice) / 10000,
            //   //     2
            //   //   )
            //   // }
            //   if(item.landPrice!==0){
            //      item.landPrice= FormMath.tofixed(
            //       FormMath.toNumber(item.landPrice) / 10000,
            //       2
            //     )
            //   }
            //   item.monthCount.forEach(item1 => {
            //     item1.currentInvestment = FormMath.tofixed(
            //       FormMath.toNumber(item1.currentInvestment) / 10000,
            //       2
            //     )
            //     item1.totalInvestment = FormMath.tofixed(
            //       FormMath.toNumber(item1.totalInvestment) / 10000,
            //       2
            //     )
            //   })
            // })
            let data = response.data
            this.total.totalEstimate = this.calculationTotal(
              data,
              'totalEstimate'
            )
            this.total.completedEstimate = this.calculationTotal(
              data,
              'completedEstimate'
            )
            this.total.currentEstimate = this.calculationTotal(
              data,
              'currentEstimate'
            )
            this.total.engineeringCost = this.calculationTotal(
              data,
              'engineeringCost'
            )
            this.total.twoTypePrice = this.calculationTotal(
              data,
              'twoTypePrice'
            )
            this.total.landPrice = this.calculationTotal(data, 'landPrice')
            this.total.adminPaymentAmount = this.calculationTotal(
              data,
              'adminPaymentAmount'
            )
            if (data.length !== 0) {
              data.push(this.total)
            }
            this.data = data
            this.pageResult = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total,
            }
            this.getYearTotal()
          },
          (error) => {
            reject(error)
          }
        )
        .finally(() => {
          if (cb) {
            cb()
          }
        })
    },
    landManager(id) {
      this.landManagerDialog.form = {
        landUnit: 1,
      }
      this.landManagerDialog.form.id = id
      this.landManagerDialog.show = true
    },
    handleLandManagerSubmit() {
      this.landManagerDialog.loading = true
      let params = this.landManagerDialog.form
      this.$http
        .post('${cqxy}/biz/projectManagement/pm/v1/updateLandCostById', params)
        .then((res) => {
          if (res.data.state) {
            this.$message.success(res.data.message)
            this.landManagerDialog.show = false
            this.$refs.AtTable.load()
          } else {
            this.$message.error(res.data.message)
          }
          this.landManagerDialog.loading = false
        })
        .catch((err) => {
          this.landManagerDialog.loading = false
          this.$message.error(err.data.message)
        })
    },
    // handleCheckAllChange(val) {
    //   this.checkedMonthsList = val ? monthOptions : []
    //   this.checkedMonths = val ? monthOptions : []
    //   this.isIndeterminate = false
    //   this.$refs.AtTable.load()
    //   this.$nextTick(() => {
    //     this.$refs.AtTable.doLayout()
    //   })
    // },
    // handleCheckedMonthsChange(value) {
    //   value = value && value.sort(this.sortNumber)
    //   this.checkedMonthsList = value
    //   let checkedCount = value.length
    //   this.checkAll = checkedCount === this.months.length
    //   this.isIndeterminate =
    //     checkedCount > 0 && checkedCount < this.months.length
    //   this.$refs.AtTable.load()
    //   this.$nextTick(() => {
    //     this.$refs.AtTable.doLayout()
    //   })
    // },
    sortNumber(a, b) {
      return a - b
    },
    // getIsShowMonth(arr) {
    //   let arr_ = [new Date().getMonth(), new Date().getMonth() + 1]
    //   return arr.length !== 0 ? arr : this.isIndeterminate ? arr_ : []
    // }
    // 计算列表合同金额合计金额
    calculationTotal(data, key) {
      let total = new BigNumber(0)
      if (key && data && data.length !== 0) {
        data.forEach((item) => {
          if (item[key]) {
            total = total.plus(item[key])
          } else {
            total = total.plus(0)
          }
        })
      }
      return this.moneyFormatter(total)
    },
    cellClassNameFn(row) {
      // 列表项目名称为【合计】隐藏复选框
      if (row.row.projectName === '合计') {
        return 'table-column-hidden'
      }
    },
  },
}
</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;
}
// #606266
.search-checkbox {
  display: flex;
  width: 580px;
  // margin-right: 10px;
  align-items: center;
}
/deep/ .el-checkbox-group {
  margin-left: 10px;
}
/deep/ .el-checkbox {
  margin-right: 5px !important;
}
/deep/ .el-checkbox__label {
  padding-left: 2px !important;
}
.editLand {
  display: flex;
  align-items: center;
  .link {
    margin-left: 20px;
  }
}
.yearTotal {
  display: flex;
  width: 100%;
  justify-content: flex-end;
  div {
    padding: 0 20px;
  }
}
.textRed {
  color: red;
  padding-right: 5px;
}
.show-slected {
  font-size: 18px;
  i {
    font-style: normal;
    font-weight: 700;
    margin: 0 5px;
    color: #f40;
  }
}
/deep/ .table-column-hidden .el-checkbox__input {
  display: none;
}
/deep/ .table-column-hidden .cell > div {
  display: none;
}
</style>
