<template>
  <div class="main">
    <div class="title">
      <img src="../../../assets/imgS/leftBack.png" alt="" @click="back">
      <span>上传成果信息</span>
    </div>
    <div class="module1">
      <div class="moduleTitle">
        <!-- <img src="../../assets/imgS/apply1.png" alt=""> -->
        <div>使用情况调研</div>
      </div>
      <el-form label-position="right" :model="form1" :rules="rules1" :disabled="active==1" class="formStyle1">
        <el-col :span="7">
          <el-form-item label="应用领域" prop="applicationArea" label-width="80px">
            <el-input placeholder="请输入应用领域" v-model="form1.applicationArea" />
          </el-form-item>
        </el-col>
        <el-col :span="7" :offset="1">
          <el-form-item label="使用超算平台软件" prop="platformSoftware" label-width="120px">
            <el-input placeholder="请输入使用超算平台软件" v-model="form1.platformSoftware" />
          </el-form-item>
        </el-col>
        <el-col :span="7" :offset="1">
          <el-form-item label="自主安装软件名" prop="softwareName" label-width="120px">
            <el-input v-model="form1.softwareName" placeholder="请输入软件名，可填写多个" />
          </el-form-item>
        </el-col>
      </el-form>
    </div>

    <div class="module1">
      <div class="moduleTitle">
        <div>成果信息</div>
        <span class="prompt">请注意：已发表成果和预约成果，两种成果至少填写一种</span>
      </div>
      <div class="secondTitle1">
        <span class="secondTitle">已发表成果</span><span class="prompt">相同成果提交一次即可，之前已经提交过的成果本次无需再重复提交</span>
      </div>
      <div class="publishAchievements">
        <div class="paperAchievements">
          <div class="smallTitle">论文</div>
          <div v-if="paperAchievementList.length > 0">
            <div v-for="(item, index) in paperAchievementList" :key="index">
              <el-form label-position="right" :model="item"  :disabled="active==1" :rules="rules1" class="formStyle1"
                :ref="'paperAchievement' + index" v-if="item.delFlag == null || item.delFlag == '0'">
                <el-col :span="22">
                  <el-form-item>
                    <div class="numberDeletion">
                      <div>论文{{ index + 1 }}</div>
                      <el-button type="text" @click="delPaper(index, item)">删除</el-button>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="发表日期" prop="allTime" label-width="100px">
                    <el-date-picker v-model="item.allTime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
                      placeholder="请选择发表日期" style="width: 100%;">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="文章题目" prop="articleTitle" label-width="100px">
                    <el-input v-model="item.articleTitle" placeholder="请输入文章题目" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="主要作者" prop="leadAuthor" label-width="100px">
                    <el-input v-model="item.leadAuthor" placeholder="请输入主要作者" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="DOI" prop="doi" label-width="100px">
                    <el-input v-model="item.doi" placeholder="请输入DOI" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="期刊名" prop="journalName" label-width="100px">
                    <el-input v-model="item.journalName" placeholder="请输入期刊名" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="期刊分区" prop="journalPartitionId" label-width="100px">
                    <el-select v-model="item.journalPartitionId" placeholder="请选择期刊分区" style="width: 100%;">
                      <el-option v-for="item in journalPartitionList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="影响因子" prop="impactFactors" label-width="100px">
                    <el-input v-model="item.impactFactors" placeholder="请输入影响因子" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目名称" prop="projectName" label-width="100px">
                    <el-input v-model="item.projectName" placeholder="请输入所属项目名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目编号" prop="projectNumber" label-width="100px">
                    <el-input v-model="item.projectNumber" placeholder="请输入所属项目编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目来源" prop="projectSource" label-width="100px">
                    <el-input v-model="item.projectSource" placeholder="请输入项目来源" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目类别" prop="projectClassId" label-width="100px">
                    <el-select v-model="item.projectClassId" placeholder="请选择项目类别" style="width: 100%;">
                      <el-option v-for="item in projectClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目周期" prop="projectCycleRange" label-width="100px">
                    <el-date-picker v-model="item.projectCycleRange" type="daterange" range-separator="-"
                      start-placeholder="开始时间" end-placeholder="结束时间" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                      style="width: 100%;" @change="projectCycleRangeChange('paperAchievementList', index, $event)">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="与郑州中心关联度" prop="correlationClassId" label-width="100px">
                    <el-select v-model="item.correlationClassId" placeholder="请选择与郑州中心关联度" style="width: 100%;">
                      <el-option v-for="item in correlationClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="22">
                  <el-form-item
                    label="成果在发表时是否注明“国家超级计算郑州中心支持(Supported by National Supercomputing Center in Zhengzhou)”"
                    prop="isNote">
                    <el-radio-group v-model="item.isNote">
                      <el-radio label="1">是</el-radio>
                      <el-radio label="0">否</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-form>
            </div>
          </div>
          <div @click="addPaper" class="addAchievements" v-if="active!=1">+添加论文信息</div>
        </div>
        <div class="paperAchievements">
          <div class="smallTitle">专利</div>
          <div v-if="patentAchievementList.length > 0">
            <div v-for="(item, index) in patentAchievementList" :key="index">
              <el-form label-position="right" :model="item" :disabled="active==1" :rules="rules2" class="formStyle1"
                :ref="'patentAchievement' + index" v-if="item.delFlag == null || item.delFlag == '0'">
                <el-col :span="22">
                  <el-form-item>
                    <div class="numberDeletion">
                      <div>专利{{ index + 1 }}</div>
                      <el-button type="text" @click="delPatent(index, item)">删除</el-button>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="专利申请日期" prop="allTime" label-width="100px">
                    <el-date-picker v-model="item.allTime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
                      placeholder="请选择专利申请日期" style="width: 100%;">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="专利类别" prop="patentClassId" label-width="100px">
                    <el-select v-model="item.patentClassId" placeholder="请选择专利类别" style="width: 100%;">
                      <el-option v-for="item in patentClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="专利名称" prop="patentName" label-width="100px">
                    <el-input v-model="item.patentName" placeholder="请输入专利名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="专利号" prop="patentNumber" label-width="100px">
                    <el-input v-model="item.patentNumber" placeholder="请输入专利号" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="主要作者" prop="leadAuthor" label-width="100px">
                    <el-input v-model="item.leadAuthor" placeholder="请输入主要作者" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目名称" prop="projectName" label-width="100px">
                    <el-input v-model="item.projectName" placeholder="请输入所属项目名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目编号" prop="projectNumber" label-width="100px">
                    <el-input v-model="item.projectNumber" placeholder="请输入所属项目编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目来源" prop="projectSource" label-width="100px">
                    <el-input v-model="item.projectSource" placeholder="请输入项目来源" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目类别" prop="projectClassId" label-width="100px">
                    <el-select v-model="item.projectClassId" placeholder="请选择项目类别" style="width: 100%;">
                      <el-option v-for="item in projectClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目周期" prop="projectCycleRange" label-width="100px">
                    <el-date-picker v-model="item.projectCycleRange" type="daterange" range-separator="-"
                      start-placeholder="开始时间" end-placeholder="结束时间" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                      style="width: 100%;" @change="projectCycleRangeChange('patentAchievementList', index, $event)">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="与郑州中心关联度" prop="correlationClassId" label-width="100px">
                    <el-select v-model="item.correlationClassId" placeholder="请选择与郑州中心关联度" style="width: 100%;">
                      <el-option v-for="item in correlationClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-form>
            </div>
          </div>
          <div @click="addPatent" class="addAchievements"  v-if="active!=1">+添加专利信息</div>
        </div>
        <div class="paperAchievements">
          <div class="smallTitle">奖项</div>
          <div v-if="prizeAchievementList.length > 0">
            <div v-for="(item, index) in prizeAchievementList" :key="index">
              <el-form label-position="right" :model="item" :disabled="active==1" :rules="rules3" class="formStyle1"
                :ref="'prizeAchievement' + index" v-if="item.delFlag == null || item.delFlag == '0'">
                <el-col :span="22">
                  <el-form-item>
                    <div class="numberDeletion">
                      <div>奖项{{ index + 1 }}</div>
                      <el-button type="text" @click="delAward(index, item)">删除</el-button>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="获奖时间" prop="allTime" label-width="100px">
                    <el-date-picker v-model="item.allTime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
                      placeholder="请选择获奖时间" style="width: 100%;">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="奖项级别" prop="prizeClassId" label-width="100px">
                    <el-select v-model="item.prizeClassId" placeholder="请选择奖项级别" style="width: 100%;">
                      <el-option v-for="item in prizeClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="奖项名称" prop="prizeName" label-width="100px">
                    <el-input v-model="item.prizeName" placeholder="请输入奖项名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="奖项题目" prop="prizeTitle" label-width="100px">
                    <el-input v-model="item.prizeTitle" placeholder="请输入奖项题目" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="参与者" prop="leadAuthor" label-width="100px">
                    <el-input v-model="item.leadAuthor" placeholder="请输入参与者,可添加多个" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目名称" prop="projectName" label-width="100px">
                    <el-input v-model="item.projectName" placeholder="请输入所属项目名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目编号" prop="projectNumber" label-width="100px">
                    <el-input v-model="item.projectNumber" placeholder="请输入所属项目编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目来源" prop="projectSource" label-width="100px">
                    <el-input v-model="item.projectSource" placeholder="请输入项目来源" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目类别" prop="projectClassId" label-width="100px">
                    <el-select v-model="item.projectClassId" placeholder="请选择项目类别" style="width: 100%;">
                      <el-option v-for="item in projectClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目周期" prop="projectCycleRange" label-width="100px">
                    <el-date-picker v-model="item.projectCycleRange" type="daterange" range-separator="-"
                      start-placeholder="开始时间" end-placeholder="结束时间" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                      style="width: 100%;" @change="projectCycleRangeChange('prizeAchievementList', index, $event)">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="与郑州中心关联度" prop="correlationClassId" label-width="100px">
                    <el-select v-model="item.correlationClassId" placeholder="请选择与郑州中心关联度" style="width: 100%;">
                      <el-option v-for="item in correlationClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-form>
            </div>
          </div>
          <div @click="addAward" class="addAchievements"  v-if="active!=1">+添加奖项信息</div>
        </div>
        <div class="paperAchievements">
          <div class="smallTitle">其他成果</div>
          <div v-if="otherAchievementList.length > 0">
            <div v-for="(item, index) in otherAchievementList" :key="index">

              <el-form label-position="right" :model="item" :disabled="active==1" :rules="rules4" class="formStyle1"
                :ref="'otherAchievement' + index" v-if="item.delFlag == null || item.delFlag == '0'">
                <el-col :span="22">
                  <el-form-item>
                    <div class="numberDeletion">
                      <div>其他成果{{ index + 1 }}</div>
                      <el-button type="text" @click="delOtherAchievements(index, item)">删除</el-button>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="发表日期" prop="allTime" label-width="100px">
                    <el-date-picker v-model="item.allTime" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
                      placeholder="请选择发表日期" style="width: 100%;">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="成果类型" prop="otherClassId" label-width="100px">
                    <el-input v-model="item.otherClassId" placeholder="请输入成果类型" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="成果名称" prop="otherName" label-width="100px">
                    <el-input v-model="item.otherName" placeholder="请输入成果名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="成果编号" prop="otherNumber" label-width="100px">
                    <el-input v-model="item.otherNumber" placeholder="请输入成果编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="参与者" prop="leadAuthor" label-width="100px">
                    <el-input v-model="item.leadAuthor" placeholder="请输入参与者,可添加多个" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目名称" prop="projectName" label-width="100px">
                    <el-input v-model="item.projectName" placeholder="请输入所属项目名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目编号" prop="projectNumber" label-width="100px">
                    <el-input v-model="item.projectNumber" placeholder="请输入所属项目编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目来源" prop="projectSource" label-width="100px">
                    <el-input v-model="item.projectSource" placeholder="请输入项目来源" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目类别" prop="projectClassId" label-width="100px">
                    <el-select v-model="item.projectClassId" placeholder="请选择项目类别" style="width: 100%;">
                      <el-option v-for="item in projectClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目周期" prop="projectCycleRange" label-width="100px">
                    <el-date-picker v-model="item.projectCycleRange" type="daterange" range-separator="-"
                      start-placeholder="开始时间" end-placeholder="结束时间" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                      style="width: 100%;" @change="projectCycleRangeChange('otherAchievementList', index, $event)">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="与郑州中心关联度" prop="correlationClassId" label-width="100px">
                    <el-select v-model="item.correlationClassId" placeholder="请选择与郑州中心关联度" style="width: 100%;">
                      <el-option v-for="item in correlationClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-form>
            </div>
          </div>
          <div @click="addOtherAchievements" class="addAchievements" v-if="active!=1">+添加其他成果信息</div>
        </div>
      </div>
      <div class="secondTitle1">
        <span class="secondTitle">预约成果</span><span class="prompt">正在利用和准备利用郑州中心平台资源进行的项目</span>
      </div>
      <div class="publishAchievements">
        <div class="paperAchievements">
          <div class="smallTitle">预约成果</div>
          <div v-if="reservationAchievementList.length > 0">
            <div v-for="(item, index) in reservationAchievementList" :key="index">
              <el-form label-position="right" :model="item" :disabled="active==1" :rules="rules5" class="formStyle1"
                :ref="'reservationAchievement' + index" v-if="item.delFlag == null || item.delFlag == '0'">
                <el-col :span="22">
                  <el-form-item>
                    <div class="numberDeletion">
                      <div>预约成果{{ index + 1 }}</div>
                      <el-button type="text" @click="delAppointmentResults(index, item)">删除</el-button>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="拟产出成果时间" prop="reservationTime" label-width="100px">
                    <el-date-picker v-model="item.reservationTime" type="date" placeholder="请选择拟产出成果时间"
                      style="width: 100%;">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="拟产出成果类别" prop="reservationClassId" label-width="100px">
                    <el-select v-model="item.reservationClassId" placeholder="请选择拟产出成果类别" style="width: 100%;">
                      <el-option v-for="item in reservationClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="拟产出成果数量" prop="reservationNum" label-width="100px">
                    <el-input v-model="item.reservationNum" placeholder="请输入拟产出成果数量" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="拟产出成果描述" prop="reservationDescribe" label-width="100px">
                    <el-input v-model="item.reservationDescribe" placeholder="请输入拟产出成果描述" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="研究领域" prop="researchField" label-width="100px">
                    <el-input v-model="item.researchField" placeholder="请输入研究领域" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="研究进展" prop="researchProgress" label-width="100px">
                    <el-input v-model="item.researchProgress" placeholder="请输入研究进展" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目名称" prop="projectName" label-width="100px">
                    <el-input v-model="item.projectName" placeholder="请输入所属项目名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="所属项目编号" prop="projectNumber" label-width="100px">
                    <el-input v-model="item.projectNumber" placeholder="请输入所属项目编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目来源" prop="projectSource" label-width="100px">
                    <el-input v-model="item.projectSource" placeholder="请输入项目来源" />
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="项目类别" prop="projectClassId" label-width="100px">
                    <el-select v-model="item.projectClassId" placeholder="请选择项目类别" style="width: 100%;">
                      <el-option v-for="item in projectClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="9">
                  <el-form-item label="与郑州中心关联度" prop="correlationClassId" label-width="100px">
                    <el-select v-model="item.correlationClassId" placeholder="请选择与郑州中心关联度" style="width: 100%;">
                      <el-option v-for="item in correlationClassList" :key="item.classId" :label="item.className"
                        :value="item.classId">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-form>
            </div>
          </div>
          <div @click="addAppointmentResults" class="addAchievements" v-if="active!=1">+添加预约成果信息</div>
        </div>
      </div>
      <div class="secondTitle2">
        <div>应用推广</div>
        <div class="agreePromoteStyle">
          <span><span style="color: red;">*</span>是否同意宣传</span>
          <el-radio-group v-model="form1.isPublicize" :disabled="active==1">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </div>
      </div>
      <div class="footer">
        <el-button @click="back">取消</el-button>
        <el-button type="primary" @click="submitForm" :disabled="active==1">保存</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import store from "@/store";

