<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      <div style="text-align: left;padding-bottom: 1%;font: bold 16px 新宋体">一、合同名称</div>
      <div v-if="num === 0">
        <el-form-item label="合同名称" prop="contractName">
          <el-input v-model="dataForm.contractName" placeholder="合同名称" label-width="12%"></el-input>
        </el-form-item>
        <el-form-item label="合同金额" prop="excelContractMoney">
          <el-input v-model="dataForm.excelContractMoney" placeholder="合同金额" label-width="12%"></el-input>
        </el-form-item>
      </div>
      <div v-else>
        <el-form-item label="合同名称" prop="contractName" label-width="12%">
          <el-input disabled v-model="dataForm.contractName" placeholder="合同名称" label-width="12%"></el-input>
        </el-form-item>
        <el-form-item label="新合同名称" prop="contractName" label-width="12%">
<!--          <el-input :disabled="dataForm.approval===1" v-model="dataForm.contractNewName" placeholder="新合同名称"></el-input>-->
          <el-input v-model="dataForm.contractNewName" placeholder="新合同名称"></el-input>
        </el-form-item>
        <el-form-item label="合同金额" prop="excelContractMoney" label-width="12%">
          <el-input disabled v-model="dataForm.excelContractMoney" placeholder="合同金额" label-width="12%"></el-input>
        </el-form-item>
        <el-form-item label="新合同金额" prop="excelContractMoney" label-width="12%">
<!--          <el-input :disabled="dataForm.approval===1" v-model="dataForm.excelContractMoneyNew" placeholder="新合同金额"></el-input>-->
          <el-input v-model="dataForm.excelContractMoneyNew" placeholder="新合同金额"></el-input>
        </el-form-item>
      </div>

      <div style="text-align: left;padding: 4% 0 1% 0;font: bold 16px 新宋体">二、属性定义</div>
      <el-form-item label="建设单位" prop="contractJsdwId" label-width="12%">
        <el-select
          v-model="dataForm.contractJsdwId"
          placeholder="选择建设单位"
          style="width: 100%;"
        >
          <el-option
            v-for="item in dicJsdwList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="施工单位" prop="contractSgdwId" label-width="12%">
        <el-select
          v-model="dataForm.contractSgdwId"
          placeholder="选择施工单位"
          style="width: 100%;"
        >
          <el-option
            v-for="item in dicSGDWList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="合同年份" prop="contractYear" label-width="12%">
        <el-date-picker
          v-model="dataForm.contractYear"
          type="year"
          value-format="yyyy"
          placeholder="选择年"
          style="width: 100%"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="直非友" prop="contractZfyId" label-width="12%">
        <el-select
          v-model="dataForm.contractZfyId"
          placeholder="选择直非友"
          style="width: 100%;"
        >
          <el-option
            v-for="item in dicZFYList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="监理单位" prop="contractJldwId" label-width="12%">
        <el-select
          v-model="dataForm.contractJldwId"
          placeholder="选择监理单位"
          style="width: 100%;"
        >
          <el-option
            v-for="item in dicJLDWList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="一审单位" prop="contractYsdwId" label-width="12%">
        <el-select
          v-model="dataForm.contractYsdwId"
          placeholder="选择一审单位"
          style="width: 100%;"
        >
          <el-option
            v-for="item in dicSJDWList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二审单位" prop="contractEsdwId" label-width="12%">
        <el-select
          v-model="dataForm.contractEsdwId"
          placeholder="选择二审单位"
          style="width: 100%;"
        >
          <el-option
            v-for="item in dicSJDWList"
            :key="item.dictId"
            :label="item.name"
            :value="item.dictId"
          ></el-option>
        </el-select>
      </el-form-item>

      <div style="text-align: left;padding: 4% 0 1% 0;font: bold 16px 新宋体">三、导入导出</div>
      <div style="border-bottom: 1px solid grey;text-align: center;width: 90%;margin-left: 5%"></div>
      <div style="width: 84%;padding-left: 8%;font-size: 16px" @click="insertProject()">
        <div style="display: flex">
          <div style="text-align: left;padding: 1% 0 1% 5%;width: 84%">添加</div>
          <div style="padding-top: 2%">
            <div class="arrowOpenRight"></div>
          </div>
        </div>
      </div>
      <div style="border-bottom: 1px solid grey;text-align: center;width: 90%;margin-left: 5%"></div>
      <div style="width: 84%;padding-left: 8%;font-size: 16px" @click="deleteProject()">
        <div style="display: flex">
          <div style="text-align: left;padding: 1% 0 1% 5%;width: 84%">删除</div>
          <div style="padding-top: 2%">
            <div class="arrowOpenRight"></div>
          </div>
        </div>
      </div>
      <div style="border-bottom: 1px solid grey;text-align: center;width: 90%;margin-left: 5%"></div>

    </el-form>
    <div v-if="num === 1">
<!--      <div style="text-align: left;padding: 4% 0 1% 0;font: bold 16px 新宋体">四、进项发票</div>-->
<!--      <span>1、相关描述</span><br>-->
<!--      <el-input :disabled="dataForm.approval===1" v-model="dataForm.contractJxfp"></el-input>-->
<!--      <span>2、相关照片</span><br>-->
<!--      <el-upload-->
<!--        :disabled="dataForm.approval===1"-->
<!--        class="avatar-uploader"-->
<!--        :headers="headers"-->
<!--        accept="image/jpeg,image/jpg,image/png"-->
<!--        :action="imageUploaderUrl"-->
<!--        :show-file-list="false"-->
<!--        :on-success="handleImageSuccess">-->

