<template>
  <div class="app-container contentBox">
    <el-row>
      <el-col>
        <div class="grid-content bg-purple">
          <el-form
            ref="formInline"
            :model="formInline"
            :rules="rules"
            :inline="true"
            class="width-80"
            :disabled="$route.query.state == 'show'"
          >
            <el-row class="title-box clearable h3Parent width-c54">
              <el-col :span="24">
                <h3 class="titleUseStyle">基本信息</h3>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <div class="grid-content bg-purple">
                  <el-form-item label="项目名称" prop="projectName">
                    <el-input
                      v-model="formInline.projectName"
                      type="textarea"
                      :rows="1"
                      resize="none"
                    ></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="单位名称" prop="unitName">
                    <el-input v-model="formInline.unitName" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="项目性质" prop="projectNature">
                    <el-select v-model="formInline.projectNature" placeholder="请选择" @change="natureVal">
                      <el-option
                        v-for="item in projectNatureList"
                        :key="item.value"
                        :label="item.label"
                        :value="item.label"
                      > 
                      </el-option>
                    </el-select>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="本级部门及代码" prop="departmentsCodes">
                   <el-input v-model="formInline.departmentsCodes" autocomplete="off"></el-input>
                     <!-- <el-select v-model="value" placeholder="请选择" @change="updateFormInlineParam">
                      <el-option
                        v-for="item in options"
                        :key="item.dictCode"
                        :label="item.dictName"
                        :value="item.dictName">
                      </el-option>
                    </el-select> -->
                    
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="实施单位" prop="implementationUnit">
                    <el-input v-model="formInline.implementationUnit" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="项目属性" prop="projectAttributes">
                   <el-input v-model="formInline.projectAttributes" autocomplete="off"></el-input>
                     <!-- <el-select v-model="value_" placeholder="请选择" @change="updateFormInlineParam_" >
                      <el-option
                        v-for="item in options_"
                        :key="item.dictCode"
                        :label="item.dictName"
                        :value="item.dictName">
                      </el-option>
                    </el-select> -->
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="项目日期" prop="projectPeriod">
                    <!-- <el-input v-model="formInline.projectPeriod" autocomplete="off"></el-input> -->
                    <el-date-picker :disabled="periodDis"
                      v-model="formInline.projectPeriod"
                      type="monthrange"
                      range-separator="至"
                      start-placeholder="开始月份"
                      end-placeholder="结束月份">
                    </el-date-picker>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row class="title-box clearable h3Parent width-c54">
              <el-col :span="24">
                <h3 class="titleUseStyle">项目资金(万元)</h3>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="年度资金总额" prop="totalAnnualFunds">
                    <el-input v-model="formInline.totalAnnualFunds" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="其中：财政拨款" prop="financialAllocation">
                    <el-input v-model="formInline.financialAllocation" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="其他资金" prop="otherFunds">
                    <el-input v-model="formInline.otherFunds" autocomplete="off" disabled></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="中期（三年）资金总额" prop="totalMediumTermFunds">
                    <el-input v-model="formInline.totalMediumTermFunds" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="其中：财政拨款" prop="mediumTermFinancialAllocati">
                    <el-input v-model="formInline.mediumTermFinancialAllocati" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="其他资金" prop="mediumTermOtherFunds">
                    <el-input v-model="formInline.mediumTermOtherFunds" autocomplete="off" disabled></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <div class="grid-content bg-purple">
                  <el-form-item label="项目描述" prop="projectContent">
                    <el-input
                      v-model="formInline.projectContent"
                      type="textarea"
                      :rows="2"
                      resize="none"
                    ></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <div v-if="this.$route.query.state=='show'">
              <el-row>
                <el-col :span="24">
                  <div class="grid-content bg-purple">
                    <el-form-item label="政策依据" prop="basisApplication">
                      <el-input
                              v-model="formInline.basisApplication"
                              type="textarea"
                              :rows="3"
                              resize="none"
                      ></el-input>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <div class="grid-content bg-purple">
                    <el-form-item label="项目背景" prop="calculatingProcess">
                      <el-input
                              v-model="formInline.calculatingProcess"
                              type="textarea"
                              :rows="3"
                              resize="none"
                      ></el-input>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>

              <el-row>
                <el-col :span="24">
                  <div class="table-from">
                  <span style="margin-right:10px;">总体目标</span>
                  <el-tooltip class="item" effect="light" content="添加总体期目标" placement="top">
                    <el-button
                      type="primary"
                      size="mini"
                      class="button"
                      icon="el-icon-circle-plus-outline"
                      @click="addTargetContent"
                      style="width:20px !important;height:20px !important;;padding:0 !important;;background-color:#49a2fa;"
                    ></el-button>
                  </el-tooltip>
                  <table border="0" cellpadding="0" rules="all" width="100%" style="margin-top:10px;">
                    <tr v-for="(item, i) in targetContentArr" :key="i">
                      <td style="width: 270px;height:60px">目标{{i+1}}</td>
                      <td style="height: 40px;position:relative">
                        <!-- <span style="font-size:16px" v-if="item.twoClassIndex && !item.isAdd">{{item.twoClassIndex}}</span> -->
                        <span style="font-size:16px" v-if="item.isAdd">
                          <el-input v-model="item.targetContent" resize="none" placeholder="请输入总体目标" maxLength="50"></el-input>
                        </span>
                        <span style="font-size:16px" v-if="!item.isAdd">{{item.targetContent}}</span>
                        <el-tooltip
                          v-if="item.isAdd"
                          class="item"
                          effect="light"
                          content="删除"
                          placement="top"
                        >
                          <!-- v-show="scope.row.findingsAudit=='未提交'" -->
                          <el-button
                            type="primary"
                            size="small"
                            class="button"
                            icon="el-icon-circle-close"
                            @click="deleteTargetContent(i)"
                            style="position:absolute;right:10px;top:20px;width:20px !important;height:20px !important;padding:0 !important;background-color:#49a2fa;"
                          ></el-button>
                        </el-tooltip>
                      </td>
                    </tr>
                  </table>
                  </div>
                </el-col>
              </el-row>

              <!-- <el-row class="title-box clearable h3Parent width-c54">
                <el-col :span="24">
                  <h3 class="titleUseStyle">总体目标</h3>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <div class="grid-content bg-purple">
                    <el-form-item label="年度目标" prop="annualTarget">
                      <el-input
                              v-model="formInline.annualTarget"
                              type="textarea"
                              :rows="3"
                              resize="none"
                      ></el-input>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <div class="grid-content bg-purple">
                    <el-form-item label="中期目标" prop="mediumTermObjectives">
                      <el-input
                              v-model="formInline.mediumTermObjectives"
                              type="textarea"
                              :rows="3"
                              resize="none"
                      ></el-input>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row> -->
            </div>
            <div v-else>
              <el-row>
                <el-col :span="24">
                  <div class="grid-content bg-purple">

                    <el-button type="text" @click="dialogFormVisible_apply = true"><span class="starRed">* </span> 政策依据(请点击填写,必填项)</el-button>

                    <el-dialog title="政策依据" :visible.sync="dialogFormVisible_apply" width="80%">
                      <el-form-item label="政策依据" prop="basisApplication">
                        <el-input
                                v-model="formInline.basisApplication"
                                type="textarea"
                                :rows="20"
                                resize="none"
                        ></el-input>
                      </el-form-item>
                      <div slot="footer" class="dialog-footer">
                        <el-button type="primary" class="iconfont iconqueren" @click="dialogFormVisible_apply = false"> 确定</el-button>
                      </div>
                    </el-dialog>

                    <!-- <el-form-item label="政策依据" prop="basisApplication">
                      <el-input
                        v-model="formInline.basisApplication"
                        type="textarea"
                        :rows="10"
                        resize="none"
                      ></el-input>
                    </el-form-item> -->
                  </div>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <div class="grid-content bg-purple">

                    <el-button type="text" @click="dialogFormVisible_calculator = true"><span class="starRed">* </span> 项目背景(请点击填写,必填项)</el-button>

                    <el-dialog title="项目背景" :visible.sync="dialogFormVisible_calculator" width="80%">
                      <el-form-item label="项目背景" prop="calculatingProcess">
                        <el-input
                                v-model="formInline.calculatingProcess"
                                type="textarea"
                                :rows="20"
                                resize="none"
                        ></el-input>
                      </el-form-item>
                      <div slot="footer" class="dialog-footer">
                        <el-button type="primary" class="iconfont iconqueren" @click="dialogFormVisible_calculator = false"> 确定</el-button>
                      </div>
                    </el-dialog>

                    <!-- <el-form-item label="测算过程" prop="calculatingProcess">
                      <el-input
                        v-model="formInline.calculatingProcess"
                        type="textarea"
                        :rows="10"
                        resize="none"
                      ></el-input>
                    </el-form-item> -->
                  </div>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <div class="table-from">
                  <span style="margin-right:10px;">总体目标</span>
                  <el-tooltip class="item" effect="light" content="添加总体期目标" placement="top">
                    <el-button
                      type="primary"
                      size="mini"
                      class="button"
                      icon="el-icon-circle-plus-outline"
                      @click="addTargetContent"
                      style="width:20px !important;height:20px !important;;padding:0 !important;;background-color:#49a2fa;"
                    ></el-button>
                  </el-tooltip>
                  <table border="0" cellpadding="0" rules="all" width="100%" style="margin-top:10px;">
                    <tr v-for="(item, i) in targetContentArr" :key="i">
                      <td style="width: 270px;height:60px">目标{{i+1}}</td>
                      <td style="height: 40px;position:relative">
                        <!-- <span style="font-size:16px" v-if="item.twoClassIndex && !item.isAdd">{{item.twoClassIndex}}</span> -->
                        <span style="font-size:16px" v-if="item.isAdd">
                          <el-input v-model="item.targetContent" resize="none" placeholder="请输入总体目标" maxLength="50"></el-input>
                        </span>
                        <span style="font-size:16px" v-if="!item.isAdd">{{item.targetContent}}</span>
                        <el-tooltip
                          v-if="item.isAdd"
                          class="item"
                          effect="light"
                          content="删除"
                          placement="top"
                        >
                          <!-- v-show="scope.row.findingsAudit=='未提交'" -->
                          <el-button
                            type="primary"
                            size="small"
                            class="button"
                            icon="el-icon-circle-close"
                            @click="deleteTargetContent(i)"
                            style="position:absolute;right:10px;top:20px;width:20px !important;height:20px !important;padding:0 !important;background-color:#49a2fa;"
                          ></el-button>
                        </el-tooltip>
                      </td>
                    </tr>
                  </table>
                  </div>
                </el-col>
              </el-row>
            </div>

            <el-row>
              <el-col>
                <div class="table-from">
                  <span style="margin-right:10px;">产出指标</span>
                        <el-tooltip class="item" effect="light" content="添加产出二级指标" placement="top">
                          <el-button
                            type="primary"
                            size="mini"
                            class="button"
                            icon="el-icon-circle-plus-outline"
                            @click="addTwoClassIndex"
                            style="width:20px !important;height:20px !important;;padding:0 !important;;background-color:#49a2fa;"
                          ></el-button>
                        </el-tooltip>
                  <table border="0" cellpadding="0" rules="all" width="100%" style="margin-top:10px;">
                    <tr>
                      <td style="width: 270px;height:60px">二级指标(产出指标)</td>
                      <!-- <td>指标内容</td>
                      <td>年度指标值</td>
                      <td>中期指标值</td> -->
                      <td style="width: 220px;height:60px">三级指标(产出指标)</td>
                      <td style="width: 80px;height:60px">绩效指示性质</td>
                      <td style="width: 70px;height:60px">绩效指示值</td>
                      <td style="width: 80px;height:60px">绩效度量单位</td>
                    </tr>
                    <tr v-for="(item, i) in outputIndexArr" :key="i">
                      <td style="height: 40px;position:relative">
                        <span style="font-size:16px" v-if="item.twoClassIndex && !item.isAdd">{{item.twoClassIndex}}</span>
                        <span style="font-size:16px" v-if="item.isAdd">
                          <el-select v-model="item.twoClassIndex" placeholder="请选择" style="width:80%">
                            <el-option
                              v-for="item in towClassOptions"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                          <!-- <el-input v-model="item.twoClassIndex" resize="none" placeholder="请输入产出指标下的二级指标" maxLength="50"></el-input> -->
                        </span>
                        <el-tooltip
                          v-if="item.isAdd"
                          class="item"
                          effect="light"
                          content="删除"
                          placement="top"
                        >
                          <!-- v-show="scope.row.findingsAudit=='未提交'" -->
                          <el-button
                            type="primary"
                            size="small"
                            class="button"
                            icon="el-icon-circle-close"
                            @click="deleteTwoClassIndex(i)"
                            style="position:absolute;right:10px;top:25px;width:20px !important;height:20px !important;padding:0 !important;background-color:#49a2fa;"
                          ></el-button>
                        </el-tooltip>
                      </td>
                      <!-- <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexContent"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.annualIndexValue"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.mediumTermIndexValue"
                        ></el-input>
                      </td> -->
                      <td style="height: 40px;position:relative">
                          <el-input v-model="item.threeClassIndex" resize="none" placeholder="请输入产出指标下的三级指标" maxLength="50"></el-input>
                      </td>
                      <td>
                        <el-select v-model="item.indexProperties" placeholder="请选择">
                          <el-option
                            v-for="item in propertiesList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          > 
                          </el-option>
                        </el-select>
                      </td>

                      <td>
                        <el-input v-if="item.indexProperties == '定量'"
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexValue"
                        ></el-input>
                        <el-select v-model="item.indexValue" v-if="item.indexProperties == '定性'">
                          <el-option
                            v-for="item in valueList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          > 
                          </el-option>
                        </el-select>
                      </td>
                      <td>
                        <el-input v-if="item.indexProperties == '定性'"
                          disabled
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.unitMeasure"
                        ></el-input>
                        <el-input v-if="item.indexProperties != '定性'"
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.unitMeasure"
                        ></el-input>
                      </td>
                      
                    </tr>
                  </table>

                  <span style="margin-right:10px;">效益指标</span>
                        <el-tooltip class="item" effect="light" content="添加效益二级指标" placement="top">
                          <el-button
                            type="primary"
                            size="mini"
                            class="button"
                            icon="el-icon-circle-plus-outline"
                            @click="addBenefitIndex"
                            style="width:20px !important;height:20px !important;;padding:0 !important;;background-color:#49a2fa;"
                          ></el-button>
                        </el-tooltip>
                  <table border="0" cellpadding="0" rules="all" width="100%" style="margin-top:10px;">
                    <tr>
                      <td style="width: 270px;height:60px">二级指标(效益指标)</td>
                      <!-- <td>指标内容</td>
                      <td>年度指标值</td>
                      <td>中期指标值</td> -->
                      <td style="width: 220px;height:60px">三级指标(效益指标)</td>
                      <td style="width: 80px;height:60px">绩效指标性质</td>
                      <td style="width: 70px;height:60px">绩效指标值</td>
                      <td style="width: 80px;height:60px">绩效度量单位</td>
                    </tr>
                    <tr v-for="(item, i) in benefitIndexArr" :key="i">
                      <td style="height: 40px;position:relative">
                        <span style="font-size:16px" v-if="item.twoClassIndex && !item.isAdd">{{item.twoClassIndex}}</span>
                        <span style="font-size:16px" v-if="item.isAdd">
                          <el-select v-model="item.twoClassIndex" placeholder="请选择" style="width:80%">
                            <el-option
                              v-for="item in xyTowClassOptions"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                          <!-- <el-input v-model="item.twoClassIndex" resize="none" placeholder="请输入效益指标下的二级指标" maxLength="50"></el-input> -->
                        </span>
                        <el-tooltip
                          v-if="item.isAdd"
                          class="item"
                          effect="light"
                          content="删除"
                          placement="top"
                        >
                          <!-- v-show="scope.row.findingsAudit=='未提交'" -->
                          <el-button
                            type="primary"
                            size="small"
                            class="button"
                            icon="el-icon-circle-close"
                            @click="deleteBenefitIndex(i)"
                            style="position:absolute;right:10px;top:25px;width:20px !important;height:20px !important;padding:0 !important;background-color:#49a2fa;"
                          ></el-button>
                        </el-tooltip>
                      </td>
                      <!-- <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexContent"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.annualIndexValue"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.mediumTermIndexValue"
                        ></el-input>
                      </td> -->
                      <td style="height: 40px;position:relative">
                          <el-input v-model="item.threeClassIndex" resize="none" placeholder="请输入产出指标下的三级指标" maxLength="50"></el-input>
                      </td>
                      <td>
                        <el-select v-model="item.indexProperties" placeholder="请选择">
                          <el-option
                            v-for="item in propertiesList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          > 
                          </el-option>
                        </el-select>
                      </td>

                      <td>
                        <el-input v-if="item.indexProperties == '定量'"
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexValue"
                        ></el-input>
                        <el-select v-model="item.indexValue" v-if="item.indexProperties == '定性'">
                          <el-option
                            v-for="item in valueList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          > 
                          </el-option>
                        </el-select>
                      </td>
                      
                      <td>
                        <el-input v-if="item.indexProperties != '定性'"
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.unitMeasure"
                        ></el-input>
                        <el-input v-if="item.indexProperties == '定性'"
                          disabled
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.unitMeasure"
                        ></el-input>
                      </td>

                      <!-- <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexProperties"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexValue"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.unitMeasure"
                        ></el-input>
                      </td> -->
                    </tr>
                  </table>

                  <span style="margin-right:10px;">满意度指标</span>
                  <el-tooltip class="item" effect="light" content="添加满意度二级指标" placement="top">
                    <el-button
                            type="primary"
                            size="mini"
                            class="button"
                            icon="el-icon-circle-plus-outline"
                            @click="addsatisfactionIndex"
                            style="width:20px !important;height:20px !important;;padding:0 !important;;background-color:#49a2fa;"
                    ></el-button>
                  </el-tooltip>
                  <table border="0" cellpadding="0" rules="all" width="100%" style="margin-top:10px;">
                    <tr>
                      <td style="width: 270px;height:60px">二级指标(满意度指标)</td>
                      <!-- <td>指标内容</td>
                      <td>年度指标值</td>
                      <td>中期指标值</td> -->
                      <td style="width: 220px;height:60px">三级指标(满意度指标)</td>
                      <td style="width: 80px;height:60px">绩效指标性质</td>
                      <td style="width: 70px;height:60px">绩效指标值</td>
                      <td style="width: 80px;height:60px">绩效度量单位</td>
                    </tr>
                    <tr v-for="(item, i) in satisfactionIndexArr" :key="i">
                      <td style="height: 40px;position:relative">
                        <span style="font-size:16px" v-if="item.twoClassIndex && !item.isAdd">{{item.twoClassIndex}}</span>
                        <span style="font-size:16px" v-if="item.isAdd">
                          <el-select v-model="item.twoClassIndex" placeholder="请选择" style="width:80%">
                            <el-option
                              v-for="item in mydTowClassOptions"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                          <!-- <el-input v-model="item.twoClassIndex" resize="none" placeholder="请输入效益指标下的二级指标" maxLength="50"></el-input> -->
                        </span>
                        <el-tooltip
                          v-if="item.isAdd"
                          class="item"
                          effect="light"
                          content="删除"
                          placement="top"
                        >
                          <!-- v-show="scope.row.findingsAudit=='未提交'" -->
                          <el-button
                            type="primary"
                            size="small"
                            class="button"
                            icon="el-icon-circle-close"
                            @click="deleteBenefitIndex(i)"
                            style="position:absolute;right:10px;top:25px;width:20px !important;height:20px !important;padding:0 !important;background-color:#49a2fa;"
                          ></el-button>
                        </el-tooltip>
                      </td>
                      <!-- <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexContent"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.annualIndexValue"
                        ></el-input>
                      </td>
                      <td>
                        <el-input
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.mediumTermIndexValue"
                        ></el-input>
                      </td> -->
                      <td style="height: 40px;position:relative">
                          <el-input v-model="item.threeClassIndex" resize="none" placeholder="请输入产出指标下的三级指标" maxLength="50"></el-input>
                      </td>
                      <td>
                        <el-select v-model="item.indexProperties" placeholder="请选择">
                          <el-option
                            v-for="item in propertiesList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          > 
                          </el-option>
                        </el-select>
                      </td>

                      <td>
                        <el-input v-if="item.indexProperties == '定量'"
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.indexValue"
                        ></el-input>
                        <el-select v-model="item.indexValue" v-if="item.indexProperties == '定性'">
                          <el-option
                            v-for="item in valueList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          > 
                          </el-option>
                        </el-select>
                      </td>
                      
                      <td>
                        <el-input v-if="item.indexProperties != '定性'"
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.unitMeasure"
                        ></el-input>
                        <el-input v-if="item.indexProperties == '定性'"
                          disabled
                          type="textarea"
                          :rows="2"
                          maxLength="50"
                          resize="none"
                          v-model="item.unitMeasure"
                        ></el-input>
                      </td>
                    </tr>
                  </table>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="申请处室" prop="applicationOffice">
                    <el-input
                      :disabled="true"
                      v-model="formInline.applicationOffice"
                      autocomplete="off"
                    ></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="申请日期">
                    <el-date-picker
                      v-model="formInline.applicationDate"
                      type="date"
                      value-format="yyyy-MM-dd"
                      style="width:100%"
                      :disabled="true"
                    ></el-date-picker>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="8">
                <div class="grid-content bg-purple">
                  <el-form-item label="单位地址" prop="unitAddress">
                    <el-input v-model="formInline.unitAddress" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="8">
                <div class="grid-content bg-purple">
                  <el-form-item label="审核人" prop="head">
                    <el-input v-model="formInline.head" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="8">
                <div class="grid-content bg-purple">
                  <el-form-item label="联系电话" prop="contactNumber">
                    <el-input v-model="formInline.contactNumber" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="8">
                <div class="grid-content bg-purple">
                  <el-form-item label="项目地点" prop="projectLocation">
                    <el-input v-model="formInline.projectLocation" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="8">
                <div class="grid-content bg-purple">
                  <el-form-item label="经办人" prop="unitManager">
                    <el-input v-model="formInline.unitManager" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="8">
                <div class="grid-content bg-purple">
                  <el-form-item label="邮政编码" prop="postCode">
                    <el-input v-model="formInline.postCode" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>




            <el-row v-show="$route.query.state !== 'show'">
              <div class="applyAdd">
                <div class="budgetSubmission-upload">
                  <el-col :span="24">
                    <span style="position: absolute;left: 0px;top: 11px; color:#F56C6C;">*</span>
                    <el-form-item label="附件" label-width="50px" style="padding-left:10px;">
                      <label class="uploadBtn" v-show="$route.query.state !== 'show'">
                        <span>上传</span>
                        <input type="file" @change="onUpload1" />
                      </label>
                      <label class="uploadBtn" v-show="$route.query.state !== 'show' || fileName1">
                        <span>删除</span>
                        <input type="file" @click.prevent="deleteFile" />
                      </label>
                      <a :href="newUrl1" download>
                        <label class="uploadBtn" v-show="$route.query.state == 'show'">
                          <span>下载</span>
                        </label>
                      </a>
                      <div class="fileBox" >
                        <a :href="newUrl1" download v-if="fileName1">
                          <i class="el-icon-document">{{fileName1}}</i>
                        </a>
                      </div>
                      <div v-if="fjshow" class="fj-error">附件为必填</div>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-row>
            <el-row v-if="$route.query.state == 'show' && fileName1">
              <div class="budgetSubmission-upload">
                <el-col :span="24">
                  <el-form-item label="附件" label-width="100px">
                    <a :href="newUrl1" download>
                      <label class="uploadBtn">
                        <span>下载</span>
                      </label>
                    </a>
                    <div class="fileBox">
                      <a :href="newUrl1" download>
                        <i class="el-icon-document">{{fileName1}}</i>
                      </a>
                    </div>
                    <div v-if="fjshow" class="fj-error">附件为必填</div>
                  </el-form-item>
                </el-col>
              </div>
            </el-row>
            <div v-if="this.$route.query.state == 'show' && formInline.processHis">
              <el-row
                      class="title-box clearable h3Parent width-c54"
                      v-if="$route.query.state"
                      v-show="formInline.findingsAudit=='审核通过' || formInline.findingsAudit=='驳回' || $route.query.state == 'update'"
              >
                <el-col :span="24">
                  <h3 class="titleUseStyle">审核内容</h3>
                </el-col>
              </el-row>
              <el-row :gutter="2" style="margin-bottom: 20px;">
                <el-col  :span="23" v-if="formInline.processHis">
                  <el-table
                          :data="formInline.processHis"
                          stripe
                          border highlight-current-row
                          style="width: 100%">
                    <el-table-column align="center" label="序号" width="70">
                      <template slot-scope="scope"><span>{{scope.$index+1}}</span></template>
                    </el-table-column>
                    <el-table-column
                            align="center"
                            prop="assigneeName"
                            width="150"
                            label="审核人">
                    </el-table-column>
                    <el-table-column
                            align="center"
                            :show-overflow-tooltip="true"
                            prop="comment"
                            label="审核意见">
                    </el-table-column>
                    <el-table-column
                            align="center"
                            prop="endDate"
                            width="180"
                            label="审核日期">
                    </el-table-column>
                  </el-table>
                </el-col>
              </el-row>

            </div>
          </el-form>
          <el-row class="saveCancel">
            <el-col :span="24">
              <div class="grid-content bg-purple">
                <el-button
                  type="primary"
                  class="iconfont iconbaocun"
                  v-show="$route.query.state !== 'show'"
                  v-if="$route.query.state"
                  @click="save('formInline')"
                > 保存</el-button>
                <el-button
                  type="primary"
                  class="iconfont iconbaocun"
                  v-show="!$route.query.state"
                  @click="saveNew('formInline')"
                > 保存</el-button>
                <el-button
                  type="primary"
                  class="iconfont icontijiao"
                  style="margin-left: 8px;"
                  v-show="$route.query.state !== 'show'"
                  @click="submissionInfo('formInline')"
                > 提交</el-button>
                <el-button
                  type="primary"
                  class="iconfont iconquxiao"
                  style="margin-left: 8px;"
                  v-show="$route.query.state !== 'show'"
                  @click="cancel"
                > 取消</el-button>
                <el-button
                  type="primary"
                  class="iconfont iconfanhui"
                  style="margin-left: 8px;"
                  v-show="$route.query.state == 'show'"
                  @click="cancel"
                > 返回</el-button>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  budgetSubmissionSave,
  budgetSubmissionSaveNew,
  budgetSubmissionModify,
  budgetSubmissionSubmission,
  uploadFile,
  deleteFiles,
  getdepartmentsCodesDataOrProjectAttribute
} from "@/api/budgetSubmission/index";
// import { saveRegister, uploadFile } from "@/api/credit/index";
import { fileApi, fileDownload } from "@/api/index";