import {
  getClassListByMark, checkResourceApply,
  getOrderDetail, getUserSelectListByRoleId,
  updateCsResourceOrderApply, getFlowList,
  addConfigs, checkConfigs, closeApply,
} from "@/api/cs/csResourceOrderApply";
export default {
  data() {
    return {
      form1: { applicationArea: '', platformSoftware: '', softwareName: '', isPublicize: '' },
      paperAchievementList: [],
      patentAchievementList: [],
      prizeAchievementList: [],
      otherAchievementList: [],
      reservationAchievementList: [],
      rules1: {
        allTime: [
          { required: true, message: "请选择发表日期", trigger: "change" },
        ],
        articleTitle: [
          { required: true, message: "请输入文章题目", trigger: "blur" },
        ],
        journalPartitionId: [
          { required: true, message: "请选择期刊分区", trigger: "change" },
        ],
        impactFactors: [
          { required: true, message: "请输入影响因子", trigger: "blur" },
        ],
        projectName: [
          { required: true, message: "请输入所属项目名称", trigger: "blur" },
        ],
        projectSource: [
          { required: true, message: "请输入项目来源", trigger: "blur" },
        ],
        projectClassId: [
          { required: true, message: "请选择项目类别", trigger: "change" },
        ],
        projectCycleRange: [
          { required: true, message: "请选择项目周期", trigger: "change" },
        ],
        isNote: [
          { required: true, message: "请选择是否注明该文字", trigger: "change" },
        ],
      },
      rules2: {
        allTime: [
          { required: true, message: "请选择专利申请日期", trigger: "change" },
        ],
        patentClassId: [
          { required: true, message: "请选择专利类别", trigger: "change" },
        ],
        patentName: [
          { required: true, message: "请输入专利名称", trigger: "blur" },
        ],
        patentNumber: [
          { required: true, message: "请输入专利号", trigger: "blur" },
        ],
        projectName: [
          { required: true, message: "请输入所属项目名称", trigger: "blur" },
        ],
        projectSource: [
          { required: true, message: "请输入项目来源", trigger: "blur" },
        ],
        projectClassId: [
          { required: true, message: "请选择项目类别", trigger: "change" },
        ],
        projectCycleRange: [
          { required: true, message: "请选择项目周期", trigger: "change" },
        ],
      },
      rules3: {
        allTime: [
          { required: true, message: "请选择获奖时间", trigger: "change" },
        ],
        prizeClassId: [
          { required: true, message: "请选择奖项级别", trigger: "change" },
        ],
        prizeName: [
          { required: true, message: "请输入奖项名称", trigger: "blur" },
        ],
        prizeTitle: [
          { required: true, message: "请输入奖项题目", trigger: "blur" },
        ],
        projectName: [
          { required: true, message: "请输入所属项目名称", trigger: "blur" },
        ],
        projectSource: [
          { required: true, message: "请输入项目来源", trigger: "blur" },
        ],
        projectClassId: [
          { required: true, message: "请选择项目类别", trigger: "change" },
        ],
        projectCycleRange: [
          { required: true, message: "请选择项目周期", trigger: "change" },
        ],
      },
      rules4: {
        allTime: [
          { required: true, message: "请选择发表日期", trigger: "change" },
        ],
        otherClassId: [
          { required: true, message: "请输入成果类型", trigger: "change" },
        ],
        otherName: [
          { required: true, message: "请输入成果名称", trigger: "blur" },
        ],
        otherNumber: [
          { required: true, message: "请输入成果编号", trigger: "blur" },
        ],
        projectName: [
          { required: true, message: "请输入所属项目名称", trigger: "blur" },
        ],
        projectSource: [
          { required: true, message: "请输入项目来源", trigger: "blur" },
        ],
        projectClassId: [
          { required: true, message: "请选择项目类别", trigger: "change" },
        ],
        projectCycleRange: [
          { required: true, message: "请选择项目周期", trigger: "change" },
        ],
      },
      rules5: {
        reservationTime: [
          { required: true, message: "请选择拟产出成果时间", trigger: "change" },
        ],
        reservationClassId: [
          { required: true, message: "请选择拟产出成果类别", trigger: "change" },
        ],
        reservationNum: [
          { required: true, message: "请输入拟产出成果数量", trigger: "blur" },
        ],
        reservationDescribe: [
          { required: true, message: "请输入拟产出成果描述", trigger: "blur" },
        ],
        researchField: [
          { required: true, message: "请输入研究领域", trigger: "blur" },
        ],
        projectName: [
          { required: true, message: "请输入所属项目名称", trigger: "blur" },
        ],
        projectSource: [
          { required: true, message: "请输入项目来源", trigger: "blur" },
        ],
        projectClassId: [
          { required: true, message: "请选择项目类别", trigger: "change" },
        ],
        researchProgress: [
          { required: true, message: "请输入研究进展", trigger: "blur" },
        ],
      },
      projectClassList: [],
      journalPartitionList: [],
      patentClassList: [],
      prizeClassList: [],
      reservationClassList: [],
      correlationClassList: [],
      active:''
    }
  },
  mounted() {
    // this.active = this.$cookie.get('adminAchievementActive')
    this.active=this.$route.query.active
    this.getProjectClassList()
    this.getJournalPartitionList()
    this.getPatentClassList()
    this.getPrizeClassList()
    this.getReservationClassList()
    this.getCorrelationClassList()
    var achievement = sessionStorage.getItem('achievement') ? JSON.parse(sessionStorage.getItem('achievement')) : ''
     if(achievement.paperAchievementList[0].isNote='0'){
     			  achievement.paperAchievementList[0].isNote='1'
     }else{
     			  achievement.paperAchievementList[0].isNote='0'
     } 
     
    if (achievement) {
      
      this.achievementObj = achievement
      console.log(achievement.applicationArea,achievement.platformSoftware,achievement.softwareName);
      
      this.paperAchievementList = achievement.paperAchievementList || []
      this.patentAchievementList = achievement.patentAchievementList || []
      this.prizeAchievementList = achievement.prizeAchievementList || []
      this.otherAchievementList = achievement.otherAchievementList || []
      this.reservationAchievementList = achievement.reservationAchievementList || []
      this.form1.applicationArea = achievement.applicationArea
      this.form1.platformSoftware = achievement.platformSoftware
      this.form1.softwareName = achievement.softwareName
      this.form1.isPublicize = achievement.isPublicize || "0" 

      this.paperAchievementList.forEach(v => {
        v.projectCycleRange = [v.projectCycleBegin || '', v.projectCycleEnd || '']
      })
      this.patentAchievementList.forEach(v => {
        v.projectCycleRange = [v.projectCycleBegin || '', v.projectCycleEnd || '']
      })
      this.prizeAchievementList.forEach(v => {
        v.projectCycleRange = [v.projectCycleBegin || '', v.projectCycleEnd || '']
      })
      this.otherAchievementList.forEach(v => {
        v.projectCycleRange = [v.projectCycleBegin || '', v.projectCycleEnd || '']
      })


    }
  },
  methods: {
    getProjectClassList() {
      getClassListByMark({ classMark: 'projectClass' }).then(res => {
        this.projectClassList = res.data
      })
    },
    getJournalPartitionList() {
      getClassListByMark({ classMark: 'journalPartition' }).then(res => {
        this.journalPartitionList = res.data
      })
    },
    getPatentClassList() {
      getClassListByMark({ classMark: 'patentClass' }).then(res => {
        this.patentClassList = res.data
      })
    },
    getPrizeClassList() {
      getClassListByMark({ classMark: 'prizeClass' }).then(res => {
        this.prizeClassList = res.data
      })
    },
    getReservationClassList() {
      getClassListByMark({ classMark: 'reservationClass' }).then(res => {
        this.reservationClassList = res.data
      })
    },
    getCorrelationClassList() {
      getClassListByMark({ classMark: 'correlationClass' }).then(res => {
        this.correlationClassList = res.data
      })
    },
    submitForm() {
      if (this.form1.isPublicize == '') {
        this.$message({
          message: '请选择是否同意宣传',
          type: 'warning'
        })
      } else {
        let paperLength = this.paperAchievementList.length
        let patentLength = this.patentAchievementList.length
        let prizeLength = this.prizeAchievementList.length
        let otherLength = this.otherAchievementList.length
        let reservationLength = this.reservationAchievementList.length
        let isValid = true
        if (paperLength > 0) {
          eval('this.$refs.paperAchievement' + (paperLength - 1))[0].validate(valid => isValid = valid)
        }
        if (patentLength > 0) {
          eval('this.$refs.patentAchievement' + (patentLength - 1))[0].validate(valid => isValid = valid)
        }
        if (prizeLength > 0) {
          eval('this.$refs.prizeAchievement' + (prizeLength - 1))[0].validate(valid => isValid = valid)
        }
        if (otherLength > 0) {
          eval('this.$refs.otherAchievement' + (otherLength - 1))[0].validate(valid => isValid = valid)
        }
        if (reservationLength > 0) {
          eval('this.$refs.reservationAchievement' + (reservationLength - 1))[0].validate(valid => isValid = valid)
        }
        if (!isValid) {
          this.$message({
            message: '有未填写的必填项',
            type: 'warning'
          })
        } else {
          let confirmForm = {
            paperAchievementList: this.paperAchievementList,
            patentAchievementList: this.patentAchievementList,
            prizeAchievementList: this.prizeAchievementList,
            otherAchievementList: this.otherAchievementList,
            reservationAchievementList: this.reservationAchievementList,
            ...this.form1
          }
          store.commit('SET_achievement', confirmForm);
         localStorage.setItem('activeInfo',this.active)
          
          this.$router.go(-1)
        
        }
      }
    },

    back() {
      this.$router.go(-1)
    },
    projectCycleRangeChange(type, index, valueList) {
      this[type][index].projectCycleBegin = valueList[0]
      this[type][index].projectCycleEnd = valueList[1]
    },
    addPaper() {
      if (this.paperAchievementList.length == 0) {
        this.paperAchievementList.push({
          sort: this.paperAchievementList.length + 1,
          allTime: '',
          articleTitle: '',
          leadAuthor: '',
          doi: '',
          journalName: '',
          journalPartitionId: '',
          impactFactors: '',
          projectName: '',
          projectNumber: '',
          projectSource: '',
          projectClassId: '',
          projectCycleRange: [],
          projectCycleBegin: '',
          projectCycleEnd: '',
          correlationClassId: '',
          isNote: '',
        })
      } else {
        let index = this.paperAchievementList.length - 1
        eval('this.$refs.paperAchievement' + index)[0].validate(valid => {
          if (valid) {
            this.paperAchievementList.push({
              sort: this.paperAchievementList.length + 1,
              allTime: '',
              articleTitle: '',
              leadAuthor: '',
              doi: '',
              journalName: '',
              journalPartitionId: '',
              impactFactors: '',
              projectName: '',
              projectNumber: '',
              projectSource: '',
              projectClassId: '',
              projectCycleRange: [],
              projectCycleBegin: '',
              projectCycleEnd: '',
              correlationClassId: '',
              isNote: '',
            })
          } else {
            this.$message({
              message: '有未填写的必填项',
              type: 'warning'
            })
          }
        })
      }
    },
    delPaper(index, item) {
      if (item.delFlag == undefined) {
        this.paperAchievementList.splice(index, 1)
      } else {
        console.log(item)
        this.paperAchievementList[index].delFlag = '1'
      }
    },
    addPatent() {
      if (this.patentAchievementList.length == 0) {
        this.patentAchievementList.push({
          sort: this.patentAchievementList.length + 1,
          allTime: '',
          patentClassId: '',
          patentName: '',
          patentNumber: '',
          leadAuthor: '',
          projectName: '',
          projectNumber: '',
          projectSource: '',
          projectClassId: '',
          projectCycleRange: [],
          projectCycleBegin: '',
          projectCycleEnd: '',
          correlationClassId: ''
        })
      } else {
        let index = this.patentAchievementList.length - 1
        eval('this.$refs.patentAchievement' + index)[0].validate(valid => {
          if (valid) {
            this.patentAchievementList.push({
              sort: this.patentAchievementList.length + 1,
              allTime: '',
              patentClassId: '',
              patentName: '',
              patentNumber: '',
              leadAuthor: '',
              projectName: '',
              projectNumber: '',
              projectSource: '',
              projectClassId: '',
              projectCycleRange: [],
              projectCycleBegin: '',
              projectCycleEnd: '',
              correlationClassId: ''
            })
          } else {
            this.$message({
              message: '有未填写的必填项',
              type: 'warning'
            })
          }
        })
      }
    },
    delPatent(index, item) {
      if (item.delFlag == undefined) {
        this.patentAchievementList.splice(index, 1)
      } else {
        this.patentAchievementList[index].delFlag = '1'
      }
    },
    addAward() {
      if (this.prizeAchievementList.length == 0) {
        this.prizeAchievementList.push({
          sort: this.prizeAchievementList.length + 1,
          allTime: '',
          leadAuthor: '',
          prizeClassId: '',
          prizeName: '',
          prizeTitle: '',
          projectName: '',
          projectNumber: '',
          projectSource: '',
          projectClassId: '',
          projectCycleRange: [],
          projectCycleBegin: '',
          projectCycleEnd: '',
          correlationClassId: ''
        })
      } else {
        let index = this.prizeAchievementList.length - 1
        eval('this.$refs.prizeAchievement' + index)[0].validate(valid => {
          if (valid) {
            this.prizeAchievementList.push({
              sort: this.prizeAchievementList.length + 1,
              allTime: '',
              leadAuthor: '',
              prizeClassId: '',
              prizeName: '',
              prizeTitle: '',
              projectName: '',
              projectNumber: '',
              projectSource: '',
              projectClassId: '',
              projectCycleRange: [],
              projectCycleBegin: '',
              projectCycleEnd: '',
              correlationClassId: ''
            })
          } else {
            this.$message({
              message: '有未填写的必填项',
              type: 'warning'
            })
          }
        })
      }
    },
    delAward(index, item) {
      if (item.delFlag == undefined) {
        this.prizeAchievementList.splice(index, 1)
      } else {
        this.prizeAchievementList[index].delFlag = '1'
      }
    },
    addOtherAchievements() {
      if (this.otherAchievementList.length == 0) {
        this.otherAchievementList.push({
          sort: this.otherAchievementList.length + 1,
          allTime: '',
          leadAuthor: '',
          otherClassId: '',
          otherName: '',
          otherNumber: '',
          projectName: '',
          projectNumber: '',
          projectSource: '',
          projectClassId: '',
          projectCycleRange: [],
          projectCycleBegin: '',
          projectCycleEnd: '',
          correlationClassId: ''
        })
      } else {
        let index = this.otherAchievementList.length - 1
        eval('this.$refs.otherAchievement' + index)[0].validate(valid => {
          if (valid) {
            this.otherAchievementList.push({
              sort: this.otherAchievementList.length + 1,
              allTime: '',
              leadAuthor: '',
              otherClassId: '',
              otherName: '',
              otherNumber: '',
              projectName: '',
              projectNumber: '',
              projectSource: '',
              projectClassId: '',
              projectCycleRange: [],
              projectCycleBegin: '',
              projectCycleEnd: '',
              correlationClassId: ''
            })
          } else {
            this.$message({
              message: '有未填写的必填项',
              type: 'warning'
            })
          }
        })
      }
    },
    delOtherAchievements(index, item) {
      if (item.delFlag == undefined) {
        this.otherAchievementList.splice(index, 1)
      } else {
        this.otherAchievementList[index].delFlag = '1'
      }
    },
    addAppointmentResults() {
      if (this.reservationAchievementList.length == 0) {
        this.reservationAchievementList.push({
          sort: this.reservationAchievementList.length + 1,
          researchField: '',
          researchProgress: '',
          reservationTime: '',
          reservationClassId: '',
          reservationNum: '',
          reservationDescribe: '',
          projectName: '',
          projectNumber: '',
          projectSource: '',
          projectClassId: '',
          correlationClassId: ''
        })
      } else {
        let index = this.reservationAchievementList.length - 1
        eval('this.$refs.reservationAchievement' + index)[0].validate(valid => {
          if (valid) {
            this.reservationAchievementList.push({
              sort: this.reservationAchievementList.length + 1,
              researchField: '',
              researchProgress: '',
              reservationTime: '',
              reservationClassId: '',
              reservationNum: '',
              reservationDescribe: '',
              projectName: '',
              projectNumber: '',
              projectSource: '',
              projectClassId: '',
              correlationClassId: ''
            })
          } else {
            this.$message({
              message: '有未填写的必填项',
              type: 'warning'
            })
          }
        })
      }
    },
    delAppointmentResults(index, item) {
      if (item.delFlag == undefined) {
        this.reservationAchievementList.splice(index, 1)
      } else {
        this.reservationAchievementList[index].delFlag = '1'
      }
    }
  }
}
</script>