<!--        <img v-if="imageUrl" :src="imageUrl" class="avatar">-->
<!--        <i v-else class="el-icon-plus avatar-uploader-icon"></i>-->
<!--      </el-upload>-->
      <div style="text-align: left;padding: 4% 0 1% 0;font: bold 16px 新宋体">四、送审进度</div>
      <table style="text-align: center;" border="1" cellspacing="0" cellpadding="0">
        <tr><td style="text-align: center;font-weight: bold" colspan="6">基本信息</td></tr>
        <tr>
<!--          <td style="width: 10vw;font-weight: bold">合同名称</td>-->
<!--          <td style="width: 30vw;"><el-input readonly v-model="dataExcelForm.contractName" placeholder="自动生成" style="border-style: none;"></el-input></td>-->
          <td style="width: 15vw;font-weight: bold">合同金额</td>
          <td style="width: 15vw;font-weight: bold">合同签订时间</td>
          <td style="width: 15vw;font-weight: bold">付款比例</td>
          <td style="width: 15vw;font-weight: bold">验收时间</td>
        </tr>
        <tr>
<!--          <td style="width: 10vw;font-weight: bold">建设单位</td>-->
<!--          <td style="width: 30vw;">-->
<!--            <el-select-->
<!--            :disabled="dataForm.approval===1"-->
<!--            v-model="dataExcelForm.contractJsdwId"-->
<!--            placeholder="选择建设单位"-->
<!--            style="width: 100%;"-->
<!--          >-->
<!--            <el-option-->
<!--              v-for="item in dicJsdwList"-->
<!--              :key="item.dictId"-->
<!--              :label="item.name"-->
<!--              :value="item.dictId"-->
<!--            ></el-option>-->
<!--          </el-select>-->
<!--          </td>-->
          <td style="width: 15vw;"><el-input disabled placeholder="自动生成" v-model="dataExcelForm.excelContractMoney"></el-input></td>
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelContractQdtime"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
          <td style="width: 15vw;"><el-input placeholder="请填写付款比例" v-model="dataExcelForm.excelFkbl"></el-input></td>
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelYsbl"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
        </tr>
        <tr>
<!--          <td style="width: 10vw;font-weight: bold">施工单位</td>-->
<!--          <td style="width: 30vw;"><el-select-->
<!--            :disabled="dataForm.approval===1"-->
<!--            v-model="dataExcelForm.contractSgdwId"-->
<!--            placeholder="选择施工单位"-->
<!--            style="width: 100%;"-->
<!--          >-->
<!--            <el-option-->
<!--              v-for="item in dicSGDWList"-->
<!--              :key="item.dictId"-->
<!--              :label="item.name"-->
<!--              :value="item.dictId"-->
<!--            ></el-option>-->
<!--          </el-select></td>-->
          <td style="width: 15vw;font-weight: bold">合同开工时间</td>
          <td style="width: 15vw;font-weight: bold">合同竣工时间</td>
          <td style="width: 15vw;font-weight: bold">实际开工时间</td>
          <td style="width: 15vw;font-weight: bold">实际竣工时间</td>
        </tr>
        <tr>
<!--          <td style="width: 10vw;font-weight: bold">监理单位</td>-->
<!--          <td style="width: 30vw;"><el-select-->
<!--            :disabled="dataForm.approval===1"-->
<!--            v-model="dataExcelForm.contractJldwId"-->
<!--            placeholder="选择监理单位"-->
<!--            style="width: 100%;"-->
<!--          >-->
<!--            <el-option-->
<!--              v-for="item in dicJLDWList"-->
<!--              :key="item.dictId"-->
<!--              :label="item.name"-->
<!--              :value="item.dictId"-->
<!--            ></el-option>-->
<!--          </el-select></td>-->
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelStartTime"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelEndTime"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelActualStart"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelActualEnd"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
        </tr>
        <tr>
<!--          <td style="width: 10vw;font-weight: bold" rowspan="2">一审单位</td>-->
<!--          <td style="width: 30vw;" rowspan="2"><el-select-->
<!--            :disabled="dataForm.approval===1"-->
<!--            v-model="dataExcelForm.contractYsdwId"-->
<!--            placeholder="选择一审单位"-->
<!--            style="width: 100%;"-->
<!--          >-->
<!--            <el-option-->
<!--              v-for="item in dicSJDWList"-->
<!--              :key="item.dictId"-->
<!--              :label="item.name"-->
<!--              :value="item.dictId"-->
<!--            ></el-option>-->
<!--          </el-select></td>-->
          <td style="width: 15vw;font-weight: bold">一审提报</td>
          <td style="width: 15vw;font-weight: bold">一审减值</td>
          <td style="width: 15vw;font-weight: bold">一审定值</td>
          <td style="width: 15vw;font-weight: bold">一审定值确定时间</td>
        </tr>
        <tr>
          <td style="width: 15vw;"><el-input placeholder="请填写一审填报" v-model="dataExcelForm.excelYstb"></el-input></td>
          <td style="width: 15vw;"><el-input placeholder="请填写一审减值" v-model="dataExcelForm.excelYstz"></el-input></td>
          <td style="width: 15vw;"><el-input placeholder="请填写一审定值" v-model="dataExcelForm.excelYsdz"></el-input></td>
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelYssureTime"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
        </tr>
        <tr>
