<template>
  <div class="container-accountability managementEditPage">
    <!-- <h3 class="tit">编辑评分表</h3> -->
    <el-form ref="form" :model="form" :inline="true" :rules="rulesForm" label-width="110px">
      <el-form-item label="评分表名称:" prop="pfbmc">
        <el-input v-model="form.pfbmc" style="width: 350px !important" type="text" clearable class="inputCompatible"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="small" class="iconfont iconxiugai1" @click="editName('form')">修改名称</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="20">
      <el-col :span="24">
        <el-tabs type="border-card" @tab-click="handleClickScore" v-model="activeNameScore" style="margin-left: 14px;">
          <!-- <el-tab-pane name="first" label="考核内容">
            <el-row class="addBtnBg">
              <el-button
                :disabled="isdisabled"
                type="primary"
                size="small"
                class="iconfont iconxinzeng"
                @click="changeExaminationContentInfo"
              >新增</el-button>
            </el-row>
            <el-row>
              <el-col>
                <el-table
                  ref="multipleTable"
                  :data="examinationContentTable"
                  tooltip-effect="dark"
                  style="width: 100%"
                  border
                  stripe
                  highlight-current-row
                  @selection-change="examinationContentChange"
                >
                  <el-table-column type="index" label="序号" align="center" width="60"></el-table-column>
                  <el-table-column
                    prop="name"
                    label="考核内容"
                    sortable
                    align="center"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column width="115" label="操作" align="center">
                    <template slot-scope="scope">
                      <el-tooltip class="item" effect="light" content="查看" placement="top">
                        <el-button
                          @click.stop="changeExaminationContentInfo(scope.row,'show')"
                          type="primary"
                          size="small"
                          class="iconfont iconchakan2 operate_show_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="编辑" placement="top" v-if="!(scope.row.isEidt == 'N' || isdisabled)">
                        <el-button
                          @click.stop="changeExaminationContentInfo(scope.row,'update')"
                          type="primary"
                          size="small"
                          class="iconfont iconxiugai1 operate_edit_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="删除" placement="top" v-if="!(scope.row.isDelete == 'N' || isdisabled)">
                        <el-button
                          @click.native.prevent.stop="examinationContentDeleteRow(scope.$index, examinationContentTable)"
                          type="primary"
                          size="small"
                          class="iconfont iconshanchu operate_delete_btn"
                        >
                        </el-button>
                      </el-tooltip>
                    </template>
                  </el-table-column>
                </el-table>
                <div style="text-align: right;margin-top: 20px">
                  <el-pagination
                    @size-change="examinationContentSizeChange"
                    @current-change="examinationContentCurrentChange"
                    :current-page="examinationContentPage.page"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="examinationContentPage.size"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="examinationContentPage.total"
                  ></el-pagination>
                </div>
              </el-col>
            </el-row>

            <el-dialog
              title="考核内容"
              :visible.sync="showExaminationContent"
              width="50%"
              :close-on-click-modal="false"
            >
              <el-form
                :model="examinationContentInfo"
                :rules="examinationContentRules"
                ref="examinationContentRef"
                label-width="120px"
              >
                <el-form-item label="考核内容" prop="name">
                  <el-input
                    type="textarea"
                    v-model="examinationContentInfo.name"
                    :disabled="examinationContentDisabled"
                    resize="none"
                    :rows="4"
                  ></el-input>
                </el-form-item>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconbaocun"
                  v-show="examinationContentType != 'show'"
                  @click="saveExaminationContent('examinationContentRef')"
                >保存</el-button>
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconfanhui"
                  @click="examinationContentClose('examinationContentRef')"
                >返回</el-button>
              </span>
            </el-dialog>
          </el-tab-pane> -->

          <!-- <el-tab-pane name="second" label="重点考核事项">
            <el-row class="addBtnBg">
              <el-button
                :disabled="isdisabled"
                type="primary"
                size="small"
                class="iconfont iconxinzeng"
                @click="changeAssessmentMattersInfo"
              >新增</el-button>
            </el-row>
            <el-row>
              <el-col>
                <el-table
                  ref="multipleTable"
                  :data="assessmentMattersTable"
                  tooltip-effect="dark"
                  style="width: 100%"
                  border
                  stripe
                  highlight-current-row
                  @selection-change="assessmentMattersChange"
                >
                  <el-table-column align="center" type="index" label="序号" width="60"></el-table-column>
                  <el-table-column
                    align="center"
                    prop="zdkssx"
                    sortable
                    label="重点考核事项"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column
                    align="center"
                    prop="khnr"
                    sortable
                    label="考核内容"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column width="115" label="操作" align="center">
                    <template slot-scope="scope">
                      <el-tooltip class="item" effect="light" content="查看" placement="top">
                        <el-button
                          @click.stop="changeAssessmentMattersInfo(scope.row,'show')"
                          type="primary"
                          size="small"
                          class="iconfont iconchakan2 operate_show_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="编辑" placement="top" v-if="!(scope.row.isEidt == 'N' || isdisabled)">
                        <el-button
                          @click.stop="changeAssessmentMattersInfo(scope.row,'update')"
                          type="primary"
                          size="small"
                          class="iconfont iconxiugai1 operate_edit_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="删除" placement="top" v-if="!(scope.row.isDelete == 'N' || isdisabled)">
                        <el-button
                          @click.native.prevent.stop="assessmentMattersDeleteRow(scope.$index, assessmentMattersTable)"
                          type="primary"
                          size="small"
                          class="iconfont iconshanchu operate_delete_btn"
                        >
                        </el-button>
                      </el-tooltip>
                    </template>
                  </el-table-column>
                </el-table>
                <div style="text-align: right;margin-top: 20px">
                  <el-pagination
                    @size-change="assessmentMattersSizeChange"
                    @current-change="assessmentMattersCurrentChange"
                    :current-page="assessmentMattersPage.page"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="assessmentMattersPage.size"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="assessmentMattersPage.total"
                  ></el-pagination>
                </div>
              </el-col>
            </el-row>
            <el-dialog
              title="重点考核事项"
              :visible.sync="showAssessmentMatters"
              width="50%"
              :close-on-click-modal="false"
            >
              <el-form
                :model="assessmentMattersInfo"
                :rules="assessmentMattersRules"
                ref="assessmentMattersRef"
                label-width="120px"
              >
                <el-form-item label="考核内容" prop="bizRespContentId">
                  <el-input
                    v-if="assessmentMattersDisabled"
                    type="textarea"
                    v-model="assessmentMattersInfo.bizRespContentId"
                    :disabled="assessmentMattersDisabled"
                    :rows="4"
                    resize="none"
                  ></el-input>
                  <el-select
                    v-model="assessmentMattersInfo.bizRespContentId"
                    :popper-append-to-body = 'false'
                    v-else
                    class="dialogSel"
                  >
                    <el-option
                      v-for="item in assessmentMattersOptions"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="重点考核事项" prop="zdkssx">
                  <el-input
                    type="textarea"
                    v-model="assessmentMattersInfo.zdkssx"
                    :disabled="assessmentMattersDisabled"
                    :rows="4"
                    resize="none"
                  ></el-input>
                </el-form-item>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconbaocun"
                  v-show="assessmentMattersType != 'show'"
                  @click="saveAssessmentMatters('assessmentMattersRef')"
                >保存</el-button>
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconfanhui"
                  @click="assessmentMattersClose('assessmentMattersRef')"
                >返回</el-button>
              </span>
            </el-dialog>
          </el-tab-pane> -->

          <!-- <el-tab-pane name="third" label="考核指标">
            <el-row class="addBtnBg">
              <el-button
                :disabled="isdisabled"
                type="primary"
                size="small"
                class="iconfont iconxinzeng"
                @click="changeAssessmentIndexInfo"
              >新增</el-button>
            </el-row>
            <el-row>
              <el-col>
                <el-table
                  ref="multipleTable"
                  :data="assessmentIndexTable"
                  tooltip-effect="dark"
                  style="width: 100%"
                  border
                  stripe
                  highlight-current-row
                  @selection-change="assessmentIndexChange"
                >
                  <el-table-column align="center" type="index" label="序号" width="60"></el-table-column>
                  <el-table-column
                    align="center"
                    prop="khzb"
                    sortable
                    label="考核指标"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column
                    align="center"
                    prop="zdkssx"
                    sortable
                    label="重点考核事项"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column width="115" label="操作" align="center">
                    <template slot-scope="scope">
                      <el-tooltip class="item" effect="light" content="查看" placement="top">
                        <el-button
                          @click.stop="changeAssessmentIndexInfo(scope.row,'show')"
                          type="primary"
                          size="small"
                          class="iconfont iconchakan2 operate_show_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="编辑" placement="top" v-if="!(scope.row.isEidt == 'N' || isdisabled)">
                        <el-button
                          @click.stop="changeAssessmentIndexInfo(scope.row,'update')"
                          type="primary"
                          size="small"
                          class="iconfont iconxiugai1 operate_edit_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="删除" placement="top" v-if="!(scope.row.isDelete == 'N' || isdisabled)">
                        <el-button
                          @click.native.prevent.stop="assessmentIndexDeleteRow(scope.$index, assessmentIndexTable)"
                          type="primary"
                          size="small"
                          class="iconfont iconshanchu operate_delete_btn"
                        >
                        </el-button>
                      </el-tooltip>
                    </template>
                  </el-table-column>
                </el-table>
                <div style="text-align: right;margin-top: 20px">
                  <el-pagination
                    @size-change="assessmentIndexSizeChange"
                    @current-change="assessmentIndexCurrentChange"
                    :current-page="assessmentIndexPage.page"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="assessmentIndexPage.size"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="assessmentIndexPage.total"
                  ></el-pagination>
                </div>
              </el-col>
            </el-row>
            <el-dialog
              title="考核指标"
              :visible.sync="showAssessmentIndex"
              width="50%"
              :close-on-click-modal="false"
            >
              <el-form
                :model="assessmentIndexInfo"
                :rules="assessmentIndexRules"
                ref="assessmentIndexRef"
                label-width="120px"
              >
                <el-form-item label="重点考核事项" prop="bizRespExaminationItemId">
                  <el-input
                    v-if="assessmentIndexDisabled"
                    type="textarea"
                    v-model="assessmentIndexInfo.bizRespExaminationItemId"
                    :disabled="assessmentIndexDisabled"
                    resize="none"
                    :rows="4"
                  ></el-input>
                  <el-select
                    v-else
                    v-model="assessmentIndexInfo.bizRespExaminationItemId"
                    :popper-append-to-body = 'false'
                    class="dialogSel"
                  >
                    <el-option
                      v-for="item in assessmentIndexOptions"
                      :key="item.id"
                      :label="item.zdkssx"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="考核指标" prop="khzb">
                  <el-input
                    type="textarea"
                    v-model="assessmentIndexInfo.khzb"
                    :disabled="assessmentIndexDisabled"
                    resize="none"
                    :rows="4"
                  ></el-input>
                </el-form-item>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconbaocun"
                  v-show="assessmentIndexType != 'show'"
                  @click="saveAssessmentIndex('assessmentIndexRef')"
                >保存</el-button>
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconfanhui"
                  @click="assessmentIndexClose('assessmentIndexRef')"
                >返回</el-button>
              </span>
            </el-dialog>
          </el-tab-pane> -->

          <el-tab-pane name="fourth" label="评分标准">
            <el-row>
              <el-form
                :model="assessmentTargetSearchInfo"
                ref="peopleform"
                :inline="true"
                class="search-bm-boder"
              >
              <el-form-item label="牵头部门:">
                <el-select
                  placeholder="请选择"
                  v-model="assessmentTargetSearchInfo.leadDepartment"
                  clearable
                  class="inputCompatible"
                >
                  <el-option
                    v-for="item in assessmentTargetDeptName2"
                    :key="item.id"
                    :label="item.name.length > 33 ? item.name.substring(0,33)+'...' : item.name"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="配合部门:">
                <el-select
                  placeholder="请选择"
                  v-model="assessmentTargetSearchInfo.coordinationDepartment"
                  clearable
                  class="inputCompatible"
                >
                  <el-option
                    v-for="item in assessmentTargetDeptName2"
                    :key="item.id"
                    :label="item.name.length > 33 ? item.name.substring(0,33)+'...' : item.name"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <div class="search-button">
                    <span class="search-line"></span>
                    <el-button
                      @click="assessmentTargetQuery"
                      type="primary"
                      class="iconfont iconchaxun"
                      size="small"
                    >查询</el-button>
                    <el-button type="primary" size="small" class="iconfont iconzhongzhi" @click="resetFun">重置</el-button>
                </div>
              </el-form-item>
              </el-form>
            </el-row>
            <el-row class="addBtnBg">
              <el-button
                :disabled="isdisabled"
                type="primary"
                size="small"
                class="iconfont iconxinzeng"
                @click="changeAssessmentTargetInfo"
              >新增</el-button>
            </el-row>
            <el-row>
              <el-col>
                <!-- @row-click="tableRowClick4" -->
                <el-table
                  ref="multipleTable"
                  :data="assessmentTargetTable"
                  tooltip-effect="dark"
                  style="width: 100%"
                  border
                  stripe
                  highlight-current-row
                  v-loading="loading"
                  @selection-change="assessmentTargetChange"
                >
                  <!-- <el-table-column
                    type="selection"
                    width="55"
                    align="center"
                    :selectable="assessmentTargetCheckSelectable"
                  ></el-table-column> -->
                  <el-table-column align="center" type="index" label="序号" width="60"></el-table-column>
                  <!-- <el-table-column
                    align="center"
                    prop="khzb"
                    sortable
                    label="考核指标"
                    :show-overflow-tooltip="true"
                  ></el-table-column> -->
                  <el-table-column
                    align="center"
                    prop="khmbru"
                    sortable
                    label="评分标准"
                    :show-overflow-tooltip="true"
                    min-width="100"
                  ></el-table-column>
                  <el-table-column
                    align="center"
                    prop="nyfz"
                    sortable
                    label="农业分值"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column
                    align="center"
                    prop="fnyfz"
                    sortable
                    label="非农业分值"
                    min-width='90'
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <!-- <el-table-column
                    align="center"
                    prop="khfs"
                    sortable
                    label="考核方式"
                    :show-overflow-tooltip="true"
                  ></el-table-column> -->
                  <el-table-column
                    align="center"
                    prop="qtbm"
                    sortable
                    label="牵头部门"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column
                    align="center"
                    prop="phbm"
                    sortable
                    label="配合部门"
                    :show-overflow-tooltip="true"
                  ></el-table-column>
                  <el-table-column label="操作" width="115" align="center">
                    <template slot-scope="scope">
                      <el-tooltip class="item" effect="light" content="查看" placement="top">
                        <el-button
                          @click.stop="changeAssessmentTargetInfo(scope.row,'show')"
                          type="primary"
                          size="small"
                          class="iconfont iconchakan2 operate_show_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="编辑" placement="top">
                        <el-button
                          :disabled="isdisabled"
                          @click.stop="changeAssessmentTargetInfo(scope.row,'update')"
                          type="primary"
                          size="small"
                          class="iconfont iconxiugai1 operate_edit_btn"
                        >
                        </el-button>
                      </el-tooltip>
                      <el-tooltip class="item" effect="light" content="删除" placement="top">
                        <el-button
                          :disabled="isdisabled"
                          @click.native.prevent.stop="assessmentTargetDeleteRow(scope.$index, assessmentTargetTable)"
                          type="primary"
                          size="small"
                          class="iconfont iconshanchu operate_delete_btn"
                        >
                        </el-button>
                      </el-tooltip>
                    </template>
                  </el-table-column>
                </el-table>
                <div style="text-align: right;margin-top: 20px">
                  <el-pagination
                    @size-change="assessmentTargetSizeChange"
                    @current-change="assessmentTargetCurrentChange"
                    :current-page="assessmentTargetPage.page"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="assessmentTargetPage.size"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="assessmentTargetPage.total"
                    v-if="paginationShow"
                  ></el-pagination>
                </div>
              </el-col>
            </el-row>

            <el-dialog
              title="评分标准"
              :visible.sync="showAssessmentTarget"
              width="50%"
              center
              :close-on-click-modal="false"
              class="taskDialog"
            >
              <el-form
                :model="assessmentTargetInfo"
                :rules="assessmentTargetRules"
                ref="assessmentTargetRef"
                label-width="140px"
              >
                <el-row>
                  <!-- <el-col>
                    <el-form-item label="考核指标" prop="bizRespExaminationQuotaId">
                      <el-input
                        v-if="assessmentTargetDisabled"
                        type="textarea"
                        v-model="assessmentTargetInfo.bizRespExaminationQuotaId"
                        :disabled="assessmentTargetDisabled"
                        resize="none"
                        :rows="4"
                      ></el-input>
                      <el-select
                        v-else
                        v-model="assessmentTargetInfo.bizRespExaminationQuotaId"
                        :popper-append-to-body = 'false'
                        class="dialogSel"
                      >
                        <el-option
                          v-for="item in assessmentTargetOptions"
                          :key="item.id"
                          :label="item.khzb"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col> -->
                </el-row>
                <el-row>
                  <el-col>
                    <el-form-item label="评分标准" prop="scoreStandard">
                      <el-input
                        type="textarea"
                        v-model="assessmentTargetInfo.scoreStandard"
                        :disabled="assessmentTargetDisabled"
                        resize="none"
                        :rows="4"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col>
                    <el-form-item label="备注" prop="pfyj">
                      <el-input
                        type="textarea"
                        v-model="assessmentTargetInfo.pfyj"
                        :disabled="assessmentTargetDisabled"
                        resize="none"
                        :rows="4"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <!-- <el-row>
                  <el-col :span="12">
                    <el-form-item label="考核方式" prop="khfs">
                      <el-select
                        v-model="assessmentTargetInfo.khfs"
                        :disabled="assessmentTargetDisabled"
                        multiple
                      >
                        <el-option
                          v-for="(item,index) in khTypeData"
                          :key="index"
                          :label="item.name"
                          :value="item.name"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row> -->
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="农业分值" prop="nyfz">
                      <el-input
                        v-model="assessmentTargetInfo.nyfz"
                        :disabled="assessmentTargetDisabled"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="非农业分值" prop="fnyfz">
                      <el-input
                        v-model="assessmentTargetInfo.fnyfz"
                        :disabled="assessmentTargetDisabled"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="牵头部门" prop="leadDepartment">
                      <el-select
                        v-model="assessmentTargetInfo.leadDepartment"
                        :disabled="assessmentTargetDisabled"
                        filterable
                      >
                        <el-option
                          v-for="item in assessmentTargetDeptName2"
                          :key="item.id"
                          :label="item.name.length > 33 ? item.name.substring(0,33)+'...' : item.name"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="配合部门">
                      <el-select
                        multiple
                        v-model="assessmentTargetInfo.coordinationDepartment"
                        :disabled="assessmentTargetDisabled"
                        filterable
                      >
                        <el-option
                          v-for="item in assessmentTargetDeptName2"
                          :key="item.id"
                          :label="item.name.length > 33 ? item.name.substring(0,33)+'...' : item.name"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconbaocun"
                  v-show="assessmentTargetType != 'show'"
                  @click="saveAssessmentTarget('assessmentTargetRef')"
                >保存</el-button>
                <el-button
                  type="primary"
                  size='small'
                  class="iconfont iconfanhui"
                  @click="assessmentTargetClose('assessmentTargetRef')"
                >返回</el-button>
              </span>
            </el-dialog>
          </el-tab-pane>

          <el-dialog
            title="上传excel"
            :visible.sync="showExcelUplod"
            width="50%"
            :close-on-click-modal="false"
          >
            <el-form label-width="120px">
              <el-form-item>
                <el-upload
                  action
                  accept=".xls"
                  :on-change="uploadFile"
                  :auto-upload="false"
                  :show-file-list="true"
                  :file-list="excelFileList"
                >
                  <el-button slot="trigger" size="small" type="primary">上传文件</el-button>
                </el-upload>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
              <el-button type="primary" size='small' class="iconfont iconfanhui" @click="excelUplodQx()">返回</el-button>
            </span>
          </el-dialog>
        </el-tabs>
      </el-col>
    </el-row>
    <div style="text-align: center;padding: 10px 0;">
      <el-button type="primary" size='small' class="iconfont iconfanhui" @click="back">返回</el-button>
    </div>
  </div>