export default {
  name:"budgetsubmissionapplyadd",
  data() {
    var validateTelphone = (rule, value, callback) => {
      const reg = /^1[3|4|5|7|8][0-9]\d{8}$/;
      if (value == '' || value == undefined || value == null) {
        callback(new Error('请填写联系电话'));
      } else {
        if ((!reg.test(value)) && value != '') {
          callback(new Error('请输正确的电话号码'));
        } else {
          callback();
        }
      }
    };
    //是否为邮政编码
    var validatePostcode = (rule, value, callback) => {
      const reg = /^[0-9][0-9]{5}$/;
      if (value == '' || value == undefined || value == null) {
        callback(new Error('请填写邮政编码'));
      } else {
        if ((!reg.test(value)) && value != '') {
          callback(new Error('请输正确的邮政编码'));
        } else {
          callback();
        }
      }
    };
    var totalAnnualFundsPass = (rule, value, callback) => {
      var reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
      if (!reg.test(value)) {
        callback(new Error("请输入正确的数字"));
      } else {
        callback();
      }
    };
    var financialAllocationPass = (rule, value, callback) => {
      var reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
      if (!reg.test(value)) {
        callback(new Error("请输入正确的数字"));
      } else {
        callback();
      }
    };
    var otherFundsPass = (rule, value, callback) => {
      var reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
      if (!reg.test(value)) {
        callback(new Error("请输入正确的数字"));
      } else {
        callback();
      }
    };
    var totalMediumTermFundsPass = (rule, value, callback) => {
      var reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
      if (!reg.test(value)) {
        callback(new Error("请输入正确的数字"));
      } else {
        callback();
      }
    };
    var mediumTermFinancialAllocatiPass = (rule, value, callback) => {
      var reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
      if (!reg.test(value)) {
        callback(new Error("请输入正确的数字"));
      } else {
        callback();
      }
    };
    var mediumTermOtherFundsPass = (rule, value, callback) => {
      var reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
      if (!reg.test(value)) {
        callback(new Error("请输入正确的数字"));
      } else {
        callback();
      }
    };
    return {
      towClassOptions: [
        {
          label:"数量指标",
          value:'数量指标'
        },
        {
          label:"质量指标",
          value:'质量指标'
        },
        {
          label:"时效指标",
          value:'时效指标'
        },
        {
          label:"成本指标",
          value:'成本指标'
        }
      ],
      xyTowClassOptions: [
        {
          label:"经济效益指标",
          value:'经济效益指标'
        },
        {
          label:"社会效益指标",
          value:'社会效益指标'
        },
        {
          label:"生态效益指标",
          value:'生态效益指标'
        },
        {
          label:"可持续影响指标",
          value:'可持续影响指标'
        }
      ],
      mydTowClassOptions: [
        {
          label:"服务对象满意度指标",
          value:'服务对象满意度指标'
        }
      ],
      dialogFormVisible_apply: false,
      dialogFormVisible_calculator:false,
      dialogFormVisible_annual:false,
      dialogFormVisible_mediumTerm: false,

      projectNatureList:[
        {
          label:"一次性项目",
          value:'1'
        },
        {
          label:"经常性项目",
          value:'2'
        }
      ],
      periodDis: false,
      propertiesList:[
        {
          label:"定量",
          value:'定量'
        },
        {
          label:"定性",
          value:'定性'
        }
      ],
      valueList:[
        {
          label:"高",
          value:'高'
        },
        {
          label:"中",
          value:'中'
        },
        {
          label:"低",
          value:'低'
        }
      ],

      //总体目标
      targetContentArr: [
        {
          targetContent:"",
          isAdd:true
        },
          {
          targetContent:"",
           isAdd:true
        }
      ],

      // 产出指标二级指标数据
      outputIndexArr:[],

      // 效益指标二级指标数据
      benefitIndexArr:[],

      // 满意度指标二级指标数据
      satisfactionIndexArr:[],

      // 实施单位数据初始化
      initImplementationUnit:JSON.parse(window.localStorage.getItem("userInfo")).deptName,
      
      // 等待本级部门及代码接口数据
      options: [],
        value: "",
        value_: "",
      // 等待项目属性接口数据
      options_: [],

      rules: {
        // mediumTermObjectives: [
        //   { required: true, message: "请填写中期目标", trigger: "blur" },
        //   { min: 1, max: 1000, message: '长度在 1 到 1000 个字符', trigger: 'blur' }
        // ],
        calculatingProcess: [
          { required: true, message: "请填写项目背景", trigger: "blur" },
          { min: 1, max: 1000, message: '长度在 1 到 1000 个字符', trigger: 'blur' }
        ],
        basisApplication: [
          { required: true, message: "请填写政策依据", trigger: "blur" },
          { min: 1, max: 1000, message: '长度在 1 到 1000 个字符', trigger: 'blur' }
        ],
        projectContent: [
          { required: true, message: "请填写项目描述", trigger: "blur" },
          { min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' }
        ],
        departmentsCodes: [
          { required: true, message: "请填写本级部门及代码", trigger: "blur" }
        ],
        // applicationOffice: [
        //   { required: true, message: "请填写申请处室", trigger: "blur" }
        // ],
        projectName: [
          { required: true, message: "请填写项目名称", trigger: "blur" },
          { min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
        ],
        unitName: [
          { required: true, message: "请填写单位名称", trigger: "blur" }
        ],
        projectNature: [
          { required: true, message: "请填写项目性质", trigger: "change" }
        ],
        implementationUnit: [
          { required: true, message: "请填写实施单位", trigger: "blur" },
          { min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
        ],
        projectAttributes: [
          { required: true, message: "请填写项目属性", trigger: "blur" }
        ],
        projectPeriod: [
          { required: true, message: "请填写项目日期", trigger: "blur" }
        ],
        // annualTarget: [
        //   { required: true, message: "请填写年度目标", trigger: "blur" },
        //   { min: 1, max: 1000, message: '长度在 1 到 1000 个字符', trigger: 'blur' }
        // ],
        totalAnnualFunds: [
          { required: true, validator: totalAnnualFundsPass, trigger: "blur" }
        ],
        financialAllocation: [
          {
            required: true,
            validator: financialAllocationPass,
            trigger: "blur"
          }
        ],
        // otherFunds: [
        //   { required: true, validator: otherFundsPass, trigger: "blur" }
        // ],
        totalMediumTermFunds: [
          {
            required: true,
            validator: totalMediumTermFundsPass,
            trigger: "blur"
          }
        ],
        mediumTermFinancialAllocati: [
          {
            required: true,
            validator: mediumTermFinancialAllocatiPass,
            trigger: "blur"
          }
        ],

        unitAddress: [
          { required: true, message: "请填写单位地址", trigger: "blur" }
        ],
         head: [
          { required: true, message: "请填写负责人", trigger: "blur" }
        ],
        contactNumber: [
          { required: true, validator: validateTelphone, trigger: "blur" }
        ],
        projectLocation: [
          { required: true, message: "请填写单位地点", trigger: "blur" }
        ],
        unitManager: [
          { required: true, message: "请填写单位经办人", trigger: "blur" }
        ],
        postCode: [
          { required: true, validator: validatePostcode, trigger: "blur" }  
        ],
        // uploadVerify: [
        //   { required: true, message: "请上传附件", trigger: "blur" }
        // ],




        // mediumTermOtherFunds: [
        //   {
        //     required: true,
        //     validator: mediumTermOtherFundsPass,
        //     trigger: "blur"
        //   }
        // ]
      },
      // totalAnnualFunds: "", //年度资金总额-,
      // financialAllocation: "", //年度 财政拨款-
      // otherFunds: "", //年度 其他资金-
      // totalMediumTermFunds: "", //中期资金总额-
      // mediumTermFinancialAllocati: "", //中期 财政拨款-
      // mediumTermOtherFunds: "", //中期 其他资金-
      formInline: {
        projectName: "", //项目名称-
        departmentsCodes: "", //本级部门及代码-
        implementationUnit: JSON.parse(window.localStorage.getItem("userInfo")).deptName, //实施单位-
        projectAttributes: "", //项目属性-
        projectPeriod: "", //项目期-
        totalAnnualFunds: "", //年度资金总额-
        financialAllocation: "", //年度 财政拨款-
        otherFunds: "", //年度 其他资金-
        totalMediumTermFunds: "", //中期资金总额-
        mediumTermFinancialAllocati: "", //中期 财政拨款-
        mediumTermOtherFunds: "", //中期 其他资金-
        projectContent: "", //项目描述-
        basisApplication: "", //政策依据-
        calculatingProcess: "", //项目背景-
        // annualTarget: "", //年度目标-
        // mediumTermObjectives: "", //中期目标-
        applicationOffice: "", //申请处室-
        applicationDate: "", //申请日期-
        auditOpinions: "", //审核意见-
        findingsAudit: "", //审核结果-
        auditor: "", //审核人-
        auditDate: "", //审核日期-

        // -----------------新增字段----------------------

        

        //单位名称
        unitName: "",
        //项目性质
        projectNature: "",
        //单位地址
        unitAddress: "",
        //负责人
        head: "",
        //联系电话
        contactNumber: "",
        //项目地点
        projectLocation: "",
        //单位经办人
        unitManager: "",
        //邮政编码
        postCode: "",

        //总体目标
        overallObjective: [],
        
        // 产出指标用户添加的二级指标数据
        outputIndex:[],

        // 效益指标用户添加的二级指标数据
        benefitIndex:[],

        // 满意度指标二级指标数据
        satisfactionIndex:[],

        // -----------------新增字段----------------------

        // quantityIndicatorContent: "", //数量指标-指标内容
        // quantityAnnualIndicator: "", //数量指标-年度指标值
        // quantityMediumTerm: "", //数量指标-中期指标值
        // qualityIndicatorContent: "", //质量指标-指标内容
        // qualityAnnualIndicator: "", //质量指标-年度指标值
        // qualityMediumTerm: "", //质量指标-中期指标值
        // prescriptionIndicatorContent: "", //时效指标-指标内容
        // prescriptionAnnualIndicator: "", //时效指标-年度指标值
        // prescriptionMediumTerm: "", //时效指标-中期指标值
        // costIndicatorContent: "", //成本指标-指标内容
        // costAnnualIndicator: "", //成本指标-年度指标值
        // costMediumTerm: "", //成本指标-中期指标值
        // economicsIndicatorContent: "", //经济效益指标-指标内容
        // economicsAnnualIndicator: "", //经济效益指标-年度指标值
        // economicsMediumTerm: "", //经济效益指标-中期指标值
        // sociologyIndicatorContent: "", //社会效益指标-指标内容
        // sociologyAnnualIndicator: "", //社会效益指标-年度指标值
        // sociologyMediumTerm: "", //社会效益指标-中期指标值
        // environmentalIndicatorConten: "", //环境效益指标-指标内容
        // environmentalAnnualIndicator: "", //环境效益指标-年度指标值
        // environmentalMediumTerm: "", //环境效益指标-中期指标值
        // sustainabiliIndicatorContent: "", //可持续性指标-指标内容
        // sustainabilitAnnualIndicator: "", //可持续性指标-年度指标值
        // sustainabilityMediumTerm: "", //可持续性指标-中期指标值
        serviceIndicatorContent: "", //服务对象满意度指标-指标内容
        serviceAnnualIndicator: "", //服务对象满意度指标-年度指标
        serviceMediumTerm: "", //服务对象满意度指标-中期指标值

        attachId: "", //附件id
        attachName: ""
      },
      newUrl1: "",
      fileName1: "",
      flag: true,
      flag_: true,
      fjshow: false
    };
  },

  watch: {

    // 监听年度资金总额变化
    "formInline.totalAnnualFunds" (newValue) {

      if(Number(newValue) > 2147483647){
        this.$message.info("最大可输入数字为：2147483647")
        this.formInline.totalAnnualFunds = 2147483647
      }
      if(this.formInline.financialAllocation===""){
        this.formInline.otherFunds = ""
        // console.log(11111)
      }else if (newValue==="") {
        this.flag = false
        this.formInline.financialAllocation=""
        this.formInline.otherFunds = ""
      }else if (newValue == 0) {
        this.formInline.financialAllocation=""
        this.formInline.otherFunds = ""
      }

      if(Number(newValue)<=Number(this.formInline.financialAllocation)){
        this.formInline.financialAllocation = newValue
        this.formInline.otherFunds = 0
        if(!this.flag){
          this.formInline.otherFunds = ""
        }
        this.flag = true
      }else if (newValue === "") {
        // console.log(2222)
        // console.log(newValue)
        this.formInline.otherFunds = ""
      }else if (Number(newValue) > Number(this.formInline.financialAllocation)) {
        // console.log(111111)
        if(this.formInline.financialAllocation !== ''){
          this.formInline.otherFunds = newValue - this.formInline.financialAllocation
        }
      }

      // this.formInline.otherFunds = newValue - this.formInline.financialAllocation

    },

    // 监听年度财政拨款金额变化
    "formInline.financialAllocation" (newValue) {
      if(Number(newValue) > 2147483647){
        this.$message.info("最大可输入数字为：2147483647")
        this.formInline.financialAllocation = 2147483647
      }
      // console.log(newValue)
      if(Number(newValue)>=Number(this.formInline.totalAnnualFunds)){
        this.formInline.totalAnnualFunds = newValue
        this.formInline.otherFunds = 0
        if(!this.flag){
          this.formInline.otherFunds = ""
        }
        this.flag = true
      }else if (newValue === "") {
        // console.log(2222)
        // console.log(newValue)
        this.formInline.otherFunds = ""
      }else if (Number(newValue) < Number(this.formInline.totalAnnualFunds)) {
        // console.log(111111)
        this.formInline.otherFunds = this.formInline.totalAnnualFunds - newValue
      }
    },

    // // 监听其他资金金额变化   先留着此注释掉的代码  防止往后更改需求时要用到此代码段
    // "formInline.otherFunds" (newValue) {
      
    //   if(newValue===""){
    //     // this.formInline.financialAllocation = this.formInline.totalAnnualFunds - newValue
    //     console.log("触发了这里")
    //     if(this.formInline.financialAllocation !== ""){
    //       this.formInline.financialAllocation = ""
    //       return
    //     }
    //     return
    //   }

    //   if(Number(newValue)>=Number(this.formInline.totalAnnualFunds)){
    //     this.formInline.totalAnnualFunds = Number(newValue) + Number(this.formInline.financialAllocation)
    //     // this.formInline.financialAllocation = ""
    //     // if(!this.flag){
    //     //   this.formInline.otherFunds = ""
    //     // }
    //     // this.flag = true
    //   }else if (Number(newValue) < Number(this.formInline.totalAnnualFunds)) {
    //     this.formInline.financialAllocation = this.formInline.totalAnnualFunds - newValue
    //   }

    // }


    // 监听中期资金总额变化
    "formInline.totalMediumTermFunds" (newValue) {
      if(Number(newValue) > 2147483647){
        this.$message.info("最大可输入数字为：2147483647")
        this.formInline.totalMediumTermFunds = 2147483647
      }
      // console.log(newValue)
      if(this.formInline.mediumTermFinancialAllocati===""){
        // console.log("nihaohiahiashd")
        this.formInline.mediumTermOtherFunds = ""
        // console.log(11111)
      }else if (newValue==="") {
        this.flag_ = false
        this.formInline.mediumTermFinancialAllocati=""
        this.formInline.mediumTermOtherFunds = ""
      }else if (newValue == 0) {
        this.formInline.mediumTermFinancialAllocati=""
        this.formInline.mediumTermOtherFunds = ""
      }

      if(Number(newValue)<=Number(this.formInline.mediumTermFinancialAllocati)){
        this.formInline.mediumTermFinancialAllocati = newValue
        this.formInline.mediumTermOtherFunds = 0
        if(!this.flag){
          this.formInline.mediumTermOtherFunds = ""
        }
        this.flag = true
      }else if (newValue === "") {
        // console.log(2222)
        // console.log(newValue)
        this.formInline.mediumTermOtherFunds = ""
      }else if (Number(newValue) > Number(this.formInline.mediumTermFinancialAllocati)) {
        // console.log(111111)
        if(this.formInline.mediumTermFinancialAllocati !== ''){
          this.formInline.mediumTermOtherFunds = newValue - this.formInline.mediumTermFinancialAllocati
        }
      }

      // this.formInline.mediumTermOtherFunds = newValue - this.formInline.mediumTermFinancialAllocati

    },

    // 监听中期财政拨款金额变化
    "formInline.mediumTermFinancialAllocati" (newValue) {
      if(Number(newValue) > 2147483647){
        this.$message.info("最大可输入数字为：2147483647")
        this.formInline.mediumTermFinancialAllocati = 2147483647
      }
      // console.log(newValue)
      if(Number(newValue)>=Number(this.formInline.totalMediumTermFunds)){
        this.formInline.totalMediumTermFunds = newValue
        this.formInline.mediumTermOtherFunds = 0
        if(!this.flag_){
          this.formInline.mediumTermOtherFunds = ""
        }
        this.flag_ = true
      }else if (newValue === "") {
        // console.log(2222)
        // console.log(newValue)
        this.formInline.mediumTermOtherFunds = ""
      }else if (Number(newValue) < Number(this.formInline.totalMediumTermFunds)) {
        // console.log(111111)
        this.formInline.mediumTermOtherFunds = this.formInline.totalMediumTermFunds - newValue
      }
    },
    
  },

  created() {

    // 调用本级部门及代码数据
    getdepartmentsCodesDataOrProjectAttribute("departmentCode").then((response)=>{
      this.options = response.data
    })

    // 调用项目属性数据
    getdepartmentsCodesDataOrProjectAttribute("XMSX").then((response)=>{
      this.options_ = response.data
    })

    if (this.$route.query.state) {
      this.info(this.$route.query.id);
    } else {
      var date = new Date();
      this.formInline.applicationDate = date;
      let tokenMsg = window.sessionStorage.getItem('TOKENL')
      let msg1 = tokenMsg.split('.')[1]
      let base64 = require('js-base64').Base64;
      let userInfo = JSON.parse(base64.decode(msg1));
      // console.log(userInfo);
      this.formInline.applicationOffice = userInfo.deptName
      // this.formInline.applicationOffice = JSON.parse(localStorage.getItem('userInfo')).deptName
    }
  },
  methods: {
    natureVal(item){
      if(item === '一次性项目'){
        this.formInline.projectPeriod = ["2019-12-31T16:00:00.000Z","2020-11-30T16:00:00.000Z"]
        this.periodDis = true;
      }else{
        this.periodDis = false;
      }
    },
    //点击添加总体目标
    addTargetContent(){
      if(!this.targetContentArr){
        this.targetContentArr = []
      }
      let obj = { isAdd: true };
      this.targetContentArr.push(obj);
    },
    //点击删除总体目标
    deleteTargetContent(i) {
      //   console.log(i);
      // console.log(this.bankArr);
      this.targetContentArr.splice(i, 1);
      // console.log(this.bankArr);
    },

    // 点击添加产出指标二级指标数据
    addTwoClassIndex() {
      if(!this.outputIndexArr){
        this.outputIndexArr = []
      }
      let obj = { isAdd: true };
      this.outputIndexArr.push(obj);
      this.formInline.outputIndex = this.outputIndexArr
    },

    // 点击删除产出指标二级指标数据
    deleteTwoClassIndex(i) {
      //   console.log(i);
      // console.log(this.bankArr);
      this.outputIndexArr.splice(i, 1);
      this.formInline.outputIndex = this.outputIndexArr
      // console.log(this.bankArr);
    },

    // 点击添加效益指标二级指标数据
    addBenefitIndex() {
      if(!this.benefitIndexArr){
        this.benefitIndexArr = []
      }
      let obj = { isAdd: true };
      this.benefitIndexArr.push(obj);
      this.formInline.benefitIndex = this.benefitIndexArr
    },

    // 点击删除效益指标二级指标数据
    deleteBenefitIndex(i) {
      //   console.log(i);
      // console.log(this.bankArr);
      this.benefitIndexArr.splice(i, 1);
      this.formInline.benefitIndex = this.benefitIndexArr
      // console.log(this.bankArr);
    },

    // 点击添加满意度指标二级指标数据
    addsatisfactionIndex() {
      if(!this.satisfactionIndexArr){
        this.satisfactionIndexArr = []
      }
      let obj = { isAdd: true };
      this.satisfactionIndexArr.push(obj);
      this.formInline.satisfactionIndex = this.satisfactionIndexArr
    },

    // 点击删除满意度指标二级指标数据
    deletesatisfactionIndex(i) {
      //   console.log(i);
      // console.log(this.bankArr);
      this.satisfactionIndexArr.splice(i, 1);
      this.formInline.satisfactionIndex = this.satisfactionIndexArr
      // console.log(this.bankArr);
    },

    updateFormInlineParam (value) {
      console.log(value)
      this.formInline.departmentsCodes = value
    },
    
    updateFormInlineParam_ (value) {
      console.log(value)
      this.formInline.projectAttributes = value
    },

    //删除附件
    deleteFile() {
      if (this.formInline.attachId) {
        if (this.$route.query.state) {
          deleteFiles(this.$route.query.id).then(res => {
            if (res.infoCode == 200) {
              this.formInline.attachId = "";
              this.formInline.attachName = "";
              this.fileName1 = "";
              this.$message.success("附件删除成功")
            } else {
              this.$message({
                type: "error",
                message: res.msg
              });
            }
          });
        } else {
          this.formInline.attachId = "";
          this.formInline.attachName = "";
          this.fileName1 = "";
          this.$message.success("附件删除成功")
        }
      } else {
        this.open();
      }
    },
    open() {
      // this.$notify({
      //   title: "请先上传附件",
      //   message: "提示",
      //   type: "info",
      //   duration: 2000,
      //   position: "bottom-right"
      // });
      this.$message.info("请先上传附件")
    },
    onUpload1(e) {
      uploadFile(e).then(res => {
        this.fileName1 = res.data.name;
        this.newUrl1 = fileDownload+ "?id=" + res.data.id;
        // this.newUrl1 = fileDownload + "?id=" + res.data.id;
        e.target.value = "";
        if (res.infoCode == 200) {
          this.formInline.attachId = res.data.id;
          this.formInline.attachName = res.data.name;
          this.$message.success("附件上传成功")
        }
      });
    },
    cancel() {
      if(this.$route.query.pageName === 'examine'){
        this.$router.push({ path: "examine" });
      }else{
        this.$router.push({ path: "apply", query: {page:this.$route.query.page}});
      }
    },
    save(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if(!this.formInline.basisApplication){
            this.$message.info("请填写政策依据")
            return
          }
          if(!this.formInline.calculatingProcess){
            this.$message.info("请填写项目背景")
            return
          }
          // if(!this.formInline.annualTarget){
          //   this.$message.info("请填写年度目标")
          //   return
          // }
          // if(!this.formInline.mediumTermObjectives){
          //   this.$message.info("请填写中期目标")
          //   return
          // }
          this.formInline.applicationDate = "";

          // if(!this.targetContentArr || this.targetContentArr.length == 0){
          //   this.formInline.overallObjective = [{
          //     targetContent: ""
          //   }]
          // }else{
          //   this.formInline.overallObjective.forEach((item,index)=>{
          //     if(Object.keys(item).length == 1 &&  this.formInline.overallObjective.length !==1){
          //       this.formInline.overallObjective.splice(index,1)
          //     }
          //   })
          // }

          if(!this.benefitIndexArr || this.benefitIndexArr.length == 0){
            this.formInline.benefitIndex = [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
              threeClassIndex: "",
              indexProperties: "",
              indexValue: "",
              unitMeasure: "",
            }]
          }else{
            this.formInline.benefitIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 &&  this.formInline.benefitIndex.length !==1){
                this.formInline.benefitIndex.splice(index,1)
              }
            })
          }
          if(!this.outputIndexArr || this.outputIndexArr.length == 0){
            this.formInline.outputIndex =  [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
              threeClassIndex: "",
              indexProperties: "",
              indexValue: "",
              unitMeasure: "",
            }]
          }else{
            this.formInline.outputIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 && this.formInline.outputIndex.length !==1){
                this.formInline.outputIndex.splice(index,1)
              }
            })
          }

          if(!this.satisfactionIndexArr || this.satisfactionIndexArr.length == 0){
            this.formInline.satisfactionIndex =  [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
              threeClassIndex: "",
              indexProperties: "",
              indexValue: "",
              unitMeasure: "",
            }]
          }else{
            this.formInline.satisfactionIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 && this.formInline.satisfactionIndex.length !== 1){
                this.formInline.satisfactionIndex.splice(index,1)
              }
            })
          }
          this.formInline.overallObjective = this.targetContentArr
          this.formInline.type = 0
          if(!this.formInline.attachId){
            this.fjshow = true;
          }else{
            this.fjshow = false;
              budgetSubmissionSaveNew(this.formInline).then(response => {
              if (response.infoCode === 200) {
                this.$message.success("编辑成功");
                this.$router.push({ path: "apply" });
              } else {
                this.$message({
                  type: "error",
                  message: response.msg
                });
              }
            });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    saveNew(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if(!this.formInline.basisApplication){
            this.$message.info("请填写政策依据")
            return
          }
          if(!this.formInline.calculatingProcess){
            this.$message.info("请填写项目背景")
            return
          }
          // if(!this.formInline.annualTarget){
          //   this.$message.info("请填写年度目标")
          //   return
          // }
          // if(!this.formInline.mediumTermObjectives){
          //   this.$message.info("请填写中期目标")
          //   return
          // }
          if(!this.benefitIndexArr || this.benefitIndexArr.length == 0){
            this.formInline.benefitIndex = [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
            }]
          }else{
            this.formInline.benefitIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 &&  this.formInline.benefitIndex.length !==1){
                this.formInline.benefitIndex.splice(index,1)
              }
            })
          }
          if(!this.outputIndexArr || this.outputIndexArr.length == 0){
            this.formInline.outputIndex =  [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
            }]
          }else{
            this.formInline.outputIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 && this.formInline.outputIndex.length !==1){
                this.formInline.outputIndex.splice(index,1)
              }
            })
          }

          if(!this.satisfactionIndexArr || this.satisfactionIndexArr.length == 0){
            this.formInline.satisfactionIndex =  [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
            }]
          }else{
            this.formInline.satisfactionIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 && this.formInline.satisfactionIndex.length !== 1){
                this.formInline.satisfactionIndex.splice(index,1)
              }
            })
          }
          this.formInline.overallObjective = this.targetContentArr
          this.formInline.applicationDate = "";
          this.formInline.type = 0
          if(!this.formInline.attachId){
            this.fjshow = true;
          }else{
            this.fjshow = false;
          budgetSubmissionSaveNew(this.formInline).then(response => {
            if (response.infoCode === 200) {
              this.$message.success("保存成功");
              this.$router.push({ path: "apply" });
            } else {
              this.$message({
                type: "error",
                message: response.msg
              });
            }
          });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    info(id) {
      budgetSubmissionModify(id).then(response => {
        if (response.infoCode === 200) {
          this.formInline = response.data;
          if(this.formInline.departmentsCodes){
            this.value = this.formInline.departmentsCodes
          }
          if(this.formInline.projectAttributes){
            this.value_ = this.formInline.projectAttributes
          }

          this.fileName1 = this.formInline.attachName;
          this.outputIndexArr = this.formInline.outputIndex;
          this.benefitIndexArr = this.formInline.benefitIndex;
          this.satisfactionIndexArr = this.formInline.satisfactionIndex;

          //总体目标
          this.targetContentArr = this.formInline.overallObjective;

          // this.newUrl1 =
          //   fileApi +
          //   "/" +
          //   "file" +
          //   "/" +
          //   "download" +
          //   "?id=" +
          //   this.formInline.attachId;
          this.newUrl1 = fileDownload + "?id=" + this.formInline.attachId;
          // this.formInline.applicationOffice = window.sessionStorage.getItem(
          //   "deptName"
          // );
          if (this.$route.query.state == "update") {
            this.formInline.applicationDate = new Date();
          }

          //总体目标
          // if(this.formInline.overallObjective.length == 1){
          //   if(this.formInline.overallObjective[0].targetContent== ""){
          //     this.formInline.overallObjective = []
          //     this.targetContentArr = []
          //   }
          // }

          if(this.formInline.outputIndex.length == 1){
            if(this.formInline.outputIndex[0].annualIndexValue== ""&&
                    this.formInline.outputIndex[0].indexContent== ""&&
                    this.formInline.outputIndex[0].mediumTermIndexValue== ""&&
                    this.formInline.outputIndex[0].twoClassIndex== ""){
              this.formInline.outputIndex = []
              this.outputIndexArr = []
            }
          }
          if(this.formInline.satisfactionIndex.length == 1){
            if(this.formInline.satisfactionIndex[0].annualIndexValue== ""&&
                    this.formInline.satisfactionIndex[0].indexContent== ""&&
                    this.formInline.satisfactionIndex[0].mediumTermIndexValue== ""&&
                    this.formInline.satisfactionIndex[0].twoClassIndex== ""){
              this.formInline.satisfactionIndex = []
              this.satisfactionIndexArr = []
            }
          }
          if(this.formInline.benefitIndex.length == 1){
            if(this.formInline.benefitIndex[0].annualIndexValue== ""&&
                    this.formInline.benefitIndex[0].indexContent== ""&&
                    this.formInline.benefitIndex[0].mediumTermIndexValue== ""&&
                    this.formInline.benefitIndex[0].twoClassIndex== ""){
              this.formInline.benefitIndex = []
              this.benefitIndexArr = []
            }

          }
        } else {
          this.$message({
            type: "error",
            message: response.msg
          });
        }
      });
    },
    submissionInfo(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if(!this.formInline.basisApplication){
            this.$message.info("请填写政策依据")
            return
          }
          if(!this.formInline.calculatingProcess){
            this.$message.info("请填写项目背景")
            return
          }
          // if(!this.formInline.annualTarget){
          //   this.$message.info("请填写年度目标")
          //   return
          // }
          // if(!this.formInline.mediumTermObjectives){
          //   this.$message.info("请填写中期目标")
          //   return
          // }
          if(!this.benefitIndexArr || this.benefitIndexArr.length == 0){
            this.formInline.benefitIndex = [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
            }]
          }else{
            this.formInline.benefitIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 &&  this.formInline.benefitIndex.length !==1){
                this.formInline.benefitIndex.splice(index,1)
              }
            })
          }
          if(!this.outputIndexArr || this.outputIndexArr.length == 0){
            this.formInline.outputIndex =  [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
            }]
          }else{
            this.formInline.outputIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 && this.formInline.outputIndex.length !==1){
                this.formInline.outputIndex.splice(index,1)
              }
            })
          }

          if(!this.satisfactionIndexArr || this.satisfactionIndexArr.length == 0){
            this.formInline.satisfactionIndex =  [{
              annualIndexValue: "",
              indexContent: "",
              mediumTermIndexValue: "",
              twoClassIndex: "",
            }]
          }else{
            this.formInline.satisfactionIndex.forEach((item,index)=>{
              if(Object.keys(item).length == 1 && this.formInline.satisfactionIndex.length !== 1){
                this.formInline.satisfactionIndex.splice(index,1)
              }
            })
          }
          this.formInline.type = 1
          this.formInline.status = 1
          this.formInline.findingsAudit = this.formInline.departmentsCodes === '内蒙古自治区粮食和物资储备局601001' ? "处室处长审核" : "待二级单位财务审核"
          if(!this.formInline.attachId){
            this.fjshow = true;
          }else{
            this.fjshow = false;
            budgetSubmissionSaveNew(this.formInline).then(response => {
              if (response.infoCode == 200) {
                this.$message.success("提交成功")
                this.$router.push({ path: "apply" });
              } else {
                this.$message({
                  type: "error",
                  message: response.msg
                });
              }
            });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    }
  }
};
</script>
<style>
@import "common.css";
.el-message--error {
  display: none !important;
}
.font-color {
  height: 34px;
  font-size: 18px;
  font-weight: 600;
}
.width-c54 {
  width: calc(100% - 50px);
  margin-bottom: 20px;
}
.table-from table {
  width: calc(100% - 50px);
  border: 1px solid #dcdfe6;
  text-align: center;
  margin-bottom: 20px;
}
.table-from table .el-textarea__inner {
  border: 0px solid #dcdfe6;
}
.budgetSubmission-upload .uploadBtn {
  margin-left: 20px;
  display: inline-block;
  line-height: normal;
  padding: 10px 10px;
  font-size: 14px;
  color: #ffffff;
  background: #49a2fa;
  border-color: #49a2fa;
  border-radius: 5px;
  cursor: pointer;
}