<!--          <td style="width: 10vw;font-weight: bold" rowspan="2">二审单位</td>-->
<!--          <td style="width: 30vw;" rowspan="2"><el-select-->
<!--            :disabled="dataForm.approval===1"-->
<!--            v-model="dataExcelForm.contractEsdwId"-->
<!--            placeholder="选择二审单位"-->
<!--            style="width: 100%;"-->
<!--          >-->
<!--            <el-option-->
<!--              v-for="item in dicSJDWList"-->
<!--              :key="item.dictId"-->
<!--              :label="item.name"-->
<!--              :value="item.dictId"-->
<!--            ></el-option>-->
<!--          </el-select></td>-->
          <td style="width: 15vw;font-weight: bold">二审提报</td>
          <td style="width: 15vw;font-weight: bold">二审减值</td>
          <td style="width: 15vw;font-weight: bold">二审定值</td>
          <td style="width: 15vw;font-weight: bold">二审定值确定时间</td>
        </tr>
        <tr>
          <td style="width: 15vw;"><el-input placeholder="请填写二审填报" v-model="dataExcelForm.excelEstb"></el-input></td>
          <td style="width: 15vw;"><el-input placeholder="请填写二审减值" v-model="dataExcelForm.excelEsjz"></el-input></td>
          <td style="width: 15vw;"><el-input placeholder="请填写二审定值" v-model="dataExcelForm.excelEsdz"></el-input></td>
          <td style="width: 15vw;">
            <el-date-picker
              v-model="dataExcelForm.excelEssureTime"
              :disabled="dataForm.approval===1"
              type="date"
              placeholder="选择日期"
              style="width: 100%"
            >
            </el-date-picker>
          </td>
        </tr>
        <tr>
          <td style="width: 10vw;font-weight: bold">备注</td>
          <td style="width: 30vw;" colspan="5"><el-input v-model="dataExcelForm.excelRemark"></el-input></td>
        </tr>
        <tr>
          <td colspan="6" style="font-weight: bold">提报与审计跟踪记录</td>
        </tr>
        <tr>
          <td colspan="6" style="text-align: left">
            <span style="font-weight: bold;color: grey">记录送审、份数、时间、盖章、涉及人员等时间进程:</span><br>
            <textarea maxlength="2500" v-model="dataExcelForm.excelRecording" style="width: 100%;height: 220px;resize: none;border: none;outline:none;"></textarea>
          </td>
        </tr>
      </table>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
    <el-dialog
      :title="'立项选取'"
      :visible.sync="selectLxId"
      width="45%"
      style="padding-top: 2%"
      append-to-body>
      <!--      <el-form :inline="true" :model="selectDataForm" @keyup.enter.native="getselectProject()">
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="selectDataForm.key" placeholder="参数名" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-button @click="getselectProject()">查询</el-button>
             </el-form-item>
            </el-form>-->
      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        @selection-change="handleSelectionChange"
        style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="80" />
        <el-table-column
          type="index"
          header-align="center"
          align="center"
          label="序号"
          width="50">
        </el-table-column>
        <el-table-column
          prop="projectYear"
          header-align="center"
          align="center"
          label="施工年份"
          width="120">
        </el-table-column>
<!--        <el-table-column-->
<!--          prop="projectJsdwId"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="建设单位">-->
<!--          <template slot-scope="scope">-->
<!--            <template v-for="item in dicJsdwList" v-if="scope.row.projectJsdwId === item.dictId">-->
<!--              {{item.name}}-->
<!--            </template>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column
          prop="project"
          header-align="center"
          align="center"
          label="立项名称">
        </el-table-column>
<!--        <el-table-column-->
<!--          prop="projectSgddId"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="施工地点">-->
<!--          <template slot-scope="scope">-->
<!--            <template v-for="item in dicSgddList" v-if="scope.row.projectSgddId === item.dictId">-->
<!--              {{item.name}}-->
<!--            </template>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="projectSgjdId"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="施工进度">-->
<!--          <template slot-scope="scope">-->
<!--            <template v-for="item in dicSgjdList" v-if="scope.row.projectSgjdId === item.dictId">-->
<!--              {{item.name}}-->
<!--            </template>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="projectPhotoConut"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="现场张片">-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="isContant"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="导入合同">-->
<!--          <template slot-scope="scope">-->
<!--            <span v-if="scope.row.isContant === 0">否</span>-->
<!--            <span v-if="scope.row.isContant === 1">是</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          width="70"-->
<!--          label="操作">-->
<!--          <template slot-scope="scope">-->
<!--              <el-button type="text" size="small" @click="chooseProject(scope.row.projectId)">选择</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
<!--      <el-pagination-->
<!--        @size-change="sizeChangeHandle"-->
<!--        @current-change="currentChangeHandle"-->
<!--        :current-page="pageIndex"-->
<!--        :page-sizes="[10, 20, 50, 100]"-->
<!--        :page-size="pageSize"-->
<!--        :total="totalPage"-->
<!--        layout="total, sizes, prev, pager, next, jumper">-->
<!--      </el-pagination>-->
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitSelectLxId()">确定</el-button>
        <el-button @click="selectLxId = false">取消</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :title="'立项移除'"
      :visible.sync="deleteLxId"
      width="45%"
      style="padding-top: 2%"
      append-to-body>
      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        @selection-change="handleSelectionChangeDel"
        style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="80" />
        <el-table-column
          type="index"
          header-align="center"
          align="center"
          label="序号"
          width="50">
        </el-table-column>
        <el-table-column
          prop="projectYear"
          header-align="center"
          align="center"
          label="施工年份"
          width="120">
        </el-table-column>
