<template>
  <div class="app-content" style="max-height:75vh;overflow:auto;">
    <a-spin :spinning="loading" style="width:100%;height:100%;">
      <a-form-model ref="from" :model="formData" :rules="rules" style="border-top: 0px" class="from-table font-line-space">
        <a-row>
          <a-col :span="24" style="border-top: 0px;">
            <div class="tb-title">
              <span>基础信息</span>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>项目合同编号</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="projNo">
              {{formData.projNo}}
              <!-- <a-input placeholder="项目合同编号" v-model="formData.projNo" :maxLength="50" style="width: 80%" /> -->
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>项目名称</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="projName">
              {{formData.projName}}
              <!-- <a-input placeholder="项目名称" v-model="formData.projName" :maxLength="100" style="width: 80%" /> -->
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>项目负责人</div>
            </div>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="personName">
              {{formData.appPersonName}}
              <!-- <a-input placeholder="项目负责人" v-model="formData.personName" :maxLength="50" style="width: 80%" /> -->
            </a-form-model-item>
          </a-col>
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>联系电话</div>
            </div>
          </a-col>
          <a-col :span="8">
            <div class="special-middle">
              <a-form-model-item prop="telephone">
                {{formData.telephone}}
                <!-- <a-input placeholder="联系电话" v-model="formData.telephone" :maxLength="50" style="width: 80%" /> -->
              </a-form-model-item>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>项目承担单位</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="unitName">
              {{formData.appUnitName}}
              <!-- <a-input placeholder="承担单位" v-model="formData.appUnitName" :maxLength="50" style="width: 80%" /> -->
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">计划类别</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="planCategory">
              <a-input placeholder="计划类别" v-model="formData.planCategory" :maxLength="50" style="width: 80%" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">研究周期</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="startDate" style="width:200px;display: inline-block;">
              <a-date-picker format="YYYY-MM-DD" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="formData.startDate" style="width: 180px" />
            </a-form-model-item>
            <span style="margin: -12px 10px 0 0px">~</span>
            <a-form-model-item prop="endDate" style="width:200px;display: inline-block;">
              <a-date-picker format="YYYY-MM-DD" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="formData.endDate" style="width: 180px" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24" style="border-top: 0px;">
            <div class="tb-title">
              <span>完成或推广情况</span>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="5" class="bg-gray">
            <div class="special-middle">
              <div class="required">研究或推广内容完成情况</div>
            </div>
          </a-col>
          <a-col :span="19">
            <div class="special-middle">
              <a-form-model-item prop="promotionContent">
                <para-radio v-model="formData.promotionContent" :typeId="60" :code="'1'" />
              </a-form-model-item>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="5" class="bg-gray">
            <div class="special-middle">
              <div class="required">研究或推广目标实现情况</div>
            </div>
          </a-col>
          <a-col :span="19">
            <div class="special-middle">
              <a-form-model-item prop="promotionTarget">
                <para-radio v-model="formData.promotionTarget" :typeId="60" :code="'2'" />
              </a-form-model-item>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="5" class="bg-gray">
            <div class="special-middle">
              <div class="required">研究水平的自我评价</div>
            </div>
          </a-col>
          <a-col :span="19">
            <div class="special-middle">
              <a-form-model-item prop="selfEvaluation">
                <para-radio v-model="formData.selfEvaluation" :typeId="60" :code="'3'" />
              </a-form-model-item>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="5" class="bg-gray">
            <div class="special-middle">
              <div class="required">取得成果情况</div>
            </div>
          </a-col>
          <a-col :span="19">
            <div class="special-middle">
              <a-form-model-item prop="achievingResults">
                <para-radio v-model="formData.achievingResults" :typeId="60" :code="'4'" />
              </a-form-model-item>
            </div>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24" style="border-top: 0px;">
            <div class="tb-title">
              <span>论文发表情况（省级以上刊物）</span>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex" class="row_center">
          <a-col :span="6" class="bg-gray">
            <div class="special-middle">
              <div class="required">论文名称</div>
            </div>
          </a-col>
          <a-col :span="3" class="bg-gray">
            <div class="special-middle">
              <div class="required">作者姓名</div>
            </div>
          </a-col>
          <a-col :span="3" class="bg-gray">
            <div class="special-middle">
              <div class="required">发表年月</div>
            </div>
          </a-col>
          <a-col :span="3" class="bg-gray">
            <div class="special-middle">
              <div class="required">发表在何种刊物</div>
            </div>
          </a-col>
          <a-col :span="3" class="bg-gray">
            <div class="special-middle">
              <div class="required">国内外反映应用情况</div>
            </div>
          </a-col>
          <a-col :span="5" class="bg-gray">
            <div class="special-middle">
              <div class="required">论文上传</div>
            </div>
          </a-col>
          <a-col :span="1" class="bg-gray">
            <div class="special-middle">
              <div>操作</div>
            </div>
          </a-col>
        </a-row>
        <a-row v-for="(thesis, index) in formData.thesisList" :key="'thesisList'+index" type="flex" class="row_center">
          <a-col :span="6">
            <a-form-model-item :prop="'thesisList.' + index + '.name'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="thesis.name" :maxLength="50" placeholder="论文名称" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="3">
            <a-form-model-item :prop="'thesisList.' + index + '.author'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="thesis.author" :maxLength="25" placeholder="作者姓名" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="3">
            <a-form-model-item :prop="'thesisList.' + index + '.publishDate'" :rules="{ required: true, message: '*', trigger: 'change',}">
              <a-month-picker format="YYYY-MM" valueFormat="YYYY-MM" v-model="thesis.publishDate" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="3">
            <a-form-model-item :prop="'thesisList.' + index + '.publication'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="thesis.publication" :maxLength="100" placeholder="发表在何种刊物" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="3">
            <a-form-model-item :prop="'thesisList.' + index + '.application'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="thesis.application" :maxLength="100" placeholder="国内外反映应用情况" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="5">
            <div class="special-middle" style="text-align: left;">
              <div v-if="thesis.downloadUrl">
                <a-icon type="paper-clip" style="margin:0 6px" />
                <a class="hover-pointer" style="margin-right:8px " @click="downloadfile(thesis)">{{thesis.fileName}}</a>
                <a-popconfirm title="确定要删除吗？" ok-text="确定" cancel-text="取消" @confirm="deletefile(thesis, index)">
                  <a-icon type="close" class="hover-pointer d-icon" />
                </a-popconfirm>
              </div>
              <div v-else>
                <a-form-model-item :prop="'thesisList.' + index + '.downloadUrl'" :rules="{required: true, message: '请上传附件',trigger: 'blur',}">
                  <input type="file" :ref="'thesisfileElem' + index" class="visually-hidden" @change="handleFiles('thesisfileElem',thesis, index)" />
                  <a-button @click="fileSelect('thesisfileElem',thesis, index)"><a-icon type="upload" />选择文件</a-button>
                </a-form-model-item>
              </div>
            </div>
          </a-col>
          <a-col :span="1">
            <div class="special-middle">
              <a-popconfirm title="确定要删除吗？" ok-text="确定" cancel-text="取消" @confirm="deleteListItem(thesis,1)">
                <a-button type="link" size="small">删除</a-button>
              </a-popconfirm>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="24" style="text-align: center">
            <div class="special-middle">
              <a-button type="dashed" style="width: 20%" @click="addListItem(1)">
                <a-icon type="plus" /> 添加 <span style="color:red;margin-left:10px"></span>
              </a-button>
            </div>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24" style="border-top: 0px;">
            <div class="tb-title">
              <span>验收材料目录</span>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex" class="row_center">
          <a-col :span="2" class="bg-gray">
            <div class="special-middle">
              <div>序号</div>
            </div>
          </a-col>
          <a-col :span="20" class="bg-gray">
            <div class="special-middle">
              <div class="required">材料名称</div>
            </div>
          </a-col>
          <a-col :span="2" class="bg-gray">
            <div class="special-middle">
              <div>操作</div>
            </div>
          </a-col>
        </a-row>
        <a-row v-for="(catalog, index) in formData.catalogList" :key="'catalogList'+index+''" type="flex" class="row_center">
          <a-col :span="2">
            <div class="special-middle">
              <div>{{index+1}}</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item :prop="'catalogList.' + index + '.name'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="catalog.name" :maxLength="50" placeholder="材料名称" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="2">
            <div class="special-middle">
              <a-popconfirm title="确定要删除吗？" ok-text="确定" cancel-text="取消" @confirm="deleteListItem(catalog,3)">
                <a-button type="link" size="small">删除</a-button>
              </a-popconfirm>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="24" style="text-align: center">
            <div class="special-middle">
              <a-button type="dashed" style="width: 20%" @click="addListItem(3)">
                <a-icon type="plus" /> 添加 <span style="color:red;margin-left:10px"></span>
              </a-button>
            </div>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24" style="border-top: 0px;">
            <div class="tb-title">
              <span>主要研究人员（按贡献大小排序）</span>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex" class="row_center">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">姓名</div>
            </div>
          </a-col>
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">性别</div>
            </div>
          </a-col>
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">年龄</div>
            </div>
          </a-col>
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">技术职称</div>
            </div>
          </a-col>
          <a-col :span="6" class="bg-gray">
            <div class="special-middle">
              <div class="required">主要贡献</div>
            </div>
          </a-col>
          <a-col :span="2" class="bg-gray">
            <div class="special-middle">
              <div>操作</div>
            </div>
          </a-col>
        </a-row>
        <a-row v-for="(researcher, index) in formData.researchersList" :key="'researcher'+index+''" type="flex" class="row_center">
          <a-col :span="4">
            <a-form-model-item :prop="'researchersList.' + index + '.name'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="researcher.name" :maxLength="25" placeholder="姓名" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="4">
            <a-form-model-item :prop="'researchersList.' + index + '.sex'" :rules="{ required: true, message: '*', trigger: 'change',}">
              <a-select v-model="researcher.sex" style="width:85%">
                <a-select-option value=''>请选择</a-select-option>
                <a-select-option value="男">男</a-select-option>
                <a-select-option value="女">女</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="4">
            <a-form-model-item :prop="'researchersList.' + index + '.age'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input-number v-model="researcher.age" :min="0" :step="1" placeholder="年龄" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="4">
            <a-form-model-item :prop="'researchersList.' + index + '.technicalTitle'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="researcher.technicalTitle" :maxLength="25" placeholder="技术职称" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item :prop="'researchersList.' + index + '.contributions'" :rules="{ required: true, message: '*', trigger: 'blur',}">
              <a-input v-model="researcher.contributions" :maxLength="100" placeholder="主要贡献" style="width:85%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="2">
            <div class="special-middle">
              <a-popconfirm title="确定要删除吗？" ok-text="确定" cancel-text="取消" @confirm="deleteListItem(researcher,2)">
                <a-button type="link" size="small">删除</a-button>
              </a-popconfirm>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="24" style="text-align: center">
            <div class="special-middle">
              <a-button type="dashed" style="width: 20%" @click="addListItem(2)">
                <a-icon type="plus" /> 添加 <span style="color:red;margin-left:10px"></span>
              </a-button>
            </div>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24" style="border-top: 0px;">
            <div class="tb-title">
              <span>经费决算</span>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">拔款(万元）</div>
            </div>
          </a-col>
          <a-col :span="20" class="inner_from">
            <a-row type="flex">
              <a-col v-for="(grant, index) in formData.grant" :key="'year'+index" :span="4">
                <div class="special-middle">
                  <a-form-model-item :prop="'grant.' + index + '.year'">
                    <a-input-number v-model="grant.year" :min="0" :step="1" style="width: 70%" />
                    <span class="font_s">年</span>
                  </a-form-model-item>
                </div>
              </a-col>
              <a-col :span="4">
                <div class="special-middle">
                  <div style="text-align:center">合计</div>
                </div>
              </a-col>
            </a-row>
            <a-row type="flex">
              <a-col v-for="(grant, index) in formData.grant" :key="'amount'+index" :span="4">
                <div class="special-middle">
                  <a-form-model-item :prop="'grant.' + index + '.amount'">
                    <a-input-number v-model="grant.amount" :min="0" :step="0.01" style="width: 70%" />
                  </a-form-model-item>
                </div>
              </a-col>
              <a-col :span="4">
                <div class="special-middle" style="text-align:center">
                  {{fundsCount(formData.grant)}}
                </div>
              </a-col>
            </a-row>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">其它途径筹资（万元）</div>
            </div>
          </a-col>
          <a-col :span="20" class="inner_from">
            <a-row type="flex">
              <a-col v-for="(finance, index) in formData.finance" :key="'finance_year'+index" :span="4">
                <div class="special-middle">
                  <a-form-model-item :prop="'finance.' + index + '.year'">
                    <a-input-number v-model="finance.year" :min="0" :step="1" style="width: 70%" />
                    <span class="font_s">年</span>
                  </a-form-model-item>
                </div>
              </a-col>
              <a-col :span="4">
                <div class="special-middle">
                  <div style="text-align:center">合计</div>
                </div>
              </a-col>
            </a-row>
            <a-row type="flex">
              <a-col v-for="(finance, index) in formData.finance" :key="'finance_amount'+index" :span="4">
                <div class="special-middle">
                  <a-form-model-item :prop="'finance.' + index + '.amount'">
                    <a-input-number v-model="finance.amount" :min="0" :step="0.01" style="width: 70%" />
                  </a-form-model-item>
                </div>
              </a-col>
              <a-col :span="4">
                <div class="special-middle" style="text-align:center">
                  {{fundsCount(formData.finance)}}
                </div>
              </a-col>
            </a-row>
          </a-col>
        </a-row>
        <a-row type="flex" class="row_center">
          <a-col :span="6" class="bg-gray">
            <div class="special-middle">
              <div class="required">主要支出项目</div>
            </div>
          </a-col>
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">金额(万元)</div>
            </div>
          </a-col>
          <a-col :span="14" class="bg-gray">
            <div class="special-middle">
              <div class="required">用途</div>
            </div>
          </a-col>
        </a-row>
        <a-row v-for="(spending, index) in formData.spending" :key="'spending'+index" type="flex" class="row_center">
          <a-col :span="6">
            <a-form-model-item :prop="'spending.' + index + '.name'">
              <a-input v-model="spending.name" :maxLength="50" :disabled="index==6" />
            </a-form-model-item>
          </a-col>
          <a-col :span="4">
            <a-form-model-item :prop="'spending.' + index + '.amount'">
              <a-input-number v-model="spending.amount" :min="0" :step="0.01" style="width: 80%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="14">
            <a-form-model-item :prop="'spending.' + index + '.used'">
              <a-input v-model="spending.used" :maxLength="100" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex" class="row_center">
          <a-col :span="6">
            <div class="special-middle">
              <div>合计</div>
            </div>
          </a-col>
          <a-col :span="4">
            <div class="special-middle">
              {{fundsCount(formData.spending)}}
            </div>
          </a-col>
          <a-col :span="14"></a-col>
        </a-row>
        <a-row type="flex" class="row_center">
          <a-col :span="6" class="bg-gray">
            <div class="special-middle">
              <div class="required">结余</div>
            </div>
          </a-col>
          <a-col :span="4" style="border-left:0px !important;">
            <div class="special-middle">
              <a-form-model-item prop="balance">
                <a-input-number v-model="formData.balance" :min="0" :step="0.01" style="width: 80%" />
              </a-form-model-item>
            </div>
          </a-col>
          <a-col :span="14"></a-col>
        </a-row>
        <a-row>
          <a-col :span="24" style="border-top: 0px;">
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">研究或推广内容及结果简介</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="researchContent">
              <a-textarea placeholder="研究或推广内容及结果简介（1、完成的研究或推广内容及水平分析；2、项目研究的创新性；3、推广应用的情况，产生的社会和经济效益，并附有关证明材料。）" v-model="formData.researchContent" :maxLength="100000" style="width: 80%; height: 160px; margin-top: 12px" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div class="required">下一步的工作打算</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="workPlan">
              <a-textarea placeholder="下一步的工作打算（进一步的的推广应用、申请鉴定、技术转让等）" v-model="formData.workPlan" :maxLength="1000" style="width: 80%; height: 160px; margin-top: 12px" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>延期报告</div>
            </div>
          </a-col>
          <a-col :span="20">
            <a-form-model-item prop="extensionReport">
              <a-textarea placeholder="延期报告（或中止研究报告）" v-model="formData.extensionReport" :maxLength="1000" style="width: 80%; height: 160px; margin-top: 12px" />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24" style="border-top: 0px;">
            <div class="tb-title">
              <span>结题材料</span>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="24" style="border-top: 0px;">
            <div class="special-middle">
              <div><span class="file-description">{{description}}</span></div>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex" class="row_center">
          <a-col :span="4" class="bg-gray">
            <div class="special-middle">
              <div>材料类型</div>
            </div>
          </a-col>
          <a-col :span="18" class="bg-gray">
            <div class="special-middle">
              <div class="required">附件上传</div>
            </div>
          </a-col>
          <a-col :span="2" class="bg-gray">
            <div class="special-middle">
              <div>操作</div>
            </div>
          </a-col>
        </a-row>
        <a-row v-for="(item, index) in formData.fileList" :key="'fileList' + index" type="flex">
          <a-col :span="4">
            <a-form-model-item :prop="'fileList.' + index + '.fileExplain'" :rules="{required: true, message: '材料类型',trigger: 'blur',}">
              <a-input v-if="index>3" v-model="item.fileExplain" :maxLength="100" style="width: 80%" />
              <span v-else> {{item.fileExplain}}</span>
            </a-form-model-item>
          </a-col>
          <a-col :span="18">
            <div class="special-middle">
              <div v-if="item.downloadUrl">
                <a-icon type="paper-clip" style="margin:0 6px" />
                <a class="hover-pointer" style="margin-right:8px " @click="downloadfile(item)">{{item.fileName}}</a>
                <a-popconfirm title="确定要删除吗？" ok-text="确定" cancel-text="取消" @confirm="deletefile(item, index)">
                  <a-icon type="close" class="hover-pointer d-icon" />
                </a-popconfirm>
                <!-- <a-icon type="close" class="hover-pointer d-icon" @click="deletefile(item, index)" /> -->
              </div>
              <div v-else>
                <a-form-model-item :prop="'fileList.' + index + '.downloadUrl'" :rules="{required: true, message: '请上传附件',trigger: 'blur',}">
                  <input type="file" :ref="'fileElem' + index" class="visually-hidden" @change="handleFiles('fileElem',item, index)" />
                  <a-button @click="fileSelect('fileElem',item, index)"><a-icon type="upload" />选择文件</a-button>
                </a-form-model-item>
              </div>
            </div>
          </a-col>
          <a-col :span="2">
            <div class="special-middle">
              <a-popconfirm v-if="index>3" title="确定要删除吗？" ok-text="确定" cancel-text="取消" @confirm="deleteListItem(item,4)">
                <a-button type="link" size="small">删除</a-button>
              </a-popconfirm>
            </div>
          </a-col>
        </a-row>
        <a-row type="flex">
          <a-col :span="24" style="text-align: center">
            <div class="special-middle">
              <a-button type="dashed" style="width: 20%" @click="addListItem(4)">
                <a-icon type="plus" /> 添加 <span style="color:red;margin-left:10px"></span>
              </a-button>
            </div>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24">
            <div class="tb-title">
              <span>审核记录</span>
            </div>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24">
            <audit-list v-model="formData.auditList" />
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </div>
</template>

