<template>
  <!--  {direction: 'DESC', property: 'currentProject'},
      {direction: 'DESC', property: 'project_code_'},
      {direction: 'DESC', property: 'project_name_'}, -->
  <at-table
    @load="loadData"
    :data="data"
    :page-result="pageResult"
    ref="AtTable"
    :default-querys="[{property: 'parent_id_', value: 'root'}]"
    :default-sorter="[
      {direction: 'ASC', property: 'project_type_'},
      {direction: 'ASC', property: 'project_manager_'},
      {direction: 'DESC', property: 'project_money_'},
    ]"
    :dialogTitle="dialogTitle"
    :dialogVisible="dialogVisible"
    :elAuth="'project_update'"
    :cellClassNameFn="cellClassNameFn"
    @select-all="handleSelect"
    @select="handleSelect"
    @handleDialogCancel="handleDialogCancel"
    @handleDialogClose="handleDialogClose"
    @handleDialogSubmit="handleDialogSubmit"
    @row-dblclick="handleRowDBClick"
    @expand-change="handleExpandChange"
  >
    <template v-slot:searchInput>
      <el-form
        ref="searchForm"
        :model="searchForm"
        label-width="80px"
        class="search-top"
        @submit.native.prevent
      >
        <!-- <project-info-selector
          v-model="searchForm.projectId"
          style="width: 100%"
        ></project-info-selector> -->
        <el-select
          v-model="searchForm.createTime"
          clearable
          placeholder="请选择年份"
          @change="findinfo"
        >
          <el-option
            v-for="item in optionYears"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>

        <dict-select
          dictCode="xmgl-xmlx"
          :hasDefaultOption="true"
          clearable
          placeholder="请选择项目类型"
          v-model="searchForm.projectType"
          style="width: 100%"
          @input="findinfo"
        />
        <el-input
          v-model="searchForm.projectName"
          placeholder="请输入项目名称"
          @keyup.enter.native="findinfo"
          clearable
        ></el-input>
        <!-- <project-info-selector
          v-model="searchForm.projectId"
          ref="projectInfoSelector"
          @keyup.enter.native="findinfo"
          @input="findinfo"
        ></project-info-selector> -->
        <!-- <el-input
          v-model="searchForm.projectName"
          placeholder="请输入项目名称"
          @keyup.enter.native="findinfo"
          clearable
        ></el-input> -->
        <!-- <dict-select
          dictCode="xmgl-jsms"
          :hasDefaultOption="true"
          clearable
          placeholder="请选择建设模式"
          v-model="searchForm.projectModel"
          style="width: 100%"
        /> -->
        <el-input
          style="margin-right: 10px"
          type="number"
          v-model="searchForm.projectMoneyOne"
          placeholder="请输入投资金额"
          @keyup.enter.native="findinfo"
          clearable
          @input="findinfo"
        ></el-input>
        <span>~</span>
        <el-input
          type="number"
          v-model="searchForm.projectMoneyTwo"
          placeholder="请输入投资金额"
          @keyup.enter.native="findinfo"
          clearable
          @input="findinfo"
        ></el-input>
        <el-select
          v-model="searchForm.isStart"
          clearable
          placeholder="请选择是否已开工"
          @change="findinfo"
        >
          <el-option
            v-for="item in optionsIsStart"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
        <el-button
          size="small"
          @click="findinfo"
          type="primary"
          class="el-icon-search search-btn"
          >查询</el-button
        >
        <el-button
          size="small"
          @click="handleReset"
          type="primary"
          plain
          class="el-icon-refresh"
          >重置</el-button
        >
      </el-form>
    </template>
    <template v-slot:operationBtn>
      <el-button
        size="small"
        type="primary"
        @click="handleAdd"
        icon="el-icon-plus"
        v-methodauth="'project_add'"
        >添加</el-button
      >
      <ht-delete-button
        :url="deleteUrl"
        :requestMethod="'POST'"
        :htTable="$refs.AtTable"
        v-methodauth="'project_del'"
        >删除</ht-delete-button
      >
      <!-- <import-data
        tempFiles=""
        bizCode=""
        :dataBaseOptions="dataBaseOptions"
        :originAPIOptions="originAPIOptions"
        @reload="load(exportQuery)"
      ></import-data>

      <export-data
        tempFiles=""
        bizCode=""
        :dataBaseOptions="dataBaseOptions"
        :originAPIOptions="originAPIOptions"
        :exportQuery="exportQuery"
      ></export-data> -->
      <import-file
        :importData="importData"
        @load="load"
        v-methodauth="'project_import'"
      ></import-file>
      <el-button
        size="small"
        type="primary"
        @click="handleExport"
        :loading="loading2"
        icon="el-icon-download"
        plain
        style="margin-left: 10px"
        v-methodauth="'project_export'"
        >导出</el-button
      >
      <!-- <el-button
        type="primary"
        plain
        size="small"
        icon="el-icon-user-solid"
        @click="handleSetCurrent"
        v-methodauth="'project_current'"
      >
        设为当前项目
      </el-button> -->
      <!-- 合并项目 -->
      <merge
        :htTable="$refs.AtTable"
        @load="load"
        @mergeNewProject="handleMergeNewProject"
        v-methodauth="'project_merge'"
      />
      <!-- v-methodauth="'project_split'" -->
      <el-popconfirm
        title="确定拆分吗？"
        @confirm="splitProject"
        rigger="hover"
        class="ht-split-button"
        v-methodauth="'project_split'"
      >
        <el-button
          type="primary"
          plain
          size="small"
          icon="el-icon-connection"
          slot="reference"
        >
          拆分项目
        </el-button>
      </el-popconfirm>
    </template>
    <template>
      <el-table-column type="expand" prop="projectCode">
        <template>
          <el-table
            :data="expandTableData"
            style="width: 100%"
            ref="expandTable"
            @select-all="handleExpSelect"
            @select="handleExpSelect"
            @row-dblclick="handleRowDBClick"
          >
            <!-- <el-table-column
              type="index"
              label="序号"
              align="center"
              width="55"
            >
            </el-table-column> -->
            <el-table-column type="selection" width="55" align="center">
            </el-table-column>
            <!-- <el-table-column
              prop="projectCode"
              label="项目代码"
              align="center"
              :show-overflow-tooltip="true"
            >
            </el-table-column> -->
            <el-table-column
              prop="projectName"
              label="项目名称"
              :show-overflow-tooltip="true"
              align="center"
              sortable
            >
            </el-table-column>
            <el-table-column
              prop="projectManager"
              label="项目负责人"
              :show-overflow-tooltip="true"
              align="center"
            >
            </el-table-column>
            <ht-table-column
              prop="projectType"
              label="项目类型"
              align="center"
              :show-overflow-tooltip="true"
              :filters="getDictData('xmgl-xmlx')"
            >
              <template v-slot="{row}">
                <span v-if="row.projectType !== '----'">
                  {{ getDictName('xmgl-xmlx', row.projectType) }}
                </span>
                <span v-else>----</span>
              </template>
            </ht-table-column>
            <!-- <el-table-column
              prop="ownerUnit"
              label="业主单位"
              align="center"
              :show-overflow-tooltip="true"
            >
            </el-table-column> -->
            <!-- <el-table-column
              prop="responsibleUnit"
              label="责任单位"
              align="center"
              :show-overflow-tooltip="true"
            >
            </el-table-column> -->
            <!-- <el-table-column
              prop="constructUnit"
              label="施工单位"
              align="center"
              :show-overflow-tooltip="true"
            >
            </el-table-column> -->
            <!-- <ht-table-column
              prop="projectModel"
              label="建设模式"
              align="center"
              :show-overflow-tooltip="true"
              :filters="getDictData('xmgl-jsms')"
            >
              <template v-slot="{row}">
                <div>{{ getDictName('xmgl-jsms', row.projectModel) }}</div>
              </template>
            </ht-table-column> -->
            <!-- <el-table-column
              prop="projectAddress"
              label="项目地址"
              align="center"
              :show-overflow-tooltip="true"
            >
            </el-table-column> -->
            <!-- <el-table-column
              prop="preliminaryEstimate"
              label="初设概算总投资(万元)"
              align="center"
              width="180"
              :show-overflow-tooltip="true"
            >
            </el-table-column> -->
            <el-table-column
              prop="projectMoney"
              label="总投资(万元)"
              :show-overflow-tooltip="true"
              align="center"
              sortable
            >
            </el-table-column>
            <!--<ht-table-column
              prop="projectStatus"
              label="项目状态"
              align="center"
              width="110"
              :show-overflow-tooltip="true"
              :filters="getDictData('xmgl-xmzt')"
            >
              <template v-slot="{row}">
                {{ getDictName('xmgl-xmzt', row.projectStatus) }}
              </template>
            </ht-table-column>
             <el-table-column
              prop="commencementTime"
              label="开工时间"
              align="center"
              :show-overflow-tooltip="true"
            >
            </el-table-column> -->
            <!-- <el-table-column
              prop="completionTime"
              label="完工时间"
              align="center"
              :show-overflow-tooltip="true"
            >
            </el-table-column> 
            <el-table-column
              prop="accumulatedProjectPayment"
              label="累计已完成投资(万元)"
              :show-overflow-tooltip="true"
              align="center"
              width="210"
              sortable
            >
            </el-table-column>
            <el-table-column
              prop="constructionProgress"
              label="本月进度"
              :show-overflow-tooltip="true"
              align="center"
              width="150"
              sortable
            >
            </el-table-column>
            <el-table-column
              prop="remarks"
              label="备注"
              align="center"
              width="120"
              :show-overflow-tooltip="true"
            >
            </el-table-column>-->
          </el-table>
          <el-pagination
            small
            class="expandPagination"
            :disabled="loading"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pagination.page"
            :page-sizes="pageSizes"
            :page-size="pagination.pageSize"
            :pager-count="pagerCount"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pagination.total"
          ></el-pagination>
        </template>
      </el-table-column>
      <el-table-column type="selection" width="55" align="center">
      </el-table-column>
      <!-- <el-table-column
        type="index"
        label="序号"
        align="center"
        width="55"
      >
      </el-table-column> -->
      <!-- <el-table-column
        prop="projectCode"
        label="项目代码"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
      <el-table-column
        prop="projectName"
        label="项目名称"
        :show-overflow-tooltip="true"
        align="center"
        min-width="300"
        sortable
      >
        <template v-slot="{row}">
          <a
            class="a-link"
            @click="handleGo(row)"
            v-if="getMethodauth('href_look')"
            >{{ row.projectName }}</a
          >
          <span v-else>{{ row.projectName }}</span>
          <!-- <el-link
            type="primary"
            @click="handleGo(row)"
          >{{
            row.projectName
          }}</el-link> -->
        </template>
      </el-table-column>
      <el-table-column
        prop="projectManager"
        label="项目负责人"
        :show-overflow-tooltip="true"
        align="center"
        width="130"
        sortable
      >
      </el-table-column>
      <ht-table-column
        prop="projectType"
        label="项目类型"
        align="center"
        width="130"
        sortable
        :show-overflow-tooltip="true"
      >
        <template v-slot="{row}">
          <span v-if="row.projectType !== '----'">
            {{ getDictName('xmgl-xmlx', row.projectType) }}
          </span>
          <span v-else>----</span>
        </template>
      </ht-table-column>
      <el-table-column
        prop="projectMoney"
        label="总投资(万元)"
        :show-overflow-tooltip="true"
        align="center"
        width="150"
        sortable
      >
      </el-table-column>
      <ht-table-column
        prop="projectStatus"
        label="项目状态"
        align="center"
        width="150"
        sortable
        :show-overflow-tooltip="true"
        :filters="getDictData('xmgl-xmzt')"
      >
        <template v-slot="{row}">
          <span v-if="row.projectStatus !== '----'">
            {{ getDictName('xmgl-xmzt', row.projectStatus) }}
          </span>
          <span v-else>----</span>
        </template>
      </ht-table-column>
      <!-- <el-table-column
        prop="remarks"
        label="备注"
        align="center"
        width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
      <el-table-column
        prop="accumulatedProjectPayment"
        label="累计已完成投资(万元)"
        :show-overflow-tooltip="true"
        align="center"
        width="200"
        sortable
      >
      </el-table-column>
      <el-table-column
        prop="constructionProgress"
        label="本月进度"
        :show-overflow-tooltip="true"
        align="center"
        width="120"
        sortable
      >
      </el-table-column>
      <!-- <el-table-column
        prop="ownerUnit"
        label="业主单位"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        prop="responsibleUnit"
        label="责任单位"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
      <!-- <el-table-column
        prop="constructUnit"
        label="施工单位"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->

      <!-- <ht-table-column
        prop="projectModel"
        label="建设模式"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
        :filters="getDictData('xmgl-jsms')"
      >
        <template v-slot="{row}">
          <div>{{ getDictName('xmgl-jsms', row.projectModel) }}</div>
        </template>
      </ht-table-column> -->
      <!-- <el-table-column
        prop="projectAddress"
        label="项目地址"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->

      <!--<el-table-column
        prop="preliminaryEstimate"
        label="初设概算总投资(万元)"
        align="center"
        width="180"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        prop="commencementTime"
        label="开工时间"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
       <el-table-column
        prop="completionTime"
        label="完工时间"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        prop="remarks"
        label="备注"
        align="center"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
      <el-table-column
        prop="option_"
        label="操作"
        align="center"
        fixed="right"
        width="130"
        v-if="getMethodauth('project_organization')"
      >
        <template v-slot="{row}">
          <el-dropdown
            v-if="row.option_ !== '----'"
            size="mini"
            split-button
            @command="handleCommand"
            @click="handleCommand({row: row, command: 'bianzhi'})"
          >
            <span>
              <el-link type="primary">
                <i class="el-icon-edit-outline">编制</i>
              </el-link>
            </span>
            <el-dropdown-menu
              slot="dropdown"
              v-if="getMethodauth('project_person')"
            >
              <el-dropdown-item :command="{row: row, command: 'person'}">
                <el-link type="primary">
                  <i class="el-icon-user-solid">人员管理</i>
                </el-link>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span v-else>----</span>
          <!-- <el-link
            type="primary"
            @click="handleRouterClick(row)"
          >
            <i class="el-icon-edit-outline"> 编制</i>
          </el-link> -->
          <!-- <el-link
            type="primary"
            @click="handleRouterClick(row)"
          >
            <i class="el-icon-user-solid"> 人员管理 </i>
          </el-link> -->
        </template>
      </el-table-column>
    </template>
    <template v-slot:dialogContent>
      <!-- <el-steps
        :active="active"
        finish-status="success"
        simple
        style="margin-top: 5px; margin-bottom: 20px"
      >
        <el-step title="基本信息"></el-step>
        <el-step title="结算审核情况"></el-step>
        <el-step title="决算审核情况"></el-step>
        <el-step title="决算审核占比情况"></el-step>
      </el-steps> -->
      <el-form
        ref="form"
        v-form
        data-vv-scope="form"
        :model="form"
        :rules="rules"
        label-width="150px"
        v-if="dialogVisible"
        v-loading.fullscreen="loading"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="projectName">
              <el-input
                v-model="form.projectName"
                placeholder="请输入项目名称"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目负责人" prop="projectManager">
              <!-- <el-input
                v-model="form.projectManager"
                placeholder="请输入项目负责人"
                clearable
              ></el-input> -->
              <eip-user-selector
                :appendToBody="true"
                :placeholder="'请选择用户'"
                ref="eipSelector"
                permission="b"
                v-model="form.projectManager"
                :config="{
                  id: 'form.projectManagerId',
                  name: 'form.projectManager',
                }"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="业主单位" prop="ownerUnit">
              <el-input
                v-model="form.ownerUnit"
                placeholder="请输入业主单位"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目类型" prop="projectType">
              <dict-select
                dictCode="xmgl-xmlx"
                :hasDefaultOption="true"
                clearable
                @input="(val, obj) => handleDict(val, obj, 'xmgl-xmlx')"
                v-model="form.projectType"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- <el-col :span="12">
            <el-form-item
              label="工程属性"
              prop="projectNature"
            >
              <dict-select
                dictCode="xmgl-gcsx"
                :hasDefaultOption="true"
                clearable
                v-model="form.projectNature"
                style="width: 100%"
              />
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="总投资" prop="projectMoney">
              <el-input
                v-model="form.projectMoney"
                type="number"
                placeholder="请输入总投资(万元)"
                clearable
              >
                <i slot="suffix">万元</i>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="建设时间" prop="commencementTime">
              <el-date-picker
                v-model="commencementTime"
                type="daterange"
                align="right"
                :unlink-panels="true"
                range-separator="~"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                @change="handleDateChange"
                style="width: 100%"
              >
              </el-date-picker>
              <!-- <el-date-picker
                v-model="form.commencementTime"
                type="date"
                placeholder="选择建设时间"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                style="width: 100%"
              >
              </el-date-picker> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目状态" prop="projectStatus">
              <dict-select
                dictCode="xmgl-xmzt"
                :hasDefaultOption="true"
                clearable
                @input="(val, obj) => handleDict(val, obj, 'xmgl-xmzt')"
                v-model="form.projectStatus"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12"></el-col>
        </el-row>
        <el-row>
          <el-col :sapn="24">
            <el-form-item label="备注" prop="remarks">
              <el-input
                type="textarea"
                v-model="form.remarks"
                placeholder="请输入备注"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- <div
          v-if="active == 0"
          class="task-con-box"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="项目名称"
                prop="projectName"
              >
                <el-input
                  v-model="form.projectName"
                  placeholder="请输入项目名称"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="项目状态"
                prop="projectStatus"
              >
                <dict-select
                  dictCode="xmgl-xmzt"
                  :hasDefaultOption="true"
                  clearable
                  @input="(val, obj) => handleDict(val, obj, 'xmgl-xmzt')"
                  v-model="form.projectStatus"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="项目负责人"
                prop="projectManager"
              >
                <el-input
                  v-model="form.projectManager"
                  placeholder="请输入项目负责人"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="项目金额"
                prop="projectMoney"
              >
                <el-input
                  v-model="form.projectMoney"
                  type="number"
                  placeholder="请输入项目金额(万元)"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="工程属性"
                prop="projectNature"
              >
                <dict-select
                  dictCode="xmgl-gcsx"
                  :hasDefaultOption="true"
                  clearable
                  v-model="form.projectNature"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="项目类型"
                prop="projectType"
              >
                <dict-select
                  dictCode="xmgl-xmlx"
                  :hasDefaultOption="true"
                  clearable
                  @input="(val, obj) => handleDict(val, obj, 'xmgl-xmlx')"
                  v-model="form.projectType"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="业主单位"
                prop="ownerUnit"
              >
                <el-input
                  v-model="form.ownerUnit"
                  placeholder="请输入业主单位"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="责任单位"
                prop="responsibleUnit"
              >
                <el-input
                  v-model="form.responsibleUnit"
                  placeholder="请输入责任单位"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="施工单位"
                prop="constructUnit"
              >
                <el-input
                  v-model="form.constructUnit"
                  placeholder="请输入施工单位"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="设计单位"
                prop="designUnit"
              >
                <el-input
                  v-model="form.designUnit"
                  placeholder="请输入设计单位"
                  clearable
                ></el-input>
              </el-form-item>

            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="地勘单位"
                prop="geologicalProspectingUnit"
              >
                <el-input
                  v-model="form.geologicalProspectingUnit"
                  placeholder="请输入地勘单位"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="施工进度"
                prop="constructionProgress"
              >
                <el-input
                  v-model="form.constructionProgress"
                  placeholder="请输入施工进度"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="合同金额"
                prop="contractAmount"
              >
                <el-input
                  v-model="form.contractAmount"
                  type="number"
                  placeholder="请输入合同金额"
                  clearable
                >
                  <i slot="suffix">万元</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="合同编号"
                prop="contractSigning"
              >
                <el-input
                  v-model="form.contractSigning"
                  placeholder="请输入合同编号"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="可研估算总投资"
                prop="feasibilityStudyEstimate"
              >
                <el-input
                  v-model="form.feasibilityStudyEstimate"
                  type="number"
                  placeholder="请输入可研估算总投资"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="立项审批机关"
                prop="projectApprovalAuthority"
              >
                <dict-select
                  dictCode="xmgl-lxspjg"
                  :hasDefaultOption="true"
                  clearable
                  v-model="form.projectApprovalAuthority"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="建设模式"
                prop="projectModel"
              >
                <dict-select
                  dictCode="xmgl-jsms"
                  :hasDefaultOption="true"
                  clearable
                  @input="(val, obj) => handleDict(val, obj, 'xmgl-jsms')"
                  v-model="form.projectModel"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="初设概算总投资"
                prop="preliminaryEstimate"
              >
                <el-input
                  v-model="form.preliminaryEstimate"
                  placeholder="请输入初设概算总投资"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="开工时间"
                prop="commencementTime"
              >
                <el-date-picker
                  v-model="form.commencementTime"
                  type="date"
                  placeholder="选择开工时间"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 100%"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="完工时间"
                prop="completionTime"
              >
                <el-date-picker
                  v-model="form.completionTime"
                  type="date"
                  placeholder="选择完工时间"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 100%"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="竣工验收时间"
                prop="completionAcceptanceTime"
              >
                <el-date-picker
                  v-model="form.completionAcceptanceTime"
                  type="date"
                  placeholder="选择竣工验收时间"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 100%"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="质保到期时间"
                prop="warrantyExpirationTime"
              >
                <el-date-picker
                  v-model="form.warrantyExpirationTime"
                  type="date"
                  placeholder="选择质保到期时间"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 100%"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item
            label="项目地址"
            prop="projectAddress"
          >
            <el-input
              v-model="form.projectAddress"
              placeholder="请输入项目地址"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item
            label="项目规模"
            prop="projectContent"
          >
            <el-input
              v-model="form.projectContent"
              placeholder="请输入项目规模"
              type="textarea"
              clearable
            ></el-input>
          </el-form-item>

          <el-form-item
            label="结算情况"
            prop="settlementInfo"
          >
            <el-input
              type="textarea"
              v-model="form.settlementInfo"
              placeholder="请输入结算情况"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="备注"
            prop="remarks"
          >
            <el-input
              type="textarea"
              v-model="form.remarks"
              placeholder="请输入备注"
            ></el-input>
          </el-form-item>
        </div>
        <div
          v-if="active == 1"
          class="task-con-box"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="报送结算金额"
                prop="submittedSettlementAmount"
              >
                <el-input
                  v-model="form.submittedSettlementAmount"
                  placeholder="报送结算金额"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="内部审定结算金额"
                prop="internalApprovedSettlementAmount"
              >
                <el-input
                  v-model="form.internalApprovedSettlementAmount"
                  placeholder="请输入内部审定结算金额"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="社会审计方式"
                prop="socialAuditType"
              >
                <dict-select
                  dictCode="xmgl-shsjfs"
                  :hasDefaultOption="true"
                  clearable
                  @input="(val, obj) => handleDict(val, obj, 'xmgl-shsjfs')"
                  v-model="form.socialAuditType"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="社会审计中介名称"
                prop="socialAuditIntermediary"
              >
                <el-input
                  v-model="form.socialAuditIntermediary"
                  placeholder="请输入社会审计中介名称"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="社会审定金额"
                prop="socialAuditMoney"
              >
                <el-input
                  v-model="form.socialAuditMoney"
                  placeholder="请输入社会审定金额"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="国家审计机关"
                prop="stateAuditOffice"
              >
                <dict-select
                  dictCode="xmgl-gjsjjg"
                  :hasDefaultOption="true"
                  clearable
                  @input="(val, obj) => handleDict(val, obj, 'xmgl-gjsjjg')"
                  v-model="form.stateAuditOffice"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="国家审定金额"
                prop="stateAuditMoney"
              >
                <el-input
                  v-model="form.stateAuditMoney"
                  placeholder="请输入国家审定金额"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div
          v-if="active == 2"
          class="task-con-box"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="决算审核机构"
                prop="finalAccountAuditMechanism"
              >
                <el-input
                  v-model="form.finalAccountAuditMechanism"
                  placeholder="请输入决算审核机构"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="决算审核决算金额"
                prop="finalAccountAuditMoney"
              >
                <el-input
                  v-model="form.finalAccountAuditMoney"
                  placeholder="请输入决算审核决算金额"
                  clearable
                >
                  <i slot="suffix">万元</i></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div
          v-if="active == 3"
          class="task-con-box"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="审定结算金额比例"
                prop="socialAuditMoneyAmount"
              >
                <el-input
                  v-model="form.socialAuditMoneyAmount"
                  placeholder="请输入审定结算金额比例"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="合同金额比例"
                prop="proportionContractAmount"
              >
                <el-input
                  v-model="form.proportionContractAmount"
                  placeholder="请输入合同金额比例"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <div class="button-box">
        <div
          v-if="active == 0"
          @click="handleDialogCancel"
        >取消</div>
        <div
          @click="prevSteps"
          v-if="active != 0"
        >上一步</div>
        <div
          @click="nextSteps"
          v-if="active != 3"
        >下一步</div>
        <div
          v-if="active == 3"
          @click="handleDialogSubmit"
        >保存</div>
      </div> -->
      <!-- <div
        class="loading"
        v-if='loading'
      >
        <i class="el-icon-loading"></i>
      </div>
      <div
        class="modelDiv"
        v-if='loading'
      ></div> -->
    </template>
    <template v-slot:showTotalData>
      <span class="show-slected">
        已选中<i>{{ selected.numbers }}</i>
        条数据， 总投资合计
        <i>{{ moneyFormatter(selected.money1) }} </i>万元，累计已完成投资合计
        <i>{{ moneyFormatter(selected.money2) }} </i>万元
      </span>
    </template>
  </at-table>