<!--        <el-table-column-->
<!--          prop="projectJsdwId"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="建设单位">-->
<!--          <template slot-scope="scope">-->
<!--            <template v-for="item in dicJsdwList" v-if="scope.row.projectJsdwId === item.dictId">-->
<!--              {{item.name}}-->
<!--            </template>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column
          prop="project"
          header-align="center"
          align="center"
          label="立项名称">
        </el-table-column>
<!--        <el-table-column-->
<!--          prop="projectSgddId"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="施工地点">-->
<!--          <template slot-scope="scope">-->
<!--            <template v-for="item in dicSgddList" v-if="scope.row.projectSgddId === item.dictId">-->
<!--              {{item.name}}-->
<!--            </template>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="projectSgjdId"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="施工进度">-->
<!--          <template slot-scope="scope">-->
<!--            <template v-for="item in dicSgjdList" v-if="scope.row.projectSgjdId === item.dictId">-->
<!--              {{item.name}}-->
<!--            </template>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="projectPhotoConut"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="现场张片">-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="isContant"-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          label="导入合同">-->
<!--          <template slot-scope="scope">-->
<!--            <span v-if="scope.row.isContant === 0">否</span>-->
<!--            <span v-if="scope.row.isContant === 1">是</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          header-align="center"-->
<!--          align="center"-->
<!--          width="70"-->
<!--          label="操作">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button type="text" size="small" @click="delProject(scope.row)">移除</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitDeleteLxId">确定</el-button>
        <el-button @click="deleteLxId = false">取消</el-button>
      </span>
    </el-dialog>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        isChecked: [],
        ids: [],
        id: '',
        visible: false,
        dataListLoading: false,
        selectLxId: false,
        deleteLxId: false,
        num: '', // 新增修改标志
        imageUrl: '', // 上传成功照片显示
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dicZFYList: [],
        dicSGDWList: [],
        dicJLDWList: [],
        dicSJDWList: [],
        dicSgddList: [],
        dicSgjdList: [],
        dicJsdwList: [],
        dataList: [],
        headers: {},
        imageUploaderUrl: '',
        newProjectId: '', // 操作删除之后的数组
        dataForm: {
          id: 0,
          contractName: '',
          contractNewName: '',
          excelContractMoney: '',
          excelContractMoneyNew: '',
          contractJsdwId: '',
          contractYear: '',
          contractLxId: '',
          contractZfyId: '',
          contractSgdwId: '',
          contractJldwId: '',
          contractYsdwId: '',
          contractEsdwId: '',
          contractJxfp: '',
          contractJxfpPhoto: '',
          contractSsjd: '',
          status: 0,
          approval: 0,
          isTotal: 0
        },
        dataOldForm: {
          id: '',
          contractName: '',
          contractNewName: '',
          excelContractMoney: '',
          excelContractMoneyNew: '',
          contractJsdwId: '',
          contractYear: '',
          contractLxId: '',
          contractZfyId: '',
          contractSgdwId: '',
          contractJldwId: '',
          contractYsdwId: '',
          contractEsdwId: '',
          contractJxfp: '',
          contractJxfpPhoto: '',
          contractSsjd: '',
          status: 0,
          approval: 0,
          isTotal: 0
        },
        dataExcelForm: {
          id: '',
          contractId: '',
          contractName: '',
          contractJsdw: '',
          contractJsdwId: '',
          contractSgdw: '',
          contractSgdwId: '',
          contractJldw: '',
          contractJldwId: '',
          contractYsdw: '',
          contractYsdwId: '',
          contractEsdw: '',
          contractEsdwId: '',
          excelContractMoney: '',
          excelContractMoneyNew: '',
          excelContractQdtime: '',
          excelFkbl: '',
          excelYsbl: '',
          excelStartTime: '',
          excelEndTime: '',
          excelActualStart: '',
          excelActualEnd: '',
          excelYstb: '',
          excelYstz: '',
          excelYsdz: '',
          excelYssureTime: '',
          excelEstb: '',
          excelEsjz: '',
          excelEsdz: '',
          excelEssureTime: '',
          excelRemark: '',
          excelRecording: ''
        },
        dataOldExcelForm: {
          id: '',
          contractId: '',
          contractName: '',
          contractJsdwId: '',
          contractJsdw: '',
          contractSgdwId: '',
          contractSgdw: '',
          contractJldwId: '',
          contractJldw: '',
          contractYsdwId: '',
          contractYsdw: '',
          contractEsdwId: '',
          contractEsdw: '',
          excelContractMoney: '',
          excelContractMoneyNew: '',
          excelContractQdtime: '',
          excelFkbl: '',
          excelYsbl: '',
          excelStartTime: '',
          excelEndTime: '',
          excelActualStart: '',
          excelActualEnd: '',
          excelYstb: '',
          excelYstz: '',
          excelYsdz: '',
          excelYssureTime: '',
          excelEstb: '',
          excelEsjz: '',
          excelEsdz: '',
          excelEssureTime: '',
          excelRemark: '',
          excelRecording: ''
        },
        dataRule: {
          contractName: [
            { required: true, message: '合同名称不能为空', trigger: 'blur' }
          ],
          excelContractMoney: [
            { required: true, message: '合同金额不能为空', trigger: 'blur' }
          ],
          contractYear: [
            { required: true, message: '年份不能为空', trigger: 'blur' }
          ],
          contractJsdwId: [
            { required: true, message: '建设单位不能为空', trigger: 'blur' }
          ],
          contractSgdwId: [
            { required: true, message: '施工单位不能为空', trigger: 'blur' }
          ],
          contractZfyId: [
            { required: true, message: '直非友不能为空', trigger: 'blur' }
          ],
          contractJldwId: [
            { required: true, message: '监理单位不能为空', trigger: 'blur' }
          ],
          contractYsdwId: [
            { required: true, message: '一审单位不能为空', trigger: 'blur' }
          ],
          contractEsdwId: [
            { required: true, message: '二审单位不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id, num) {
        this.id = id
        this.dataForm.id = id || 0
        this.num = num
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/business/businesscontract/info/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.contractName = data.businessContract.contractName
                this.dataForm.contractNewName = data.businessContract.contractNewName
                this.dataForm.excelContractMoney = data.businessContract.excelContractMoney
                this.dataForm.excelContractMoneyNew = data.businessContract.excelContractMoneyNew
                if(data.businessContract.excelContractMoneyNew){
                  this.dataExcelForm.excelContractMoney = data.businessContract.excelContractMoneyNew
                } else {
                  this.dataExcelForm.excelContractMoney = data.businessContract.excelContractMoney
                }
                this.dataForm.contractJsdwId = data.businessContract.contractJsdwId
                this.dataForm.contractYear = data.businessContract.contractYear
                this.dataForm.contractLxId = data.businessContract.contractLxId
                this.dataForm.contractZfyId = data.businessContract.contractZfyId
                this.dataForm.contractSgdwId = data.businessContract.contractSgdwId
                this.dataForm.contractJldwId = data.businessContract.contractJldwId
                this.dataForm.contractYsdwId = data.businessContract.contractYsdwId
                this.dataForm.contractEsdwId = data.businessContract.contractEsdwId
                this.dataForm.contractJxfp = data.businessContract.contractJxfp
                this.dataForm.contractJxfpPhoto = data.businessContract.contractJxfpPhoto
                this.dataForm.contractSsjd = data.businessContract.contractSsjd
                this.dataForm.status = data.businessContract.status
                this.dataForm.createTime = data.businessContract.createTime
                this.dataForm.updateTime = data.businessContract.updateTime
                this.dataForm.createName = data.businessContract.createName
                this.dataForm.approval = data.businessContract.approval
                this.dataForm.isTotal = data.businessContract.isTotal
                this.dataForm.projectId = data.businessContract.projectId
                // if (this.dataForm.contractJxfpPhoto) {
                //   this.$http.request({
                //     url: this.$http.adornUrl('/sys/oss/list?filePath=' + this.dataForm.contractJxfpPhoto),
                //     method: 'get'
                //   }).then(({data}) => {
                //     this.imageUrl = data.replace(/[\r\n]/g, '')
                //   })
                // }
                if (num === 1) {
                  this.dataOldForm = {
                    ...data.businessContract
                  }
                }
              }
            })
            // 送审进度
            this.$http.request({
              url: this.$http.adornUrl('/business/businessssjdexcel/contractInfo/' + id),
              method: 'get'
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataExcelForm = {
                  ...this.dataForm
                }
                this.dataOldExcelForm = {
                  ...this.dataForm
                }
                if (data.businessSsjdexcel !== null) {
                  this.dataExcelForm = {
                    ...data.businessSsjdexcel
                  }
                  this.dataOldExcelForm = {
                    ...data.businessSsjdexcel
                  }
                }
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        if (this.num === 0) {
          this.$refs['dataForm'].validate((valid) => {
            if (valid) {
              this.$http({
                url: this.$http.adornUrl(`/business/businesscontract/${!this.dataForm.id ? 'save' : 'update'}`),
                method: 'post',
                data: this.$http.adornData({
                  'id': this.dataForm.id || undefined,
                  'contractName': this.dataForm.contractName,
                  'contractNewName': this.dataForm.contractNewName,
                  'excelContractMoney': this.dataForm.excelContractMoney,
                  'excelContractMoneyNew': this.dataForm.excelContractMoneyNew,
                  'contractJsdwId': this.dataForm.contractJsdwId,
                  'contractYear': this.dataForm.contractYear,
                  'contractLxId': this.dataForm.contractLxId,
                  'contractZfyId': this.dataForm.contractZfyId,
                  'contractSgdwId': this.dataForm.contractSgdwId,
                  'contractJldwId': this.dataForm.contractJldwId,
                  'contractYsdwId': this.dataForm.contractYsdwId,
                  'contractEsdwId': this.dataForm.contractEsdwId,
                  'contractJxfp': this.dataForm.contractJxfp,
                  'contractSsjd': this.dataForm.contractSsjd,
                  'status': this.dataForm.status,
                  'createTime': this.dataForm.createTime,
                  'updateTime': this.dataForm.updateTime,
                  'createName': this.dataForm.createName,
                  'approval': this.dataForm.approval,
                  'isTotal': this.dataForm.isTotal,
                  'projectId': this.dataForm.projectId
                })
              }).then(({data}) => {
                if (data && data.code === 0) {
                  this.$message({
                    message: '操作成功',
                    type: 'success',
                    duration: 1500,
                    onClose: () => {
                      this.visible = false
                      this.$emit('refreshDataList')
                    }
                  })
                } else {
                  this.$message.error(data.msg)
                }
              })
            }
          })
        } else {
          // if (this.approval !== 1 && (JSON.stringify(this.dataForm) !== JSON.stringify(this.dataOldForm) || JSON.stringify(this.dataOldExcelForm) !== JSON.stringify(this.dataExcelForm))) {
          //   if (this.dataForm.contractNewName !== '' && this.dataForm.contractNewName !== null && this.dataForm.contractNewName !== undefined) {
          //     this.$http.request({
          //       url: this.$http.adornUrl('/business/businessapproval/save'),
          //       method: 'post',
          //       data: this.$http.adornData({
          //         'approvalId': this.dataForm.id,
          //         'approvalName': this.dataForm.contractNewName,
          //         'approvalData': JSON.stringify(this.dataForm),
          //         'approvalOldData': JSON.stringify(this.dataOldForm),
          //         'approvalSonData': JSON.stringify(this.dataExcelForm),
          //         'approvalSonOldData': JSON.stringify(this.dataOldExcelForm),
          //         'approvalType': 4,
          //         'approvalSuccess': 0
          //       })
          //     }).then(({data}) => {
          //       if (data && data.code === 0) {
          //         this.$message({
          //           message: '操作成功',
          //           type: 'success',
          //           duration: 1500,
          //           onClose: () => {
          //             this.visible = false
          //             this.$emit('refreshDataList')
          //           }
          //         })
          //       } else {
          //         this.$message.error(data.msg)
          //       }
          //     })
          //   } else {
          //     this.$refs['dataForm'].validate((valid) => {
          //       if (valid) {
          //         this.$http.request({
          //           url: this.$http.adornUrl('/business/businessapproval/save'),
          //           method: 'post',
          //           data: this.$http.adornData({
          //             'approvalId': this.dataForm.id,
          //             'approvalName': this.dataForm.contractName,
          //             'approvalData': JSON.stringify(this.dataForm),
          //             'approvalOldData': JSON.stringify(this.dataOldForm),
          //             'approvalSonData': JSON.stringify(this.dataExcelForm),
          //             'approvalSonOldData': JSON.stringify(this.dataOldExcelForm),
          //             'approvalType': 4,
          //             'approvalSuccess': 0
          //           })
          //         }).then(({data}) => {
          //           if (data && data.code === 0) {
          //             this.$message({
          //               message: '操作成功',
          //               type: 'success',
          //               duration: 1500,
          //               onClose: () => {
          //                 this.visible = false
          //                 this.$emit('refreshDataList')
          //               }
          //             })
          //           } else {
          //             this.$message.error(data.msg)
          //           }
          //         })
          //       }
          //     })
          //   }
          //   this.$refs['dataForm'].validate((valid) => {
          //     if (valid) {
          //       this.$http({
          //         url: this.$http.adornUrl(`/business/businesscontract/update`),
          //         method: 'post',
          //         data: this.$http.adornData({
          //           'id': this.dataForm.id,
          //           'approval': 1
          //         })
          //       }).then(({data}) => {
          //         if (data && data.code === 0) {
          //           this.$message({
          //             message: '操作成功',
          //             type: 'success',
          //             duration: 1500,
          //             onClose: () => {
          //               this.visible = false
          //               this.$emit('refreshDataList')
          //             }
          //           })
          //         } else {
          //           this.$message.error(data.msg)
          //         }
          //       })
          //     }
          //   })
          // } else if (this.approval === 1) {
          //   this.$message('请等待上次申请通过后再次申请')
          // } else if (this.approval !== 1 && JSON.stringify(this.dataOldForm) === JSON.stringify(this.dataForm) && JSON.stringify(this.dataExcelForm) === JSON.stringify(this.dataOldExcelForm)) {
          //   this.$message('没有信息修改,请修改后申请')
          // }
          if (JSON.stringify(this.dataOldExcelForm) !== JSON.stringify(this.dataExcelForm)) {
            if (this.dataForm.contractNewName !== '' && this.dataForm.contractNewName !== null && this.dataForm.contractNewName !== undefined) {
              this.$http.request({
                url: this.$http.adornUrl('/business/businessapproval/save'),
                method: 'post',
                data: this.$http.adornData({
                  'approvalId': this.dataForm.id,
                  'approvalName': this.dataForm.contractNewName,
                  'approvalData': JSON.stringify(this.dataForm),
                  'approvalOldData': JSON.stringify(this.dataOldForm),
                  'approvalSonData': JSON.stringify(this.dataExcelForm),
                  'approvalSonOldData': JSON.stringify(this.dataOldExcelForm),
                  'approvalType': 4,
                  'approvalSuccess': 0
                })
              }).then(({data}) => {})
            } else {
              this.$http.request({
                url: this.$http.adornUrl('/business/businessapproval/save'),
                method: 'post',
                data: this.$http.adornData({
                  'approvalId': this.dataForm.id,
                  'approvalName': this.dataForm.contractName,
                  'approvalData': JSON.stringify(this.dataForm),
                  'approvalOldData': JSON.stringify(this.dataOldForm),
                  'approvalSonData': JSON.stringify(this.dataExcelForm),
                  'approvalSonOldData': JSON.stringify(this.dataOldExcelForm),
                  'approvalType': 4,
                  'approvalSuccess': 0
                })
              }).then(({data}) => {})
            }
            this.$refs['dataForm'].validate((valid) => {
              if (valid) {
                this.$http({
                  url: this.$http.adornUrl(`/business/businesscontract/update`),
                  method: 'post',
                  data: this.$http.adornData({
                    'id': this.dataForm.id,
                    'approval': 0
                  })
                }).then(({data}) => {
                  if (data && data.code === 0) {
                    this.$message({
                      message: '操作成功',
                      type: 'success',
                      duration: 1500,
                      onClose: () => {
                        this.visible = false
                        this.$emit('refreshDataList')
                      }
                    })
                  } else {
                    this.$message.error(data.msg)
                  }
                })
              }
            })
          } else {
            if (this.dataForm.contractNewName !== '' && this.dataForm.contractNewName !== null && this.dataForm.contractNewName !== undefined) {
              this.$http.request({
                url: this.$http.adornUrl('/business/businessapproval/save'),
                method: 'post',
                data: this.$http.adornData({
                  'approvalId': this.dataForm.id,
                  'approvalName': this.dataForm.contractNewName,
                  'approvalData': JSON.stringify(this.dataForm),
                  'approvalOldData': JSON.stringify(this.dataOldForm),
                  'approvalType': 4,
                  'approvalSuccess': 0
                })
              }).then(({data}) => {})
            } else {
              this.$http.request({
                url: this.$http.adornUrl('/business/businessapproval/save'),
                method: 'post',
                data: this.$http.adornData({
                  'approvalId': this.dataForm.id,
                  'approvalName': this.dataForm.contractName,
                  'approvalData': JSON.stringify(this.dataForm),
                  'approvalOldData': JSON.stringify(this.dataOldForm),
                  'approvalType': 4,
                  'approvalSuccess': 0
                })
              }).then(({data}) => {})
            }
            this.$refs['dataForm'].validate((valid) => {
              if (valid) {
                this.$http({
                  url: this.$http.adornUrl(`/business/businesscontract/update`),
                  method: 'post',
                  data: this.$http.adornData({
                    'id': this.dataForm.id,
                    'approval': 0
                  })
                }).then(({data}) => {
                  if (data && data.code === 0) {
                    this.$message({
                      message: '操作成功',
                      type: 'success',
                      duration: 1500,
                      onClose: () => {
                        this.visible = false
                        this.$emit('refreshDataList')
                      }
                    })
                  } else {
                    this.$message.error(data.msg)
                  }
                })
              }
            })
          }
        }
      },
      // 导入项目
      insertProject () {
        this.selectLxId = true
        this.getselectProject()
      },
      // 删除项目
      deleteProject () {
        console.log(this.dataForm.projectId)
        this.deleteLxId = true
        this.dataList = []
        let projectId = '-1'
        if (this.dataForm.projectId !== '' && this.dataForm.projectId !== null && this.dataForm.projectId !== undefined) {
          projectId = this.dataForm.projectId
        }
        this.$http.request({
          url: this.$http.adornUrl('/business/businesscontract/projectList/' + projectId),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            data.page.forEach((item) => {
              if (item.projectNewName !== null) {
                item.project = item.projectNewName
              }
              this.dataList.push(item)
            })
          }
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getselectProject()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getselectProject()
      },
      // 选择立项
      // chooseProject (project) {
      //   if (this.dataForm.projectId === undefined) {
      //     this.dataForm.projectId = project.projectId
      //   } else {
      //     let newProjectIds = ''
      //     let flag = 0 // 判断有没有标志
      //     if (!this.dataForm.projectId.toString().includes(',')) { // 说明字段里面没有第二个立项
      //       if (this.dataForm.projectId !== project.projectId) {
      //         this.dataForm.projectId += ',' + project.projectId
      //       } else {
      //         this.dataForm.projectId = ''
      //       }
      //     } else {
      //       this.dataForm.projectId.split(',').forEach((item) => {
      //         // 不含有则添加新数组里
      //         if (item !== project.projectId.toString()) {
      //           if (newProjectIds === '') {
      //             newProjectIds = item
      //           } else {
      //             newProjectIds += ',' + item
      //           }
      //         } else {
      //           flag = 1 // 说明有
      //         }
      //       })
      //       if (flag === 0) { // 说明选择的立项不在字段中
      //         newProjectIds += ',' + project.projectId
      //       }
      //       this.dataForm.projectId = newProjectIds
      //     }
      //   }
      //   this.newProjectId = this.dataForm.projectId
      // },
      // 从选择的立项数组中移除
      delProject (project) {
        let newProjectIds = ''
        if (!this.newProjectId.toString().includes(',')) { // 说明字段里面没有第二个立项或者说明是空的数组
          if (this.newProjectId.toString().includes(project.projectId.toString())) { // 说明包含则清空
            this.newProjectId = ''
          } else { // 不包含则添加
            if (this.newProjectId === '') {
              this.newProjectId = project.projectId
            } else {
              this.newProjectId += ',' + project.projectId
            }
          }
        } else {
          //  先判断 数组中含不含有此立项id
          if (this.newProjectId.includes(project.projectId.toString())) { // 说明含有移除此立项
            this.newProjectId.split(',').forEach((item) => {
              if (item !== project.projectId.toString()) { // 不想等放入中间数组
                if (newProjectIds === '') {
                  newProjectIds = item
                } else {
                  newProjectIds += ',' + item
                }
              }
            })
            this.newProjectId = newProjectIds
          } else { // 说明不含有此立项则加入立项数组中
            this.newProjectId += ',' + project.projectId
          }
        }
      },
      // 图片上传成功的回调
      handleImageSuccess (res, file) {
        if (res && res.code === 0) {
          this.imageUrl = URL.createObjectURL(file.raw)
          this.dataForm.contractJxfpPhoto = res.data
        }
      },
      // 获取立项列表
      getselectProject () {
        this.dataListLoading = true
        this.dataList = []
        this.$http.request({
          url: this.$http.adornUrl('/business/businesscontract/projectList'),
          method: 'get',
          params: this.$http.adornParams({
            'isContant': 0,
            'projectJsdwId': this.dataForm.contractJsdwId
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            let proIds = this.dataForm.projectId.split(',')
            let ids_dict = {}
            proIds.forEach((item) => {
              ids_dict[item] = item
            })
            data.page.forEach((item) => {
              if (ids_dict[item.projectId]) {
              } else {
                if (item.projectNewName !== null) {
                  item.project = item.projectNewName
                }
                this.dataList.push(item)
              }
            })
          }
        })
        this.dataListLoading = false
      },
      handleSelectionChange (val) {
        let selectedIds = val.map((item) => item.projectId.toString())
        this.dataForm.projectId.split(',').forEach((item) => {
          let beal = selectedIds.includes(item)
          if(!beal){
            selectedIds.push(item)
          }
        })
        this.ids = selectedIds
      },
      submitSelectLxId () {
        this.dataForm.projectId = this.ids.join(',')
        this.selectLxId = false
      },
      handleSelectionChangeDel (val) {
        this.ids = this.dataForm.projectId.split(',')
        let selectedIds = val.map((item) => item.projectId.toString())
        selectedIds.forEach((id) => {
          this.ids = this.ids.filter(function(item) {
            return item !== id
          })
        })
        console.log(this.ids)
      },
      submitDeleteLxId () {
        this.dataForm.projectId = this.ids.join(',')
        this.deleteLxId = false
      }
    },
    mounted () {
      this.imageUploaderUrl = this.$http.adornUrl('') + '/sys/oss/upload?categoryType=invoice'
      this.$http({
        url: this.$http.adornUrl('/business/businessplan/dictList'),
        method: 'get'
      }).then(({data}) => {
        if (data && data.code === 0) {
          data.data.forEach((item) => {
            if (item.dictCode === 'is_one_day') {
              this.isOneDayList = item.children
            } else if (item.dictCode === 'work_place') { // 施工地点
              this.dicSgddList = item.children
            } else if (item.dictCode === 'work_tatus') { // 施工进度
              this.dicSgjdList = item.children
            } else if (item.dictCode === 'construction_unit') { // 建设单位
              this.dicJsdwList = item.children
            } else if (item.dictCode === 'is_friend') { // 直非友
              this.dicZFYList = item.children
            } else if (item.dictCode === 'building_section') { // 施工单位
              this.dicSGDWList = item.children
            } else if (item.dictCode === 'surveillance_unit') { // 监理单位
              this.dicJLDWList = item.children
            } else if (item.dictCode === 'approval_unit') { // 审批单位(一审单位、二审单位)
              this.dicSJDWList = item.children
            }
          })
        }
        this.dataListLoading = false
      })
      this.$http.request({
        url: this.$http.adornUrl('/business/businessplan/fpWlzList'),
        method: 'get'
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.ryList = data.page
        }
      })
    }
  }
</script>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
/* 利用穿透，设置input边框隐藏 */
.inputDeep>>>.el-input__inner {
  border: 0;
}
/* 如果你的 el-input type 设置成textarea ，就要用这个了 */
.inputDeep>>>.el-textarea__inner {
  border: 0;
  resize: none;/* 这个是去掉 textarea 下面拉伸的那个标志，如下图 */
}

.bgColor {
  background-color: #19be6b;
  color: black;
  width: 90%;
  height: 70%;
  display: flex;
  justify-content: center;
  align-items: center;
}


</style>