<style scoped>
.main {
  padding: 20px;
}

.title {
  height: 56px;
  padding-left: 20px;
  background: #FFFFFF;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.title>img {
  width: 14px;
  height: 19px;
  margin-right: 10px;
  cursor: pointer;
}

.title>span {
  font-weight: bold;
  font-size: 20px;
  color: #000000;
  text-align: left;
}

.module1 {
  height: auto;
  margin-bottom: 10px;
  padding: 16px 16px 20px 16px;
  background: #FFFFFF;
  border-radius: 4px;
  margin-top: 10px;
}

.moduleTitle {
  display: flex;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid #EBEBEB;
}

.moduleTitle>img {
  width: 22px;
  height: 22px;
}

.moduleTitle>div {
  height: 22px;
  margin-left: 6px;
  font-weight: bold;
  font-size: 16px;
  color: #0051AA;
  line-height: 22px;
  text-align: left;
  font-style: normal;
  text-transform: none;
}

.formStyle1 {
  display: flex;
  flex-wrap: wrap;
}

.prompt {
  font-size: 12px;
  color: #0051AA;
  text-align: center;
  padding-left: 20px;
}

.secondTitle1 {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

.secondTitle {
  font-weight: 500;
  font-size: 14px;
  color: #0051AA;
  padding-left: 6px;
}

.publishAchievements {
  height: auto;
  margin-bottom: 30px;
}

.paperAchievements {
  padding-bottom: 30px;
}

.smallTitle {
  font-weight: bold;
  padding-left: 6px;
}

.numberDeletion {
  display: flex;
  justify-content: space-around;
}

.addAchievements {
  height: 50px;
  text-align: center;
  line-height: 50px;
  color: #0051AA;
  border: 1px dashed #0051AA;
  margin: 10px 0;
  cursor: pointer;
}

.secondTitle2>div:nth-of-type(1) {
  color: #0051AA;
  font-weight: bold;
  margin-bottom: 10px;
}

.agreePromoteStyle>span {
  padding-right: 20px;
}

.footer {
  display: flex;
  justify-content: center;
  padding: 20px 0 50px 0;
}
</style>