</template>
<script>
import {
  uploadExcelFile,
  findYear,
  updateYearTime,
  saveYearTime,
  examinationContentSorce,
  examinationContentList,
  examinationContentSave,
  examinationContentUpdate,
  examinationContentDelete,
  examinationContentOption,
  assessmentMattersList,
  assessmentMattersSave,
  assessmentMattersSorce,
  assessmentMattersUpdate,
  assessmentMattersDelete,
  assessmentMattersOption,
  assessmentIndexList,
  assessmentIndexSorce,
  assessmentIndexSave,
  assessmentIndexUpdate,
  assessmentIndexDelete,
  assessmentIndexOption,
  assessmentTargetList,
  assessmentTargetScore,
  assessmentTargetSave,
  assessmentTargetUpdate,
  assessmentTargetDelete,
  assessmentTargetDetail,
  assessmentTargetDeptName,
  assessmentTargetrRelease,
  getIfShowButtonTask,
  reportProgressDetail,
  reportProgressFiles,
  reportProgressFileUpload,
  deptOpinionProcess,
  checkTargetTask,
  findByTaskId,
  examinationContentfindIfRelease,
  assessmentMattersfindIfRelease,
  assessmentIndexfindIfRelease
} from "@/api/foodSecurity";
import * as management from "@/api/headResponsibility/management";
import * as validate from "@/utils/validate";
export default {
  data() {
    // 根据评分表名称和年分查询数据是否存在
    const findByPfbmc = (rule, value, callback) => {
      if (!value) {
        return callback()
      } else {
        const data = {
          pfbmc: value,
          year: this.form.year,
          id: this.$route.query.id
        }
        management.findByPfbmc(data).then(res => {
          if (res.infoCode==200) {
            callback()
          } else {
            return callback(new Error(res.msg))
          }
        })
      }
    }
    return {
      isdisabled: "",
      form: {},
      activeNameScore: "fourth",
      examinationContentPage: {
        page: 1,
        size: 10,
        total: 0
      },
      examinationContentTable: [],
      showExaminationContent: false,
      examinationContentInfo: {
        name: null,
        score: null
      },
      rulesForm: {
        pfbmc: [
          { required: true, message: "请输入评分表名称", trigger: "blur" },
          {trigger: ['blur', 'change'], validator: findByPfbmc},
          { validator: validate.validateFive, trigger: "blur" }
        ]
      },
      examinationContentRules: {
        name: [
          { required: true, message: "请输入考核内容", trigger: "blur" },
          { validator: validate.validateTenBai, trigger: "blur" }
        ],
        score: [
          {
            required: true,
            pattern: /^[1-9][0-9]*([.][0-9]+)?$/,
            message: "请输入数字格式",
            trigger: "blur"
          },
          { validator: validate.isPriceVlidator, trigger: "blur" }
        ]
      },
      examinationContentDisabled: false,
      ruleTime: {
        value6: [],
        value7: [],
        ids: null,
        totalScore: ""
      },
      examinationContentScore: "",
      examinationContentFxzf: 0,
      examinationContentType: "",
      assessmentMattersTable: [],
      assessmentMattersPage: {
        page: 1,
        size: 10,
        total: 0
      },
      showAssessmentMatters: false,
      assessmentMattersInfo: {
        ids: null,
        zdkssx: null,
        bizRespContentId: null,
        score: null
      },
      assessmentMattersRules: {
        zdkssx: [
          { required: true, message: "请输入重点考核事项", trigger: "blur" },
          { validator: validate.validateTenBai, trigger: "blur" }
        ],
        bizRespContentId: [
          { required: true, message: "请选择考核内容", trigger: "change" }
        ],
        score: [
          {
            required: true,
            pattern: /^[1-9][0-9]*([.][0-9]+)?$/,
            message: "请输入数字格式",
            trigger: "blur"
          },
          { validator: validate.isPriceVlidator, trigger: "blur" }
        ]
      },
      assessmentMattersDisabled: false,
      assessmentMattersType: "",
      assessmentMattersOptions: [],
      assessmentMattersScore: {
        total: null,
        score: null
      },
      assessmentMattersFXZFScore: "0",
      assessmentIndexTable: [],
      assessmentIndexPage: {
        page: 1,
        size: 10,
        total: 0
      },
      showAssessmentIndex: false,
      assessmentIndexInfo: {
        ids: null,
        khzb: null,
        bizRespExaminationItemId: null,
        score: null
      },
      assessmentIndexRules: {
        khzb: [
          { required: true, message: "请输入考核指标", trigger: "blur" },
          { validator: validate.validateTenBai, trigger: "blur" }
        ],
        bizRespExaminationItemId: [
          { required: true, message: "请选择重点考核事项", trigger: "change" }
        ],
        score: [
          {
            required: true,
            pattern: /^[1-9][0-9]*([.][0-9]+)?$/,
            message: "请输入数字格式",
            trigger: "blur"
          },
          { validator: validate.isPriceVlidator, trigger: "blur" }
        ]
      },
      assessmentIndexDisabled: false,
      assessmentIndexOptions: [],
      assessmentIndexScore: {
        total: null,
        score: null,
        fxzf: "0"
      },
      assessmentIndexFXZFScore: "0",
      assessmentIndexType: "",
      assessmentTargetSearchInfo: {
        leadDepartment: null,
        coordinationDepartment: null
      },
      assessmentTargetDeptName2: [],
      //填报进度
      reportProgressSearchInfo: {
        leadDepartment: null,
        coordinationDepartment: null,
        statusType: ""
      },
      reportProgressOptions: [
        {
          value: "0",
          label: "编辑中"
        },
        {
          value: "10",
          label: "已发布"
        },
        {
          value: "20",
          label: "已完成"
        }
      ],
      loading: false,
      assessmentTargetTable: [],
      assessmentTargetIds: [],
      assessmentTargetOptions: [],
      assessmentTargetDeptName1: [],
      assessmentTargetDeptName2: [],
      assessmentTargetSearchInfo: {
        leadDepartment: null,
        coordinationDepartment: null
      },
      paginationShow: true,
      assessmentTargetPage: {
        page: 1,
        size: 10,
        total: 0
      },
      showAssessmentTarget: false,
      assessmentTargetInfo: {
        ids: null,
        // taskName: null,
        bizRespExaminationQuotaId: null,
        selfEvaluationDepartment: null,
        leadDepartment: '',
        coordinationDepartment: [],
        scoreStandard: null,
        pfyj: '',
        khfs: [],
        nyfz: '',
        fnyfz: ''
      },
      khTypeData: [
        {
          name: '集中评审'
        },
        {
          name: '根据日常统计结果评定'
        }
      ],
      assessmentTargetRules: {
        khzb: [{ required: true, message: "请输入考核指标", trigger: "blur" }],
        bizRespExaminationItemId: [
          { required: true, message: "请选择重点考核事项", trigger: "change" }
        ],
        bizRespExaminationQuotaId: [
          { required: false, message: "请选择考核指标", trigger: "blur" }
        ],
        selfEvaluationDepartment: [
          { required: true, message: "此项为必填项", trigger: "blur" }
        ],
        leadDepartment: [
          { required: true, message: "请选择牵头部门", trigger: "blur" }
        ],
        scoreStandard: [
          { required: true, message: "请输入评分标准", trigger: "blur" },
          { validator: validate.validateTenBai, trigger: "blur" }
        ],
        pfyj: [
          { required: true, message: "请输入评分依据", trigger: "blur" },
          { validator: validate.validateTenBai, trigger: "blur" }
        ],
        khfs: [
          { required: false, message: "请选择考核方式", trigger: "blur" }
        ],
        nyfz: [
          { required: true, message: "请输入农业分值", trigger: "blur" },
          { validator: validate.validateNumber, trigger: "blur" }
        ],
        fnyfz: [
          { required: true, message: "请输入非农业分值", trigger: "blur" },
          { validator: validate.validateNumber, trigger: "blur" }
        ]
      },
      assessmentTargetDisabled: false,
      assessmentTargetType: "",
      showExcelUplod: false,
      excelFileList: [],
      peopleform: {
        // 人员抽取结果
        peopleYear: null
      }
    };
  },
  methods: {
    /**
     * 返回按钮
     */
    back() {
      this.$router.push({
        path: '/accountability/management',
        query: {
          markYear: this.$route.query.markYear
        }
      })
    },

    getData() {
      management.responsibilityFindByIds(this.$route.query.id).then(res => {
        if (res.infoCode == 200) {
          this.form = res.data;
        }
      });
    },
    handleClickScore(tab, event) {
      switch (tab.name) {
        case "first":
          this.getExaminationContentInfo();
          break;
        case "second":
          this.getAssessmentMattersInfo();
          break;
        case "third":
          this.getAssessmentIndexInfo();
          break;
        case "fourth":
          this.getAssessmentTargetInfo();
          //自评部门
          assessmentTargetDeptName(1).then(res => {
            this.assessmentTargetDeptName1 = res.data;
          });
          //牵头部门 、 配合部门
          assessmentTargetDeptName(0).then(res => {
            this.assessmentTargetDeptName2 = res.data;
          });
          break;
      }
    },

    getAssessmentTargetInfo() {
      this.loading = true;
      let data = {
        year: this.peopleform.peopleYear,
        source: 1,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = this.assessmentTargetPage.page;
      let size = this.assessmentTargetPage.size;
      assessmentTargetList(data, page, size).then(res => {
        this.assessmentTargetTable = res.data.list;
        // console.log(this.assessmentTargetTable, "list");
        this.assessmentTargetPage.total = res.data.total;
        this.loading = false;
      });
    },

    //评分标准保存
    saveAssessmentTarget(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          let coordinationDepartmentVal = this.assessmentTargetInfo
            .coordinationDepartment;
          if (this.assessmentTargetInfo.coordinationDepartment) {
            coordinationDepartmentVal = this.assessmentTargetInfo.coordinationDepartment.join(
              ","
            );
          }

          // let leadDepartment = "";

          // if (this.assessmentTargetInfo.leadDepartment) {
          //   for (let item in this.assessmentTargetInfo.leadDepartment) {
          //     leadDepartment +=
          //       this.assessmentTargetInfo.leadDepartment[item] + ",";
          //   }
          // }
          // leadDepartment = leadDepartment.substring(
          //   0,
          //   leadDepartment.length - 1
          // );
          let data = {
            // taskName: this.assessmentTargetInfo.taskName,
            selfEvaluationDepartment: this.assessmentTargetInfo
              .selfEvaluationDepartment,
            // leadDepartment: leadDepartment,
            leadDepartment:this.assessmentTargetInfo.leadDepartment,
            coordinationDepartment: coordinationDepartmentVal,
            scoreStandard: this.assessmentTargetInfo.scoreStandard,
            pfyj: this.assessmentTargetInfo.pfyj,
            khfs: this.assessmentTargetInfo.khfs.join(','),
            nyfz: this.assessmentTargetInfo.nyfz,
            fnyfz: this.assessmentTargetInfo.fnyfz,
            // totalScore: this.assessmentTargetInfo.totalScore,
            ids: this.assessmentTargetInfo.id,
            bizRespExaminationQuotaId: this.assessmentTargetInfo
              .bizRespExaminationQuotaId,
            bizRespResponsibilityId: this.ruleTime.ids,
            year: this.peopleform.peopleYear
          };
          if (this.assessmentTargetType == "update") {
            (data.status = this.assessmentTargetInfo.status),
              assessmentTargetUpdate(data).then(res => {
                if (res.infoCode == 200) {
                  this.$message({
                    message: "保存成功",
                    type: "success",
                    duration: 2000
                  });
                  this.getAssessmentTargetInfo();
                  this.$refs[formName].resetFields();
                  this.showAssessmentTarget = false;
                  // this.assessmentTargetedit("0");
                } else {
                  this.$message({
                    message: res.msg,
                    type: "error",
                    duration: 2000
                  });
                }
              });
          } else {
            data.status = 0;
            assessmentTargetSave(data).then(res => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                  duration: 2000
                });
                this.getAssessmentTargetInfo();
                this.$refs[formName].resetFields();
                this.showAssessmentTarget = false;
                // this.assessmentTargetedit("0");
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                  duration: 2000
                });
              }
            });
          }
        } else {
          return false;
        }
      });
    },

    //考核目标弹窗取消
    assessmentTargetClose(formName) {
      this.$refs[formName].resetFields();
      this.showAssessmentTarget = false;
      // this.assessmentTargetScore = [];
      // this.assessmentTargetedit("0");
    },

    //考核事项列表
    getAssessmentMattersInfo() {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = this.assessmentMattersPage.page;
      let size = this.assessmentMattersPage.size;
      assessmentMattersList(data, page, size).then(res => {
        // console.log(res.data);
        this.assessmentMattersTable = res.data.list;
        this.assessmentMattersPage.total = res.data.total;
      });
    },

    //考核事项弹窗取消
    assessmentMattersClose(formName) {
      this.$refs[formName].resetFields();
      this.showAssessmentMatters = false;
      this.assessmentMattersScore = [];
    },

    //考核事项保存
    saveAssessmentMatters(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          let data = {
            name: this.assessmentMattersInfo.zdkssx,
            ids: this.assessmentMattersInfo.id,
            bizRespContentId: this.assessmentMattersInfo.bizRespContentId,
            bizRespResponsibilityId: this.ruleTime.ids,
            year: this.peopleform.peopleYear,
            score: this.assessmentMattersInfo.score
          };

          if (this.assessmentMattersType == "update") {
            assessmentMattersUpdate(data).then(res => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                  duration: 2000
                });
                this.getAssessmentMattersInfo();
                this.$refs[formName].resetFields();
                this.showAssessmentMatters = false;
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                  duration: 2000
                });
              }
            });
          } else {
            assessmentMattersSave(data).then(res => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                  duration: 2000
                });
                this.getAssessmentMattersInfo();
                this.$refs[formName].resetFields();
                this.showAssessmentMatters = false;
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                  duration: 2000
                });
              }
            });
          }
        } else {
          return false;
        }
      });
    },

    // 考核目标行内删除
    assessmentTargetDeleteRow(index, rows) {
      this.$confirm("您确定要删除吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let data = [];
          data.push(rows[index].id);
          assessmentTargetDelete(data).then(res => {
            if (res.infoCode == 200) {
              this.getAssessmentTargetInfo();
              this.$message({
                message: '删除成功',
                type: "success",
                duration: 2000
              });
            } else {
              this.$message({
                message: res.msg,
                type: "error",
                duration: 2000
              });
            }
          });
        })
    },
    editName(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let data = {
            ids: this.$route.query.id,
            pfbmc: this.form.pfbmc,
            year: this.form.year
          };
          management.editPpf(data).then(res => {
            if (res.infoCode == 200) {
              this.$message({
                message: '修改成功',
                type: "success",
                duration: 2000
              });
            } else if (res.infoCode == 504) {
              this.$message.warning(res.msg);
            } else {
              this.$message.error(res.msg);
            }
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    getAssessmentIndexInfo() {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = this.assessmentIndexPage.page;
      let size = this.assessmentIndexPage.size;
      assessmentIndexList(data, page, size).then(res => {
        this.assessmentIndexTable = res.data.list;
        this.assessmentIndexPage.total = res.data.total;
      });
    },

    //考核指标弹窗取消
    assessmentIndexClose(formName) {
      this.$refs[formName].resetFields();
      this.showAssessmentIndex = false;
      this.assessmentIndexScore = [];
    },

    getExaminationContentInfo() {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = this.examinationContentPage.page;
      let size = this.examinationContentPage.size;
      examinationContentList(data, page, size).then(res => {
        this.examinationContentTable = res.data.list;
        this.examinationContentPage.total = res.data.total;
      });
    },

    //考核指标保存
    saveAssessmentIndex(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          let data = {
            name: this.assessmentIndexInfo.khzb,
            ids: this.assessmentIndexInfo.id,
            score: this.assessmentIndexInfo.score,
            bizRespExaminationItemId: this.assessmentIndexInfo
              .bizRespExaminationItemId,
            bizRespResponsibilityId: this.ruleTime.ids,
            year: this.peopleform.peopleYear
          };

          if (this.assessmentIndexType == "update") {
            assessmentIndexUpdate(data).then(res => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                  duration: 2000
                });
                this.getAssessmentIndexInfo();
                this.getExaminationContentInfo();
                this.$refs[formName].resetFields();
                this.showAssessmentIndex = false;
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                  duration: 2000
                });
              }
            });
          } else {
            assessmentIndexSave(data).then(res => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                  duration: 2000
                });
                this.getAssessmentIndexInfo();
                this.$refs[formName].resetFields();
                this.showAssessmentIndex = false;
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                  duration: 2000
                });
              }
            });
          }
        } else {
          return false;
        }
      });
    },

    tableRowClick(row, column, event) {
      if (event.label != "操作") {
        this.changeExaminationContentInfo(row, "show");
      }
    },
    changeExaminationContentInfo(row, type) {
      this.showExaminationContent = true;
      if (type == "show") {
        this.examinationContentInfo.score = row.score;
        this.examinationContentInfo.name = row.name;
        this.examinationContentInfo.id = row.id;
        this.examinationContentDisabled = true;
        this.examinationContentType = "show";
      } else if (type == "update") {
        this.examinationContentInfo.score = row.score;
        this.examinationContentInfo.name = row.name;
        this.examinationContentInfo.id = row.id;
        this.examinationContentDisabled = false;
        this.examinationContentType = "update";
      } else {
        this.examinationContentDisabled = false;
        this.examinationContentType = "";
        this.examinationContentInfo.name = null;
        this.examinationContentInfo.score = null;
      }
    },

    //考核内容保存
    saveExaminationContent(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          let data = {
            name: this.examinationContentInfo.name,
            ids: this.examinationContentInfo.id,
            score: this.examinationContentInfo.score,
            bizRespResponsibilityId: this.ruleTime.ids
          };

          if (this.examinationContentType == "update") {
            examinationContentUpdate(data).then(res => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                  duration: 2000
                });
                this.getExaminationContentInfo();
                this.showExaminationContent = false;
                this.$refs[formName].resetFields();
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                  duration: 2000
                });
              }
            });
          } else {
            examinationContentSave(data).then(res => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                  duration: 2000
                });
                this.getExaminationContentInfo();
                this.showExaminationContent = false;
                this.$refs[formName].resetFields();
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                  duration: 2000
                });
              }
            });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    // 考核内容行内删除
    examinationContentDeleteRow(index, rows) {
      this.$confirm("您确定要删除吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let data = [];
          data.push(rows[index].id);
          examinationContentDelete(data).then(res => {
            if (res.infoCode == 200) {
              this.getExaminationContentInfo();
              this.$message({
                message: "删除成功",
                type: "success",
                duration: 2000
              });
            } else {
              this.$message({
                message: res.msg,
                type: "error",
                duration: 2000
              });
            }
          });
        })
    },

    //考核内容弹窗取消
    examinationContentClose(formName) {
      this.$refs[formName].resetFields();
      this.showExaminationContent = false;
    },
    examinationContentChange(val) {
      this.assessmentMattersIds = val;
    },
    examinationContentSizeChange(val) {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = this.examinationContentPage.page;
      let size = (this.examinationContentPage.size = val);
      examinationContentList(data, page, size).then(res => {
        this.examinationContentTable = res.data.list;
        this.examinationContentPage.total = res.data.total;
      });
    },
    //考核内容分页
    examinationContentCurrentChange(val) {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = (this.examinationContentPage.page = val);
      let size = this.examinationContentPage.size;
      examinationContentList(data, page, size).then(res => {
        this.examinationContentTable = res.data.list;
        this.examinationContentPage.total = res.data.total;
      });
    },

    // 考核内容行内删除
    assessmentMattersDeleteRow(index, rows) {
      this.$confirm("您确定要删除吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let data = [];
          data.push(rows[index].id);
          assessmentMattersDelete(data).then(res => {
            if (res.infoCode == 200) {
              this.getAssessmentMattersInfo();
              this.$message({
                message: '删除成功',
                type: "success",
                duration: 2000
              });
            } else {
              this.$message({
                message: res.msg,
                type: "error",
                duration: 2000
              });
            }
          });
        })
    },

    // 重点考核事项新增、详情、修改
    changeAssessmentMattersInfo(row, type) {
      this.showAssessmentMatters = true;
      this.assessmentMattersFXZFScore = "0";
      this.assessmentMattersScore = [];
      let year = this.peopleform.peopleYear;
      if(type == "show") {
        this.assessmentMattersInfo.bizRespContentId = row.khnr
      }else {
        examinationContentOption(year, this.$route.query.id).then(res => {
          this.assessmentMattersOptions = res.data;//下拉框数据
          res.data.forEach(item => {
            if (item.name == row.khnr) {
              this.assessmentMattersInfo.bizRespContentId = item.id;
            }
          });
        });
      }
      if (type == "show") {
        this.assessmentMattersInfo.score = row.score;
        this.assessmentMattersInfo.zdkssx = row.zdkssx;
        this.assessmentMattersInfo.id = row.id;
        this.assessmentMattersType = "show";
        this.assessmentMattersDisabled = true;
      } else if (type == "update") {
        this.assessmentMattersInfo.score = row.score;
        this.assessmentMattersInfo.zdkssx = row.zdkssx;
        this.assessmentMattersInfo.id = row.id;
        this.assessmentMattersDisabled = false;
        this.assessmentMattersType = "update";
      } else {
        this.assessmentMattersDisabled = false;
        this.assessmentMattersInfo.zdkssx = null;
        this.assessmentMattersInfo.score = null;
        this.assessmentMattersType = "";
        this.assessmentMattersInfo.bizRespContentId = null;
      }
    },
    tableRowClick2(row, column, event) {
      if (event.label != "操作") {
        this.changeAssessmentMattersInfo(row, "show");
      }
    },
    assessmentMattersChange(val) {
      let assessmentMattersIds = [];
      val.forEach(item => {
        assessmentMattersIds.push(item.id);
      });
      this.assessmentMattersIds = assessmentMattersIds;
    },
    assessmentMattersSizeChange(val) {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = this.assessmentMattersPage.page;
      let size = (this.assessmentMattersPage.size = val);
      assessmentMattersList(data, page, size).then(res => {
        this.assessmentMattersTable = res.data.list;
        this.assessmentMattersPage.total = res.data.total;
      });
    },
    assessmentMattersCurrentChange(val) {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = (this.assessmentMattersPage.page = val);
      let size = this.assessmentMattersPage.size;
      assessmentMattersList(data, page, size).then(res => {
        this.assessmentMattersTable = res.data.list;
        this.assessmentMattersPage.total = res.data.total;
      });
    },
    tableRowClick3(row, column, event) {
      if (event.label != "操作") {
        this.changeAssessmentIndexInfo(row, "show");
      }
    },
    // 考核指标新增、详情、修改
    changeAssessmentIndexInfo(row, type) {
      this.showAssessmentIndex = true;
      this.assessmentIndexFXZFScore = "0";
      this.assessmentIndexScore = [];
      let year = this.peopleform.peopleYear;
      assessmentMattersOption(year, this.$route.query.id).then(res => {
        this.assessmentIndexOptions = res.data;
      });
      if (type == "show") {
        this.assessmentIndexInfo.khzb = row.khzb;
        this.assessmentIndexInfo.score = row.score;
        this.assessmentIndexInfo.id = row.id;
        this.assessmentIndexInfo.bizRespExaminationItemId = row.zdkssx;
        this.assessmentIndexDisabled = true;
        this.assessmentIndexType = "show";
      } else if (type == "update") {
        this.assessmentIndexInfo.khzb = row.khzb;
        this.assessmentIndexInfo.score = row.score;
        this.assessmentIndexInfo.id = row.id;
        this.assessmentIndexInfo.bizRespExaminationItemId = row.itemid;
        this.assessmentIndexDisabled = false;
        this.assessmentIndexType = "update";
      } else {
        this.assessmentIndexDisabled = false;
        this.assessmentIndexInfo.khzb = null;
        this.assessmentIndexInfo.bizRespExaminationItemId = row.itemid;
        this.assessmentIndexType = "";
        this.assessmentIndexInfo.score = null;
      }
    },

    // 考核指标行内删除
    assessmentIndexDeleteRow(index, rows) {
      this.$confirm("您确定要删除吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let data = [];
          data.push(rows[index].id);
          assessmentIndexDelete(data).then(res => {
            if (res.infoCode == 200) {
              this.getAssessmentIndexInfo();
              this.$message({
                message: "删除成功",
                type: "success",
                duration: 2000
              });
            } else {
              this.$message({
                message: res.msg,
                type: "error",
                duration: 2000
              });
            }
          });
        })
    },
    //考核指标多选
    assessmentIndexChange(val) {
      let assessmentIndexIds = [];
      val.forEach(item => {
        assessmentIndexIds.push(item.id);
      });
      this.assessmentIndexIds = assessmentIndexIds;
    },
    //考核指标分页
    assessmentIndexSizeChange(val) {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = this.assessmentIndexPage.page;
      let size = (this.assessmentIndexPage.size = val);
      assessmentIndexList(data, page, size).then(res => {
        this.assessmentIndexTable = res.data.list;
        this.assessmentIndexPage.total = res.data.total;
      });
    },
    //考核指标分页
    assessmentIndexCurrentChange(val) {
      let data = {
        year: this.peopleform.peopleYear,
        bizRespResponsibilityId: this.$route.query.id
      };
      let page = (this.assessmentIndexPage.page = val);
      let size = this.assessmentIndexPage.size;
      assessmentIndexList(data, page, size).then(res => {
        this.assessmentIndexTable = res.data.list;
        this.assessmentIndexPage.total = res.data.total;
      });
    },
    // 搜索
    assessmentTargetQuery(option) {
      this.loading = true;
      this.paginationShow = false;
      //this.assessmentTargetCurrentChange(1)
      this.$nextTick(function() {
        this.paginationShow = true;
      });
      let data
      let page
      let size
      if(option != 'reset') {
        data = {
          bizRespResponsibilityId: this.$route.query.id,
          year: this.peopleform.peopleYear,
          leadDepartment: this.assessmentTargetSearchInfo.leadDepartment,
          coordinationDepartment: this.assessmentTargetSearchInfo
            .coordinationDepartment,
          source: 1,
          statusType: this.reportProgressSearchInfo.statusType
        };
        page = this.assessmentTargetPage.page;
        size = this.assessmentTargetPage.size;
      }else {//重置时
        this.assessmentTargetSearchInfo.leadDepartment = ''
        this.assessmentTargetSearchInfo.coordinationDepartment = ''
        data = {
          bizRespResponsibilityId: this.$route.query.id,
          year: this.peopleform.peopleYear,
          leadDepartment: '',
          coordinationDepartment: '',
          source: 1,
          statusType: this.reportProgressSearchInfo.statusType
        };
        page = 1
        size = 10
      }
      assessmentTargetList(data, page, size).then(res => {
        this.assessmentTargetTable = res.data.list;
        this.assessmentTargetPage.total = res.data.total;
        this.loading = false;
      });
    },
    resetFun() {
      this.assessmentTargetQuery('reset')
    },
    tableRowClick4(row, column, event) {
      if (event.label != "操作") {
        this.changeAssessmentTargetInfo(row, "show");
      }
    },
    // 考核目标新增、详情、修改
    changeAssessmentTargetInfo(row, type) {
      // this.assessmentTargetScore = [];
      if (row.ZT === 0) {
        this.zhuangt = false;
        // this.selfTargetDisable = true;
      } else {
        this.zhuangt = true;
        // this.selfTargetDisable = false;
      }

      let year = this.peopleform.peopleYear;
      assessmentIndexOption(year, this.$route.query.id).then(res => {
        this.assessmentTargetOptions = res.data;//下拉数据
      });
      if (type) {
        assessmentTargetDetail(row.id).then(res => {
          if(res.infoCode == 200) {
            this.assessmentTargetInfo = res.data;
            this.assessmentTargetInfo.khfs = this.assessmentTargetInfo.khfs.split(',')//考核方式
            if(type == "show") {
              this.assessmentTargetInfo.bizRespExaminationQuotaId = row.khzb;
            }
            this.assessmentTargetInfo.id = row.id;
            if (this.assessmentTargetInfo.coordinationDepartment == null) {
              this.assessmentTargetInfo.coordinationDepartment = [];
            } else {
              this.assessmentTargetInfo.coordinationDepartment = this.assessmentTargetInfo.coordinationDepartment.split(
                ","
              );
            }
          }
          // if (this.assessmentTargetInfo.leadDepartment == null) {
          //   this.assessmentTargetInfo.leadDepartment = [];
          // } else {
          //   this.assessmentTargetInfo.leadDepartment = this.assessmentTargetInfo.leadDepartment.split(
          //     ","
          //   );
          // }
        });
      }
      if (type == "show") {
        this.assessmentTargetDisabled = true;
        this.assessmentTargetType = "show";
      } else if (type == "update") {
        // this.selfTargetDisable = true;
        this.assessmentTargetDisabled = false;
        this.assessmentTargetType = "update";
      } else {
        // this.selfTargetDisable = true;
        this.assessmentTargetDisabled = false;
        this.assessmentTargetType = "";
        this.assessmentTargetInfo.ids = null;
        // this.assessmentTargetInfo.taskName = null;
        this.assessmentTargetInfo.bizRespExaminationQuotaId = null;
        this.assessmentTargetInfo.selfEvaluationDepartment = null;
        this.assessmentTargetInfo.leadDepartment = '';
        this.assessmentTargetInfo.coordinationDepartment = [];
        this.assessmentTargetInfo.scoreStandard = null;
        this.assessmentTargetInfo.pfyj = '';
        this.assessmentTargetInfo.khfs = [];
        this.assessmentTargetInfo.nyfz = '';
        this.assessmentTargetInfo.fnyfz = '';
        // this.assessmentTargetInfo.totalScore = null;
      }
      const id = row.id;
      checkTargetTask(id).then(res => {
        if (res.infoCode === 200) {
          let type = "";
          const file = {};
          const list = [];
          this.taskTarget = res.data;
          if (res.data.fileName && res.data.fileId) {
            file.name = res.data.fileName;
            file.id = res.data.fileId;
            list.push(file);
            this.fileList = list;
            this.downloadFileId = this.fileList[0].id;
          }

          // findByTaskId(row.id).then(res => {
          //   this.gradeTableData = [];
          //   this.phTableData = [];
          //   this.gradeTableData = res.data.opinion;
          //   for (var i = 0; i < this.gradeTableData.length; i++) {
          //     if (this.gradeTableData[i].sfLeadDepartment == 0) {
          //       this.phTableData.push(this.gradeTableData[i]);
          //     }
          //   }
          // });
        }
      });
      this.showAssessmentTarget = true;
    },
    //考核目标多选
    assessmentTargetChange(val) {
      let assessmentTargetIds = [];
      val.forEach(item => {
        assessmentTargetIds.push(item.id);
      });
      this.assessmentTargetIds = assessmentTargetIds;
    },
    //考核目标发布禁止选中
    assessmentTargetCheckSelectable(row) {
      if (row.ZT == 0) {
        return true;
      } else {
        return false;
      }
    },
    //考核目标分页
    assessmentTargetSizeChange(val) {
      this.loading = true;
      let data = {
        bizRespResponsibilityId: this.$route.query.id,
        year: this.peopleform.peopleYear,
        leadDepartment: this.assessmentTargetSearchInfo.leadDepartment,
        coordinationDepartment: this.assessmentTargetSearchInfo
          .coordinationDepartment,
        statusType: "0,10,20",
        source: 1
      };
      let page = this.assessmentTargetPage.page;
      let size = (this.assessmentTargetPage.size = val);
      assessmentTargetList(data, page, size).then(res => {
        this.assessmentTargetTable = res.data.list;
        this.assessmentTargetPage.total = res.data.total;
        this.loading = false;
      });
    },
    //考核目标分页
    assessmentTargetCurrentChange(val) {
      this.loading = true;
      let data = {
        bizRespResponsibilityId: this.$route.query.id,
        year: this.peopleform.peopleYear,
        leadDepartment: this.assessmentTargetSearchInfo.leadDepartment,
        coordinationDepartment: this.assessmentTargetSearchInfo
          .coordinationDepartment,
        //"statusType": '0,10,20',
        statusType: this.reportProgressSearchInfo.statusType,
        source: 1
      };
      let page = val;
      let size = this.assessmentTargetPage.size;
      assessmentTargetList(data, page, size).then(res => {
        this.assessmentTargetTable = res.data.list;
        this.assessmentTargetPage.total = res.data.total;
        this.loading = false;
      });
    },
    uploadFile(item) {
      this.excelData.year = this.peopleform.peopleYear;
      this.excelData.responsibilityId = this.ruleTime.ids;
      const formData = new FormData();
      formData.append("file", item.raw);
      uploadExcelFile(this.excelData, formData).then(res => {
        // console.log("res", res);
        if (res.infoCode == 200) {
          // this.$message({
          //   message: "上传成功",
          //   type: "success",
          //   duration: 2000
          // });
          this.getYearTime(this.$route.query.year, this.$route.query.id);
        } else {
          this.$message({
            message: res.msg,
            type: "error"
          });
        }
      });
    },
    //获取年份填报日期
    getYearTime(year, id) {
      this.showAssessmentTargetMessage = "";
      findYear(year, id).then(res => {
        if (res.data) {
          let selfEvaluation = [];
          let examination = [];
          selfEvaluation.push(res.data.selfEvaluationStartTime);
          selfEvaluation.push(res.data.selfEvaluationEndTime);
          examination.push(res.data.examinationStartTime);
          examination.push(res.data.examinationEndTime);
          this.ruleTime.value6 = selfEvaluation;
          this.ruleTime.value7 = examination;
          this.ruleTime.ids = res.data.ids;
          this.ruleTime.totalScore = res.data.totalScore;
        } else {
          this.activeName = "first";
          this.ruleTime = {
            value6: [],
            value7: [],
            totalScore: ""
          };
          this.startInfo = true;
          this.$message({
            message: "请填写填报日期！",
            type: "warning"
          });
        }

        // this.getExaminationContentInfo();
        // this.getAssessmentMattersInfo();
        // this.getAssessmentIndexInfo();
        this.getAssessmentTargetInfo();
        // this.showAssessmentTargetedit(this.ruleTime.ids);
        // this.assessmentTargetedit("0");
      });
    },
    //根据填报设置id查询 查询 编辑完成按钮和重新编按钮 显示 那一个
    showAssessmentTargetedit(responsibilityId) {
      let data = {
        responsibilityId: responsibilityId
      };
      getIfShowButtonTask(data).then(res => {
        if (res.infoCode == 200) {
          //状态为: 编缉中
          if (res.data == 0) {
            //填报设置总分  显示
            this.showButtonTBSZZF = false;
            //发布  隐藏
            this.showButtonFB = true;
          }
          //状态为：可发布
          if (res.data == 2) {
            //填报设置总分  隐藏
            this.showButtonTBSZZF = true;
            //发布  显示
            this.showButtonFB = false;
          }

          //已发布
          if (res.data == 3) {
            //填报设置总分  隐藏
            this.showButtonTBSZZF = true;
            //发布  显示
            this.showButtonFB = true;
            this.showExcelUpload = true;
          }

          //没有添加评分标准 数据
          if (res.data == 4) {
            //填报设置总分  显示
            this.showButtonTBSZZF = false;
            //发布  隐藏
            this.showButtonFB = true;

            this.showExcelUpload = false;
          }
        }
      });
    },
    //评分标准 编辑完成
    assessmentTargetedit(status) {
      let data = {
        status: status,
        responsibilityId: this.ruleTime.ids
      };
      assessmentTargetrRelease(data).then(res => {
        if (res.infoCode == 200) {
          this.getAssessmentTargetInfo();
          //显示按钮
          // this.showAssessmentTargetedit(this.ruleTime.ids);
          this.showAssessmentTargetMessage = null;
        } else {
          this.showAssessmentTargetMessage = res.msg;
        }
      });
    }
  },
  created() {
    this.getData();
    this.peopleform.peopleYear = this.$route.query.year;
    this.getYearTime(this.$route.query.year, this.$route.query.id);
    let isDisabled = this.$route.query.isDisabled;
    //查询
    if (isDisabled == 1) {
      this.isdisabled = true;
    }
    //编辑
    if (isDisabled == 2) {
      this.isdisabled = false;
    }

    this.getAssessmentTargetInfo();
    //自评部门
    assessmentTargetDeptName(1).then(res => {
      this.assessmentTargetDeptName1 = res.data;
    });
    //牵头部门 、 配合部门
    assessmentTargetDeptName(0).then(res => {
      this.assessmentTargetDeptName2 = res.data;
    });
  }
};
</script>
<style lang="scss">
  // .el-tooltip__popper {
  //   max-width: 85%;
  // }