<script>
const Thesis = { name: null, author: null, publishDate: null, publication: null, application: null, downloadId: null, fileName: null, downloadUrl: null }
const Researchers = { name: null, sex: null, age: null, technicalTitle: null, contributions: null }
const FUNDS = { year: null, name: null, amount: null, use: null, type: 1 }
const File = { fileName: '', downloadUrl: '', fileExplain: '', downloadId: '' }
const Catalog = { name: '', remark: '' }
import { isEmptyParams } from "@/views/utils/common"
import paraRadio from '@/views/components/common/paraRadio'
import axios from 'axios'
import AuditList from '@/views/audit/components/auditInfo'

export default {
  name: "conclusionEdit",
  components: {
    paraRadio, AuditList
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null;
      },
    },
  },
  data () {
    return {
      province: process.env.VUE_APP_SYSTEM_PROVINCE,
      formData: {
        projNo: null,
        projName: null,
        appPersonName: null,
        appUnitName: null,
        telephone: null,
        planCategory: null,
        startDate: null,
        endDate: null,
        promotionContent: null,
        promotionTarget: null,
        selfEvaluation: null,
        achievingResults: null,
        thesisList: [],
        researchersList: [],
        //拔款
        grant: [],
        //其它途径筹资
        finance: [],
        //主要支出项目
        spending: [],
        balance: null,
        researchContent: null,
        workPlan: null,
        extensionReport: null,
        fileList: [],
        catalogList: [],
        auditList: [],
      },
      rules: {
        proj_no: [{ required: true, message: '请填写项目合同编号', trigger: 'blur' },],
        projName: [{ required: true, message: '请填写项目名称', trigger: 'blur' },],
        planCategory: [{ required: true, message: '请填写计划类别', trigger: 'blur' },],
        startDate: [{ required: true, message: '请选择开始日期', trigger: 'change' },],
        endDate: [{ required: true, message: '请选择结束日期', trigger: 'change' },],
        balance: [{ required: true, message: '请填写结余', trigger: 'blur' },],
        promotionContent: [{ required: true, message: '请选择研究或推广内容完成情况', trigger: 'change' },],
        promotionTarget: [{ required: true, message: '请选择研究或推广目标实现情况', trigger: 'change' },],
        selfEvaluation: [{ required: true, message: '请选择研究水平的自我评价', trigger: 'change' },],
        achievingResults: [{ required: true, message: '请选择取得成果情况', trigger: 'change' },],
        researchContent: [{ required: true, message: '请填写研究或推广内容及结果简介', trigger: 'blur' },],
        workPlan: [{ required: true, message: '请填写下一步的工作打算', trigger: 'blur' },],
        extensionReport: [{ required: false, message: '请填写延期报告', trigger: 'blur' },],
      },
      loading: true,
      description: "上传说明：请上传PDF文档，文件大小小于20M"
    };
  },
  created () {
    this.getConclusionByProjId()
  },
  computed: {

  },
  methods: {
    getConclusionByProjId () {
      let pars = { id: this.value }
      if (!!this.value) {
        this.$api.conclusion.getConclusionByProjId(pars).then(({ data = {} }) => {
          if (data) {
            this.formData = data
            this.initializeList(this.formData.grant, 1)
            this.initializeList(this.formData.finance, 2)
            this.initializeList(this.formData.spending, 3)
            if (!data.fileList || !data.fileList.length || data.fileList.length == 0) {
              this.formData.fileList = []
              this.formData.fileList.push(Object.assign({ ...File }, { fileExplain: this.province + '卫生健康委科研项目结题报告书' }))
              this.formData.fileList.push(Object.assign({ ...File }, { fileExplain: '项目研究报告' }))
              this.formData.fileList.push(Object.assign({ ...File }, { fileExplain: '立项文件和合同复印件' }))
              this.formData.fileList.push(Object.assign({ ...File }, { fileExplain: '附件（支撑材料）' }))
            }
            this.loading = false
          } else {
            this.$emit('close', 'error')
          }
        }).catch(() => {
          this.$message.error('500 Internal Server Error！');
          this.$emit('close', 'error')
        })
      }
    },
    fundsCount (list) {
      let total = 0.00
      list.forEach(e => {
        if (e.amount) {
          total = total + e.amount
        }
      })
      return total
    },
    initializeList (list, type) {
      if (!!list && list.length && list.length > 0) {
        let len = list.length
        switch (type) {
          case 1:
            for (let i = len; i < 5; i++) {
              this.formData.grant.push(Object.assign({ ...FUNDS }, { type: 1 }))
            }
            break
          case 2:
            for (let i = len; i < 5; i++) {
              this.formData.finance.push(Object.assign({ ...FUNDS }, { type: 2 }))
            }
            break
          case 3:
            for (let i = 1; i <= 7 - len; i++) {
              this.formData.spending.splice(len - 1, 0, Object.assign({ ...FUNDS }, { type: 3 }));
            }
            break
        }
      } else {
        switch (type) {
          case 1:
            this.formData.grant = []
            for (let i = 1; i <= 5; i++) {
              this.formData.grant.push(Object.assign({ ...FUNDS }, { type: 1 }))
            }
            break
          case 2:
            this.formData.finance = []
            for (let i = 1; i <= 5; i++) {
              this.formData.finance.push(Object.assign({ ...FUNDS }, { type: 2 }))
            }
            break
          case 3:
            this.formData.spending = []
            for (let i = 1; i <= 7; i++) {
              if (i == 7)
                this.formData.spending.push(Object.assign({ ...FUNDS }, { name: '其他各项开支', type: 3 }))
              else
                this.formData.spending.push(Object.assign({ ...FUNDS }, { type: 3 }))
            }
            break
        }
      }
    },
    addListItem (type) {
      switch (type) {
        case 1:
          this.formData.thesisList.push({ ...Thesis })
          break
        case 2:
          this.formData.researchersList.push({ ...Researchers })
          break
        case 3:
          this.formData.catalogList.push({ ...Catalog })
          break
        case 4:
          this.formData.fileList.push({ ...File })
          break
      }
    },
    deleteListItem (obj, type) {
      switch (type) {
        case 1:
          if (this.formData.thesisList.length == 1) {
            this.$message.error('至少填写一篇论文信息！')
          }
          else {
            let i = this.formData.thesisList.indexOf(obj)
            if (i !== -1) {
              this.formData.thesisList.splice(i, 1)
            }
          }
          break
        case 2:
          if (this.formData.researchersList.length == 1) {
            this.$message.error('至少填写一名主要研究人员！');
          }
          else {
            let j = this.formData.researchersList.indexOf(obj)
            if (j !== -1) {
              this.formData.researchersList.splice(j, 1)
            }
          }
          break
        case 3:
          if (this.formData.catalogList.length == 1) {
            this.$message.error('验收材料目录必须填写！');
          }
          else {
            let k = this.formData.catalogList.indexOf(obj)
            if (k !== -1) {
              this.formData.catalogList.splice(k, 1)
            }
          }
          break
        case 4:
          let k = this.formData.fileList.indexOf(obj)
          if (k !== -1) {
            this.formData.fileList.splice(k, 1)
          }
          break
      }
    },
    fileSelect (Fname, item, index) {
      let fileElem = this.$refs[Fname + index][0]
      if (fileElem) {
        fileElem.click()
      }
    },
    handleFiles (Fname, item, index) {
      let fileElem = this.$refs[Fname + index][0]
      let files = fileElem.files
      if (files.length <= 0) {
        this.$message.error('未选中文件，请尝试重新选择')
        return
      }
      //判断是否小于1M
      let isLtSize = files[0].size < 1024 * 1024 * 20;
      if (!isLtSize) {
        this.$message.error('所选文件超过20M，已自动过滤，请检查~');
        return
      }
      var fileNames = files[0].name.split('.')
      var fileType = fileNames[fileNames.length - 1].toLocaleLowerCase()
      var extList = ['pdf'] //'doc', 'docx', 
      if (!extList.find((item) => item == fileType)) {
        this.$message.error('文件格式错误！')
        return
      }
      this.$api.base.asyncUpload(this.uploadHandle(files[0], files[0].name)).then(({ data = {} }) => {

        item.downloadId = data.id
        item.fileName = files[0].name
        item.downloadUrl = data.downloadUrl

      }).catch(() => {
        this.$message.error('上传失败')
      })
    },
    uploadHandle (file, fileName) {
      let formData = new FormData()
      formData.append('file', file)
      formData.append('fileName', fileName)
      return formData
    },
    downloadfile (item) {
      axios({
        url: item.downloadUrl,
        method: 'GET',
        responseType: 'blob' // 告诉axios返回的数据类型为Blob
      }).then(response => {
        const url = window.URL.createObjectURL(new Blob([response.data]))
        const link = document.createElement('a')
        link.href = url
        link.setAttribute('download', item.fileName)  // 下载文件的名称
        document.body.appendChild(link)
        link.click()
      })
    },
    deletefile (item, index) {
      this.$api.base.deletefile({ id: item.downloadId }).then(({ data = {} }) => {
        if (data) {
          item.fileName = ''
          item.downloadUrl = ''
          item.downloadId = ''
        }
      }).catch(() => {
        this.$message.error('删除失败')
      })
    },
    beforeUpload (file, fileList) {
      if (this.fileList.length >= 4) {
        this.$message.error('只允许上传4个文件！');
        return false;
      }
      //判断是否小于1M
      let isLtSize = file.size < 1024 * 1024 * 5;
      if (!isLtSize) {
        //将fileList中本次file文件删掉
        fileList.splice(fileList.indexOf(file), 1);
        this.$message.error('所选文件单个超过5M，已自动过滤，请检查~');
        return false
      } else {
        //判断选择文件个数是否大于10个
        if (fileList.length > 4) {
          //将10个之外的文件去除
          fileList.splice(4);
          this.$message.error('所选文件超过2个，超出部分已自动过滤，请检查~');
          return false;
        }
      }
      var fileNames = file.name.split('.')
      var fileType = fileNames[fileNames.length - 1].toLocaleLowerCase()
      var extList = ['pdf']//'doc', 'docx', 
      if (!extList.find((item) => item == fileType)) {
        this.$message.error('文件格式错误！')
        return false;
      }
      return true
    },
    customRequest (option) {
      this.loading = true
      const { onProgress, onError, onSuccess, file, name } = option
      const formData = new FormData();
      formData.append('file', file)
      formData.append('fileName', file.name)
      this.$api.base.asyncUpload(formData).then(({ data = {} }) => {
        if (data) {
          this.fileList.push({ id: data.id, uid: file.uid, name: file.name, status: 'done', url: data.downloadUrl })
        } else {
          this.$message.error('上传失败请稍后再试！');
        }
        this.loading = false
      }).catch((ex) => {
        this.$message.error('上传失败请稍后再试！');
        this.loading = false
      })
    },
    onRemove (file) {
      this.$confirm({
        title: '确定要删除吗?',
        onOk: () => {
          this.fileList.splice(this.fileList.indexOf(file), 1);
          //   this.$api.base.deletefile({ id: file.id }).then(({ data = {} }) => {
          //     if (data) {
          //       this.fileList.splice(this.fileList.indexOf(file), 1);
          //     }
          //   }).catch(() => {
          //     this.$message.error('删除失败！')
          //   })
        },
      });
    },
    handleChange (info) {

    },
    save () {
      this.loading = true
      let pars = isEmptyParams(this.formData)
      let par = { ...pars }
      this.$api.conclusion.save(par).then(({ data = {} }) => {
        if (data) {
          this.formData.id = data
          this.$message.success('保存成功！')
          this.$emit('close', 'save')
        } this.loading = false
      }).catch(() => {
        this.$message.error('500 Internal Server Error！');
        this.loading = false
      })
    },
    submit () {
      this.$refs.from.validate(valid => {
        if (valid) {
          this.loading = true
          if (this.formData.state != 30)
            this.formData.state = 10
          let pars = isEmptyParams(this.formData)
          let par = { ...pars }
          this.$api.conclusion.save(par).then(({ data = {} }) => {
            if (data) {
              this.formData.id = data
              this.$emit('close', 'edit')
            }
          }).catch(() => { this.loading = false })
        } else {
          this.$message.error('信息未填写完全，请检查！')
          return false
        }
      })
    },
  },
};
</script>
<style scoped lang="less">
.file-description {
  display: block;
  width: 100%;
  line-height: 22px;
  padding: 3px 3px 3px 3px;
  color: red;
  white-space: normal;
  word-wrap: break-word;
  //   text-indent: 1em;
}
.inner_from {
  .ant-row-flex:last-child .ant-col {
    border-bottom: 0;
  }
  .ant-row-flex .ant-col:first-child {
    border-left: 0;
  }
  .ant-row-flex {
    border-right: 0;
  }
}
.special-middle {
  .font_s {
    margin: 0 6px;
  }
}
</style>