</template>
<script>
// import projectArr from '../../../src/assets/data.json'
import req from '@/request.js'
import merge from './Merge.vue'
const eipUserSelector = () =>
  import('@/components/selector/EipUserSelector.vue')
const BigNumber = require('bignumber.js')
export default {
  name: 'projectManagentSub',
  components: {
    merge,
    eipUserSelector,
  },
  data() {
    return {
      total: {
        projectName: '合计',
        projectManager: '----',
        projectType: '----',
        projectMoney: 0,
        projectStatus: '----',
        accumulatedProjectPayment: 0,
        constructionProgress: '----',
        option_: '----',
      },
      selected: {numbers: 0, money1: '0', money2: '0'},
      loading2: false,
      importData: {
        title: '项目管理导入',
        templateName: '项目管理模板.xls',
        downloadUrl: './../static/excel/ExportProjectManagent.xlsx',
        importUrl:
          window.context.cqxy + '/biz/projectManagement/pm/v1/importExcelData',
      },
      searchForm: {
        projectId: '',
        projectName: '',
        projectType: '',
        // projectModel: '',
        projectMoneyOne: '',
        projectMoneyTwo: '',
        isStart: '', //是否已开工
        year: '',
        createTime: '', //new Date().getFullYear()
      }, //顶部搜索参数
      optionYears: [], //顶部搜索年份选择数组
      optionsIsStart: [
        {label: '是', value: 1},
        {label: '否', value: 2},
      ], //顶部搜索是否开工选择数据
      dataBaseOptions: {
        dataBaseId: '',
        tableName: '', // 必填
        tableSchema: '',
      },
      ConstructionModeArr: [],
      ProjectTypeArr: [],
      originAPIOptions: {
        url: '', // 列表请求接口地址
        method: 'post', // 列表请求方法
        moduleRoot: '', // 微服务根路径
      },
      exportQuery: {},
      data: [], //表格数据
      pageResult: {
        page: 1,
        pageSize: 50,
        total: 0,
      },
      form: {}, //基本信息表单
      dialogVisible: false,
      dialogTitle: '添加',
      indexArr: [],
      // activeNames: ['1', '2', '3', '4'],
      active: 0,
      loading: false,
      expandTableData: [],
      currentPage: 1,
      /* 合并新项目 */
      newProjectIds: '',
      pageSizes: [10, 20, 50, 100, 200, 300, 500],
      pagerCount: 11,
      pagination: {page: 1, pageSize: 10, total: 0},
      parent: '',
      querySearch: [], //导出时传入查询的参数
      elTableSection: null,
      commencementTime: '', //查看修改回调建设时间
      rules: {
        // projectCode: {
        //   required: true,
        //   message: '请输入项目代码',
        //   trigger: 'blur',
        // },
        projectName: {
          required: true,
          message: '请输入项目名称',
          trigger: 'blur',
        },
        projectManager: {
          required: true,
          message: '必填',
          trigger: 'blur',
        },
        // projectNature: {
        //   required: true,
        //   message: '请选择工程属性',
        //   trigger: 'blur'
        // },
        // projectMoney: {
        //   required: true,
        //   message: '请输入项目金额',
        //   trigger: 'blur',
        // },
        projectType: {
          required: true,
          message: '请选择项目类型',
          trigger: 'blur',
        },
        ownerUnit: {
          required: true,
          message: '请输入业主单位',
          trigger: 'blur',
        },
        // responsibleUnit: {
        //   required: true,
        //   message: '请输入责任单位',
        //   trigger: 'blur',
        // },
        // constructUnit: {
        //   required: true,
        //   message: '请输入施工单位',
        //   trigger: 'blur',
        // },
        // projectModel: {
        //   required: true,
        //   message: '请选择建设模式',
        //   trigger: 'blur',
        // },
        // projectAddress: {
        //   required: true,
        //   message: '请输入项目地址',
        //   trigger: 'blur',
        // },
        // preliminaryEstimate: {
        //   required: true,
        //   message: '请输入初设概算总投资',
        //   trigger: 'blur',
        // },
        // projectStatus: {
        //   required: true,
        //   message: '请选择项目状态',
        //   trigger: 'blur',
        // },
        // commencementTime: {
        //   required: true,
        //   message: '请选择开工时间',
        //   trigger: 'blur',
        // },
        // completionTime: {
        //   required: true,
        //   message: '请选择完工时间',
        //   trigger: 'blur',
        // },
      },
      querysParams: [],
    }
  },
  mounted() {},
  created() {
    this.getYear()
  },
  computed: {
    deleteUrl: function () {
      return window.context.cqxy + '/biz/projectManagement/pm/v1/delete'
    },
  },
  methods: {
    //跳转单个项目页面
    handleGo(row) {
      const {href} = this.$router.resolve({
        name: 'projectBefore',
        params: {
          id: row.id,
          projectName: row.projectName,
        },
      })
      window.open(href, '_blank')
    },
    handleRouterClick(params) {
      this.$router.push({
        name: 'ProjectFlowChart',
        params: {id: params.id},
      })
    },
    handleCommand(params) {
      if (params.command == 'bianzhi') {
        this.$router.push({
          name: 'ProjectFlowChart',
          params: {
            id: params.row.id,
            projectName: params.row.projectName,
          },
        })
      } else if (params.command == 'person') {
        this.$router.push({
          name: 'PersonnelManagement',
          params: params.row,
        })
      }
    },
    //重置
    handleReset() {
      this.searchForm.projectName = ''
      this.searchForm.createTime = ''
      this.searchForm.projectId = ''
      this.searchForm.projectType = ''
      this.searchForm.projectModel = ''
      this.searchForm.projectMoneyOne = ''
      this.searchForm.projectMoneyTwo = ''
      this.searchForm.isStart = ''
      this.$refs['searchForm'].resetFields()
      this.pageResult = {
        page: 1,
        pageSize: 20,
        total: 0,
      }
      this.$nextTick(() => {
        this.$refs.AtTable.handleClearFilter()
      })
    },
    //导入后重新加载数据
    load() {
      this.$refs.AtTable.load(true)
      this.pagination = {...this.pagination, page}
      this.handleExpandChange(this.parent, true)
    },
    //导出
    handleExport() {
      this.loading2 = true
      let query = [
        // {
        //   group: 'defaultQueryGroup',
        //   operation: 'EQUAL',
        //   relation: 'AND',
        //   property: 'parent_id_',
        //   value: 'root',
        // },
        ...this.querysParams.querys
      ]
    //   let search = {
    //     id_: this.searchForm.projectId,
    //     project_name_: this.searchForm.projectName,
    //     project_type_: this.searchForm.projectType,
    //     // project_model_: this.searchForm.projectModel
    //     CREATE_TIME_: this.searchForm.createTime,
    //     project_status_: this.searchForm.isStart,
    //     project_money_: [
    //       this.searchForm.projectMoneyOne,
    //       this.searchForm.projectMoneyTwo,
    //     ],
    //   }
    //   for (let i in search) {
    //     if (search[i] && typeof search[i] !== 'undefined') {
    //       //判断是否已开工
    //       if (i == 'project_status_') {
    //         for (let j = 1; j <= 9; j++) {
    //           if (search[i] == 2) {
    //             query.push({
    //               group: 'advance',
    //               operation: 'LIKE',
    //               property: i,
    //               relation: 'OR',
    //               value: j,
    //             })
    //           } else {
    //             query.push({
    //               group: 'advance',
    //               operation: 'LIKE',
    //               property: i,
    //               relation: 'OR',
    //               value: j + 6,
    //             })
    //           }
    //         }
    //         //判断投资金额范围
    //       } else if (i == 'project_money_') {
    //         if (search[i][0] && typeof search[i][0] !== 'undefined') {
    //           query.push({
    //             group: 'advance',
    //             operation: 'GREAT',
    //             property: i,
    //             relation: 'AND',
    //             value: search[i][0],
    //           })
    //         }
    //         if (search[i][1] && typeof search[i][1] !== 'undefined') {
    //           query.push({
    //             group: 'advance',
    //             operation: 'LESS',
    //             property: i,
    //             relation: 'AND',
    //             value: search[i][1],
    //           })
    //         }
    //       } else if (i == 'CREATE_TIME_') {
    //         query.push(
    //           {
    //             group: 'createTimeGroup',
    //             operation: 'BETWEEN',
    //             property: 'commencement_time_',
    //             relation: 'OR',
    //             value: [
    //               `${search[i]}-01-01 00:00:00`,
    //               `${search[i]}-12-31 23:59:59`,
    //             ],
    //           }
    //           // {
    //           //   group: 'createTimeGroup',
    //           //   operation: 'BETWEEN',
    //           //   parentGroup: '',
    //           //   property: 'COMPLETION_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 {
    //         query.push({
    //           group: 'advance',
    //           operation: 'LIKE',
    //           property: i,
    //           relation: 'AND',
    //           value: search[i],
    //         })
    //       }
    //     }
    //   }
      let data = {
        pageBean: {
          page: 1,
          pageSize: -1,
          showTotal: true,
        },
        querys: query,
      }
      req
        .downloadPostCopy(
          '${cqxy}/biz/projectManagement/pm/v1/exportDataToExcel',
          data
        )
        .then((res) => {
          if (res.status == 200) {
            this.loading2 = false
            this.$message.success('导出成功')
          } else {
            this.loading2 = false
            this.$message.error('导出失败')
          }
        })
    },
    //上一步
    prevSteps() {
      this.active--
      this.active = this.active
    },
    //下一步
    nextSteps() {
      if (this.active !== 0) {
        this.active++
        this.active = this.active
        this.$refs['form'].clearValidate()
      }
      let _this = this
      let vaitalArr = [
        // 'projectCode',
        'projectName',
        // 'projectManager',
        // 'projectNature',
        // 'projectMoney',
        // 'projectType',
        // 'ownerUnit',
        // 'responsibleUnit',
        // 'constructUnit',
        // 'projectModel',
        // 'projectAddress',
        // 'preliminaryEstimate',
        // 'projectStatus',
        // 'commencementTime',
        // 'completionTime',
      ]
      Promise.all(
        vaitalArr.map((item) => {
          const p = new Promise((resolve, reject) => {
            _this.$refs.form.validateField(item, (vaild) => {
              resolve(vaild)
            })
          })
          return p
        })
      ).then((result) => {
        result = result.filter((item) => item)
        if (!result.length) {
          this.active++
          this.active = this.active
          this.$refs['form'].clearValidate()
        }
      })
    },
    handleDict(val, obj, str) {
      if (str === 'xmgl-xmzt') {
        this.form.projectStatusValue = obj.name
      } else if (str === 'xmgl-xmlx') {
        this.form.projectTypeValue = obj.name
      } else if (str === 'xmgl-jsms') {
        this.form.projectModelValue = obj.name
      } else if (str === 'xmgl-shsjfs') {
        this.form.socialAuditTypeValue = obj.name
      } else if (str === 'xmgl-gjsjjg') {
        this.form.stateAuditOfficeValue = obj.name
      }
    },
    handleAdd() {
      this.dialogTitle = '添加'
      this.commencementTime = []
      // 获取当前登录用户名
      let currentUser = JSON.parse(window.sessionStorage.getItem('currentUser'))
      this.form = {
        projectCode: '',
        projectName: '',
        projectType: 1, //项目类型
        // projectModel: 1, //建设模式
        // projectStatus: 1, //项目状态
        // socialAuditType: 1, //社会审计方式
        // stateAuditOffice: 1, //国家审计机关
        projectNature: 1, //工程属性
        // projectApprovalAuthority: 1, //立项审批机关
        // commencementTime: this.getDate(),
        // completionTime: this.getDate(),
        // commencementTime: '',
        // completionTime: ''
        ownerUnit: '重庆西永微电子产业园区开发有限公司',
        projectManagerId: currentUser.userId,
        projectManager: currentUser.username,
      }
      this.dialogVisible = true
    },
    handleRowDBClick(data) {
      // if (this.getMethodauth('project_update')) {
      this.$http
        .get('${cqxy}/biz/projectManagement/pm/v1/' + data.id)
        .then((res) => {
          if (res.status == 200) {
            this.dialogTitle = '修改'
            this.dialogVisible = true
            this.form = res.data
            this.commencementTime = [
              this.form.commencementTime || '',
              this.form.completionTime || '',
            ]
          } else {
            this.$message.error('请求出错,请重新选择')
          }
        })
      // }
    },
    handleSelect(selection) {
      this.indexArr = selection

      selection.forEach((item, index) => {
        if (item.projectName === '合计') {
          selection.splice(index, 1)
        }
      })
      this.selected.numbers = selection.length
      let total1 = this.calculationTotal(selection, 'projectMoney')
      let total2 = this.calculationTotal(selection, 'accumulatedProjectPayment')
      this.selected.money1 = total1
      this.selected.money2 = total2
    },
    handleDialogCancel() {
      this.dialogVisible = false
      this.active = 0
      /* 发送一个事件用于侧边栏按钮监听是否显示 */
      this.$bus.$emit('handleAsideBtn', true)
    },
    handleDialogClose() {
      this.dialogVisible = false
      this.active = 0
    },
    handleSetCurrent() {
      if (this.indexArr.length === 1) {
        this.$http
          .post(
            '${cqxy}/biz/projectManagement/pm/v1/currentProject/' +
              this.indexArr[0].id
          )
          .then((res) => {
            let data = res.data
            if (data.state) {
              this.$message.success(data.message)
            } else {
              this.$message.error(data.message)
            }
            this.$refs.AtTable.load()
          })
      } else {
        this.$message.info('请选择一个项目作为当前项目!')
      }
    },
    handleDialogSubmit() {
      let url, params
      if (this.newProjectIds) {
        url = '/biz/projectManagement/pm/v1/mergeItems'
        params = {
          projectIds: this.newProjectIds,
          projectManagement: this.form,
        }
      } else {
        url = '/biz/projectManagement/pm/v1/save'
        params = this.form
      }
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loading = true
          this.$http.post('${cqxy}' + url, params).then((res) => {
            this.loading = false
            if (res.data.state) {
              // this.$refs.projectInfoSelector.getProjectData()
              this.$refs.form.resetFields()
              this.$message.success(res.data.message)
              this.dialogVisible = false
              this.$refs.AtTable.load()
              this.active = 0
            } else {
              this.$message.error(res.data.message)
            }
          })
        }
      })
    },
    //上传发送事件
    handleUpload() {
      this.$bus.$emit('openUploader')
    },
    loadData(param, cb) {
      //   this.$refs.projectInfoSelector.getProjectData(this.searchForm.createTime)
      let query = []
      let search = {
        id_: this.searchForm.projectId,
        project_name_: this.searchForm.projectName,
        project_type_: this.searchForm.projectType,
        // project_model_: this.searchForm.projectModel
        CREATE_TIME_: this.searchForm.createTime,
        project_status_: this.searchForm.isStart,
        project_money_: [
          this.searchForm.projectMoneyOne,
          this.searchForm.projectMoneyTwo,
        ],
      }
      for (let i in search) {
        if (search[i] && typeof search[i] !== 'undefined') {
          //判断是否已开工
          if (i == 'project_status_') {
            for (let j = 1; j <= 9; j++) {
              if (search[i] == 2) {
                query.push({
                  group: 'advance',
                  operation: 'EQUAL',
                  property: i,
                  relation: 'OR',
                  value: j,
                })
              } else {
                query.push({
                  group: 'advance',
                  operation: 'EQUAL',
                  property: i,
                  relation: 'OR',
                  value: j + 6,
                })
              }
            }
            //判断投资金额范围
          } else if (i == 'project_money_') {
            if (search[i][0] && typeof search[i][0] !== 'undefined') {
              query.push({
                group: 'advance',
                operation: 'GREAT',
                property: i,
                relation: 'AND',
                value: search[i][0],
              })
            }
            if (search[i][1] && typeof search[i][1] !== 'undefined') {
              query.push({
                group: 'advance',
                operation: 'LESS',
                property: i,
                relation: 'AND',
                value: search[i][1],
              })
            }
          } else if (i == 'CREATE_TIME_') {
            query.push(
              {
                group: 'createTimeGroup',
                operation: 'BETWEEN',
                parentGroup: '',
                property: 'commencement_time_',
                relation: 'AND',
                value: [
                  `${search[i]}-01-01 00:00:00`,
                  `${search[i]}-12-31 23:59:59`,
                ],
              }
              // {
              //   group: 'createTimeGroup',
              //   operation: 'BETWEEN',
              //   parentGroup: '',
              //   property: 'COMPLETION_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 {
            query.push({
              group: 'advance',
              operation: 'LIKE',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          }
        }
      }
      if (param.querys && param.querys.length) {
        param.querys.push(...query)
      } else {
        param.querys = query
      }
      this.querysParams = param
      this.$http
        .post('${cqxy}/biz/projectManagement/pm/v1/page', param)
        .then(
          (resp) => {
            let response = resp.data.value
            this.selected = {
              numbers: 0,
              money1: '0',
              money2: '0',
            }
            let data = response.rows
            let total = this.calculationTotal(data, 'accumulatedProjectPayment')
            this.total.accumulatedProjectPayment = total
            this.total.projectMoney = this.calculationTotal(
              data,
              'projectMoney'
            )
            if (data.length !== 0) {
              data.push(this.total)
            }
            this.data = data
            this.pageResult = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total,
            }
          },
          (error) => {
            reject(error)
          }
        )
        .finally(() => {
          if (cb) {
            cb()
          }
        })
    },
    findinfo() {
      this.$refs.AtTable.load()
      // this.loadData()
    },
    /* 项目合并方法 */
    handleSizeChange(pageSize) {
      this.pagination = {...this.pagination, pageSize}
      this.handleExpandChange(this.parent)
    },
    handleCurrentChange(page) {
      this.pagination = {...this.pagination, page}
      this.handleExpandChange(this.parent, true)
    },
    handleMergeNewProject(ids) {
      let currentUser = JSON.parse(window.sessionStorage.getItem('currentUser'))
      this.form = {
        projectCode: '',
        projectName: '',
        projectType: 1, //项目类型
        projectNature: 1, //工程属性
        ownerUnit: '重庆西永微电子产业园区开发有限公司',
        projectManagerId: currentUser.userId,
        projectManager: currentUser.username,
      }
      this.newProjectIds = ids
      this.dialogVisible = true
    },
    handleExpandChange(row, doNotResetPage) {
      this.parent = {
        id: row.id,
      }
      // 默认重置页码为第一页
      if (!doNotResetPage) {
        this.pagination.page = 1
      }
      let param = {
        pageBean: {
          ...this.pagination,
          showTotal: true,
        },
        querys: [
          {
            group: 'main',
            operation: 'EQUAL',
            property: 'parent_Id_',
            relation: 'AND',
            value: this.parent.id,
          },
        ],
        // params: {
        //   parentId: this.parent.id,
        // },
      }
      delete param.pageBean.total
      this.$http
        .post('${cqxy}/biz/projectManagement/pm/v1/page', param)
        .then((resp) => {
          let response = resp.data.value
          this.expandTableData = response.rows
          this.pagination = {
            page: response.page,
            pageSize: response.pageSize,
            total: response.total,
          }
        })
    },
    //返回一个boolean类型，是否显示列表按钮
    getMethodauth(elAuth) {
      let allMethod = window.sessionStorage.allMethod
      let methodAuth = window.sessionStorage.methodAuth
      let allMethodArray = allMethod && allMethod.split(',')
      let methodAuthArray = methodAuth && methodAuth.split(',')
      // 无权限则隐藏按钮
      if (
        methodAuthArray &&
        methodAuthArray.includes(elAuth) &&
        allMethodArray &&
        allMethodArray.includes(elAuth)
      ) {
        return true
      } else {
        return false
      }
    },
    //获取顶部搜索的年份区间
    getYear() {
      const myDate = new Date()
      const startYear = 2006 //起始年份
      const endYear = myDate.getFullYear() + 3 //结束年份
      for (let i = endYear; i >= startYear; i--) {
        this.optionYears.push({
          label: i + '年',
          value: i,
        })
      }
    },
    getByYearTime() {
      let arr = []
      if (typeof this.searchForm.commencementTime !== 'undefined') {
        let year = this.searchForm.year
        arr = [year + '01-01', year + '12-30']
        this.searchForm.year = arr
      }
    },
    handleExpSelect(selection) {
      this.elTableSection = selection
    },
    splitProject() {
      this.ids = []
      if (
        this.$refs.AtTable.selection &&
        this.$refs.AtTable.selection.length !== 0 &&
        !this.elTableSection
      ) {
        this.$message.error('请选择展开的项目')
        return
      }
      if (!this.elTableSection) {
        this.$message.error('请至少选择一条数据')
        return
      }
      if (this.elTableSection && this.elTableSection.length == 0 && !this.row) {
        this.$message.error('请至少选择一条数据')
        return
      }
      if (this.row) {
        this.ids.push(this.row.id)
      } else {
        for (let item of this.elTableSection) {
          this.ids.push(item.id)
        }
      }
      this.$http
        .post('${cqxy}/biz/projectManagement/pm/v1/splitItems?ids=' + this.ids)
        .then((res) => {
          if (res.data.state) {
            this.$message.success(res.data.message)
            this.$refs.AtTable.load(true)
            /* 刷新合并项目里面的数据 */
            this.pagination = {...this.pagination, page}
            this.handleExpandChange(this.parent, true)
          } else {
            this.message.error(res.data.message)
          }
        })
    },
    handleDateChange(e) {
      if (e.length !== 0) {
        this.form.commencementTime = e[0]
        this.form.completionTime = e[1]
      }
    },
    // 计算列表合同金额合计金额
    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-form--label-top .el-form-item__label {
  padding: 0 !important;
}

// /deep/ .el-form-item {
//   // margin-bottom: 10px !important;
// }
// /deep/ .el-dialog__body {
//   padding: 5px 20px !important;
// }
// /deep/ .el-dialog {
//   height: 780PX;
// }
/deep/ .el-step.is-simple:not(:last-of-type) .el-step__title {
  max-width: 60% !important;
}

.button-box {
  display: flex;
  justify-content: flex-end;

  // position: absolute;
  // bottom: 30px;
  // right: 30px;
  div {
    padding: 10px;
    background: #2f86ff;
    margin: 10px;
    border-radius: 4px;
    cursor: pointer;
    color: #ffffff;
  }
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  i {
    font-size: 30px;
  }
}

.modelDiv {
  position: absolute;
  width: 1000px;
  height: 700px;
  top: 50px;
  left: 0;
  background-color: rgba($color: #000000, $alpha: 0.2);
}

/* 分页 */
.expandPagination {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* 表格头部样式 */
/deep/ .has-gutter th {
  color: #000;
  background-color: rgba($color: rgb(239, 239, 239), $alpha: 0.8);
}

/deep/ .el-dialog__header {
  border-bottom: 1px solid #eee;
}

/deep/ .el-table__column-filter-trigger i {
  color: #000 !important;
}

/* 是否显示展开符号 */
/deep/ .expand .el-table__expand-column .cell {
  display: none;
}

.ht-split-button {
  margin-left: 10px;
}

.a-link {
  color: #409eff;
  // font-size: 18px;

  &:hover {
    text-decoration: underline;
    cursor: pointer;
  }
}
.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>
<style>
.el-select-dropdown {
  max-width: 600px !important;
}
</style>