.managementEditPage {
  //解决下拉选项内容过长问题
  .el-select-dropdown{
    // max-width: 243px;
    // min-width: 450px !important;
    max-width: 800px;
  }
  .el-select-dropdown__item{
      // display: inline-block;
      text-overflow: unset;
      overflow:unset;
  }
  .el-select-dropdown__item span {
      // min-width: 205px;
      // display: inline-block;
      padding-right: 20px;
  }
  .tit {
    text-align: center;
    margin-bottom: 32px;
  }
  .el-select {
    width: 100%;
  }
  .taskDialog .el-dialog--center .el-dialog__body {
    padding-bottom: 0px;
  }
  .curStyle {
    margin-bottom: 0;
  }
  .lastDialog.el-form-item{
    position: relative;
    .el-form-item__content{
      line-height: 0px;
    }
    .el-form-item__label{
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      line-height: 18px;
    }
  }
  .el-button--danger {
    height: 34px;
    padding: 0px 10px;
    border: none;
  }
  .el-scrollbar__wrap {
    overflow-x: visible;
  }
  // .el-scrollbar {
  //   min-height: 46px;
  //   height: auto;
  // }
  .el-select-dropdown__wrap.el-scrollbar__wrap{
    margin-bottom: 0px !important;
  }
  .el-scrollbar__bar.is-horizontal{
    display: none;
  }
  // .dialogSel{
  //   ::-webkit-scrollbar {
  //     background-color: rgba(144,147,153,.3);
  //     height: 6px;
  //     width: 10px;
  //     border-radius: 4px;
  //   }
  //   ::-webkit-scrollbar:hover{
  //     background-color: rgba(144,147,153,.5);
  //   }
  // }
}
</style>