.budgetSubmission-upload .uploadBtn input[type="file"] {
  display: none;
}
.applyAdd .budgetSubmission-upload .fileBox {
  position: absolute;
  left: 158px;
  top: 0px;
  width: calc(100% - 156px);
  font-size: 16px;
  height: 30px;
  line-height: normal;
  background-color: #dcdfe6;
  color: #409eff;
  padding: 5px 10px;
  margin-top: 0px;
}

.budgetSubmission-upload .fileBox > i {
  float: right;
  font-size: 20px;
  margin: 0px 5px;
  color: #000000;
  cursor: pointer;
}

.budgetSubmission-upload .fileBox i:hover {
  color: #409eff;
}
</style>
<style lang="scss">

/* .el-input__inner {
  padding-left: 45%;
} */

.h3Parent {
  .el-col {
    position: relative;
  }
}
.title-box {
    //新增等标题外的el-row用样式（如调控管理>涉粮企业管理系统>企业基础信息管理>新增）
    .el-col {
        height: 38px;
    }
}
.titleUseStyle {
    position: absolute;
    top: 0px;
    font-size: 14px;
    width: 100%;
    height: 30px;
    line-height: 30px;
    color: #fff;
    font-weight: 400;
    background: #49a2fa;
  padding: 5px 0 5px 8px ;
    &::before {
        position: relative;
        top: 2px;
        content: '';
        display: inline-block;
        margin-right: 10px;
        width: 2px;
        height: 14px;
        background-color: #fff;
    }
}
  .starRed{
    display: inline-block;
    padding-bottom: 10px;
    color: #f56c6c;
  }
  .fj-error{ font-size: 12px; color: #F56C6C;}
</style>



